21 #include "../../include/esp3d_config.h"
22 #ifdef ESP_GCODE_HOST_FEATURE
24 #include "../../core/settings_esp3d.h"
25 #include "../../core/commands.h"
26 #include "../../core/esp3doutput.h"
27 #include "../serial/serial_service.h"
28 #include "../filesystem/esp_filesystem.h"
35 _waitwhenidle =
false;
47 _waitwhenidle = waitwhenidle;
62 uint8_t checksum_val =0;
63 if (command == NULL) {
66 for (uint32_t i=0; i < commandSize; i++) {
67 checksum_val = checksum_val ^ ((uint8_t)command[i]);
74 String commandchecksum =
"N" + String((uint32_t)commandnb)+
" " + command;
75 uint8_t crc =
Checksum(commandchecksum.c_str(), commandchecksum.length());
76 commandchecksum+=
"*"+String(crc);
77 return commandchecksum;
82 uint32_t start = millis();
91 String resetcmd =
"M110 N0";
108 _needcommandnumber = _commandnumber;
109 uint32_t start = millis();
111 while ((millis()-start) < timeout) {
114 uint8_t * sbuf = (uint8_t *)malloc(len+1);
120 answer+= (
const char *)sbuf;
125 if (answer.indexOf(ack) != -1) {
131 if (answer.indexOf(
"ok") != -1) {
137 String ackstring =
"ok " + String(_commandnumber);
138 if (answer.indexOf(ackstring) != -1) {
146 if ((answer.indexOf(
"Resend:") != -1) || (answer.indexOf(
"rs N") != -1)) {
148 if (_needcommandnumber == _commandnumber) {
152 log_esp3d(
"Error provived %d but need %d", _commandnumber, _needcommandnumber);
157 if (answer.indexOf(
"skip") != -1) {
192 uint32_t start = millis();
237 uint32_t start = millis();
242 if ((millis() - start ) > timeout) {
249 log_esp3d(
"**\n%s\n", (
const char *)buf);
251 String s = (
const char *)buf;
253 if((s.indexOf (
"wait") > -1) || (s.indexOf (
"busy") > -1)) {
267 String sresend =
"Resend:";
271 int pos = response.indexOf(sresend);
273 log_esp3d(
"Cannot find label %d", _error);
276 pos+=sresend.length();
277 int pos2 = response.indexOf(
"\n", pos);
278 String snum = response.substring(pos, pos2);
280 snum.replace(
"\r",
"");
282 log_esp3d(
"Command number to resend is %s", String((uint32_t)l).c_str());
289 log_esp3d(
"Processing FS : %s", filename);
299 size_t filesize = f.
size();
302 for (
size_t c = 0; c< filesize ; c++) {
309 if ((ch == 13)||(ch == 10) || (c==(filesize-1))) {
311 if (!((ch == 13)||(ch == 10)) && (c==(filesize-1))) {
315 if(cmd.length() > 0) {
359 for (uint p = 0; p < strlen(line); p++) {
360 if ((line[p]==10) || (line[p]==13) || (p == (strlen(line)-1))) {
361 if (!((line[p]==10) || (line[p]==13)) && (p == (strlen(line)-1))) {
391 String FileName = filename;
393 log_esp3d(
"Processing: %s", FileName.c_str());
404 #endif //ESP_GCODE_HOST_FEATURE