-
Notifications
You must be signed in to change notification settings - Fork 7.4k
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
HardwareSerial Available For Write #9319
Conversation
It makes sure that setting TX buffer size will match availableForWrite() response. It also sets the buffer to the minimum instead of doing nothing and returning an error. For RX Buffer, it sets the minimum and also don't return an error. This makes the APIs better and easy to understand its results.
This will allow to set TX buffer to a minimum with no error message. It also makes it works as in the Arduino API specification that is to return the buffer available space. In ESP32 case it will be the minmum the HW TX FIFO size of 128 bytes.
This change will make sure that if no TX Ringbuffer is used, it will return the UART FIFO available space. Otherwise, it will return the Ringbuffer available space, as defined in the Arduino especification.
👋 Hello SuGlider, we appreciate your contribution to this project! Click to see more instructions ...
Review and merge process you can expect ...
|
* feat(uart): backports UART pin attachment from 3.0.0 to 2.0.15 * Fix (uart): Fixes additional Serial HardwareSerial errors for 2.0.14 * Update esp32-hal-uart.c * Update HardwareSerial.h * Apply suggestions from code review * Fixes UartAvailableForWrite #9319 * Fixes (set RX/TX buffer size)
Description of Change
When setting RX buffer, the
setRxBufferSize()
method would fail with values lower than 128 bytes.Although it seems what IDF requests, it is not the best way to execute it, because the return value would be zero and the buffer size would be kept the same, by default 256. Now it returns the size it has been set, defining a minimum of 128+1 bytes, as required by IDF UART driver.
By other hand, for TX buffer, the
setTxBufferSize()
method also fails with less than 128 bytes, returning also 0.With the change, it will return and set it to 128 (minimum), as requeired by IDF.
It also changes
availableForWrite()
in order to return a value that matchessetTxBufferSize()
when there is no data to be written, making it possible for applications to better compare and decide when to write to the UART.Tests scenarios
Tested with ESP32 and ESP32-S3.
Related links
Closes #9317