Skip to content

Commit 5bfc8fd

Browse files
committed
always trust the programming port
bonjour could take a lot to discover a network port, so trust its source at programming time Former-commit-id: 7fed55b9a1e60ddd828e7db7c6277a4c95d2d36f [formerly 3703076d971f4d8a7fdaddd1f2e5a2fa88441326] Former-commit-id: 2ccd08b56a568ef20747d25da2e65d0f699d47cd
1 parent 4c257d3 commit 5bfc8fd

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

programmer.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,10 @@ func spProgramRW(portname string, boardname string, boardname_rewrite string, fi
150150

151151
// check if the port is physical or network
152152
var networkPort bool
153-
myport, exist := findPortByNameRerun(portname)
153+
myport, exist := findPortByNameRerun(portname, false)
154154
if !exist {
155-
spErr("Could not find the port " + portname + " that you were trying to open.")
156-
return
155+
// it could be a network port that has not been found at the second lap
156+
networkPort = true
157157
} else {
158158
networkPort = myport.NetworkPort
159159
}

serial.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ func writeToChannels(cmds []string, idArr []string, bufTypeArr []string) {
417417
func spList() {
418418

419419
// call our os specific implementation of getting the serial list
420-
list, _ := GetList()
420+
list, _ := GetList(true)
421421

422422
// do a quick loop to see if any of our open ports
423423
// did not end up in the list port list. this can
@@ -476,7 +476,7 @@ func spList() {
476476
Baud: 0,
477477
BufferAlgorithm: "",
478478
AvailableBufferAlgorithms: availableBufferAlgorithms,
479-
Ver: versionFloat,
479+
Ver: versionFloat,
480480
NetworkPort: item.NetworkPort,
481481
}
482482

@@ -653,9 +653,9 @@ func findPortByName(portname string) (*serport, bool) {
653653
return nil, false
654654
}
655655

656-
func findPortByNameRerun(portname string) (OsSerialPort, bool) {
656+
func findPortByNameRerun(portname string, network bool) (OsSerialPort, bool) {
657657
portnamel := strings.ToLower(portname)
658-
list, _ := GetList()
658+
list, _ := GetList(network)
659659
for _, item := range list {
660660
if strings.ToLower(item.Name) == portnamel {
661661
return item, true

seriallist.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ type OsSerialPort struct {
2222
NetworkPort bool
2323
}
2424

25-
func GetList() ([]OsSerialPort, error) {
25+
func GetList(network bool) ([]OsSerialPort, error) {
2626

2727
//log.Println("Doing GetList()")
2828

@@ -56,8 +56,10 @@ func GetList() ([]OsSerialPort, error) {
5656

5757
arrPorts = removeNonArduinoBoards(arrPorts)
5858

59-
netportList, _ := GetNetworkList()
60-
arrPorts = append(arrPorts, netportList...)
59+
if network {
60+
netportList, _ := GetNetworkList()
61+
arrPorts = append(arrPorts, netportList...)
62+
}
6163

6264
//log.Printf("Done doing GetList(). arrPorts:%v\n", arrPorts)
6365

0 commit comments

Comments
 (0)