Skip to main content

Communication with LabBench devices

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

labbench_comm-0.1.3.tar.gz (40.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

labbench_comm-0.1.3-py3-none-any.whl (68.4 kB view details)

Uploaded Python 3

File details

Details for the file labbench_comm-0.1.3.tar.gz.

File metadata

  • Download URL: labbench_comm-0.1.3.tar.gz
  • Upload date:
  • Size: 40.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for labbench_comm-0.1.3.tar.gz
Algorithm Hash digest
SHA256 66565b25f8e7855df331f57fe0ed3ae325fdcf921453499d21e9a20937286763
MD5 f83f4618bbb7c4c1cdf8033f5f9ea4c1
BLAKE2b-256 e1525949e5063a6d0c34f31381a30fa78fe664af66a522360ffb2b9e7eb9d989

See more details on using hashes here.

File details

Details for the file labbench_comm-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: labbench_comm-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 68.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for labbench_comm-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 3622ef44ad5cf066844770b673870834afc55b8a873501813e414013d7783a07
MD5 fd0d7ffa23042dabe7bc28eea9f74d3a
BLAKE2b-256 2b7647895c4f5ee046d6cf4654a2c66b5bbef922fb7892f199f11e4d0b7499ae

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page