Simplify example

This commit is contained in:
chemicstry 2022-05-26 14:11:15 +03:00
parent 4b6162694a
commit 667abe6d1d

View File

@ -26,13 +26,11 @@ async fn main(_spawner: Spawner, p: Peripherals) {
unsafe { BufferedUart::new(&mut state, usart, irq, &mut tx_buf, &mut rx_buf) }; unsafe { BufferedUart::new(&mut state, usart, irq, &mut tx_buf, &mut rx_buf) };
loop { loop {
let n = { let buf = buf_usart.fill_buf().await.unwrap();
let buf = buf_usart.fill_buf().await.unwrap(); info!("Received: {}", buf);
info!("Received: {}", buf);
buf.len()
};
// Read bytes have to be explicitly consumed, otherwise fill_buf() will return them again // Read bytes have to be explicitly consumed, otherwise fill_buf() will return them again
let n = buf.len();
buf_usart.consume(n); buf_usart.consume(n);
} }
} }