Module for unified command line handling. More...
Data Structures |
|
| struct | nrf_cli_cmd_entry |
|
CLI command descriptor.
More...
|
|
| struct | nrf_cli_static_entry |
|
CLI static command descriptor.
More...
|
|
| struct | nrf_cli_transport_api_t |
|
Unified CLI transport interface.
More...
|
|
| struct | nrf_cli_transport_s |
| struct | nrf_cli_flag_t |
| union | nrf_cli_internal_t |
| struct | nrf_cli_ctx_t |
|
CLI instance context.
More...
|
|
| struct | nrf_cli_log_backend_t |
| struct | nrf_cli |
|
CLI instance internals.
More...
|
|
| struct | nrf_cli_getopt_option |
|
Option descriptor.
More...
|
|
Macros |
|
| #define | NRF_CLI_CMD_REGISTER (p_syntax, p_subcmd, p_help, p_handler) |
|
Macro for defining and adding a root command (level 0).
More...
|
|
| #define | NRF_CLI_CREATE_STATIC_SUBCMD_SET (name) |
|
Macro for creating a subcommand set. It must be used outside of any function body.
More...
|
|
| #define | NRF_CLI_SUBCMD_SET_END {NULL} |
|
Define ending subcommands set.
|
|
| #define | NRF_CLI_CREATE_DYNAMIC_CMD (name, p_get) |
|
Macro for creating a dynamic entry.
More...
|
|
| #define | NRF_CLI_CMD (_p_syntax, _p_subcmd, _p_help, _p_handler) |
|
Initializes a CLI command (
nrf_cli_static_entry
).
More...
|
|
| #define | NRF_LOG_BACKEND_CLI_DEF (_name_, _queue_sz_) |
| #define | NRF_CLI_BACKEND_PTR (_name_) NULL |
| #define | NRF_CLI_MEMOBJ_PTR (_name_) NULL |
| #define | NRF_CLI_HISTORY_MEM_OBJ (name) |
| #define | NRF_CLI_DEF (name, cli_prefix, p_transport_iface, newline_ch, log_queue_size) |
|
Macro for defining a command line interface instance.
More...
|
|
| #define | NRF_CLI_DEFAULT NRF_CLI_VT100_COLOR_DEFAULT |
|
CLI colors for
nrf_cli_fprintf
function.
More...
|
|
| #define | NRF_CLI_NORMAL NRF_CLI_VT100_COLOR_WHITE |
| #define | NRF_CLI_INFO NRF_CLI_VT100_COLOR_GREEN |
| #define | NRF_CLI_OPTION NRF_CLI_VT100_COLOR_CYAN |
| #define | NRF_CLI_WARNING NRF_CLI_VT100_COLOR_YELLOW |
| #define | NRF_CLI_ERROR NRF_CLI_VT100_COLOR_RED |
| #define | NRF_CLI_OPT (_p_optname, _p_shortname, _p_help) |
|
Option structure initializer
nrf_cli_getopt_option
.
More...
|
|
Typedefs |
|
| typedef struct nrf_cli | nrf_cli_t |
|
Aliases to:
Command Line Interface
,
nrf_cli_cmd_entry
, and
nrf_cli_static_entry
. Must be created here to satisfy module declaration order dependencies.
|
|
| typedef struct nrf_cli_cmd_entry | nrf_cli_cmd_entry_t |
| typedef struct nrf_cli_static_entry | nrf_cli_static_entry_t |
| typedef void(* | nrf_cli_dynamic_get )(size_t idx, nrf_cli_static_entry_t *p_static) |
|
CLI dynamic command descriptor.
More...
|
|
| typedef void(* | nrf_cli_cmd_handler )( nrf_cli_t const *p_cli, size_t argc, char **argv) |
|
CLI command handler prototype.
|
|
| typedef void(* | nrf_cli_transport_handler_t )( nrf_cli_transport_evt_t evt_type, void *p_context) |
| typedef struct nrf_cli_transport_s | nrf_cli_transport_t |
|
typedef struct
nrf_cli_getopt_option |
nrf_cli_getopt_option_t |
|
Option descriptor.
|
|
Enumerations |
|
| enum |
nrf_cli_receive_t
{
NRF_CLI_RECEIVE_DEFAULT , NRF_CLI_RECEIVE_ESC , NRF_CLI_RECEIVE_ESC_SEQ } |
| enum |
nrf_cli_state_t
{
NRF_CLI_STATE_UNINITIALIZED , NRF_CLI_STATE_INITIALIZED , NRF_CLI_STATE_ACTIVE , NRF_CLI_STATE_PANIC_MODE_ACTIVE , NRF_CLI_STATE_PANIC_MODE_INACTIVE } |
| enum |
nrf_cli_transport_evt_t
{
NRF_CLI_TRANSPORT_EVT_RX_RDY , NRF_CLI_TRANSPORT_EVT_TX_RDY } |
|
Event type from CLI transport.
|
|
Functions |
|
| STATIC_ASSERT (sizeof( nrf_cli_flag_t )==sizeof(uint32_t)) | |
| ret_code_t | nrf_cli_init ( nrf_cli_t const *p_cli, void const *p_transport_config, bool use_colors, bool log_backend, nrf_log_severity_t init_lvl) |
|
Function for initializing a transport layer and internal CLI state.
More...
|
|
| ret_code_t | nrf_cli_task_create ( nrf_cli_t const *p_cli) |
| ret_code_t | nrf_cli_uninit ( nrf_cli_t const *p_cli) |
|
Function for uninitializing a transport layer and internal CLI state. If function returns NRF_ERROR_BUSY, you must call
nrf_cli_process
before calling nrf_cli_uninit again.
More...
|
|
| ret_code_t | nrf_cli_start ( nrf_cli_t const *p_cli) |
|
Function for starting CLI processing.
More...
|
|
| ret_code_t | nrf_cli_stop ( nrf_cli_t const *p_cli) |
|
Function for stopping CLI processing.
More...
|
|
| void | nrf_cli_fprintf ( nrf_cli_t const *p_cli, nrf_cli_vt100_color_t color, char const *p_fmt,...) |
|
Printf-like function which sends formatted data stream to the CLI. This function shall not be used outside of the CLI module or CLI command context.
More...
|
|
| void | nrf_cli_process ( nrf_cli_t const *p_cli) |
|
Process function, which should be executed when data is ready in the transport interface.
More...
|
|
| __STATIC_INLINE bool | nrf_cli_help_requested ( nrf_cli_t const *p_cli) |
|
Informs that a command has been called with -h or –help option.
More...
|
|
| void | nrf_cli_help_print ( nrf_cli_t const *p_cli, nrf_cli_getopt_option_t const *p_opt, size_t opt_len) |
|
Prints the current command help.
More...
|
|
| void | nrf_cli_print_stream (void const *p_user_ctx, char const *p_data, size_t data_len) |
Variables |
|
| const nrf_log_backend_api_t | nrf_log_backend_cli_api |
Detailed Description
Module for unified command line handling.
Macro Definition Documentation
| #define NRF_CLI_CMD | ( | _p_syntax, | |
| _p_subcmd, | |||
| _p_help, | |||
| _p_handler | |||
| ) |
Initializes a CLI command ( nrf_cli_static_entry ).
- Parameters
-
[in] _p_syntax Command syntax (for example: history). [in] _p_subcmd Pointer to a subcommands array. [in] _p_help Pointer to a command help string. [in] _p_handler Pointer to a function handler.
| #define NRF_CLI_CMD_REGISTER | ( | p_syntax, | |
| p_subcmd, | |||
| p_help, | |||
| p_handler | |||
| ) |
Macro for defining and adding a root command (level 0).
- Note
- Each root command shall have unique syntax.
- Parameters
-
[in] p_syntax Command syntax (for example: history). [in] p_subcmd Pointer to a subcommands array. [in] p_help Pointer to a command help string. [in] p_handler Pointer to a function handler.
| #define NRF_CLI_CREATE_DYNAMIC_CMD | ( | name, | |
| p_get | |||
| ) |
Macro for creating a dynamic entry.
- Parameters
-
[in] name Name of the dynamic entry. [in] p_get Pointer to the function returning dynamic commands array nrf_cli_dynamic_get .
| #define NRF_CLI_CREATE_STATIC_SUBCMD_SET | ( | name | ) |
Macro for creating a subcommand set. It must be used outside of any function body.
- Parameters
-
[in] name Name of the subcommand set.
| #define NRF_CLI_DEF | ( | name, | |
| cli_prefix, | |||
| p_transport_iface, | |||
| newline_ch, | |||
| log_queue_size | |||
| ) |
Macro for defining a command line interface instance.
- Parameters
-
[in] name Instance name. [in] cli_prefix CLI prefix string. [in] p_transport_iface Pointer to the transport interface. [in] newline_ch New line character - only allowed values are '\n' or '\r'. [in] log_queue_size Logger processing queue size.
| #define NRF_CLI_DEFAULT NRF_CLI_VT100_COLOR_DEFAULT |
CLI colors for nrf_cli_fprintf function.
Turn off character attributes.
| #define NRF_CLI_ERROR NRF_CLI_VT100_COLOR_RED |
Error color printf.
| #define NRF_CLI_INFO NRF_CLI_VT100_COLOR_GREEN |
Info color printf.
| #define NRF_CLI_NORMAL NRF_CLI_VT100_COLOR_WHITE |
Normal color printf.
| #define NRF_CLI_OPT | ( | _p_optname, | |
| _p_shortname, | |||
| _p_help | |||
| ) |
Option structure initializer nrf_cli_getopt_option .
- Parameters
-
[in] _p_optname Option name long. [in] _p_shortname Option name short. [in] _p_help Option help string.
| #define NRF_CLI_OPTION NRF_CLI_VT100_COLOR_CYAN |
Option color printf.
| #define NRF_CLI_WARNING NRF_CLI_VT100_COLOR_YELLOW |
Warning color printf.
Typedef Documentation
| typedef void(* nrf_cli_dynamic_get)(size_t idx, nrf_cli_static_entry_t *p_static) |
CLI dynamic command descriptor.
Function shall fill the received nrf_cli_static_entry structure with requested (idx) dynamic subcommand data. If there is more than one dynamic subcommand available, the function shall ensure that the returned commands: p_static->p_syntax are sorted in alphabetical order. If idx exceeds the available dynamic subcommands, the function must write to p_static->p_syntax NULL value. This will indicate to the CLI module that there are no more dynamic commands to read.
Enumeration Type Documentation
| enum nrf_cli_state_t |
Function Documentation
| void nrf_cli_fprintf | ( | nrf_cli_t const * | p_cli , |
| nrf_cli_vt100_color_t | color , | ||
| char const * | p_fmt , | ||
| ... | |||
| ) |
Printf-like function which sends formatted data stream to the CLI. This function shall not be used outside of the CLI module or CLI command context.
- Parameters
-
[in] p_cli Pointer to the CLI instance. [in] color Printf color. [in] p_fmt Format string. [in] ... List of parameters to print.
| void nrf_cli_help_print | ( | nrf_cli_t const * | p_cli , |
| nrf_cli_getopt_option_t const * | p_opt , | ||
| size_t | opt_len | ||
| ) |
Prints the current command help.
Function will print a help string with: the currently entered command, its options, and subcommands (if they exist).
- Parameters
-
[in] p_cli Pointer to the CLI instance. [in] p_opt Pointer to the optional option array. [in] opt_len Option array size.
| __STATIC_INLINE bool nrf_cli_help_requested | ( | nrf_cli_t const * | p_cli | ) |
Informs that a command has been called with -h or –help option.
- Parameters
-
[in] p_cli Pointer to the CLI instance.
- Returns
- True if help has been requested.
| ret_code_t nrf_cli_init | ( | nrf_cli_t const * | p_cli , |
| void const * | p_transport_config , | ||
| bool | use_colors , | ||
| bool | log_backend , | ||
| nrf_log_severity_t | init_lvl | ||
| ) |
Function for initializing a transport layer and internal CLI state.
- Parameters
-
[in] p_cli Pointer to CLI instance. [in] p_transport_config Configuration forwarded to the transport during initialization. [in] use_colors Enables colored prints. [in] log_backend If true, the console will be used as logger backend. [in] init_lvl Default severity level for the logger.
- Returns
- Standard error code.
| void nrf_cli_process | ( | nrf_cli_t const * | p_cli | ) |
Process function, which should be executed when data is ready in the transport interface.
- Parameters
-
[in] p_cli Pointer to the CLI instance.
| ret_code_t nrf_cli_start | ( | nrf_cli_t const * | p_cli | ) |
Function for starting CLI processing.
- Parameters
-
p_cli Pointer to the CLI instance.
- Returns
- Standard error code.
| ret_code_t nrf_cli_stop | ( | nrf_cli_t const * | p_cli | ) |
Function for stopping CLI processing.
- Parameters
-
p_cli Pointer to CLI instance.
- Returns
- Standard error code.
| ret_code_t nrf_cli_uninit | ( | nrf_cli_t const * | p_cli | ) |
Function for uninitializing a transport layer and internal CLI state. If function returns NRF_ERROR_BUSY, you must call nrf_cli_process before calling nrf_cli_uninit again.
- Parameters
-
p_cli Pointer to CLI instance.
- Returns
- Standard error code.