Trait kernel::hil::can::Receive

source ·
pub trait Receive<const PACKET_SIZE: usize> {
    const PACKET_SIZE: usize = PACKET_SIZE;

    // Required methods
    fn set_client(
        &self,
        client: Option<&'static dyn ReceiveClient<PACKET_SIZE>>
    );
    fn start_receive_process(
        &self,
        buffer: &'static mut [u8; PACKET_SIZE]
    ) -> Result<(), (ErrorCode, &'static mut [u8; PACKET_SIZE])>;
    fn stop_receive(&self) -> Result<(), ErrorCode>;
}
Expand description

The Receive trait is used to interact with the CAN driver through receive requests only.

The CAN peripheral must be configured first, in order to be able to send data.

Provided Associated Constants§

source

const PACKET_SIZE: usize = PACKET_SIZE

Required Methods§

source

fn set_client(&self, client: Option<&'static dyn ReceiveClient<PACKET_SIZE>>)

Set the client to be used for callbacks of the Receive implementation.

source

fn start_receive_process( &self, buffer: &'static mut [u8; PACKET_SIZE] ) -> Result<(), (ErrorCode, &'static mut [u8; PACKET_SIZE])>

Start receiving messaged on the CAN bus.

In most cases, this function should be called after the peripheral was previously configured. When calling this function, there MUST be no filters enabled by the user. The implementation of this function MUST permit receiving frames on all available receiving FIFOs.

Arguments:
  • buffer - A buffer to store the data
Return values:
  • Ok() - The receive request was successful and the caller waits for the message_received callback function to receive data
  • Err(ErrorCode, &'static mut [u8]) - tuple with the error that occurred during the reception request and the buffer that was received as an argument to the function
source

fn stop_receive(&self) -> Result<(), ErrorCode>

Asks the driver to stop receiving messages. This function should be called only after a call to the start_receive_process function.

Return values:
  • Ok() - The request was successful an the caller waits for the stopped callback function after this command
  • Err(ErrorCode) - Indicates the error because of which the request cannot be completed

Object Safety§

This trait is not object safe.

Implementors§