pub struct QueueOnlyDriver<I, const TC: usize, const RC: usize> { /* private fields */ }
Expand description

A driver that contains frame queues only, and requires external code to actually send and receive messages

This may be useful on embedded devices that do not have a hardware-managed queue of incoming frames. A high-priority interrupt handler can read frames from the CAN peripheral into another queue, and then pass them to this driver when there are no incoming frames waiting.

To transmit frames, this driver stores an ArrayQueue that lets external code remove frames and send them to a CAN peripheral.

Type parameters:

  • I: A time instant
  • TC: The transmit queue capacity, in frames
  • RC: The receive queue capacity, in frames

Filters

When a driver calls apply_filters(), this struct stores a Vec of the current subscriptions. External code should get these subscriptions using the subscriptions() function and manually send them to the CAN driver.

Implementations§

source§

impl<I: Default + Clone, const TC: usize, const RC: usize> QueueOnlyDriver<I, TC, RC>

source

pub fn new() -> Self

Creates a driver

source

pub fn push_rx_frame(&mut self, frame: Frame<I>) -> Result<(), OutOfMemoryError>

Pushes a received frame onto the back of the receive queue

The frame can be retrieved using the receive() function.

source

pub fn pop_tx_frame(&mut self) -> Option<Frame<I>>

Removes and returns a frame from the front of the transmit queue

source

pub fn return_tx_frame( &mut self, frame: Frame<I> ) -> Result<(), OutOfMemoryError>

Returns a frame to the front of the transmit queue

The frame will be moved back beyond any other frames already in the queue that have higher priority.

source

pub fn subscriptions(&self) -> Option<&[Subscription]>

Returns the subscriptions provided in the last call to apply_filters()

This function returns None if empty_filters() has not been called, was called with no subscriptions, or was called but an out-of-memory error occurred while collecting the subscriptions

Trait Implementations§

source§

impl<I: Default, const TC: usize, const RC: usize> Default for QueueOnlyDriver<I, TC, RC>

source§

fn default() -> Self

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

impl<C: Clock, const TC: usize, const RC: usize> ReceiveDriver<C> for QueueOnlyDriver<C::Instant, TC, RC>

§

type Error = Infallible

The error type
source§

fn receive(&mut self, _clock: &mut C) -> Result<Frame<C::Instant>, Self::Error>

Attempts to receive a frame without blocking
source§

fn apply_filters<S>( &mut self, _local_node: Option<CanNodeId>, new_subscriptions: S )where S: IntoIterator<Item = Subscription>,

Sets up frame reception filters to accept only frames matching the provided subscriptions Read more
source§

fn apply_accept_all(&mut self)

Sets up frame reception filters to accept all incoming frames
source§

impl<C: Clock, const TC: usize, const RC: usize> TransmitDriver<C> for QueueOnlyDriver<C::Instant, TC, RC>where C::Instant: Default,

§

type Error = Infallible

The error type
source§

fn try_reserve(&mut self, frames: usize) -> Result<(), OutOfMemoryError>

Attempts to reserve space to transmit frames additional frames Read more
source§

fn transmit( &mut self, frame: Frame<C::Instant>, _clock: &mut C ) -> Result<Option<Frame<C::Instant>>, Self::Error>

Attempts to send a frame without blocking Read more
source§

fn flush(&mut self, _clock: &mut C) -> Result<(), Self::Error>

Attempts to flush all frames out of any in-memory queues that may exist and transmit them

Auto Trait Implementations§

§

impl<I, const TC: usize, const RC: usize> RefUnwindSafe for QueueOnlyDriver<I, TC, RC>where I: RefUnwindSafe,

§

impl<I, const TC: usize, const RC: usize> Send for QueueOnlyDriver<I, TC, RC>where I: Send,

§

impl<I, const TC: usize, const RC: usize> Sync for QueueOnlyDriver<I, TC, RC>where I: Sync,

§

impl<I, const TC: usize, const RC: usize> Unpin for QueueOnlyDriver<I, TC, RC>where I: Unpin,

§

impl<I, const TC: usize, const RC: usize> UnwindSafe for QueueOnlyDriver<I, TC, RC>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, 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.