"getComplexData" needs a time-out safety
Opened this issue · 1 comments
Dear author:
Thank you for you work. This library works very reliably for us. We did have to make a small change though to the function "getComplexData". The while-loop in there may hang and the function may run indefinitely.
We changed the code around the while loop waiting for the STATUS_DATA_VALID as follows:
bool AD5933::getComplexData(int *real, int *imag) {
// ako, 2021-02-09: this while loop may hang! --> return if max requests exceeded
// Wait for a measurement to be available
int maxLoops = 1000;
while ((readStatusRegister() & STATUS_DATA_VALID) != STATUS_DATA_VALID) {
if(maxLoops > 0){
maxLoops--;
delay(1);
}
else
{
// timeout
*real = -1;
*imag = -1;
return false;
}
}
...
Would you consider incorporating this into the official release?
Best regards,
Adrian
I am going through the same issue.
I am stuck at the while loop..
Everytime I re-start esp32, it' gets stuck at the same point..
Can you give me an advice?