-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Ok, I've got a weird situation.
I think what's happening is the following:
- I have a uart with a floating rx pin (sensor is disconnected)
- The RxStarted event fires:
embassy/embassy-nrf/src/buffered_uarte.rs
Line 113 in 2a79c55
if r.events_rxstarted().read() != 0 || !s.rx_started.load(Ordering::Relaxed) { - This allocates the part of the internal ring buffer:
embassy/embassy-nrf/src/buffered_uarte.rs
Line 167 in 2a79c55
rx.push_done(half_len);
- This allocates the part of the internal ring buffer:
- Then no rxdrdy event fires (because no valid bytes are received?)
- In my code I check:
embassy/embassy-nrf/src/buffered_uarte.rs
Lines 829 to 836 in 2a79c55
/// we are ready to read if there is data in the buffer fn read_ready(&self) -> Result<bool, Error> { let state = self.buffered_state; if state.rx_overrun.swap(false, Ordering::Acquire) { return Err(Error::Overrun); } Ok(!state.rx_buf.is_empty()) } - It returns true because we allocated in the buffer
- I then call read, expecting it to not block
- That checks the rxdrdy counter:
embassy/embassy-nrf/src/buffered_uarte.rs
Lines 774 to 776 in 2a79c55
// Read the RXDRDY counter. timer.cc(0).capture(); let mut end = timer.cc(0).read() as usize; - But it determines the buffer is empty:
embassy/embassy-nrf/src/buffered_uarte.rs
Lines 794 to 799 in 2a79c55
if start == end { //trace!(" empty"); ss.rx_waker.register(cx.waker()); r.intenset().write(|w| w.set_rxdrdy(true)); return Poll::Pending; }
So the ready function says we have data in the buffer, but the read function disagrees. They have different definitions of what empty means.
So... we need to change the ready function? I think the read function has the correct definition, right?