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
impl CanFdFrame
Sourcepub fn with_flags(
id: impl Into<Id>,
data: &[u8],
flags: FdFlags,
) -> Option<Self>
pub fn with_flags( id: impl Into<Id>, data: &[u8], flags: FdFlags, ) -> Option<Self>
Create a new FD frame with FD flags
Sourcepub fn flags(&self) -> FdFlags
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.
Sourcepub fn is_brs(&self) -> bool
pub fn is_brs(&self) -> bool
Whether the frame uses a bit rate switch (second bit rate for payload data).
Sourcepub fn is_valid_data_len(len: usize) -> bool
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
.
Sourcepub fn next_valid_ext_dlen(len: usize) -> usize
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
impl AsPtr for CanFdFrame
Source§fn as_ptr(&self) -> *const Self::Inner
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
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
type Inner = canfd_frame
Source§fn as_bytes_mut(&mut self) -> &[u8] ⓘ
fn as_bytes_mut(&mut self) -> &[u8] ⓘ
Source§impl AsRef<canfd_frame> for CanFdFrame
impl AsRef<canfd_frame> for CanFdFrame
Source§fn as_ref(&self) -> &canfd_frame
fn as_ref(&self) -> &canfd_frame
Source§impl Clone for CanFdFrame
impl Clone for CanFdFrame
Source§fn clone(&self) -> CanFdFrame
fn clone(&self) -> CanFdFrame
1.0.0 · 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 Frame for CanFdFrame
impl Frame for CanFdFrame
Source§fn new_remote(_id: impl Into<Id>, _dlc: usize) -> Option<Self>
fn new_remote(_id: impl Into<Id>, _dlc: usize) -> Option<Self>
CAN FD frames don’t support remote
Source§fn is_extended(&self) -> bool
fn is_extended(&self) -> bool
Check if frame uses 29-bit extended ID format.
Source§fn is_remote_frame(&self) -> bool
fn is_remote_frame(&self) -> bool
The FD frames don’t support remote request
Source§fn data(&self) -> &[u8] ⓘ
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
fn is_standard(&self) -> bool
Source§fn is_data_frame(&self) -> bool
fn is_data_frame(&self) -> bool
Source§impl Frame for CanFdFrame
impl Frame for CanFdFrame
Source§fn set_data(&mut self, data: &[u8]) -> Result<(), ConstructionError>
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>
fn from_raw_id(id: u32, data: &[u8]) -> Option<Self>
Source§fn remote_from_raw_id(id: u32, dlc: usize) -> Option<Self>
fn remote_from_raw_id(id: u32, dlc: usize) -> Option<Self>
Source§fn is_error_frame(&self) -> bool
fn is_error_frame(&self) -> bool
Source§impl From<CanDataFrame> for CanFdFrame
impl From<CanDataFrame> for CanFdFrame
Source§fn from(frame: CanDataFrame) -> Self
fn from(frame: CanDataFrame) -> Self
Source§impl From<CanFdFrame> for CanAnyFrame
impl From<CanFdFrame> for CanAnyFrame
Source§fn from(frame: CanFdFrame) -> Self
fn from(frame: CanFdFrame) -> Self
Source§impl From<canfd_frame> for CanFdFrame
impl From<canfd_frame> for CanFdFrame
Source§fn from(frame: canfd_frame) -> Self
fn from(frame: canfd_frame) -> Self
Source§impl TryFrom<CanAnyFrame> for CanFdFrame
impl TryFrom<CanAnyFrame> for CanFdFrame
Source§type Error = ConstructionError
type Error = ConstructionError
Source§impl TryFrom<CanFdFrame> for CanDataFrame
impl TryFrom<CanFdFrame> for CanDataFrame
Source§type Error = ConstructionError
type Error = ConstructionError
Source§impl TryFrom<CanFdFrame> for CanFrame
impl TryFrom<CanFdFrame> for CanFrame
Source§fn try_from(
frame: CanFdFrame,
) -> Result<Self, <Self as TryFrom<CanFdFrame>>::Error>
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
type Error = ConstructionError
Source§impl UpperHex for CanFdFrame
impl UpperHex for CanFdFrame
impl Copy for CanFdFrame
Auto Trait Implementations§
impl Freeze for CanFdFrame
impl RefUnwindSafe for CanFdFrame
impl Send for CanFdFrame
impl Sync for CanFdFrame
impl Unpin for CanFdFrame
impl UnwindSafe for CanFdFrame
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,
Source§impl<T> ControllerSpecificErrorInformation for Twhere
T: Frame,
impl<T> ControllerSpecificErrorInformation for Twhere
T: Frame,
Source§fn get_ctrl_err(&self) -> Option<&[u8]>
fn get_ctrl_err(&self) -> Option<&[u8]>
Get the controller specific error information.
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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