About buffer that uart flush functions clear

zliudr
Posts: 357
Joined: Thu Oct 03, 2019 5:15 am

About buffer that uart flush functions clear

Postby zliudr » Sun Nov 17, 2019 5:28 pm

I read about the uart flush function documents and it's not clear to me what they do, maybe lost in translation:

https://docs.espressif.com/projects/esp ... art_port_t
esp_err_t uart_flush(uart_port_t uart_num)

Alias of uart_flush_input. UART ring buffer flush. This will discard all data in the UART RX buffer.

Note
Instead of waiting the data sent out, this function will clear UART rx buffer. In order to send all the data in tx FIFO, we can use uart_wait_tx_done function.
Return

ESP_OK Success
ESP_FAIL Parameter error

Parameters

uart_num: UART_NUM_0, UART_NUM_1 or UART_NUM_2

esp_err_t uart_flush_input(uart_port_t uart_num)

Clear input buffer, discard all the data is in the ring-buffer.

Note
In order to send all the data in tx FIFO, we can use uart_wait_tx_done function.
Return

ESP_OK Success
ESP_FAIL Parameter error

Parameters

uart_num: UART_NUM_0, UART_NUM_1 or UART_NUM_2
So my guess is that uart_flush() discards all content in TX ring buffer in main memory. What happens to the content of the 16-byte UART hardware TX buffer? Discarded as well?

My next guess is that uart_flush_input() discards all content in the RX ring buffer in main memory. What happens to the content in the 16-byte hardware RX buffer? Discarded as well?

Thank you!

FlorianR
Posts: 28
Joined: Fri Mar 12, 2021 2:00 pm

Re: About buffer that uart flush functions clear

Postby FlorianR » Thu Sep 23, 2021 7:10 am

Hi,
I also noticed that today. And I also think that they do not work correct. Maybe because of the Hardware FIFO.

Who is online

Users browsing this forum: Lvalue, zelenecul and 116 guests