Skip to main content

Python bindings for FIRM Client using Rust

Project description

FIRM-Client

A modular Rust library for parsing FIRM data packets, with bindings for Python and WebAssembly.

Project Structure

The project is organized as a Cargo workspace with the following crates:

  • firm_core: The core no_std crate containing the packet parser, CRC logic, and data structures. This is the foundation for all other crates and can be used in embedded environments.
  • firm_rust: A high-level Rust API that uses serialport to read from a serial device and provides a threaded client for receiving packets.
  • firm_python: Python bindings for the Rust client.
  • firm_typescript: WebAssembly bindings and TypeScript code for using the parser in web applications.

Philosophy

The goal of FIRM-Client is to provide a single, efficient, and correct implementation of the FIRM parser that can be used across different ecosystems (Rust, Python, Web/JS, Embedded). By centralizing the parsing logic in firm_core, we ensure consistency and reduce code duplication.

Building

Prerequisites

  • Rust (latest stable)
  • Python 3.10+ (for Python bindings)
  • maturin (for building Python wheels)
  • wasm-pack (for building WASM)
  • Node.js/npm (for TypeScript)

Build Instructions

We assume that you are using a Unix-like environment (Linux or macOS).

Windows users may need to adapt some commands (we will mention where this is the case), or use WSL (Windows Subsystem for Linux) for best compatibility.

Make sure you have Cargo and uv installed.

You would also need npm if you want to test the web/TypeScript bindings. Install it and Node.js here: https://nodejs.org/en/download/

  1. Build all Rust crates:

    cargo build
    
  2. Build Python bindings:

    cargo build -p firm_python
    uv sync
    # or to build a wheel
    uv run maturin build --release
    
  3. Build WASM/TypeScript:

    cd firm_typescript
    npm install
    npm run clean
    npm run build
    
    # For testing the code with examples/index.html
    npx serve .
    

Usage

Rust

Add firm_rust to your Cargo.toml.

use firm_rust::FirmClient;
use std::{thread, time::Duration};

fn main() {
    let mut client = FIRMClient::new("/dev/ttyUSB0", 2_000_000, 0.1);
    client.start();

    loop {
        while let Ok(packet) = client.get_packets(Some(Duration::from_millis(100))) {
            println!("{:#?}", packet);
        }
    }
}

Python

You can install the library via pip (once published) or build from source.

pip install firm-client

This library supports Python 3.10 and above, including Python 3.14 free threaded.

from firm_client import FIRMClient
import time

# Using context manager (automatically starts and stops)
with FIRMClient("/dev/ttyUSB0", baud_rate=2_000_000, timeout=0.1) as client:
    client.get_data_packets(block=True)  # Clear initial packets
    client.zero_out_pressure_altitude()
    while True:
        packets = client.get_data_packets()
        for packet in packets:
            print(packet.timestamp_seconds, packet.raw_acceleration_x_gs)

Web (TypeScript)

todo: Add usage example.

Publishing

This is mostly for maintainers, but here are the steps to publish each crate to their respective package registries:

Rust API (crates.io)

todo (idk actually know yet)

Python Bindings (PyPI)

We need to to first build wheels for each platform, right now the workflow is to do this locally and then upload to PyPI. At the minimum, we build for Linux x86_64 and aarch64 for python versions 3.10+, including free threaded wheels.

  1. We should always bump the version in firm_python/Cargo.toml and pyproject.toml before publishing. Make sure they match exactly.

  2. Build the wheels (.sh files can only run on Unix-like systems, so Windows users may simply open the file and run the commands manually):

./compile.sh

This will create wheels in the target/wheels directory, for Python versions 3.10 to 3.14, for both x86_64 and aarch64.

  1. Make sure you also have a source distribution:
uv run maturin sdist
  1. We will use uv to publish these wheels to PyPI. Make sure you are part of the HPRC organization on PyPI, so you have access to the project and can publish new versions.
uv publish target/wheels/*

This will ask for PyPI credentials, make sure you get the token from the website.

TypeScript Package (npm)

  1. Login to npm

npm login

  1. Publish it

npm publish

(Ensure the version in package.json is bumped before publishing.)

License

Licensed under the MIT License. See LICENSE file for details.

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

firm_client-1.0.0.tar.gz (40.0 kB view details)

Uploaded Source

Built Distributions

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

firm_client-1.0.0-cp314-cp314t-win_amd64.whl (270.0 kB view details)

Uploaded CPython 3.14tWindows x86-64

firm_client-1.0.0-cp314-cp314t-manylinux_2_31_aarch64.whl (350.9 kB view details)

Uploaded CPython 3.14tmanylinux: glibc 2.31+ ARM64

firm_client-1.0.0-cp314-cp314-win_amd64.whl (270.9 kB view details)

Uploaded CPython 3.14Windows x86-64

firm_client-1.0.0-cp314-cp314-manylinux_2_31_aarch64.whl (352.1 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.31+ ARM64

firm_client-1.0.0-cp313-cp313-win_amd64.whl (269.9 kB view details)

Uploaded CPython 3.13Windows x86-64

firm_client-1.0.0-cp313-cp313-manylinux_2_31_aarch64.whl (351.2 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.31+ ARM64

firm_client-1.0.0-cp312-cp312-win_amd64.whl (270.2 kB view details)

Uploaded CPython 3.12Windows x86-64

firm_client-1.0.0-cp312-cp312-manylinux_2_31_aarch64.whl (351.4 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.31+ ARM64

firm_client-1.0.0-cp311-cp311-win_amd64.whl (270.1 kB view details)

Uploaded CPython 3.11Windows x86-64

firm_client-1.0.0-cp311-cp311-manylinux_2_31_aarch64.whl (351.9 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.31+ ARM64

firm_client-1.0.0-cp310-cp310-win_amd64.whl (270.9 kB view details)

Uploaded CPython 3.10Windows x86-64

firm_client-1.0.0-cp310-cp310-manylinux_2_31_aarch64.whl (351.3 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.31+ ARM64

File details

Details for the file firm_client-1.0.0.tar.gz.

File metadata

  • Download URL: firm_client-1.0.0.tar.gz
  • Upload date:
  • Size: 40.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.8

File hashes

Hashes for firm_client-1.0.0.tar.gz
Algorithm Hash digest
SHA256 7f24eb3f1a2d8cbd1b7d8d62a3797b2e3f010d2677d215af72c81e3dcb524400
MD5 ce7ef83537d1b8daf00a9b6d6f3a46d9
BLAKE2b-256 bd8207f593371b33797d651c42473a23e084286ad9cd2a04fe68374c5138a55f

See more details on using hashes here.

File details

Details for the file firm_client-1.0.0-cp314-cp314t-win_amd64.whl.

File metadata

File hashes

Hashes for firm_client-1.0.0-cp314-cp314t-win_amd64.whl
Algorithm Hash digest
SHA256 307ed9b229fb9ae2635c636c2ea1f44221047ba47e053caac631bd5e45ecf9af
MD5 8c1586c02dfb6d214776422373d2dbba
BLAKE2b-256 580fcc61228154d7b7248e24597d6e133bf6d84f0979ac8f782d692dcbc1db4f

See more details on using hashes here.

File details

Details for the file firm_client-1.0.0-cp314-cp314t-manylinux_2_31_aarch64.whl.

File metadata

File hashes

Hashes for firm_client-1.0.0-cp314-cp314t-manylinux_2_31_aarch64.whl
Algorithm Hash digest
SHA256 40c3b1a17166b56c148288a7fafe104db5350bbe1acdc3dba0a6538bffa47876
MD5 c4169870630e3566b6c9b29f3b5a0c4a
BLAKE2b-256 99e28247b4fb7f13f3513410f100c29a3727f56578dba1d555669f05aae38952

See more details on using hashes here.

File details

Details for the file firm_client-1.0.0-cp314-cp314-win_amd64.whl.

File metadata

File hashes

Hashes for firm_client-1.0.0-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 2042e192be9d30b4655e8c104bee0e172f872f8d38286e42e015368c1a714f8f
MD5 63cec0f6d51e21b527186868057cc70c
BLAKE2b-256 0653f353c5c34497c4779e2c099a2ee9038ff3320ca4eac54df2ebe3ea59c7a6

See more details on using hashes here.

File details

Details for the file firm_client-1.0.0-cp314-cp314-manylinux_2_31_aarch64.whl.

File metadata

File hashes

Hashes for firm_client-1.0.0-cp314-cp314-manylinux_2_31_aarch64.whl
Algorithm Hash digest
SHA256 6d1452903599de6554ef0e027c1b6cb3a6d80fdf36b53425820a96d58fde9587
MD5 97b7f4008d2e033705d790c0072f9000
BLAKE2b-256 80bcc2b737183a8185de2206472473dec013a2464c3a43c8c276d3bdd063a55d

See more details on using hashes here.

File details

Details for the file firm_client-1.0.0-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for firm_client-1.0.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 f4fe1c00cfe938dd4985c09ed6f7cfcb7f8092d274f3db3a7b867975410581e5
MD5 3bd267a70d40f3152a10a5dd998965f8
BLAKE2b-256 b82d3c88fe2cba3fad3b26473b12e2b14e763b2efaadf2547d01432b166598df

See more details on using hashes here.

File details

Details for the file firm_client-1.0.0-cp313-cp313-manylinux_2_31_aarch64.whl.

File metadata

File hashes

Hashes for firm_client-1.0.0-cp313-cp313-manylinux_2_31_aarch64.whl
Algorithm Hash digest
SHA256 136d62ffd4c3d55738a770a1c394c83f40d6333aebac91ffe4d90bb774b9623a
MD5 551bbe09a14cc1cdcb568516467ce046
BLAKE2b-256 d282e55d0d22c2fdf22a4b0cc5e0207c6681331668394d324846e4b0e4cecbe4

See more details on using hashes here.

File details

Details for the file firm_client-1.0.0-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for firm_client-1.0.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 cbfc0ac28a4453a39c63a421bc57ea32b4df978c439d142c5a4763a0e2fe3f63
MD5 ddd16484f08bffd4c01015c61c684808
BLAKE2b-256 369bf267770d81c34aea269c80a2f99c43765070b26b9da9a126cdee00195c03

See more details on using hashes here.

File details

Details for the file firm_client-1.0.0-cp312-cp312-manylinux_2_31_aarch64.whl.

File metadata

File hashes

Hashes for firm_client-1.0.0-cp312-cp312-manylinux_2_31_aarch64.whl
Algorithm Hash digest
SHA256 5441a3b1a13ae00e0e991acfc42e9c23b4c019100d8f21cd4b7a0aff5120b661
MD5 7665aac427011c2366677482d48a54dd
BLAKE2b-256 f7530a701e17bfef8dc3ed1e713d34e012bd96f0de9431477917686bede38ada

See more details on using hashes here.

File details

Details for the file firm_client-1.0.0-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for firm_client-1.0.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 09305a8a52e61a248be27ce27e2ceada119e9efccc63d4c34d226d698c0e8460
MD5 d61b6601226741b072ff5fa447623f25
BLAKE2b-256 55cd73c7a099bf9c576e858a54cde6801dd675f057e8216a5198c5f9851a7d12

See more details on using hashes here.

File details

Details for the file firm_client-1.0.0-cp311-cp311-manylinux_2_31_aarch64.whl.

File metadata

File hashes

Hashes for firm_client-1.0.0-cp311-cp311-manylinux_2_31_aarch64.whl
Algorithm Hash digest
SHA256 29a22368b9562e07ab0f33719ce09baeca2a225a5d263014af39296c28d28aae
MD5 d4ee44b0c197aeebdd75c6b37cee4880
BLAKE2b-256 227423421c0aa92ec65aa0805d12a16d5385af2b9fd5b6559bc8cef6f61fd06d

See more details on using hashes here.

File details

Details for the file firm_client-1.0.0-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for firm_client-1.0.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 a4c3f5d1812367e3dd447c779d399b723d6dbebf5954da2ffef8d257afcdb406
MD5 4530e3a50497e7c64ef6282af4b06d0c
BLAKE2b-256 788f2e7149ac5c8b03a434adac9d039160b99b491e669bde354a81cb9b44d6e3

See more details on using hashes here.

File details

Details for the file firm_client-1.0.0-cp310-cp310-manylinux_2_31_aarch64.whl.

File metadata

File hashes

Hashes for firm_client-1.0.0-cp310-cp310-manylinux_2_31_aarch64.whl
Algorithm Hash digest
SHA256 17ee8c0a9d42311f6bd9387d81c85dfbb9dfc671adf65b59b2a7548a7c52626e
MD5 818e927a362667ba733a1bb65bc55157
BLAKE2b-256 9ee72134495683cd2b0b229d7a951ea55fffd362af2b828d5abe6c8454316abd

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