Skip to main content

rust-shdlc-driver

High-performance asynchronous Rust SHDLC driver and Python bindings for Sensirion SHDLC devices over serial, TCP, and custom transports.

Features

  • Synchronous & Asynchronous APIs: Provides both blocking (ShdlcDevice, ShdlcConnection, ShdlcSerialPort, ShdlcTcpPort, ShdlcFirmwareUpdate) and async (AsyncShdlcDevice, AsyncShdlcConnection, AsyncShdlcFirmwareUpdate) APIs in Rust and Python.
  • Python Bindings (Python >= 3.11): Native PyO3 and Maturin bindings with full type support and asyncio integration.
  • Firmware Update: Complete support for Intel-Hex firmware images, signature validation, checksum verification, and device flashing over SHDLC bootloader.
  • Mock Transport: Built-in high-fidelity in-memory mock transport for test-driven development and unit testing without physical hardware.

It is strongly recommended to set up and use a dedicated Python virtual environment for isolated dependency management:

Linux / macOS

# Create a virtual environment using Python 3.11+
python3.11 -m venv .venv

# Activate the virtual environment
source .venv/bin/activate

# Upgrade pip and install maturin
pip install --upgrade pip maturin

Windows

# Create a virtual environment using Python 3.11+
py -3.11 -m venv .venv

# Activate the virtual environment
.venv\Scripts\activate

# Upgrade pip and install maturin
pip install --upgrade pip maturin

Python Installation

Once your virtual environment is active:

# Development editable install
maturin develop

# Optimized release install
maturin develop --release

Python Usage Examples

Synchronous Usage

from rust_shdlc_driver import ShdlcSerialPort, ShdlcConnection, ShdlcDevice

with ShdlcSerialPort(port="/dev/ttyUSB0", baudrate=115200) as port:
    conn = ShdlcConnection(port)
    device = ShdlcDevice(conn, slave_address=0)
    
    product_type = device.get_product_type()
    product_name = device.get_product_name()
    serial_number = device.get_serial_number()
    version = device.get_version()
    
    print(f"Product: {product_name} ({product_type})")
    print(f"Serial: {serial_number}")
    print(f"Version: {version}")

Asynchronous Usage (Asyncio)

import asyncio
from rust_shdlc_driver import ShdlcSerialPort, AsyncShdlcConnection, AsyncShdlcDevice

async def main():
    port = ShdlcSerialPort(port="/dev/ttyUSB0", baudrate=115200)
    conn = AsyncShdlcConnection(port)
    device = AsyncShdlcDevice(conn, slave_address=0)
    
    name = await device.get_product_name()
    print(f"Product name: {name}")

asyncio.run(main())

Virtual Mock Port for Testing

from rust_shdlc_driver import ShdlcMockPort, ShdlcConnection, ShdlcDevice

port = ShdlcMockPort(bitrate=115200)
conn = ShdlcConnection(port)
device = ShdlcDevice(conn, slave_address=1)

# Push response frame to virtual mock queue
port.push_rx_data(b"\x7e\x01\xd0\x00\x06SHT31\0\x7d\x5d\x7e")
assert device.get_product_name() == "SHT31"

Running Tests

# Rust unit and mock integration tests
cargo test

# Python pytest suite
pytest python_tests/ -v

Building Documentation

pip install sphinx sphinx_rtd_theme
sphinx-build -b html docs docs/_build/html

License

See LICENSE.

Metadata

Release files for rust-shdlc-driver 0.1.0

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

Source distribution (sdist)

Source distribution for rust-shdlc-driver 0.1.0
File Size Uploaded Provenance Actions
rust_shdlc_driver-0.1.0.tar.gz 109.6 kB Without provenance Details for rust_shdlc_driver-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for rust-shdlc-driver 0.1.0
File Interpreter ABI Platform Actions
rust_shdlc_driver-0.1.0-cp311-abi3-win_amd64.whl CPython 3.11 abi3 Windows x86-64 Details for rust_shdlc_driver-0.1.0-cp311-abi3-win_amd64.whl

Total release size: 1.0 MB

Release files / rust_shdlc_driver-0.1.0.tar.gz

Download URL rust_shdlc_driver-0.1.0.tar.gz
Size 109.6 kB
Tags Source
SHA-256 checksum
How to use checksums
ac08a645f6f42c742b54312987d3a99b1c9cd9c15332bcaa00e7d086a2b7b1a5
BLAKE2b-256 checksum
How to use checksums
125eedb8bbade195d50a4243a5143d004bf9dbae5ec646c298e7250a25372f70
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / rust_shdlc_driver-0.1.0-cp311-abi3-win_amd64.whl

Download URL rust_shdlc_driver-0.1.0-cp311-abi3-win_amd64.whl
Size 910.8 kB
Tags CPython 3.11 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
d05fe9341d18d9eade9a5284a70a11c29a82f8cd7a43f1c90a783c196d0bfab7
BLAKE2b-256 checksum
How to use checksums
c984c6e14d1b49d22152574238e354ff816504e05e3dcd51049c00da8fc93476
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Security for rust-shdlc-driver 0.1.0

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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

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