summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--documentation/pyserial_api.rst4
-rw-r--r--serial/tools/list_ports_linux.py17
-rw-r--r--serial/tools/list_ports_posix.py32
3 files changed, 27 insertions, 26 deletions
diff --git a/documentation/pyserial_api.rst b/documentation/pyserial_api.rst
index 12a7765..2503ec5 100644
--- a/documentation/pyserial_api.rst
+++ b/documentation/pyserial_api.rst
@@ -150,7 +150,7 @@ Native ports
:rtype: bytes
Read *size* bytes from the serial port. If a timeout is set it may
- return less characters as requested. With no timeout it will block
+ return fewer characters than requested. With no timeout it will block
until the requested number of bytes is read.
.. versionchanged:: 2.5
@@ -166,7 +166,7 @@ Native ports
Read until an expected sequence is found ('\\n' by default), the size
is exceeded or until timeout occurs. If a timeout is set it may
- return less characters as requested. With no timeout it will block
+ return fewer characters than requested. With no timeout it will block
until the requested number of bytes is read.
.. versionchanged:: 2.5
diff --git a/serial/tools/list_ports_linux.py b/serial/tools/list_ports_linux.py
index c8c1cfc..ec2e0ca 100644
--- a/serial/tools/list_ports_linux.py
+++ b/serial/tools/list_ports_linux.py
@@ -89,15 +89,16 @@ class SysFS(list_ports_common.ListPortInfo):
def comports(include_links=False):
- devices = glob.glob('/dev/ttyS*') # built-in serial ports
- devices.extend(glob.glob('/dev/ttyUSB*')) # usb-serial with own driver
- devices.extend(glob.glob('/dev/ttyXRUSB*')) # xr-usb-serial port exar (DELL Edge 3001)
- devices.extend(glob.glob('/dev/ttyACM*')) # usb-serial with CDC-ACM profile
- devices.extend(glob.glob('/dev/ttyAMA*')) # ARM internal port (raspi)
- devices.extend(glob.glob('/dev/rfcomm*')) # BT serial devices
- devices.extend(glob.glob('/dev/ttyAP*')) # Advantech multi-port serial controllers
+ devices = set()
+ devices.update(glob.glob('/dev/ttyS*')) # built-in serial ports
+ devices.update(glob.glob('/dev/ttyUSB*')) # usb-serial with own driver
+ devices.update(glob.glob('/dev/ttyXRUSB*')) # xr-usb-serial port exar (DELL Edge 3001)
+ devices.update(glob.glob('/dev/ttyACM*')) # usb-serial with CDC-ACM profile
+ devices.update(glob.glob('/dev/ttyAMA*')) # ARM internal port (raspi)
+ devices.update(glob.glob('/dev/rfcomm*')) # BT serial devices
+ devices.update(glob.glob('/dev/ttyAP*')) # Advantech multi-port serial controllers
if include_links:
- devices.extend(list_ports_common.list_links(devices))
+ devices.update(list_ports_common.list_links(devices))
return [info
for info in [SysFS(d) for d in devices]
if info.subsystem != "platform"] # hide non-present internal serial ports
diff --git a/serial/tools/list_ports_posix.py b/serial/tools/list_ports_posix.py
index 79bc8ed..b115754 100644
--- a/serial/tools/list_ports_posix.py
+++ b/serial/tools/list_ports_posix.py
@@ -37,63 +37,63 @@ elif plat == 'cygwin': # cygwin/win32
# (such as 'open' call, explicit 'ls'), but 'glob.glob'
# and bare 'ls' do not; so use /dev/ttyS* instead
def comports(include_links=False):
- devices = glob.glob('/dev/ttyS*')
+ devices = set(glob.glob('/dev/ttyS*'))
if include_links:
- devices.extend(list_ports_common.list_links(devices))
+ devices.update(list_ports_common.list_links(devices))
return [list_ports_common.ListPortInfo(d) for d in devices]
elif plat[:7] == 'openbsd': # OpenBSD
def comports(include_links=False):
- devices = glob.glob('/dev/cua*')
+ devices = set(glob.glob('/dev/cua*'))
if include_links:
- devices.extend(list_ports_common.list_links(devices))
+ devices.update(list_ports_common.list_links(devices))
return [list_ports_common.ListPortInfo(d) for d in devices]
elif plat[:3] == 'bsd' or plat[:7] == 'freebsd':
def comports(include_links=False):
- devices = glob.glob('/dev/cua*[!.init][!.lock]')
+ devices = set(glob.glob('/dev/cua*[!.init][!.lock]'))
if include_links:
- devices.extend(list_ports_common.list_links(devices))
+ devices.update(list_ports_common.list_links(devices))
return [list_ports_common.ListPortInfo(d) for d in devices]
elif plat[:6] == 'netbsd': # NetBSD
def comports(include_links=False):
"""scan for available ports. return a list of device names."""
- devices = glob.glob('/dev/dty*')
+ devices = set(glob.glob('/dev/dty*'))
if include_links:
- devices.extend(list_ports_common.list_links(devices))
+ devices.update(list_ports_common.list_links(devices))
return [list_ports_common.ListPortInfo(d) for d in devices]
elif plat[:4] == 'irix': # IRIX
def comports(include_links=False):
"""scan for available ports. return a list of device names."""
- devices = glob.glob('/dev/ttyf*')
+ devices = set(glob.glob('/dev/ttyf*'))
if include_links:
- devices.extend(list_ports_common.list_links(devices))
+ devices.update(list_ports_common.list_links(devices))
return [list_ports_common.ListPortInfo(d) for d in devices]
elif plat[:2] == 'hp': # HP-UX (not tested)
def comports(include_links=False):
"""scan for available ports. return a list of device names."""
- devices = glob.glob('/dev/tty*p0')
+ devices = set(glob.glob('/dev/tty*p0'))
if include_links:
- devices.extend(list_ports_common.list_links(devices))
+ devices.update(list_ports_common.list_links(devices))
return [list_ports_common.ListPortInfo(d) for d in devices]
elif plat[:5] == 'sunos': # Solaris/SunOS
def comports(include_links=False):
"""scan for available ports. return a list of device names."""
- devices = glob.glob('/dev/tty*c')
+ devices = set(glob.glob('/dev/tty*c'))
if include_links:
- devices.extend(list_ports_common.list_links(devices))
+ devices.update(list_ports_common.list_links(devices))
return [list_ports_common.ListPortInfo(d) for d in devices]
elif plat[:3] == 'aix': # AIX
def comports(include_links=False):
"""scan for available ports. return a list of device names."""
- devices = glob.glob('/dev/tty*')
+ devices = set(glob.glob('/dev/tty*'))
if include_links:
- devices.extend(list_ports_common.list_links(devices))
+ devices.update(list_ports_common.list_links(devices))
return [list_ports_common.ListPortInfo(d) for d in devices]
else: