Skip to content

Commit 2714904

Browse files
committed
Fix bug reading Macro on SPIFFS
1 parent e7252dc commit 2714904

File tree

2 files changed

+30
-29
lines changed

2 files changed

+30
-29
lines changed

esp3d/command.cpp

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1217,38 +1217,39 @@ bool COMMAND::execute_command(int cmd,String cmd_params, tpipe output, level_aut
12171217
if (currentfile) {//if file open success
12181218
//flush to be sure send buffer is empty
12191219
ESP_SERIAL_OUT.flush();
1220-
//read content
1221-
String currentline = currentfile.readString();
12221220
//until no line in file
1223-
while (currentline.length() >0) {
1224-
int ESPpos = currentline.indexOf("[ESP");
1225-
if (ESPpos>-1) {
1226-
//is there the second part?
1227-
int ESPpos2 = currentline.indexOf("]",ESPpos);
1228-
if (ESPpos2>-1) {
1229-
//Split in command and parameters
1230-
String cmd_part1=currentline.substring(ESPpos+4,ESPpos2);
1231-
String cmd_part2="";
1232-
//is there space for parameters?
1233-
if (ESPpos2<currentline.length()) {
1234-
cmd_part2=currentline.substring(ESPpos2+1);
1235-
}
1236-
//if command is a valid number then execute command
1237-
if(cmd_part1.toInt()!=0) {
1238-
execute_command(cmd_part1.toInt(),cmd_part2,NO_PIPE);
1221+
while (currentfile.available()) {
1222+
String currentline = currentfile.readStringUntil('\n');
1223+
currentline.replace("\n","");
1224+
currentline.replace("\r","");
1225+
if (currentline.length() > 0) {
1226+
int ESPpos = currentline.indexOf("[ESP");
1227+
if (ESPpos>-1) {
1228+
//is there the second part?
1229+
int ESPpos2 = currentline.indexOf("]",ESPpos);
1230+
if (ESPpos2>-1) {
1231+
//Split in command and parameters
1232+
String cmd_part1=currentline.substring(ESPpos+4,ESPpos2);
1233+
String cmd_part2="";
1234+
//is there space for parameters?
1235+
if (ESPpos2<currentline.length()) {
1236+
cmd_part2=currentline.substring(ESPpos2+1);
1237+
}
1238+
//if command is a valid number then execute command
1239+
if(cmd_part1.toInt()!=0) {
1240+
execute_command(cmd_part1.toInt(),cmd_part2,NO_PIPE);
1241+
}
1242+
//if not is not a valid [ESPXXX] command ignore it
12391243
}
1240-
//if not is not a valid [ESPXXX] command ignore it
1244+
} else {
1245+
//send line to serial
1246+
ESP_SERIAL_OUT.println(currentline);
1247+
//flush to be sure send buffer is empty
1248+
delay(0);
1249+
ESP_SERIAL_OUT.flush();
12411250
}
1242-
} else {
1243-
//send line to serial
1244-
ESP_SERIAL_OUT.println(currentline);
1245-
//flush to be sure send buffer is empty
1246-
delay(0);
1247-
ESP_SERIAL_OUT.flush();
1251+
delay(0);
12481252
}
1249-
currentline="";
1250-
//read next line if any
1251-
currentline = currentfile.readString();
12521253
}
12531254
currentfile.close();
12541255
BRIDGE::println(OK_CMD_MSG, output);

esp3d/config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ extern "C" {
186186
#endif
187187
#include "wificonf.h"
188188
//version and sources location
189-
#define FW_VERSION "0.9.99"
189+
#define FW_VERSION "0.9.100"
190190
#define REPOSITORY "https://github.com/luc-github/ESP3D"
191191

192192
typedef enum {

0 commit comments

Comments
 (0)