Zephyr Project API 3.7.0
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
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_PROMPT_BUFF_SIZE
30#define CONFIG_SHELL_PROMPT_BUFF_SIZE 0
31#endif
32
33#ifndef CONFIG_SHELL_CMD_BUFF_SIZE
34#define CONFIG_SHELL_CMD_BUFF_SIZE 0
35#endif
36
37#ifndef CONFIG_SHELL_PRINTF_BUFF_SIZE
38#define CONFIG_SHELL_PRINTF_BUFF_SIZE 0
39#endif
40
41#ifndef CONFIG_SHELL_HISTORY_BUFFER
42#define CONFIG_SHELL_HISTORY_BUFFER 0
43#endif
44
45#define Z_SHELL_CMD_ROOT_LVL (0u)
46
47#define SHELL_HEXDUMP_BYTES_IN_LINE 16
48
60#define SHELL_OPT_ARG_RAW (0xFE)
61
65#define SHELL_OPT_ARG_CHECK_SKIP (0xFF)
66
71#define SHELL_OPT_ARG_MAX (0xFD)
72
83
95typedef void (*shell_dynamic_get)(size_t idx,
96 struct shell_static_entry *entry);
97
108
109struct shell;
110
115
131const struct device *shell_device_lookup(size_t idx,
132 const char *prefix);
133
144typedef bool (*shell_device_filter_t)(const struct device *dev);
145
159const struct device *shell_device_filter(size_t idx,
160 shell_device_filter_t filter);
161
174typedef int (*shell_cmd_handler)(const struct shell *sh,
175 size_t argc, char **argv);
176
190typedef int (*shell_dict_cmd_handler)(const struct shell *sh, size_t argc,
191 char **argv, void *data);
192
193/* When entries are added to the memory section a padding is applied for
194 * native_posix_64 and x86_64 targets. Adding padding to allow handle data
195 * in the memory section as array.
196 */
197#if (defined(CONFIG_ARCH_POSIX) && defined(CONFIG_64BIT)) || defined(CONFIG_X86_64)
198#define Z_SHELL_STATIC_ENTRY_PADDING 24
199#else
200#define Z_SHELL_STATIC_ENTRY_PADDING 0
201#endif
202
203/*
204 * @brief Shell static command descriptor.
205 */
207 const char *syntax;
208 const char *help;
209 const union shell_cmd_entry *subcmd;
212 uint8_t padding[Z_SHELL_STATIC_ENTRY_PADDING];
213};
214
230#define SHELL_CMD_ARG_REGISTER(syntax, subcmd, help, handler, \
231 mandatory, optional) \
232 static const struct shell_static_entry UTIL_CAT(_shell_, syntax) = \
233 SHELL_CMD_ARG(syntax, subcmd, help, handler, mandatory, optional); \
234 static const TYPE_SECTION_ITERABLE(union shell_cmd_entry, \
235 UTIL_CAT(shell_cmd_, syntax), shell_root_cmds, \
236 UTIL_CAT(shell_cmd_, syntax) \
237 ) = { \
238 .entry = &UTIL_CAT(_shell_, syntax) \
239 }
240
261#define SHELL_COND_CMD_ARG_REGISTER(flag, syntax, subcmd, help, handler, \
262 mandatory, optional) \
263 COND_CODE_1(\
264 flag, \
265 (\
266 SHELL_CMD_ARG_REGISTER(syntax, subcmd, help, handler, \
267 mandatory, optional) \
268 ), \
269 (\
270 static shell_cmd_handler dummy_##syntax##_handler __unused = \
271 handler;\
272 static const union shell_cmd_entry *dummy_subcmd_##syntax \
273 __unused = subcmd\
274 ) \
275 )
287#define SHELL_CMD_REGISTER(syntax, subcmd, help, handler) \
288 SHELL_CMD_ARG_REGISTER(syntax, subcmd, help, handler, 0, 0)
289
303#define SHELL_COND_CMD_REGISTER(flag, syntax, subcmd, help, handler) \
304 SHELL_COND_CMD_ARG_REGISTER(flag, syntax, subcmd, help, handler, 0, 0)
305
324#define SHELL_STATIC_SUBCMD_SET_CREATE(name, ...) \
325 static const struct shell_static_entry shell_##name[] = { \
326 __VA_ARGS__ \
327 }; \
328 static const union shell_cmd_entry name = { \
329 .entry = shell_##name \
330 }
331
332#define Z_SHELL_UNDERSCORE(x) _##x
333#define Z_SHELL_SUBCMD_NAME(...) \
334 UTIL_CAT(shell_subcmds, MACRO_MAP_CAT(Z_SHELL_UNDERSCORE, __VA_ARGS__))
335#define Z_SHELL_SUBCMD_SECTION_TAG(...) MACRO_MAP_CAT(Z_SHELL_UNDERSCORE, __VA_ARGS__)
336#define Z_SHELL_SUBCMD_SET_SECTION_TAG(x) \
337 Z_SHELL_SUBCMD_SECTION_TAG(NUM_VA_ARGS_LESS_1 x, __DEBRACKET x)
338#define Z_SHELL_SUBCMD_ADD_SECTION_TAG(x, y) \
339 Z_SHELL_SUBCMD_SECTION_TAG(NUM_VA_ARGS_LESS_1 x, __DEBRACKET x, y)
340
353#define SHELL_SUBCMD_SET_CREATE(_name, _parent) \
354 static const TYPE_SECTION_ITERABLE(struct shell_static_entry, _name, shell_subcmds, \
355 Z_SHELL_SUBCMD_SET_SECTION_TAG(_parent))
356
357
377#define SHELL_SUBCMD_COND_ADD(_flag, _parent, _syntax, _subcmd, _help, _handler, \
378 _mand, _opt) \
379 COND_CODE_1(_flag, \
380 (static const TYPE_SECTION_ITERABLE(struct shell_static_entry, \
381 Z_SHELL_SUBCMD_NAME(__DEBRACKET _parent, _syntax), \
382 shell_subcmds, \
383 Z_SHELL_SUBCMD_ADD_SECTION_TAG(_parent, _syntax)) = \
384 SHELL_EXPR_CMD_ARG(1, _syntax, _subcmd, _help, \
385 _handler, _mand, _opt)\
386 ), \
387 (static shell_cmd_handler dummy_handler_##_syntax __unused = _handler;\
388 static const union shell_cmd_entry dummy_subcmd_##_syntax __unused = { \
389 .entry = (const struct shell_static_entry *)_subcmd\
390 } \
391 ) \
392 )
393
406#define SHELL_SUBCMD_ADD(_parent, _syntax, _subcmd, _help, _handler, _mand, _opt) \
407 SHELL_SUBCMD_COND_ADD(1, _parent, _syntax, _subcmd, _help, _handler, _mand, _opt)
408
413#define SHELL_SUBCMD_SET_END {NULL}
414
421#define SHELL_DYNAMIC_CMD_CREATE(name, get) \
422 static const TYPE_SECTION_ITERABLE(union shell_cmd_entry, name, \
423 shell_dynamic_subcmds, name) = \
424 { \
425 .dynamic_get = get \
426 }
427
441#define SHELL_CMD_ARG(syntax, subcmd, help, handler, mand, opt) \
442 SHELL_EXPR_CMD_ARG(1, syntax, subcmd, help, handler, mand, opt)
443
463#define SHELL_COND_CMD_ARG(flag, syntax, subcmd, help, handler, mand, opt) \
464 SHELL_EXPR_CMD_ARG(IS_ENABLED(flag), syntax, subcmd, help, \
465 handler, mand, opt)
466
486#define SHELL_EXPR_CMD_ARG(_expr, _syntax, _subcmd, _help, _handler, \
487 _mand, _opt) \
488 { \
489 .syntax = (_expr) ? (const char *)STRINGIFY(_syntax) : "", \
490 .help = (_expr) ? (const char *)_help : NULL, \
491 .subcmd = (const union shell_cmd_entry *)((_expr) ? \
492 _subcmd : NULL), \
493 .handler = (shell_cmd_handler)((_expr) ? _handler : NULL), \
494 .args = { .mandatory = _mand, .optional = _opt} \
495 }
496
505#define SHELL_CMD(_syntax, _subcmd, _help, _handler) \
506 SHELL_CMD_ARG(_syntax, _subcmd, _help, _handler, 0, 0)
507
520#define SHELL_COND_CMD(_flag, _syntax, _subcmd, _help, _handler) \
521 SHELL_COND_CMD_ARG(_flag, _syntax, _subcmd, _help, _handler, 0, 0)
522
536#define SHELL_EXPR_CMD(_expr, _syntax, _subcmd, _help, _handler) \
537 SHELL_EXPR_CMD_ARG(_expr, _syntax, _subcmd, _help, _handler, 0, 0)
538
539/* Internal macro used for creating handlers for dictionary commands. */
540#define Z_SHELL_CMD_DICT_HANDLER_CREATE(_data, _handler) \
541static int UTIL_CAT(UTIL_CAT(cmd_dict_, UTIL_CAT(_handler, _)), \
542 GET_ARG_N(1, __DEBRACKET _data))( \
543 const struct shell *sh, size_t argc, char **argv) \
544{ \
545 return _handler(sh, argc, argv, \
546 (void *)GET_ARG_N(2, __DEBRACKET _data)); \
547}
548
549/* Internal macro used for creating dictionary commands. */
550#define SHELL_CMD_DICT_CREATE(_data, _handler) \
551 SHELL_CMD_ARG(GET_ARG_N(1, __DEBRACKET _data), NULL, GET_ARG_N(3, __DEBRACKET _data), \
552 UTIL_CAT(UTIL_CAT(cmd_dict_, UTIL_CAT(_handler, _)), \
553 GET_ARG_N(1, __DEBRACKET _data)), 1, 0)
554
588#define SHELL_SUBCMD_DICT_SET_CREATE(_name, _handler, ...) \
589 FOR_EACH_FIXED_ARG(Z_SHELL_CMD_DICT_HANDLER_CREATE, (), \
590 _handler, __VA_ARGS__) \
591 SHELL_STATIC_SUBCMD_SET_CREATE(_name, \
592 FOR_EACH_FIXED_ARG(SHELL_CMD_DICT_CREATE, (,), _handler, __VA_ARGS__), \
593 SHELL_SUBCMD_SET_END \
594 )
595
606
617
623
625 void *context);
626
627
628typedef void (*shell_uninit_cb_t)(const struct shell *sh, int res);
629
636typedef void (*shell_bypass_cb_t)(const struct shell *sh,
637 uint8_t *data,
638 size_t len);
639
640struct shell_transport;
641
658 int (*init)(const struct shell_transport *transport,
659 const void *config,
660 shell_transport_handler_t evt_handler,
661 void *context);
662
670 int (*uninit)(const struct shell_transport *transport);
671
684 int (*enable)(const struct shell_transport *transport,
685 bool blocking_tx);
686
697 int (*write)(const struct shell_transport *transport,
698 const void *data, size_t length, size_t *cnt);
699
710 int (*read)(const struct shell_transport *transport,
711 void *data, size_t length, size_t *cnt);
712
720 void (*update)(const struct shell_transport *transport);
721
722};
723
726 void *ctx;
727};
728
735
736#ifdef CONFIG_SHELL_STATS
737#define Z_SHELL_STATS_DEFINE(_name) static struct shell_stats _name##_stats
738#define Z_SHELL_STATS_PTR(_name) (&(_name##_stats))
739#else
740#define Z_SHELL_STATS_DEFINE(_name)
741#define Z_SHELL_STATS_PTR(_name) NULL
742#endif /* CONFIG_SHELL_STATS */
743
755
756BUILD_ASSERT((sizeof(struct shell_backend_config_flags) == sizeof(uint32_t)),
757 "Structure must fit in 4 bytes");
758
762#define SHELL_DEFAULT_BACKEND_CONFIG_FLAGS \
763{ \
764 .insert_mode = 0, \
765 .echo = 1, \
766 .obscure = IS_ENABLED(CONFIG_SHELL_START_OBSCURED), \
767 .mode_delete = 1, \
768 .use_colors = 1, \
769 .use_vt100 = 1, \
770};
771
782
783BUILD_ASSERT((sizeof(struct shell_backend_ctx_flags) == sizeof(uint32_t)),
784 "Structure must fit in 4 bytes");
785
793
801
809
813struct shell_ctx {
814#if defined(CONFIG_SHELL_PROMPT_CHANGE) && CONFIG_SHELL_PROMPT_CHANGE
816#else
817 const char *prompt;
818#endif
819
825
828
831
836
839
842
843#if defined CONFIG_SHELL_GETOPT
845 struct getopt_state getopt;
846#endif
847
855
858
861
862 volatile union shell_backend_cfg cfg;
863 volatile union shell_backend_ctx ctx;
864
866
871
875};
876
877extern const struct log_backend_api log_backend_shell_api;
878
886
890struct shell {
891 const char *default_prompt;
893 const struct shell_transport *iface;
894 struct shell_ctx *ctx;
897
899
901
903
905
907
908 const char *name;
911};
912
913extern void z_shell_print_stream(const void *user_ctx, const char *data,
914 size_t data_len);
928#define SHELL_DEFINE(_name, _prompt, _transport_iface, \
929 _log_queue_size, _log_timeout, _shell_flag) \
930 static const struct shell _name; \
931 static struct shell_ctx UTIL_CAT(_name, _ctx); \
932 static uint8_t _name##_out_buffer[CONFIG_SHELL_PRINTF_BUFF_SIZE]; \
933 Z_SHELL_LOG_BACKEND_DEFINE(_name, _name##_out_buffer, \
934 CONFIG_SHELL_PRINTF_BUFF_SIZE, \
935 _log_queue_size, _log_timeout); \
936 Z_SHELL_HISTORY_DEFINE(_name##_history, CONFIG_SHELL_HISTORY_BUFFER); \
937 Z_SHELL_FPRINTF_DEFINE(_name##_fprintf, &_name, _name##_out_buffer, \
938 CONFIG_SHELL_PRINTF_BUFF_SIZE, \
939 true, z_shell_print_stream); \
940 LOG_INSTANCE_REGISTER(shell, _name, CONFIG_SHELL_LOG_LEVEL); \
941 Z_SHELL_STATS_DEFINE(_name); \
942 static K_KERNEL_STACK_DEFINE(_name##_stack, CONFIG_SHELL_STACK_SIZE); \
943 static struct k_thread _name##_thread; \
944 static const STRUCT_SECTION_ITERABLE(shell, _name) = { \
945 .default_prompt = _prompt, \
946 .iface = _transport_iface, \
947 .ctx = &UTIL_CAT(_name, _ctx), \
948 .history = IS_ENABLED(CONFIG_SHELL_HISTORY) ? \
949 &_name##_history : NULL, \
950 .shell_flag = _shell_flag, \
951 .fprintf_ctx = &_name##_fprintf, \
952 .stats = Z_SHELL_STATS_PTR(_name), \
953 .log_backend = Z_SHELL_LOG_BACKEND_PTR(_name), \
954 LOG_INSTANCE_PTR_INIT(log, shell, _name) \
955 .name = STRINGIFY(_name), \
956 .thread = &_name##_thread, \
957 .stack = _name##_stack \
958 }
959
973int shell_init(const struct shell *sh, const void *transport_config,
974 struct shell_backend_config_flags cfg_flags,
975 bool log_backend, uint32_t init_log_level);
976
983void shell_uninit(const struct shell *sh, shell_uninit_cb_t cb);
984
992int shell_start(const struct shell *sh);
993
1001int shell_stop(const struct shell *sh);
1002
1006#define SHELL_NORMAL SHELL_VT100_COLOR_DEFAULT
1007
1011#define SHELL_INFO SHELL_VT100_COLOR_GREEN
1012
1016#define SHELL_OPTION SHELL_VT100_COLOR_CYAN
1017
1021#define SHELL_WARNING SHELL_VT100_COLOR_YELLOW
1022
1026#define SHELL_ERROR SHELL_VT100_COLOR_RED
1027
1039void __printf_like(3, 4) shell_fprintf_impl(const struct shell *sh, enum shell_vt100_color color,
1040 const char *fmt, ...);
1041
1042#define shell_fprintf(sh, color, fmt, ...) shell_fprintf_impl(sh, color, fmt, ##__VA_ARGS__)
1043
1056void shell_vfprintf(const struct shell *sh, enum shell_vt100_color color,
1057 const char *fmt, va_list args);
1058
1074void shell_hexdump_line(const struct shell *sh, unsigned int offset,
1075 const uint8_t *data, size_t len);
1076
1084void shell_hexdump(const struct shell *sh, const uint8_t *data, size_t len);
1085
1095#define shell_info(_sh, _ft, ...) \
1096 shell_fprintf(_sh, SHELL_INFO, _ft "\n", ##__VA_ARGS__)
1097
1107#define shell_print(_sh, _ft, ...) \
1108 shell_fprintf(_sh, SHELL_NORMAL, _ft "\n", ##__VA_ARGS__)
1109
1119#define shell_warn(_sh, _ft, ...) \
1120 shell_fprintf(_sh, SHELL_WARNING, _ft "\n", ##__VA_ARGS__)
1121
1131#define shell_error(_sh, _ft, ...) \
1132 shell_fprintf(_sh, SHELL_ERROR, _ft "\n", ##__VA_ARGS__)
1133
1140void shell_process(const struct shell *sh);
1141
1151int shell_prompt_change(const struct shell *sh, const char *prompt);
1152
1161void shell_help(const struct shell *sh);
1162
1164#define SHELL_CMD_HELP_PRINTED (1)
1165
1183int shell_execute_cmd(const struct shell *sh, const char *cmd);
1184
1196int shell_set_root_cmd(const char *cmd);
1197
1206void shell_set_bypass(const struct shell *sh, shell_bypass_cb_t bypass);
1207
1215bool shell_ready(const struct shell *sh);
1216
1227int shell_insert_mode_set(const struct shell *sh, bool val);
1228
1240int shell_use_colors_set(const struct shell *sh, bool val);
1241
1252int shell_use_vt100_set(const struct shell *sh, bool val);
1253
1264int shell_echo_set(const struct shell *sh, bool val);
1265
1277int shell_obscure_set(const struct shell *sh, bool obscure);
1278
1290int shell_mode_delete_set(const struct shell *sh, bool val);
1291
1299int shell_get_return_value(const struct shell *sh);
1300
1305#ifdef __cplusplus
1306}
1307#endif
1308
1309#ifdef CONFIG_SHELL_CUSTOM_HEADER
1310/* This include must always be at the end of shell.h */
1311#include <zephyr_custom_shell.h>
1312#endif
1313
1314#endif /* SHELL_H__ */
struct z_thread_stack_element k_thread_stack_t
Typedef of struct z_thread_stack_element.
Definition arch_interface.h:46
long atomic_t
Definition atomic_types.h:15
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:628
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:190
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:624
int shell_mode_delete_set(const struct shell *sh, bool val)
Allow application to control whether the delete key backspaces or deletes.
int(* shell_cmd_handler)(const struct shell *sh, size_t argc, char **argv)
Shell command handler prototype.
Definition shell.h:174
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:882
const struct device * shell_device_lookup(size_t idx, const char *prefix)
Get by index a device that matches .
shell_signal
Definition shell.h:802
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.
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.
void shell_fprintf_impl(const struct shell *sh, enum shell_vt100_color color, const char *fmt,...)
printf-like function which sends formatted data stream to the shell.
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:600
bool(* shell_device_filter_t)(const struct device *dev)
Filter callback type, for use with shell_device_lookup_filter.
Definition shell.h:144
void(* shell_bypass_cb_t)(const struct shell *sh, uint8_t *data, size_t len)
Bypass callback.
Definition shell.h:636
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.
const struct log_backend_api log_backend_shell_api
const struct device * shell_device_filter(size_t idx, shell_device_filter_t filter)
Get a device by index and filter.
shell_transport_evt
Shell transport event.
Definition shell.h:619
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.
shell_state
Definition shell.h:610
void(* shell_dynamic_get)(size_t idx, struct shell_static_entry *entry)
Shell dynamic command descriptor.
Definition shell.h:95
@ SHELL_FLAG_CRLF_DEFAULT
Do not map CR or LF.
Definition shell.h:883
@ SHELL_FLAG_OLF_CRLF
Map LF to CRLF on output.
Definition shell.h:884
@ SHELL_SIGNALS
Definition shell.h:807
@ SHELL_SIGNAL_TXDONE
Definition shell.h:806
@ SHELL_SIGNAL_RXRDY
Definition shell.h:803
@ SHELL_SIGNAL_LOG_MSG
Definition shell.h:804
@ SHELL_SIGNAL_KILL
Definition shell.h:805
@ SHELL_RECEIVE_DEFAULT
Definition shell.h:601
@ SHELL_RECEIVE_ESC_SEQ
Definition shell.h:603
@ SHELL_RECEIVE_ESC
Definition shell.h:602
@ SHELL_RECEIVE_TILDE_EXP
Definition shell.h:604
@ SHELL_TRANSPORT_EVT_TX_RDY
Definition shell.h:621
@ SHELL_TRANSPORT_EVT_RX_RDY
Definition shell.h:620
@ SHELL_STATE_UNINITIALIZED
Definition shell.h:611
@ SHELL_STATE_PANIC_MODE_INACTIVE
Panic requested, not supported.
Definition shell.h:615
@ SHELL_STATE_ACTIVE
Definition shell.h:613
@ SHELL_STATE_PANIC_MODE_ACTIVE
Panic activated.
Definition shell.h:614
@ SHELL_STATE_INITIALIZED
Definition shell.h:612
Public kernel APIs.
flags
Definition parser.h:96
#define CONFIG_SHELL_PROMPT_BUFF_SIZE
Definition shell.h:30
#define CONFIG_SHELL_CMD_BUFF_SIZE
Definition shell.h:34
#define CONFIG_SHELL_PRINTF_BUFF_SIZE
Definition shell.h:38
shell_vt100_color
Definition shell_types.h:14
#define bool
Definition stdbool.h:13
__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:403
Mutex Structure.
Definition kernel.h:2917
Poll Event.
Definition kernel.h:5715
Definition kernel.h:5691
Thread Structure.
Definition thread.h:259
Logger backend API.
Definition log_backend.h:63
Logger backend structure.
Definition log_backend.h:94
Definition shell.h:747
uint32_t use_vt100
Controls VT100 commands usage in shell.
Definition shell.h:753
uint32_t mode_delete
Operation mode of backspace key.
Definition shell.h:751
uint32_t echo
Controls shell echo.
Definition shell.h:749
uint32_t insert_mode
Controls insert mode for text introduction.
Definition shell.h:748
uint32_t obscure
If echo on, print asterisk instead.
Definition shell.h:750
uint32_t use_colors
Controls colored syntax.
Definition shell.h:752
Definition shell.h:772
uint32_t print_noinit
Print request from not initialized shell.
Definition shell.h:778
uint32_t sync_mode
Shell in synchronous mode.
Definition shell.h:779
uint32_t tx_rdy
Definition shell.h:774
uint32_t handle_log
Shell is handling logger backend.
Definition shell.h:780
uint32_t processing
Shell is executing process function.
Definition shell.h:773
uint32_t last_nl
Last received new line character.
Definition shell.h:776
uint32_t history_exit
Request to exit history mode.
Definition shell.h:775
uint32_t cmd_ctx
Shell is executing command.
Definition shell.h:777
Shell instance context.
Definition shell.h:813
const struct shell_static_entry * selected_cmd
New root command.
Definition shell.h:827
shell_uninit_cb_t uninit_cb
Callback called from shell thread context when unitialization is completed just before aborting shell...
Definition shell.h:835
struct shell_vt100_ctx vt100_ctx
VT100 color and cursor position, terminal width.
Definition shell.h:830
const char * prompt
Definition shell.h:817
k_tid_t tid
Definition shell.h:873
char temp_buff[0]
Command temporary buffer.
Definition shell.h:857
char cmd_buff[0]
Command input buffer.
Definition shell.h:854
struct shell_static_entry active_cmd
Currently executed command.
Definition shell.h:824
uint32_t log_level
Definition shell.h:841
volatile union shell_backend_cfg cfg
Definition shell.h:862
uint16_t cmd_tmp_buff_len
Command length in tmp buffer.
Definition shell.h:851
struct k_poll_signal signals[SHELL_SIGNALS]
Definition shell.h:865
enum shell_state state
Internal module state.
Definition shell.h:820
struct k_mutex wr_mtx
Definition shell.h:872
shell_bypass_cb_t bypass
When bypass is set, all incoming data is passed to the callback.
Definition shell.h:838
uint16_t cmd_buff_len
Command length.
Definition shell.h:848
uint16_t cmd_buff_pos
Command buffer cursor position.
Definition shell.h:849
int ret_val
Definition shell.h:874
char printf_buff[0]
Printf buffer size.
Definition shell.h:860
struct k_poll_event events[SHELL_SIGNALS]
Events that should be used only internally by shell thread.
Definition shell.h:870
enum shell_receive_state receive_state
Escape sequence indicator.
Definition shell.h:821
volatile union shell_backend_ctx ctx
Definition shell.h:863
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:111
uint8_t mandatory
Number of mandatory arguments.
Definition shell.h:112
uint8_t optional
Number of optional arguments.
Definition shell.h:113
Definition shell.h:206
const union shell_cmd_entry * subcmd
Pointer to subcommand.
Definition shell.h:209
uint8_t padding[0]
Definition shell.h:212
shell_cmd_handler handler
Command handler.
Definition shell.h:210
struct shell_static_args args
Command arguments.
Definition shell.h:211
const char * help
Command help string.
Definition shell.h:208
const char * syntax
Command syntax strings.
Definition shell.h:207
Shell statistics structure.
Definition shell.h:732
atomic_t log_lost_cnt
Lost log counter.
Definition shell.h:733
Unified shell transport interface.
Definition shell.h:646
void(* update)(const struct shell_transport *transport)
Function called in shell thread loop.
Definition shell.h:720
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:658
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:697
int(* uninit)(const struct shell_transport *transport)
Function for uninitializing the shell transport interface.
Definition shell.h:670
int(* enable)(const struct shell_transport *transport, bool blocking_tx)
Function for enabling transport in given TX mode.
Definition shell.h:684
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:710
Definition shell.h:724
void * ctx
Definition shell.h:726
const struct shell_transport_api * api
Definition shell.h:725
Definition shell_types.h:44
Shell instance internals.
Definition shell.h:890
struct k_thread * thread
Definition shell.h:909
LOG_INSTANCE_PTR_DECLARE(log)
enum shell_flag shell_flag
Definition shell.h:898
const struct shell_log_backend * log_backend
Definition shell.h:904
struct shell_history * history
Definition shell.h:896
struct shell_stats * stats
Definition shell.h:902
const char * name
Definition shell.h:908
const char * default_prompt
shell default prompt.
Definition shell.h:891
const struct shell_fprintf * fprintf_ctx
Definition shell.h:900
struct shell_ctx * ctx
Internal context.
Definition shell.h:894
const struct shell_transport * iface
Transport interface.
Definition shell.h:893
k_thread_stack_t * stack
Definition shell.h:910
static fdata_t data[2]
Definition test_fifo_contexts.c:15
Definition shell.h:789
atomic_t value
Definition shell.h:790
Definition shell.h:797
uint32_t value
Definition shell.h:798
Shell command descriptor.
Definition shell.h:101
const struct shell_static_entry * entry
Pointer to array of static commands.
Definition shell.h:106
shell_dynamic_get dynamic_get
Pointer to function returning dynamic commands.
Definition shell.h:103
Misc utilities.