...
- A brief description
- The function prototype
- The filename of the source code
- A description of the arguments passed to the function
- A description of the returned value(s)
- Specific notes and warnings on using the service
- A usage example
Shell_CmdTblAdd()
Code Block |
---|
|
void Shell_CmdTblAdd (CPU_CHAR *cmd_tbl_name,
SHELL_CMD cmd_tbl[],
SHELL_ERR *perr); |
File | Called from |
shell.c | Application |
...
The names of those module commands are respectively 'Net
' and 'FS
'.
Example
Code Block |
---|
language | cpp |
---|
linenumbers | true |
---|
|
static SHELL_CMD App_ShellAppCmdTbl[] = {
{"App_test", App_TestShellCmd},
{0, 0}
};
void App_CmdTblAdd (void)
{
SHELL_ERR err;
APP_TRACE_DEBUG(("Adding Shell command table ... "));
Shell_CmdTblAdd("App", App_ShellAppCmdTbl, &err);
if (err == SHELL_ERR_NONE) {
APP_TRACE_DEBUG(("done.\n\r"));
} else {
APP_TRACE_DEBUG(("failed.\n\r"));
}
} |
Shell_CmdTblRem ()
Code Block |
---|
|
void Shell_CmdTblRem (CPU_CHAR *cmd_tbl_name,
SHELL_ERR *perr); |
File | Called from |
shell.c | Application |
...
Returned Values
None.
Notes/Warnings
None.
Example
Code Block |
---|
language | cpp |
---|
linenumbers | true |
---|
|
void App_CmdTblRem (void)
{
SHELL_ERR err;
APP_TRACE_DEBUG(("Removing Shell command table ... "));
Shell_CmdTblRem("App", &err);
if (err == SHELL_ERR_NONE) {
APP_TRACE_DEBUG(("done.\n\r"));
} else {
APP_TRACE_DEBUG(("failed.\n\r"));
}
} |
Shell_Exec ()
Code Block |
---|
|
CPU_INT16S Shell_Exec (CPU_CHAR *in,
SHELL_OUT_FNCT out_fnct, |
File | Called from |
shell.c | Application |
Parses and executes the command passed in parameter.
Arguments
in
Pointer to a CPU_CHAR
string holding a complete command and its argument(s).
...
The command may generate some output that should be transmitted to some device (socket, RS-232 link, ...). The caller of this function is hence responsible for the implementation of such function, if output is desired.
Example
Code Block |
---|
language | cpp |
---|
linenumbers | true |
---|
|
void App_Exec (void)
{
SHELL_ERR err;
APP_TRACE_DEBUG(("Testing Shell, executing command ...\n\r"));
Shell_Exec("App_test -a -b -c", &App_TestShellOut, &err);
switch (err) {
case SHELL_ERR_NONE:
APP_TRACE_DEBUG(("Command executed, no error.\n\r"));
break;
case SHELL_ERR_NULL_PTR:
APP_TRACE_DEBUG(("Error, NULL pointer passed.\n\r"));
break;
case SHELL_ERR_CMD_NOT_FOUND:
APP_TRACE_DEBUG(("Error, command NOT found.\n\r"));
break;
case SHELL_ERR_CMD_SEARCH:
APP_TRACE_DEBUG(("Error, searching command.\n\r"));
break;
case SHELL_ERR_ARG_TBL_FULL:
APP_TRACE_DEBUG(("Error, too many arguments\n\r"));
break;
case SHELL_ERR_CMD_EXEC:
APP_TRACE_DEBUG (("Error, executing command.\n\r"));
break;
default:
break;
}
} |
Shell_Init()
Code Block |
---|
|
CPU_BOOLEAN Shell_Init (void); |
File | Called from |
shell.c | Application |
...
The Shell_Init()
function must be called before the other Shell function are invoked. Shell_Init()
must also only be called once from product's application.
Example
Code Block |
---|
language | cpp |
---|
linenumbers | true |
---|
|
void App_Init (void)
{
CPU_BOOLEAN success;
SHELL_ERR err;
APP_TRACE_DEBUG(("Initialize shell ... "));
Success = Shell_Init();
if (success == DEF_OK) {
APP_TRACE_DEBUG(("done.\n\r"));
} else {
APP_TRACE_DEBUG(("failed.\n\r"));
}
} |