Hi, beginner here, so please be gentle
I am trying to stop a while look if a timer runs out (millis(). But I just cannot find a way of doing it.
What I am trying to do is if a certain string is not received before the timer reaches the target time, I want it to get out of the while loop. I tried all I can to my knowledge, and also searched online. No answer found, perhaps i didnât search the correct words
So, here is my current code. The variable âDumpActiveâ is set true by a button.
The line println(âDump Abortedâ); is displayed if there is data transfer from the Arduino, It shouldnât. When data didnât start flowing, and the time is up, this line should be displayed, and the while loop exited.
Thank you.
if (DumpActive) {
myPort.write("RequestEEprom");
myPort.write('\n');
while (myPort.available() > 0) {
inData = myPort.readStringUntil('\n');
if (inData != null) {
inData = inData.trim();
if ("END".equals(inData)) {
SerialCheck = true;
EEpromReceived = true;
}
if (!SerialCheck) {
EepromData[SlotCount] = inData;
// println(inData);
}
inData = "";
if (SlotCount > 16383) SlotCount = 0;
SlotCount = SlotCount + 1;
}
if (TimerDump + 4000 < millis()) {
if(inData == null) {
DumpActive = false;
SerialCheck = true;
println("Dump Aborted");
}
}
if (SerialCheck) {
SlotCount = 0;
SerialCheck = false;
DumpActive = false;
AquireData();
}
}
}