serial_transport.py
pyserial adapter and privacy-safe serial-port identity helpers.
Overview
pyserial adapter and privacy-safe serial-port identity helpers.
depends on serial.ts · used by __init__.py agent.py cli.py
API
Cclass SerialTransportError(RuntimeError)
A serial transport error that never includes a device path or USB serial.
PySerialConnection.close, _import_serial, open_serial_connection, resolve_serial_portCclass SerialPort
One discoverable serial port with a non-reversible stable identity.
discover_serial_portsF_import_serial() -> Any
Import pyserial (serial, list_ports); raise SerialTransportError if not installed.
discover_serial_ports, open_serial_connection · calls SerialTransportErrorFserial_identity(*, vid: Optional[int], pid: Optional[int], serial_number: Optional[str], interface: Optional[str], device: Optional[str]=None) -> Optional[str]
Hash one USB console endpoint without retaining serial or path text.
Some macOS J-Link drivers omit the CDC interface name. In that case, include the currently assigned endpoint name so two console endpoints cannot collapse into one identity and silently select the wrong one. A later rename fails closed and requires reconfiguration rather than guessing.
discover_serial_portsFdiscover_serial_ports(ports: Optional[Iterable[Any]]=None) -> tuple[SerialPort, ...]
List ports without exposing their paths or USB serials in diagnostics.
resolve_serial_port · calls SerialPort, _import_serial, serial_identityFresolve_serial_port(serial_port: str, serial_identity_value: Optional[str], *, ports: Optional[Iterable[SerialPort]]=None) -> str
Resolve an explicit path or one unambiguous privacy-safe USB identity.
SerialTransportError, discover_serial_portsCclass PySerialConnection
Async wrapper around one opened pyserial connection.
open_serial_connectionFPySerialConnection.__init__(self, connection: Any) -> None
Initialize a serial connection wrapper around an open pyserial port object.
FPySerialConnection.readline(self) -> bytes
Wait for a line without blocking the caller's asyncio event loop.
FPySerialConnection.write(self, data: bytes) -> None
Write a bounded command without blocking the asyncio event loop.
FPySerialConnection.close(self) -> None
Release the serial port and unblock any pending read.
SerialTransportErrorFopen_serial_connection(serial_port: str, baud: int, *, serial_factory: Optional[Callable[..., Any]]=None) -> PySerialConnection
Open one serial port with finite read and write timeouts.
PySerialConnection, SerialTransportError, _import_serial