From 5662285a3e7a72d789ccd8134305751df9e09a42 Mon Sep 17 00:00:00 2001 From: chriz Date: Mon, 26 Jan 2026 23:29:23 +0100 Subject: [PATCH] Clear command log after saving. --- cmd_parser.c | 8 +++++++- cmd_parser.h | 1 + html/system.js | 6 ++++++ httpd/httpd.c | 8 ++++++++ 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/cmd_parser.c b/cmd_parser.c index ed7d159..23ee86f 100644 --- a/cmd_parser.c +++ b/cmd_parser.c @@ -993,7 +993,13 @@ void execute_config(void) __banked config_done: // Start saving commands to cmd_history save_cmd = 1; + clear_command_history(); +} + +void clear_command_history(void) __banked +{ for (cmd_history_ptr = 0; cmd_history_ptr < CMD_HISTORY_SIZE; cmd_history_ptr++) cmd_history[cmd_history_ptr] = 0; cmd_history_ptr = 0; -} + return; +} \ No newline at end of file diff --git a/cmd_parser.h b/cmd_parser.h index 09805bd..816d00b 100644 --- a/cmd_parser.h +++ b/cmd_parser.h @@ -12,4 +12,5 @@ uint8_t cmd_tokenize(void) __banked; void cmd_parser(void) __banked; void execute_config(void) __banked; void print_sw_version(void) __banked; +void clear_command_history(void) __banked; #endif diff --git a/html/system.js b/html/system.js index 69741b4..e58113c 100644 --- a/html/system.js +++ b/html/system.js @@ -46,6 +46,12 @@ async function flashSave() { var configContent = document.getElementById("config_display").value; console.log("CONFIGURATION to save: ", configContent); sendConfig(configContent); + // Clear the command log 1 second after initiating the config save + setTimeout(() => { + fetch('/cmd_log_clear', { method: 'GET' }) + .then(response => console.log('Command log cleared', response)) + .catch(err => console.error('Error clearing command log:', err)); + }, 1000); } function clearConfig() { diff --git a/httpd/httpd.c b/httpd/httpd.c index b9d6ead..194fc60 100644 --- a/httpd/httpd.c +++ b/httpd/httpd.c @@ -301,6 +301,8 @@ uint8_t stream_upload(uint16_t bptr) print_string("Checksum incorrect!"); } print_string("\nUpload to flash done, will reset!\n"); + // close connection to avoid retries by browser + uip_close(); reset_chip(); } // Make sure there is a 0 at the end of the uploaded data @@ -310,6 +312,9 @@ uint8_t stream_upload(uint16_t bptr) flash_write_bytes(flash_buf); if (bptr >= uip_len) return 0; + if(!verify_crc) + //ugly hack to signal connection finished after config upload. + uip_close(); return 1; } if (p[bptr] == boundary[bindex]) { @@ -593,6 +598,9 @@ void httpd_appcall(void) send_config(); } else if (is_word(q, "/cmd_log")) { send_cmd_log(); + } else if (is_word(q, "/cmd_log_clear")) { + clear_command_history(); + send_mtu(); // dummy response } else { send_not_found(); }