A lightweight Rust library for seamlessly parsing and editing DBC (CAN Database) files, with robust support for encoding and decoding messages and signals.
- Zero dependencies - Pure Rust, no external runtime dependencies
- no_std compatible - Works on embedded targets (Cortex-M, RISC-V)
- Flexible memory - Heap (
alloc) or stack (heapless) allocation - Memory safe -
forbid(unsafe_code)enforced - Full read/write - Parse, modify, and serialize DBC files
[dependencies]
dbc-rs = "0.1"use dbc_rs::Dbc;
// Parse DBC content
let dbc = Dbc::parse(dbc_content)?;
// Decode a CAN frame (ID 0x100, 8 bytes, standard 11-bit ID)
let signals = dbc.decode(0x100, &frame_data, false)?;
for signal in signals {
println!("{}: {:.2} {}", signal.name, signal.value, signal.unit);
}use dbc_rs::Dbc;
let dbc = Dbc::parse(dbc_content)?;
// Encode signal values into a CAN frame payload
let payload = dbc.encode(0x100, &[
("RPM", 2500.0),
("Temperature", 85.0),
])?;[dependencies]
dbc-rs = { version = "0.1", default-features = false, features = ["heapless"] }See examples/ for complete working examples:
decode.rs- Signal decoding basicsdecode_frame.rs- Usingembedded-canFrame traitencode.rs- Encoding signals to CAN payloadscreate_dbc.rs- Building DBC files programmaticallyparse_std.rs/parse_no_std.rs- Parsing in different environments
| Feature | Description | Default |
|---|---|---|
std |
Standard library with builders | Yes |
alloc |
Heap allocation | Via std |
heapless |
Stack-only for no_std |
No |
embedded-can |
embedded-can crate integration |
No |
- API Reference
- ARCHITECTURE.md - Internal design
- SPECIFICATIONS.md - DBC format reference
- SECURITY.md - Security audit
MIT OR Apache-2.0. See LICENSING.md.