labbench-comm is an asynchronous Python framework for communicating with LabBench hardware devices over serial connections.
It provides a testable protocol stack for deterministic device communication, with typed device functions, messages, packet framing, checksums, and concrete device implementations.
- Async-first communication using
asyncio - Serial transport support using
pyserial - Protocol primitives for frames, packets, stuffing, checksums, dispatch, and device functions
- Typed device-specific functions and messages
- Hardware-oriented examples for supported LabBench devices
- Unit tests plus optional hardware integration tests
- CPAR+: pressure stimulation device support, including waveform control and status/event messages
- LabBench I/O (LIO): response ports, trigger I/O, analog input/status messages, waveform output, stimulus programs, calibration/event records
- Python 3.12+
- Windows, Linux, or macOS
- Serial access to compatible LabBench hardware for hardware examples and integration tests
Install the package:
pip install labbench-commThe Python import package is named labbench_comm:
import labbench_comm.devices.lio as lio
import labbench_comm.devices.cpar as cparimport asyncio
from labbench_comm.protocols.bus_central import BusCentral
from labbench_comm.serial.async_serial_connection import AsyncSerialConnection
from labbench_comm.serial.connection import PySerialIO
import labbench_comm.devices.lio as lio
async def main() -> None:
serial_io = PySerialIO(port="COM3", baudrate=57600)
connection = AsyncSerialConnection(serial_io)
bus = BusCentral(connection)
device = lio.LIOCentral(bus)
async with device:
count = await device.ping()
print("Ping:", count)
asyncio.run(main())Examples live in examples/.
LIO examples include device identification, input monitoring, analog reads, direct voltage output, stimulus programs, waveforms, trigger sequences, and calibration/event records.
Some examples directly drive hardware outputs. Review the script and connected setup before running output-driving examples such as:
python examples/lio/manual_voltage.py --port COM3 --voltage 1.0
python examples/lio/stimulus_program.py --port COM3This repository uses a src/ layout. Install it into the same environment that will run tests or examples:
python -m pip install -e .[dev]Run unit tests:
python -m pytest -m unittest -vBuild and verify distributions:
python -m build
twine check dist/*This project is in alpha. APIs may change while device support and protocol coverage mature.
See CONTRIBUTING.md for development setup, testing guidance, and contribution expectations.
This project is licensed under the MIT License. See LICENSE.