const int rxBytes = uart_read_bytes(UART_NUM_0, data, RX_BUF_SIZE, 10 / portTICK_RATE_MS);
To flush input data you can read from the uart repeatedly with a timeout of 0 until zero bytes are returned.