From de9ef8984b4e92e3c7f966b94adb961b5e10723a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BD=D0=B8=D0=BB=D0=B0=20=D0=93=D0=BE=D1=80?= =?UTF-8?q?=D0=BD=D1=83=D1=88=D0=BA=D0=BE?= Date: Tue, 28 Nov 2023 17:09:17 +0300 Subject: [PATCH] refactor argtable options registration --- main/cmd_can.c | 8 ++++---- main/cmd_utils.c | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/main/cmd_can.c b/main/cmd_can.c index 55e1dc1..7dd268e 100644 --- a/main/cmd_can.c +++ b/main/cmd_can.c @@ -34,7 +34,7 @@ static struct { } cansend_args; static struct { - struct arg_str *speed; + struct arg_int *speed; struct arg_str *filters; struct arg_lit *autorecover; struct arg_str *mode; @@ -182,7 +182,7 @@ static int candown(int argc, char **argv) { static void register_cansend(void) { cansend_args.message = arg_str1(NULL, NULL, "ID#data", "Message to send, ID and data bytes, all in hex. # is the delimiter."); - cansend_args.end = arg_end(1); + cansend_args.end = arg_end(2); const esp_console_cmd_t cmd = { .command = "cansend", @@ -196,10 +196,10 @@ static void register_cansend(void) { static void register_canup(void) { - canup_args.speed = arg_str1(NULL, NULL, "", "CAN bus speed, in bps. See help for supported speeds."); + canup_args.speed = arg_int1(NULL, NULL, "", "CAN bus speed, in bps. See help for supported speeds."); canup_args.mode = arg_str0("m", "mode", "", "Set CAN mode. Normal (default), No Ack (for self-testing) or Listen Only (to prevent transmitting, for monitoring)."); canup_args.filters = arg_str0("f", "filters", "", "CAN filters to receive only selected frames."); - canup_args.autorecover = arg_litn("r", "auto-recovery", 0, 1, "Set to enable auto-recovery of CAN bus if case of bus-off event"); + canup_args.autorecover = arg_lit0("r", "auto-recovery", "Set to enable auto-recovery of CAN bus if case of bus-off event"); canup_args.end = arg_end(4); const esp_console_cmd_t cmd = { diff --git a/main/cmd_utils.c b/main/cmd_utils.c index b062687..f73ab9c 100644 --- a/main/cmd_utils.c +++ b/main/cmd_utils.c @@ -39,8 +39,8 @@ static int timestamp(int argc, char **argv) { static void register_timestamp(void) { - timestamp_args.disable = arg_litn("d", "disable", 0, 1, "Set to disable timestamps."); - timestamp_args.end = arg_end(1); + timestamp_args.disable = arg_lit0("d", "disable", "Set to disable timestamps."); + timestamp_args.end = arg_end(2); const esp_console_cmd_t cmd = { .command = "timestamp",