panoptes.utils.serial package¶
Submodules¶
panoptes.utils.serial.device module¶
- class panoptes.utils.serial.device.SerialDevice(port: str | None = None, name: str | None = None, reader_callback: Callable | None = None, serial_settings: SerialDeviceDefaults | dict | None = None, reader_queue_size: int = 50)[source]¶
Bases:
object
- property is_connected¶
True if serial port is open, False otherwise.
- property port¶
Name of the port.
- class panoptes.utils.serial.device.SerialDeviceDefaults(baudrate: int = 9600, timeout: float = 1.0, write_timeout: float = 1.0, bytesize: int = 8, parity: str = 'N', stopbits: int = 1, xonxoff: bool = False, rtscts: bool = False, dsrdtr: bool = False)[source]¶
Bases:
object
Dataclass for the serial port defaults.
This can be instantiated with changed values and then passed to the serial device via the apply_settings method.
Values are:
write_timeout, inter_byte_timeout, dsrdtr, baudrate, timeout, parity, bytesize, rtscts, stopbits, xonxoff
See https://pyserial.readthedocs.io/en/latest/pyserial_api.html#serial.Serial.get_settings
- panoptes.utils.serial.device.find_serial_port(vendor_id, product_id, return_all=False)[source]¶
Finds the serial port that matches the given vendor and product id.
>>> from panoptes.utils.serial.device import find_serial_port >>> vendor_id = 0x2a03 # arduino >>> product_id = 0x0043 # Uno Rev 3 >>> find_serial_port(vendor_id, product_id) '/dev/ttyACM0' >>> # Raises error when not found. >>> find_serial_port(0x1234, 0x4321) Traceback (most recent call last): ... panoptes.utils.error.NotFound: NotFound: No serial ports...
- Parameters:
- Returns:
Either the path to the detected port or a list of all comports that match.
- Return type:
- panoptes.utils.serial.device.get_serial_port_info()[source]¶
Returns the serial ports defined on the system sorted by device name.
>>> from panoptes.utils.serial.device import get_serial_port_info >>> devices = get_serial_port_info() >>> devices [<serial.tools.list_ports_linux.SysFS object at 0x7f6c9cbd9460>] >>> devices[0].hwid 'USB VID:PID=2886:802D SER=3C788B875337433838202020FF122204 LOCATION=3-5:1.0'
- Returns: a list of PySerial’s ListPortInfo objects. See:
https://github.com/pyserial/pyserial/blob/master/serial/tools/list_ports_common.py