Zephyr Project API  3.3.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>
18#include <zephyr/sys/util.h>
19
20#if defined CONFIG_SHELL_GETOPT
21#include <getopt.h>
22#endif
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
28#ifndef CONFIG_SHELL_CMD_BUFF_SIZE
29#define CONFIG_SHELL_CMD_BUFF_SIZE 0
30#endif
31
32#ifndef CONFIG_SHELL_PRINTF_BUFF_SIZE
33#define CONFIG_SHELL_PRINTF_BUFF_SIZE 0
34#endif
35
36#ifndef CONFIG_SHELL_HISTORY_BUFFER
37#define CONFIG_SHELL_HISTORY_BUFFER 0
38#endif
39
40#define Z_SHELL_CMD_ROOT_LVL (0u)
41
42#define SHELL_HEXDUMP_BYTES_IN_LINE 16
43
55#define SHELL_OPT_ARG_RAW (0xFE)
56
60#define SHELL_OPT_ARG_CHECK_SKIP (0xFF)
61
66#define SHELL_OPT_ARG_MAX (0xFD)
67
76
88typedef void (*shell_dynamic_get)(size_t idx,
89 struct shell_static_entry *entry);
90
97
100};
101
102struct shell;
103
107};
108
124const struct device *shell_device_lookup(size_t idx,
125 const char *prefix);
126
139typedef int (*shell_cmd_handler)(const struct shell *shell,
140 size_t argc, char **argv);
141
155typedef int (*shell_dict_cmd_handler)(const struct shell *shell, size_t argc,
156 char **argv, void *data);
157
158/* When entries are added to the memory section a padding is applied for
159 * native_posix_64 and x86_64 targets. Adding padding to allow handle data
160 * in the memory section as array.
161 */
162#if (defined(CONFIG_ARCH_POSIX) && defined(CONFIG_64BIT)) || defined(CONFIG_X86_64)
163#define Z_SHELL_STATIC_ENTRY_PADDING 24
164#else
165#define Z_SHELL_STATIC_ENTRY_PADDING 0
166#endif
167
168/*
169 * @brief Shell static command descriptor.
170 */
172 const char *syntax;
173 const char *help;
174 const union shell_cmd_entry *subcmd;
177 uint8_t padding[Z_SHELL_STATIC_ENTRY_PADDING];
178};
179
195#define SHELL_CMD_ARG_REGISTER(syntax, subcmd, help, handler, \
196 mandatory, optional) \
197 static const struct shell_static_entry UTIL_CAT(_shell_, syntax) = \
198 SHELL_CMD_ARG(syntax, subcmd, help, handler, mandatory, optional); \
199 static const union shell_cmd_entry UTIL_CAT(shell_cmd_, syntax) \
200 __attribute__ ((section("." \
201 STRINGIFY(UTIL_CAT(shell_root_cmd_, syntax))))) \
202 __attribute__((used)) = { \
203 .entry = &UTIL_CAT(_shell_, syntax) \
204 }
205
226#define SHELL_COND_CMD_ARG_REGISTER(flag, syntax, subcmd, help, handler, \
227 mandatory, optional) \
228 COND_CODE_1(\
229 flag, \
230 (\
231 SHELL_CMD_ARG_REGISTER(syntax, subcmd, help, handler, \
232 mandatory, optional) \
233 ), \
234 (\
235 static shell_cmd_handler dummy_##syntax##_handler __unused = \
236 handler;\
237 static const union shell_cmd_entry *dummy_subcmd_##syntax \
238 __unused = subcmd\
239 ) \
240 )
252#define SHELL_CMD_REGISTER(syntax, subcmd, help, handler) \
253 SHELL_CMD_ARG_REGISTER(syntax, subcmd, help, handler, 0, 0)
254
268#define SHELL_COND_CMD_REGISTER(flag, syntax, subcmd, help, handler) \
269 SHELL_COND_CMD_ARG_REGISTER(flag, syntax, subcmd, help, handler, 0, 0)
270
287#define SHELL_STATIC_SUBCMD_SET_CREATE(name, ...) \
288 static const struct shell_static_entry shell_##name[] = { \
289 __VA_ARGS__ \
290 }; \
291 static const union shell_cmd_entry name = { \
292 .entry = shell_##name \
293 }
294
295#define Z_SHELL_UNDERSCORE(x) _##x
296#define Z_SHELL_SUBCMD_NAME(...) \
297 UTIL_CAT(shell_subcmd, MACRO_MAP_CAT(Z_SHELL_UNDERSCORE, __VA_ARGS__))
298
310#define SHELL_SUBCMD_SET_CREATE(_name, _parent) \
311 static const struct shell_static_entry _name \
312 __attribute__ ((section("." \
313 STRINGIFY(Z_SHELL_SUBCMD_NAME(NUM_VA_ARGS_LESS_1 _parent, \
314 __DEBRACKET _parent))))) \
315 __attribute__((used))
316
336#define SHELL_SUBCMD_COND_ADD(_flag, _parent, _syntax, _subcmd, _help, _handler, \
337 _mand, _opt) \
338 COND_CODE_1(_flag, \
339 (static const struct shell_static_entry \
340 Z_SHELL_SUBCMD_NAME(__DEBRACKET _parent, _syntax)\
341 __attribute__ ((section("." \
342 STRINGIFY(Z_SHELL_SUBCMD_NAME(NUM_VA_ARGS_LESS_1 _parent, \
343 __DEBRACKET _parent, _syntax))))) \
344 __attribute__((used)) = \
345 SHELL_EXPR_CMD_ARG(1, _syntax, _subcmd, _help, \
346 _handler, _mand, _opt)\
347 ), \
348 (static shell_cmd_handler dummy_##syntax##_handler __unused = _handler;\
349 static const union shell_cmd_entry dummy_subcmd_##syntax __unused = { \
350 .entry = (const struct shell_static_entry *)_subcmd\
351 } \
352 ) \
353 )
354
367#define SHELL_SUBCMD_ADD(_parent, _syntax, _subcmd, _help, _handler, _mand, _opt) \
368 SHELL_SUBCMD_COND_ADD(1, _parent, _syntax, _subcmd, _help, _handler, _mand, _opt)
369
374#define SHELL_SUBCMD_SET_END {NULL}
375
382#define SHELL_DYNAMIC_CMD_CREATE(name, get) \
383 static const union shell_cmd_entry name \
384 __attribute__ ((section("." \
385 STRINGIFY(UTIL_CAT(shell_dynamic_subcmd_, syntax))))) \
386 __attribute__((used)) = { \
387 .dynamic_get = get \
388 }
389
403#define SHELL_CMD_ARG(syntax, subcmd, help, handler, mand, opt) \
404 SHELL_EXPR_CMD_ARG(1, syntax, subcmd, help, handler, mand, opt)
405
425#define SHELL_COND_CMD_ARG(flag, syntax, subcmd, help, handler, mand, opt) \
426 SHELL_EXPR_CMD_ARG(IS_ENABLED(flag), syntax, subcmd, help, \
427 handler, mand, opt)
428
448#define SHELL_EXPR_CMD_ARG(_expr, _syntax, _subcmd, _help, _handler, \
449 _mand, _opt) \
450 { \
451 .syntax = (_expr) ? (const char *)STRINGIFY(_syntax) : "", \
452 .help = (_expr) ? (const char *)_help : NULL, \
453 .subcmd = (const union shell_cmd_entry *)((_expr) ? \
454 _subcmd : NULL), \
455 .handler = (shell_cmd_handler)((_expr) ? _handler : NULL), \
456 .args = { .mandatory = _mand, .optional = _opt} \
457 }
458
467#define SHELL_CMD(_syntax, _subcmd, _help, _handler) \
468 SHELL_CMD_ARG(_syntax, _subcmd, _help, _handler, 0, 0)
469
482#define SHELL_COND_CMD(_flag, _syntax, _subcmd, _help, _handler) \
483 SHELL_COND_CMD_ARG(_flag, _syntax, _subcmd, _help, _handler, 0, 0)
484
498#define SHELL_EXPR_CMD(_expr, _syntax, _subcmd, _help, _handler) \
499 SHELL_EXPR_CMD_ARG(_expr, _syntax, _subcmd, _help, _handler, 0, 0)
500
501/* Internal macro used for creating handlers for dictionary commands. */
502#define Z_SHELL_CMD_DICT_HANDLER_CREATE(_data, _handler) \
503static int UTIL_CAT(UTIL_CAT(cmd_dict_, UTIL_CAT(_handler, _)), \
504 GET_ARG_N(1, __DEBRACKET _data))( \
505 const struct shell *shell, size_t argc, char **argv) \
506{ \
507 return _handler(shell, argc, argv, \
508 (void *)GET_ARG_N(2, __DEBRACKET _data)); \
509}
510
511/* Internal macro used for creating dictionary commands. */
512#define SHELL_CMD_DICT_CREATE(_data, _handler) \
513 SHELL_CMD_ARG(GET_ARG_N(1, __DEBRACKET _data), NULL, GET_ARG_N(3, __DEBRACKET _data), \
514 UTIL_CAT(UTIL_CAT(cmd_dict_, UTIL_CAT(_handler, _)), \
515 GET_ARG_N(1, __DEBRACKET _data)), 1, 0)
516
548#define SHELL_SUBCMD_DICT_SET_CREATE(_name, _handler, ...) \
549 FOR_EACH_FIXED_ARG(Z_SHELL_CMD_DICT_HANDLER_CREATE, (), \
550 _handler, __VA_ARGS__) \
551 SHELL_STATIC_SUBCMD_SET_CREATE(_name, \
552 FOR_EACH_FIXED_ARG(SHELL_CMD_DICT_CREATE, (,), _handler, __VA_ARGS__), \
553 SHELL_SUBCMD_SET_END \
554 )
555
566
577
583
585 void *context);
586
587
588typedef void (*shell_uninit_cb_t)(const struct shell *shell, int res);
589
596typedef void (*shell_bypass_cb_t)(const struct shell *shell,
597 uint8_t *data,
598 size_t len);
599
600struct shell_transport;
601
617 int (*init)(const struct shell_transport *transport,
618 const void *config,
619 shell_transport_handler_t evt_handler,
620 void *context);
621
629 int (*uninit)(const struct shell_transport *transport);
630
643 int (*enable)(const struct shell_transport *transport,
644 bool blocking_tx);
645
656 int (*write)(const struct shell_transport *transport,
657 const void *data, size_t length, size_t *cnt);
658
669 int (*read)(const struct shell_transport *transport,
670 void *data, size_t length, size_t *cnt);
671
679 void (*update)(const struct shell_transport *transport);
680
681};
682
685 void *ctx;
686};
687
693};
694
695#ifdef CONFIG_SHELL_STATS
696#define Z_SHELL_STATS_DEFINE(_name) static struct shell_stats _name##_stats
697#define Z_SHELL_STATS_PTR(_name) (&(_name##_stats))
698#else
699#define Z_SHELL_STATS_DEFINE(_name)
700#define Z_SHELL_STATS_PTR(_name) NULL
701#endif /* CONFIG_SHELL_STATS */
702
713};
714
715BUILD_ASSERT((sizeof(struct shell_backend_config_flags) == sizeof(uint32_t)),
716 "Structure must fit in 4 bytes");
717
721#define SHELL_DEFAULT_BACKEND_CONFIG_FLAGS \
722{ \
723 .insert_mode = 0, \
724 .echo = 1, \
725 .obscure = IS_ENABLED(CONFIG_SHELL_START_OBSCURED), \
726 .mode_delete = 1, \
727 .use_colors = 1, \
728 .use_vt100 = 1, \
729};
730
739};
740
741BUILD_ASSERT((sizeof(struct shell_backend_ctx_flags) == sizeof(uint32_t)),
742 "Structure must fit in 4 bytes");
743
750};
751
758};
759
764 SHELL_SIGNAL_TXDONE, /* TXDONE must be last one before SHELL_SIGNALS */
767
771struct shell_ctx {
772 const char *prompt;
779
780 /* New root command. If NULL shell uses default root commands. */
782
785
790
793
794#if defined CONFIG_SHELL_GETOPT
796 struct getopt_state getopt;
797#endif
798
806
809
812
813 volatile union shell_backend_cfg cfg;
814 volatile union shell_backend_ctx ctx;
815
817
822
825};
826
827extern const struct log_backend_api log_backend_shell_api;
828
833 SHELL_FLAG_CRLF_DEFAULT = (1<<0), /* Do not map CR or LF */
834 SHELL_FLAG_OLF_CRLF = (1<<1) /* Map LF to CRLF on output */
836
840struct shell {
841 const char *default_prompt;
843 const struct shell_transport *iface;
844 struct shell_ctx *ctx;
847
849
851
853
855
857
858 const char *thread_name;
861};
862
863extern void z_shell_print_stream(const void *user_ctx, const char *data,
864 size_t data_len);
878#define SHELL_DEFINE(_name, _prompt, _transport_iface, \
879 _log_queue_size, _log_timeout, _shell_flag) \
880 static const struct shell _name; \
881 static struct shell_ctx UTIL_CAT(_name, _ctx); \
882 static uint8_t _name##_out_buffer[CONFIG_SHELL_PRINTF_BUFF_SIZE]; \
883 Z_SHELL_LOG_BACKEND_DEFINE(_name, _name##_out_buffer, \
884 CONFIG_SHELL_PRINTF_BUFF_SIZE, \
885 _log_queue_size, _log_timeout); \
886 Z_SHELL_HISTORY_DEFINE(_name##_history, CONFIG_SHELL_HISTORY_BUFFER); \
887 Z_SHELL_FPRINTF_DEFINE(_name##_fprintf, &_name, _name##_out_buffer, \
888 CONFIG_SHELL_PRINTF_BUFF_SIZE, \
889 true, z_shell_print_stream); \
890 LOG_INSTANCE_REGISTER(shell, _name, CONFIG_SHELL_LOG_LEVEL); \
891 Z_SHELL_STATS_DEFINE(_name); \
892 static K_KERNEL_STACK_DEFINE(_name##_stack, CONFIG_SHELL_STACK_SIZE); \
893 static struct k_thread _name##_thread; \
894 static const STRUCT_SECTION_ITERABLE(shell, _name) = { \
895 .default_prompt = _prompt, \
896 .iface = _transport_iface, \
897 .ctx = &UTIL_CAT(_name, _ctx), \
898 .history = IS_ENABLED(CONFIG_SHELL_HISTORY) ? \
899 &_name##_history : NULL, \
900 .shell_flag = _shell_flag, \
901 .fprintf_ctx = &_name##_fprintf, \
902 .stats = Z_SHELL_STATS_PTR(_name), \
903 .log_backend = Z_SHELL_LOG_BACKEND_PTR(_name), \
904 LOG_INSTANCE_PTR_INIT(log, shell, _name) \
905 .thread_name = STRINGIFY(_name), \
906 .thread = &_name##_thread, \
907 .stack = _name##_stack \
908 }
909
923int shell_init(const struct shell *shell, const void *transport_config,
924 struct shell_backend_config_flags cfg_flags,
925 bool log_backend, uint32_t init_log_level);
926
934
942int shell_start(const struct shell *shell);
943
951int shell_stop(const struct shell *shell);
952
956#define SHELL_NORMAL SHELL_VT100_COLOR_DEFAULT
957
961#define SHELL_INFO SHELL_VT100_COLOR_GREEN
962
966#define SHELL_OPTION SHELL_VT100_COLOR_CYAN
967
971#define SHELL_WARNING SHELL_VT100_COLOR_YELLOW
972
976#define SHELL_ERROR SHELL_VT100_COLOR_RED
977
989void __printf_like(3, 4) shell_fprintf(const struct shell *shell,
990 enum shell_vt100_color color,
991 const char *fmt, ...);
992
1005void shell_vfprintf(const struct shell *shell, enum shell_vt100_color color,
1006 const char *fmt, va_list args);
1007
1023void shell_hexdump_line(const struct shell *shell, unsigned int offset,
1024 const uint8_t *data, size_t len);
1025
1033void shell_hexdump(const struct shell *shell, const uint8_t *data, size_t len);
1034
1044#define shell_info(_sh, _ft, ...) \
1045 shell_fprintf(_sh, SHELL_INFO, _ft "\n", ##__VA_ARGS__)
1046
1056#define shell_print(_sh, _ft, ...) \
1057 shell_fprintf(_sh, SHELL_NORMAL, _ft "\n", ##__VA_ARGS__)
1058
1068#define shell_warn(_sh, _ft, ...) \
1069 shell_fprintf(_sh, SHELL_WARNING, _ft "\n", ##__VA_ARGS__)
1070
1080#define shell_error(_sh, _ft, ...) \
1081 shell_fprintf(_sh, SHELL_ERROR, _ft "\n", ##__VA_ARGS__)
1082
1089void shell_process(const struct shell *shell);
1090
1100int shell_prompt_change(const struct shell *shell, const char *prompt);
1101
1110void shell_help(const struct shell *shell);
1111
1112/* @brief Command's help has been printed */
1113#define SHELL_CMD_HELP_PRINTED (1)
1114
1132int shell_execute_cmd(const struct shell *shell, const char *cmd);
1133
1145int shell_set_root_cmd(const char *cmd);
1146
1155void shell_set_bypass(const struct shell *shell, shell_bypass_cb_t bypass);
1156
1164bool shell_ready(const struct shell *sh);
1165
1176int shell_insert_mode_set(const struct shell *shell, bool val);
1177
1189int shell_use_colors_set(const struct shell *shell, bool val);
1190
1201int shell_echo_set(const struct shell *shell, bool val);
1202
1214int shell_obscure_set(const struct shell *shell, bool obscure);
1215
1227int shell_mode_delete_set(const struct shell *shell, bool val);
1228
1233#ifdef __cplusplus
1234}
1235#endif
1236
1237#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
int shell_prompt_change(const struct shell *shell, const char *prompt)
Change displayed shell prompt.
int shell_execute_cmd(const struct shell *shell, const char *cmd)
Execute command.
void shell_uninit(const struct shell *shell, shell_uninit_cb_t cb)
Uninitializes the transport layer and the internal shell state.
int(* shell_cmd_handler)(const struct shell *shell, size_t argc, char **argv)
Shell command handler prototype.
Definition: shell.h:139
void(* shell_transport_handler_t)(enum shell_transport_evt evt, void *context)
Definition: shell.h:584
void shell_set_bypass(const struct shell *shell, shell_bypass_cb_t bypass)
Set bypass callback.
int shell_use_colors_set(const struct shell *shell, bool val)
Allow application to control whether terminal output uses colored syntax. Value is modified atomicall...
int shell_init(const struct shell *shell, 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_flag
Flags for setting shell output newline sequence.
Definition: shell.h:832
const struct device * shell_device_lookup(size_t idx, const char *prefix)
Get by index a device that matches .
shell_signal
Definition: shell.h:760
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 atomical...
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.
void shell_hexdump(const struct shell *shell, const uint8_t *data, size_t len)
Print data in hexadecimal format.
shell_receive_state
Definition: shell.h:560
void(* shell_bypass_cb_t)(const struct shell *shell, uint8_t *data, size_t len)
Bypass callback.
Definition: shell.h:596
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...
void shell_help(const struct shell *shell)
Prints the current command help.
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.
int shell_start(const struct shell *shell)
Function for starting shell processing.
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.
int shell_obscure_set(const struct shell *shell, bool obscure)
Allow application to control whether user input is obscured with asterisks – useful for implementing ...
const struct log_backend_api log_backend_shell_api
int shell_stop(const struct shell *shell)
Function for stopping shell processing.
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 ...
int(* shell_dict_cmd_handler)(const struct shell *shell, size_t argc, char **argv, void *data)
Shell dictionary command handler prototype.
Definition: shell.h:155
shell_transport_evt
Shell transport event.
Definition: shell.h:579
void(* shell_uninit_cb_t)(const struct shell *shell, int res)
Definition: shell.h:588
shell_state
Definition: shell.h:570
void(* shell_dynamic_get)(size_t idx, struct shell_static_entry *entry)
Shell dynamic command descriptor.
Definition: shell.h:88
void shell_process(const struct shell *shell)
Process function, which should be executed when data is ready in the transport interface....
@ SHELL_FLAG_CRLF_DEFAULT
Definition: shell.h:833
@ SHELL_FLAG_OLF_CRLF
Definition: shell.h:834
@ SHELL_SIGNALS
Definition: shell.h:765
@ SHELL_SIGNAL_TXDONE
Definition: shell.h:764
@ SHELL_SIGNAL_RXRDY
Definition: shell.h:761
@ SHELL_SIGNAL_LOG_MSG
Definition: shell.h:762
@ SHELL_SIGNAL_KILL
Definition: shell.h:763
@ SHELL_RECEIVE_DEFAULT
Definition: shell.h:561
@ SHELL_RECEIVE_ESC_SEQ
Definition: shell.h:563
@ SHELL_RECEIVE_ESC
Definition: shell.h:562
@ SHELL_RECEIVE_TILDE_EXP
Definition: shell.h:564
@ SHELL_TRANSPORT_EVT_TX_RDY
Definition: shell.h:581
@ SHELL_TRANSPORT_EVT_RX_RDY
Definition: shell.h:580
@ SHELL_STATE_UNINITIALIZED
Definition: shell.h:571
@ SHELL_STATE_PANIC_MODE_INACTIVE
Definition: shell.h:575
@ SHELL_STATE_ACTIVE
Definition: shell.h:573
@ SHELL_STATE_PANIC_MODE_ACTIVE
Definition: shell.h:574
@ SHELL_STATE_INITIALIZED
Definition: shell.h:572
Public kernel APIs.
flags
Definition: parser.h:96
#define CONFIG_SHELL_CMD_BUFF_SIZE
Definition: shell.h:29
#define CONFIG_SHELL_PRINTF_BUFF_SIZE
Definition: shell.h:33
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:378
Definition: kernel.h:2764
Poll Event.
Definition: kernel.h:5483
Definition: kernel.h:5459
Definition: thread.h:245
Logger backend API.
Definition: log_backend.h:62
Logger backend structure.
Definition: log_backend.h:93
Definition: shell.h:706
uint32_t use_vt100
Definition: shell.h:712
uint32_t mode_delete
Definition: shell.h:710
uint32_t echo
Definition: shell.h:708
uint32_t insert_mode
Definition: shell.h:707
uint32_t obscure
Definition: shell.h:709
uint32_t use_colors
Definition: shell.h:711
Definition: shell.h:731
uint32_t print_noinit
Definition: shell.h:737
uint32_t sync_mode
Definition: shell.h:738
uint32_t tx_rdy
Definition: shell.h:733
uint32_t processing
Definition: shell.h:732
uint32_t last_nl
Definition: shell.h:735
uint32_t history_exit
Definition: shell.h:734
uint32_t cmd_ctx
Definition: shell.h:736
Shell instance context.
Definition: shell.h:771
const struct shell_static_entry * selected_cmd
Definition: shell.h:781
shell_uninit_cb_t uninit_cb
Definition: shell.h:789
struct shell_vt100_ctx vt100_ctx
Definition: shell.h:784
const char * prompt
Definition: shell.h:772
k_tid_t tid
Definition: shell.h:824
char temp_buff[0]
Definition: shell.h:808
char cmd_buff[0]
Definition: shell.h:805
struct shell_static_entry active_cmd
Definition: shell.h:778
volatile union shell_backend_cfg cfg
Definition: shell.h:813
uint16_t cmd_tmp_buff_len
Definition: shell.h:802
struct k_poll_signal signals[SHELL_SIGNALS]
Definition: shell.h:816
enum shell_state state
Definition: shell.h:774
struct k_mutex wr_mtx
Definition: shell.h:823
shell_bypass_cb_t bypass
Definition: shell.h:792
uint16_t cmd_buff_len
Definition: shell.h:799
uint16_t cmd_buff_pos
Definition: shell.h:800
char printf_buff[0]
Definition: shell.h:811
struct k_poll_event events[SHELL_SIGNALS]
Definition: shell.h:821
enum shell_receive_state receive_state
Definition: shell.h:775
volatile union shell_backend_ctx ctx
Definition: shell.h:814
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:104
uint8_t mandatory
Definition: shell.h:105
uint8_t optional
Definition: shell.h:106
Definition: shell.h:171
const union shell_cmd_entry * subcmd
Definition: shell.h:174
uint8_t padding[0]
Definition: shell.h:177
shell_cmd_handler handler
Definition: shell.h:175
struct shell_static_args args
Definition: shell.h:176
const char * help
Definition: shell.h:173
const char * syntax
Definition: shell.h:172
Shell statistics structure.
Definition: shell.h:691
atomic_t log_lost_cnt
Definition: shell.h:692
Unified shell transport interface.
Definition: shell.h:605
void(* update)(const struct shell_transport *transport)
Function called in shell thread loop.
Definition: shell.h:679
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:617
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:656
int(* uninit)(const struct shell_transport *transport)
Function for uninitializing the shell transport interface.
Definition: shell.h:629
int(* enable)(const struct shell_transport *transport, bool blocking_tx)
Function for enabling transport in given TX mode.
Definition: shell.h:643
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:669
Definition: shell.h:683
void * ctx
Definition: shell.h:685
const struct shell_transport_api * api
Definition: shell.h:684
Definition: shell_types.h:44
Shell instance internals.
Definition: shell.h:840
struct k_thread * thread
Definition: shell.h:859
const char * thread_name
Definition: shell.h:858
LOG_INSTANCE_PTR_DECLARE(log)
enum shell_flag shell_flag
Definition: shell.h:848
const struct shell_log_backend * log_backend
Definition: shell.h:854
struct shell_history * history
Definition: shell.h:846
struct shell_stats * stats
Definition: shell.h:852
const char * default_prompt
Definition: shell.h:841
const struct shell_fprintf * fprintf_ctx
Definition: shell.h:850
struct shell_ctx * ctx
Definition: shell.h:844
const struct shell_transport * iface
Definition: shell.h:843
k_thread_stack_t * stack
Definition: shell.h:860
static fdata_t data[2]
Definition: test_fifo_contexts.c:15
Definition: shell.h:747
atomic_t value
Definition: shell.h:748
Definition: shell.h:755
uint32_t value
Definition: shell.h:756
Shell command descriptor.
Definition: shell.h:94
const struct shell_static_entry * entry
Definition: shell.h:99
shell_dynamic_get dynamic_get
Definition: shell.h:96
Misc utilities.