Skip to main content

Crate rm_frame

Crate rm_frame 

Source
Expand description

A lightweight binary framing protocol library.

This crate provides a minimal, allocation-free framing layer designed for embedded and resource-constrained environments. It focuses on deterministic binary encoding, checksum validation, and zero-copy decoding.

§Architecture Overview

  • Validator Defines CRC algorithms used to validate frames.

  • DjiValidator A concrete validator using DJI-compatible CRC8 and CRC16.

  • Marshaler Describes how a typed payload is serialized into bytes and deserialized from raw payload data.

  • Messager Implements frame packing and unpacking, combining framing, validation, and payload marshaling.

  • RawFrame A validated, zero-copy view of a decoded frame.

§Typical Usage

  1. Implement Marshaler for your message types
  2. Create a Messager with a chosen Validator
  3. Use pack to encode frames
  4. Use unpack to decode frames into RawFrame
  5. Use Marshaler to convert RawFrame payloads to typed messages

§Frame Layout

+--------+--------+--------+--------+--------+---------+--------+
|  SOF   |  LEN   |  SEQ   |  CRC8  | CMD_ID |  DATA   | CRC16  |
+--------+--------+--------+--------+--------+---------+--------+
| 1 byte | 2 byte | 1 byte | 1 byte | 2 byte | N bytes | 2 byte |
+--------+--------+--------+--------+--------+---------+--------+

§Protocol Source

See RoboMaster Resources Hub for official documentation and protocol details: RMU Communication Protocol

Structs§

DjiValidator
DJI protocol CRC validator.
Messager
Frame encoder and decoder.
RawFrame
A validated, undecoded frame.

Enums§

MarshalerError
Errors returned by Marshaler::marshal, Marshaler::unmarshal, and RawFrame::unmarshal.
PackError
Errors returned by Messager::pack.
UnPackError
Errors returned by Messager::unpack and Messager::unmarshal.

Traits§

ImplCommandMsg
Provides the command ID and payload size constants for a message type.
ImplMarshal
Payload serialization half of Marshaler.
ImplUnMarshal
Payload deserialization half of Marshaler.
Marshaler
Payload marshaling interface.
Validator
CRC validator abstraction for the frame protocol.

Functions§

calc_dji8
Calculate CRC8-DJI Checksum
calc_dji16
Calculate CRC16-DJI Checksum