When the REPL input backend is unavailable, linenoise() may return NULL
immediately. esp_console_repl_task() currently retries without yielding,
which can make the console_repl task spin continuously.
For USB Serial/JTAG console this can happen when the REPL is started
without an attached USB host. Since the REPL task has priority 2, this
can starve lower-priority tasks, prevent app_main from continuing after
esp_console_start_repl(), and trigger the task watchdog due to IDLE not
running.
Add a small delay before retrying when linenoise() returns NULL.
Closes https://github.com/espressif/esp-idf/issues/18485
Current implementation implicitly forces the developer to use global variables
to enter its context during the command invocation, this change enables each
module to register a context for command to find without the need to manage
global variables.
No API breakage.
Fields added:
esp_console_cmd_t::func_w_context - (*)(int argc, char **argv, void *context)
Functions added:
esp_err_t esp_console_cmd_set_context(const char *cmd, void *context)
Usage:
esp_console_cmd_register(&cmd));
esp_console_cmd_set_context(cmd.command, (void *)"context"));
Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
console commands may be registered in random order in application, for example
each module registers its own commands.
the output of help is displayed to human, best to have consistent sorted
output so that the implementation ordering will not affect the output and
allow the user to see a list in some logic order.
Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>