Search code examples
cuartesp32

How can I flush/empty my UART(RX) each time before I receive a new message?


const int rxBytes = uart_read_bytes(UART_NUM_0, data, RX_BUF_SIZE, 10 / portTICK_RATE_MS);

Solution

  • To flush input data you can read from the uart repeatedly with a timeout of 0 until zero bytes are returned.