Serialenum is a simple utility to correctly enumerate all available and present serial ports on a given system. There are a number of ways to enumerate serial ports, but they are platform-specific and vary in effectiveness. Serialenum attempts to provide the best possible methods for each supported platform.
pip install serialenum
import serialenum
serialenum.enumerate()
The enumerate method will return a list of serial ports or a blank list, if
none are found. If serial ports could not be enumerated, it will return None.
- Windows XP or later
- Recent Linux 2.6+ kernels
The Windows implementation iterates over a registry key to ensure that usb-to-serial converters and oddly-named COM ports are discovered. This should work correctly on any modern version of Windows.
The Linux implementation uses /dev/serial to enumerate attached serialenum
port devices. This avoids the fake ttyS devices typically present and also
accounts for usb-to-serial converters.
- Add fallback support for older Linux systems
- Add support for more operating systems (testing help needed)