Skip to content

Commit 1e12a53

Browse files
author
Alice Pintus
committed
Merge pull request #10 from arduino/revert-9-fix_non_arduino_boards
Revert "Fix bug about non arduino boards not showing up"
2 parents e18a5ba + 6fb49f7 commit 1e12a53

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

seriallist_darwin.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ func removeNonArduinoBoards(ports []OsSerialPort) []OsSerialPort {
3232
//log.Println(string(cmdOutput))
3333
cmdOutSlice := strings.Split(string(cmdOutput), "\n")
3434

35+
var arduino_ports []OsSerialPort
36+
var other_ports []OsSerialPort
37+
3538
// how many lines is the output? boards attached = lines/8
3639
for i := 0; i < len(cmdOutSlice)/8; i++ {
3740

@@ -59,17 +62,22 @@ func removeNonArduinoBoards(ports []OsSerialPort) []OsSerialPort {
5962
if !strings.Contains(port.Name, "/cu") {
6063
port.RelatedNames = append(port.RelatedNames, archBoardName)
6164
port.FriendlyName = strings.Trim(boardName, "\n")
65+
arduino_ports = append(arduino_ports, port)
66+
} else {
67+
other_ports = append(other_ports, port)
6268
}
6369
}
6470
}
6571
}
6672

73+
arduino_ports = append(arduino_ports, other_ports...)
74+
6775
// additional remove phase
68-
ports = Filter(ports, func(port OsSerialPort) bool {
76+
arduino_ports = Filter(arduino_ports, func(port OsSerialPort) bool {
6977
return !strings.Contains(port.Name, "Blue") && !strings.Contains(port.Name, "/cu")
7078
})
7179

72-
return ports
80+
return arduino_ports
7381
}
7482

7583
func getList() ([]OsSerialPort, os.SyscallError) {

seriallist_linux.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ func removeNonArduinoBoards(ports []OsSerialPort) []OsSerialPort {
3939
cmdOutSlice = append(cmdOutSlice, re.FindString(element))
4040
}
4141

42+
var arduino_ports, other_ports []OsSerialPort
43+
4244
for _, element := range cmdOutSlice {
4345

4446
if element == "" {
@@ -58,11 +60,16 @@ func removeNonArduinoBoards(ports []OsSerialPort) []OsSerialPort {
5860
if strings.Contains(element, strings.Trim(cmdOutput2S, "\n")) && cmdOutput2S != "" {
5961
port.RelatedNames = append(port.RelatedNames, archBoardName)
6062
port.FriendlyName = strings.Trim(boardName, "\n")
63+
arduino_ports = append(arduino_ports, port)
64+
} else {
65+
other_ports = append(other_ports, port)
6166
}
6267
}
6368
}
6469

65-
return ports
70+
arduino_ports = append(arduino_ports, other_ports...)
71+
72+
return arduino_ports
6673
}
6774

6875
func getList() ([]OsSerialPort, os.SyscallError) {

0 commit comments

Comments
 (0)