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
parser.start()  # Starts a background thread to collect data

try:
    while True:
        packets = parser.get_data_packets(block=True)  # Block until data is available
        for packet in packets:
            print(packet)
except KeyboardInterrupt:
    pass
finally:
    parser.stop()

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

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/*

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.1.0.tar.gz (611.8 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.1.0-cp314-cp314t-manylinux_2_34_x86_64.whl (382.5 kB view details)

Uploaded CPython 3.14tmanylinux: glibc 2.34+ x86-64

mscl_rs-0.1.0-cp314-cp314t-manylinux_2_31_aarch64.whl (325.9 kB view details)

Uploaded CPython 3.14tmanylinux: glibc 2.31+ ARM64

mscl_rs-0.1.0-cp314-cp314-manylinux_2_34_x86_64.whl (3.5 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.34+ x86-64

mscl_rs-0.1.0-cp314-cp314-manylinux_2_31_aarch64.whl (326.3 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.31+ ARM64

mscl_rs-0.1.0-cp313-cp313-manylinux_2_34_x86_64.whl (382.8 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ x86-64

mscl_rs-0.1.0-cp313-cp313-manylinux_2_31_aarch64.whl (327.0 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.31+ ARM64

File details

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

File metadata

  • Download URL: mscl_rs-0.1.0.tar.gz
  • Upload date:
  • Size: 611.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.15 {"installer":{"name":"uv","version":"0.9.15","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.1.0.tar.gz
Algorithm Hash digest
SHA256 88e3a0b79f436c6a408ef58236e0025ea3a4a0eaf31ebf03433514518d9e48c8
MD5 6aa28c565decc41cde62d74419d0bfb9
BLAKE2b-256 c8949fe96db7e6b7e95665b65c6c7297c97c9de2a0ed765694558d9bda208d7d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mscl_rs-0.1.0-cp314-cp314t-manylinux_2_34_x86_64.whl
  • Upload date:
  • Size: 382.5 kB
  • Tags: CPython 3.14t, manylinux: glibc 2.34+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.15 {"installer":{"name":"uv","version":"0.9.15","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.1.0-cp314-cp314t-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 3a91045ee49049f8a75f0761d8f73c883bc0f00b24926c7700b5ac00a7e0e591
MD5 cb4636762053c4a807dde7afaff8bbe4
BLAKE2b-256 f9f287189aed7be2d73c71eedae164d609a4147fd3a2dce81c6be4b9d18657ca

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mscl_rs-0.1.0-cp314-cp314t-manylinux_2_31_aarch64.whl
  • Upload date:
  • Size: 325.9 kB
  • Tags: CPython 3.14t, manylinux: glibc 2.31+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.15 {"installer":{"name":"uv","version":"0.9.15","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.1.0-cp314-cp314t-manylinux_2_31_aarch64.whl
Algorithm Hash digest
SHA256 1b97837106b42ec00f6f90ed9b0e5ff32e4f36f21b0c9c6d9928f411a6f219e6
MD5 7e3f2a2a1f953e60b4bb302cc2fff668
BLAKE2b-256 5ac5a324dee2b5734023ba2d6ded300341019a1813d00287fbdc2b8694c142b1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mscl_rs-0.1.0-cp314-cp314-manylinux_2_34_x86_64.whl
  • Upload date:
  • Size: 3.5 MB
  • Tags: CPython 3.14, manylinux: glibc 2.34+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.15 {"installer":{"name":"uv","version":"0.9.15","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.1.0-cp314-cp314-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 dfd522a0e423f24623acc1ce2084503dc461a1ae8381c77c6a2aa8a8cab6651f
MD5 916cfa4f19cdbe965020296c7b9f4ce4
BLAKE2b-256 f35a1262eaadebdc7aed0ab9b0cdd840d403443ef29a9b5c1ba2216fc2ad124c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mscl_rs-0.1.0-cp314-cp314-manylinux_2_31_aarch64.whl
  • Upload date:
  • Size: 326.3 kB
  • Tags: CPython 3.14, manylinux: glibc 2.31+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.15 {"installer":{"name":"uv","version":"0.9.15","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.1.0-cp314-cp314-manylinux_2_31_aarch64.whl
Algorithm Hash digest
SHA256 ca7a0b9d7e1847e4ffc4a1b578e59877f004fc8a4460f64da9577b11edcc4de5
MD5 f3181652a3d455b7ef9fdbd0faef65be
BLAKE2b-256 6e9ae21341aef324e729f35a96ee7aafa56f52de6ac64e30ce18a4a0e811a0b6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mscl_rs-0.1.0-cp313-cp313-manylinux_2_34_x86_64.whl
  • Upload date:
  • Size: 382.8 kB
  • Tags: CPython 3.13, manylinux: glibc 2.34+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.15 {"installer":{"name":"uv","version":"0.9.15","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.1.0-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 d27d507e5315e4f8044afedd5547bcd8f8039e82aa7ddfd5a74868a824a1c1ca
MD5 13308526bd0160625497abbd3924b960
BLAKE2b-256 c8f488d7b26f0ea46a0a8852870c59d7c10f752eb7b6a5013dbf13433a03996d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mscl_rs-0.1.0-cp313-cp313-manylinux_2_31_aarch64.whl
  • Upload date:
  • Size: 327.0 kB
  • Tags: CPython 3.13, manylinux: glibc 2.31+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.15 {"installer":{"name":"uv","version":"0.9.15","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.1.0-cp313-cp313-manylinux_2_31_aarch64.whl
Algorithm Hash digest
SHA256 4f5e83fa39a218fb65dca90ad6d73f6b21c3e65b59b35708d3e8a2978daf5bb8
MD5 18ae2caf9f6993c8ec44b301687c09a3
BLAKE2b-256 ce3ee8a5fd7041dee391370db11b029727951d93dacf4a64f16691663f2befcc

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