AnsweredAssumed Answered

Unable to create Tx buffer using libiio API with AD9371

Question asked by Abhisheknaik on Apr 27, 2017
Latest reply on Apr 28, 2017 by mhennerich

Hello everyone,

                  I am writing linux application just like ad9361-iiostream.c with help libiio API..  I have created Rx buffer and trying to create Tx buffer. But iio_create_buffer function is giving me error as invalid arguments.. I have enabled all Tx channel before creating buffer..

ad9371-iiostream.c

int main ()
{
// Streaming devices
          struct iio_device *tx;
    struct iio_device *rx;
const char *id ;
ctx = iio_create_default_context( ) ;

rx = iio_context_find_device( ctx, "axi-ad9371-rx-hpc" ) ;
tx = iio_context_find_device( ctx, "axi-ad9371-tx-hpc" ) ;
int i = 0 ;

 

rx1_i = iio_device_find_channel(rx, "voltage1_i", 0);
rx1_q = iio_device_find_channel(rx, "voltage1_q", 0);

tx0_i = iio_device_find_channel(tx, "altvoltage0", 1);
tx0_q = iio_device_find_channel(tx, "voltage1", 1);
tx1_i = iio_device_find_channel(tx, "altvoltage5", 1);
tx1_q = iio_device_find_channel(tx, "altvoltage4", 1);
tx2_i = iio_device_find_channel(tx, "altvoltage6", 1);
tx2_q = iio_device_find_channel(tx, "altvoltage3", 1);
tx3_i = iio_device_find_channel(tx, "voltage2", 1);
tx3_q = iio_device_find_channel(tx, "voltage3", 1);
tx4_i = iio_device_find_channel(tx, "altvoltage7", 1);
tx4_q = iio_device_find_channel(tx, "altvoltage2", 1);
tx5_i = iio_device_find_channel(tx, "altvoltage1", 1);
tx5_q = iio_device_find_channel(tx, "voltage0", 1);
if (!rx1_i || !rx1_q || !tx0_i || !tx0_q)
printf ( "ERROR\n" ) ;

iio_channel_enable(rx1_i);
iio_channel_enable(rx1_q);

iio_channel_enable(tx0_i);
iio_channel_enable(tx0_q);
iio_channel_enable(tx1_i);
iio_channel_enable(tx1_q);
iio_channel_enable(tx2_i);
iio_channel_enable(tx2_q);
iio_channel_enable(tx3_i);
iio_channel_enable(tx3_q);
iio_channel_enable(tx4_i);
iio_channel_enable(tx4_q);
iio_channel_enable(tx5_i);
iio_channel_enable(tx5_q);

 

rxbuf = iio_device_create_buffer(rx, 16, false);
if (!rxbuf) {
perror("Could not create RX buffer");
shutdown();
}
txbuf = iio_device_create_buffer(tx, 16, true);
if (!txbuf) {
perror("Could not create TX buffer");
shutdown();
}
}

 

Outcomes