From 4bca8efd6ada37f94c277e67414c819ce9ce38de Mon Sep 17 00:00:00 2001 From: f4exb Date: Sat, 18 Apr 2020 18:32:56 +0200 Subject: [PATCH] LimeSDR MIMO: unsuccessful attempt to fix --- .../samplemimo/limesdrmimo/limesdrmimo.cpp | 308 ++++++++++-------- .../samplemimo/limesdrmimo/limesdrmimogui.cpp | 84 +---- .../samplemimo/limesdrmimo/limesdrmimogui.ui | 175 +++++----- .../limesdrmimo/limesdrmimosettings.cpp | 84 ++--- .../limesdrmimo/limesdrmimosettings.h | 12 +- .../limesdrmimo/limesdrmithread.cpp | 20 +- .../samplemimo/limesdrmimo/limesdrmithread.h | 1 + .../limesdrmimo/limesdrmothread.cpp | 3 + 8 files changed, 323 insertions(+), 364 deletions(-) diff --git a/plugins/samplemimo/limesdrmimo/limesdrmimo.cpp b/plugins/samplemimo/limesdrmimo/limesdrmimo.cpp index 9b70c057e..846e91d35 100644 --- a/plugins/samplemimo/limesdrmimo/limesdrmimo.cpp +++ b/plugins/samplemimo/limesdrmimo/limesdrmimo.cpp @@ -569,7 +569,7 @@ bool LimeSDRMIMO::applySettings(const LimeSDRMIMOSettings& settings, bool force) bool forceRxNCOFrequency = false; bool forceTxNCOFrequency = false; - qDebug() << "LimeSDRMIMO::applySettings: " + qDebug() << "LimeSDRMIMO::applySettings: common:" << " m_devSampleRate: " << settings.m_devSampleRate << " m_LOppmTenths: " << settings.m_LOppmTenths << " m_gpioDir: " << settings.m_gpioDir @@ -581,7 +581,8 @@ bool LimeSDRMIMO::applySettings(const LimeSDRMIMOSettings& settings, bool force) << " m_reverseAPIAddress: " << settings.m_reverseAPIAddress << " m_reverseAPIPort: " << settings.m_reverseAPIPort << " m_reverseAPIDeviceIndex: " << settings.m_reverseAPIDeviceIndex - // Rx general + << " force: " << force; + qDebug() << "LimeSDRMIMO::applySettings: Rx general:" << " m_rxCenterFrequency: " << settings.m_rxCenterFrequency << " m_log2HardDecim: " << settings.m_log2HardDecim << " m_log2SoftDecim: " << settings.m_log2SoftDecim @@ -589,54 +590,48 @@ bool LimeSDRMIMO::applySettings(const LimeSDRMIMOSettings& settings, bool force) << " m_iqCorrection: " << settings.m_iqCorrection << " m_rxTransverterMode: " << settings.m_rxTransverterMode << " m_rxTransverterDeltaFrequency: " << settings.m_rxTransverterDeltaFrequency - // Rx0 + << " m_ncoEnableRx: " << settings.m_ncoEnableRx + << " m_ncoFrequencyRx: " << settings.m_ncoFrequencyRx; + qDebug() << "LimeSDRMIMO::applySettings: Rx0:" << " m_lpfBWRx0: " << settings.m_lpfBWRx0 << " m_lpfFIREnableRx0: " << settings.m_lpfFIREnableRx0 << " m_lpfFIRBWRx0: " << settings.m_lpfFIRBWRx0 << " m_gainRx0: " << settings.m_gainRx0 - << " m_ncoEnableRx0: " << settings.m_ncoEnableRx0 - << " m_ncoFrequencyRx0: " << settings.m_ncoFrequencyRx0 << " m_antennaPathRx0: " << settings.m_antennaPathRx0 << " m_gainModeRx0: " << settings.m_gainModeRx0 << " m_lnaGainRx0: " << settings.m_lnaGainRx0 << " m_tiaGainRx0: " << settings.m_tiaGainRx0 - << " m_pgaGainRx0: " << settings.m_pgaGainRx0 - // Rx1 + << " m_pgaGainRx0: " << settings.m_pgaGainRx0; + qDebug() << "LimeSDRMIMO::applySettings: Rx1:" << " m_lpfBWRx1: " << settings.m_lpfBWRx1 << " m_lpfFIREnableRx1: " << settings.m_lpfFIREnableRx1 << " m_lpfFIRBWRx1: " << settings.m_lpfFIRBWRx1 << " m_gainRx1: " << settings.m_gainRx1 - << " m_ncoEnableRx1: " << settings.m_ncoEnableRx1 - << " m_ncoFrequencyRx1: " << settings.m_ncoFrequencyRx1 << " m_antennaPathRx1: " << settings.m_antennaPathRx1 << " m_gainModeRx1: " << settings.m_gainModeRx1 << " m_lnaGainRx1: " << settings.m_lnaGainRx1 << " m_tiaGainRx1: " << settings.m_tiaGainRx1 - << " m_pgaGainRx1: " << settings.m_pgaGainRx1 - // Tx general + << " m_pgaGainRx1: " << settings.m_pgaGainRx1; + qDebug() << "LimeSDRMIMO::applySettings: Tx general:" << " m_txCenterFrequency: " << settings.m_txCenterFrequency << " m_log2HardInterp: " << settings.m_log2HardInterp << " m_log2SoftInterp: " << settings.m_log2SoftInterp << " m_txTransverterMode: " << settings.m_txTransverterMode << " m_txTransverterDeltaFrequency: " << settings.m_txTransverterDeltaFrequency - // Tx0 + << " m_ncoEnableTx: " << settings.m_ncoEnableTx + << " m_ncoFrequencyTx: " << settings.m_ncoFrequencyTx; + qDebug() << "LimeSDRMIMO::applySettings: Tx0:" << " m_lpfBWTx0: " << settings.m_lpfBWTx0 << " m_lpfFIREnableTx0: " << settings.m_lpfFIREnableTx0 << " m_lpfFIRBWTx0: " << settings.m_lpfFIRBWTx0 << " m_gainTx0: " << settings.m_gainTx0 - << " m_ncoEnableTx0: " << settings.m_ncoEnableTx0 - << " m_ncoFrequencyTx0: " << settings.m_ncoFrequencyTx0 - << " m_antennaPathTx0: " << settings.m_antennaPathTx0 - // Tx1 + << " m_antennaPathTx0: " << settings.m_antennaPathTx0; + qDebug() << "LimeSDRMIMO::applySettings: Tx1:" << " m_lpfBWTx1: " << settings.m_lpfBWTx1 << " m_lpfFIREnableTx1: " << settings.m_lpfFIREnableTx1 << " m_lpfFIRBWTx1: " << settings.m_lpfFIRBWTx1 << " m_gainTx1: " << settings.m_gainTx1 - << " m_ncoEnableTx1: " << settings.m_ncoEnableTx1 - << " m_ncoFrequencyTx1: " << settings.m_ncoFrequencyTx1 - << " m_antennaPathTx1: " << settings.m_antennaPathTx1 - // force - << " force: " << force; + << " m_antennaPathTx1: " << settings.m_antennaPathTx1; qint64 rxDeviceCenterFrequency = settings.m_rxCenterFrequency; rxDeviceCenterFrequency -= settings.m_rxTransverterMode ? settings.m_rxTransverterDeltaFrequency : 0; @@ -646,6 +641,8 @@ bool LimeSDRMIMO::applySettings(const LimeSDRMIMOSettings& settings, bool force) txDeviceCenterFrequency -= settings.m_txTransverterMode ? settings.m_txTransverterDeltaFrequency : 0; txDeviceCenterFrequency = txDeviceCenterFrequency < 0 ? 0 : txDeviceCenterFrequency; + // Common + if (LMS_GetClockFreq(m_deviceParams->getDevice(), LMS_CLOCK_CGEN, &clockGenFreq) != 0) { qCritical("LimeSDRMIMO::applySettings: could not get clock gen frequency"); } else { @@ -655,6 +652,24 @@ bool LimeSDRMIMO::applySettings(const LimeSDRMIMOSettings& settings, bool force) if ((m_settings.m_devSampleRate != settings.m_devSampleRate) || force) { reverseAPIKeys.append("devSampleRate"); } + if ((m_settings.m_log2HardDecim != settings.m_log2HardDecim) || force) { + reverseAPIKeys.append("log2HardDecim"); + } + if ((m_settings.m_rxCenterFrequency != settings.m_rxCenterFrequency) || force) { + reverseAPIKeys.append("rxCenterFrequency"); + } + if ((m_settings.m_rxTransverterMode != settings.m_rxTransverterMode) || force) { + reverseAPIKeys.append("rxTransverterMode"); + } + if ((m_settings.m_rxTransverterDeltaFrequency != settings.m_rxTransverterDeltaFrequency) || force) { + reverseAPIKeys.append("rxTransverterDeltaFrequency"); + } + if ((m_settings.m_ncoFrequencyRx != settings.m_ncoFrequencyRx) || force) { + reverseAPIKeys.append("ncoFrequencyRx"); + } + if ((m_settings.m_ncoEnableRx != settings.m_ncoEnableRx) || force) { + reverseAPIKeys.append("ncoEnableRx"); + } if ((m_settings.m_dcBlock != settings.m_dcBlock) || force) { reverseAPIKeys.append("dcBlock"); } @@ -671,6 +686,67 @@ bool LimeSDRMIMO::applySettings(const LimeSDRMIMOSettings& settings, bool force) m_deviceAPI->configureCorrections(settings.m_dcBlock, settings.m_iqCorrection, 1); } + if ((m_settings.m_devSampleRate != settings.m_devSampleRate) + || (m_settings.m_log2HardDecim != settings.m_log2HardDecim) || force) + { + forwardChangeRxDSP = true; + + if (m_deviceParams->getDevice()) + { + if (LMS_SetSampleRateDir( + m_deviceParams->getDevice(), + LMS_CH_RX, + settings.m_devSampleRate, + 1<m_log2OvSRRx = settings.m_log2HardDecim; + m_deviceParams->m_sampleRate = settings.m_devSampleRate; + forceRxNCOFrequency = true; + qDebug("LimeSDRMIMO::applySettings: set sample rate set to %d with Rx oversampling of %d", + settings.m_devSampleRate, + 1<getDevice()) + { + if (LMS_SetClockFreq(m_deviceParams->getDevice(), LMS_CLOCK_SXR, rxDeviceCenterFrequency) < 0) + { + qCritical("LimeSDRMIMO::applySettings: could not set Rx frequency to %lld", rxDeviceCenterFrequency); + } + else + { + doCalibrationRx0 = true; + doCalibrationRx1 = true; + qDebug("LimeSDRMIMO::applySettings: Rx frequency set to %lld", rxDeviceCenterFrequency); + } + } + } + + if ((m_settings.m_ncoFrequencyRx != settings.m_ncoFrequencyRx) || + (m_settings.m_ncoEnableRx != settings.m_ncoEnableRx) || force) + { + forwardChangeRxDSP = true; + applyRxNCOFrequency(0, settings.m_ncoEnableRx, settings.m_ncoFrequencyRx); + applyRxNCOFrequency(1, settings.m_ncoEnableRx, settings.m_ncoFrequencyRx); + } + + // Rx0/1 + if ((m_settings.m_gainModeRx0 != settings.m_gainModeRx0) || force) { reverseAPIKeys.append("gainModeRx0"); @@ -747,36 +823,6 @@ bool LimeSDRMIMO::applySettings(const LimeSDRMIMOSettings& settings, bool force) applyRxLNAGain(1, doCalibrationRx1, settings.m_pgaGainRx1); } - if ((m_settings.m_devSampleRate != settings.m_devSampleRate) - || (m_settings.m_log2HardDecim != settings.m_log2HardDecim) || force) - { - reverseAPIKeys.append("log2HardDecim"); - - if (m_deviceParams->getDevice()) - { - if (LMS_SetSampleRateDir( - m_deviceParams->getDevice(), - LMS_CH_RX, - settings.m_devSampleRate, - 1<m_log2OvSRRx = settings.m_log2HardDecim; - m_deviceParams->m_sampleRate = settings.m_devSampleRate; - //doCalibration = true; - forceRxNCOFrequency = true; - qDebug("LimeSDRMIMO::applySettings: set sample rate set to %d with Rx oversampling of %d", - settings.m_devSampleRate, - 1<getDevice()) - { - if (LMS_SetClockFreq(m_deviceParams->getDevice(), LMS_CLOCK_SXR, rxDeviceCenterFrequency) < 0) - { - qCritical("LimeSDRMIMO::applySettings: could not set Rx frequency to %lld", rxDeviceCenterFrequency); - } - else - { - doCalibrationRx0 = true; - doCalibrationRx1 = true; - qDebug("LimeSDRMIMO::applySettings: Rx frequency set to %lld", rxDeviceCenterFrequency); - } - } - } - // Tx + if ((m_settings.m_log2HardInterp != settings.m_log2HardInterp) || force) { + reverseAPIKeys.append("log2HardInterp"); + } + if ((m_settings.m_txCenterFrequency != settings.m_txCenterFrequency) || force) { + reverseAPIKeys.append("txCenterFrequency"); + } + if ((m_settings.m_txTransverterMode != settings.m_txTransverterMode) || force) { + reverseAPIKeys.append("txTransverterMode"); + } + if ((m_settings.m_txTransverterDeltaFrequency != settings.m_txTransverterDeltaFrequency) || force) { + reverseAPIKeys.append("txTransverterDeltaFrequency"); + } + if ((m_settings.m_ncoFrequencyTx != settings.m_ncoFrequencyTx) || force) { + reverseAPIKeys.append("ncoFrequencyTx"); + } + if ((m_settings.m_ncoEnableTx != settings.m_ncoEnableTx) || force) { + reverseAPIKeys.append("ncoEnableTx"); + } + if ((m_settings.m_gainTx0 != settings.m_gainTx0) || force) { reverseAPIKeys.append("gainTx0"); @@ -885,7 +910,7 @@ bool LimeSDRMIMO::applySettings(const LimeSDRMIMOSettings& settings, bool force) if ((m_settings.m_devSampleRate != settings.m_devSampleRate) || (m_settings.m_log2HardInterp != settings.m_log2HardInterp) || force) { - reverseAPIKeys.append("log2HardInterp"); + forwardChangeTxDSP = true; if (m_deviceParams->getDevice()) { @@ -928,6 +953,38 @@ bool LimeSDRMIMO::applySettings(const LimeSDRMIMOSettings& settings, bool force) qDebug("LimeSDRMIMO::applySettings: resize MO FIFO: rate %u", fifoRate); } + if ((m_settings.m_txCenterFrequency != settings.m_txCenterFrequency) + || (m_settings.m_txTransverterMode != settings.m_txTransverterMode) + || (m_settings.m_txTransverterDeltaFrequency != settings.m_txTransverterDeltaFrequency) + || force) + { + forwardChangeTxDSP = true; + + if (m_deviceParams->getDevice()) + { + if (LMS_SetClockFreq(m_deviceParams->getDevice(), LMS_CLOCK_SXT, txDeviceCenterFrequency) < 0) + { + qCritical("LimeSDRMIMO::applySettings: could not set Tx frequency to %lld", txDeviceCenterFrequency); + } + else + { + doCalibrationTx0 = true; + doCalibrationTx1 = true; + qDebug("LimeSDRMIMO::applySettings: Tx frequency set to %lld", txDeviceCenterFrequency); + } + } + } + + if ((m_settings.m_ncoFrequencyTx != settings.m_ncoFrequencyTx) || + (m_settings.m_ncoEnableTx != settings.m_ncoEnableTx) || force || forceTxNCOFrequency) + { + forwardChangeTxDSP = true; + applyTxNCOFrequency(0, settings.m_ncoEnableTx, settings.m_ncoFrequencyTx); + applyTxNCOFrequency(1, settings.m_ncoEnableTx, settings.m_ncoFrequencyTx); + } + + // Tx 0/1 + if ((m_settings.m_lpfBWTx0 != settings.m_lpfBWTx0) || force) { reverseAPIKeys.append("lpfBWTx0"); @@ -956,22 +1013,6 @@ bool LimeSDRMIMO::applySettings(const LimeSDRMIMOSettings& settings, bool force) applyTxLPFIRBW(1, settings.m_lpfFIREnableTx1, settings.m_lpfFIRBWTx1); } - if ((m_settings.m_ncoFrequencyTx0 != settings.m_ncoFrequencyTx0) || - (m_settings.m_ncoEnableTx0 != settings.m_ncoEnableTx0) || force || forceTxNCOFrequency) - { - reverseAPIKeys.append("ncoFrequencyTx0"); - reverseAPIKeys.append("ncoEnableTx0"); - applyTxNCOFrequency(0, settings.m_ncoEnableTx0, settings.m_ncoFrequencyTx0); - } - - if ((m_settings.m_ncoFrequencyTx1 != settings.m_ncoFrequencyTx1) || - (m_settings.m_ncoEnableTx1 != settings.m_ncoEnableTx1) || force || forceTxNCOFrequency) - { - reverseAPIKeys.append("ncoFrequencyTx1"); - reverseAPIKeys.append("ncoEnableTx1"); - applyTxNCOFrequency(1, settings.m_ncoEnableTx1, settings.m_ncoFrequencyTx1); - } - if ((m_settings.m_log2SoftInterp != settings.m_log2SoftInterp) || force) { reverseAPIKeys.append("log2SoftInterp"); @@ -995,32 +1036,7 @@ bool LimeSDRMIMO::applySettings(const LimeSDRMIMOSettings& settings, bool force) applyTxAntennaPath(1, doCalibrationTx1, settings.m_antennaPathTx1); } - if ((m_settings.m_txCenterFrequency != settings.m_txCenterFrequency) - || (m_settings.m_txTransverterMode != settings.m_txTransverterMode) - || (m_settings.m_txTransverterDeltaFrequency != settings.m_txTransverterDeltaFrequency) - || force) - { - reverseAPIKeys.append("txCenterFrequency"); - reverseAPIKeys.append("txTransverterMode"); - reverseAPIKeys.append("txTransverterDeltaFrequency"); - forwardChangeTxDSP = true; - - if (m_deviceParams->getDevice()) - { - if (LMS_SetClockFreq(m_deviceParams->getDevice(), LMS_CLOCK_SXT, txDeviceCenterFrequency) < 0) - { - qCritical("LimeSDRMIMO::applySettings: could not set Tx frequency to %lld", txDeviceCenterFrequency); - } - else - { - doCalibrationTx0 = true; - doCalibrationTx1 = true; - qDebug("LimeSDRMIMO::applySettings: Tx frequency set to %lld", txDeviceCenterFrequency); - } - } - } - - // common + // Post common if ((m_settings.m_extClock != settings.m_extClock) || (settings.m_extClock && (m_settings.m_extClockFreq != settings.m_extClockFreq)) || force) @@ -1152,6 +1168,30 @@ bool LimeSDRMIMO::applySettings(const LimeSDRMIMOSettings& settings, bool force) m_sinkThread->startWork(); } } + + // forward changes + + if (forwardChangeRxDSP) + { + int sampleRate = settings.m_devSampleRate/(1<getDeviceEngineInputMessageQueue()->push(notif0); + DSPMIMOSignalNotification *notif1 = new DSPMIMOSignalNotification(sampleRate, settings.m_rxCenterFrequency + ncoShift, true, 1); + m_deviceAPI->getDeviceEngineInputMessageQueue()->push(notif1); + } + + if (forwardChangeTxDSP) + { + int sampleRate = settings.m_devSampleRate/(1<getDeviceEngineInputMessageQueue()->push(notif0); + DSPMIMOSignalNotification *notif1 = new DSPMIMOSignalNotification(sampleRate, settings.m_txCenterFrequency + ncoShift, false, 1); + m_deviceAPI->getDeviceEngineInputMessageQueue()->push(notif1); + } + + return true; } void LimeSDRMIMO::applyRxGainMode( diff --git a/plugins/samplemimo/limesdrmimo/limesdrmimogui.cpp b/plugins/samplemimo/limesdrmimo/limesdrmimogui.cpp index 030c18516..feb73d88a 100644 --- a/plugins/samplemimo/limesdrmimo/limesdrmimogui.cpp +++ b/plugins/samplemimo/limesdrmimo/limesdrmimogui.cpp @@ -445,12 +445,8 @@ void LimeSDRMIMOGUI::setRxCenterFrequencyDisplay() int64_t centerFrequency = m_settings.m_rxCenterFrequency; ui->centerFrequency->setToolTip(QString("Main center frequency in kHz (LO: %1 kHz)").arg(centerFrequency/1000)); - if ((m_streamIndex == 0) && (m_settings.m_ncoEnableRx0)) { - centerFrequency += m_settings.m_ncoFrequencyRx0; - } - - if ((m_streamIndex == 1) && (m_settings.m_ncoEnableRx1)) { - centerFrequency += m_settings.m_ncoFrequencyRx1; + if (m_settings.m_ncoEnableRx) { + centerFrequency += m_settings.m_ncoFrequencyRx; } ui->centerFrequency->blockSignals(true); @@ -462,10 +458,8 @@ void LimeSDRMIMOGUI::setRxCenterFrequencySetting(uint64_t kHzValue) { int64_t centerFrequency = kHzValue*1000; - if (m_streamIndex == 0 && m_settings.m_ncoEnableRx0) { - centerFrequency -= m_settings.m_ncoFrequencyRx0; - } else if (m_streamIndex == 1 && m_settings.m_ncoEnableRx1) { - centerFrequency -= m_settings.m_ncoFrequencyRx1; + if (m_settings.m_ncoEnableRx) { + centerFrequency -= m_settings.m_ncoFrequencyRx; } m_settings.m_rxCenterFrequency = centerFrequency < 0 ? 0 : (uint64_t) centerFrequency; @@ -488,12 +482,8 @@ void LimeSDRMIMOGUI::setTxCenterFrequencyDisplay() int64_t centerFrequency = m_settings.m_txCenterFrequency; ui->centerFrequency->setToolTip(QString("Main center frequency in kHz (LO: %1 kHz)").arg(centerFrequency/1000)); - if ((m_streamIndex == 0) && (m_settings.m_ncoEnableTx0)) { - centerFrequency += m_settings.m_ncoFrequencyTx0; - } - - if ((m_streamIndex == 1) && (m_settings.m_ncoEnableTx1)) { - centerFrequency += m_settings.m_ncoFrequencyTx1; + if (m_settings.m_ncoEnableTx) { + centerFrequency += m_settings.m_ncoFrequencyTx; } ui->centerFrequency->blockSignals(true); @@ -505,10 +495,8 @@ void LimeSDRMIMOGUI::setTxCenterFrequencySetting(uint64_t kHzValue) { int64_t centerFrequency = kHzValue*1000; - if (m_streamIndex == 0 && m_settings.m_ncoEnableTx0) { - centerFrequency -= m_settings.m_ncoFrequencyTx0; - } else if (m_streamIndex == 1 && m_settings.m_ncoEnableTx1) { - centerFrequency -= m_settings.m_ncoFrequencyTx1; + if (m_settings.m_ncoEnableTx) { + centerFrequency -= m_settings.m_ncoFrequencyTx; } m_settings.m_txCenterFrequency = centerFrequency < 0 ? 0 : (uint64_t) centerFrequency; @@ -571,18 +559,8 @@ void LimeSDRMIMOGUI::setNCODisplay() ui->ncoFrequency->blockSignals(true); ui->ncoFrequency->setToolTip(QString("NCO frequency shift in Hz (Range: +/- %1 kHz)").arg(ncoHalfRange/1000)); - - if (m_streamIndex == 0) - { - ui->ncoFrequency->setValue(m_settings.m_ncoFrequencyRx0); - ui->ncoEnable->setChecked(m_settings.m_ncoEnableRx0); - } - else - { - ui->ncoFrequency->setValue(m_settings.m_ncoFrequencyRx1); - ui->ncoEnable->setChecked(m_settings.m_ncoEnableRx1); - } - + ui->ncoFrequency->setValue(m_settings.m_ncoFrequencyRx); + ui->ncoEnable->setChecked(m_settings.m_ncoEnableRx); ui->ncoFrequency->blockSignals(false); } else @@ -596,18 +574,8 @@ void LimeSDRMIMOGUI::setNCODisplay() ui->ncoFrequency->blockSignals(true); ui->ncoFrequency->setToolTip(QString("NCO frequency shift in Hz (Range: +/- %1 kHz)").arg(ncoHalfRange/1000)); - - if (m_streamIndex == 0) - { - ui->ncoFrequency->setValue(m_settings.m_ncoFrequencyTx0); - ui->ncoEnable->setChecked(m_settings.m_ncoEnableTx0); - } - else - { - ui->ncoFrequency->setValue(m_settings.m_ncoFrequencyTx1); - ui->ncoEnable->setChecked(m_settings.m_ncoEnableTx1); - } - + ui->ncoFrequency->setValue(m_settings.m_ncoFrequencyTx); + ui->ncoEnable->setChecked(m_settings.m_ncoEnableTx); ui->ncoFrequency->blockSignals(false); } } @@ -848,22 +816,12 @@ void LimeSDRMIMOGUI::on_ncoEnable_toggled(bool checked) { if (m_rxElseTx) { - if (m_streamIndex == 0) { - m_settings.m_ncoEnableRx0 = checked; - } else if (m_streamIndex == 1) { - m_settings.m_ncoEnableRx1 = checked; - } - + m_settings.m_ncoEnableRx = checked; setRxCenterFrequencyDisplay(); } else { - if (m_streamIndex == 0) { - m_settings.m_ncoEnableTx0 = checked; - } else if (m_streamIndex == 1) { - m_settings.m_ncoEnableTx1 = checked; - } - + m_settings.m_ncoEnableTx = checked; setTxCenterFrequencyDisplay(); } @@ -874,22 +832,12 @@ void LimeSDRMIMOGUI::on_ncoFrequency_changed(qint64 value) { if (m_rxElseTx) { - if (m_streamIndex == 0) { - m_settings.m_ncoFrequencyRx0 = value; - } else if (m_streamIndex == 1) { - m_settings.m_ncoFrequencyRx1 = value; - } - + m_settings.m_ncoFrequencyRx = value; setRxCenterFrequencyDisplay(); } else { - if (m_streamIndex == 0) { - m_settings.m_ncoFrequencyTx0 = value; - } else if (m_streamIndex == 1) { - m_settings.m_ncoFrequencyTx1 = value; - } - + m_settings.m_ncoFrequencyTx = value; setTxCenterFrequencyDisplay(); } diff --git a/plugins/samplemimo/limesdrmimo/limesdrmimogui.ui b/plugins/samplemimo/limesdrmimo/limesdrmimogui.ui index b6d5cddb8..bbe9c0d7a 100644 --- a/plugins/samplemimo/limesdrmimo/limesdrmimogui.ui +++ b/plugins/samplemimo/limesdrmimo/limesdrmimogui.ui @@ -365,25 +365,6 @@ - - - - - 20 - 0 - - - - Channel number - - - #0 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - @@ -572,6 +553,71 @@ 2 + + + + + 26 + 0 + + + + + 26 + 16777215 + + + + Toggle between device to host (SR) and base band (BB) sample rate input + + + SR + + + true + + + true + + + + + + + + 0 + 0 + + + + + 32 + 16 + + + + + Liberation Mono + 12 + 50 + false + + + + PointingHandCursor + + + Device to host sample rate + + + + + + + S/s + + + @@ -582,6 +628,19 @@ + + + + Qt::Horizontal + + + + 40 + 20 + + + + @@ -689,84 +748,6 @@ - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 26 - 0 - - - - - 26 - 16777215 - - - - Toggle between device to host (SR) and base band (BB) sample rate input - - - SR - - - true - - - true - - - - - - - - 0 - 0 - - - - - 32 - 16 - - - - - Liberation Mono - 12 - 50 - false - - - - PointingHandCursor - - - Device to host sample rate - - - - - - - S/s - - - diff --git a/plugins/samplemimo/limesdrmimo/limesdrmimosettings.cpp b/plugins/samplemimo/limesdrmimo/limesdrmimosettings.cpp index fd98a6f2c..ec805a081 100644 --- a/plugins/samplemimo/limesdrmimo/limesdrmimosettings.cpp +++ b/plugins/samplemimo/limesdrmimo/limesdrmimosettings.cpp @@ -45,13 +45,13 @@ void LimeSDRMIMOSettings::resetToDefaults() m_iqCorrection = false; m_rxTransverterMode = false; m_rxTransverterDeltaFrequency = 0; + m_ncoEnableRx = false; + m_ncoFrequencyRx = 0; m_lpfBWRx0 = 4.5e6f; m_lpfFIREnableRx0 = false; m_lpfFIRBWRx0 = 2.5e6f; m_gainRx0 = 50; - m_ncoEnableRx0 = false; - m_ncoFrequencyRx0 = 0; m_antennaPathRx0 = PATH_RFE_RX_NONE; m_gainModeRx0 = GAIN_AUTO; m_lnaGainRx0 = 15; @@ -62,8 +62,6 @@ void LimeSDRMIMOSettings::resetToDefaults() m_lpfFIREnableRx1 = false; m_lpfFIRBWRx1 = 2.5e6f; m_gainRx1 = 50; - m_ncoEnableRx1 = false; - m_ncoFrequencyRx1 = 0; m_antennaPathRx1 = PATH_RFE_RX_NONE; m_gainModeRx1 = GAIN_AUTO; m_lnaGainRx1 = 15; @@ -75,21 +73,19 @@ void LimeSDRMIMOSettings::resetToDefaults() m_log2SoftInterp = 0; m_txTransverterMode = false; m_txTransverterDeltaFrequency = 0; + m_ncoEnableTx = false; + m_ncoFrequencyTx = 0; m_lpfBWTx0 = 5.5e6f; m_lpfFIREnableTx0 = false; m_lpfFIRBWTx0 = 2.5e6f; m_gainTx0 = 4; - m_ncoEnableTx0 = false; - m_ncoFrequencyTx0 = 0; m_antennaPathTx0 = PATH_RFE_TX_NONE; m_lpfBWTx1 = 5.5e6f; m_lpfFIREnableTx1 = false; m_lpfFIRBWTx1 = 2.5e6f; m_gainTx1 = 4; - m_ncoEnableTx1 = false; - m_ncoFrequencyTx1 = 0; m_antennaPathTx1 = PATH_RFE_TX_NONE; } @@ -116,52 +112,48 @@ QByteArray LimeSDRMIMOSettings::serialize() const s.writeBool(24, m_iqCorrection); s.writeBool(25, m_rxTransverterMode); s.writeS64(26, m_rxTransverterDeltaFrequency); + s.writeBool(27, m_ncoEnableRx); + s.writeS32(28, m_ncoFrequencyRx); s.writeFloat(30, m_lpfBWRx0); s.writeBool(31, m_lpfFIREnableRx0); s.writeFloat(32, m_lpfFIRBWRx0); s.writeU32(33, m_gainRx0); - s.writeBool(34, m_ncoEnableRx0); - s.writeS32(35, m_ncoFrequencyRx0); - s.writeS32(36, (int) m_antennaPathRx0); - s.writeS32(37, (int) m_gainModeRx0); - s.writeU32(38, m_lnaGainRx0); - s.writeU32(39, m_tiaGainRx0); - s.writeU32(40, m_pgaGainRx0); + s.writeS32(34, (int) m_antennaPathRx0); + s.writeS32(35, (int) m_gainModeRx0); + s.writeU32(36, m_lnaGainRx0); + s.writeU32(37, m_tiaGainRx0); + s.writeU32(38, m_pgaGainRx0); s.writeFloat(50, m_lpfBWRx1); s.writeBool(51, m_lpfFIREnableRx1); s.writeFloat(52, m_lpfFIRBWRx1); s.writeU32(53, m_gainRx1); - s.writeBool(54, m_ncoEnableRx1); - s.writeS32(55, m_ncoFrequencyRx1); - s.writeS32(56, (int) m_antennaPathRx1); - s.writeS32(57, (int) m_gainModeRx1); - s.writeU32(58, m_lnaGainRx1); - s.writeU32(59, m_tiaGainRx1); - s.writeU32(60, m_pgaGainRx1); + s.writeS32(54, (int) m_antennaPathRx1); + s.writeS32(55, (int) m_gainModeRx1); + s.writeU32(56, m_lnaGainRx1); + s.writeU32(57, m_tiaGainRx1); + s.writeU32(58, m_pgaGainRx1); s.writeU64(70, m_txCenterFrequency); s.writeU32(71, m_log2HardInterp); s.writeU32(72, m_log2SoftInterp); s.writeBool(73, m_txTransverterMode); s.writeS64(74, m_txTransverterDeltaFrequency); + s.writeBool(75, m_ncoEnableTx); + s.writeS32(76, m_ncoFrequencyTx); s.writeFloat(80, m_lpfBWTx0); s.writeBool(81, m_lpfFIREnableTx0); s.writeFloat(82, m_lpfFIRBWTx0); s.writeU32(83, m_gainTx0); - s.writeBool(84, m_ncoEnableTx0); - s.writeS32(85, m_ncoFrequencyTx0); - s.writeS32(86, (int) m_antennaPathTx0); + s.writeS32(84, (int) m_antennaPathTx0); s.writeFloat(90, m_lpfBWTx1); s.writeBool(91, m_lpfFIREnableTx1); s.writeFloat(92, m_lpfFIRBWTx1); s.writeU32(93, m_gainTx1); - s.writeBool(94, m_ncoEnableTx1); - s.writeS32(95, m_ncoFrequencyTx1); - s.writeS32(96, (int) m_antennaPathTx1); + s.writeS32(94, (int) m_antennaPathTx1); return s.final(); } @@ -210,57 +202,53 @@ bool LimeSDRMIMOSettings::deserialize(const QByteArray& data) d.readBool(24, &m_iqCorrection, false); d.readBool(25, &m_rxTransverterMode, false); d.readS64(26, &m_rxTransverterDeltaFrequency, 0); + d.readBool(27, &m_ncoEnableRx, false); + d.readS32(28, &m_ncoFrequencyRx, 0); d.readFloat(30, &m_lpfBWRx0, 1.5e6); d.readBool(31, &m_lpfFIREnableRx0, false); d.readFloat(32, &m_lpfFIRBWRx0, 1.5e6); d.readU32(33, &m_gainRx0, 50); - d.readBool(34, &m_ncoEnableRx0, false); - d.readS32(35, &m_ncoFrequencyRx0, 0); - d.readS32(36, &intval, 0); + d.readS32(34, &intval, 0); m_antennaPathRx0 = (PathRxRFE) intval; - d.readS32(37, &intval, 0); + d.readS32(35, &intval, 0); m_gainModeRx0 = (RxGainMode) intval; - d.readU32(38, &m_lnaGainRx0, 15); - d.readU32(39, &m_tiaGainRx0, 2); - d.readU32(40, &m_pgaGainRx0, 16); + d.readU32(36, &m_lnaGainRx0, 15); + d.readU32(37, &m_tiaGainRx0, 2); + d.readU32(38, &m_pgaGainRx0, 16); d.readFloat(50, &m_lpfBWRx1, 1.5e6); d.readBool(51, &m_lpfFIREnableRx1, false); d.readFloat(52, &m_lpfFIRBWRx1, 1.5e6); d.readU32(53, &m_gainRx1, 50); - d.readBool(54, &m_ncoEnableRx1, false); - d.readS32(55, &m_ncoFrequencyRx1, 0); - d.readS32(56, &intval, 0); + d.readS32(54, &intval, 0); m_antennaPathRx1 = (PathRxRFE) intval; - d.readS32(57, &intval, 0); + d.readS32(55, &intval, 0); m_gainModeRx1 = (RxGainMode) intval; - d.readU32(58, &m_lnaGainRx1, 15); - d.readU32(59, &m_tiaGainRx1, 2); - d.readU32(60, &m_pgaGainRx1, 16); + d.readU32(56, &m_lnaGainRx1, 15); + d.readU32(57, &m_tiaGainRx1, 2); + d.readU32(58, &m_pgaGainRx1, 16); d.readU64(70, &m_txCenterFrequency, 435000*1000); d.readU32(71, &m_log2HardInterp, 2); d.readU32(72, &m_log2SoftInterp, 0); d.readBool(73, &m_txTransverterMode, false); d.readS64(74, &m_txTransverterDeltaFrequency, 0); + d.readBool(75, &m_ncoEnableTx, false); + d.readS32(76, &m_ncoFrequencyTx, 0); d.readFloat(80, &m_lpfBWTx0, 1.5e6); d.readBool(81, &m_lpfFIREnableTx0, false); d.readFloat(82, &m_lpfFIRBWTx0, 1.5e6); d.readU32(83, &m_gainTx0, 4); - d.readBool(84, &m_ncoEnableTx0, false); - d.readS32(85, &m_ncoFrequencyTx0, 0); - d.readS32(86, &intval, 0); + d.readS32(84, &intval, 0); m_antennaPathTx0 = (PathTxRFE) intval; d.readFloat(90, &m_lpfBWTx1, 1.5e6); d.readBool(91, &m_lpfFIREnableTx1, false); d.readFloat(92, &m_lpfFIRBWTx1, 1.5e6); d.readU32(93, &m_gainTx1, 4); - d.readBool(94, &m_ncoEnableTx1, false); - d.readS32(95, &m_ncoFrequencyTx1, 0); - d.readS32(96, &intval, 0); + d.readS32(94, &intval, 0); m_antennaPathTx1 = (PathTxRFE) intval; return true; diff --git a/plugins/samplemimo/limesdrmimo/limesdrmimosettings.h b/plugins/samplemimo/limesdrmimo/limesdrmimosettings.h index 662121bb2..48ef8815c 100644 --- a/plugins/samplemimo/limesdrmimo/limesdrmimosettings.h +++ b/plugins/samplemimo/limesdrmimo/limesdrmimosettings.h @@ -72,14 +72,14 @@ struct LimeSDRMIMOSettings bool m_iqCorrection; bool m_rxTransverterMode; qint64 m_rxTransverterDeltaFrequency; + bool m_ncoEnableRx; //!< Rx Enable TSP NCO and mixing + int m_ncoFrequencyRx; //!< Rx Actual NCO frequency (the resulting frequency with mixing is displayed) // Rx channel 0 float m_lpfBWRx0; //!< Rx[0] LMS analog lowpass filter bandwidth (Hz) bool m_lpfFIREnableRx0; //!< Rx[0] Enable LMS digital lowpass FIR filters float m_lpfFIRBWRx0; //!< Rx[0] LMS digital lowpass FIR filters bandwidth (Hz) uint32_t m_gainRx0; //!< Rx[0] Optimally distributed gain (dB) - bool m_ncoEnableRx0; //!< Rx[0] Enable TSP NCO and mixing - int m_ncoFrequencyRx0; //!< Rx[0] Actual NCO frequency (the resulting frequency with mixing is displayed) PathRxRFE m_antennaPathRx0; //!< Rx[0] Antenna connection RxGainMode m_gainModeRx0; //!< Rx[0] Gain mode: auto or manual uint32_t m_lnaGainRx0; //!< Rx[0] Manual LAN gain @@ -91,8 +91,6 @@ struct LimeSDRMIMOSettings bool m_lpfFIREnableRx1; //!< Rx[1] Enable LMS digital lowpass FIR filters float m_lpfFIRBWRx1; //!< Rx[1] LMS digital lowpass FIR filters bandwidth (Hz) uint32_t m_gainRx1; //!< Rx[1] Optimally distributed gain (dB) - bool m_ncoEnableRx1; //!< Rx[1] Enable TSP NCO and mixing - int m_ncoFrequencyRx1; //!< Rx[1] Actual NCO frequency (the resulting frequency with mixing is displayed) PathRxRFE m_antennaPathRx1; //!< Rx[1] Antenna connection RxGainMode m_gainModeRx1; //!< Rx[1] Gain mode: auto or manual uint32_t m_lnaGainRx1; //!< Rx[1] Manual LAN gain @@ -105,14 +103,14 @@ struct LimeSDRMIMOSettings uint32_t m_log2SoftInterp; bool m_txTransverterMode; qint64 m_txTransverterDeltaFrequency; + bool m_ncoEnableTx; //!< Tx Enable TSP NCO and mixing + int m_ncoFrequencyTx; //!< Tx Actual NCO frequency (the resulting frequency with mixing is displayed) // Tx channel 0 float m_lpfBWTx0; //!< Tx[0] LMS amalog lowpass filter bandwidth (Hz) bool m_lpfFIREnableTx0; //!< Tx[0] Enable LMS digital lowpass FIR filters float m_lpfFIRBWTx0; //!< Tx[0] LMS digital lowpass FIR filters bandwidth (Hz) uint32_t m_gainTx0; //!< Tx[0] Optimally distributed gain (dB) - bool m_ncoEnableTx0; //!< Tx[0] Enable TSP NCO and mixing - int m_ncoFrequencyTx0; //!< Tx[0] Actual NCO frequency (the resulting frequency with mixing is displayed) PathTxRFE m_antennaPathTx0; //!< Tx[0] Antenna connection // Tx channel 1 @@ -120,8 +118,6 @@ struct LimeSDRMIMOSettings bool m_lpfFIREnableTx1; //!< Tx[1] Enable LMS digital lowpass FIR filters float m_lpfFIRBWTx1; //!< Tx[1] LMS digital lowpass FIR filters bandwidth (Hz) uint32_t m_gainTx1; //!< Tx[1] Optimally distributed gain (dB) - bool m_ncoEnableTx1; //!< Tx[1] Enable TSP NCO and mixing - int m_ncoFrequencyTx1; //!< Tx[1] Actual NCO frequency (the resulting frequency with mixing is displayed) PathTxRFE m_antennaPathTx1; //!< Tx[1] Antenna connection LimeSDRMIMOSettings(); diff --git a/plugins/samplemimo/limesdrmimo/limesdrmithread.cpp b/plugins/samplemimo/limesdrmimo/limesdrmithread.cpp index 494675e24..bb7e15d60 100644 --- a/plugins/samplemimo/limesdrmimo/limesdrmithread.cpp +++ b/plugins/samplemimo/limesdrmimo/limesdrmithread.cpp @@ -31,6 +31,9 @@ LimeSDRMIThread::LimeSDRMIThread(lms_stream_t* stream0, lms_stream_t* stream1, Q for (unsigned int i = 0; i < 2; i++) { m_convertBuffer[i].resize(DeviceLimeSDR::blockSize, Sample{0,0}); } + + m_vBegin.push_back(m_convertBuffer[0].begin()); + m_vBegin.push_back(m_convertBuffer[1].begin()); } LimeSDRMIThread::~LimeSDRMIThread() @@ -53,6 +56,7 @@ void LimeSDRMIThread::startWork() if (LMS_StartStream(m_stream0) < 0) { qCritical("LimeSDRMIThread::startWork: could not start stream 0"); + return; } else { @@ -66,6 +70,8 @@ void LimeSDRMIThread::startWork() if (LMS_StartStream(m_stream1) < 0) { qCritical("LimeSDRMIThread::startWork: could not start stream 1"); + LMS_StopStream(m_stream0); + return; } else { @@ -137,7 +143,6 @@ void LimeSDRMIThread::run() lms_stream_meta_t metadata; //Use metadata for additional control over sample receive function behaviour metadata.flushPartialPacket = false; //Do not discard data remainder when read size differs from packet size metadata.waitForTimestamp = false; //Do not wait for specific timestamps - std::vector vbegin; int lengths[2]; m_running = true; @@ -160,11 +165,9 @@ void LimeSDRMIThread::run() else { std::fill(m_convertBuffer[0].begin(), m_convertBuffer[0].end(), Sample{0,0}); - lengths[0] = m_convertBuffer[0].size(); + lengths[0] = m_convertBuffer[0].size() / (1<writeSync(vbegin, lengths[0]); + qDebug("LimeSDRMIThread::run: writeSync %d samples", lengths[0]); + m_sampleFifo->writeSync(m_vBegin, lengths[0]); } else { qWarning("LimeSDRMIThread::run: unequal channel lengths: [0]=%d [1]=%d", lengths[0], lengths[1]); - m_sampleFifo->writeSync(vbegin, (std::min)(lengths[0], lengths[1])); + m_sampleFifo->writeSync(m_vBegin, (std::min)(lengths[0], lengths[1])); } } diff --git a/plugins/samplemimo/limesdrmimo/limesdrmithread.h b/plugins/samplemimo/limesdrmimo/limesdrmithread.h index 1b4a9b9ef..a6682b8fd 100644 --- a/plugins/samplemimo/limesdrmimo/limesdrmithread.h +++ b/plugins/samplemimo/limesdrmimo/limesdrmithread.h @@ -56,6 +56,7 @@ private: lms_stream_t* m_stream1; qint16 m_buf[2][2*DeviceLimeSDR::blockSize]; SampleVector m_convertBuffer[2]; + std::vector m_vBegin; SampleMIFifo* m_sampleFifo; Decimators m_decimators[2]; unsigned int m_log2Decim; diff --git a/plugins/samplemimo/limesdrmimo/limesdrmothread.cpp b/plugins/samplemimo/limesdrmimo/limesdrmothread.cpp index 1c1ac99e1..cf79995b7 100644 --- a/plugins/samplemimo/limesdrmimo/limesdrmothread.cpp +++ b/plugins/samplemimo/limesdrmimo/limesdrmothread.cpp @@ -53,6 +53,7 @@ void LimeSDRMOThread::startWork() if (LMS_StartStream(m_stream0) < 0) { qCritical("LimeSDROutputThread::startWork: could not start stream 0"); + return; } else { @@ -66,6 +67,8 @@ void LimeSDRMOThread::startWork() if (LMS_StartStream(m_stream1) < 0) { qCritical("LimeSDROutputThread::startWork: could not start stream 1"); + LMS_StopStream(m_stream0); + return; } else {