navigate.model.devices.MonitoredSerial
- class navigate.model.devices.MonitoredSerial(*args, **kwargs)
Bases:
SerialMonitoredSerial - Serial class that logs read/write events.
- __init__(*args, **kwargs)
Initialize comm port object. If a “port” is given, then the port will be opened immediately. Otherwise a Serial port object in closed state is returned.
Methods
__init__(*args, **kwargs)Initialize comm port object.
log_event(payload, duration_ns)Log the read/write event with performance data.
read([size])Read bytes from the serial port and log the event.
readline([size])Read a line from the serial port and log the event.
write(data)Write data to the serial port and log the event.
Attributes
- log_event(payload: bytes, duration_ns: int) → None
Log the read/write event with performance data.
- Parameters:
payload (bytes) – The data that was read or written.
duration_ns (int) – The duration of the read/write operation in nanoseconds.
- read(size=1) → bytes
Read bytes from the serial port and log the event.
- Parameters:
size (int, optional) – The number of bytes to read, by default 1.
- Returns:
The bytes read from the serial port.
- Return type:
bytes
- readline(size: Optional[int] = -1, /) → bytes
Read a line from the serial port and log the event.
- Parameters:
size (int, optional) – The maximum number of bytes to read, by default -1 (read until timeout).
- Returns:
The line read from the serial port.
- Return type:
bytes
- write(data: bytes)
Write data to the serial port and log the event.
- Parameters:
data (bytes) – Data to be written to the serial port.
- BAUDRATES = (50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800, 9600, 19200, 38400, 57600, 115200, 230400, 460800, 500000, 576000, 921600, 1000000, 1152000, 1500000, 2000000, 2500000, 3000000, 3500000, 4000000)
- BAUDRATE_CONSTANTS = {0: 0, 50: 1, 75: 2, 110: 3, 134: 4, 150: 5, 200: 6, 300: 7, 600: 8, 1200: 9, 1800: 10, 2400: 11, 4800: 12, 9600: 13, 19200: 14, 38400: 15, 57600: 4097, 115200: 4098, 230400: 4099, 460800: 4100, 500000: 4101, 576000: 4102, 921600: 4103, 1000000: 4104, 1152000: 4105, 1500000: 4106, 2000000: 4107, 2500000: 4108, 3000000: 4109, 3500000: 4110, 4000000: 4111}
- BYTESIZES = (5, 6, 7, 8)
- PARITIES = ('N', 'E', 'O', 'M', 'S')
- STOPBITS = (1, 1.5, 2)
- closed