Thanks to visit codestin.com
Credit goes to docs.rs

CanFdFrame

Struct 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)

Payload data that is greater than 8 bytes and whose data length does not match a valid CANFD data length is padded with 0 bytes to the next higher valid CANFD data length.

Note:

  • The FDF flag is forced on when created.

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

Source

pub fn is_valid_data_len(len: usize) -> bool

Checks whether a given length is a valid CANFD data length.

Valid values are 0 - 8, 12, 16, 20, 24, 32, 48 or 64.

Source

pub fn next_valid_ext_dlen(len: usize) -> usize

Returns the next larger valid CANFD extended data length into which the given length fits, up to a maximum of CANFD_MAX_DLEN.

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.

Source§

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§

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

Gets a byte slice to the inner type
Source§

fn as_bytes_mut(&mut self) -> &[u8]

Gets a mutable byte slice to 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 duplicate 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.

This should only be one of the valid CAN FD data lengths.

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 len(&self) -> usize

Get the data length

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 can_id(&self) -> CanId

Return the CAN ID.
Source§

fn hal_id(&self) -> Id

Return the CAN ID as the embedded HAL Id type.
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<CanAnyFrame> for CanFdFrame

Source§

type Error = ConstructionError

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

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

Performs the conversion.
Source§

impl TryFrom<CanFdFrame> for CanDataFrame

Source§

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.

Source§

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. Read more
Source§

impl Copy for CanFdFrame

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> ControllerSpecificErrorInformation for T
where 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 T
where 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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 T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.