在收到新消息之前,我如何才能每次 flush/empty 我的 UART(RX)?

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);

要刷新输入数据,您可以使用超时 0 重复读取 uart,直到返回零字节。