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 |
#54 in #packet-parser
28KB
678 lines
crsf-rs
This crate provides a #[no_std] parser for the crossfire protocol.
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.5–1MB
~22K SLoC