Add ptdump shell command

This commit is contained in:
Mario Hüttel 2020-04-19 16:37:33 +02:00
parent c745f865bd
commit 310922161a

View File

@ -37,6 +37,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 +55,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;
}
@ -233,6 +234,46 @@ 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;
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 +284,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 +301,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 +323,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 +331,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 +339,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,7 +347,7 @@ 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",
@ -306,7 +355,7 @@ static shellmatta_cmd_t cmd[9] = {
.helpText = "Get the stack pointer",
.usageText = "",
.cmdFct = shell_get_sp,
.next = &cmd[8],
.next = &cmd[9],
},
{
.cmd = "rotary-encoder",