From 945bd36884763f955747da5293db9aec15fcb71c Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Wed, 13 Mar 2019 20:19:55 +0800 Subject: [PATCH] examples: don't enable buffering on stdout in console examples MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit newlib uses significantly more stack space when printing to an unbuffered stream. To reduce the amount of stack space required to use the console, don’t disable buffering. linenoise should support unbuffered stdout instead. --- examples/ethernet/iperf/main/iperf_example_main.c | 3 +-- .../peripherals/i2c/i2c_tools/main/i2ctools_example_main.c | 3 +-- examples/system/console/main/console_example_main.c | 3 +-- examples/wifi/iperf/main/iperf_example_main.c | 3 +-- .../wifi/simple_sniffer/main/simple_sniffer_example_main.c | 3 +-- 5 files changed, 5 insertions(+), 10 deletions(-) diff --git a/examples/ethernet/iperf/main/iperf_example_main.c b/examples/ethernet/iperf/main/iperf_example_main.c index b36ea1270d..479a192fbb 100644 --- a/examples/ethernet/iperf/main/iperf_example_main.c +++ b/examples/ethernet/iperf/main/iperf_example_main.c @@ -56,9 +56,8 @@ static void initialize_nvs() static void initialize_console() { - /* Disable buffering on stdin and stdout */ + /* Disable buffering on stdin */ setvbuf(stdin, NULL, _IONBF, 0); - 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); 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 eacf80c38b..7e24968a79 100644 --- a/examples/peripherals/i2c/i2c_tools/main/i2ctools_example_main.c +++ b/examples/peripherals/i2c/i2c_tools/main/i2ctools_example_main.c @@ -56,9 +56,8 @@ static void initialize_nvs() static void initialize_console() { - /* Disable buffering on stdin and stdout */ + /* Disable buffering on stdin */ setvbuf(stdin, NULL, _IONBF, 0); - 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); diff --git a/examples/system/console/main/console_example_main.c b/examples/system/console/main/console_example_main.c index 23d1cf2c91..ba16a9e619 100644 --- a/examples/system/console/main/console_example_main.c +++ b/examples/system/console/main/console_example_main.c @@ -59,9 +59,8 @@ static void initialize_nvs() static void initialize_console() { - /* Disable buffering on stdin and stdout */ + /* Disable buffering on stdin */ setvbuf(stdin, NULL, _IONBF, 0); - 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); diff --git a/examples/wifi/iperf/main/iperf_example_main.c b/examples/wifi/iperf/main/iperf_example_main.c index a3a666ed2a..50779b3e23 100644 --- a/examples/wifi/iperf/main/iperf_example_main.c +++ b/examples/wifi/iperf/main/iperf_example_main.c @@ -28,9 +28,8 @@ static void initialize_console() { - /* Disable buffering on stdin and stdout */ + /* Disable buffering on stdin */ setvbuf(stdin, NULL, _IONBF, 0); - 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); 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 fffc1cc375..fcd01d8b63 100644 --- a/examples/wifi/simple_sniffer/main/simple_sniffer_example_main.c +++ b/examples/wifi/simple_sniffer/main/simple_sniffer_example_main.c @@ -75,9 +75,8 @@ static void initialize_wifi() /* Initialize console component */ static void initialize_console() { - /* Disable buffering on stdin and stdout */ + /* Disable buffering on stdin */ setvbuf(stdin, NULL, _IONBF, 0); - 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); -- 2.40.0