You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// discoverLoop periodically update the list of ports found
151
152
funcdiscoverLoop() {
152
-
SerialPorts.Mu.Lock()
153
-
SerialPorts.Network=false
154
-
SerialPorts.Ports=make([]SpPortItem, 0)
155
-
SerialPorts.Mu.Unlock()
156
-
NetworkPorts.Mu.Lock()
157
-
NetworkPorts.Network=true
158
-
NetworkPorts.Ports=make([]SpPortItem, 0)
159
-
NetworkPorts.Mu.Unlock()
153
+
serialPorts.Mu.Lock()
154
+
serialPorts.Network=false
155
+
serialPorts.Ports=make([]SpPortItem, 0)
156
+
serialPorts.Mu.Unlock()
157
+
networkPorts.Mu.Lock()
158
+
networkPorts.Network=true
159
+
networkPorts.Ports=make([]SpPortItem, 0)
160
+
networkPorts.Mu.Unlock()
160
161
161
162
gofunc() {
162
163
for {
163
164
if!upload.Busy {
164
-
spListDual(false)
165
+
updateSerialPortList()
165
166
}
166
167
time.Sleep(2*time.Second)
167
168
}
168
169
}()
169
170
gofunc() {
170
171
for {
171
-
spListDual(true)
172
+
updateNetworkPortList()
172
173
time.Sleep(2*time.Second)
173
174
}
174
175
}()
175
176
}
176
177
177
-
funcspListDual(networkbool) {
178
-
179
-
// call our os specific implementation of getting the serial list
180
-
list, err:=GetList(network)
181
-
182
-
//log.Println(list)
183
-
//log.Println(err)
184
-
178
+
funcupdateSerialPortList() {
179
+
ports, err:=enumerateSerialPorts()
185
180
iferr!=nil {
186
-
// avoid reporting dummy data if an error occurred
181
+
// REPORT
182
+
fmt.Println("GET SERIAL LIST ERROR:", err)
187
183
return
188
184
}
185
+
list:=spListDual(ports)
186
+
serialPorts.Mu.Lock()
187
+
serialPorts.Ports=list
188
+
serialPorts.Mu.Unlock()
189
+
}
189
190
190
-
// do a quick loop to see if any of our open ports
191
-
// did not end up in the list port list. this can
192
-
// happen on windows in a fallback scenario where an
193
-
// open port can't be identified because it is locked,
194
-
// so just solve that by manually inserting
195
-
// if network {
196
-
// for port := range sh.ports {
197
-
198
-
// isFound := false
199
-
// for _, item := range list {
200
-
// if strings.ToLower(port.portConf.Name) == strings.ToLower(item.Name) {
201
-
// isFound = true
202
-
// }
203
-
// }
204
-
205
-
// if !isFound {
206
-
// // artificially push to front of port list
207
-
// log.Println(fmt.Sprintf("Did not find an open port in the serial port list. We are going to artificially push it onto the list. port:%v", port.portConf.Name))
0 commit comments