bladeRF
bladeRF copied to clipboard
Reading IQ data samples using libbladeRF library
I am working with a bladeRF 2.0 micro xA4, details below:
bladeRF> info
Board: Nuand bladeRF 2.0 (bladerf2)
Serial #: 55a30137bc6c4713824c46b2e3baf1e4
VCTCXO DAC calibration: 0x1f0b
FPGA size: 49 KLE
FPGA loaded: yes
Flash size: 32 Mbit
USB bus: 6
USB address: 4
USB speed: SuperSpeed
Backend: libusb
Instance: 0
bladeRF> version
bladeRF-cli version: 1.8.0-git-c8320f71-ppafocal
libbladeRF version: 2.2.1-git-c8320f71-ppafocal
Firmware version: 2.3.1
FPGA version: 0.11.0 (configured by USB host)
I am also using the tutorial code here : https://nuand.com/bladeRF-doc/libbladeRF/v2.2.1/index.html to access the samples using libbladeRF. Most of the code is similar, with two differences:
a) I need to get the signal simultaneously for both the channels. Hence I using configure_channel to configure both the channels and then in the bladerf_sync_config, I use BLADERF_RX_X2.
b) To get the IQ data of a sample for both the channels, I run the following part of the code:
status = bladerf_enable_module(dev, BLADERF_RX, true);
/* Receive samples. This call leads to busy wait*/
status = bladerf_sync_rx(dev, rx_samples, samples_len, NULL, 5000);
/* Disable RX, shutting down our underlying RX stream */
status = bladerf_enable_module(dev, BLADERF_RX, false);
//Read data from the rx_samples buffer.
std::vector<std::vector<int16_t>> csi_data;
std::cout << sizeof(int16_t) << std::endl;
for (int j=0; j<samples_len/num_channels;j++)
{
std::vector<int16_t> temp (4,0);
int16_t inBytes16, out;
memcpy(&inBytes16, init_pointer, 1*sizeof(int16_t)); // I_1
temp[0] = inBytes16;
init_pointer+=1;
memcpy(&inBytes16, init_pointer, 1*sizeof(int16_t)); // Q_1
temp[1] = inBytes16;
init_pointer+=1;
memcpy(&inBytes16, init_pointer, 1*sizeof(int16_t)); // I_2
temp[2] = inBytes16;
init_pointer+=1;
memcpy(&inBytes16, init_pointer, 1*sizeof(int16_t)); // Q_2
temp[3] = inBytes16;
init_pointer+=1;
csi_data.push_back(temp);
// exit(1);
}
Basically, temp need to store [I0[j], Q0[j], I1[j], Q1[j]] for any jth sample. However I am unsure whether this is the correct way to read data from the rx_samples buffer. As per the doc here, buffer stores Q value in the first 2 bytes and then the I value. Does this refer to the internal buffer or the user buffer? Is there a better way to read data from the buffer? I have also attached the entire code file that I am using, for reference.
Thanks! blade_rf_test.txt