Skip to main content

Parser for MicroStrain Communication Library (MSCL) packets in Rust.

Project description

mscl-rs

Rust parser for data from the 3DM®-CX5-15 IMU. This library provides python bindings in a convenient format so that the client side (Python) does not need to spend precious processing time parsing the data.

This library has been benchmarked to be ~10x faster than the official Python python-mscl equivalent (which has a C++ backend).

This library is not intended to be a full replacement for the C++ MSCL library but rather a lightweight parser for the data packets, and intended to be more well maintained and Python free threading compatible.

Features will be added as needed, open an issue or PR if you need something!

Installation

This package is available on PyPI, you can install it via pip:

pip install mscl-rs

Wheels are available for Linux (x86_64 and aarch64) 3.13, 3.14, and 3.14t. Any other platform or python version will require building from source, which your package manager (e.g. pip) will automatically handle, but you still need to install Rust.

Public API

The main entrypoint is the SerialParser class, which can be used to read data from the IMU over a serial connection. E.g.

from mscl_rs import SerialParser

parser = SerialParser(port="/dev/ttyUSB0", timeout=1.0)  # Timeout of 1 second

with parser:  # calls parser.start() and parser.stop() automatically
    while True:
        packets = parser.get_data_packets(block=True)  # Block until data is available
        for packet in packets:
            print(packet)

To see all available methods, documentation, and the data packet structure, see the mscl_rs.pyi file.

Local Development Setup:

You will need uv, and Rust installed.

Then clone the repository:

git clone https://github.com/NCSU-High-Powered-Rocketry-Club/mscl_rs.git && cd mscl-rs && uv run pre-commit install

If you have plugged in your IMU via USB, you can test the example parser script by the command below. Make sure to change the serial port in examples/parse_mscl_rs.py if needed.

uv run examples/parse_mscl_rs.py

This will automatically build the Rust code and install the package in a virtual environment, and automatically run the example script.

You do not need to separately run maturin develop at all.

To switch between development and release builds, you can change the config-settings in pyproject.toml.

Testing

This library has tests both in the Rust and Python layers. To run the tests, run the following commands:

# Run Rust tests
cargo test
# Run Python tests
uv run pytest tests/

If you have an actual IMU connected via serial, this will also run tests that parse real data from the IMU, and benchmark the performance against the official python-mscl library.

Cross compiling and releasing

To build wheels for all platforms, you can use maturin's and Zig's cross compiling support. If you are on linux, you can run the compile.sh script to build wheels for the platforms and python versions we provide first class support for.

chmod +x compile.sh
./compile.sh

This will create wheels in the target/wheels/ folder.

We can now publish to PyPI using uv:

uv publish target/wheels/*

Changelog

See the GitHub releases page for the changelog.

License

This project is licensed under the MIT License. See the 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

mscl_rs-0.2.0.tar.gz (621.1 kB view details)

Uploaded Source

Built Distributions

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

mscl_rs-0.2.0-cp314-cp314t-manylinux_2_34_x86_64.whl (385.4 kB view details)

Uploaded CPython 3.14tmanylinux: glibc 2.34+ x86-64

mscl_rs-0.2.0-cp314-cp314t-manylinux_2_31_aarch64.whl (327.6 kB view details)

Uploaded CPython 3.14tmanylinux: glibc 2.31+ ARM64

mscl_rs-0.2.0-cp314-cp314-manylinux_2_34_x86_64.whl (385.1 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.34+ x86-64

mscl_rs-0.2.0-cp314-cp314-manylinux_2_31_aarch64.whl (328.0 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.31+ ARM64

mscl_rs-0.2.0-cp313-cp313-manylinux_2_34_x86_64.whl (386.5 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ x86-64

mscl_rs-0.2.0-cp313-cp313-manylinux_2_31_aarch64.whl (329.2 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.31+ ARM64

File details

Details for the file mscl_rs-0.2.0.tar.gz.

File metadata

  • Download URL: mscl_rs-0.2.0.tar.gz
  • Upload date:
  • Size: 621.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.16 {"installer":{"name":"uv","version":"0.9.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for mscl_rs-0.2.0.tar.gz
Algorithm Hash digest
SHA256 08627bb22dcb0cecaf16858b4e3102aa2eaed962eab7c61bc13d6534beaa6a60
MD5 c9b499c0c9c2ed5978fac82cf2c14798
BLAKE2b-256 423ce44f1be703b1de8b61127953779a1a4d45b74575cb6a6f118ba577d385dc

See more details on using hashes here.

File details

Details for the file mscl_rs-0.2.0-cp314-cp314t-manylinux_2_34_x86_64.whl.

File metadata

  • Download URL: mscl_rs-0.2.0-cp314-cp314t-manylinux_2_34_x86_64.whl
  • Upload date:
  • Size: 385.4 kB
  • Tags: CPython 3.14t, manylinux: glibc 2.34+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.16 {"installer":{"name":"uv","version":"0.9.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for mscl_rs-0.2.0-cp314-cp314t-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 dd1c9bf00f6eb1723c0bab18ce98b8156c4ece67d59525f1e1bd13bbd35d5537
MD5 e7ffdbae434b89395ca39c6f03763774
BLAKE2b-256 17690cb3a3b8306a65a76ac19b31ec31ef36cee7f74a0da8d6ea634f8ce095bf

See more details on using hashes here.

File details

Details for the file mscl_rs-0.2.0-cp314-cp314t-manylinux_2_31_aarch64.whl.

File metadata

  • Download URL: mscl_rs-0.2.0-cp314-cp314t-manylinux_2_31_aarch64.whl
  • Upload date:
  • Size: 327.6 kB
  • Tags: CPython 3.14t, manylinux: glibc 2.31+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.16 {"installer":{"name":"uv","version":"0.9.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for mscl_rs-0.2.0-cp314-cp314t-manylinux_2_31_aarch64.whl
Algorithm Hash digest
SHA256 129ec2a2429b0e6dc04db81762890023d1b2ba768095c3f84dade42d4e4e4372
MD5 bad2520572ddadeb8aa5f232ef6aa24e
BLAKE2b-256 30a15f5a4887c9c97c5a4d528c1d2a8fd0f04abcebe02594e433d46bc91d232a

See more details on using hashes here.

File details

Details for the file mscl_rs-0.2.0-cp314-cp314-manylinux_2_34_x86_64.whl.

File metadata

  • Download URL: mscl_rs-0.2.0-cp314-cp314-manylinux_2_34_x86_64.whl
  • Upload date:
  • Size: 385.1 kB
  • Tags: CPython 3.14, manylinux: glibc 2.34+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.16 {"installer":{"name":"uv","version":"0.9.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for mscl_rs-0.2.0-cp314-cp314-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 22f9356d9055ea6402922147de90778aaf96e96a31970de96275d4ff80cadb4f
MD5 886608f590ac25e6654d95443aae3a54
BLAKE2b-256 cf70682021b9c4fb0ba6ee7127ce0260bd11eea4cde3ef2dba3a24e648e78eed

See more details on using hashes here.

File details

Details for the file mscl_rs-0.2.0-cp314-cp314-manylinux_2_31_aarch64.whl.

File metadata

  • Download URL: mscl_rs-0.2.0-cp314-cp314-manylinux_2_31_aarch64.whl
  • Upload date:
  • Size: 328.0 kB
  • Tags: CPython 3.14, manylinux: glibc 2.31+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.16 {"installer":{"name":"uv","version":"0.9.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for mscl_rs-0.2.0-cp314-cp314-manylinux_2_31_aarch64.whl
Algorithm Hash digest
SHA256 11871f4abbce73527b3fe4fce24e9cc0a77ddbd9bbfca28d2754b8029159f4fd
MD5 935aac2e554091b2ec2afdd683ad85f5
BLAKE2b-256 eea48be249680073a8a8480c8102ab5fd7942da9bdad6a85d132770da845dd2c

See more details on using hashes here.

File details

Details for the file mscl_rs-0.2.0-cp313-cp313-manylinux_2_34_x86_64.whl.

File metadata

  • Download URL: mscl_rs-0.2.0-cp313-cp313-manylinux_2_34_x86_64.whl
  • Upload date:
  • Size: 386.5 kB
  • Tags: CPython 3.13, manylinux: glibc 2.34+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.16 {"installer":{"name":"uv","version":"0.9.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for mscl_rs-0.2.0-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 23c1b98f49bbaaf9a47baa2927cebdb5a4dd9f167dd91550b1b5b629231c2ded
MD5 2e10c463028532ca646ecb13a9063f35
BLAKE2b-256 43b4c22c52eeceff2c7d60e733b0aabf3e02c48b25c282b1d2447cc723c7ab1c

See more details on using hashes here.

File details

Details for the file mscl_rs-0.2.0-cp313-cp313-manylinux_2_31_aarch64.whl.

File metadata

  • Download URL: mscl_rs-0.2.0-cp313-cp313-manylinux_2_31_aarch64.whl
  • Upload date:
  • Size: 329.2 kB
  • Tags: CPython 3.13, manylinux: glibc 2.31+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.16 {"installer":{"name":"uv","version":"0.9.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for mscl_rs-0.2.0-cp313-cp313-manylinux_2_31_aarch64.whl
Algorithm Hash digest
SHA256 ff57bb61d50a6cec101b1ebd6a525d6ae1da01c4c73cc4f8302e8d87682fa031
MD5 926c503127369a8cf82e80463650ff6d
BLAKE2b-256 d33b0257995887c9f083335d0053ed8c7279600ba0dc3c11b42672873752ea92

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