OSCP IMU Rust Library
oscp-imu is a Rust crate for communicating with OSCP MK2 IMU units. It decodes
the operating frames emitted by the unit and encodes the command set for both
supported transports: RS422 (byte stream) and CAN-FD (message based).
https://github.com/OSCPS/oscp-imu-rs
Build & install
The crate is distributed as a Git dependency. It is not yet published on crates.io.
Dependencies
| Crate | Source | Role |
|---|---|---|
oscp-imu |
https://github.com/OSCPS/oscp-imu-rs.git |
Library crate |
cobs |
crates.io, resolved by Cargo | COBS encoding and decoding |
serde |
crates.io, resolved by Cargo, optional | Serialize implementations for decoded types |
Add it to your project
-
Add the dependency to
Cargo.toml:[dependencies] oscp-imu = { git = "https://github.com/OSCPS/oscp-imu-rs.git" } -
To derive
serde::Serializeon frames and command responses, enable theserdefeature:[dependencies] oscp-imu = { git = "https://github.com/OSCPS/oscp-imu-rs.git", features = ["serde"] } -
For reproducible builds, pin a commit with
rev = "<commit>". - Import items from the crate root:
use oscp_imu::{OscpParser, OscpFrame, OscpTransport};
Requirements
Rust 1.85 or later (edition 2024). Fields are decoded with
from_le_bytes, so the crate is independent of host byte order.
Features
-
No dynamic allocation
Parser state is held in a caller-owned
OscpParsercontaining fixed-size arrays. The crate usescoreonly and does not allocate, so it isno_std-compatible. -
Two transports, one frame type
A byte-stream parser for RS422 and a stateless decode function for CAN-FD. Both return
OscpFrame. -
Frame coverage
Raw, Euler, Quaternion, Rotation Matrix, GNSS, Debug 1/2 and Startup frames are decoded into typed structs.
-
Command set
16 commands, encoded for either transport. Each argument is a typed enum.
-
Integrity checks
CRC-16 on every frame. COBS framing on RS422.
-
Error handling
Fallible functions return
Result. The RS422 parser counts dropped frames inOscpStats.
Supported hardware
| Model | Description |
|---|---|
| MK2M2 | OSCP Tactical-Grade MEMS IMU |
| MK2E2 | OSCP Tactical-Grade MEMS + Optical Gyroscope IMU |
| MK2Z | OSCP Navigation-Grade MEMS + Optical Gyroscope IMU |
Documentation map
-
RS422 byte-stream parser and CAN-FD message decoder.
-
Operating frames, field by field, with types and units.
-
Commands, state classes and argument enumerations.
-
Public functions, types and errors.
-
RS422 and CAN-FD reception, and command transmission.
Revision
This documentation tracks oscp-imu v0.1.0.