AnsweredAssumed Answered

Could not create TX buffer: Device or resource busy

Question asked by gdo on Nov 23, 2016
Latest reply on Jan 4, 2017 by gdo

Hello,

 

We want to generate a tx buffer to send a CW signal at -2 dBm and about 400 MHz.

 

We previously succeeded via iio-oscilloscope using a DAC Buffer with the 10.txt file example.

 

We try to reproduce the same signal using libiio functions but we have the following error at the TX buffer creation :

Could not create TX buffer: Device or resource busy

Here is the part or the source code related to the buffer creation :

rxbuf = iio_device_create_buffer(rx, 4000000, false);
if (!rxbuf) {
perror("Could not create RX buffer");
shutdown();
}

txbuf = iio_device_create_buffer(tx, 94, true);
if (!txbuf) {
perror("Could not create TX buffer");
shutdown();
}

 

// Starting IO streaming (press CTRL+C to cancel
while (cnt < 1)//!stop)
{
ssize_t nbytes_rx, total_rx, nbytes_tx;
void *p_start, *p_dat, *p_end;
ptrdiff_t p_inc;

// WRITE: Get pointers to TX buf and write IQ to TX buf port 0
p_inc = iio_buffer_step(txbuf);
p_end = iio_buffer_end(txbuf);
for (p_dat = iio_buffer_first(txbuf, tx0_i); p_dat < p_end; p_dat += p_inc) {
// Example: fill with zeros
((int16_t*)p_dat)[0] = 1; // Real (I)
((int16_t*)p_dat)[1] = 0; // Imag (Q)
}

// Schedule TX buffer
nbytes_tx = iio_buffer_push(txbuf);
if (nbytes_tx < 0) { printf("Error pushing buf %d\n", (int) nbytes_tx); shutdown(); }

total_rx = 0;

for (int i = 0; i < 2; i++) {
// Refill RX buffer
do {
nbytes_rx = iio_buffer_refill(rxbuf);
} while (nbytes_rx == -EBUSY);

if (nbytes_rx < 0) {
printf("Error refilling buf %d\n",(int) nbytes_rx);
shutdown();
}
p_inc = iio_buffer_step(rxbuf);
for (p_dat = iio_buffer_first(rxbuf, rx0_i); p_dat < p_end; p_dat += p_inc) { //p_dat = iio_buffer_first(rxbuf, rx0_i)
data_buf[SAMPLE_I][cnt] = ((int16_t*)p_dat)[0]; // Real (I)
data_buf[SAMPLE_Q][cnt++] = ((int16_t*)p_dat)[1]; // Imag (Q)
}
total_rx += nbytes_rx;
}
}

 

Do you see something wrong ?

 

Thx,

gdo

Outcomes