mirror of
https://github.com/logicog/RTLPlayground.git
synced 2026-10-29 17:54:14 +08:00
config: skip a line the parser cannot buffer instead of stopping
execute_config() replays the saved configuration line by line into cmd_buffer. A line that does not fit, or one cmd_tokenize() rejects, ended the replay right there: everything below it was silently left unapplied, while the file itself and the editor showing it stayed complete. On a switch here, a 130-byte line placed after the last real setting was enough to lose every line that followed it on the next boot. Report the offending line and carry on with the next one. The skip flag lives across the flash page refill, so a long line that crosses a page boundary is not resumed halfway and run as a truncated command.
This commit is contained in:
1 parent
530e2683f0
commit
3a6f62b1d5
1 file changed
+11
-5
+11
-5
@@ -1956,6 +1956,7 @@ void execute_config(void) __banked
|
|||||||
save_cmd = 0;
|
save_cmd = 0;
|
||||||
|
|
||||||
uint8_t cmd_idx = 0;
|
uint8_t cmd_idx = 0;
|
||||||
|
uint8_t skipping = 0;
|
||||||
do {
|
do {
|
||||||
flash_region.addr = pos;
|
flash_region.addr = pos;
|
||||||
flash_region.len = FLASH_READ_BURST_SIZE;
|
flash_region.len = FLASH_READ_BURST_SIZE;
|
||||||
@@ -1966,29 +1967,34 @@ void execute_config(void) __banked
|
|||||||
do {
|
do {
|
||||||
if (cmd_idx >= (CMD_BUF_SIZE - 1)) {
|
if (cmd_idx >= (CMD_BUF_SIZE - 1)) {
|
||||||
cmd_buffer[cmd_idx] = NUL;
|
cmd_buffer[cmd_idx] = NUL;
|
||||||
print_string("ERROR: Command too long: ");
|
print_string("ERROR: Command too long, skipped: ");
|
||||||
print_string_x(cmd_buffer);
|
print_string_x(cmd_buffer);
|
||||||
write_char('\n');
|
write_char('\n');
|
||||||
err_status = ERR_CMD_TOO_LONG;
|
cmd_idx = 0;
|
||||||
goto config_done;
|
skipping = 1;
|
||||||
}
|
}
|
||||||
c = flash_buf[cfg_idx++];
|
c = flash_buf[cfg_idx++];
|
||||||
if (c == 0 || c == '\n') {
|
if (c == 0 || c == '\n') {
|
||||||
|
if (skipping) {
|
||||||
|
skipping = 0;
|
||||||
|
} else {
|
||||||
cmd_buffer[cmd_idx] = NUL;
|
cmd_buffer[cmd_idx] = NUL;
|
||||||
if (cmd_idx) {
|
if (cmd_idx) {
|
||||||
cmd_tokenize();
|
cmd_tokenize();
|
||||||
if (err_status != ERR_OK)
|
if (err_status == ERR_OK)
|
||||||
goto config_done;
|
|
||||||
cmd_parser();
|
cmd_parser();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (c == 0)
|
if (c == 0)
|
||||||
goto config_done;
|
goto config_done;
|
||||||
cmd_idx = 0;
|
cmd_idx = 0;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!skipping) {
|
||||||
cmd_buffer[cmd_idx] = c;
|
cmd_buffer[cmd_idx] = c;
|
||||||
cmd_idx++;
|
cmd_idx++;
|
||||||
|
}
|
||||||
} while (cfg_idx);
|
} while (cfg_idx);
|
||||||
|
|
||||||
pages_left--;
|
pages_left--;
|
||||||
|
|||||||
Reference in new issue
Block a user