mirror of
https://git.mirrors.martin98.com/https://github.com/luc-github/ESP3D.git
synced 2025-08-12 23:49:07 +08:00
Fix bug reading Macro on SPIFFS
This commit is contained in:
parent
e7252dca66
commit
2714904c52
@ -1217,38 +1217,39 @@ bool COMMAND::execute_command(int cmd,String cmd_params, tpipe output, level_aut
|
|||||||
if (currentfile) {//if file open success
|
if (currentfile) {//if file open success
|
||||||
//flush to be sure send buffer is empty
|
//flush to be sure send buffer is empty
|
||||||
ESP_SERIAL_OUT.flush();
|
ESP_SERIAL_OUT.flush();
|
||||||
//read content
|
|
||||||
String currentline = currentfile.readString();
|
|
||||||
//until no line in file
|
//until no line in file
|
||||||
while (currentline.length() >0) {
|
while (currentfile.available()) {
|
||||||
int ESPpos = currentline.indexOf("[ESP");
|
String currentline = currentfile.readStringUntil('\n');
|
||||||
if (ESPpos>-1) {
|
currentline.replace("\n","");
|
||||||
//is there the second part?
|
currentline.replace("\r","");
|
||||||
int ESPpos2 = currentline.indexOf("]",ESPpos);
|
if (currentline.length() > 0) {
|
||||||
if (ESPpos2>-1) {
|
int ESPpos = currentline.indexOf("[ESP");
|
||||||
//Split in command and parameters
|
if (ESPpos>-1) {
|
||||||
String cmd_part1=currentline.substring(ESPpos+4,ESPpos2);
|
//is there the second part?
|
||||||
String cmd_part2="";
|
int ESPpos2 = currentline.indexOf("]",ESPpos);
|
||||||
//is there space for parameters?
|
if (ESPpos2>-1) {
|
||||||
if (ESPpos2<currentline.length()) {
|
//Split in command and parameters
|
||||||
cmd_part2=currentline.substring(ESPpos2+1);
|
String cmd_part1=currentline.substring(ESPpos+4,ESPpos2);
|
||||||
|
String cmd_part2="";
|
||||||
|
//is there space for parameters?
|
||||||
|
if (ESPpos2<currentline.length()) {
|
||||||
|
cmd_part2=currentline.substring(ESPpos2+1);
|
||||||
|
}
|
||||||
|
//if command is a valid number then execute command
|
||||||
|
if(cmd_part1.toInt()!=0) {
|
||||||
|
execute_command(cmd_part1.toInt(),cmd_part2,NO_PIPE);
|
||||||
|
}
|
||||||
|
//if not is not a valid [ESPXXX] command ignore it
|
||||||
}
|
}
|
||||||
//if command is a valid number then execute command
|
} else {
|
||||||
if(cmd_part1.toInt()!=0) {
|
//send line to serial
|
||||||
execute_command(cmd_part1.toInt(),cmd_part2,NO_PIPE);
|
ESP_SERIAL_OUT.println(currentline);
|
||||||
}
|
//flush to be sure send buffer is empty
|
||||||
//if not is not a valid [ESPXXX] command ignore it
|
delay(0);
|
||||||
|
ESP_SERIAL_OUT.flush();
|
||||||
}
|
}
|
||||||
} else {
|
delay(0);
|
||||||
//send line to serial
|
|
||||||
ESP_SERIAL_OUT.println(currentline);
|
|
||||||
//flush to be sure send buffer is empty
|
|
||||||
delay(0);
|
|
||||||
ESP_SERIAL_OUT.flush();
|
|
||||||
}
|
}
|
||||||
currentline="";
|
|
||||||
//read next line if any
|
|
||||||
currentline = currentfile.readString();
|
|
||||||
}
|
}
|
||||||
currentfile.close();
|
currentfile.close();
|
||||||
BRIDGE::println(OK_CMD_MSG, output);
|
BRIDGE::println(OK_CMD_MSG, output);
|
||||||
|
@ -186,7 +186,7 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
#include "wificonf.h"
|
#include "wificonf.h"
|
||||||
//version and sources location
|
//version and sources location
|
||||||
#define FW_VERSION "0.9.99"
|
#define FW_VERSION "0.9.100"
|
||||||
#define REPOSITORY "https://github.com/luc-github/ESP3D"
|
#define REPOSITORY "https://github.com/luc-github/ESP3D"
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user