AnsweredAssumed Answered

Ringbuffer with libiio

Question asked by lenny25 on May 30, 2017
Latest reply on Jun 1, 2017 by ttyler777

ANALOG DEVICES recommends in his wiki the libiio library:
The API is described here:


With the library it would be easy to recognize all devices and their channels in a system automatically.
Then you can determine how many samples of all enabled channels of one device you want to cyclically load into a buffer by using "iio_device_create_buffer()".
These samples can then be read with " iio_buffer_first(), iio_buffer_step() and iio_buffer_end()"


The duration between two read cycles should be 100 ms. At this cycle length and maximum possible frequency of a device module of 4.8 kHz, theoretically 480 samples would be possible.
Since IIO uses a ringbuffer and blocks the read process until the data is there, a simple loop should be sufficient, which copies continuesly all data into the userspace.

Is this correct?

Do you have to use the function "iio_buffer_refill()" bevore calling "iio_buffer_first()" the first time?

Do you have to use "iio_buffer_refill()" every time bevore calling "iio_buffer_first()" inside the loop while setting iio_device_create_buffer - parameter cyclic to true?

Thanks in advance,