pub struct Message { /* private fields */ }Expand description
Represents a CAN message in a DBC file.
A Message contains:
- A unique ID (CAN identifier)
- A name
- A DLC (Data Length Code) specifying the message size in bytes
- A sender node (ECU that transmits this message)
- A collection of signals
§Examples
use dbc_rs::Dbc;
let dbc_content = r#"VERSION "1.0"
BU_: ECM
BO_ 256 EngineData : 8 ECM
SG_ RPM : 0|16@0+ (0.25,0) [0|8000] "rpm" *
"#;
let dbc = Dbc::parse(dbc_content)?;
let message = dbc.messages().at(0).unwrap();
println!("Message: {} (ID: {})", message.name(), message.id());Implementations§
Source§impl Message
impl Message
Sourcepub fn id(&self) -> u32
pub fn id(&self) -> u32
Returns the CAN message ID.
§Examples
use dbc_rs::Dbc;
let dbc = Dbc::parse(r#"VERSION "1.0"\n\nBU_: ECM\n\nBO_ 256 EngineData : 8 ECM"#)?;
let message = dbc.messages().at(0).unwrap();
assert_eq!(message.id(), 256);Sourcepub fn name(&self) -> &str
pub fn name(&self) -> &str
Returns the message name.
§Examples
use dbc_rs::Dbc;
let dbc = Dbc::parse(r#"VERSION "1.0"\n\nBU_: ECM\n\nBO_ 256 EngineData : 8 ECM"#)?;
let message = dbc.messages().at(0).unwrap();
assert_eq!(message.name(), "EngineData");Sourcepub fn dlc(&self) -> u8
pub fn dlc(&self) -> u8
Returns the Data Length Code (DLC) in bytes.
DLC specifies the size of the message payload. For classic CAN, this is 1-8 bytes. For CAN FD, this can be up to 64 bytes.
§Examples
use dbc_rs::Dbc;
let dbc = Dbc::parse(r#"VERSION "1.0"\n\nBU_: ECM\n\nBO_ 256 EngineData : 8 ECM"#)?;
let message = dbc.messages().at(0).unwrap();
assert_eq!(message.dlc(), 8);pub fn sender(&self) -> &str
Sourcepub fn signals(&self) -> &SignalList
pub fn signals(&self) -> &SignalList
Get a reference to the signals collection
pub fn to_dbc_string(&self) -> String
pub fn to_string_full(&self) -> String
Trait Implementations§
impl Eq for Message
impl StructuralPartialEq for Message
Auto Trait Implementations§
impl Freeze for Message
impl RefUnwindSafe for Message
impl Send for Message
impl Sync for Message
impl Unpin for Message
impl UnwindSafe for Message
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more