iblrig.serial_singleton.SerialSingleton
- class iblrig.serial_singleton.SerialSingleton[source]
-
- 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()
andread()
.- Parameters:
query (
Any
) – Query to be sent to the serial device.data_specifier (
int
orstr
, 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
ortuple[Any]
- read(data_specifier: int = 1) bytes [source]
- read(data_specifier: str) tuple[Any, ...]
Read data from the serial device.
- Parameters:
data_specifier (
int
orstr
, 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
ortuple[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.
- write_packed(format_string, *data)[source]
Pack values according to format string and write to serial device.
- Parameters:
format_string (
str
) – Format string describing the data layout for packing the data following the conventions of thestruct
module. See https://docs.python.org/3/library/struct.html#format-charactersdata (
Any
) – Data to be written to the serial device.
- Returns:
Number of bytes written to the serial device.
- Return type:
- Parameters: