UART flush doesn't clear RX buffer
Posted: Mon Feb 07, 2022 7:30 am
ESP-IDF version: 4.4
ESP: ESP32-WROOM-32D
Background: I'm trying to make a program that communicates through UART with another device. The other device is usually constantly sending data, which I want to ignore, and only actually process it's messages, when I'm awaiting a response to one of my UART messages.
The problem: I start the UART at the start of the program, but after some time, the RX FIFO buffer gets filled up and can no longer receive any messages. I would expect that the RX FIFO buffer being a ring buffer it would just start overwriting old data when it gets full or at the very least calling uart_flush_input(UART_PORT) before writing my message and waiting for the other devices reply would clear the whole RX FIFO buffer, but it does not.
I have tried setting up the UART events example to see what happens. If I leave the part where it constantly reads the data while it's being received, everything is fine, but if I remove it, but leave the part where when it reaches overflow and it flushes, it gets filled up and stuck. The ESP will happily receive the messages at the start but after receiving a "Ring buffer full" and then "HW FIFO overflow", the FIFO overflow event keeps popping up every time I receive a message and I cannot actually read any data.
So, is uart_flush_input() supposed to do something else, or is it supposed to clear the whole UART RX buffer but is not working correctly?
ESP: ESP32-WROOM-32D
Background: I'm trying to make a program that communicates through UART with another device. The other device is usually constantly sending data, which I want to ignore, and only actually process it's messages, when I'm awaiting a response to one of my UART messages.
The problem: I start the UART at the start of the program, but after some time, the RX FIFO buffer gets filled up and can no longer receive any messages. I would expect that the RX FIFO buffer being a ring buffer it would just start overwriting old data when it gets full or at the very least calling uart_flush_input(UART_PORT) before writing my message and waiting for the other devices reply would clear the whole RX FIFO buffer, but it does not.
I have tried setting up the UART events example to see what happens. If I leave the part where it constantly reads the data while it's being received, everything is fine, but if I remove it, but leave the part where when it reaches overflow and it flushes, it gets filled up and stuck. The ESP will happily receive the messages at the start but after receiving a "Ring buffer full" and then "HW FIFO overflow", the FIFO overflow event keeps popping up every time I receive a message and I cannot actually read any data.
So, is uart_flush_input() supposed to do something else, or is it supposed to clear the whole UART RX buffer but is not working correctly?