Expand description
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());
Structs§
- Maps channel values to the ones that betaflight uses(1000->2000)
- Stores LinkStatistics packet data
- Crossfire packet parser
- Stores raw packet data
- Stores RcChannelsPacked packet data
- Maps channels according to a ChannelMapper
Enums§
- Represents different kinds of packets
- Represents packet addresses
- Represents packet errors
- Crossfire packet types
Constants§
- Max crsf packet length
- Crsf packet header length
Traits§
- Trait for mapping channel values