diff --git a/examples/system/console/components/cmd_system/cmd_system.c b/examples/system/console/components/cmd_system/cmd_system.c index 1acb295250..26c36f9940 100644 --- a/examples/system/console/components/cmd_system/cmd_system.c +++ b/examples/system/console/components/cmd_system/cmd_system.c @@ -10,6 +10,7 @@ #include #include #include +#include #include "esp_log.h" #include "esp_console.h" #include "esp_system.h" @@ -295,13 +296,13 @@ static int light_sleep(int argc, char **argv) if (io_count > 0) { ESP_ERROR_CHECK( esp_sleep_enable_gpio_wakeup() ); } - if (CONFIG_ESP_CONSOLE_UART_NUM <= UART_NUM_1) { + if (CONFIG_ESP_CONSOLE_UART_NUM >= 0 && CONFIG_ESP_CONSOLE_UART_NUM <= UART_NUM_1) { ESP_LOGI(TAG, "Enabling UART wakeup (press ENTER to exit light sleep)"); ESP_ERROR_CHECK( uart_set_wakeup_threshold(CONFIG_ESP_CONSOLE_UART_NUM, 3) ); ESP_ERROR_CHECK( esp_sleep_enable_uart_wakeup(CONFIG_ESP_CONSOLE_UART_NUM) ); } fflush(stdout); - uart_wait_tx_idle_polling(CONFIG_ESP_CONSOLE_UART_NUM); + fsync(fileno(stdout)); esp_light_sleep_start(); esp_sleep_wakeup_cause_t cause = esp_sleep_get_wakeup_cause(); const char *cause_str;