Import
Methods
| Method | Description |
|---|---|
get_path() | Get the device path (e.g., /dev/ttyUSB0) |
connect() | Connect and return a pyserial Serial object |
get_baudrate() | Get the configured baudrate |
get_config() | Get the raw net configuration |
Method Reference
Net.get(name, type=NetType.UART)
Get a UART net by name.
| Parameter | Type | Description |
|---|---|---|
name | str | Name of the UART net |
type | NetType | Must be NetType.UART |
UARTNet instance
get_path()
Get the device path for the UART net.
str - Device path like /dev/ttyUSB0
Raises: FileNotFoundError if the UART device is not connected
connect(**overrides)
Connect to the UART serial port with pyserial.
| Parameter | Type | Description |
|---|---|---|
baudrate | int | Baud rate (default from config or 115200) |
timeout | float | Read timeout in seconds |
bytesize | int | Data bits (5, 6, 7, or 8) |
parity | str | Parity ('N', 'E', 'O') |
stopbits | float | Stop bits (1, 1.5, or 2) |
serial.Serial - Connected pyserial object
get_baudrate()
Get the configured baudrate for this net.
int - Configured baudrate (default: 115200)
get_config()
Get the raw net configuration dictionary.
dict - Configuration dictionary
Properties
| Property | Type | Description |
|---|---|---|
name | str | Net name |
usb_serial | str | USB serial number for device identification |
channel | str | Channel/port number |
params | dict | Serial parameters (baudrate, etc.) |
Examples
Basic UART Communication
Using Device Path Directly
Interactive Console
Command/Response Pattern
Production Test with UART
Multi-Net UART Test
UART vs Serial Module
The Lager Python SDK provides two ways to work with serial communication:| Feature | UART Net (NetType.UART) | Serial (pyserial) |
|---|---|---|
| Device Discovery | Automatic via USB serial number | Manual device path |
| Configuration | Stored in Lager config | Manual in code |
| Integration | Full Lager net system | Standalone |
| Best For | Production tests, multi-device | Quick prototyping |
- Device paths may change between reboots
- You need to identify devices by USB serial number
- You’re using Lager’s net configuration system
- Running automated production tests
- You know the exact device path
- You need maximum flexibility
- You’re doing quick debugging
Hardware Integration
| Hardware | Description |
|---|---|
| USB-Serial Adapters | FTDI, CP2102, CH340, etc. |
| UART Bridges | Multi-port USB-UART converters |
| Built-in UART | Native UART on Lager Box hardware |
Notes
- UART nets resolve device paths using USB serial numbers for consistent identification
- The
connect()method returns a standard pyserialSerialobject - Default baudrate is 115200 if not specified in configuration
- Device paths are cached after first resolution
- Use
get_path()if you need the raw device path for other tools - Serial parameters from net configuration can be overridden in
connect()

