diff --git a/seriallist_darwin.go b/seriallist_darwin.go index a85164da1..9d367ff70 100644 --- a/seriallist_darwin.go +++ b/seriallist_darwin.go @@ -32,6 +32,9 @@ func removeNonArduinoBoards(ports []OsSerialPort) []OsSerialPort { //log.Println(string(cmdOutput)) cmdOutSlice := strings.Split(string(cmdOutput), "\n") + var arduino_ports []OsSerialPort + var other_ports []OsSerialPort + // how many lines is the output? boards attached = lines/8 for i := 0; i < len(cmdOutSlice)/8; i++ { @@ -59,17 +62,22 @@ func removeNonArduinoBoards(ports []OsSerialPort) []OsSerialPort { if !strings.Contains(port.Name, "/cu") { port.RelatedNames = append(port.RelatedNames, archBoardName) port.FriendlyName = strings.Trim(boardName, "\n") + arduino_ports = append(arduino_ports, port) + } else { + other_ports = append(other_ports, port) } } } } + arduino_ports = append(arduino_ports, other_ports...) + // additional remove phase - ports = Filter(ports, func(port OsSerialPort) bool { + arduino_ports = Filter(arduino_ports, func(port OsSerialPort) bool { return !strings.Contains(port.Name, "Blue") && !strings.Contains(port.Name, "/cu") }) - return ports + return arduino_ports } func getList() ([]OsSerialPort, os.SyscallError) { diff --git a/seriallist_linux.go b/seriallist_linux.go index d389803d4..26cc3d3b4 100755 --- a/seriallist_linux.go +++ b/seriallist_linux.go @@ -39,6 +39,8 @@ func removeNonArduinoBoards(ports []OsSerialPort) []OsSerialPort { cmdOutSlice = append(cmdOutSlice, re.FindString(element)) } + var arduino_ports, other_ports []OsSerialPort + for _, element := range cmdOutSlice { if element == "" { @@ -58,11 +60,16 @@ func removeNonArduinoBoards(ports []OsSerialPort) []OsSerialPort { if strings.Contains(element, strings.Trim(cmdOutput2S, "\n")) && cmdOutput2S != "" { port.RelatedNames = append(port.RelatedNames, archBoardName) port.FriendlyName = strings.Trim(boardName, "\n") + arduino_ports = append(arduino_ports, port) + } else { + other_ports = append(other_ports, port) } } } - return ports + arduino_ports = append(arduino_ports, other_ports...) + + return arduino_ports } func getList() ([]OsSerialPort, os.SyscallError) {