plesty.lib.traffic.serial_ports
Explain why a serial port refused to open.
pyserial reports every open failure as SerialException, and the two that
matter most look alike in a log line: a port that does not exist and a port
that exists but is held. The second one costs sessions — the user re-checks
drivers and port names while Thorlabs Kinesis, a serial terminal, or a stray
interpreter still owns the device.
Attributes
Functions
|
Return the OS error number behind a serial open failure, if any. |
|
Return |
|
Return one sentence of guidance for a serial open failure, or |
Module Contents
- plesty.lib.traffic.serial_ports._WINDOWS_OSERROR
- plesty.lib.traffic.serial_ports._HELD_HINT = 'The port exists but is open in another process. Close Thorlabs Kinesis/APT (a loaded stage...
- plesty.lib.traffic.serial_ports._DIALOUT_HINT = 'Not permitted to open the port. Add the user to the serial group (`sudo usermod -aG dialout...
- plesty.lib.traffic.serial_ports._open_errno(exc: BaseException) int | None
Return the OS error number behind a serial open failure, if any.
- Parameters:
exc (BaseException)
- Return type:
int | None
- plesty.lib.traffic.serial_ports.describe_port(port: str) str
Return
device: description, hwidfor port, or""when unlisted.- Parameters:
port (str) – A port name as passed to
serial.Serial.- Return type:
str
- plesty.lib.traffic.serial_ports.explain_serial_open_error(exc: BaseException, port: str, platform: str | None = None) str | None
Return one sentence of guidance for a serial open failure, or
None.Only EACCES and EBUSY are explained — they are the two a user cannot tell apart from a wrong port name, and the two whose remedy is not on the device side. Everything else (
ENOENT, timeouts) is left to speak for itself.- Parameters:
exc (BaseException) – The exception
serial.Serialraised.port (str) – The port that was being opened, for the
list_portsline.platform (str | None) –
sys.platformoverride for tests;Nonereads it.
- Return type:
str | None