Struct canadensis_can::Frame

source ·
pub struct Frame<I> { /* private fields */ }
Expand description

CAN or CAN FD data frame with up to 64 bytes of data and an extended 29-bit ID

RTR/Error frames are not used and therefore not modeled here. CAN frames with 11-bit ID are not used by Cyphal/CAN and so they are not supported by the library.

Loopback

Each frame has a loopback flag.

For an outgoing frame, if loopback is true the driver should place a copy of this frame in the received frame path (as if it had been received on the bus) with the copy’s timestamp set to the time the frame was transmitted.

For an incoming frame, if loopback is true this frame was not actually received from another device. The frame timestamp is the time the original frame was sent.

This is useful for time synchronization.

Implementations§

source§

impl<I> Frame<I>

source

pub fn new(timestamp: I, id: CanId, data: &[u8]) -> Self

Creates a frame

The loopback flag is set to false.

Panics

This function will panic if the length of data is greater than FRAME_CAPACITY.

source

pub fn set_timestamp(&mut self, timestamp: I)

Sets the timestamp

source

pub fn set_loopback(&mut self, loopback: bool)

Sets the loopback flag

source

pub fn loopback(&self) -> bool

Returns the loopback flag

source

pub fn id(&self) -> CanId

Returns the ID of this frame

source

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

Returns the data in this frame

source§

impl<I: Clone> Frame<I>

source

pub fn timestamp(&self) -> I

Returns the timestamp when this frame was received (for incoming frames) or the transmission deadline (for outgoing frames)

Trait Implementations§

source§

impl<I: Clone> Clone for Frame<I>

source§

fn clone(&self) -> Frame<I>

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<I: Debug> Debug for Frame<I>

source§

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

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

impl<I: Default> Default for Frame<I>

source§

fn default() -> Frame<I>

Returns the “default value” for a type. Read more
source§

impl<I: PartialEq> PartialEq<Frame<I>> for Frame<I>

source§

fn eq(&self, other: &Frame<I>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<I> StructuralPartialEq for Frame<I>

Auto Trait Implementations§

§

impl<I> RefUnwindSafe for Frame<I>where I: RefUnwindSafe,

§

impl<I> Send for Frame<I>where I: Send,

§

impl<I> Sync for Frame<I>where I: Sync,

§

impl<I> Unpin for Frame<I>where I: Unpin,

§

impl<I> UnwindSafe for Frame<I>where I: UnwindSafe,

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,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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.
const: unstable · 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.
const: unstable · source§

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

Performs the conversion.