#[non_exhaustive]pub struct CanFdFrame {
pub channel: Option<usize>,
pub arbitration_id: u32,
pub data: [u8; 64],
pub size: u8,
pub brs: Toggle,
pub fdcan_frame: Toggle,
}Expand description
A CAN-FD frame.
This structure represents a CAN-FD frame with only standard CAN fields:
arbitration ID, payload data, and CAN-FD options. Moteus-specific routing
(destination, source, can_prefix) is handled by the higher-level Command
type in the moteus crate.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.channel: Option<usize>Channel index identifying which transport device this frame was received from or should be sent to.
arbitration_id: u32CAN arbitration ID
data: [u8; 64]Frame payload data (up to 64 bytes for CAN-FD)
size: u8Actual size of data in the frame
brs: ToggleBit rate switch (BRS) toggle
fdcan_frame: ToggleFD frame format toggle
Implementations§
Source§impl CanFdFrame
impl CanFdFrame
Sourcepub fn payload_mut(&mut self) -> &mut [u8]
pub fn payload_mut(&mut self) -> &mut [u8]
Returns the payload data as a mutable slice.
Sourcepub fn clear_data(&mut self)
pub fn clear_data(&mut self)
Clears the frame data, keeping metadata.
Sourcepub fn remaining_capacity(&self) -> usize
pub fn remaining_capacity(&self) -> usize
Returns the remaining capacity in bytes.
Sourcepub fn brs_enabled(&self) -> bool
pub fn brs_enabled(&self) -> bool
Returns true if BRS (bit rate switching) should be enabled.
Sourcepub fn fdcan_enabled(&self) -> bool
pub fn fdcan_enabled(&self) -> bool
Returns true if FD CAN frame format should be used.
Sourcepub fn round_up_dlc(size: usize) -> usize
pub fn round_up_dlc(size: usize) -> usize
Rounds up a data length to the next valid CAN-FD DLC size.
Sourcepub fn pad_to_dlc(&mut self)
pub fn pad_to_dlc(&mut self)
Pads the frame data with 0x50 to the next valid CAN-FD DLC size.
Trait Implementations§
Source§impl Clone for CanFdFrame
impl Clone for CanFdFrame
Source§fn clone(&self) -> CanFdFrame
fn clone(&self) -> CanFdFrame
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CanFdFrame
impl Debug for CanFdFrame
Source§impl Default for CanFdFrame
impl Default for CanFdFrame
Source§impl PartialEq for CanFdFrame
impl PartialEq for CanFdFrame
Source§fn eq(&self, other: &CanFdFrame) -> bool
fn eq(&self, other: &CanFdFrame) -> bool
self and other values to be equal, and is used by ==.