pyserial support for serial communication with your DUT.
Import
Methods
Method Reference
serial.Serial(port, baudrate, **kwargs)
Create a serial connection.
Returns:
Serial object
readline()
Read a line from the serial port.
bytes - The received line
read(size)
Read a specified number of bytes.
Returns:
bytes - The received data
read_until(expected=b'\n', size=None)
Read until expected sequence is found.
Returns:
bytes - Data up to expected sequence
write(data)
Write data to the serial port.
Returns:
int - Number of bytes written
close()
Close the serial connection.
is_open
Check if connection is open.
bool - True if connection is open
Examples
Basic Communication
Interactive Session
Data Logging
Command/Response Pattern
Hardware Integration
Notes
- Lager supports native
pyserialfor serial communication - Serial ports are designated during Lager setup configuration
- Supports both raw UART and USB CDC connections
- Default baud rate is 115200
- Always handle
SerialExceptionerrors appropriately - Use
decode('utf-8')for string conversion

