openlifu.io.LIFUUart.LIFUUart¶
- class openlifu.io.LIFUUart.LIFUUart(vid, pid, baudrate=921600, timeout=10, align=0, desc='VCP', demo_mode=False, async_mode=False)[source]¶
Bases:
object- __init__(vid, pid, baudrate=921600, timeout=10, align=0, desc='VCP', demo_mode=False, async_mode=False)[source]¶
Initialize the UART instance.
- Parameters:
vid (int) – Vendor ID of the USB device.
pid (int) – Product ID of the USB device.
baudrate (int) – Communication speed.
timeout (int) – Read timeout in seconds.
align (int) – Data alignment parameter.
desc (str) – Descriptor for the device (e.g. “TX” or “HV”).
demo_mode (bool) – If True, simulate the connection.
async_mode (bool) – If True, use asynchronous mode.
- is_connected() bool[source]¶
Check if the device is connected.
- Returns:
True if connected, False otherwise.
- Return type:
bool
- read_packet(timeout=20) UartPacket[source]¶
Read a packet from the UART interface.
- Returns:
Parsed packet or an error packet if parsing fails.
- Return type:
- reopen_after_reset(retries=5, delay=1.0)[source]¶
Attempt to reopen the serial port after a device reset or disconnection. Returns True if reconnected, False otherwise.