This section describes the programming interface of the Shell middleware.
Shell controls MCUs by commands via the specified communication peripheral based on the debug console driver.
Function groups
Initialization
To initialize the Shell middleware, call the SHELL_Init() function with these parameters. This function automatically enables the middleware.
Then, after the initialization was successful, call a command to control MCUs.
This example shows how to call the SHELL_Init() given the user configuration structure.
SHELL_Init(&user_context, SHELL_SendDataCallback, SHELL_ReceiveDataCallback,
"SHELL>> ");
Advanced Feature
- Support to get a character from standard input devices.
static uint8_t GetChar(p_shell_context_t context);
Commands | Description |
Help | Lists all commands which are supported by Shell. |
Exit | Exits the Shell program. |
strCompare | Compares the two input strings. |
Input character | Description |
A | Gets the latest command in the history. |
B | Gets the first command in the history. |
C | Replaces one character at the right of the pointer. |
D | Replaces one character at the left of the pointer. |
| Run AutoComplete function |
| Run cmdProcess function |
| Clears a command. |
Shell Operation
SHELL_Init(&user_context, SHELL_SendDataCallback, SHELL_ReceiveDataCallback,
"SHELL>> ");
|
typedef void(* | send_data_cb_t )(uint8_t *buf, uint32_t len) |
| Shell user send data callback prototype. More...
|
|
typedef void(* | recv_data_cb_t )(uint8_t *buf, uint32_t len) |
| Shell user receiver data callback prototype. More...
|
|
typedef int(* | printf_data_t )(const char *format,...) |
| Shell user printf data prototype. More...
|
|
typedef int32_t(* | cmd_function_t )(p_shell_context_t context, int32_t argc, char **argv) |
| User command function prototype. More...
|
|
struct shell_context_struct |
struct shell_command_context_t |
const char* shell_command_context_t::pcCommand |
For example "help". It must be all lower case.
char* shell_command_context_t::pcHelpString |
It should start with the command itself, and end with "\r\n". For example "help: Returns a list of all the commands\r\n".
uint8_t shell_command_context_t::cExpectedNumberOfParameters |
struct shell_command_context_list_t |
#define SHELL_USE_HISTORY (0U) |
#define SHELL_SEARCH_IN_HIST (1U) |
#define SHELL_USE_FILE_STREAM (0U) |
#define SHELL_AUTO_COMPLETE (1U) |
#define SHELL_BUFFER_SIZE (64U) |
#define SHELL_MAX_ARGS (8U) |
#define SHELL_HIST_MAX (3U) |
#define SHELL_MAX_CMD (6U) |
typedef void(* send_data_cb_t)(uint8_t *buf, uint32_t len) |
typedef void(* recv_data_cb_t)(uint8_t *buf, uint32_t len) |
typedef int(* printf_data_t)(const char *format,...) |
typedef int32_t(* cmd_function_t)(p_shell_context_t context, int32_t argc, char **argv) |
Enumerator |
---|
kSHELL_Normal |
Normal key.
|
kSHELL_Special |
Special key.
|
kSHELL_Function |
Function key.
|
This function must be called before calling all other Shell functions. Call operation the Shell commands with user-defined settings. The example below shows how to set up the middleware Shell and how to call the SHELL_Init function by passing in these parameters: Example:
*
SHELL_Init(&user_context, SendDataFunc, ReceiveDataFunc,
"SHELL>> ");
*
- Parameters
-
context | The pointer to the Shell environment and runtime states. |
send_cb | The pointer to call back send data function. |
recv_cb | The pointer to call back receive data function. |
prompt | The string prompt of Shell |
- Parameters
-
command_context | The pointer to the command data structure. |
- Returns
- -1 if error or 0 if success
int32_t SHELL_Main |
( |
p_shell_context_t |
context | ) |
|
Main loop for Shell; After this function is called, Shell begins to initialize the basic variables and starts to work.
- Parameters
-
context | The pointer to the Shell environment and runtime states. |
- Returns
- this function does not return until Shell command exit was called.