#parser #packet-parser #protocols #crossfire

crsf

This crate provides a #[no_std] parser for the crossfire protocol

5 releases (3 stable)

2.0.1 Apr 15, 2024
2.0.0 Apr 3, 2024
1.0.1 Feb 22, 2024
0.2.0 Feb 4, 2024
0.1.0 Oct 13, 2023

#41 in #packet-parser

Download history 283/week @ 2024-02-18 42/week @ 2024-02-25 5/week @ 2024-03-03 7/week @ 2024-03-10 30/week @ 2024-03-17 2/week @ 2024-03-24 121/week @ 2024-03-31 14/week @ 2024-04-07 130/week @ 2024-04-14

272 downloads per month

MIT license

28KB
678 lines

crsf-rs

This crate provides a #[no_std] parser for the crossfire protocol.

CRSF protocol specification

Examples

Check out the examples directory.

Documentation

Not available yet.

License

Licensed under the MIT License.

Contribution

Feel free to contribute code, as the project it's still a work in progress.


lib.rs:

This crate provides a #[no_std] parser for the crossfire protocol.

Usage

Packet Parsing

use crsf::{PacketParser, PacketAddress, PacketType};

let mut parser = PacketParser::<1024>::new();

// Sync
parser.push_bytes(&[PacketAddress::Controller as u8]);
// Len
parser.push_bytes(&[24]);
// Type
parser.push_bytes(&[PacketType::RcChannelsPacked as u8]);
// Payload
parser.push_bytes(&[0; 22]);
// Checksum
parser.push_bytes(&[239]);

while let Some(Ok((dest, packet))) = parser.next_packet() {
    println!("{:?} {:?}", dest, packet);
}

Packet Construction

use crsf::{Packet, PacketAddress, RcChannels};

let channels: [u16; 16] = [0xffff; 16];
let packet = Packet::RcChannels(RcChannels(channels));
let raw_packet = packet.into_raw(PacketAddress::Transmitter);
println!("{:?}", raw_packet.data());

Dependencies

~0.6–1MB
~23K SLoC