From ee7cd4e1d84c6e9da51331ad7f7340767497e8ae Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Thu, 12 Dec 2019 17:20:39 +1100 Subject: [PATCH] driver: test: Ensure UART is fully idle before starting loopback RX/TX test Possible fix for sporadic failures of this test in CI, may be due to a byte already being queued in one of the FIFOs --- components/driver/test/test_uart.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/components/driver/test/test_uart.c b/components/driver/test/test_uart.c index cd3d26ca39..f371dd108a 100644 --- a/components/driver/test/test_uart.c +++ b/components/driver/test/test_uart.c @@ -250,6 +250,11 @@ TEST_CASE("uart read write test", "[uart]") TEST_ESP_OK(uart_driver_install(uart_num, BUF_SIZE * 2, 0, 20, NULL, 0)); TEST_ESP_OK(uart_param_config(uart_num, &uart_config)); TEST_ESP_OK(uart_set_loop_back(uart_num, true)); + + TEST_ESP_OK(uart_wait_tx_done(uart_num, portMAX_DELAY)); + vTaskDelay(1 / portTICK_PERIOD_MS); // make sure last byte has flushed from TX FIFO + TEST_ESP_OK(uart_flush_input(uart_num)); + xTaskCreate(uart_write_task, "uart_write_task", 2048 * 4, (void *)uart_num, 5, NULL); int len_tmp = 0; int rd_len = 1024;