AnsweredAssumed Answered

AD9361 / libiio creation of cyclic Tx buffers

Question asked by HStoner on Aug 12, 2015
Latest reply on Aug 12, 2015 by larsc

On the AD9361, using the cf-ad9361-dds-core-lpc device, I would like to use libiio to create a buffer, fill it with a waveform, and push it in cyclic mode to the device.

Then, while this buffer is 'playing', I'd like to fill another buffer with another waveform... When done 'playing' the first buffer, I'd like to stop it from playing, and push the second buffer in cyclic mode to the device.


Then I'd like to continue creating new buffers to be played 'next', while playing the 'current' buffer.


I thought I could do this with the following pseudocode:


cyclic = true;

currBuf = iio_device_create_buffer(dev, nSamps, cyclic);



while (1) {

  iio_buffer_push(currBuf);     // push current buffer to device

  nextBuf = iio_device_create_buffer(dev, nSamps, cyclic);





  currBuf = nextBuf;




But it won't let me create the second buffer.... I get an errno = 16 (EBUSY) error returned from the line :

  nextBuf = iio_device_create_buffer(dev, nSamps, cyclic);

Is there any way to ping-pong back and forth, creating and filling a second buffer while the first is playing, then stopping the first, playing the second buffer, and filling the first (or a new buffer)?

Or do I have to destory the first buffer before I can create a second?

I have tried looking at the libiio documentation libiio: Main Page, but it doesn't seem very clear on this point.