Open both I and Q channels on plutosdr and change the inputthread accordingly

This commit is contained in:
Felix Schneider 2020-08-19 09:05:09 +02:00
parent afd76e274e
commit 7848b01987
3 changed files with 12 additions and 7 deletions

View File

@ -41,6 +41,7 @@ DevicePlutoSDRBox::DevicePlutoSDRBox(const std::string& uri) :
m_devRx(0),
m_devTx(0),
m_chnRx0(0),
m_chnRxQ(0),
m_chnTx0i(0),
m_chnTx0q(0),
m_rxBuf(0),
@ -254,12 +255,14 @@ bool DevicePlutoSDRBox::openRx()
{
if (!m_valid) { return false; }
if (!m_chnRx0) {
if (!m_chnRx0 || !m_chnRxQ) {
m_chnRx0 = iio_device_find_channel(m_devRx, "voltage0", false);
m_chnRxQ = iio_device_find_channel(m_devRx, "voltage1", false);
}
if (m_chnRx0) {
if (m_chnRx0 && m_chnRxQ) {
iio_channel_enable(m_chnRx0);
iio_channel_enable(m_chnRxQ);
const struct iio_data_format *df = iio_channel_get_data_format(m_chnRx0);
qDebug("DevicePlutoSDRBox::openRx: length: %u bits: %u shift: %u signed: %s be: %s with_scale: %s scale: %lf repeat: %u",
df->length,

View File

@ -120,6 +120,7 @@ private:
struct iio_device *m_devRx;
struct iio_device *m_devTx;
struct iio_channel *m_chnRx0;
struct iio_channel* m_chnRxQ;
struct iio_channel *m_chnTx0i;
struct iio_channel *m_chnTx0q;
struct iio_buffer *m_rxBuf;

View File

@ -94,7 +94,7 @@ void PlutoSDRInputThread::run()
// Refill RX buffer
nbytes_rx = m_plutoBox->rxBufferRefill();
if (nbytes_rx != m_blockSizeSamples*2)
if (nbytes_rx != m_blockSizeSamples*4)
{
qWarning("PlutoSDRInputThread::run: error refilling buf (1) %d / %d",(int) nbytes_rx, (int) m_blockSizeSamples*2);
usleep(200000);
@ -111,13 +111,14 @@ void PlutoSDRInputThread::run()
for (p_dat = m_plutoBox->rxBufferFirst(); p_dat < p_end; p_dat += p_inc)
{
m_buf[ihs] = *((int16_t *) p_dat);
m_buf[ihs++] = *((int16_t *) p_dat);
m_buf[ihs++] = *(((int16_t*)p_dat)+1);
// iio_channel_convert(m_plutoBox->getRxChannel0(), (void *) &m_bufConv[ihs], (const void *) &m_buf[ihs]);
ihs++;
//ihs++;
}
// Refill RX buffer again - we still need twice more samples to complete since they come as I followed by Q
nbytes_rx = m_plutoBox->rxBufferRefill();
/*nbytes_rx = m_plutoBox->rxBufferRefill();
if (nbytes_rx != m_blockSizeSamples*2)
{
@ -139,7 +140,7 @@ void PlutoSDRInputThread::run()
// iio_channel_convert(m_plutoBox->getRxChannel0(), (void *) &m_bufConv[ihs], (const void *) &m_buf[ihs]);
ihs++;
}
*/
if (m_iqOrder) {
convertIQ(m_buf, 2*m_blockSizeSamples); // size given in number of int16_t (I and Q interleaved)
} else {