Skip to content

uart_rx_fifo_available considerations #4565

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

Closed
d-a-v opened this issue Mar 26, 2018 · 3 comments
Closed

uart_rx_fifo_available considerations #4565

d-a-v opened this issue Mar 26, 2018 · 3 comments

Comments

@d-a-v
Copy link
Collaborator

d-a-v commented Mar 26, 2018

According to @jasoroony's comments and after checking the doc, it appears that:

inline size_t uart_rx_fifo_available(uart_t* uart) {
     return (USS(uart->uart_nr) >> USRXC) & 0x7F;
}

should be:

inline size_t uart_rx_fifo_available(uart_t* uart) {
     return (USS(uart->uart_nr) >> USRXC) & 0xFF;
}

reference section 11.3.7:

Rx fifo length:
(READ_PERI_REG(UART_STATUS(UART0))>>UART_RXFIFO_CNT_S)&UART_RXFIFO_CNT;

where

tools/sdk/include/uart_register.h:#define UART_RXFIFO_CNT 0x000000FF

(both USRXC and UART_RXFIFO_CNT_S are 0)

devyte added a commit that referenced this issue Mar 28, 2018
* Fix for #4565 (rx fifo length), protect access to rx_buffer

* Fix typo

* reworked to separate safe from unsafe functions, factorized some code, constness

* additional rework for uart_rx_fifo_available()

* swapped unsafe function definition order

* Remove static for overrun string

* Some shorthand for perf and readability
@ghost
Copy link

ghost commented Mar 28, 2018

Good work guys, the new commit works perfectly with all my serial tests, including a simulated DOS attack while WiFi is on. I did see my S/W buffer as high as 900 characters during that, but it's still running and no errors were detected in the Serial stream.

@d-a-v
Copy link
Collaborator Author

d-a-v commented Mar 28, 2018

Thanks for your feedback !

bryceschober pushed a commit to bryceschober/Arduino that referenced this issue Apr 5, 2018
…sp8266#4568)

* Fix for esp8266#4565 (rx fifo length), protect access to rx_buffer

* Fix typo

* reworked to separate safe from unsafe functions, factorized some code, constness

* additional rework for uart_rx_fifo_available()

* swapped unsafe function definition order

* Remove static for overrun string

* Some shorthand for perf and readability

(cherry picked from commit 29580e8)
@sarfata
Copy link

sarfata commented Apr 24, 2018

Just wanted to add a comment here to say that this change fixes a crash in my project that was very easy to reproduce when there is sufficient messages being sent to the ESP8266 serial port.

With the new version of uart.c, I have not been able to reproduce the crash after hours of testing where before it would usually crash in 15 minutes (with load). The symptom was a hardware watchdog timer crash with epc in uart_isr.

🙇 🤗 🎁

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants