Trait socketcan::frame::Frame

source ·
pub trait Frame: EmbeddedFrame {
    // Required methods
    fn id_word(&self) -> canid_t;
    fn set_id(&mut self, id: impl Into<Id>);
    fn set_data(&mut self, data: &[u8]) -> Result<(), ConstructionError>;

    // Provided methods
    fn from_raw_id(id: u32, data: &[u8]) -> Option<Self> { ... }
    fn remote_from_raw_id(id: u32, dlc: usize) -> Option<Self> { ... }
    fn raw_id(&self) -> canid_t { ... }
    fn id_flags(&self) -> IdFlags { ... }
    fn hal_id(&self) -> Id { ... }
    fn len(&self) -> usize { ... }
    fn is_error_frame(&self) -> bool { ... }
}
Expand description

Shared trait for CAN frames

Required Methods§

source

fn id_word(&self) -> canid_t

Get the composite SocketCAN ID word, with EFF/RTR/ERR flags

source

fn set_id(&mut self, id: impl Into<Id>)

Sets the CAN ID for the frame

source

fn set_data(&mut self, data: &[u8]) -> Result<(), ConstructionError>

Sets the data payload of the frame.

Provided Methods§

source

fn from_raw_id(id: u32, data: &[u8]) -> Option<Self>

Creates a frame using a raw, integer CAN ID.

If the id is <= 0x7FF, it’s assumed to be a standard ID, otherwise it is created as an Extened ID. If you require an Etended ID <= 0x7FF, use new().

source

fn remote_from_raw_id(id: u32, dlc: usize) -> Option<Self>

Creates a remote frame using a raw, integer CAN ID.

If the id is <= 0x7FF, it’s assumed to be a standard ID, otherwise it is created as an Extened ID. If you require an Etended ID <= 0x7FF, use new_remote().

source

fn raw_id(&self) -> canid_t

Return the actual raw CAN ID (without EFF/RTR/ERR flags)

source

fn id_flags(&self) -> IdFlags

Returns the EFF/RTR/ERR flags from the ID word

source

fn hal_id(&self) -> Id

Return the CAN ID as the embedded HAL Id type.

source

fn len(&self) -> usize

Get the data length

source

fn is_error_frame(&self) -> bool

Check if frame is an error message

Object Safety§

This trait is not object safe.

Implementors§