Espressif ESP32-S2 Programming Manual page 811

Table of Contents

Advertisement

Chapter 2. API Reference
esp_console_run()
esp_console_split_argv(), looks up the command in the list of registered components, and if it is
found, executes its handler.
esp_console_register_help_command()
This command prints the list of all the registered commands, along with their arguments and help texts.
esp_console_get_completion()
Callback() from linenoise library. Provides completions to linenoise based on the list of registered com-
mands.
esp_console_get_hint()
linenoise library. Provides argument hints for registered commands to linenoise.
Initialize console REPL environment
To establish a basic REPL environment, console component provides several useful APIs, combining those func-
tions described above.
In a typical application, you only need to call
ronment based on UART device, including driver install, basic console configuration, spawning a thread to do REPL
task and register several useful commands (e.g. help).
After that, you can register your own commands with esp_console_cmd_register(). The REPL environ-
ment keeps in init state until you call esp_console_start_repl().
Application Example
Example application illustrating usage of the console component is available in
example shows how to initialize UART and VFS functions, set up linenoise library, read and handle commands from
UART, and store command history in Flash. See README.md in the example directory for more details.
Besides that, ESP-IDF contains several useful examples which based on console component and can be treated as
"tools"when developing applications. For example, peripherals/i2c/i2c_tools, wifi/iperf.
API Reference
Header File
components/console/esp_console.h
Functions
esp_err_t
esp_console_init(const
initialize console module
Note Call this once before using other console module features
Return
• ESP_OK on success
• ESP_ERR_NO_MEM if out of memory
• ESP_ERR_INVALID_STATE if already initialized
• ESP_ERR_INVALID_ARG if the configuration is invalid
Parameters
• config: console configuration
esp_err_t
esp_console_deinit(void)
de-initialize console module
Note Call this once when done using console module functions
Return
• ESP_OK on success
• ESP_ERR_INVALID_STATE if not initialized yet
Espressif Systems
This function takes the command line string, splits it into argc/argv argument list using
Callback function to be used with linenoiseSetCompletion-
Callback function to be used with linenoiseSetHintsCallback() from
esp_console_new_repl_uart()
esp_console_config_t
Submit Document Feedback
Adds help command to the list of registered commands.
*config)
800
to initialize the REPL envi-
system/console
directory. This
Release v4.4

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the ESP32-S2 and is the answer not in the manual?

Questions and answers

Subscribe to Our Youtube Channel

Table of Contents

Save PDF