cmd handler stuff
This commit is contained in:
parent
4a71801170
commit
ab3a6ac5ac
@ -4,6 +4,7 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
#include <socket.h>
|
#include <socket.h>
|
||||||
|
|
||||||
@ -41,29 +42,39 @@ typedef struct {
|
|||||||
|
|
||||||
|
|
||||||
// clear statistics
|
// clear statistics
|
||||||
bool clearCmd() {
|
bool clearCmd(char *cmdLine) {
|
||||||
t_mbusCommStats zeroedStats = { .requestCnt = 0, .errorCnt = 0 };
|
t_mbusCommStats zeroedStats = { .requestCnt = 0, .errorCnt = 0 };
|
||||||
mbusCommSetStats(zeroedStats);
|
mbusCommSetStats(zeroedStats);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool globalStatsCmd(char *cmdLine) {
|
||||||
|
t_mbusCommStats *stats = mbusCommGetStats();
|
||||||
|
char buf[256];
|
||||||
|
sprintf(buf, \
|
||||||
|
"Global statistics\n\r" \
|
||||||
|
" Requests: %d\n\r" \
|
||||||
|
" Errors: %d\n\r",
|
||||||
|
stats->requestCnt, stats->errorCnt
|
||||||
|
);
|
||||||
|
send(CMD_SOCK, buf, strlen(buf));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const static cmd_t COMMANDS[] = {
|
const static cmd_t COMMANDS[] = {
|
||||||
{ .requiredConfigMode = true,
|
{ .requiredConfigMode = true, .name = "clear", .cmdFunc = clearCmd,
|
||||||
.name = "clear",
|
.help = \
|
||||||
.help = \
|
|
||||||
"clear ................................ Clears the global Meterbus\n\r" \
|
"clear ................................ Clears the global Meterbus\n\r" \
|
||||||
" statistics\n\r" \
|
" statistics\n\r" \
|
||||||
" Required configuration mode\n\r",
|
" Required configuration mode\n\r"
|
||||||
.cmdFunc = clearCmd
|
|
||||||
},
|
},
|
||||||
{ .requiredConfigMode = false,
|
{ .requiredConfigMode = false, .name = "globalStats", .cmdFunc = globalStatsCmd,
|
||||||
.name = "END_OF_CMDS",
|
.help = \
|
||||||
.help = "",
|
"globalStats .......................... Show the global statistics\n\r" \
|
||||||
.cmdFunc = NULL
|
" counters requestCnt and errorCnt\n\r"
|
||||||
}
|
},
|
||||||
|
{ .requiredConfigMode = false, .name = "END_OF_CMDS", .help = "",.cmdFunc = NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user