embassy
embassy copied to clipboard
Dropping a BufferedUarte after writing to it hangs.
In the following example "after write" is printed but "after drop" is never reached. All the read methods also block forever but while that could be an issue on my end, blocking forever on drop seems very unexpected so I raised this issue.
#[embassy::main]
async fn main(_spawner: Spawner) {
let mut p = unsafe { Peripherals::steal() };
let mut irq = interrupt::take!(UARTE0_UART0);
loop {
let mut tx_buffer = [0u8; 4096];
let mut rx_buffer = [0u8; 4096];
{
let mut config = uarte::Config::default();
config.parity = uarte::Parity::EXCLUDED;
config.baudrate = uarte::Baudrate::BAUD115200;
let uart = unsafe {
BufferedUarte::new(
&mut p.UARTE0,
&mut p.TIMER0,
&mut p.PPI_CH0,
&mut p.PPI_CH1,
&mut irq,
&mut p.P1_05,
&mut p.P1_04,
&mut p.P1_07,
&mut p.P1_06,
config,
&mut rx_buffer,
&mut tx_buffer,
)
};
info!("uart initialized!");
pin_mut!(uart);
Timer::after(Duration::from_millis(1000)).await;
info!("before write");
uart.write_all(b"AT\r\n").await.unwrap();
info!("after write");
}
info!("after drop");
}
}
This is kinda "known", but it should be fixed yup. UARTE disabling is super tricky.
https://github.com/embassy-rs/embassy/blob/master/embassy-nrf/src/buffered_uarte.rs#L271