Skip to content

[nRF9160] BufferedUarte hangs #4774

@diondokter

Description

@diondokter

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:
    if r.events_rxstarted().read() != 0 || !s.rx_started.load(Ordering::Relaxed) {
  • Then no rxdrdy event fires (because no valid bytes are received?)
  • In my code I check:
    /// 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:
    // Read the RXDRDY counter.
    timer.cc(0).capture();
    let mut end = timer.cc(0).read() as usize;
  • But it determines the buffer is empty:
    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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions