Skip to main content

TxFrameIo

Trait TxFrameIo 

Source
pub trait TxFrameIo {
    type Frame;
    type Error;

    // Required methods
    fn send(&mut self, frame: &Self::Frame) -> Result<(), Self::Error>;
    fn try_send(&mut self, frame: &Self::Frame) -> Result<(), Self::Error>;
    fn send_timeout(
        &mut self,
        frame: &Self::Frame,
        timeout: Duration,
    ) -> Result<(), Self::Error>;
}
Expand description

Transmit-side (blocking) CAN frame I/O.

This is the minimal interface a protocol needs to send frames. You can implement it for a full CAN controller type, or for a dedicated “TX half” returned by SplitTxRx.

Required Associated Types§

Source

type Frame

The CAN frame type.

Most implementations use a concrete frame type from a driver crate; it must represent a CAN frame (including ID, DLC, payload) and is typically also an embedded_can::Frame.

Source

type Error

Error returned by the driver implementation.

Required Methods§

Source

fn send(&mut self, frame: &Self::Frame) -> Result<(), Self::Error>

Send a frame, blocking until it is accepted by the driver.

Source

fn try_send(&mut self, frame: &Self::Frame) -> Result<(), Self::Error>

Attempt to send a frame without blocking.

When the driver cannot accept a frame immediately (e.g. no TX mailbox), implementations typically return an error such as nb::Error::WouldBlock.

Source

fn send_timeout( &mut self, frame: &Self::Frame, timeout: Duration, ) -> Result<(), Self::Error>

Send a frame, waiting up to timeout for the driver to accept it.

Implementations that cannot support timeouts may treat this as TxFrameIo::send.

Implementors§