-
Notifications
You must be signed in to change notification settings - Fork 7.9k
fix/feat(uart): uart_read_bytes() timeout fixed, added uart_read_bytes_partial() (IDFGH-16315) #17462
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
base: master
Are you sure you want to change the base?
Conversation
👋 Hello BitsForPeople, we appreciate your contribution to this project! 📘 Please review the project's Contributions Guide for key guidelines on code, documentation, testing, and more. 🖊️ Please also make sure you have read and signed the Contributor License Agreement for this project. Click to see more instructions ...
Review and merge process you can expect ...
|
|
You're right in that you can achieve the same overall behavior as uart_read_bytes_partial() by using UART events. That's a whole different programming paradigm though from simple blocking reads. I'd argue that |
Description
fix:
uart_read_bytes()
did not correctly handle the given ticks_to_wait timeout; when trying to read N bytes from the UART, it could take up to (N+1) * ticks_to_wait ticks to return. The new version returns as soon as ticks_to_wait ticks have elapsed.This change may in theory break applications which implicitly relied on the the given time limit not being honored.
feat: New function
uart_read_bytes_partial()
- blocks until any data is read from the RX buffer, not until the given buffer is full. Useful when you don't know in advance exactly how many bytes you expect to receive and you still want to react quickly to received data. This method also allows tasks to 'synchronize' to the UART's RX interrupt and consequently to more directly match the UART's behavior defined via the RX_FULL_THRESH and RX_TOUT settings.Related
Testing
Wrote a test application using UART loop-back to verify specifically the timing behavior of both uart_read_bytes() and uart_read_bytes_partial(), ran it on an -S3.
Checklist
Before submitting a Pull Request, please ensure the following: