Make ptdump command async: Main loop will continue if comamnd is called
This commit is contained in:
@@ -205,8 +205,8 @@ static shellmatta_retCode_t shell_cmd_cal(const shellmatta_handle_t handle,
|
||||
}
|
||||
|
||||
static shellmatta_retCode_t shell_meminfo(const shellmatta_handle_t handle,
|
||||
const char *arguments,
|
||||
uint32_t length)
|
||||
const char *arguments,
|
||||
uint32_t length)
|
||||
{
|
||||
(void)arguments;
|
||||
(void)length;
|
||||
@@ -251,50 +251,20 @@ static shellmatta_retCode_t shell_cmd_rot(const shellmatta_handle_t handle,
|
||||
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;
|
||||
(void)arguments;
|
||||
(void)length;
|
||||
static uint64_t timestamp = 0ULL;
|
||||
|
||||
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");
|
||||
if (systick_ticks_have_passed(timestamp, 150)) {
|
||||
shell_cmd_pt1000_res(handle, "", 0UL);
|
||||
|
||||
led_set(1, led_status);
|
||||
if (adc_pt1000_check_error() & ADC_PT1000_WATCHDOG_ERROR) {
|
||||
led_set(0, 1);
|
||||
}
|
||||
|
||||
led_status ^= 0x1;
|
||||
|
||||
systick_wait_ms(150);
|
||||
timestamp = systick_get_global_tick();
|
||||
}
|
||||
|
||||
led_set(0, 0);
|
||||
led_set(1, 0);
|
||||
|
||||
return SHELLMATTA_OK;
|
||||
return SHELLMATTA_CONTINUE;
|
||||
}
|
||||
|
||||
static shellmatta_retCode_t shell_cmd_ls(const shellmatta_handle_t handle, const char *arguments,
|
||||
uint32_t length)
|
||||
uint32_t length)
|
||||
{
|
||||
(void)length;
|
||||
(void)arguments;
|
||||
@@ -320,7 +290,7 @@ static shellmatta_retCode_t shell_cmd_ls(const shellmatta_handle_t handle, const
|
||||
}
|
||||
|
||||
static shellmatta_retCode_t shell_cmd_reset(const shellmatta_handle_t handle, const char *arguments,
|
||||
uint32_t length)
|
||||
uint32_t length)
|
||||
{
|
||||
(void)handle;
|
||||
(void)length;
|
||||
@@ -332,7 +302,7 @@ static shellmatta_retCode_t shell_cmd_reset(const shellmatta_handle_t handle, co
|
||||
}
|
||||
|
||||
static shellmatta_retCode_t shell_cmd_cat(const shellmatta_handle_t handle, const char *arguments,
|
||||
uint32_t length)
|
||||
uint32_t length)
|
||||
{
|
||||
FIL file;
|
||||
char path_buff[256];
|
||||
@@ -404,7 +374,7 @@ static shellmatta_cmd_t cmd[13] = {
|
||||
.cmd = "pt1000-dump",
|
||||
.cmdAlias = "ptdump",
|
||||
.helpText = "Get current filtered and calibrated PT1000 resistance in a loop",
|
||||
.usageText = "pt1000-dump [--single-line]",
|
||||
.usageText = "pt1000-dump",
|
||||
.cmdFct = shell_cmd_pt1000_res_loop,
|
||||
.next = &cmd[3],
|
||||
},
|
||||
|
Reference in New Issue
Block a user