Serial¶
The Serial interface is a wrapper for the pyserial library.
-
class
labtronyx.interfaces.i_Serial.i_Serial(manager, **kwargs)[source]¶ Serial Interface
Wraps PySerial.
-
class
labtronyx.interfaces.i_Serial.r_Serial(manager, resID, **kwargs)[source]¶ Serial Resource Base class.
Wraps PySerial
Resource API is compatible with VISA resources, so any driver written for a VISA resource should also work for serial resources in the case that a VISA library is not available.
-
close()[source]¶ Close the resource. If a driver is loaded, that driver is also closed
Returns: True if successful, False otherwise
-
configure(**kwargs)[source]¶ Configure Serial port parameters for the resource.
Parameters: - timeout (int) – Command timeout
- write_termination (str) – Write termination
- baud_rate (int) – Serial Baudrate. Default 9600
- data_bits (int) – Number of bits per frame. Default 8.
- parity (str) – Data frame parity (‘N’one, ‘E’ven, ‘O’dd, ‘M’ark or ‘S’pace)
- stop_bits (int) – Number of stop bits. Default 1
-
getProperties()[source]¶ Get the property dictionary for the Serial resource.
Return type: dict[str:object]
-
inWaiting()[source]¶ Return the number of bytes in the receive buffer
Returns: int Raises: InterfaceError
-
open()[source]¶ Open the resource and prepare to receive commands. If a driver is loaded, the driver will also be opened
Returns: True if successful, False otherwise Raises: ResourceUnavailable
-
query(data, delay=None)[source]¶ Retreive ASCII-encoded data from the device given a prompt.
A combination of write(data) and read()
Parameters: Returns: str
Raises: ResourceNotOpen
Raises: InterfaceTimeout
Raises: InterfaceError
-
read(termination=None)[source]¶ Read string data from the instrument.
Reading stops when the device stops sending, or the termination characters sequence was detected.
All line-ending characters are stripped from the end of the string.
Raises: ResourceNotOpen
-
read_raw(size=None)[source]¶ Read Binary-encoded data from the instrument.
No termination characters are stripped.
Parameters: size (int) – Number of bytes to read Returns: bytes Raises: ResourceNotOpen
-