AnsweredAssumed Answered

libiio iio_device_create_buffer

Question asked by cevans on Jul 1, 2016
Latest reply on Jul 4, 2016 by pcercuei

I'm using an AD9361/FMCOMMS5 configuration to transmit 4 channels of IQ data. I am calling iio_buffer_push_partial multiple times and seeing intermittently dropped data. I believe this stems from my confusion with some of the parameters and return values in libiio's API functions. Especially with regards to sample lengths.


By following the steps in About libiio [Analog Devices Wiki] , I have come up with the following procedure:



for (chan_idx=0; chan_idx<4; chan_idx++) {


    iio_channel_enable ( /*chn_idx_inphase*/ );


    iio_channel_enable ( /*chn_idx_quadrature*/ );






txbuf = iio_device_create_buffer(dev, SAMPLE_LEN, false);




while(burst_idx-- > 0) {


    memcpy(    iio_buffer_first(txbuf, /*chn_idx_0_inphase*/),




                      SAMPLE_LEN * 2 * sizeof(int16_t)




    nbytes_tx = iio_buffer_push_partial(txbuf, SAMPLE_LEN);



Firstly, am I memcpy'ing the correct amount of data to fill each of the buffers (four created in the kernel with iio_device_create_buffer())?


Secondly, when varying the SAMPLE_LEN parameter, I find the following results for nbytes_tx:




The waveform captured on an oscilloscope has the expected duration (based on a sample rate of 7MHz) ONLY with SAMPLE_LEN == 16384. With 32768, the signal is too short, and with less than 16384, there are intermittent "dropouts" of data between the calls to iio_buffer_push_partial(). Do I need to be calling iio_buffer_push_partial mutliple times between each memcpy?