pub struct CanErrorFrame(/* private fields */);
Expand description

A SocketCAN error frame.

This is returned from a read/receive by the OS or interface device driver when it detects an error, such as a problem on the bus. The frame encodes detailed information about the error, which can be managed directly by the application or converted into a Rust error

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

Implementations§

source§

impl CanErrorFrame

source

pub fn new_error( can_id: canid_t, data: &[u8] ) -> Result<Self, ConstructionError>

Creates a CAN error frame from raw parts.

Note that an application would not normally ever create an error frame. This is included mainly to aid in implementing mocks and other tests for an application.

The data byte slice should have the necessary codes for the supplied error. They will be zero padded to a full frame of 8 bytes.

Also note:

  • The error flag is forced on
  • The other, non-error, flags are forced off
  • The frame data is always padded with zero’s to 8 bytes, regardless of the length of the data parameter provided.
source

pub fn error_bits(&self) -> u32

Return the error bits from the ID word of the error frame.

source

pub fn into_error(self) -> CanError

Converts this error frame into a CanError

Trait Implementations§

source§

impl AsPtr for CanErrorFrame

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 = can_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<can_frame> for CanErrorFrame

source§

fn as_ref(&self) -> &can_frame

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

impl Clone for CanErrorFrame

source§

fn clone(&self) -> CanErrorFrame

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 CanErrorFrame

source§

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

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

impl Frame for CanErrorFrame

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 This does nothing on an error frame.

source§

fn set_data(&mut self, _data: &[u8]) -> Result<(), ConstructionError>

Sets the data payload of the frame. This is an error on an error 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 Frame for CanErrorFrame

source§

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

Create an error frame.

Note that an application would not normally ever create an error frame. This is included mainly to aid in implementing mocks and other tests for an application.

This will set the error bit in the CAN ID word.

source§

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

The application should not create an error frame. This will always return None.

source§

fn is_extended(&self) -> bool

Check if frame uses 29-bit extended ID format.

source§

fn is_remote_frame(&self) -> bool

Check if frame is a remote transmission request.

source§

fn is_data_frame(&self) -> bool

Check if frame is a data frame.

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. An error frame can always acess the full 8-byte data payload.

source§

fn is_standard(&self) -> bool

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

impl From<CanError> for CanErrorFrame

source§

fn from(err: CanError) -> Self

Converts to this type from the input type.
source§

impl From<CanErrorFrame> for CanError

source§

fn from(frame: CanErrorFrame) -> Self

Constructs a CAN error from an error frame.

source§

impl From<CanErrorFrame> for CanFrame

source§

fn from(frame: CanErrorFrame) -> Self

Create a CanFrame from an error frame

source§

impl From<CanErrorFrame> for Error

source§

fn from(frame: CanErrorFrame) -> Self

Converts to this type from the input type.
source§

impl TryFrom<can_frame> for CanErrorFrame

source§

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

Try to create a CanErrorFrame from a C can_frame

This will only succeed the C frame is marked as an error frame.

§

type Error = ConstructionError

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

impl UpperHex for CanErrorFrame

source§

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

Formats the value using the given formatter.
source§

impl Copy for CanErrorFrame

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.