AnsweredAssumed Answered

Can't create RX buffer using Libiio and ad_adc driver

Question asked by njp on Apr 1, 2015
Latest reply on Apr 2, 2015 by njp

I'm having issues creating a buffer using Libiio and the ad_adc driver (configured for AD7980).  The ad_adc is showing up as an IIO device with a buffer (enable and length) and the scan_elements. The function iio_context_find_device works fine, but when I call iio_device_create_buffer I get an error.

 

I have tracked the error to the function "iio_device_get_sample_size_mask()" in device.c of Libiio. I put the code snippet at the bottom of the post. My issue is:

  • dev->nb_channels = 1
    • This is what I want
  • *mask = 0
    • I'm not sure what the value is supposed to be, but with it being 0 it hits the continue and then size is returned as 0

 

I haven't yet tracked this down, but I'm assuming it's something missing in ad_adc.c. I haven't had this issue when using the ad9361.c driver.

 

Thanks!

 

 

 

 

ssize_t iio_device_get_sample_size_mask(const struct iio_device *dev,

        uint32_t *mask, size_t words)

{

    ssize_t size = 0;

    unsigned int i;

 

    if (words != (dev->nb_channels + 31) / 32) {

        return -EINVAL;

    }

 

    for (i = 0; i < dev->nb_channels; i++) {

        const struct iio_channel *chn = dev->channels[i];

        unsigned int length = chn->format.length / 8;

 

        if (chn->index < 0) {

            break;

        }

        if (!TEST_BIT(mask, chn->index)) {

            continue;

        }

 

        if (size % length) {

            size += 2 * length - (size % length);

        }

        else {

            size += length;

        }

    }

    return size;

}

Outcomes