Crate sbus_rs

Source
Expand description

§sbus-rs

A no_std compatible library for parsing SBUS (Serial Bus) protocol, commonly used in RC (Radio Control) systems. SBUS is a protocol developed by Futaba for RC receivers to communicate with flight controllers and other devices.

§Features

  • blocking: Enables blocking I/O operations (enabled by default)
  • async: Enables async I/O operations
  • std: Enables standard library features

§Example

use sbus_rs::{SbusParser, SbusPacket};
use embedded_io_adapters::std::FromStd;
use std::io::Cursor;

let data = [0x0F, /* ... SBUS frame data ... */ 0x00];
let cursor = Cursor::new(data);
let mut parser = SbusParser::new(FromStd::new(cursor));

match parser.read_frame() {
    Ok(packet) => {
        println!("Channel 1 value: {}", packet.channels[0]);
        if packet.flags.failsafe {
            println!("Failsafe active!");
        }
    }
    Err(e) => println!("Error reading frame: {:?}", e),
}

§Protocol Details

SBUS frames are 25 bytes long with the following structure:

  • Start byte (0x0F)
  • 22 bytes of channel data (16 channels, 11 bits each)
  • 1 byte of flags
  • End byte (0x00)

Modules§

blocking

Structs§

Flags
Status flags contained in an SBUS frame
Parser
SbusPacket
Represents a complete SBUS packet with channel data and flags
SbusParser
Parser for reading SBUS frames from a blocking I/O source
SbusParserAsync

Enums§

SbusError
Error types for SBUS operations

Constants§

CHANNEL_COUNT
The number of channels in a SBus Frame.
CHANNEL_MAX
The maximum value of a channel.
SBUS_FOOTER
The SBus Frame footer should end with a zero byte 0x00 (0 decimal).
SBUS_FRAME_LENGTH
The SBus Frame length
SBUS_HEADER
The SBus Frame header should start with 0x0F byte (15 decimal).

Traits§

Mode

Functions§

channels_parsing
pack_channels