pub trait Transmit<const PACKET_SIZE: usize> {
const PACKET_SIZE: usize = PACKET_SIZE;
// Required methods
fn set_client(
&self,
client: Option<&'static dyn TransmitClient<PACKET_SIZE>>,
);
fn send(
&self,
id: Id,
buffer: &'static mut [u8; PACKET_SIZE],
len: usize,
) -> Result<(), (ErrorCode, &'static mut [u8; PACKET_SIZE])>;
}
Expand description
The Transmit
trait is used to interact with the CAN driver through transmission
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 TransmitClient<PACKET_SIZE>>)
fn set_client(&self, client: Option<&'static dyn TransmitClient<PACKET_SIZE>>)
Set the client to be used for callbacks of the Transmit
implementation.
Sourcefn send(
&self,
id: Id,
buffer: &'static mut [u8; PACKET_SIZE],
len: usize,
) -> Result<(), (ErrorCode, &'static mut [u8; PACKET_SIZE])>
fn send( &self, id: Id, buffer: &'static mut [u8; PACKET_SIZE], len: usize, ) -> Result<(), (ErrorCode, &'static mut [u8; PACKET_SIZE])>
Sends a buffer using the CAN bus.
In most cases, this function should be called after the peripheral was previously configures and at least one filter has been enabled.
§Arguments:
id
- The identifier of the message (standard or extended)buffer
- Data to be written on the buslen
- Length of the current message
§Return values:
Ok()
- The transmission request was successful and the caller will receive a for thetransmit_complete
callback function callErr(ErrorCode, &'static mut [u8])
- a tuple with the error that occurred during the transmission request and the buffer that was provided as an argument to the function
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.