Shell update command: Take file name as argument

This commit is contained in:
Mario Hüttel 2021-04-10 20:09:52 +02:00
parent 3381840bba
commit 6273c68821

View File

@ -632,8 +632,30 @@ shellmatta_retCode_t shell_cmd_update(const shellmatta_handle_t handle, const ch
(void)handle; (void)handle;
(void)arguments; (void)arguments;
(void)length; (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; return SHELLMATTA_OK;
} }
@ -872,7 +894,7 @@ static shellmatta_cmd_t cmd[21] = {
{ {
.cmd = "save-calibration", .cmd = "save-calibration",
.cmdAlias = "save-cal", .cmdAlias = "save-cal",
.helpText = "", .helpText = "Permanently save the calibration to EEPROM",
.usageText = "", .usageText = "",
.cmdFct = shell_cmd_save_cal, .cmdFct = shell_cmd_save_cal,
.next = &cmd[13], .next = &cmd[13],
@ -920,8 +942,8 @@ static shellmatta_cmd_t cmd[21] = {
{ {
.cmd = "update", .cmd = "update",
.cmdAlias = NULL, .cmdAlias = NULL,
.helpText = "Update Firmware. The updater searches for a file called update.hex", .helpText = "Update Firmware from HEX file",
.usageText = "update", .usageText = "update </path/to/update.hex>",
.cmdFct = shell_cmd_update, .cmdFct = shell_cmd_update,
.next = &cmd[19], .next = &cmd[19],