Crate ucpack

Source
Expand description

§ucpack docs.rs

Rust implementation of the ucpack serialization format used in the Arduino Alvik using serde.

This crate does not implement the body API itself, but rather the binary protocol and format it uses to encode its messages.

§The crate

This crate exposes a struct called UcPack which you can initialize to start encoding and decoding serde compatible data types and structures.

[!WARNING] Not every type is compatible with ucpack. Namely any integer above 16 bits, lists and maps.

You can also const initialize UcPack and use it const-ly from anywhere if carrying state isn’t an option:

const packer: UcPack = UcPack::new(b'A', b'#');

fn main() {
    packer.serialize_slice(...); // ecc..
}

§The protocol

NOTE: Table gently borrowed from ucpack’s c++ repo

A packet is managed as:

index_bytemessage lengthmessagestop_bytecrc8
1 byte (default A)1 byteN bytes from message length1 byte (default #)1 byte

This crate, opposed to the c++ and micropython respectives, is agnostic across the message content (referred to by the name payload in this crate).

Modules§

Structs§

Enums§

Functions§

  • Calculates a CRC8 checksum over any u8 iterator
  • Helper function to calculate crc8 over byte slices
  • Check a buffer for a message. This method is useful during hardware interrupts, to check whether the received data is a readble message or more data has yet to arrive