void loop()
{
recvWithEndMarker();
if (newData == true) {
switch (receivedChars[0]) {
case '1':
DW1000Ranging.loop();
break;
}
}
}
The recvWithEndMarker(); receives the data from the serial monitor, if I write a 1 the value will be assigned to receivedChars[0].
But that is not my problem, my problem comes with DW1000Ranging.loop(); It enters the loop of another function and never exits, so "break" is not executed. (To break this loop I have to modify the library, but I don't know professional C++, so it's best to look for an alternative like the one I just thought of.)
I'm thinking of some solution like Arduino reset after X time, no matter it's in the loop. That is, first enter the loop, pass the time and then reset the Arduino. Any solution?
Note: I use ESP32 and it is reset with ESP.restart();
Please post your full sketch so that we can see your code snippet in context. For instance, which library are you using to create the W1000Ranging object and where did you get it from ?
You never set newData to false, so once you receive a serial input, the if statement will always be true, and the switch statement will be executed repeatedly for the same input.
You seem to have not yet understood how receive with endmarker works:
after first program start newData is false
only if the endmarker is received the flag variable newData is set to true
Now
You
the user has to do
two
things :
react on the data
set flag-variable newData to false again to enable processing the next data that is received
I have no idea what you want to say with that.
trying to be quick through beeing short on words turns out to be slow in fact.
problem-solving can be accelerated through taking time for a detailed description