From e390c17f99c5ab57e40c337dec63d99610c82905 Mon Sep 17 00:00:00 2001 From: David Cermak Date: Tue, 1 Oct 2024 19:33:52 +0200 Subject: [PATCH] fix(common_connect): Fix example's stdin/out to setup UART interrupt once Function example_configure_stdin_stdout() was used for simple UART I/O operation in CI to enter test env configuration (wifi ssid, IPs, etc). It could be called multiple times, but didn't handle the situation where we install UART interrupt from multiple source (e.g. in ICMP tests, where we first need to enter wifi credentials of test AP and then we start ping-cmd console to handle ping commands) --- .../common_components/protocol_examples_common/stdin_out.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/examples/common_components/protocol_examples_common/stdin_out.c b/examples/common_components/protocol_examples_common/stdin_out.c index 9f3a5163f3..57c61fb8f8 100644 --- a/examples/common_components/protocol_examples_common/stdin_out.c +++ b/examples/common_components/protocol_examples_common/stdin_out.c @@ -15,8 +15,7 @@ esp_err_t example_configure_stdin_stdout(void) { - static bool configured = false; - if (configured) { + if (uart_is_driver_installed((uart_port_t)CONFIG_ESP_CONSOLE_UART_NUM)) { return ESP_OK; } // Initialize VFS & UART so we can use std::cout/cin @@ -29,6 +28,5 @@ esp_err_t example_configure_stdin_stdout(void) uart_vfs_dev_port_set_rx_line_endings(CONFIG_ESP_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_CR); /* Move the caret to the beginning of the next line on '\n' */ uart_vfs_dev_port_set_tx_line_endings(CONFIG_ESP_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_CRLF); - configured = true; return ESP_OK; }