main: restore support for flashing Espressif chips
This reverts commit 303410d3fc
and also
removes the unnecessary fallback.
Этот коммит содержится в:
родитель
7513fa2c96
коммит
5a92c35536
1 изменённых файлов: 8 добавлений и 13 удалений
19
main.go
19
main.go
|
@ -999,6 +999,7 @@ func getDefaultPort(portFlag string, usbInterfaces []string) (port string, err e
|
|||
}
|
||||
|
||||
var primaryPorts []string // ports picked from preferred USB VID/PID
|
||||
var secondaryPorts []string // other ports (as a fallback)
|
||||
for _, p := range portsList {
|
||||
if !p.IsUSB {
|
||||
continue
|
||||
|
@ -1020,6 +1021,8 @@ func getDefaultPort(portFlag string, usbInterfaces []string) (port string, err e
|
|||
continue
|
||||
}
|
||||
}
|
||||
|
||||
secondaryPorts = append(secondaryPorts, p.Name)
|
||||
}
|
||||
if len(primaryPorts) == 1 {
|
||||
// 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
|
|||
// one device of the same type are connected (e.g. two Arduino
|
||||
// Unos).
|
||||
ports = primaryPorts
|
||||
}
|
||||
|
||||
if len(ports) == 0 {
|
||||
// fallback
|
||||
switch runtime.GOOS {
|
||||
case "darwin":
|
||||
ports, err = filepath.Glob("/dev/cu.usb*")
|
||||
case "linux":
|
||||
ports, err = filepath.Glob("/dev/ttyACM*")
|
||||
case "windows":
|
||||
ports, err = serial.GetPortsList()
|
||||
}
|
||||
} else {
|
||||
// No preferred ports found. Fall back to other serial ports
|
||||
// available in the system.
|
||||
ports = secondaryPorts
|
||||
}
|
||||
default:
|
||||
return "", errors.New("unable to search for a default USB device to be flashed on this OS")
|
||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче