Struct CanFrame
pub struct CanFrame {
pub id: u32,
pub flags: FrameFlags,
pub len: u8,
/* private fields */
}Expand description
Unified CAN frame: covers both classical CAN (8-byte payload) and CAN-FD (up to 64-byte payload).
The inline [u8; 64] payload buffer is sized for CAN-FD’s maximum DLC;
classical frames use only the first 8 bytes and pay ~56 bytes of latent
memory in exchange for full upper-layer agnosticism between classical and
FD. See openspec/changes/walking-skeleton-single-arm/design.md Decision 14.
Fields§
§id: u32CAN identifier (11-bit base or 29-bit extended; see FrameFlags::EXTENDED_ID).
flags: FrameFlagsMetadata bits (FD/BRS/ESI/EXTENDED/RTR).
len: u8Payload length in bytes. len <= 8 for classical, len <= 64 for FD.
Implementations§
§impl CanFrame
impl CanFrame
pub fn classical(id: u32, payload: &[u8]) -> Result<CanFrame, FrameError>
pub fn classical(id: u32, payload: &[u8]) -> Result<CanFrame, FrameError>
Construct a classical CAN frame with an 11-bit base identifier.
pub fn classical_extended(
id: u32,
payload: &[u8],
) -> Result<CanFrame, FrameError>
pub fn classical_extended( id: u32, payload: &[u8], ) -> Result<CanFrame, FrameError>
Construct a classical CAN frame with a 29-bit extended identifier.
pub fn fd(id: u32, payload: &[u8]) -> Result<CanFrame, FrameError>
pub fn fd(id: u32, payload: &[u8]) -> Result<CanFrame, FrameError>
Construct a CAN-FD frame. Length must be a valid FD DLC; BRS is set by default.
pub fn fd_extended(id: u32, payload: &[u8]) -> Result<CanFrame, FrameError>
pub fn fd_extended(id: u32, payload: &[u8]) -> Result<CanFrame, FrameError>
Construct a CAN-FD frame with a 29-bit extended identifier.
pub fn from_parts(
id: u32,
flags: FrameFlags,
payload: &[u8],
) -> Result<CanFrame, FrameError>
pub fn from_parts( id: u32, flags: FrameFlags, payload: &[u8], ) -> Result<CanFrame, FrameError>
Construct a frame from raw fields. Performs the flag-compatibility
validation that CanFrame::classical / CanFrame::fd enforce
automatically.
pub fn is_fd(&self) -> bool
pub fn is_fd(&self) -> bool
True iff FrameFlags::FD_FORMAT is set.
pub fn is_extended(&self) -> bool
pub fn is_extended(&self) -> bool
True iff FrameFlags::EXTENDED_ID is set.
Trait Implementations§
impl Copy for CanFrame
impl Eq for CanFrame
impl StructuralPartialEq for CanFrame
Auto Trait Implementations§
impl Freeze for CanFrame
impl RefUnwindSafe for CanFrame
impl Send for CanFrame
impl Sync for CanFrame
impl Unpin for CanFrame
impl UnsafeUnpin for CanFrame
impl UnwindSafe for CanFrame
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.