endail/pico-scale

tests/main.c freezes inside scale_zero

ali1234 opened this issue · 3 comments

Checking the source, the reason is here:

while(hx711_get_value_timeout(sc->_hx, timeout, &val)) {

This while loop can never be exited because timeout is always 10 seconds on each loop. The absolute time at which the timeout ends is always 10 seconds from the point of calling the function: https://github.com/endail/hx711-pico-c/blob/main/src/hx711.c#L301 - ie inside the call.

So this while loop will keep reading until the realloc fails, at which point the pico seems to crash.

In fact if you watch the serial long enough it eventually does this, which confirms it:


*** PANIC ***

Out of memory

Note that calibration.c works okay, because it uses a sample count rather than a timeout.

Thanks! Will definitely fix this.

endail commented

Fixed in b979211