void loop() {
start:
pwrErr = 0;
if (Serial2.available() > 0) {
command = Serial2.readString();
command.trim();
if (command == "auto") {
delay(tOPing);
String C00 = "0";
Serial1.println("CPM");
CPM = Serial1.readString();
CPM.trim();
if (CPM.substring(1) == "APM") {
Serial.println(CPM + " Ping OK");
myNex.writeStr("t1.txt+", "Ping OK...\\r");
tstCnt++;
} else {
digitalWrite(RELPWR, LOW);
serErr = 1;
Serial.println(CPM + "Ping fail");
myNex.writeStr("t1.txt+", "Failed...\\r");
myNex.writeStr("t1.txt+", "Aborted\\r");
myNex.writeStr("t2.txt", (String) "Failed - (" + tstCnt + "/" + totTst + ") OK");
myNex.writeNum("t2.bco", 63488);
delay(tO1);
myNex.writeStr("b4.txt", "Repeat");
myNex.writeStr("vis b4,1");
myNex.writeStr("vis b5,1");
myNex.writeStr("vis b6,1");
delay(tO1);
goto start;
}
}
There is another issue with that part of my code, without the tO1 delays, it does not print all the strings to the nextion touchscreen. It somehow jumps back to start too quick.
The code works great but I don't like it.
I know its not a good idea to use "goto", any other ideas?