Zephyr Project API  3.4.0
A Scalable Open Source RTOS
shell.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#ifndef SHELL_H__
8#define SHELL_H__
9
10#include <zephyr/kernel.h>
17#include <zephyr/logging/log.h>
19#include <zephyr/sys/util.h>
20
21#if defined CONFIG_SHELL_GETOPT
22#include <getopt.h>
23#endif
24
25#ifdef __cplusplus
26extern "C" {
27#endif
28
29#ifndef CONFIG_SHELL_CMD_BUFF_SIZE
30#define CONFIG_SHELL_CMD_BUFF_SIZE 0
31#endif
32
33#ifndef CONFIG_SHELL_PRINTF_BUFF_SIZE
34#define CONFIG_SHELL_PRINTF_BUFF_SIZE 0
35#endif
36
37#ifndef CONFIG_SHELL_HISTORY_BUFFER
38#define CONFIG_SHELL_HISTORY_BUFFER 0
39#endif
40
41#define Z_SHELL_CMD_ROOT_LVL (0u)
42
43#define SHELL_HEXDUMP_BYTES_IN_LINE 16
44
56#define SHELL_OPT_ARG_RAW (0xFE)
57
61#define SHELL_OPT_ARG_CHECK_SKIP (0xFF)
62
67#define SHELL_OPT_ARG_MAX (0xFD)
68
77
89typedef void (*shell_dynamic_get)(size_t idx,
90 struct shell_static_entry *entry);
91
98
101};
102
103struct shell;
104
108};
109
125const struct device *shell_device_lookup(size_t idx,
126 const char *prefix);
127
140typedef int (*shell_cmd_handler)(const struct shell *sh,
141 size_t argc, char **argv);
142
156typedef int (*shell_dict_cmd_handler)(const struct shell *sh, size_t argc,
157 char **argv, void *data);
158
159/* When entries are added to the memory section a padding is applied for
160 * native_posix_64 and x86_64 targets. Adding padding to allow handle data
161 * in the memory section as array.
162 */
163#if (defined(CONFIG_ARCH_POSIX) && defined(CONFIG_64BIT)) || defined(CONFIG_X86_64)
164#define Z_SHELL_STATIC_ENTRY_PADDING 24
165#else
166#define Z_SHELL_STATIC_ENTRY_PADDING 0
167#endif
168
169/*
170 * @brief Shell static command descriptor.
171 */
173 const char *syntax;
174 const char *help;
175 const union shell_cmd_entry *subcmd;
178 uint8_t padding[Z_SHELL_STATIC_ENTRY_PADDING];
179};
180
196#define SHELL_CMD_ARG_REGISTER(syntax, subcmd, help, handler, \
197 mandatory, optional) \
198 static const struct shell_static_entry UTIL_CAT(_shell_, syntax) = \
199 SHELL_CMD_ARG(syntax, subcmd, help, handler, mandatory, optional); \
200 static const TYPE_SECTION_ITERABLE(union shell_cmd_entry, \
201 UTIL_CAT(shell_cmd_, syntax), shell_root_cmds, \
202 UTIL_CAT(shell_cmd_, syntax) \
203 ) = { \
204 .entry = &UTIL_CAT(_shell_, syntax) \
205 }
206
227#define SHELL_COND_CMD_ARG_REGISTER(flag, syntax, subcmd, help, handler, \
228 mandatory, optional) \
229 COND_CODE_1(\
230 flag, \
231 (\
232 SHELL_CMD_ARG_REGISTER(syntax, subcmd, help, handler, \
233 mandatory, optional) \
234 ), \
235 (\
236 static shell_cmd_handler dummy_##syntax##_handler __unused = \
237 handler;\
238 static const union shell_cmd_entry *dummy_subcmd_##syntax \
239 __unused = subcmd\
240 ) \
241 )
253#define SHELL_CMD_REGISTER(syntax, subcmd, help, handler) \
254 SHELL_CMD_ARG_REGISTER(syntax, subcmd, help, handler, 0, 0)
255
269#define SHELL_COND_CMD_REGISTER(flag, syntax, subcmd, help, handler) \
270 SHELL_COND_CMD_ARG_REGISTER(flag, syntax, subcmd, help, handler, 0, 0)
271
288#define SHELL_STATIC_SUBCMD_SET_CREATE(name, ...) \
289 static const struct shell_static_entry shell_##name[] = { \
290 __VA_ARGS__ \
291 }; \
292 static const union shell_cmd_entry name = { \
293 .entry = shell_##name \
294 }
295
296#define Z_SHELL_UNDERSCORE(x) _##x
297#define Z_SHELL_SUBCMD_NAME(...) \
298 UTIL_CAT(shell_subcmds, MACRO_MAP_CAT(Z_SHELL_UNDERSCORE, __VA_ARGS__))
299#define Z_SHELL_SUBCMD_SECTION_TAG(...) MACRO_MAP_CAT(Z_SHELL_UNDERSCORE, __VA_ARGS__)
300#define Z_SHELL_SUBCMD_SET_SECTION_TAG(x) \
301 Z_SHELL_SUBCMD_SECTION_TAG(NUM_VA_ARGS_LESS_1 x, __DEBRACKET x)
302#define Z_SHELL_SUBCMD_ADD_SECTION_TAG(x, y) \
303 Z_SHELL_SUBCMD_SECTION_TAG(NUM_VA_ARGS_LESS_1 x, __DEBRACKET x, y)
304
317#define SHELL_SUBCMD_SET_CREATE(_name, _parent) \
318 static const TYPE_SECTION_ITERABLE(struct shell_static_entry, _name, shell_subcmds, \
319 Z_SHELL_SUBCMD_SET_SECTION_TAG(_parent))
320
321
341#define SHELL_SUBCMD_COND_ADD(_flag, _parent, _syntax, _subcmd, _help, _handler, \
342 _mand, _opt) \
343 COND_CODE_1(_flag, \
344 (static const TYPE_SECTION_ITERABLE(struct shell_static_entry, \
345 Z_SHELL_SUBCMD_NAME(__DEBRACKET _parent, _syntax), \
346 shell_subcmds, \
347 Z_SHELL_SUBCMD_ADD_SECTION_TAG(_parent, _syntax)) = \
348 SHELL_EXPR_CMD_ARG(1, _syntax, _subcmd, _help, \
349 _handler, _mand, _opt)\
350 ), \
351 (static shell_cmd_handler dummy_##syntax##_handler __unused = _handler;\
352 static const union shell_cmd_entry dummy_subcmd_##syntax __unused = { \
353 .entry = (const struct shell_static_entry *)_subcmd\
354 } \
355 ) \
356 )
357
370#define SHELL_SUBCMD_ADD(_parent, _syntax, _subcmd, _help, _handler, _mand, _opt) \
371 SHELL_SUBCMD_COND_ADD(1, _parent, _syntax, _subcmd, _help, _handler, _mand, _opt)
372
377#define SHELL_SUBCMD_SET_END {NULL}
378
385#define SHELL_DYNAMIC_CMD_CREATE(name, get) \
386 static const TYPE_SECTION_ITERABLE(union shell_cmd_entry, name, \
387 shell_dynamic_subcmds, name) = \
388 { \
389 .dynamic_get = get \
390 }
391
405#define SHELL_CMD_ARG(syntax, subcmd, help, handler, mand, opt) \
406 SHELL_EXPR_CMD_ARG(1, syntax, subcmd, help, handler, mand, opt)
407
427#define SHELL_COND_CMD_ARG(flag, syntax, subcmd, help, handler, mand, opt) \
428 SHELL_EXPR_CMD_ARG(IS_ENABLED(flag), syntax, subcmd, help, \
429 handler, mand, opt)
430
450#define SHELL_EXPR_CMD_ARG(_expr, _syntax, _subcmd, _help, _handler, \
451 _mand, _opt) \
452 { \
453 .syntax = (_expr) ? (const char *)STRINGIFY(_syntax) : "", \
454 .help = (_expr) ? (const char *)_help : NULL, \
455 .subcmd = (const union shell_cmd_entry *)((_expr) ? \
456 _subcmd : NULL), \
457 .handler = (shell_cmd_handler)((_expr) ? _handler : NULL), \
458 .args = { .mandatory = _mand, .optional = _opt} \
459 }
460
469#define SHELL_CMD(_syntax, _subcmd, _help, _handler) \
470 SHELL_CMD_ARG(_syntax, _subcmd, _help, _handler, 0, 0)
471
484#define SHELL_COND_CMD(_flag, _syntax, _subcmd, _help, _handler) \
485 SHELL_COND_CMD_ARG(_flag, _syntax, _subcmd, _help, _handler, 0, 0)
486
500#define SHELL_EXPR_CMD(_expr, _syntax, _subcmd, _help, _handler) \
501 SHELL_EXPR_CMD_ARG(_expr, _syntax, _subcmd, _help, _handler, 0, 0)
502
503/* Internal macro used for creating handlers for dictionary commands. */
504#define Z_SHELL_CMD_DICT_HANDLER_CREATE(_data, _handler) \
505static int UTIL_CAT(UTIL_CAT(cmd_dict_, UTIL_CAT(_handler, _)), \
506 GET_ARG_N(1, __DEBRACKET _data))( \
507 const struct shell *sh, size_t argc, char **argv) \
508{ \
509 return _handler(sh, argc, argv, \
510 (void *)GET_ARG_N(2, __DEBRACKET _data)); \
511}
512
513/* Internal macro used for creating dictionary commands. */
514#define SHELL_CMD_DICT_CREATE(_data, _handler) \
515 SHELL_CMD_ARG(GET_ARG_N(1, __DEBRACKET _data), NULL, GET_ARG_N(3, __DEBRACKET _data), \
516 UTIL_CAT(UTIL_CAT(cmd_dict_, UTIL_CAT(_handler, _)), \
517 GET_ARG_N(1, __DEBRACKET _data)), 1, 0)
518
550#define SHELL_SUBCMD_DICT_SET_CREATE(_name, _handler, ...) \
551 FOR_EACH_FIXED_ARG(Z_SHELL_CMD_DICT_HANDLER_CREATE, (), \
552 _handler, __VA_ARGS__) \
553 SHELL_STATIC_SUBCMD_SET_CREATE(_name, \
554 FOR_EACH_FIXED_ARG(SHELL_CMD_DICT_CREATE, (,), _handler, __VA_ARGS__), \
555 SHELL_SUBCMD_SET_END \
556 )
557
568
579
585
587 void *context);
588
589
590typedef void (*shell_uninit_cb_t)(const struct shell *sh, int res);
591
598typedef void (*shell_bypass_cb_t)(const struct shell *sh,
599 uint8_t *data,
600 size_t len);
601
602struct shell_transport;
603
619 int (*init)(const struct shell_transport *transport,
620 const void *config,
621 shell_transport_handler_t evt_handler,
622 void *context);
623
631 int (*uninit)(const struct shell_transport *transport);
632
645 int (*enable)(const struct shell_transport *transport,
646 bool blocking_tx);
647
658 int (*write)(const struct shell_transport *transport,
659 const void *data, size_t length, size_t *cnt);
660
671 int (*read)(const struct shell_transport *transport,
672 void *data, size_t length, size_t *cnt);
673
681 void (*update)(const struct shell_transport *transport);
682
683};
684
687 void *ctx;
688};
689
695};
696
697#ifdef CONFIG_SHELL_STATS
698#define Z_SHELL_STATS_DEFINE(_name) static struct shell_stats _name##_stats
699#define Z_SHELL_STATS_PTR(_name) (&(_name##_stats))
700#else
701#define Z_SHELL_STATS_DEFINE(_name)
702#define Z_SHELL_STATS_PTR(_name) NULL
703#endif /* CONFIG_SHELL_STATS */
704
715};
716
717BUILD_ASSERT((sizeof(struct shell_backend_config_flags) == sizeof(uint32_t)),
718 "Structure must fit in 4 bytes");
719
723#define SHELL_DEFAULT_BACKEND_CONFIG_FLAGS \
724{ \
725 .insert_mode = 0, \
726 .echo = 1, \
727 .obscure = IS_ENABLED(CONFIG_SHELL_START_OBSCURED), \
728 .mode_delete = 1, \
729 .use_colors = 1, \
730 .use_vt100 = 1, \
731};
732
741};
742
743BUILD_ASSERT((sizeof(struct shell_backend_ctx_flags) == sizeof(uint32_t)),
744 "Structure must fit in 4 bytes");
745
752};
753
760};
761
766 SHELL_SIGNAL_TXDONE, /* TXDONE must be last one before SHELL_SIGNALS */
769
773struct shell_ctx {
774 const char *prompt;
781
782 /* New root command. If NULL shell uses default root commands. */
784
787
792
795
796#if defined CONFIG_SHELL_GETOPT
798 struct getopt_state getopt;
799#endif
800
808
811
814
815 volatile union shell_backend_cfg cfg;
816 volatile union shell_backend_ctx ctx;
817
819
824
828};
829
830extern const struct log_backend_api log_backend_shell_api;
831
836 SHELL_FLAG_CRLF_DEFAULT = (1<<0), /* Do not map CR or LF */
837 SHELL_FLAG_OLF_CRLF = (1<<1) /* Map LF to CRLF on output */
839
843struct shell {
844 const char *default_prompt;
846 const struct shell_transport *iface;
847 struct shell_ctx *ctx;
850
852
854
856
858
860
861 const char *thread_name;
864};
865
866extern void z_shell_print_stream(const void *user_ctx, const char *data,
867 size_t data_len);
881#define SHELL_DEFINE(_name, _prompt, _transport_iface, \
882 _log_queue_size, _log_timeout, _shell_flag) \
883 static const struct shell _name; \
884 static struct shell_ctx UTIL_CAT(_name, _ctx); \
885 static uint8_t _name##_out_buffer[CONFIG_SHELL_PRINTF_BUFF_SIZE]; \
886 Z_SHELL_LOG_BACKEND_DEFINE(_name, _name##_out_buffer, \
887 CONFIG_SHELL_PRINTF_BUFF_SIZE, \
888 _log_queue_size, _log_timeout); \
889 Z_SHELL_HISTORY_DEFINE(_name##_history, CONFIG_SHELL_HISTORY_BUFFER); \
890 Z_SHELL_FPRINTF_DEFINE(_name##_fprintf, &_name, _name##_out_buffer, \
891 CONFIG_SHELL_PRINTF_BUFF_SIZE, \
892 true, z_shell_print_stream); \
893 LOG_INSTANCE_REGISTER(shell, _name, CONFIG_SHELL_LOG_LEVEL); \
894 Z_SHELL_STATS_DEFINE(_name); \
895 static K_KERNEL_STACK_DEFINE(_name##_stack, CONFIG_SHELL_STACK_SIZE); \
896 static struct k_thread _name##_thread; \
897 static const STRUCT_SECTION_ITERABLE(shell, _name) = { \
898 .default_prompt = _prompt, \
899 .iface = _transport_iface, \
900 .ctx = &UTIL_CAT(_name, _ctx), \
901 .history = IS_ENABLED(CONFIG_SHELL_HISTORY) ? \
902 &_name##_history : NULL, \
903 .shell_flag = _shell_flag, \
904 .fprintf_ctx = &_name##_fprintf, \
905 .stats = Z_SHELL_STATS_PTR(_name), \
906 .log_backend = Z_SHELL_LOG_BACKEND_PTR(_name), \
907 LOG_INSTANCE_PTR_INIT(log, shell, _name) \
908 .thread_name = STRINGIFY(_name), \
909 .thread = &_name##_thread, \
910 .stack = _name##_stack \
911 }
912
926int shell_init(const struct shell *sh, const void *transport_config,
927 struct shell_backend_config_flags cfg_flags,
928 bool log_backend, uint32_t init_log_level);
929
936void shell_uninit(const struct shell *sh, shell_uninit_cb_t cb);
937
945int shell_start(const struct shell *sh);
946
954int shell_stop(const struct shell *sh);
955
959#define SHELL_NORMAL SHELL_VT100_COLOR_DEFAULT
960
964#define SHELL_INFO SHELL_VT100_COLOR_GREEN
965
969#define SHELL_OPTION SHELL_VT100_COLOR_CYAN
970
974#define SHELL_WARNING SHELL_VT100_COLOR_YELLOW
975
979#define SHELL_ERROR SHELL_VT100_COLOR_RED
980
992void __printf_like(3, 4) shell_fprintf(const struct shell *sh,
993 enum shell_vt100_color color,
994 const char *fmt, ...);
995
1008void shell_vfprintf(const struct shell *sh, enum shell_vt100_color color,
1009 const char *fmt, va_list args);
1010
1026void shell_hexdump_line(const struct shell *sh, unsigned int offset,
1027 const uint8_t *data, size_t len);
1028
1036void shell_hexdump(const struct shell *sh, const uint8_t *data, size_t len);
1037
1047#define shell_info(_sh, _ft, ...) \
1048 shell_fprintf(_sh, SHELL_INFO, _ft "\n", ##__VA_ARGS__)
1049
1059#define shell_print(_sh, _ft, ...) \
1060 shell_fprintf(_sh, SHELL_NORMAL, _ft "\n", ##__VA_ARGS__)
1061
1071#define shell_warn(_sh, _ft, ...) \
1072 shell_fprintf(_sh, SHELL_WARNING, _ft "\n", ##__VA_ARGS__)
1073
1083#define shell_error(_sh, _ft, ...) \
1084 shell_fprintf(_sh, SHELL_ERROR, _ft "\n", ##__VA_ARGS__)
1085
1092void shell_process(const struct shell *sh);
1093
1103int shell_prompt_change(const struct shell *sh, const char *prompt);
1104
1113void shell_help(const struct shell *sh);
1114
1115/* @brief Command's help has been printed */
1116#define SHELL_CMD_HELP_PRINTED (1)
1117
1135int shell_execute_cmd(const struct shell *sh, const char *cmd);
1136
1148int shell_set_root_cmd(const char *cmd);
1149
1158void shell_set_bypass(const struct shell *sh, shell_bypass_cb_t bypass);
1159
1167bool shell_ready(const struct shell *sh);
1168
1179int shell_insert_mode_set(const struct shell *sh, bool val);
1180
1192int shell_use_colors_set(const struct shell *sh, bool val);
1193
1204int shell_use_vt100_set(const struct shell *sh, bool val);
1205
1216int shell_echo_set(const struct shell *sh, bool val);
1217
1229int shell_obscure_set(const struct shell *sh, bool obscure);
1230
1242int shell_mode_delete_set(const struct shell *sh, bool val);
1243
1251int shell_get_return_value(const struct shell *sh);
1252
1257#ifdef __cplusplus
1258}
1259#endif
1260
1261#endif /* SHELL_H__ */
struct z_thread_stack_element k_thread_stack_t
Typedef of struct z_thread_stack_element.
Definition: arch_interface.h:44
long atomic_t
Definition: atomic.h:22
static void cmd(uint32_t command)
Execute a display list command by co-processor engine.
Definition: ft8xx_reference_api.h:153
void shell_uninit(const struct shell *sh, shell_uninit_cb_t cb)
Uninitializes the transport layer and the internal shell state.
void(* shell_uninit_cb_t)(const struct shell *sh, int res)
Definition: shell.h:590
void shell_hexdump_line(const struct shell *sh, unsigned int offset, const uint8_t *data, size_t len)
Print a line of data in hexadecimal format.
int(* shell_dict_cmd_handler)(const struct shell *sh, size_t argc, char **argv, void *data)
Shell dictionary command handler prototype.
Definition: shell.h:156
int shell_prompt_change(const struct shell *sh, const char *prompt)
Change displayed shell prompt.
void(* shell_transport_handler_t)(enum shell_transport_evt evt, void *context)
Definition: shell.h:586
int shell_mode_delete_set(const struct shell *sh, bool val)
Allow application to control whether the delete key backspaces or deletes. Value is modified atomical...
int(* shell_cmd_handler)(const struct shell *sh, size_t argc, char **argv)
Shell command handler prototype.
Definition: shell.h:140
int shell_get_return_value(const struct shell *sh)
Retrieve return value of most recently executed shell command.
shell_flag
Flags for setting shell output newline sequence.
Definition: shell.h:835
const struct device * shell_device_lookup(size_t idx, const char *prefix)
Get by index a device that matches .
shell_signal
Definition: shell.h:762
void shell_vfprintf(const struct shell *sh, enum shell_vt100_color color, const char *fmt, va_list args)
vprintf-like function which sends formatted data stream to the shell.
void shell_set_bypass(const struct shell *sh, shell_bypass_cb_t bypass)
Set bypass callback.
int shell_set_root_cmd(const char *cmd)
Set root command for all shell instances.
bool shell_ready(const struct shell *sh)
Get shell readiness to execute commands.
int shell_use_colors_set(const struct shell *sh, bool val)
Allow application to control whether terminal output uses colored syntax. Value is modified atomicall...
void shell_process(const struct shell *sh)
Process function, which should be executed when data is ready in the transport interface....
int shell_use_vt100_set(const struct shell *sh, bool val)
Allow application to control whether terminal is using vt100 commands. Value is modified atomically a...
int shell_obscure_set(const struct shell *sh, bool obscure)
Allow application to control whether user input is obscured with asterisks – useful for implementing ...
int shell_init(const struct shell *sh, const void *transport_config, struct shell_backend_config_flags cfg_flags, bool log_backend, uint32_t init_log_level)
Function for initializing a transport layer and internal shell state.
shell_receive_state
Definition: shell.h:562
void(* shell_bypass_cb_t)(const struct shell *sh, uint8_t *data, size_t len)
Bypass callback.
Definition: shell.h:598
int shell_execute_cmd(const struct shell *sh, const char *cmd)
Execute command.
void shell_help(const struct shell *sh)
Prints the current command help.
int shell_stop(const struct shell *sh)
Function for stopping shell processing.
int shell_start(const struct shell *sh)
Function for starting shell processing.
int shell_echo_set(const struct shell *sh, bool val)
Allow application to control whether user input is echoed back. Value is modified atomically and the ...
const struct log_backend_api log_backend_shell_api
shell_transport_evt
Shell transport event.
Definition: shell.h:581
void shell_hexdump(const struct shell *sh, const uint8_t *data, size_t len)
Print data in hexadecimal format.
int shell_insert_mode_set(const struct shell *sh, bool val)
Allow application to control text insert mode. Value is modified atomically and the previous value is...
shell_state
Definition: shell.h:572
void(* shell_dynamic_get)(size_t idx, struct shell_static_entry *entry)
Shell dynamic command descriptor.
Definition: shell.h:89
@ SHELL_FLAG_CRLF_DEFAULT
Definition: shell.h:836
@ SHELL_FLAG_OLF_CRLF
Definition: shell.h:837
@ SHELL_SIGNALS
Definition: shell.h:767
@ SHELL_SIGNAL_TXDONE
Definition: shell.h:766
@ SHELL_SIGNAL_RXRDY
Definition: shell.h:763
@ SHELL_SIGNAL_LOG_MSG
Definition: shell.h:764
@ SHELL_SIGNAL_KILL
Definition: shell.h:765
@ SHELL_RECEIVE_DEFAULT
Definition: shell.h:563
@ SHELL_RECEIVE_ESC_SEQ
Definition: shell.h:565
@ SHELL_RECEIVE_ESC
Definition: shell.h:564
@ SHELL_RECEIVE_TILDE_EXP
Definition: shell.h:566
@ SHELL_TRANSPORT_EVT_TX_RDY
Definition: shell.h:583
@ SHELL_TRANSPORT_EVT_RX_RDY
Definition: shell.h:582
@ SHELL_STATE_UNINITIALIZED
Definition: shell.h:573
@ SHELL_STATE_PANIC_MODE_INACTIVE
Definition: shell.h:577
@ SHELL_STATE_ACTIVE
Definition: shell.h:575
@ SHELL_STATE_PANIC_MODE_ACTIVE
Definition: shell.h:576
@ SHELL_STATE_INITIALIZED
Definition: shell.h:574
Public kernel APIs.
flags
Definition: parser.h:96
#define CONFIG_SHELL_CMD_BUFF_SIZE
Definition: shell.h:30
#define CONFIG_SHELL_PRINTF_BUFF_SIZE
Definition: shell.h:34
shell_vt100_color
Definition: shell_types.h:14
__UINT32_TYPE__ uint32_t
Definition: stdint.h:90
__UINT8_TYPE__ uint8_t
Definition: stdint.h:88
__UINT16_TYPE__ uint16_t
Definition: stdint.h:89
Runtime device structure (in ROM) per driver instance.
Definition: device.h:380
Definition: kernel.h:2822
Poll Event.
Definition: kernel.h:5541
Definition: kernel.h:5517
Definition: thread.h:245
Logger backend API.
Definition: log_backend.h:63
Logger backend structure.
Definition: log_backend.h:94
Definition: shell.h:708
uint32_t use_vt100
Definition: shell.h:714
uint32_t mode_delete
Definition: shell.h:712
uint32_t echo
Definition: shell.h:710
uint32_t insert_mode
Definition: shell.h:709
uint32_t obscure
Definition: shell.h:711
uint32_t use_colors
Definition: shell.h:713
Definition: shell.h:733
uint32_t print_noinit
Definition: shell.h:739
uint32_t sync_mode
Definition: shell.h:740
uint32_t tx_rdy
Definition: shell.h:735
uint32_t processing
Definition: shell.h:734
uint32_t last_nl
Definition: shell.h:737
uint32_t history_exit
Definition: shell.h:736
uint32_t cmd_ctx
Definition: shell.h:738
Shell instance context.
Definition: shell.h:773
const struct shell_static_entry * selected_cmd
Definition: shell.h:783
shell_uninit_cb_t uninit_cb
Definition: shell.h:791
struct shell_vt100_ctx vt100_ctx
Definition: shell.h:786
const char * prompt
Definition: shell.h:774
k_tid_t tid
Definition: shell.h:826
char temp_buff[0]
Definition: shell.h:810
char cmd_buff[0]
Definition: shell.h:807
struct shell_static_entry active_cmd
Definition: shell.h:780
volatile union shell_backend_cfg cfg
Definition: shell.h:815
uint16_t cmd_tmp_buff_len
Definition: shell.h:804
struct k_poll_signal signals[SHELL_SIGNALS]
Definition: shell.h:818
enum shell_state state
Definition: shell.h:776
struct k_mutex wr_mtx
Definition: shell.h:825
shell_bypass_cb_t bypass
Definition: shell.h:794
uint16_t cmd_buff_len
Definition: shell.h:801
uint16_t cmd_buff_pos
Definition: shell.h:802
int ret_val
Definition: shell.h:827
char printf_buff[0]
Definition: shell.h:813
struct k_poll_event events[SHELL_SIGNALS]
Definition: shell.h:823
enum shell_receive_state receive_state
Definition: shell.h:777
volatile union shell_backend_ctx ctx
Definition: shell.h:816
fprintf context
Definition: shell_fprintf.h:29
Definition: shell_history.h:21
Shell log backend instance structure (RO data).
Definition: shell_log_backend.h:36
Definition: shell.h:105
uint8_t mandatory
Definition: shell.h:106
uint8_t optional
Definition: shell.h:107
Definition: shell.h:172
const union shell_cmd_entry * subcmd
Definition: shell.h:175
uint8_t padding[0]
Definition: shell.h:178
shell_cmd_handler handler
Definition: shell.h:176
struct shell_static_args args
Definition: shell.h:177
const char * help
Definition: shell.h:174
const char * syntax
Definition: shell.h:173
Shell statistics structure.
Definition: shell.h:693
atomic_t log_lost_cnt
Definition: shell.h:694
Unified shell transport interface.
Definition: shell.h:607
void(* update)(const struct shell_transport *transport)
Function called in shell thread loop.
Definition: shell.h:681
int(* init)(const struct shell_transport *transport, const void *config, shell_transport_handler_t evt_handler, void *context)
Function for initializing the shell transport interface.
Definition: shell.h:619
int(* write)(const struct shell_transport *transport, const void *data, size_t length, size_t *cnt)
Function for writing data to the transport interface.
Definition: shell.h:658
int(* uninit)(const struct shell_transport *transport)
Function for uninitializing the shell transport interface.
Definition: shell.h:631
int(* enable)(const struct shell_transport *transport, bool blocking_tx)
Function for enabling transport in given TX mode.
Definition: shell.h:645
int(* read)(const struct shell_transport *transport, void *data, size_t length, size_t *cnt)
Function for reading data from the transport interface.
Definition: shell.h:671
Definition: shell.h:685
void * ctx
Definition: shell.h:687
const struct shell_transport_api * api
Definition: shell.h:686
Definition: shell_types.h:44
Shell instance internals.
Definition: shell.h:843
struct k_thread * thread
Definition: shell.h:862
const char * thread_name
Definition: shell.h:861
LOG_INSTANCE_PTR_DECLARE(log)
enum shell_flag shell_flag
Definition: shell.h:851
const struct shell_log_backend * log_backend
Definition: shell.h:857
struct shell_history * history
Definition: shell.h:849
struct shell_stats * stats
Definition: shell.h:855
const char * default_prompt
Definition: shell.h:844
const struct shell_fprintf * fprintf_ctx
Definition: shell.h:853
struct shell_ctx * ctx
Definition: shell.h:847
const struct shell_transport * iface
Definition: shell.h:846
k_thread_stack_t * stack
Definition: shell.h:863
static fdata_t data[2]
Definition: test_fifo_contexts.c:15
Definition: shell.h:749
atomic_t value
Definition: shell.h:750
Definition: shell.h:757
uint32_t value
Definition: shell.h:758
Shell command descriptor.
Definition: shell.h:95
const struct shell_static_entry * entry
Definition: shell.h:100
shell_dynamic_get dynamic_get
Definition: shell.h:97
Misc utilities.