1
0
mirror of https://github.com/bdring/Grbl_Esp32.git synced 2025-08-17 12:00:59 +02:00

Added begin and end markers to data blocks

This commit is contained in:
Mitch Bradley
2021-08-04 09:52:32 -10:00
parent 9546dc27f0
commit 9cd024a791
5 changed files with 14 additions and 1 deletions

View File

@@ -50,9 +50,11 @@ namespace Configuration {
} else { } else {
if (newValue_ == nullptr) { if (newValue_ == nullptr) {
ClientStream ss(CLIENT_ALL); ClientStream ss(CLIENT_ALL);
ss << dataBeginMarker;
ss << setting_ << ":\n"; ss << setting_ << ":\n";
Configuration::Generator generator(ss, 1); Configuration::Generator generator(ss, 1);
value->group(generator); value->group(generator);
ss << dataEndMarker;
isHandled_ = true; isHandled_ = true;
} else { } else {
log_error("Can't set a value on a section"); log_error("Can't set a value on a section");

View File

@@ -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) { Error dump_config(const char* value, WebUI::AuthenticationLevel auth_level, WebUI::ESPResponseStream* out) {
grbl_send(CLIENT_ALL, dataBeginMarker);
try { try {
ClientStream ss(CLIENT_ALL); ClientStream ss(CLIENT_ALL);
Configuration::Generator generator(ss); Configuration::Generator generator(ss);
config->group(generator); config->group(generator);
} catch (std::exception& ex) { log_info("Config dump error: " << ex.what()); } } catch (std::exception& ex) { log_info("Config dump error: " << ex.what()); }
grbl_send(CLIENT_ALL, dataEndMarker);
return Error::Ok; return Error::Ok;
} }

View File

@@ -897,3 +897,6 @@ float* get_wco() {
} }
return wco; return wco;
} }
const char* dataBeginMarker = "[MSG: BeginData]\n";
const char* dataEndMarker = "[MSG: EndData]\n";

View File

@@ -139,3 +139,6 @@ float* get_wco();
void mpos_to_wpos(float* position); void mpos_to_wpos(float* position);
void addPinReport(char* status, char pinLetter); void addPinReport(char* status, char pinLetter);
extern const char* dataBeginMarker;
extern const char* dataEndMarker;

View File

@@ -293,6 +293,7 @@ namespace WebUI {
if (!currentfile) { if (!currentfile) {
return Error::FsFailedOpenFile; return Error::FsFailedOpenFile;
} }
webPrint(dataBeginMarker);
while (currentfile.available()) { while (currentfile.available()) {
// String currentline = currentfile.readStringUntil('\n'); // String currentline = currentfile.readStringUntil('\n');
// if (currentline.length() > 0) { // if (currentline.length() > 0) {
@@ -301,6 +302,7 @@ namespace WebUI {
webPrintln(currentfile.readStringUntil('\n')); webPrintln(currentfile.readStringUntil('\n'));
} }
currentfile.close(); currentfile.close();
webPrint(dataEndMarker);
return Error::Ok; return Error::Ok;
} }
@@ -661,6 +663,7 @@ namespace WebUI {
if ((err = openSDFile(parameter)) != Error::Ok) { if ((err = openSDFile(parameter)) != Error::Ok) {
return err; return err;
} }
webPrint(dataBeginMarker);
config->_sdCard->_client = (espresponse) ? espresponse->client() : CLIENT_ALL; config->_sdCard->_client = (espresponse) ? espresponse->client() : CLIENT_ALL;
char fileLine[255]; char fileLine[255];
Error res; Error res;
@@ -670,8 +673,8 @@ namespace WebUI {
if (res != Error::Eof) { if (res != Error::Eof) {
webPrintln(errorString(res)); webPrintln(errorString(res));
} }
webPrintln("");
config->_sdCard->closeFile(); config->_sdCard->closeFile();
webPrint(dataEndMarker);
return Error::Ok; return Error::Ok;
} }