From a293dfea7a37cb8586c1ab23b2e1913a1d71d685 Mon Sep 17 00:00:00 2001 From: houwenxiang Date: Tue, 14 Jul 2020 01:07:30 +0800 Subject: [PATCH] feature: support vfs uart set line endings with specified uart number release/v3.3 --- components/vfs/include/esp_vfs_dev.h | 38 +++++++++++++++++++ components/vfs/test/test_vfs_uart.c | 4 +- components/vfs/vfs_uart.c | 37 ++++++++++++++---- .../main/ble_mesh_console_main.c | 4 +- .../main/ble_mesh_console_main.c | 4 +- .../ble_mesh_wifi_coexist/main/main.c | 4 +- .../ethernet/iperf/main/iperf_example_main.c | 4 +- .../i2c_tools/main/i2ctools_example_main.c | 4 +- .../asio/chat_client/components/wifi_asio.cpp | 4 +- .../asio/chat_server/components/wifi_asio.cpp | 4 +- .../tcp_echo_server/components/wifi_asio.cpp | 4 +- .../udp_echo_server/components/wifi_asio.cpp | 4 +- .../protocols/asio/wifi_init/wifi_asio.cpp | 4 +- .../console/main/console_example_main.c | 4 +- .../main/advanced_https_ota_example.c | 4 +- .../main/native_ota_example.c | 4 +- .../main/simple_ota_example.c | 4 +- examples/wifi/iperf/main/iperf_example_main.c | 4 +- .../main/simple_sniffer_example_main.c | 4 +- 19 files changed, 102 insertions(+), 41 deletions(-) diff --git a/components/vfs/include/esp_vfs_dev.h b/components/vfs/include/esp_vfs_dev.h index b330b4c56..637f1449f 100644 --- a/components/vfs/include/esp_vfs_dev.h +++ b/components/vfs/include/esp_vfs_dev.h @@ -68,6 +68,44 @@ void esp_vfs_dev_uart_set_rx_line_endings(esp_line_endings_t mode); */ void esp_vfs_dev_uart_set_tx_line_endings(esp_line_endings_t mode); +/** + * @brief Set the line endings expected to be received on specified UART + * + * This specifies the conversion between line endings received on UART and + * newlines ('\n', LF) passed into stdin: + * + * - ESP_LINE_ENDINGS_CRLF: convert CRLF to LF + * - ESP_LINE_ENDINGS_CR: convert CR to LF + * - ESP_LINE_ENDINGS_LF: no modification + * + * @note this function is not thread safe w.r.t. reading from UART + * + * @param uart_num the UART number + * @param mode line endings to send to UART + * @return 0 if successed, or -1 + * when an error (specified by errno) have occurred. + */ +int esp_vfs_dev_uart_port_set_rx_line_endings(int uart_num, esp_line_endings_t mode); + +/** + * @brief Set the line endings to sent to specified UART + * + * This specifies the conversion between newlines ('\n', LF) on stdout and line + * endings sent over UART: + * + * - ESP_LINE_ENDINGS_CRLF: convert LF to CRLF + * - ESP_LINE_ENDINGS_CR: convert LF to CR + * - ESP_LINE_ENDINGS_LF: no modification + * + * @note this function is not thread safe w.r.t. writing to UART + * + * @param uart_num the UART number + * @param mode line endings to send to UART + * @return 0 if successed, or -1 + * when an error (specified by errno) have occurred. + */ +int esp_vfs_dev_uart_port_set_tx_line_endings(int uart_num, esp_line_endings_t mode); + /** * @brief set VFS to use simple functions for reading and writing UART * Read is non-blocking, write is busy waiting until TX FIFO has enough space. diff --git a/components/vfs/test/test_vfs_uart.c b/components/vfs/test/test_vfs_uart.c index 2e45d76bf..59a6ccf0e 100644 --- a/components/vfs/test/test_vfs_uart.c +++ b/components/vfs/test/test_vfs_uart.c @@ -77,8 +77,8 @@ TEST_CASE("can read from stdin", "[vfs]") TEST_CASE("CRs are removed from the stdin correctly", "[vfs]") { - esp_vfs_dev_uart_set_rx_line_endings(ESP_LINE_ENDINGS_CRLF); - esp_vfs_dev_uart_set_tx_line_endings(ESP_LINE_ENDINGS_CRLF); + esp_vfs_dev_uart_port_set_rx_line_endings(CONFIG_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_CRLF); + esp_vfs_dev_uart_port_set_tx_line_endings(CONFIG_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_CRLF); flush_stdin_stdout(); const char* send_str = "1234567890\n\r123\r\n4\n"; diff --git a/components/vfs/vfs_uart.c b/components/vfs/vfs_uart.c index ebff91a87..c6aa6f096 100644 --- a/components/vfs/vfs_uart.c +++ b/components/vfs/vfs_uart.c @@ -71,14 +71,15 @@ static fd_set *_writefds_orig = NULL; static fd_set *_errorfds_orig = NULL; // Newline conversion mode when transmitting -static esp_line_endings_t s_tx_mode = +static esp_line_endings_t s_tx_mode [UART_NUM] = { [0 ... UART_NUM-1] = #if CONFIG_NEWLIB_STDOUT_LINE_ENDING_CRLF - ESP_LINE_ENDINGS_CRLF; + ESP_LINE_ENDINGS_CRLF #elif CONFIG_NEWLIB_STDOUT_LINE_ENDING_CR - ESP_LINE_ENDINGS_CR; + ESP_LINE_ENDINGS_CR #else - ESP_LINE_ENDINGS_LF; + ESP_LINE_ENDINGS_LF #endif + }; // Newline conversion mode when receiving static esp_line_endings_t s_rx_mode[UART_NUM] = { [0 ... UART_NUM-1] = @@ -172,9 +173,9 @@ static ssize_t uart_write(int fd, const void * data, size_t size) _lock_acquire_recursive(&s_uart_write_locks[fd]); for (size_t i = 0; i < size; i++) { int c = data_c[i]; - if (c == '\n' && s_tx_mode != ESP_LINE_ENDINGS_LF) { + if (c == '\n' && s_tx_mode[fd] != ESP_LINE_ENDINGS_LF) { s_uart_tx_func[fd](fd, '\r'); - if (s_tx_mode == ESP_LINE_ENDINGS_CR) { + if (s_tx_mode[fd] == ESP_LINE_ENDINGS_CR) { continue; } } @@ -927,7 +928,29 @@ void esp_vfs_dev_uart_set_rx_line_endings(esp_line_endings_t mode) void esp_vfs_dev_uart_set_tx_line_endings(esp_line_endings_t mode) { - s_tx_mode = mode; + for (int i = 0; i < UART_NUM; ++i) { + s_tx_mode[i] = mode; + } +} + +int esp_vfs_dev_uart_port_set_rx_line_endings(int uart_num, esp_line_endings_t mode) +{ + if (uart_num < 0 || uart_num >= UART_NUM) { + errno = EBADF; + return -1; + } + s_rx_mode[uart_num] = mode; + return 0; +} + +int esp_vfs_dev_uart_port_set_tx_line_endings(int uart_num, esp_line_endings_t mode) +{ + if (uart_num < 0 || uart_num >= UART_NUM) { + errno = EBADF; + return -1; + } + s_tx_mode[uart_num] = mode; + return 0; } void esp_vfs_dev_uart_use_nonblocking(int uart_num) diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/ble_mesh_console_main.c b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/ble_mesh_console_main.c index 3e961a4f2..f4bf0edc8 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/ble_mesh_console_main.c +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/ble_mesh_console_main.c @@ -58,9 +58,9 @@ static void initialize_console(void) setvbuf(stdout, NULL, _IONBF, 0); /* Minicom, screen, idf_monitor send CR when ENTER key is pressed */ - esp_vfs_dev_uart_set_rx_line_endings(ESP_LINE_ENDINGS_CR); + esp_vfs_dev_uart_port_set_rx_line_endings(CONFIG_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_CR); /* Move the caret to the beginning of the next line on '\n' */ - esp_vfs_dev_uart_set_tx_line_endings(ESP_LINE_ENDINGS_CRLF); + esp_vfs_dev_uart_port_set_tx_line_endings(CONFIG_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_CRLF); /* Install UART driver for interrupt-driven reads and writes */ ESP_ERROR_CHECK( uart_driver_install(CONFIG_CONSOLE_UART_NUM, diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_console_main.c b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_console_main.c index 357c93636..3401aa485 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_console_main.c +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_console_main.c @@ -61,9 +61,9 @@ static void initialize_console(void) setvbuf(stdout, NULL, _IONBF, 0); /* Minicom, screen, idf_monitor send CR when ENTER key is pressed */ - esp_vfs_dev_uart_set_rx_line_endings(ESP_LINE_ENDINGS_CR); + esp_vfs_dev_uart_port_set_rx_line_endings(CONFIG_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_CR); /* Move the caret to the beginning of the next line on '\n' */ - esp_vfs_dev_uart_set_tx_line_endings(ESP_LINE_ENDINGS_CRLF); + esp_vfs_dev_uart_port_set_tx_line_endings(CONFIG_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_CRLF); /* Install UART driver for interrupt-driven reads and writes */ ESP_ERROR_CHECK( uart_driver_install(CONFIG_CONSOLE_UART_NUM, diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_wifi_coexist/main/main.c b/examples/bluetooth/esp_ble_mesh/ble_mesh_wifi_coexist/main/main.c index 774ef90f9..95a92f2f2 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_wifi_coexist/main/main.c +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_wifi_coexist/main/main.c @@ -751,9 +751,9 @@ static void initialize_console(void) setvbuf(stdout, NULL, _IONBF, 0); /* Minicom, screen, idf_monitor send CR when ENTER key is pressed */ - esp_vfs_dev_uart_set_rx_line_endings(ESP_LINE_ENDINGS_CR); + esp_vfs_dev_uart_port_set_rx_line_endings(CONFIG_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_CR); /* Move the caret to the beginning of the next line on '\n' */ - esp_vfs_dev_uart_set_tx_line_endings(ESP_LINE_ENDINGS_CRLF); + esp_vfs_dev_uart_port_set_tx_line_endings(CONFIG_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_CRLF); /* Install UART driver for interrupt-driven reads and writes */ ESP_ERROR_CHECK( uart_driver_install(CONFIG_CONSOLE_UART_NUM, diff --git a/examples/ethernet/iperf/main/iperf_example_main.c b/examples/ethernet/iperf/main/iperf_example_main.c index 479a192fb..7d1c46b7f 100644 --- a/examples/ethernet/iperf/main/iperf_example_main.c +++ b/examples/ethernet/iperf/main/iperf_example_main.c @@ -60,9 +60,9 @@ static void initialize_console() setvbuf(stdin, NULL, _IONBF, 0); /* Minicom, screen, idf_monitor send CR when ENTER key is pressed */ - esp_vfs_dev_uart_set_rx_line_endings(ESP_LINE_ENDINGS_CR); + esp_vfs_dev_uart_port_set_rx_line_endings(CONFIG_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_CR); /* Move the caret to the beginning of the next line on '\n' */ - esp_vfs_dev_uart_set_tx_line_endings(ESP_LINE_ENDINGS_CRLF); + esp_vfs_dev_uart_port_set_tx_line_endings(CONFIG_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_CRLF); /* Configure UART. Note that REF_TICK is used so that the baud rate remains * correct while APB frequency is changing in light sleep mode. diff --git a/examples/peripherals/i2c/i2c_tools/main/i2ctools_example_main.c b/examples/peripherals/i2c/i2c_tools/main/i2ctools_example_main.c index 7e24968a7..278b877ee 100644 --- a/examples/peripherals/i2c/i2c_tools/main/i2ctools_example_main.c +++ b/examples/peripherals/i2c/i2c_tools/main/i2ctools_example_main.c @@ -60,9 +60,9 @@ static void initialize_console() setvbuf(stdin, NULL, _IONBF, 0); /* Minicom, screen, idf_monitor send CR when ENTER key is pressed */ - esp_vfs_dev_uart_set_rx_line_endings(ESP_LINE_ENDINGS_CR); + esp_vfs_dev_uart_port_set_rx_line_endings(CONFIG_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_CR); /* Move the caret to the beginning of the next line on '\n' */ - esp_vfs_dev_uart_set_tx_line_endings(ESP_LINE_ENDINGS_CRLF); + esp_vfs_dev_uart_port_set_tx_line_endings(CONFIG_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_CRLF); /* Configure UART. Note that REF_TICK is used so that the baud rate remains * correct while APB frequency is changing in light sleep mode. diff --git a/examples/protocols/asio/chat_client/components/wifi_asio.cpp b/examples/protocols/asio/chat_client/components/wifi_asio.cpp index b90ce26ae..c8d6832a3 100644 --- a/examples/protocols/asio/chat_client/components/wifi_asio.cpp +++ b/examples/protocols/asio/chat_client/components/wifi_asio.cpp @@ -124,9 +124,9 @@ extern "C" void app_main() 256, 0, 0, NULL, 0) ); /* Tell VFS to use UART driver */ esp_vfs_dev_uart_use_driver(CONFIG_CONSOLE_UART_NUM); - esp_vfs_dev_uart_set_rx_line_endings(ESP_LINE_ENDINGS_CR); + esp_vfs_dev_uart_port_set_rx_line_endings(CONFIG_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_CR); /* Move the caret to the beginning of the next line on '\n' */ - esp_vfs_dev_uart_set_tx_line_endings(ESP_LINE_ENDINGS_CRLF); + esp_vfs_dev_uart_port_set_tx_line_endings(CONFIG_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_CRLF); // wait till we receive IP, so asio realated code can be started xEventGroupWaitBits(wifi_event_group, WIFI_CONNECTED_BIT, 1, 1, portMAX_DELAY); diff --git a/examples/protocols/asio/chat_server/components/wifi_asio.cpp b/examples/protocols/asio/chat_server/components/wifi_asio.cpp index b90ce26ae..c8d6832a3 100644 --- a/examples/protocols/asio/chat_server/components/wifi_asio.cpp +++ b/examples/protocols/asio/chat_server/components/wifi_asio.cpp @@ -124,9 +124,9 @@ extern "C" void app_main() 256, 0, 0, NULL, 0) ); /* Tell VFS to use UART driver */ esp_vfs_dev_uart_use_driver(CONFIG_CONSOLE_UART_NUM); - esp_vfs_dev_uart_set_rx_line_endings(ESP_LINE_ENDINGS_CR); + esp_vfs_dev_uart_port_set_rx_line_endings(CONFIG_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_CR); /* Move the caret to the beginning of the next line on '\n' */ - esp_vfs_dev_uart_set_tx_line_endings(ESP_LINE_ENDINGS_CRLF); + esp_vfs_dev_uart_port_set_tx_line_endings(CONFIG_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_CRLF); // wait till we receive IP, so asio realated code can be started xEventGroupWaitBits(wifi_event_group, WIFI_CONNECTED_BIT, 1, 1, portMAX_DELAY); diff --git a/examples/protocols/asio/tcp_echo_server/components/wifi_asio.cpp b/examples/protocols/asio/tcp_echo_server/components/wifi_asio.cpp index b90ce26ae..c8d6832a3 100644 --- a/examples/protocols/asio/tcp_echo_server/components/wifi_asio.cpp +++ b/examples/protocols/asio/tcp_echo_server/components/wifi_asio.cpp @@ -124,9 +124,9 @@ extern "C" void app_main() 256, 0, 0, NULL, 0) ); /* Tell VFS to use UART driver */ esp_vfs_dev_uart_use_driver(CONFIG_CONSOLE_UART_NUM); - esp_vfs_dev_uart_set_rx_line_endings(ESP_LINE_ENDINGS_CR); + esp_vfs_dev_uart_port_set_rx_line_endings(CONFIG_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_CR); /* Move the caret to the beginning of the next line on '\n' */ - esp_vfs_dev_uart_set_tx_line_endings(ESP_LINE_ENDINGS_CRLF); + esp_vfs_dev_uart_port_set_tx_line_endings(CONFIG_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_CRLF); // wait till we receive IP, so asio realated code can be started xEventGroupWaitBits(wifi_event_group, WIFI_CONNECTED_BIT, 1, 1, portMAX_DELAY); diff --git a/examples/protocols/asio/udp_echo_server/components/wifi_asio.cpp b/examples/protocols/asio/udp_echo_server/components/wifi_asio.cpp index b90ce26ae..c8d6832a3 100644 --- a/examples/protocols/asio/udp_echo_server/components/wifi_asio.cpp +++ b/examples/protocols/asio/udp_echo_server/components/wifi_asio.cpp @@ -124,9 +124,9 @@ extern "C" void app_main() 256, 0, 0, NULL, 0) ); /* Tell VFS to use UART driver */ esp_vfs_dev_uart_use_driver(CONFIG_CONSOLE_UART_NUM); - esp_vfs_dev_uart_set_rx_line_endings(ESP_LINE_ENDINGS_CR); + esp_vfs_dev_uart_port_set_rx_line_endings(CONFIG_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_CR); /* Move the caret to the beginning of the next line on '\n' */ - esp_vfs_dev_uart_set_tx_line_endings(ESP_LINE_ENDINGS_CRLF); + esp_vfs_dev_uart_port_set_tx_line_endings(CONFIG_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_CRLF); // wait till we receive IP, so asio realated code can be started xEventGroupWaitBits(wifi_event_group, WIFI_CONNECTED_BIT, 1, 1, portMAX_DELAY); diff --git a/examples/protocols/asio/wifi_init/wifi_asio.cpp b/examples/protocols/asio/wifi_init/wifi_asio.cpp index b90ce26ae..c8d6832a3 100644 --- a/examples/protocols/asio/wifi_init/wifi_asio.cpp +++ b/examples/protocols/asio/wifi_init/wifi_asio.cpp @@ -124,9 +124,9 @@ extern "C" void app_main() 256, 0, 0, NULL, 0) ); /* Tell VFS to use UART driver */ esp_vfs_dev_uart_use_driver(CONFIG_CONSOLE_UART_NUM); - esp_vfs_dev_uart_set_rx_line_endings(ESP_LINE_ENDINGS_CR); + esp_vfs_dev_uart_port_set_rx_line_endings(CONFIG_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_CR); /* Move the caret to the beginning of the next line on '\n' */ - esp_vfs_dev_uart_set_tx_line_endings(ESP_LINE_ENDINGS_CRLF); + esp_vfs_dev_uart_port_set_tx_line_endings(CONFIG_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_CRLF); // wait till we receive IP, so asio realated code can be started xEventGroupWaitBits(wifi_event_group, WIFI_CONNECTED_BIT, 1, 1, portMAX_DELAY); diff --git a/examples/system/console/main/console_example_main.c b/examples/system/console/main/console_example_main.c index ba16a9e61..b5a156d98 100644 --- a/examples/system/console/main/console_example_main.c +++ b/examples/system/console/main/console_example_main.c @@ -63,9 +63,9 @@ static void initialize_console() setvbuf(stdin, NULL, _IONBF, 0); /* Minicom, screen, idf_monitor send CR when ENTER key is pressed */ - esp_vfs_dev_uart_set_rx_line_endings(ESP_LINE_ENDINGS_CR); + esp_vfs_dev_uart_port_set_rx_line_endings(CONFIG_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_CR); /* Move the caret to the beginning of the next line on '\n' */ - esp_vfs_dev_uart_set_tx_line_endings(ESP_LINE_ENDINGS_CRLF); + esp_vfs_dev_uart_port_set_tx_line_endings(CONFIG_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_CRLF); /* Configure UART. Note that REF_TICK is used so that the baud rate remains * correct while APB frequency is changing in light sleep mode. diff --git a/examples/system/ota/advanced_https_ota/main/advanced_https_ota_example.c b/examples/system/ota/advanced_https_ota/main/advanced_https_ota_example.c index 3ec256a4d..e4217e623 100644 --- a/examples/system/ota/advanced_https_ota/main/advanced_https_ota_example.c +++ b/examples/system/ota/advanced_https_ota/main/advanced_https_ota_example.c @@ -56,9 +56,9 @@ static esp_err_t example_configure_stdin_stdout(void) 256, 0, 0, NULL, 0) ); /* Tell VFS to use UART driver */ esp_vfs_dev_uart_use_driver(CONFIG_CONSOLE_UART_NUM); - esp_vfs_dev_uart_set_rx_line_endings(ESP_LINE_ENDINGS_CR); + esp_vfs_dev_uart_port_set_rx_line_endings(CONFIG_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_CR); /* Move the caret to the beginning of the next line on '\n' */ - esp_vfs_dev_uart_set_tx_line_endings(ESP_LINE_ENDINGS_CRLF); + esp_vfs_dev_uart_port_set_tx_line_endings(CONFIG_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_CRLF); return ESP_OK; } #endif diff --git a/examples/system/ota/native_ota_example/main/native_ota_example.c b/examples/system/ota/native_ota_example/main/native_ota_example.c index 744e4ef21..2d8243e76 100644 --- a/examples/system/ota/native_ota_example/main/native_ota_example.c +++ b/examples/system/ota/native_ota_example/main/native_ota_example.c @@ -67,9 +67,9 @@ static esp_err_t example_configure_stdin_stdout(void) 256, 0, 0, NULL, 0) ); /* Tell VFS to use UART driver */ esp_vfs_dev_uart_use_driver(CONFIG_CONSOLE_UART_NUM); - esp_vfs_dev_uart_set_rx_line_endings(ESP_LINE_ENDINGS_CR); + esp_vfs_dev_uart_port_set_rx_line_endings(CONFIG_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_CR); /* Move the caret to the beginning of the next line on '\n' */ - esp_vfs_dev_uart_set_tx_line_endings(ESP_LINE_ENDINGS_CRLF); + esp_vfs_dev_uart_port_set_tx_line_endings(CONFIG_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_CRLF); return ESP_OK; } #endif diff --git a/examples/system/ota/simple_ota_example/main/simple_ota_example.c b/examples/system/ota/simple_ota_example/main/simple_ota_example.c index c06d6297c..7d0c58328 100644 --- a/examples/system/ota/simple_ota_example/main/simple_ota_example.c +++ b/examples/system/ota/simple_ota_example/main/simple_ota_example.c @@ -56,9 +56,9 @@ static esp_err_t example_configure_stdin_stdout(void) 256, 0, 0, NULL, 0) ); /* Tell VFS to use UART driver */ esp_vfs_dev_uart_use_driver(CONFIG_CONSOLE_UART_NUM); - esp_vfs_dev_uart_set_rx_line_endings(ESP_LINE_ENDINGS_CR); + esp_vfs_dev_uart_port_set_rx_line_endings(CONFIG_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_CR); /* Move the caret to the beginning of the next line on '\n' */ - esp_vfs_dev_uart_set_tx_line_endings(ESP_LINE_ENDINGS_CRLF); + esp_vfs_dev_uart_port_set_tx_line_endings(CONFIG_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_CRLF); return ESP_OK; } #endif diff --git a/examples/wifi/iperf/main/iperf_example_main.c b/examples/wifi/iperf/main/iperf_example_main.c index 50779b3e2..de44984e9 100644 --- a/examples/wifi/iperf/main/iperf_example_main.c +++ b/examples/wifi/iperf/main/iperf_example_main.c @@ -32,9 +32,9 @@ static void initialize_console() setvbuf(stdin, NULL, _IONBF, 0); /* Minicom, screen, idf_monitor send CR when ENTER key is pressed */ - esp_vfs_dev_uart_set_rx_line_endings(ESP_LINE_ENDINGS_CR); + esp_vfs_dev_uart_port_set_rx_line_endings(CONFIG_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_CR); /* Move the caret to the beginning of the next line on '\n' */ - esp_vfs_dev_uart_set_tx_line_endings(ESP_LINE_ENDINGS_CRLF); + esp_vfs_dev_uart_port_set_tx_line_endings(CONFIG_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_CRLF); /* Install UART driver for interrupt-driven reads and writes */ ESP_ERROR_CHECK( uart_driver_install(CONFIG_CONSOLE_UART_NUM, diff --git a/examples/wifi/simple_sniffer/main/simple_sniffer_example_main.c b/examples/wifi/simple_sniffer/main/simple_sniffer_example_main.c index fcd01d8b6..3865f1bea 100644 --- a/examples/wifi/simple_sniffer/main/simple_sniffer_example_main.c +++ b/examples/wifi/simple_sniffer/main/simple_sniffer_example_main.c @@ -79,9 +79,9 @@ static void initialize_console() setvbuf(stdin, NULL, _IONBF, 0); /* Minicom, screen, idf_monitor send CR when ENTER key is pressed */ - esp_vfs_dev_uart_set_rx_line_endings(ESP_LINE_ENDINGS_CR); + esp_vfs_dev_uart_port_set_rx_line_endings(CONFIG_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_CR); /* Move the caret to the beginning of the next line on '\n' */ - esp_vfs_dev_uart_set_tx_line_endings(ESP_LINE_ENDINGS_CRLF); + esp_vfs_dev_uart_port_set_tx_line_endings(CONFIG_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_CRLF); /* Install UART driver for interrupt-driven reads and writes */ ESP_ERROR_CHECK(uart_driver_install(CONFIG_CONSOLE_UART_NUM,