change cmd_tokenize().

Remove the return argument because `err_status` is also reflecting the result.
Fix the error message when too many arguments are found.

refactor `execute_config()`, error out when err_status is not OK.
This commit is contained in:
René van Dorst
2026-04-19 22:00:31 +02:00
parent f2ff7d7737
commit da768171a5
+8 -9
View File
@@ -1187,7 +1187,7 @@ err:
// Parse command into words // Parse command into words
// cmd_words_len contains the number of words found. // cmd_words_len contains the number of words found.
// cmd_words_b[] contains only start of a word offset. // cmd_words_b[] contains only start of a word offset.
uint8_t cmd_tokenize(void) __banked void cmd_tokenize(void) __banked
{ {
#ifdef DEBUG #ifdef DEBUG
print_string("Tokenizing command\n"); print_string("Tokenizing command\n");
@@ -1211,7 +1211,7 @@ uint8_t cmd_tokenize(void) __banked
if (line_ptr == CMD_BUF_SIZE - 1) { if (line_ptr == CMD_BUF_SIZE - 1) {
err_status = ERR_CMD_TOO_LONG; err_status = ERR_CMD_TOO_LONG;
return 1; return;
} }
if (is_white && c != ' ') { if (is_white && c != ' ') {
@@ -1220,9 +1220,9 @@ uint8_t cmd_tokenize(void) __banked
cmd_words_b[word++] = line_ptr; cmd_words_b[word++] = line_ptr;
if (word >= N_WORDS) { if (word >= N_WORDS) {
cmd_words_len = 0; cmd_words_len = 0;
print_string("\ntoo many arguments, truncated"); print_string("\nSyntax error: too many arguments.");
err_status = ERR_TOO_MANY_ARGUMENTS; err_status = ERR_TOO_MANY_ARGUMENTS;
return 1; return;
} }
} else if (c == ' ') { } else if (c == ' ') {
is_white = 1; is_white = 1;
@@ -1230,8 +1230,6 @@ uint8_t cmd_tokenize(void) __banked
line_ptr++; line_ptr++;
} }
return 0;
} }
// Print GPIO status // Print GPIO status
@@ -1551,10 +1549,11 @@ void execute_config(void) __banked
c = flash_buf[cfg_idx++]; c = flash_buf[cfg_idx++];
if (c == 0 || c == '\n') { if (c == 0 || c == '\n') {
cmd_buffer[cmd_idx] = '\0'; cmd_buffer[cmd_idx] = '\0';
if (cmd_idx && !cmd_tokenize()) { if (cmd_idx) {
cmd_parser(); cmd_tokenize();
if (err_status) if (err_status != ERR_OK)
goto config_done; goto config_done;
cmd_parser();
} }
if (c == 0) if (c == 0)
goto config_done; goto config_done;