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);Sourcepub fn sender(&self) -> &str
pub fn sender(&self) -> &str
Get the sender node name for this message.
The sender is the node that transmits this message on the CAN bus.
§Examples
use dbc_rs::Dbc;
let dbc = Dbc::parse(r#"VERSION "1.0"
BU_: ECM TCM
BO_ 256 Engine : 8 ECM
SG_ RPM : 0|16@1+ (0.25,0) [0|8000] "rpm" *
"#)?;
let message = dbc.messages().iter().next().unwrap();
assert_eq!(message.sender(), "ECM");Source§impl Message
impl Message
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§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)