Add ptdump shell command
This commit is contained in:
parent
c745f865bd
commit
310922161a
@ -37,6 +37,7 @@
|
|||||||
#define GIT_VER "VERSION NOT SET"
|
#define GIT_VER "VERSION NOT SET"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
extern struct stm_uart shell_uart;
|
||||||
static shellmatta_instance_t shell;
|
static shellmatta_instance_t shell;
|
||||||
static char shell_buffer[512];
|
static char shell_buffer[512];
|
||||||
static char history_buffer[1024];
|
static char history_buffer[1024];
|
||||||
@ -233,6 +234,46 @@ static shellmatta_retCode_t shell_cmd_rot(const shellmatta_handle_t handle,
|
|||||||
return SHELLMATTA_OK;
|
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
|
//typedef struct shellmatta_cmd
|
||||||
//{
|
//{
|
||||||
// char *cmd; /**< command name */
|
// 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 */
|
// struct shellmatta_cmd *next; /**< pointer to next command or NULL */
|
||||||
//} shellmatta_cmd_t;
|
//} shellmatta_cmd_t;
|
||||||
|
|
||||||
static shellmatta_cmd_t cmd[9] = {
|
static shellmatta_cmd_t cmd[10] = {
|
||||||
{
|
{
|
||||||
.cmd = "version",
|
.cmd = "version",
|
||||||
.cmdAlias = "ver",
|
.cmdAlias = "ver",
|
||||||
@ -260,13 +301,21 @@ static shellmatta_cmd_t cmd[9] = {
|
|||||||
.cmdFct = shell_cmd_pt1000_res,
|
.cmdFct = shell_cmd_pt1000_res,
|
||||||
.next = &cmd[2],
|
.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",
|
.cmd = "pt1000-clear-error",
|
||||||
.cmdAlias = "pt-clear",
|
.cmdAlias = "pt-clear",
|
||||||
.helpText = "Clear error status of PT1000 reading",
|
.helpText = "Clear error status of PT1000 reading",
|
||||||
.usageText = NULL,
|
.usageText = NULL,
|
||||||
.cmdFct = shell_cmd_clear_error_status,
|
.cmdFct = shell_cmd_clear_error_status,
|
||||||
.next = &cmd[3],
|
.next = &cmd[4],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.cmd = "digio-get",
|
.cmd = "digio-get",
|
||||||
@ -274,7 +323,7 @@ static shellmatta_cmd_t cmd[9] = {
|
|||||||
.helpText = "Read all digital input/output ports",
|
.helpText = "Read all digital input/output ports",
|
||||||
.usageText = NULL,
|
.usageText = NULL,
|
||||||
.cmdFct = shell_cmd_digio_get,
|
.cmdFct = shell_cmd_digio_get,
|
||||||
.next = &cmd[4],
|
.next = &cmd[5],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.cmd = "digio-set",
|
.cmd = "digio-set",
|
||||||
@ -282,7 +331,7 @@ static shellmatta_cmd_t cmd[9] = {
|
|||||||
.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],
|
.next = &cmd[6],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.cmd = "uptime",
|
.cmd = "uptime",
|
||||||
@ -290,7 +339,7 @@ static shellmatta_cmd_t cmd[9] = {
|
|||||||
.helpText = "Get uptime in seconds",
|
.helpText = "Get uptime in seconds",
|
||||||
.usageText = "",
|
.usageText = "",
|
||||||
.cmdFct = shell_cmd_uptime,
|
.cmdFct = shell_cmd_uptime,
|
||||||
.next = &cmd[6],
|
.next = &cmd[7],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.cmd = "calibrate",
|
.cmd = "calibrate",
|
||||||
@ -298,7 +347,7 @@ static shellmatta_cmd_t cmd[9] = {
|
|||||||
.helpText = "Calibrate resistance measurement",
|
.helpText = "Calibrate resistance measurement",
|
||||||
.usageText = "",
|
.usageText = "",
|
||||||
.cmdFct = shell_cmd_cal,
|
.cmdFct = shell_cmd_cal,
|
||||||
.next = &cmd[7],
|
.next = &cmd[8],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.cmd = "get-stack-pointer",
|
.cmd = "get-stack-pointer",
|
||||||
@ -306,7 +355,7 @@ static shellmatta_cmd_t cmd[9] = {
|
|||||||
.helpText = "Get the stack pointer",
|
.helpText = "Get the stack pointer",
|
||||||
.usageText = "",
|
.usageText = "",
|
||||||
.cmdFct = shell_get_sp,
|
.cmdFct = shell_get_sp,
|
||||||
.next = &cmd[8],
|
.next = &cmd[9],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.cmd = "rotary-encoder",
|
.cmd = "rotary-encoder",
|
||||||
|
Loading…
Reference in New Issue
Block a user