This commit is contained in:
rafael 2024-07-14 16:42:54 +02:00
parent 08f1454527
commit c7f775dc20

View File

@ -436,6 +436,12 @@ impl<'d> BufferedUartRx<'d> {
}
}
/// we are ready to read if there is data in the buffer
fn read_ready() -> Result<bool, Error> {
let state = T::buffered_state();
Ok(!state.rx_buf.is_empty())
}
/// Reconfigure the driver
pub fn set_config(&mut self, config: &Config) -> Result<(), ConfigError> {
reconfigure(self.info, self.kernel_clock, config)?;
@ -610,6 +616,18 @@ impl<'d> embedded_io_async::Read for BufferedUartRx<'d> {
}
}
impl<'d> embedded_io_async::ReadReady for BufferedUart<'d> {
fn read_ready(&mut self) -> Result<bool, Self::Error> {
BufferedUartRx::<'d>::read_ready()
}
}
impl<'d> embedded_io_async::ReadReady for BufferedUartRx<'d> {
fn read_ready(&mut self) -> Result<bool, Self::Error> {
Self::read_ready()
}
}
impl<'d> embedded_io_async::BufRead for BufferedUart<'d> {
async fn fill_buf(&mut self) -> Result<&[u8], Self::Error> {
self.rx.fill_buf().await