Zephyr API Documentation
2.7.0-rc2
A Scalable Open Source RTOS
|
Shell API. More...
Data Structures | |
struct | shell_cmd_entry |
Shell command descriptor. More... | |
struct | shell_static_args |
struct | shell_static_entry |
struct | shell_transport_api |
Unified shell transport interface. More... | |
struct | shell_transport |
struct | shell_stats |
Shell statistics structure. More... | |
struct | shell_flags |
union | shell_internal |
struct | shell_ctx |
Shell instance context. More... | |
struct | shell |
Shell instance internals. More... | |
Macros | |
#define | SHELL_CMD_ARG_REGISTER(syntax, subcmd, help, handler, mandatory, optional) |
Macro for defining and adding a root command (level 0) with required number of arguments. More... | |
#define | SHELL_COND_CMD_ARG_REGISTER(flag, syntax, subcmd, help, handler, mandatory, optional) |
Macro for defining and adding a conditional root command (level 0) with required number of arguments. More... | |
#define | SHELL_CMD_REGISTER(syntax, subcmd, help, handler) SHELL_CMD_ARG_REGISTER(syntax, subcmd, help, handler, 0, 0) |
Macro for defining and adding a root command (level 0) with arguments. More... | |
#define | SHELL_COND_CMD_REGISTER(flag, syntax, subcmd, help, handler) SHELL_COND_CMD_ARG_REGISTER(flag, syntax, subcmd, help, handler, 0, 0) |
Macro for defining and adding a conditional root command (level 0) with arguments. More... | |
#define | SHELL_STATIC_SUBCMD_SET_CREATE(name, ...) |
Macro for creating a subcommand set. It must be used outside of any function body. More... | |
#define | SHELL_SUBCMD_SET_END {NULL} |
Define ending subcommands set. More... | |
#define | SHELL_DYNAMIC_CMD_CREATE(name, get) |
Macro for creating a dynamic entry. More... | |
#define | SHELL_CMD_ARG(syntax, subcmd, help, handler, mand, opt) SHELL_EXPR_CMD_ARG(1, syntax, subcmd, help, handler, mand, opt) |
Initializes a shell command with arguments. More... | |
#define | SHELL_COND_CMD_ARG(flag, syntax, subcmd, help, handler, mand, opt) |
Initializes a conditional shell command with arguments. More... | |
#define | SHELL_EXPR_CMD_ARG(_expr, _syntax, _subcmd, _help, _handler, _mand, _opt) |
Initializes a conditional shell command with arguments if expression gives non-zero result at compile time. More... | |
#define | SHELL_CMD(_syntax, _subcmd, _help, _handler) SHELL_CMD_ARG(_syntax, _subcmd, _help, _handler, 0, 0) |
Initializes a shell command. More... | |
#define | SHELL_COND_CMD(_flag, _syntax, _subcmd, _help, _handler) SHELL_COND_CMD_ARG(_flag, _syntax, _subcmd, _help, _handler, 0, 0) |
Initializes a conditional shell command. More... | |
#define | SHELL_EXPR_CMD(_expr, _syntax, _subcmd, _help, _handler) SHELL_EXPR_CMD_ARG(_expr, _syntax, _subcmd, _help, _handler, 0, 0) |
Initializes shell command if expression gives non-zero result at compile time. More... | |
#define | SHELL_CMD_DICT_CREATE(_data) |
#define | SHELL_SUBCMD_DICT_SET_CREATE(_name, _handler, ...) |
Initializes shell dictionary commands. More... | |
#define | SHELL_DEFINE(_name, _prompt, _transport_iface, _log_queue_size, _log_timeout, _shell_flag) |
Macro for defining a shell instance. More... | |
#define | SHELL_NORMAL SHELL_VT100_COLOR_DEFAULT |
Terminal default text color for shell_fprintf function. More... | |
#define | SHELL_INFO SHELL_VT100_COLOR_GREEN |
Green text color for shell_fprintf function. More... | |
#define | SHELL_OPTION SHELL_VT100_COLOR_CYAN |
Cyan text color for shell_fprintf function. More... | |
#define | SHELL_WARNING SHELL_VT100_COLOR_YELLOW |
Yellow text color for shell_fprintf function. More... | |
#define | SHELL_ERROR SHELL_VT100_COLOR_RED |
Red text color for shell_fprintf function. More... | |
#define | shell_info(_sh, _ft, ...) shell_fprintf(_sh, SHELL_INFO, _ft "\n", ##__VA_ARGS__) |
Print info message to the shell. More... | |
#define | shell_print(_sh, _ft, ...) shell_fprintf(_sh, SHELL_NORMAL, _ft "\n", ##__VA_ARGS__) |
Print normal message to the shell. More... | |
#define | shell_warn(_sh, _ft, ...) shell_fprintf(_sh, SHELL_WARNING, _ft "\n", ##__VA_ARGS__) |
Print warning message to the shell. More... | |
#define | shell_error(_sh, _ft, ...) shell_fprintf(_sh, SHELL_ERROR, _ft "\n", ##__VA_ARGS__) |
Print error message to the shell. More... | |
#define | SHELL_CMD_HELP_PRINTED (1) |
Typedefs | |
typedef void(* | shell_dynamic_get) (size_t idx, struct shell_static_entry *entry) |
Shell dynamic command descriptor. More... | |
typedef int(* | shell_cmd_handler) (const struct shell *shell, size_t argc, char **argv) |
Shell command handler prototype. More... | |
typedef int(* | shell_dict_cmd_handler) (const struct shell *shell, size_t argc, char **argv, void *data) |
Shell dictionary command handler prototype. More... | |
typedef void(* | shell_transport_handler_t) (enum shell_transport_evt evt, void *context) |
typedef void(* | shell_uninit_cb_t) (const struct shell *shell, int res) |
typedef void(* | shell_bypass_cb_t) (const struct shell *shell, uint8_t *data, size_t len) |
Bypass callback. More... | |
Enumerations | |
enum | shell_receive_state { SHELL_RECEIVE_DEFAULT , SHELL_RECEIVE_ESC , SHELL_RECEIVE_ESC_SEQ , SHELL_RECEIVE_TILDE_EXP } |
enum | shell_state { SHELL_STATE_UNINITIALIZED , SHELL_STATE_INITIALIZED , SHELL_STATE_ACTIVE , SHELL_STATE_PANIC_MODE_ACTIVE , SHELL_STATE_PANIC_MODE_INACTIVE } |
enum | shell_transport_evt { SHELL_TRANSPORT_EVT_RX_RDY , SHELL_TRANSPORT_EVT_TX_RDY } |
Shell transport event. More... | |
enum | shell_signal { SHELL_SIGNAL_RXRDY , SHELL_SIGNAL_LOG_MSG , SHELL_SIGNAL_KILL , SHELL_SIGNAL_TXDONE , SHELL_SIGNALS } |
enum | shell_flag { SHELL_FLAG_CRLF_DEFAULT = (1<<0) , SHELL_FLAG_OLF_CRLF = (1<<1) } |
Flags for setting shell output newline sequence. More... | |
Functions | |
const struct device * | shell_device_lookup (size_t idx, const char *prefix) |
Get by index a device that matches . More... | |
int | shell_init (const struct shell *shell, const void *transport_config, bool use_colors, bool log_backend, uint32_t init_log_level) |
Function for initializing a transport layer and internal shell state. More... | |
void | shell_uninit (const struct shell *shell, shell_uninit_cb_t cb) |
Uninitializes the transport layer and the internal shell state. More... | |
int | shell_start (const struct shell *shell) |
Function for starting shell processing. More... | |
int | shell_stop (const struct shell *shell) |
Function for stopping shell processing. More... | |
void | shell_fprintf (const struct shell *shell, enum shell_vt100_color color, const char *fmt,...) |
printf-like function which sends formatted data stream to the shell. More... | |
void | shell_vfprintf (const struct shell *shell, enum shell_vt100_color color, const char *fmt, va_list args) |
vprintf-like function which sends formatted data stream to the shell. More... | |
void | shell_hexdump_line (const struct shell *shell, unsigned int offset, const uint8_t *data, size_t len) |
Print a line of data in hexadecimal format. More... | |
void | shell_hexdump (const struct shell *shell, const uint8_t *data, size_t len) |
Print data in hexadecimal format. More... | |
void | shell_process (const struct shell *shell) |
Process function, which should be executed when data is ready in the transport interface. To be used if shell thread is disabled. More... | |
int | shell_prompt_change (const struct shell *shell, const char *prompt) |
Change displayed shell prompt. More... | |
void | shell_help (const struct shell *shell) |
Prints the current command help. More... | |
int | shell_execute_cmd (const struct shell *shell, const char *cmd) |
Execute command. More... | |
int | shell_set_root_cmd (const char *cmd) |
Set root command for all shell instances. More... | |
void | shell_set_bypass (const struct shell *shell, shell_bypass_cb_t bypass) |
Set bypass callback. More... | |
int | shell_insert_mode_set (const struct shell *shell, bool val) |
Allow application to control text insert mode. Value is modified atomically and the previous value is returned. More... | |
int | shell_use_colors_set (const struct shell *shell, bool val) |
Allow application to control whether terminal output uses colored syntax. Value is modified atomically and the previous value is returned. More... | |
int | shell_echo_set (const struct shell *shell, bool val) |
Allow application to control whether user input is echoed back. Value is modified atomically and the previous value is returned. More... | |
int | shell_obscure_set (const struct shell *shell, bool obscure) |
Allow application to control whether user input is obscured with asterisks – useful for implementing passwords. Value is modified atomically and the previous value is returned. More... | |
int | shell_mode_delete_set (const struct shell *shell, bool val) |
Allow application to control whether the delete key backspaces or deletes. Value is modified atomically and the previous value is returned. More... | |
Variables | |
const struct log_backend_api | log_backend_shell_api |
Shell API.
#define SHELL_CMD | ( | _syntax, | |
_subcmd, | |||
_help, | |||
_handler | |||
) | SHELL_CMD_ARG(_syntax, _subcmd, _help, _handler, 0, 0) |
#include <include/shell/shell.h>
Initializes a shell command.
[in] | _syntax | Command syntax (for example: history). |
[in] | _subcmd | Pointer to a subcommands array. |
[in] | _help | Pointer to a command help string. |
[in] | _handler | Pointer to a function handler. |
#define SHELL_CMD_ARG | ( | syntax, | |
subcmd, | |||
help, | |||
handler, | |||
mand, | |||
opt | |||
) | SHELL_EXPR_CMD_ARG(1, syntax, subcmd, help, handler, mand, opt) |
#include <include/shell/shell.h>
Initializes a shell command with arguments.
[in] | syntax | Command syntax (for example: history). |
[in] | subcmd | Pointer to a subcommands array. |
[in] | help | Pointer to a command help string. |
[in] | handler | Pointer to a function handler. |
[in] | mand | Number of mandatory arguments includig command name. |
[in] | opt | Number of optional arguments. |
#define SHELL_CMD_ARG_REGISTER | ( | syntax, | |
subcmd, | |||
help, | |||
handler, | |||
mandatory, | |||
optional | |||
) |
#include <include/shell/shell.h>
Macro for defining and adding a root command (level 0) with required number of arguments.
[in] | syntax | Command syntax (for example: history). |
[in] | subcmd | Pointer to a subcommands array. |
[in] | help | Pointer to a command help string. |
[in] | handler | Pointer to a function handler. |
[in] | mandatory | Number of mandatory arguments includig command name. |
[in] | optional | Number of optional arguments. |
#define SHELL_CMD_DICT_CREATE | ( | _data | ) |
#include <include/shell/shell.h>
#define SHELL_CMD_HELP_PRINTED (1) |
#include <include/shell/shell.h>
#define SHELL_CMD_REGISTER | ( | syntax, | |
subcmd, | |||
help, | |||
handler | |||
) | SHELL_CMD_ARG_REGISTER(syntax, subcmd, help, handler, 0, 0) |
#include <include/shell/shell.h>
Macro for defining and adding a root command (level 0) with arguments.
[in] | syntax | Command syntax (for example: history). |
[in] | subcmd | Pointer to a subcommands array. |
[in] | help | Pointer to a command help string. |
[in] | handler | Pointer to a function handler. |
#define SHELL_COND_CMD | ( | _flag, | |
_syntax, | |||
_subcmd, | |||
_help, | |||
_handler | |||
) | SHELL_COND_CMD_ARG(_flag, _syntax, _subcmd, _help, _handler, 0, 0) |
#include <include/shell/shell.h>
Initializes a conditional shell command.
[in] | _flag | Compile time flag. Command is present only if flag exists and equals 1. |
[in] | _syntax | Command syntax (for example: history). |
[in] | _subcmd | Pointer to a subcommands array. |
[in] | _help | Pointer to a command help string. |
[in] | _handler | Pointer to a function handler. |
#include <include/shell/shell.h>
Initializes a conditional shell command with arguments.
[in] | flag | Compile time flag. Command is present only if flag exists and equals 1. |
[in] | syntax | Command syntax (for example: history). |
[in] | subcmd | Pointer to a subcommands array. |
[in] | help | Pointer to a command help string. |
[in] | handler | Pointer to a function handler. |
[in] | mand | Number of mandatory arguments includig command name. |
[in] | opt | Number of optional arguments. |
#include <include/shell/shell.h>
Macro for defining and adding a conditional root command (level 0) with required number of arguments.
Macro can be used to create a command which can be conditionally present. It is and alternative to #ifdefs around command registration and command handler. If command is disabled handler and subcommands are removed from the application.
[in] | flag | Compile time flag. Command is present only if flag exists and equals 1. |
[in] | syntax | Command syntax (for example: history). |
[in] | subcmd | Pointer to a subcommands array. |
[in] | help | Pointer to a command help string. |
[in] | handler | Pointer to a function handler. |
[in] | mandatory | Number of mandatory arguments includig command name. |
[in] | optional | Number of optional arguments. |
#define SHELL_COND_CMD_REGISTER | ( | flag, | |
syntax, | |||
subcmd, | |||
help, | |||
handler | |||
) | SHELL_COND_CMD_ARG_REGISTER(flag, syntax, subcmd, help, handler, 0, 0) |
#include <include/shell/shell.h>
Macro for defining and adding a conditional root command (level 0) with arguments.
[in] | flag | Compile time flag. Command is present only if flag exists and equals 1. |
[in] | syntax | Command syntax (for example: history). |
[in] | subcmd | Pointer to a subcommands array. |
[in] | help | Pointer to a command help string. |
[in] | handler | Pointer to a function handler. |
#define SHELL_DEFINE | ( | _name, | |
_prompt, | |||
_transport_iface, | |||
_log_queue_size, | |||
_log_timeout, | |||
_shell_flag | |||
) |
#include <include/shell/shell.h>
Macro for defining a shell instance.
[in] | _name | Instance name. |
[in] | _prompt | Shell default prompt string. |
[in] | _transport_iface | Pointer to the transport interface. |
[in] | _log_queue_size | Logger processing queue size. |
[in] | _log_timeout | Logger thread timeout in milliseconds on full log queue. If queue is full logger thread is blocked for given amount of time before log message is dropped. |
[in] | _shell_flag | Shell output newline sequence. |
#define SHELL_DYNAMIC_CMD_CREATE | ( | name, | |
get | |||
) |
#include <include/shell/shell.h>
Macro for creating a dynamic entry.
[in] | name | Name of the dynamic entry. |
[in] | get | Pointer to the function returning dynamic commands array |
#define SHELL_ERROR SHELL_VT100_COLOR_RED |
#include <include/shell/shell.h>
Red text color for shell_fprintf function.
#define shell_error | ( | _sh, | |
_ft, | |||
... | |||
) | shell_fprintf(_sh, SHELL_ERROR, _ft "\n", ##__VA_ARGS__) |
#include <include/shell/shell.h>
Print error message to the shell.
See shell_fprintf.
[in] | _sh | Pointer to the shell instance. |
[in] | _ft | Format string. |
[in] | ... | List of parameters to print. |
#define SHELL_EXPR_CMD | ( | _expr, | |
_syntax, | |||
_subcmd, | |||
_help, | |||
_handler | |||
) | SHELL_EXPR_CMD_ARG(_expr, _syntax, _subcmd, _help, _handler, 0, 0) |
#include <include/shell/shell.h>
Initializes shell command if expression gives non-zero result at compile time.
[in] | _expr | Compile time expression. Command is present only if expression is non-zero. |
[in] | _syntax | Command syntax (for example: history). |
[in] | _subcmd | Pointer to a subcommands array. |
[in] | _help | Pointer to a command help string. |
[in] | _handler | Pointer to a function handler. |
#define SHELL_EXPR_CMD_ARG | ( | _expr, | |
_syntax, | |||
_subcmd, | |||
_help, | |||
_handler, | |||
_mand, | |||
_opt | |||
) |
#include <include/shell/shell.h>
Initializes a conditional shell command with arguments if expression gives non-zero result at compile time.
[in] | _expr | Expression. |
[in] | _syntax | Command syntax (for example: history). |
[in] | _subcmd | Pointer to a subcommands array. |
[in] | _help | Pointer to a command help string. |
[in] | _handler | Pointer to a function handler. |
[in] | _mand | Number of mandatory arguments includig command name. |
[in] | _opt | Number of optional arguments. |
#define SHELL_INFO SHELL_VT100_COLOR_GREEN |
#include <include/shell/shell.h>
Green text color for shell_fprintf function.
#define shell_info | ( | _sh, | |
_ft, | |||
... | |||
) | shell_fprintf(_sh, SHELL_INFO, _ft "\n", ##__VA_ARGS__) |
#include <include/shell/shell.h>
Print info message to the shell.
See shell_fprintf.
[in] | _sh | Pointer to the shell instance. |
[in] | _ft | Format string. |
[in] | ... | List of parameters to print. |
#define SHELL_NORMAL SHELL_VT100_COLOR_DEFAULT |
#include <include/shell/shell.h>
Terminal default text color for shell_fprintf function.
#define SHELL_OPTION SHELL_VT100_COLOR_CYAN |
#include <include/shell/shell.h>
Cyan text color for shell_fprintf function.
#define shell_print | ( | _sh, | |
_ft, | |||
... | |||
) | shell_fprintf(_sh, SHELL_NORMAL, _ft "\n", ##__VA_ARGS__) |
#include <include/shell/shell.h>
Print normal message to the shell.
See shell_fprintf.
[in] | _sh | Pointer to the shell instance. |
[in] | _ft | Format string. |
[in] | ... | List of parameters to print. |
#define SHELL_STATIC_SUBCMD_SET_CREATE | ( | name, | |
... | |||
) |
#include <include/shell/shell.h>
Macro for creating a subcommand set. It must be used outside of any function body.
Example usage: SHELL_STATIC_SUBCMD_SET_CREATE( foo, SHELL_CMD(abc, ...), SHELL_CMD(def, ...), SHELL_SUBCMD_SET_END )
[in] | name | Name of the subcommand set. |
[in] | ... | List of commands created with SHELL_CMD_ARG or or SHELL_CMD |
#define SHELL_SUBCMD_DICT_SET_CREATE | ( | _name, | |
_handler, | |||
... | |||
) |
#include <include/shell/shell.h>
Initializes shell dictionary commands.
This is a special kind of static commands. Dictionary commands can be used every time you want to use a pair: (string <-> corresponding data) in a command handler. The string is usually a verbal description of a given data. The idea is to use the string as a command syntax that can be prompted by the shell and corresponding data can be used to process the command.
[in] | _name | Name of the dictionary subcommand set |
[in] | _handler | Command handler common for all dictionary commands. |
[in] | ... | Dictionary pairs: (command_syntax, value). Value will be passed to the _handler as user data. |
Example usage: static int my_handler(const struct shell *shell, size_t argc, char **argv, void *data) { int val = (int)data;
shell_print(shell, "(syntax, value) : (%s, %d)", argv[0], val); return 0; }
SHELL_SUBCMD_DICT_SET_CREATE(sub_dict_cmds, my_handler, (value_0, 0), (value_1, 1), (value_2, 2), (value_3, 3) ); SHELL_CMD_REGISTER(dictionary, &sub_dict_cmds, NULL, NULL);
#define SHELL_SUBCMD_SET_END {NULL} |
#include <include/shell/shell.h>
Define ending subcommands set.
#define shell_warn | ( | _sh, | |
_ft, | |||
... | |||
) | shell_fprintf(_sh, SHELL_WARNING, _ft "\n", ##__VA_ARGS__) |
#include <include/shell/shell.h>
Print warning message to the shell.
See shell_fprintf.
[in] | _sh | Pointer to the shell instance. |
[in] | _ft | Format string. |
[in] | ... | List of parameters to print. |
#define SHELL_WARNING SHELL_VT100_COLOR_YELLOW |
#include <include/shell/shell.h>
Yellow text color for shell_fprintf function.
#include <include/shell/shell.h>
Bypass callback.
shell | Shell instance. |
data | Raw data from transport. |
len | Data length. |
#include <include/shell/shell.h>
Shell command handler prototype.
shell | Shell instance. |
argc | Arguments count. |
argv | Arguments. |
0 | Successful command execution. |
1 | Help printed and command not executed. |
-EINVAL | Argument validation failed. |
-ENOEXEC | Command not executed. |
typedef int(* shell_dict_cmd_handler) (const struct shell *shell, size_t argc, char **argv, void *data) |
#include <include/shell/shell.h>
Shell dictionary command handler prototype.
shell | Shell instance. |
argc | Arguments count. |
argv | Arguments. |
data | Pointer to the user data. |
0 | Successful command execution. |
1 | Help printed and command not executed. |
-EINVAL | Argument validation failed. |
-ENOEXEC | Command not executed. |
typedef void(* shell_dynamic_get) (size_t idx, struct shell_static_entry *entry) |
#include <include/shell/shell.h>
Shell dynamic command descriptor.
Function shall fill the received shell_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: entry->syntax are sorted in alphabetical order. If idx exceeds the available dynamic subcommands, the function must write to entry->syntax NULL value. This will indicate to the shell module that there are no more dynamic commands to read.
typedef void(* shell_transport_handler_t) (enum shell_transport_evt evt, void *context) |
#include <include/shell/shell.h>
#include <include/shell/shell.h>
enum shell_flag |
#include <include/shell/shell.h>
Flags for setting shell output newline sequence.
Enumerator | |
---|---|
SHELL_FLAG_CRLF_DEFAULT | |
SHELL_FLAG_OLF_CRLF |
enum shell_receive_state |
#include <include/shell/shell.h>
Enumerator | |
---|---|
SHELL_RECEIVE_DEFAULT | |
SHELL_RECEIVE_ESC | |
SHELL_RECEIVE_ESC_SEQ | |
SHELL_RECEIVE_TILDE_EXP |
enum shell_signal |
#include <include/shell/shell.h>
Enumerator | |
---|---|
SHELL_SIGNAL_RXRDY | |
SHELL_SIGNAL_LOG_MSG | |
SHELL_SIGNAL_KILL | |
SHELL_SIGNAL_TXDONE | |
SHELL_SIGNALS |
enum shell_state |
#include <include/shell/shell.h>
Enumerator | |
---|---|
SHELL_STATE_UNINITIALIZED | |
SHELL_STATE_INITIALIZED | |
SHELL_STATE_ACTIVE | |
SHELL_STATE_PANIC_MODE_ACTIVE | Panic activated. |
SHELL_STATE_PANIC_MODE_INACTIVE | Panic requested, not supported. |
enum shell_transport_evt |
#include <include/shell/shell.h>
Shell transport event.
Enumerator | |
---|---|
SHELL_TRANSPORT_EVT_RX_RDY | |
SHELL_TRANSPORT_EVT_TX_RDY |
const struct device * shell_device_lookup | ( | size_t | idx, |
const char * | prefix | ||
) |
#include <include/shell/shell.h>
Get by index a device that matches .
This can be used, for example, to identify I2C_1 as the second I2C device.
Devices that failed to initialize or do not have a non-empty name are excluded from the candidates for a match.
idx | the device number starting from zero. |
prefix | optional name prefix used to restrict candidate devices. Indexing is done relative to devices with names that start with this text. Pass null if no prefix match is required. |
#include <include/shell/shell.h>
Allow application to control whether user input is echoed back. Value is modified atomically and the previous value is returned.
[in] | shell | Pointer to the shell instance. |
[in] | val | Echo mode. |
0 | or 1: previous value |
-EINVAL | if shell is NULL. |
int shell_execute_cmd | ( | const struct shell * | shell, |
const char * | cmd | ||
) |
#include <include/shell/shell.h>
Execute command.
Pass command line to shell to execute.
Note: This by no means makes any of the commands a stable interface, so this function should only be used for debugging/diagnostic.
This function must not be called from shell command context!
[in] | shell | Pointer to the shell instance. It can be NULL when the embed:rst:inline :kconfig:`CONFIG_SHELL_BACKEND_DUMMY`option is enabled. |
[in] | cmd | Command to be executed. |
void shell_fprintf | ( | const struct shell * | shell, |
enum shell_vt100_color | color, | ||
const char * | fmt, | ||
... | |||
) |
#include <include/shell/shell.h>
printf-like function which sends formatted data stream to the shell.
This function can be used from the command handler or from threads, but not from an interrupt context.
[in] | shell | Pointer to the shell instance. |
[in] | color | Printed text color. |
[in] | fmt | Format string. |
[in] | ... | List of parameters to print. |
#include <include/shell/shell.h>
Prints the current command help.
Function will print a help string with: the currently entered command and subcommands (if they exist).
[in] | shell | Pointer to the shell instance. |
#include <include/shell/shell.h>
Print data in hexadecimal format.
[in] | shell | Pointer to the shell instance. |
[in] | data | Pointer to data. |
[in] | len | Length of data. |
void shell_hexdump_line | ( | const struct shell * | shell, |
unsigned int | offset, | ||
const uint8_t * | data, | ||
size_t | len | ||
) |
#include <include/shell/shell.h>
Print a line of data in hexadecimal format.
Each line shows the offset, bytes and then ASCII representation.
For example:
00008010: 20 25 00 20 2f 48 00 08 80 05 00 20 af 46 00 | %. /H.. ... .F. |
[in] | shell | Pointer to the shell instance. |
[in] | offset | Offset to show for this line. |
[in] | data | Pointer to data. |
[in] | len | Length of data. |
int shell_init | ( | const struct shell * | shell, |
const void * | transport_config, | ||
bool | use_colors, | ||
bool | log_backend, | ||
uint32_t | init_log_level | ||
) |
#include <include/shell/shell.h>
Function for initializing a transport layer and internal shell state.
[in] | shell | Pointer to shell instance. |
[in] | transport_config | Transport configuration during initialization. |
[in] | use_colors | Enables colored prints. |
[in] | log_backend | If true, the console will be used as logger backend. |
[in] | init_log_level | Default severity level for the logger. |
#include <include/shell/shell.h>
Allow application to control text insert mode. Value is modified atomically and the previous value is returned.
[in] | shell | Pointer to the shell instance. |
[in] | val | Insert mode. |
0 | or 1: previous value |
-EINVAL | if shell is NULL. |
#include <include/shell/shell.h>
Allow application to control whether the delete key backspaces or deletes. Value is modified atomically and the previous value is returned.
[in] | shell | Pointer to the shell instance. |
[in] | val | Delete mode. |
0 | or 1: previous value |
-EINVAL | if shell is NULL. |
#include <include/shell/shell.h>
Allow application to control whether user input is obscured with asterisks – useful for implementing passwords. Value is modified atomically and the previous value is returned.
[in] | shell | Pointer to the shell instance. |
[in] | obscure | Obscure mode. |
0 | or 1: previous value. |
-EINVAL | if shell is NULL. |
#include <include/shell/shell.h>
Process function, which should be executed when data is ready in the transport interface. To be used if shell thread is disabled.
[in] | shell | Pointer to the shell instance. |
int shell_prompt_change | ( | const struct shell * | shell, |
const char * | prompt | ||
) |
#include <include/shell/shell.h>
Change displayed shell prompt.
[in] | shell | Pointer to the shell instance. |
[in] | prompt | New shell prompt. |
void shell_set_bypass | ( | const struct shell * | shell, |
shell_bypass_cb_t | bypass | ||
) |
#include <include/shell/shell.h>
Set bypass callback.
Bypass callback is called whenever data is received. Shell is bypassed and data is passed directly to the callback. Use null to disable bypass functionality.
[in] | shell | Pointer to the shell instance. |
[in] | bypass | Bypass callback or null to disable. |
int shell_set_root_cmd | ( | const char * | cmd | ) |
#include <include/shell/shell.h>
Set root command for all shell instances.
It allows setting from the code the root command. It is an equivalent of calling select command with one of the root commands as the argument (e.g "select log") except it sets command for all shell instances.
cmd | String with one of the root commands or null pointer to reset. |
0 | if root command is set. |
-EINVAL | if invalid root command is provided. |
int shell_start | ( | const struct shell * | shell | ) |
#include <include/shell/shell.h>
Function for starting shell processing.
shell | Pointer to the shell instance. |
int shell_stop | ( | const struct shell * | shell | ) |
#include <include/shell/shell.h>
Function for stopping shell processing.
shell | Pointer to shell instance. |
void shell_uninit | ( | const struct shell * | shell, |
shell_uninit_cb_t | cb | ||
) |
#include <include/shell/shell.h>
Uninitializes the transport layer and the internal shell state.
shell | Pointer to shell instance. |
cb | Callback called when uninitialization is completed. |
#include <include/shell/shell.h>
Allow application to control whether terminal output uses colored syntax. Value is modified atomically and the previous value is returned.
[in] | shell | Pointer to the shell instance. |
[in] | val | Color mode. |
0 | or 1: previous value |
-EINVAL | if shell is NULL. |
void shell_vfprintf | ( | const struct shell * | shell, |
enum shell_vt100_color | color, | ||
const char * | fmt, | ||
va_list | args | ||
) |
#include <include/shell/shell.h>
vprintf-like function which sends formatted data stream to the shell.
This function can be used from the command handler or from threads, but not from an interrupt context. It is similar to shell_fprintf() but takes a va_list instead of variable arguments.
[in] | shell | Pointer to the shell instance. |
[in] | color | Printed text color. |
[in] | fmt | Format string. |
[in] | args | List of parameters to print. |
|
extern |
#include <include/shell/shell.h>