OSCP IMU C Library
oscp-imu-c is a portable, dependency-light C library for communicating with
OSCP MK2 IMU units. It decodes every operating frame the unit emits and encodes
the full command set, over both transports the family supports: streamed
RS422 and framed CAN-FD.
https://github.com/OSCPS/oscp-imu-c
Build & install
The library is small enough to drop straight into your build - no package manager required. Copy four files into your source tree and compile them alongside your own code.
What you need
Four files:
| File | From | Role |
|---|---|---|
oscp_imu.h |
repository root | Library header |
oscp_imu.c |
repository root | Library implementation |
cobs.h |
third-party/cobs-c/ |
Craig McQueen COBS dependency (header) |
cobs.c |
third-party/cobs-c/ |
Craig McQueen COBS dependency (implementation) |
Add it to your project
- Copy the four files into your source tree (e.g. a
third-party/oscp-imu-c/folder). - Compile
oscp_imu.candcobs.cas part of your build. - Add the folders holding
oscp_imu.handcobs.hto your include path. - Include the one public header:
#include "oscp_imu.h"
That's the whole installation.
Requirements
A C compiler (GCC, Clang or MSVC) and a little-endian target
(Cortex-M, x86, ARM64). Decoding is a memcpy into packed structs, which
is correct only when host and wire byte orders match.
Big-endian targets fail to compile - by design
A #error guard in oscp_imu.h stops the build on big-endian hosts. To
support one, replace the decode_* functions with explicit byte-swap
helpers. Reach out to OSCP if you need this.
Why this library
-
Zero dynamic allocation
All parser state lives in a caller-owned
oscp_parser_t. Nothing usesmalloc- safe for bare-metal and RTOS targets. -
Two transports, one decoder
A byte-stream parser for RS422 and a single stateless call for CAN-FD. Both produce the same
oscp_frame_t. -
Full frame coverage
Raw, Euler, Quaternion, Rotation Matrix, GNSS, Debug 1/2 and Startup frames are decoded into typed structs.
-
Complete command set
17 commands encoded for either transport, with enumerations for every argument.
-
Integrity built in
CRC-16 validation on every frame, plus COBS framing on the RS422 path.
-
Genuinely portable
Builds with GCC, Clang and MSVC. Runs on Cortex-M, x86 and ARM64.
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
-
Choose between the RS422 byte-stream parser and the CAN-FD message decoder.
-
Every operating frame, field by field, with units and bytes layout.
-
All 17 commands, their state classes, and the argument enumerations.
-
Every public function, type and return code in one place.
-
Copy-paste starting points for RS422, CAN-FD and command transmission.
Version
This documentation tracks oscp-imu-c v0.2.0.