Struct socketcan::frame::CanFdFrame

source ·
pub struct CanFdFrame(/* private fields */);
Expand description

The CAN flexible data rate frame with up to 64-bytes of data.

This is highly compatible with the canfd_frame from libc. (ref)

Implementations§

source§

impl CanFdFrame

source

pub fn with_flags( id: impl Into<Id>, data: &[u8], flags: FdFlags ) -> Option<Self>

Create a new FD frame with FD flags

source

pub fn flags(&self) -> FdFlags

Gets the flags for the FD frame.

These are the bits from the separate FD frame flags, not the flags in the composite ID word.

source

pub fn is_brs(&self) -> bool

Whether the frame uses a bit rate switch (second bit rate for payload data).

source

pub fn set_brs(&mut self, on: bool)

Sets whether the frame uses a bit rate switch.

source

pub fn is_esi(&self) -> bool

Gets the error state indicator of the transmitting node

source

pub fn set_esi(&mut self, on: bool)

Sets the error state indicator of the transmitting node

Trait Implementations§

source§

impl AsPtr for CanFdFrame

source§

fn as_ptr(&self) -> *const Self::Inner

Gets a pointer to the CAN frame structure that is compatible with the Linux C API.

source§

fn as_mut_ptr(&mut self) -> *mut Self::Inner

Gets a mutable pointer to the CAN frame structure that is compatible with the Linux C API.

§

type Inner = canfd_frame

The inner type to which we resolve as a pointer
source§

fn size(&self) -> usize

The size of the inner type
source§

impl AsRef<canfd_frame> for CanFdFrame

source§

fn as_ref(&self) -> &canfd_frame

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl Clone for CanFdFrame

source§

fn clone(&self) -> CanFdFrame

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for CanFdFrame

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for CanFdFrame

source§

fn default() -> Self

The default FD frame has all fields and data set to zero, and all flags off.

source§

impl Frame for CanFdFrame

source§

fn new(id: impl Into<Id>, data: &[u8]) -> Option<Self>

Create a new FD frame

source§

fn new_remote(_id: impl Into<Id>, _dlc: usize) -> Option<Self>

CAN FD frames don’t support remote

source§

fn is_extended(&self) -> bool

Check if frame uses 29-bit extended ID format.

source§

fn is_remote_frame(&self) -> bool

The FD frames don’t support remote request

source§

fn id(&self) -> Id

Return the frame identifier.

source§

fn dlc(&self) -> usize

Data length code

source§

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

A slice into the actual data.

For normal CAN frames the slice will always be <= 8 bytes in length.

source§

fn is_standard(&self) -> bool

Returns true if this frame is a standard frame.
source§

fn is_data_frame(&self) -> bool

Returns true if this frame is a data frame.
source§

impl Frame for CanFdFrame

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.

source§

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

Creates a frame using a raw, integer CAN ID. Read more
source§

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

Creates a remote frame using a raw, integer CAN ID. Read more
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
source§

impl From<CanDataFrame> for CanFdFrame

source§

fn from(frame: CanDataFrame) -> Self

Converts to this type from the input type.
source§

impl From<CanFdFrame> for CanAnyFrame

source§

fn from(frame: CanFdFrame) -> Self

Converts to this type from the input type.
source§

impl From<canfd_frame> for CanFdFrame

source§

fn from(frame: canfd_frame) -> Self

Converts to this type from the input type.
source§

impl TryFrom<CanFdFrame> for CanDataFrame

§

type Error = ConstructionError

The type returned in the event of a conversion error.
source§

fn try_from(frame: CanFdFrame) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<CanFdFrame> for CanFrame

source§

fn try_from( frame: CanFdFrame ) -> Result<Self, <Self as TryFrom<CanFdFrame>>::Error>

Try to convert a CAN FD frame into a classic CAN 2.0 frame.

This should work if it’s a data frame with 8 or fewer data bytes.

§

type Error = ConstructionError

The type returned in the event of a conversion error.
source§

impl UpperHex for CanFdFrame

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter.
source§

impl Copy for CanFdFrame

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> ControllerSpecificErrorInformation for Twhere T: Frame,

source§

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

Get the controller specific error information.

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.