[−][src]Crate can_dbc
A CAN database (dbc) format parser written with Rust's nom parser combinator library. CAN databases are used to exchange details about a CAN network. E.g. what messages are being send over the CAN bus and what data do they contain.
use can_dbc::DBC; use codegen::Scope; use std::fs::File; use std::io; use std::io::prelude::*; fn main() -> io::Result<()> { let mut f = File::open("./examples/sample.dbc")?; let mut buffer = Vec::new(); f.read_to_end(&mut buffer)?; let dbc = can_dbc::DBC::from_slice(&buffer).expect("Failed to parse dbc file"); let mut scope = Scope::new(); for message in dbc.messages() { for signal in message.signals() { let mut scope = Scope::new(); let message_struct = scope.new_struct(message.message_name()); for signal in message.signals() { message_struct.field(signal.name().to_lowercase().as_str(), "f64"); } } } println!("{}", scope.to_string()); Ok(()) }
Modules
parser | Module containing nom parser combinators |
Structs
AttrDefault | |
AttributeDefault | |
AttributeValueForObject | |
Baudrate | Baudrate of network in kbit/s |
DBC | |
EnvironmentVariable | |
EnvironmentVariableData | |
Message | CAN message (frame) details including signal details |
MessageId | CAN id in header of CAN frame. Must be unique in DBC file. |
MessageTransmitter | |
Node | CAN network nodes, names must be unique |
Signal | One or multiple signals are the payload of a CAN frame.
To determine the actual value of a signal the following fn applies:
|
SignalExtendedValueTypeList | |
SignalGroups | Signal groups define a group of signals within a message |
SignalType | |
SignalTypeRef | |
Symbol | |
ValDescription | |
ValueTable | Global value table |
Version | Version generated by DB editor |
Enums
AccessNode | |
AccessType | |
AttributeDefinition | |
AttributeValue | |
AttributeValueType | |
AttributeValuedForObjectType | |
ByteOrder | |
Comment | Object comments |
EnvType | |
Error | Possible error cases for |
MultiplexIndicator | |
SignalAttributeValue | |
SignalExtendedValueType | |
Transmitter | |
ValueDescription | Encoding for signal raw values. |
ValueType |