Implement saftey memory dump feature and increase heap space
This commit is contained in:
@@ -39,6 +39,7 @@
|
||||
#include <reflow-controller/settings/settings.h>
|
||||
#include <reflow-controller/button.h>
|
||||
#include <reflow-controller/safety/fault.h>
|
||||
#include <reflow-controller/safety/safety-memory.h>
|
||||
|
||||
#ifndef GIT_VER
|
||||
#define GIT_VER "VERSION NOT SET"
|
||||
@@ -546,6 +547,70 @@ static shellmatta_retCode_t shell_cmd_panic(const shellmatta_handle_t handle, co
|
||||
return SHELLMATTA_OK;
|
||||
}
|
||||
|
||||
static char *get_safety_mem_dump(size_t *used_bytes)
|
||||
{
|
||||
char *buffer;
|
||||
int res;
|
||||
|
||||
buffer = (char *)malloc(5470);
|
||||
|
||||
res = safety_memory_dump_base64(buffer, 5470UL, used_bytes);
|
||||
if (res) {
|
||||
if (buffer)
|
||||
free(buffer);
|
||||
buffer = NULL;
|
||||
}
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
static shellmatta_retCode_t shell_cmd_dump_safety_mem(const shellmatta_handle_t handle, const char *arguments,
|
||||
uint32_t length)
|
||||
{
|
||||
(void)arguments;
|
||||
(void)length;
|
||||
static char *buffer;
|
||||
static const char *ptr;
|
||||
size_t used_bytes;
|
||||
static size_t full_lines = 0;
|
||||
static size_t current_line;
|
||||
size_t remainder;
|
||||
static const char *hline = "----------------------------------------------------------------";
|
||||
|
||||
if (full_lines == 0) {
|
||||
shellmatta_printf(handle, "Safety memory content\r\n%s\r\n", hline);
|
||||
|
||||
buffer = get_safety_mem_dump(&used_bytes);
|
||||
if (!buffer) {
|
||||
shellmatta_printf(handle, "Error dumping memory!\r\n");
|
||||
return SHELLMATTA_OK;
|
||||
}
|
||||
|
||||
full_lines = (used_bytes - 1) / 64;
|
||||
remainder = (used_bytes - 1) % 64;
|
||||
if (remainder)
|
||||
full_lines++;
|
||||
|
||||
ptr = buffer;
|
||||
current_line = 0;
|
||||
return SHELLMATTA_BUSY;
|
||||
} else {
|
||||
if (current_line < full_lines) {
|
||||
shellmatta_printf(handle, "%.64s\r\n", ptr);
|
||||
ptr += 64;
|
||||
current_line++;
|
||||
} else {
|
||||
shellmatta_printf(handle, "%s\r\n", hline);
|
||||
full_lines = 0;
|
||||
if (buffer)
|
||||
free(buffer);
|
||||
buffer = NULL;
|
||||
return SHELLMATTA_OK;
|
||||
}
|
||||
}
|
||||
return SHELLMATTA_BUSY;
|
||||
}
|
||||
|
||||
//typedef struct shellmatta_cmd
|
||||
//{
|
||||
// char *cmd; /**< command name */
|
||||
@@ -555,7 +620,7 @@ static shellmatta_retCode_t shell_cmd_panic(const shellmatta_handle_t handle, co
|
||||
// shellmatta_cmdFct_t cmdFct; /**< pointer to the cmd callack function */
|
||||
// struct shellmatta_cmd *next; /**< pointer to next command or NULL */
|
||||
//} shellmatta_cmd_t;
|
||||
static shellmatta_cmd_t cmd[17] = {
|
||||
static shellmatta_cmd_t cmd[18] = {
|
||||
{
|
||||
.cmd = "version",
|
||||
.cmdAlias = "ver",
|
||||
@@ -690,6 +755,14 @@ static shellmatta_cmd_t cmd[17] = {
|
||||
.helpText = "Panic Mode!",
|
||||
.usageText = "",
|
||||
.cmdFct = shell_cmd_panic,
|
||||
.next = &cmd[17],
|
||||
},
|
||||
{
|
||||
.cmd = "safety-mem-dump",
|
||||
.cmdAlias = NULL,
|
||||
.helpText = "",
|
||||
.usageText = "",
|
||||
.cmdFct = shell_cmd_dump_safety_mem,
|
||||
.next = NULL,
|
||||
},
|
||||
};
|
||||
|
Reference in New Issue
Block a user