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§
const PACKET_SIZE: usize = PACKET_SIZE
Required Methods§
sourcefn set_client(&self, client: Option<&'static dyn ReceiveClient<PACKET_SIZE>>)
fn set_client(&self, client: Option<&'static dyn ReceiveClient<PACKET_SIZE>>)
Set the client to be used for callbacks of the Receive
implementation.
sourcefn start_receive_process(
&self,
buffer: &'static mut [u8; PACKET_SIZE],
) -> Result<(), (ErrorCode, &'static mut [u8; PACKET_SIZE])>
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 themessage_received
callback function to receive dataErr(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
sourcefn stop_receive(&self) -> Result<(), ErrorCode>
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 thestopped
callback function after this commandErr(ErrorCode)
- Indicates the error because of which the request cannot be completed
Object Safety§
This trait is not object safe.