From 9cd024a791694cd9c0ac34f2f90b5a43b3c71c98 Mon Sep 17 00:00:00 2001 From: Mitch Bradley Date: Wed, 4 Aug 2021 09:52:32 -1000 Subject: [PATCH] Added begin and end markers to data blocks --- Grbl_Esp32/src/Configuration/RuntimeSetting.cpp | 2 ++ Grbl_Esp32/src/ProcessSettings.cpp | 2 ++ Grbl_Esp32/src/Report.cpp | 3 +++ Grbl_Esp32/src/Report.h | 3 +++ Grbl_Esp32/src/WebUI/WebSettings.cpp | 5 ++++- 5 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Grbl_Esp32/src/Configuration/RuntimeSetting.cpp b/Grbl_Esp32/src/Configuration/RuntimeSetting.cpp index cca93f3d..474580af 100644 --- a/Grbl_Esp32/src/Configuration/RuntimeSetting.cpp +++ b/Grbl_Esp32/src/Configuration/RuntimeSetting.cpp @@ -50,9 +50,11 @@ namespace Configuration { } else { if (newValue_ == nullptr) { ClientStream ss(CLIENT_ALL); + ss << dataBeginMarker; ss << setting_ << ":\n"; Configuration::Generator generator(ss, 1); value->group(generator); + ss << dataEndMarker; isHandled_ = true; } else { log_error("Can't set a value on a section"); diff --git a/Grbl_Esp32/src/ProcessSettings.cpp b/Grbl_Esp32/src/ProcessSettings.cpp index ee321e93..7c077999 100644 --- a/Grbl_Esp32/src/ProcessSettings.cpp +++ b/Grbl_Esp32/src/ProcessSettings.cpp @@ -498,11 +498,13 @@ Error motor_disable(const char* value, WebUI::AuthenticationLevel auth_level, We } Error dump_config(const char* value, WebUI::AuthenticationLevel auth_level, WebUI::ESPResponseStream* out) { + grbl_send(CLIENT_ALL, dataBeginMarker); try { ClientStream ss(CLIENT_ALL); Configuration::Generator generator(ss); config->group(generator); } catch (std::exception& ex) { log_info("Config dump error: " << ex.what()); } + grbl_send(CLIENT_ALL, dataEndMarker); return Error::Ok; } diff --git a/Grbl_Esp32/src/Report.cpp b/Grbl_Esp32/src/Report.cpp index eb1a5fe9..9fb895bf 100644 --- a/Grbl_Esp32/src/Report.cpp +++ b/Grbl_Esp32/src/Report.cpp @@ -897,3 +897,6 @@ float* get_wco() { } return wco; } + +const char* dataBeginMarker = "[MSG: BeginData]\n"; +const char* dataEndMarker = "[MSG: EndData]\n"; diff --git a/Grbl_Esp32/src/Report.h b/Grbl_Esp32/src/Report.h index 11c055fd..32b9b168 100644 --- a/Grbl_Esp32/src/Report.h +++ b/Grbl_Esp32/src/Report.h @@ -139,3 +139,6 @@ float* get_wco(); void mpos_to_wpos(float* position); void addPinReport(char* status, char pinLetter); + +extern const char* dataBeginMarker; +extern const char* dataEndMarker; diff --git a/Grbl_Esp32/src/WebUI/WebSettings.cpp b/Grbl_Esp32/src/WebUI/WebSettings.cpp index ddbceadd..c074ddde 100644 --- a/Grbl_Esp32/src/WebUI/WebSettings.cpp +++ b/Grbl_Esp32/src/WebUI/WebSettings.cpp @@ -293,6 +293,7 @@ namespace WebUI { if (!currentfile) { return Error::FsFailedOpenFile; } + webPrint(dataBeginMarker); while (currentfile.available()) { // String currentline = currentfile.readStringUntil('\n'); // if (currentline.length() > 0) { @@ -301,6 +302,7 @@ namespace WebUI { webPrintln(currentfile.readStringUntil('\n')); } currentfile.close(); + webPrint(dataEndMarker); return Error::Ok; } @@ -661,6 +663,7 @@ namespace WebUI { if ((err = openSDFile(parameter)) != Error::Ok) { return err; } + webPrint(dataBeginMarker); config->_sdCard->_client = (espresponse) ? espresponse->client() : CLIENT_ALL; char fileLine[255]; Error res; @@ -670,8 +673,8 @@ namespace WebUI { if (res != Error::Eof) { webPrintln(errorString(res)); } - webPrintln(""); config->_sdCard->closeFile(); + webPrint(dataEndMarker); return Error::Ok; }