@@ -998,7 +998,8 @@ func getDefaultPort(portFlag string, usbInterfaces []string) (port string, err e
998
998
preferredPortIDs = append (preferredPortIDs , [2 ]uint16 {uint16 (vid ), uint16 (pid )})
999
999
}
1000
1000
1001
- var primaryPorts []string // ports picked from preferred USB VID/PID
1001
+ var primaryPorts []string // ports picked from preferred USB VID/PID
1002
+ var secondaryPorts []string // other ports (as a fallback)
1002
1003
for _ , p := range portsList {
1003
1004
if ! p .IsUSB {
1004
1005
continue
@@ -1020,6 +1021,8 @@ func getDefaultPort(portFlag string, usbInterfaces []string) (port string, err e
1020
1021
continue
1021
1022
}
1022
1023
}
1024
+
1025
+ secondaryPorts = append (secondaryPorts , p .Name )
1023
1026
}
1024
1027
if len (primaryPorts ) == 1 {
1025
1028
// There is exactly one match in the set of preferred ports. Use
@@ -1031,18 +1034,10 @@ func getDefaultPort(portFlag string, usbInterfaces []string) (port string, err e
1031
1034
// one device of the same type are connected (e.g. two Arduino
1032
1035
// Unos).
1033
1036
ports = primaryPorts
1034
- }
1035
-
1036
- if len (ports ) == 0 {
1037
- // fallback
1038
- switch runtime .GOOS {
1039
- case "darwin" :
1040
- ports , err = filepath .Glob ("/dev/cu.usb*" )
1041
- case "linux" :
1042
- ports , err = filepath .Glob ("/dev/ttyACM*" )
1043
- case "windows" :
1044
- ports , err = serial .GetPortsList ()
1045
- }
1037
+ } else {
1038
+ // No preferred ports found. Fall back to other serial ports
1039
+ // available in the system.
1040
+ ports = secondaryPorts
1046
1041
}
1047
1042
default :
1048
1043
return "" , errors .New ("unable to search for a default USB device to be flashed on this OS" )
0 commit comments