iblrig.serial_singleton.SerialSingleton

Inheritance diagram of SerialSingleton

class iblrig.serial_singleton.SerialSingleton[source]
__init__(port=None, connect=True, **kwargs)[source]
Parameters:
Return type:

None

static __new__(cls, port=None, serial_number=None, *args, **kwargs)[source]
Parameters:
  • port (str | None)

  • serial_number (str | None)

close()[source]
Return type:

None

open()[source]
Return type:

None

query(query: Any, data_specifier: int = 1) bytes[source]
query(query: Any, data_specifier: str) tuple[Any, ...]

Query data from the serial device.

This method is a combination of write() and read().

Parameters:
  • query (Any) – Query to be sent to the serial device.

  • data_specifier (int or str, default: 1) – The number of bytes to receive from the serial device, or a format string for unpacking.

    When providing an integer, the specified number of bytes will be returned as a bytestring. When providing a format string, the data will be unpacked into a tuple accordingly. Format strings follow the conventions of the struct module.

Returns:

Data returned by the serial device. By default, data is formatted as a bytestring. Alternatively, when provided with a format string, data will be unpacked into a tuple according to the specified format string.

Return type:

bytes or tuple[Any]

read(data_specifier: int = 1) bytes[source]
read(data_specifier: str) tuple[Any, ...]

Read data from the serial device.

Parameters:

data_specifier (int or str, default: 1) – The number of bytes to receive from the serial device, or a format string for unpacking.

When providing an integer, the specified number of bytes will be returned as a bytestring. When providing a format string, the data will be unpacked into a tuple accordingly. Format strings follow the conventions of the struct module.

Returns:

Data returned by the serial device. By default, data is formatted as a bytestring. Alternatively, when provided with a format string, data will be unpacked into a tuple according to the specified format string.

Return type:

bytes or tuple[Any]

static to_bytes(data)[source]

Convert data to bytestring.

This method extends serial.to_bytes() with support for NumPy types, strings (interpreted as utf-8) and lists.

Parameters:

data (Any) – Data to be converted to bytestring.

Returns:

Data converted to bytestring.

Return type:

bytes

Parameters:

data (Any)

write(data)[source]
Return type:

int | None

write_packed(format_string, *data)[source]

Pack values according to format string and write to serial device.

Parameters:
Returns:

Number of bytes written to the serial device.

Return type:

int or None

Parameters:
  • format_string (str)

  • data (Any)

property port: str | None

Get the serial device’s communication port.

Returns:

The serial port (e.g., ‘COM3’, ‘/dev/ttyUSB0’) used by the serial device.

Return type:

str