subsys: shell: add handlers diagnostic function
Added function: shell_execute_cmd that can be called for command diagnostic purposes. Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
This commit is contained in:
parent
99f64c1e47
commit
61ca8c17c8
2 changed files with 32 additions and 0 deletions
|
@ -585,6 +585,20 @@ bool shell_cmd_precheck(const struct shell *shell,
|
||||||
void shell_print_stream(const void *user_ctx, const char *data,
|
void shell_print_stream(const void *user_ctx, const char *data,
|
||||||
size_t data_len);
|
size_t data_len);
|
||||||
|
|
||||||
|
/** @brief Execute command.
|
||||||
|
*
|
||||||
|
* Pass command line to shell to execute.
|
||||||
|
*
|
||||||
|
* Note: This by no means makes any of the commands a stable interface, so
|
||||||
|
* this function should only be used for debugging/diagnostic.
|
||||||
|
*
|
||||||
|
* @param[in] shell Pointer to the shell instance.
|
||||||
|
* @param[in] cmd Command to be executed.
|
||||||
|
*
|
||||||
|
* @returns Result of the execution
|
||||||
|
*/
|
||||||
|
int shell_execute_cmd(const struct shell *shell, const char *cmd);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1720,3 +1720,21 @@ bool shell_cmd_precheck(const struct shell *shell,
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int shell_execute_cmd(const struct shell *shell, const char *cmd)
|
||||||
|
{
|
||||||
|
u16_t cmd_len = shell_strlen(cmd);
|
||||||
|
|
||||||
|
if ((cmd == NULL) || (shell == NULL)) {
|
||||||
|
return -ENOEXEC;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cmd_len > (CONFIG_SHELL_CMD_BUFF_SIZE - 1)) {
|
||||||
|
return -ENOEXEC;
|
||||||
|
}
|
||||||
|
|
||||||
|
strcpy(shell->ctx->cmd_buff, cmd);
|
||||||
|
shell->ctx->cmd_buff_len = cmd_len;
|
||||||
|
|
||||||
|
return shell_execute(shell);
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue