Struct canadensis_can::queue::QueueOnlyDriver
source · 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 instantTC
: The transmit queue capacity, in framesRC
: 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>
impl<I: Default + Clone, const TC: usize, const RC: usize> QueueOnlyDriver<I, TC, RC>
sourcepub fn push_rx_frame(&mut self, frame: Frame<I>) -> Result<(), OutOfMemoryError>
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.
sourcepub fn pop_tx_frame(&mut self) -> Option<Frame<I>>
pub fn pop_tx_frame(&mut self) -> Option<Frame<I>>
Removes and returns a frame from the front of the transmit queue
sourcepub fn return_tx_frame(
&mut self,
frame: Frame<I>
) -> Result<(), OutOfMemoryError>
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.
sourcepub fn subscriptions(&self) -> Option<&[Subscription]>
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<C: Clock, const TC: usize, const RC: usize> ReceiveDriver<C> for QueueOnlyDriver<C::Instant, TC, RC>
impl<C: Clock, const TC: usize, const RC: usize> ReceiveDriver<C> for QueueOnlyDriver<C::Instant, TC, RC>
§type Error = Infallible
type Error = Infallible
source§fn receive(&mut self, _clock: &mut C) -> Result<Frame<C::Instant>, Self::Error>
fn receive(&mut self, _clock: &mut C) -> Result<Frame<C::Instant>, Self::Error>
source§fn apply_filters<S>(
&mut self,
_local_node: Option<CanNodeId>,
new_subscriptions: S
)where
S: IntoIterator<Item = Subscription>,
fn apply_filters<S>( &mut self, _local_node: Option<CanNodeId>, new_subscriptions: S )where S: IntoIterator<Item = Subscription>,
source§fn apply_accept_all(&mut self)
fn apply_accept_all(&mut self)
source§impl<C: Clock, const TC: usize, const RC: usize> TransmitDriver<C> for QueueOnlyDriver<C::Instant, TC, RC>where
C::Instant: Default,
impl<C: Clock, const TC: usize, const RC: usize> TransmitDriver<C> for QueueOnlyDriver<C::Instant, TC, RC>where C::Instant: Default,
§type Error = Infallible
type Error = Infallible
source§fn try_reserve(&mut self, frames: usize) -> Result<(), OutOfMemoryError>
fn try_reserve(&mut self, frames: usize) -> Result<(), OutOfMemoryError>
frames
additional frames Read more