Skip enumerating ports that are not accessible for any reason

Otherwise ports like /dev/ttyS0 may be listed in case of "access
denied" errors.
This commit is contained in:
Cristian Maglie
2022-02-18 11:45:32 +01:00
parent f344e5f764
commit b27526b25d

View File

@@ -286,10 +286,7 @@ func nativeGetPortsList() ([]string, error) {
if strings.HasPrefix(f.Name(), "ttyS") {
port, err := nativeOpen(portName, &Mode{})
if err != nil {
serr, ok := err.(*PortError)
if ok && serr.Code() == InvalidSerialPort {
continue
}
} else {
port.Close()
}