From 6273c68821bf9b14c65b6498ff5e4f5d6d4ff5f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20H=C3=BCttel?= Date: Sat, 10 Apr 2021 20:09:52 +0200 Subject: [PATCH] Shell update command: Take file name as argument --- stm-firmware/shell.c | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/stm-firmware/shell.c b/stm-firmware/shell.c index dac0404..e56244d 100644 --- a/stm-firmware/shell.c +++ b/stm-firmware/shell.c @@ -632,8 +632,30 @@ shellmatta_retCode_t shell_cmd_update(const shellmatta_handle_t handle, const ch (void)handle; (void)arguments; (void)length; + shellmatta_retCode_t opt_stat; + char option; + char *argument; + uint32_t arg_len; + const char *update_file = NULL; - updater_update_from_file("update.hex"); + const shellmatta_opt_long_t options[] = { + {NULL, '\0', SHELLMATTA_OPT_ARG_NONE}, + }; + + while (1) { + opt_stat = shellmatta_opt_long(handle, options, &option, &argument, &arg_len); + if (opt_stat != SHELLMATTA_OK) + break; + switch (option) { + case '\0': + update_file = argument; + break; + default: + break; + } + } + + updater_update_from_file(update_file); return SHELLMATTA_OK; } @@ -872,7 +894,7 @@ static shellmatta_cmd_t cmd[21] = { { .cmd = "save-calibration", .cmdAlias = "save-cal", - .helpText = "", + .helpText = "Permanently save the calibration to EEPROM", .usageText = "", .cmdFct = shell_cmd_save_cal, .next = &cmd[13], @@ -920,8 +942,8 @@ static shellmatta_cmd_t cmd[21] = { { .cmd = "update", .cmdAlias = NULL, - .helpText = "Update Firmware. The updater searches for a file called update.hex", - .usageText = "update", + .helpText = "Update Firmware from HEX file", + .usageText = "update ", .cmdFct = shell_cmd_update, .next = &cmd[19],