Skip to main content

labbench-comm

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.

Features

  • 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

Supported Devices

  • 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

Requirements

  • Python 3.12+
  • Windows, Linux, or macOS
  • Serial access to compatible LabBench hardware for hardware examples and integration tests

Installation

Install the package:

pip install labbench-comm

The Python import package is named labbench_comm:

import labbench_comm.devices.lio as lio
import labbench_comm.devices.cpar as cpar

Quick Start

import 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

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 COM3

Documentation

  • Package documentation starts at docs/index.md.
  • Public API reference is in docs/api/index.md.
  • Agent-oriented documentation maps are available in llms.txt and docs/agents.md.
  • Release documentation is published with GitHub Pages at https://labbench-society.github.io/LabBench.Python/ after v* release tags are deployed.

Build local documentation:

python -m pip install -e .[dev,docs]
python -m sphinx -W --keep-going -b html docs docs/_build/html

Update package docs when public API, examples, packet semantics, safety behavior, or device workflows change.

Development Setup

This 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 -v

Build and verify distributions:

python -m build
twine check dist/*

Project Status

This project is in alpha. APIs may change while device support and protocol coverage mature.

Contributing

See CONTRIBUTING.md for development setup, testing guidance, and contribution expectations.

License

This project is licensed under the MIT License. See LICENSE.

Metadata

Release files for labbench-comm 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for labbench-comm 0.1.3
File Size Uploaded Provenance Actions
labbench_comm-0.1.3.tar.gz 40.9 kB Without provenance Details for labbench_comm-0.1.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for labbench-comm 0.1.3
File Interpreter ABI Platform Actions
labbench_comm-0.1.3-py3-none-any.whl Python 3 none any Details for labbench_comm-0.1.3-py3-none-any.whl

Total release size: 109.3 kB

Release files / labbench_comm-0.1.3.tar.gz

Download URL labbench_comm-0.1.3.tar.gz
Size 40.9 kB
Tags Source
SHA-256 checksum
How to use checksums
66565b25f8e7855df331f57fe0ed3ae325fdcf921453499d21e9a20937286763
BLAKE2b-256 checksum
How to use checksums
e1525949e5063a6d0c34f31381a30fa78fe664af66a522360ffb2b9e7eb9d989
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Release files / labbench_comm-0.1.3-py3-none-any.whl

Download URL labbench_comm-0.1.3-py3-none-any.whl
Size 68.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3622ef44ad5cf066844770b673870834afc55b8a873501813e414013d7783a07
BLAKE2b-256 checksum
How to use checksums
2b7647895c4f5ee046d6cf4654a2c66b5bbef922fb7892f199f11e4d0b7499ae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Security for labbench-comm 0.1.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page