Skip to main content

ClassicFrame

Struct ClassicFrame 

Source
pub struct ClassicFrame(/* private fields */);
Expand description

A frame that is known to be classic CAN, for code written against embedded-can.

embedded_can::Frame promises at most 8 bytes of data, which a Frame cannot keep: a 64-byte FD frame is a Frame too. The trait is therefore implemented on this type, which the trait constructors build directly and which TryFrom<Frame> refuses to make from an FD frame.

The type dereferences to the Frame it wraps and converts back into one for CanFd::transmit.

Implementations§

Source§

impl ClassicFrame

Source

pub fn into_frame(self) -> Frame

Returns the frame this wraps.

Methods from Deref<Target = Frame>§

Source

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.

Source

pub fn payload(&self) -> &[u8]

Returns the payload the frame carries.

Source

pub fn len(&self) -> usize

Returns the payload length in bytes.

Source

pub fn is_empty(&self) -> bool

Returns whether the frame carries no payload.

Source

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.

Source

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.

Source

pub fn id(&self) -> Id

Returns the arbitration identifier.

Source

pub fn is_extended(&self) -> bool

Returns whether the identifier is a 29-bit extended one.

Source

pub fn is_request(&self) -> bool

Returns whether this is a request frame, which carries no payload.

Source

pub fn is_fd(&self) -> bool

Returns whether the frame uses the CAN FD format.

Source

pub fn is_bit_rate_switched(&self) -> bool

Returns whether the data phase uses the FD bit rate.

Source

pub fn error_state_indicator(&self) -> bool

Returns the error state indicator of the transmitting node.

Source

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§

Source§

impl Clone for ClassicFrame

Available on crate feature unstable only.
Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable)§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for ClassicFrame

Available on crate feature unstable only.
Source§

impl Debug for ClassicFrame

Available on crate feature unstable only.
Source§

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

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

impl Deref for ClassicFrame

Available on crate feature unstable only.
Source§

type Target = Frame

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Frame

Dereferences the value.
Source§

impl Frame for ClassicFrame

Available on crate feature unstable only.

§Stability

This API is marked as unstable and is only available when the unstable crate feature is enabled. This comes with no stability guarantees, and could be changed or removed at any time.

Source§

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

Creates a new frame. Read more
Source§

fn new_remote(id: impl Into<Id>, dlc: usize) -> Option<Self>

Creates a new remote frame (RTR bit set). Read more
Source§

fn is_extended(&self) -> bool

Returns true if this frame is a extended frame.
Source§

fn is_remote_frame(&self) -> bool

Returns true if this frame is a remote frame.
Source§

fn id(&self) -> Id

Returns the frame identifier.
Source§

fn dlc(&self) -> usize

Returns the data length code (DLC) which is in the range 0..8. Read more
Source§

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

Returns the frame data (0..8 bytes in length).
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 From<ClassicFrame> for Frame

Available on crate feature unstable only.
Source§

fn from(frame: ClassicFrame) -> Self

Converts to this type from the input type.
Source§

impl TryFrom<Frame> for ClassicFrame

Available on crate feature unstable only.
Source§

fn try_from(frame: Frame) -> Result<Self, FrameError>

§Errors

FrameError::NotClassic when the frame uses the CAN FD format.

Source§

type Error = FrameError

The type returned in the event of a conversion error.

Auto Trait Implementations§

§

impl Freeze for ClassicFrame

§

impl RefUnwindSafe for ClassicFrame

§

impl Send for ClassicFrame

§

impl Sync for ClassicFrame

§

impl Unpin for ClassicFrame

§

impl UnsafeUnpin for ClassicFrame

§

impl UnwindSafe for ClassicFrame

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

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

§

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
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

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

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.