Skip to content

Commit c7325dc

Browse files
committed
Return the list of modified ports
1 parent 47cce29 commit c7325dc

File tree

2 files changed

+3
-18
lines changed

2 files changed

+3
-18
lines changed

seriallist_darwin.go

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@ 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-
3835
// how many lines is the output? boards attached = lines/8
3936
for i := 0; i < len(cmdOutSlice)/8; i++ {
4037

@@ -62,22 +59,17 @@ func removeNonArduinoBoards(ports []OsSerialPort) []OsSerialPort {
6259
if !strings.Contains(port.Name, "/cu") {
6360
port.RelatedNames = append(port.RelatedNames, archBoardName)
6461
port.FriendlyName = strings.Trim(boardName, "\n")
65-
arduino_ports = append(arduino_ports, port)
66-
} else {
67-
other_ports = append(other_ports, port)
6862
}
6963
}
7064
}
7165
}
7266

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

80-
return arduino_ports
72+
return ports
8173
}
8274

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

seriallist_linux.go

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

42-
var arduino_ports, other_ports []OsSerialPort
43-
4442
for _, element := range cmdOutSlice {
4543

4644
if element == "" {
@@ -60,16 +58,11 @@ func removeNonArduinoBoards(ports []OsSerialPort) []OsSerialPort {
6058
if strings.Contains(element, strings.Trim(cmdOutput2S, "\n")) && cmdOutput2S != "" {
6159
port.RelatedNames = append(port.RelatedNames, archBoardName)
6260
port.FriendlyName = strings.Trim(boardName, "\n")
63-
arduino_ports = append(arduino_ports, port)
64-
} else {
65-
other_ports = append(other_ports, port)
6661
}
6762
}
6863
}
6964

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

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

0 commit comments

Comments
 (0)