Crates.io | sbus-rs |
lib.rs | sbus-rs |
version | |
source | src |
created_at | 2024-11-07 18:54:28.852832 |
updated_at | 2024-11-07 21:02:23.655789 |
description | A no_std compatible SBUS protocol parser for embedded systems |
homepage | |
repository | https://github.com/Ragarnoy/sbus-rs |
max_upload_size | |
id | 1440049 |
Cargo.toml error: | TOML parse error at line 19, column 1 | 19 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
A no_std compatible Rust implementation of the SBUS (Serial Bus) protocol parser, commonly used in RC (Radio Control) applications. Part of the AeroRust organization, dedicated to aerospace-related software in Rust.
no_std
compatible for embedded systemsAdd this to your Cargo.toml
:
[dependencies]
sbus-rs = "0.1.0"
For async support:
[dependencies]
sbus-rs = { version = "0.1.0", features = ["async"] }
use sbus_rs::{SbusParser, SbusError};
use embedded_io_adapters::std::FromStd;
fn main() -> Result<(), SbusError> {
let serial = /* your serial port */;
let mut parser = SbusParser::new(FromStd::new(serial));
// Read a single SBUS frame
let frame = parser.read_frame()?;
// Access channel values (0-2047)
println!("Channel 1: {}", frame.channels[0]);
// Check flags
if frame.flags.failsafe {
println!("Failsafe active!");
}
Ok(())
}
use sbus_rs::{SbusParserAsync, SbusError};
use embedded_io_adapters::tokio_1::FromTokio;
async fn read_sbus() -> Result<(), SbusError> {
let serial = /* your async serial port */;
let mut parser = SbusParserAsync::new(FromTokio::new(serial));
// Read frames asynchronously
let frame = parser.read_frame().await?;
println!("Channels: {:?}", frame.channels);
println!("Frame lost: {}", frame.flags.frame_lost);
Ok(())
}
SBUS frames consist of:
Channel values range from 0 to 2047 (11 bits).
Flag bits:
The library is optimized for performance with careful consideration of:
Benchmarks are available and can be run with:
cargo bench
Contributions are welcome! Please feel free to submit a Pull Request. Make sure to:
cargo test --all-features
cargo bench
cargo clippy --all-features
cargo fmt
The crate uses safe Rust and includes:
This project is licensed under the MIT License - see the LICENSE file for details.
Part of the AeroRust organization, promoting the use of Rust in aerospace applications.
Special thanks to: