Skip to main content

CanFrameExt

Trait CanFrameExt 

Source
pub trait CanFrameExt {
    // Required method
    fn as_bytes(&self) -> &[u8];

    // Provided methods
    fn id_word(&self) -> Option<u32> { ... }
    fn dlc(&self) -> Option<u8> { ... }
    fn data_bytes(&self) -> Option<&[u8]> { ... }
    fn is_extended_frame(&self) -> bool { ... }
    fn is_rtr(&self) -> bool { ... }
    fn is_error_frame(&self) -> bool { ... }
    fn can_id(&self) -> Option<Result<CanId, CanError>> { ... }
    fn validate(&self) -> Result<(), CanError> { ... }
    fn is_valid(&self) -> bool { ... }
    fn pci_offset(mode: &AddressMode) -> usize { ... }
    fn isotp_bytes(&self, mode: &IsoTpAddressingMode) -> Option<&[u8]> { ... }
}
Expand description

Byte layout of a raw classic CAN frame:

[0..=3] - 32-bit CAN ID word (big-endian) bit 31: extended frame flag (EFF) bit 30: remote transmission request (RTR) bit 29: error frame flag (ERR) bits 28-0: CAN ID (11-bit in bits 10-0 for standard, 29-bit in bits 28-0 for extended) [4] - DLC (0–8) [5..=12]- data bytes (0–8 bytes, DLC determines count)

Required Methods§

Source

fn as_bytes(&self) -> &[u8]

Provided Methods§

Source

fn id_word(&self) -> Option<u32>

Source

fn dlc(&self) -> Option<u8>

Source

fn data_bytes(&self) -> Option<&[u8]>

Source

fn is_extended_frame(&self) -> bool

Source

fn is_rtr(&self) -> bool

Source

fn is_error_frame(&self) -> bool

Source

fn can_id(&self) -> Option<Result<CanId, CanError>>

Source

fn validate(&self) -> Result<(), CanError>

Source

fn is_valid(&self) -> bool

Source

fn pci_offset(mode: &AddressMode) -> usize

Returns the PCI byte offset given the addressing mode.

Source

fn isotp_bytes(&self, mode: &IsoTpAddressingMode) -> Option<&[u8]>

Returns the data bytes available for ISO-TP PCI + payload given the addressing mode, or None if the frame is too short.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<'a> CanFrameExt for CanFrame<'a>

Source§

fn as_bytes(&self) -> &[u8]

Source§

impl<'a> CanFrameExt for CanFrameMut<'a>

Source§

fn as_bytes(&self) -> &[u8]

Implementors§