Skip to content

"getComplexData" needs a time-out safety #15

Description

@eawag-squid

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions