Hi,
I am trying to capture the RX samples from PLUTO SDR and save them to a file on my PC.
I simply modified the "ad9361-iiostream.c" example to write the RX buffer contents into a file instead of swapping I and Q.
https://github.com/analogdevicesinc/libiio/blob/master/examples/ad9361-iiostream.c
However, it seemed that some IQ samples were always lost at every iteration of the while loop.
What should I do to avoid date drops and capture the RX stream continuously?
// Refill RX buffer
nbytes_rx = iio_buffer_refill(rxbuf);
if (nbytes_rx < 0) { printf("Error refilling buf %d\n",(int) nbytes_rx); shutdown(); }// READ: Get pointers to RX buf and read IQ from RX buf port 0
p_inc = iio_buffer_step(rxbuf);
p_end = iio_buffer_end(rxbuf);
/*
for (p_dat = (char *)iio_buffer_first(rxbuf, rx0_i); p_dat < p_end; p_dat += p_inc) {
// Example: swap I and Q
const int16_t i = ((int16_t*)p_dat)[0]; // Real (I)
const int16_t q = ((int16_t*)p_dat)[1]; // Imag (Q)
((int16_t*)p_dat)[0] = q;
((int16_t*)p_dat)[1] = i;
}
*/
p_dat = (char*)iio_buffer_first(rxbuf, rx0_i);
fwrite(p_dat, 1, p_end - p_dat, fdo);