EasyManua.ls Logo

Espressif ESP32-S2 - Page 811

Espressif ESP32-S2
1695 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Chapter 2. API Reference
esp_console_run() This function takes the command line string, splits it into argc/argv argument list using
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() Adds help command to the list of registered commands.
This command prints the list of all the registered commands, along with their arguments and help texts.
esp_console_get_completion() Callback function to be used with linenoiseSetCompletion-
Callback() from linenoise library. Provides completions to linenoise based on the list of registered com-
mands.
esp_console_get_hint() Callback function to be used with linenoiseSetHintsCallback() from
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 esp_console_new_repl_uart() to initialize the REPL envi-
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 system/console directory. This
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
toolswhen 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 esp_console_config_t *config)
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 800
Submit Document Feedback
Release v4.4

Table of Contents