pub struct Frame { /* private fields */ }Expand description
A CAN FD frame.
Implementations§
Source§impl Frame
impl Frame
Sourcepub fn new(id: impl Into<Id>, payload: &[u8]) -> Result<Self, FrameError>
pub fn new(id: impl Into<Id>, payload: &[u8]) -> Result<Self, FrameError>
Creates a new classic CAN data frame.
§Errors
FrameError::PayloadTooLong when payload is longer than 8 bytes.
Sourcepub fn new_request(id: impl Into<Id>, len: usize) -> Result<Self, FrameError>
pub fn new_request(id: impl Into<Id>, len: usize) -> Result<Self, FrameError>
Creates a new classic CAN request frame.
A request frame carries no payload. len is the payload length that the
frame asks for.
§Errors
FrameError::PayloadTooLong when len is greater than 8.
Sourcepub fn new_fd(id: impl Into<Id>, payload: &[u8]) -> Result<Self, FrameError>
pub fn new_fd(id: impl Into<Id>, payload: &[u8]) -> Result<Self, FrameError>
Creates a new CAN FD data frame.
The data phase uses the nominal bit rate unless
Frame::with_bit_rate_switch is set.
§Errors
FrameError::PayloadTooLong when payload is longer than 64 bytes.
Sourcepub fn with_bit_rate_switch(self, bit_rate_switch: bool) -> Self
pub fn with_bit_rate_switch(self, bit_rate_switch: bool) -> Self
Sets whether the data phase is sent at the FD bit rate.
Only a CAN FD frame can switch bit rate; the setting is ignored on a classic frame.
Sourcepub fn requested_len(&self) -> usize
pub fn requested_len(&self) -> usize
Returns the payload length a request frame asks for, in bytes.
Zero for a data frame, whose length is Frame::len.
Sourcepub fn dlc(&self) -> u8
pub fn dlc(&self) -> u8
Returns the data length code the frame is sent with.
A payload length that no code expresses is padded up to the next one,
so a received copy of the frame can be longer than Frame::len.
Sourcepub fn is_extended(&self) -> bool
pub fn is_extended(&self) -> bool
Returns whether the identifier is a 29-bit extended one.
Sourcepub fn is_request(&self) -> bool
pub fn is_request(&self) -> bool
Returns whether this is a request frame, which carries no payload.
Sourcepub fn is_bit_rate_switched(&self) -> bool
pub fn is_bit_rate_switched(&self) -> bool
Returns whether the data phase uses the FD bit rate.
Sourcepub fn error_state_indicator(&self) -> bool
pub fn error_state_indicator(&self) -> bool
Returns the error state indicator of the transmitting node.
Sourcepub fn timestamp(&self) -> u64
pub fn timestamp(&self) -> u64
Returns the timestamp captured when the frame was received.
Zero for a frame that was not received; see
CanFd::start_timestamp_timer.
Trait Implementations§
impl Copy for Frame
unstable only.Source§impl From<ClassicFrame> for Frame
Available on crate feature unstable only.
impl From<ClassicFrame> for Frame
unstable only.Source§fn from(frame: ClassicFrame) -> Self
fn from(frame: ClassicFrame) -> Self
Source§impl TryFrom<Frame> for ClassicFrame
Available on crate feature unstable only.
impl TryFrom<Frame> for ClassicFrame
unstable only.Source§fn try_from(frame: Frame) -> Result<Self, FrameError>
fn try_from(frame: Frame) -> Result<Self, FrameError>
§Errors
FrameError::NotClassic when the frame uses the CAN FD format.
Source§type Error = FrameError
type Error = FrameError
Auto Trait Implementations§
impl Freeze for Frame
impl RefUnwindSafe for Frame
impl Send for Frame
impl Sync for Frame
impl Unpin for Frame
impl UnsafeUnpin for Frame
impl UnwindSafe for Frame
Blanket Implementations§
§impl<T> Any for Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)