Struct socketcan::frame::CanErrorFrame
source · 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
impl CanErrorFrame
sourcepub fn new_error(
can_id: canid_t,
data: &[u8]
) -> Result<Self, ConstructionError>
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.
sourcepub fn error_bits(&self) -> u32
pub fn error_bits(&self) -> u32
Return the error bits from the ID word of the error frame.
sourcepub fn into_error(self) -> CanError
pub fn into_error(self) -> CanError
Converts this error frame into a CanError
Trait Implementations§
source§impl AsPtr for CanErrorFrame
impl AsPtr for CanErrorFrame
source§impl AsRef<can_frame> for CanErrorFrame
impl AsRef<can_frame> for CanErrorFrame
source§impl Clone for CanErrorFrame
impl Clone for CanErrorFrame
source§fn clone(&self) -> CanErrorFrame
fn clone(&self) -> CanErrorFrame
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for CanErrorFrame
impl Debug for CanErrorFrame
source§impl Frame for CanErrorFrame
impl Frame for CanErrorFrame
source§fn set_id(&mut self, _id: impl Into<Id>)
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>
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>
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 Frame for CanErrorFrame
impl Frame for CanErrorFrame
source§fn new(id: impl Into<Id>, data: &[u8]) -> Option<Self>
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>
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
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
Check if frame is a remote transmission request.
source§fn is_data_frame(&self) -> bool
fn is_data_frame(&self) -> bool
Check if frame is a data frame.
source§fn data(&self) -> &[u8] ⓘ
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
fn is_standard(&self) -> bool
source§impl From<CanError> for CanErrorFrame
impl From<CanError> for CanErrorFrame
source§impl From<CanErrorFrame> for CanError
impl From<CanErrorFrame> for CanError
source§fn from(frame: CanErrorFrame) -> Self
fn from(frame: CanErrorFrame) -> Self
Constructs a CAN error from an error frame.
source§impl From<CanErrorFrame> for CanFrame
impl From<CanErrorFrame> for CanFrame
source§fn from(frame: CanErrorFrame) -> Self
fn from(frame: CanErrorFrame) -> Self
Create a CanFrame
from an error frame
source§impl From<CanErrorFrame> for Error
impl From<CanErrorFrame> for Error
source§fn from(frame: CanErrorFrame) -> Self
fn from(frame: CanErrorFrame) -> Self
source§impl TryFrom<can_frame> for CanErrorFrame
impl TryFrom<can_frame> for CanErrorFrame
source§impl UpperHex for CanErrorFrame
impl UpperHex for CanErrorFrame
impl Copy for CanErrorFrame
Auto Trait Implementations§
impl RefUnwindSafe for CanErrorFrame
impl Send for CanErrorFrame
impl Sync for CanErrorFrame
impl Unpin for CanErrorFrame
impl UnwindSafe for CanErrorFrame
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> 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.