-
Notifications
You must be signed in to change notification settings - Fork 225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Async uart idle line detection #885
Comments
Yes, I can confirm that on ESP32-C3 I got unexpected behaviour when reading NMEA sentences sent via UART. |
This is a mixture of incorrect docs and missing functionality. For it to work the way docs say, we need to implement idle line detection so that when the uart stops receiving data an interrupt is fixed and we can return those bytes.
I believe your issue is probably #882 |
It may not be necessary to include idle line detection, as this isn't a requirement specified by The implementation presented in the commit at 02667e8 seems to align closely with the documentation for However, I concur that users may have varying expectations regarding when an asynchronous read operation should complete. For instance, they might expect it to finish when:
To address these diverse needs, I would suggest either offering a way to configure this behavior or providing different methods for asynchronous reads that complete upon specific events. I'm undecided on which approach is more in line with Rust's conventions. If you provide guidance on which variation you prefer, I'm happy to help. |
I agree it's not required, but it's something we want because it uses the hardware more efficiently than setting the FIFO threshold to 1 byte.
The current approach is to allow a mix of these conditions, and I think for the default
I think adding support for idle line detection will be the most beneficial addition. That should hopefully be relatively straightforward to add; I'm happy to mentor adding it :). After that, we can take a look at possibly adding separate read methods for the different approaches. |
What kind of idle line detection to do have in mind? With a timer to check the line has been idle for a while? or is there some uart hw peripheral feature (I haven't read the entire technical reference doc yet)... |
Idle line detection is built into the UART, take a look at the |
Ok. This should indeed be straightforward to add. I'll try to do this in the coming weeks... |
I have some issues with the async uart implementation (on the main branch).
Expected behavior, after reading embedded-io-async::Read :
Actual behavior (https://github.com/esp-rs/esp-hal/blob/main/esp-hal-common/src/uart.rs#L1443-L1498)
read_async
says, the method will not error out if neitherset_rx_fifo_full_threshold
orset_at_cmd
was called, instead it will just hang forever. (At least I cannot see code that would error out in this case).I suggest that we add separate async methods, that can be used to wait on a FIFO full/overflow interrupt or at command interrupt, and that the embedded-io-async::Read implementation behaves as one expects when looking at the trait documentation (like in 02667e8).
The text was updated successfully, but these errors were encountered: