My assumption with the READBUF or when a refill call from the host using libiio is if the circular buffer used to store samples with a trigger handler is empty or less than what was configured as buffer size in the host, it should just get an -EAGAIN. However, it crashed the tinyiio and looking at the code here,
|
ret = do_read_buff(desc, conn); |
the -EAGAIN propagated to the iio_app instead of passing it to the conn->res.
Catching the -EAGAIN and preventing it from propagating to the calling functions solved the issue of crashing. But, libiio now returns a timeout when refill was called when circular buffer in tinyiio was empty, which is fine since we can just call the refill function with a backoff timer from the application. Is there a way to safely refill when tinyiio buffer is empty?
To replicate:
- You need an iio driver with a trigger handler (without .submit/read_rev ops) that fills the circullar buffer with samples. Use a large delay for example 5000ms per trigger. Set the number of samples pushed to 2 per trigger.
- You can create a very simple pyadi-iio (or maybe use iio cli toos) to get the buffer contents every 1 second. Set the buffer size to 2.
- If the interrupt started ahead of your .rx() call in pyadi-iio, you will get data until the buffer is empty and it will crash after a few timeouts and READ INTEGER and READLINE errors.
My assumption with the READBUF or when a refill call from the host using libiio is if the circular buffer used to store samples with a trigger handler is empty or less than what was configured as buffer size in the host, it should just get an -EAGAIN. However, it crashed the tinyiio and looking at the code here,
no-OS/iio/iiod.c
Line 832 in 05c0d20
Catching the -EAGAIN and preventing it from propagating to the calling functions solved the issue of crashing. But, libiio now returns a timeout when refill was called when circular buffer in tinyiio was empty, which is fine since we can just call the refill function with a backoff timer from the application. Is there a way to safely refill when tinyiio buffer is empty?
To replicate: