From 4916f9fdf0b59abb635c12a34105df325b42b449 Mon Sep 17 00:00:00 2001 From: Mitch Bradley Date: Sat, 22 May 2021 14:58:35 -1000 Subject: [PATCH] Use default config after a panic ... to prevent reset loops. --- Grbl_Esp32/src/MachineConfig.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Grbl_Esp32/src/MachineConfig.cpp b/Grbl_Esp32/src/MachineConfig.cpp index d18cb250..1391b4cc 100644 --- a/Grbl_Esp32/src/MachineConfig.cpp +++ b/Grbl_Esp32/src/MachineConfig.cpp @@ -433,8 +433,17 @@ bool MachineConfig::load(const char* filename) { } config = instance(); - char* buffer; - size_t filesize = readFile(filename, buffer); + // If the system crashes we skip the config file and use the default + // builtin config. This helps prevent reset loops on bad config files. + size_t filesize = 0; + char* buffer; + esp_reset_reason_t reason = esp_reset_reason(); + if (reason == ESP_RST_PANIC) { + log_debug("Skipping configuration file due to panic"); + } else { + filesize = readFile(filename, buffer); + } + StringRange* input; if (filesize > 0) {