Trait kernel::hil::uart::ReceiveAdvanced

source ·
pub trait ReceiveAdvanced<'a>: Receive<'a> {
    // Required method
    fn receive_automatic(
        &self,
        rx_buffer: &'static mut [u8],
        rx_len: usize,
        interbyte_timeout: u8,
    ) -> Result<(), (ErrorCode, &'static mut [u8])>;
}
Expand description

Trait with optional UART features that certain hardware may support.

The operations in this trait are not required for basic UART operation, but provide useful abstractions that capsules may want to be able to leverage.

The interfaces are included here because some hardware platforms may be able to directly implement them, while others platforms may need to emulate them in software. The ones that can implement them in hardware should be able to leverage that efficiency, and by placing the interfaces here in the HIL they can do that.

Other interface ideas that have been discussed, but are not included due to the lack of a clear use case, but are noted here in case they might help someone in the future:

  • receive_until_terminator(): This would read in bytes until a specified byte is received (or the buffer is full) and then return to the client.
  • receive_len_then_message(): This would do a one byte read to get a length byte and then read that many more bytes from UART before returning to the client.

Required Methods§

source

fn receive_automatic( &self, rx_buffer: &'static mut [u8], rx_len: usize, interbyte_timeout: u8, ) -> Result<(), (ErrorCode, &'static mut [u8])>

Receive data until interbyte_timeout bit periods have passed since the last byte or buffer is full.

This does not timeout until at least one byte has been received.

§Arguments:
  • rx_buffer: Buffer to receive into.
  • rx_len: Maximum number of bytes to receive.
  • interbyte_timeout: number of bit periods to wait between bytes before returning.
§Return values
  • Ok(()): Receive was started correctly. [ReceiveClient::received_buffer] will be called.
  • Err(OFF): The underlying hardware is not available, perhaps because it has not been initialized or in the case of a shared hardware USART controller because it is set up for SPI.
  • Err(BUSY): the UART is already receiving and has not made a reception callback yet.
  • Err(SIZE): rx_len is larger than the passed slice.

Implementors§