Compare commits

..

4 Commits

Author SHA1 Message Date
83978e8188 Fix typo 2020-04-20 01:06:01 +02:00
4e4dc8e16e Add dynamic memory info to meminfo command 2020-04-20 01:05:48 +02:00
66d6a76e1a Fix shell prompt 2020-04-20 00:15:37 +02:00
310922161a Add ptdump shell command 2020-04-19 16:37:33 +02:00
2 changed files with 78 additions and 16 deletions

View File

@ -159,7 +159,7 @@ int calibration_sequence_shell_cmd(shellmatta_handle_t shell)
/* Check noise values */
if (dev > CALIBRATION_MAX_PEAK_PEAK_NOISE_OHM || dev2 > CALIBRATION_MAX_PEAK_PEAK_NOISE_OHM) {
shellmatta_printf(shell, "Calibration failed! Too much noise. Check you're hardware.\r\n");
shellmatta_printf(shell, "Calibration failed! Too much noise. Check your hardware.\r\n");
return -3;
}

View File

@ -24,6 +24,7 @@
#include <reflow-controller/adc-meas.h>
#include <reflow-controller/digio.h>
#include <stdlib.h>
#include <malloc.h>
#include <helper-macros/helper-macros.h>
#include <reflow-controller/systick.h>
#include <stm-periph/unique-id.h>
@ -37,6 +38,7 @@
#define GIT_VER "VERSION NOT SET"
#endif
extern struct stm_uart shell_uart;
static shellmatta_instance_t shell;
static char shell_buffer[512];
static char history_buffer[1024];
@ -54,8 +56,8 @@ static shellmatta_retCode_t shell_cmd_ver(const shellmatta_handle_t handle,
unique_id_get(&high_id, &mid_id, &low_id);
shellmatta_printf(handle, "Reflow Oven Controller Firmware " xstr(GIT_VER) "\r\n"
"Compiled: " __DATE__ " at " __TIME__ "\r\n"
"Serial: %08X-%08X-%08X", high_id, mid_id, low_id);
"Compiled: " __DATE__ " at " __TIME__ "\r\n"
"Serial: %08X-%08X-%08X", high_id, mid_id, low_id);
return SHELLMATTA_OK;
}
@ -199,12 +201,13 @@ static shellmatta_retCode_t shell_cmd_cal(const shellmatta_handle_t handle,
return SHELLMATTA_OK;
}
static shellmatta_retCode_t shell_get_sp(const shellmatta_handle_t handle,
static shellmatta_retCode_t shell_meminfo(const shellmatta_handle_t handle,
const char *arguments,
uint32_t length)
{
(void)arguments;
(void)length;
struct mallinfo mi;
shellmatta_printf(handle,
"Stack pointer: %p\r\n"
@ -213,6 +216,15 @@ static shellmatta_retCode_t shell_get_sp(const shellmatta_handle_t handle,
read_stack_pointer(),
stack_check_get_usage(),
stack_check_get_free());
mi = mallinfo();
shellmatta_printf(handle, "\r\nDynamic Memory Management\r\n");
shellmatta_printf(handle, "Allocated bytes: %d\r\n", mi.arena, mi.arena);
shellmatta_printf(handle, "Number of free chunks: %d\r\n", mi.ordblks);
shellmatta_printf(handle, "Top-most, releasable space: %d\r\n", mi.keepcost);
shellmatta_printf(handle, "Total free space: %d\r\n", mi.fordblks);
shellmatta_printf(handle, "Total allocated space: %d\r\n", mi.uordblks);
return SHELLMATTA_OK;
}
@ -233,6 +245,48 @@ static shellmatta_retCode_t shell_cmd_rot(const shellmatta_handle_t handle,
return SHELLMATTA_OK;
}
static shellmatta_retCode_t shell_cmd_pt1000_res_loop(const shellmatta_handle_t handle, const char *arguments,
uint32_t length)
{
char arg[20];
size_t arg_len;
int led_status = 0;
bool run_loop = true;
bool single_line = false;
const char *data;
size_t len;
unsigned int i;
arg_len = (sizeof(arg) < length ? sizeof(arg) : length);
strncpy(arg, arguments, arg_len);
if (strstr(arg, "--single-line"))
single_line = true;
shellmatta_printf(handle, "\r\n");
while (run_loop) {
uart_receive_data_with_dma(&shell_uart, &data , &len);
for (i = 0; i < len; i++) {
if (data[i] == '\x03')
run_loop = false;
}
if (single_line)
shellmatta_printf(handle, "\x1b[1A\x1b[150D\x1b[K");
shell_cmd_pt1000_res(handle, "", 0UL);
led_set(0, led_status);
led_set(1, !led_status);
led_status ^= 0x1;
systick_wait_ms(150);
}
led_set(0, 0);
led_set(1, 0);
return SHELLMATTA_OK;
}
//typedef struct shellmatta_cmd
//{
// char *cmd; /**< command name */
@ -243,7 +297,7 @@ static shellmatta_retCode_t shell_cmd_rot(const shellmatta_handle_t handle,
// struct shellmatta_cmd *next; /**< pointer to next command or NULL */
//} shellmatta_cmd_t;
static shellmatta_cmd_t cmd[9] = {
static shellmatta_cmd_t cmd[10] = {
{
.cmd = "version",
.cmdAlias = "ver",
@ -260,13 +314,21 @@ static shellmatta_cmd_t cmd[9] = {
.cmdFct = shell_cmd_pt1000_res,
.next = &cmd[2],
},
{
.cmd = "pt1000-dump",
.cmdAlias = "ptdump",
.helpText = "Get current filtered and calibrated PT1000 resistance in a loop",
.usageText = "pt1000-dump [--single-line]",
.cmdFct = shell_cmd_pt1000_res_loop,
.next = &cmd[3],
},
{
.cmd = "pt1000-clear-error",
.cmdAlias = "pt-clear",
.helpText = "Clear error status of PT1000 reading",
.usageText = NULL,
.cmdFct = shell_cmd_clear_error_status,
.next = &cmd[3],
.next = &cmd[4],
},
{
.cmd = "digio-get",
@ -274,7 +336,7 @@ static shellmatta_cmd_t cmd[9] = {
.helpText = "Read all digital input/output ports",
.usageText = NULL,
.cmdFct = shell_cmd_digio_get,
.next = &cmd[4],
.next = &cmd[5],
},
{
.cmd = "digio-set",
@ -282,7 +344,7 @@ static shellmatta_cmd_t cmd[9] = {
.helpText = "Set DIGIO Port",
.usageText = "digio-set <num> <state>",
.cmdFct = shell_cmd_digio_set,
.next = &cmd[5],
.next = &cmd[6],
},
{
.cmd = "uptime",
@ -290,7 +352,7 @@ static shellmatta_cmd_t cmd[9] = {
.helpText = "Get uptime in seconds",
.usageText = "",
.cmdFct = shell_cmd_uptime,
.next = &cmd[6],
.next = &cmd[7],
},
{
.cmd = "calibrate",
@ -298,15 +360,15 @@ static shellmatta_cmd_t cmd[9] = {
.helpText = "Calibrate resistance measurement",
.usageText = "",
.cmdFct = shell_cmd_cal,
.next = &cmd[7],
.next = &cmd[8],
},
{
.cmd = "get-stack-pointer",
.cmdAlias = "sp",
.helpText = "Get the stack pointer",
.cmd = "meminfo",
.cmdAlias = NULL,
.helpText = "Get information about memory usage",
.usageText = "",
.cmdFct = shell_get_sp,
.next = &cmd[8],
.cmdFct = shell_meminfo,
.next = &cmd[9],
},
{
.cmd = "rotary-encoder",
@ -324,7 +386,7 @@ shellmatta_handle_t shell_init(shellmatta_write_t write_func)
shellmatta_retCode_t ret;
ret = shellmatta_doInit(&shell, &handle, shell_buffer, sizeof(shell_buffer), history_buffer, sizeof(history_buffer),
"\e[1;32mEnter command:\e[m\r\n", cmd, write_func);
"\e[1;32mReflow Controller>\e[m ", cmd, write_func);
if (ret != SHELLMATTA_OK)
handle = NULL;