Add uptime shell command

This commit is contained in:
Mario Hüttel 2020-02-11 22:59:30 +01:00
parent 673e651910
commit d80ce20675
1 changed files with 20 additions and 1 deletions

View File

@ -5,6 +5,7 @@
#include <digio.h> #include <digio.h>
#include <stdlib.h> #include <stdlib.h>
#include <helper-macros/helper-macros.h> #include <helper-macros/helper-macros.h>
#include <systick.h>
#ifndef GIT_VER #ifndef GIT_VER
#define GIT_VER "VERSION NOT SET" #define GIT_VER "VERSION NOT SET"
@ -123,6 +124,16 @@ static shellmatta_retCode_t shell_cmd_clear_error_status(const shellmatta_handle
return SHELLMATTA_OK; return SHELLMATTA_OK;
} }
static shellmatta_retCode_t shell_cmd_uptime(const shellmatta_handle_t handle,
const char *arguments,
uint32_t length)
{
(void)arguments;
(void)length;
shellmatta_printf(handle, "Uptime: %llu secs", global_tick_ms/1000);
return SHELLMATTA_OK;
}
//typedef struct shellmatta_cmd //typedef struct shellmatta_cmd
//{ //{
// char *cmd; /**< command name */ // char *cmd; /**< command name */
@ -133,7 +144,7 @@ static shellmatta_retCode_t shell_cmd_clear_error_status(const shellmatta_handle
// struct shellmatta_cmd *next; /**< pointer to next command or NULL */ // struct shellmatta_cmd *next; /**< pointer to next command or NULL */
//} shellmatta_cmd_t; //} shellmatta_cmd_t;
static shellmatta_cmd_t cmd[5] = { static shellmatta_cmd_t cmd[6] = {
{ {
.cmd = "version", .cmd = "version",
.cmdAlias = "ver", .cmdAlias = "ver",
@ -172,6 +183,14 @@ static shellmatta_cmd_t cmd[5] = {
.helpText = "Set DIGIO Port", .helpText = "Set DIGIO Port",
.usageText = "digio-set <num> <state>", .usageText = "digio-set <num> <state>",
.cmdFct = shell_cmd_digio_set, .cmdFct = shell_cmd_digio_set,
.next = &cmd[5],
},
{
.cmd = "uptime",
.cmdAlias = "upt",
.helpText = "Get uptime in seconds",
.usageText = "",
.cmdFct = shell_cmd_uptime,
.next = NULL, .next = NULL,
}, },
}; };