From b27526b25dd7475befcca1f2f6b89403a649b447 Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Fri, 18 Feb 2022 11:45:32 +0100 Subject: [PATCH] Skip enumerating ports that are not accessible for any reason Otherwise ports like /dev/ttyS0 may be listed in case of "access denied" errors. --- serial_unix.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/serial_unix.go b/serial_unix.go index 541660c..3508796 100644 --- a/serial_unix.go +++ b/serial_unix.go @@ -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 - } + continue } else { port.Close() }