A simple Python module to list serial ports on Windows, Linux, and macOS.
This is a modified version of serial.tools.list_ports from
pySerial with the goal of integrating some fixes and
improvements to the original list_ports functionality with a faster release cycle.
pip install lsportsThe module provides a single function comports that returns a list of PortInfo objects.
Each PortInfo object contains information about a connected serial port.
from lsports import comports
for port in comports():
print(port.device, port.product, port.hwid)For a full list of available attributes, see the PortInfo class. Only comports and PortInfo
are considered public API.
- The information class name is
PortInfoinstead ofListPortInfo. - On Linux, the objects returned by
comports()are now instances ofPortInfo, the same as other operating systems. Previously, Linux returned a subclassSysFSinstead. - On windows, the "Bus Reported Device Name" is used as the
productattribute which was not previously used. This brings the Windows implementation closer to the POSIX ones. - On Windows, increase the location path buffer size to 500 characters to support longer paths.
- On MacOS, the internal functions have been changed to use
bytesinstead ofstras the project only supports python3.