From b9a491ba775412cf9abbad79f0db5f953d93cd54 Mon Sep 17 00:00:00 2001 From: f4exb Date: Fri, 17 Apr 2020 18:50:47 +0200 Subject: [PATCH] XTRX MIMO: fixed Rx set sample rate --- devices/xtrx/devicextrx.cpp | 74 +++++- devices/xtrx/devicextrx.h | 3 +- plugins/samplemimo/xtrxmimo/xtrxmimo.cpp | 233 ++++++++++-------- plugins/samplemimo/xtrxmimo/xtrxmimo.h | 3 +- plugins/samplemimo/xtrxmimo/xtrxmimogui.cpp | 65 +++-- plugins/samplemimo/xtrxmimo/xtrxmimogui.ui | 5 + .../samplemimo/xtrxmimo/xtrxmimosettings.cpp | 25 +- .../samplemimo/xtrxmimo/xtrxmimosettings.h | 7 +- 8 files changed, 246 insertions(+), 169 deletions(-) diff --git a/devices/xtrx/devicextrx.cpp b/devices/xtrx/devicextrx.cpp index eaa83b2a0..5a0f553c8 100644 --- a/devices/xtrx/devicextrx.cpp +++ b/devices/xtrx/devicextrx.cpp @@ -115,7 +115,7 @@ void DeviceXTRX::getAutoGains(uint32_t autoGain, uint32_t& lnaGain, uint32_t& ti pgaGain = m_pgaTbl[value]; } -double DeviceXTRX::set_samplerate(double rate, double master, bool output) +double DeviceXTRX::setSamplerate(double rate, double master, bool output) { m_masterRate = master; @@ -125,24 +125,26 @@ double DeviceXTRX::set_samplerate(double rate, double master, bool output) m_inputRate = rate; } - int res = xtrx_set_samplerate(m_dev, - m_masterRate, - m_inputRate, - m_outputRate, - 0, - &m_clockGen, - &m_actualInputRate, - &m_actualOutputRate); + int res = xtrx_set_samplerate( + m_dev, + m_masterRate, + m_inputRate, + m_outputRate, + 0, + &m_clockGen, + &m_actualInputRate, + &m_actualOutputRate + ); if (res) { - qCritical("DeviceXTRX::set_samplerate: Unable to set %s samplerate, m_masterRate: %f, m_inputRate: %f, m_outputRate: %f, error=%d", + qCritical("DeviceXTRX::setSamplerate: Unable to set %s samplerate, m_masterRate: %f, m_inputRate: %f, m_outputRate: %f, error=%d", output ? "output" : "input", m_masterRate, m_inputRate, m_outputRate, res); return 0; } else { - qDebug() << "DeviceXTRX::set_samplerate: sample rate set: " + qDebug() << "DeviceXTRX::setSamplerate: sample rate set: " << "output: "<< output << "m_masterRate: " << m_masterRate << "m_inputRate: " << m_inputRate @@ -157,4 +159,52 @@ double DeviceXTRX::set_samplerate(double rate, double master, bool output) } return m_inputRate; -} \ No newline at end of file +} + +bool DeviceXTRX::setSamplerate(double rate, uint32_t log2Decim, uint32_t log2Interp, bool output) +{ + double master, rxRate, txRate; + + if (output) + { + master = (log2Interp == 0) ? 0 : (rate * 4 * (1 << log2Interp)); + rxRate = (rate * 4 * (1 << log2Interp)) / (4 * (1 << log2Decim)); + txRate = rate; + } + else + { + master = (log2Decim == 0) ? 0 : (rate * 4 * (1 << log2Decim)); + rxRate = rate; + txRate = (rate * 4 * (1 << log2Decim)) / (4 * (1 << log2Interp)); + } + + m_masterRate = master; + m_inputRate = rxRate; + m_outputRate = txRate; + + int res = xtrx_set_samplerate( + m_dev, + master, + rxRate, + txRate, + XTRX_SAMPLERATE_FORCE_UPDATE, + &m_clockGen, + &m_actualInputRate, + &m_actualOutputRate + ); + + qDebug() << "DeviceXTRX::setSamplerate: sample rate set: " + << "rate: " << rate + << "log2Decim: " << log2Decim + << "log2Interp: " << log2Interp + << "output: " << output + << "res: "<< res + << "m_masterRate: " << m_masterRate + << "m_inputRate: " << m_inputRate + << "m_outputRate: " << m_outputRate + << "m_clockGen: " << m_clockGen + << "m_actualInputRate: " << m_actualInputRate + << "m_actualOutputRate: " << m_actualOutputRate; + + return !(res < 0); +} diff --git a/devices/xtrx/devicextrx.h b/devices/xtrx/devicextrx.h index a2124991f..936b8b533 100644 --- a/devices/xtrx/devicextrx.h +++ b/devices/xtrx/devicextrx.h @@ -36,7 +36,8 @@ public: void close(); static void enumOriginDevices(const QString& hardwareId, PluginInterface::OriginDevices& originDevices); struct xtrx_dev *getDevice() { return m_dev; } - double set_samplerate(double rate, double master, bool output); + double setSamplerate(double rate, double master, bool output); + bool setSamplerate(double rate, uint32_t log2Decim, uint32_t log2Interp, bool output); double getMasterRate() const { return m_masterRate; } double getClockGen() const { return m_clockGen; } double getActualInputRate() const { return m_actualInputRate; } diff --git a/plugins/samplemimo/xtrxmimo/xtrxmimo.cpp b/plugins/samplemimo/xtrxmimo/xtrxmimo.cpp index 8fac703b1..d870fbff2 100644 --- a/plugins/samplemimo/xtrxmimo/xtrxmimo.cpp +++ b/plugins/samplemimo/xtrxmimo/xtrxmimo.cpp @@ -231,14 +231,14 @@ const QString& XTRXMIMO::getDeviceDescription() const int XTRXMIMO::getSourceSampleRate(int index) const { (void) index; - int rate = m_settings.m_devSampleRate; + uint32_t rate = getRxDevSampleRate(); return (rate / (1<getActualInputRate(); } else { - return m_settings.m_devSampleRate; + return m_settings.m_rxDevSampleRate; + } +} + +uint32_t XTRXMIMO::getTxDevSampleRate() const +{ + if (m_deviceShared.m_dev) { + return m_deviceShared.m_dev->getActualOutputRate(); + } else { + return m_settings.m_txDevSampleRate; } } @@ -459,12 +468,12 @@ bool XTRXMIMO::applySettings(const XTRXMIMOSettings& settings, bool force) qint64 txXlatedDeviceCenterFrequency = settings.m_txCenterFrequency; qDebug() << "XTRXMIMO::applySettings: common:" - << " m_devSampleRate: " << settings.m_devSampleRate << " m_extClock: " << settings.m_extClock << " m_extClockFreq: " << settings.m_extClockFreq << " force: " << force; qDebug() << "XTRXMIMO::applySettings: Rx:" - << " m_rxCenterFrequency: " << settings.m_txCenterFrequency + << " m_rxDevSampleRate: " << settings.m_rxDevSampleRate + << " m_rxCenterFrequency: " << settings.m_rxCenterFrequency << " m_log2HardDecim: " << settings.m_log2HardDecim << " m_log2SoftDecim: " << settings.m_log2SoftDecim << " m_dcBlock: " << settings.m_dcBlock @@ -481,6 +490,7 @@ bool XTRXMIMO::applySettings(const XTRXMIMOSettings& settings, bool force) << " m_lpfBWRx1: " << settings.m_lpfBWRx1 << " m_pwrmodeRx1: " << settings.m_pwrmodeRx1; qDebug() << "XTRXMIMO::applySettings: Tx:" + << " m_txDevSampleRate: " << settings.m_txDevSampleRate << " m_txCenterFrequency: " << settings.m_txCenterFrequency << " m_log2HardInterp: " << settings.m_log2HardInterp << " m_log2SoftInterp: " << settings.m_log2SoftInterp @@ -525,10 +535,6 @@ bool XTRXMIMO::applySettings(const XTRXMIMOSettings& settings, bool force) } } - if ((m_settings.m_devSampleRate != settings.m_devSampleRate) || force) { - reverseAPIKeys.append("devSampleRate"); - } - // Rx if ((m_settings.m_dcBlock != settings.m_dcBlock) || force) @@ -543,17 +549,20 @@ bool XTRXMIMO::applySettings(const XTRXMIMOSettings& settings, bool force) m_deviceAPI->configureCorrections(settings.m_dcBlock, settings.m_iqCorrection); } + if ((m_settings.m_rxDevSampleRate != settings.m_rxDevSampleRate) || force) { + reverseAPIKeys.append("rxDevSampleRate"); + } if ((m_settings.m_log2HardDecim != settings.m_log2HardDecim) || force) { reverseAPIKeys.append("log2HardDecim"); } - if ((m_settings.m_devSampleRate != settings.m_devSampleRate) + if ((m_settings.m_rxDevSampleRate != settings.m_rxDevSampleRate) || (m_settings.m_log2HardDecim != settings.m_log2HardDecim) || force) { forwardChangeRxDSP = true; if (m_deviceShared.m_dev->getDevice()) { - doTxChangeSampleRate = true; + doRxChangeSampleRate = true; } } @@ -791,11 +800,14 @@ bool XTRXMIMO::applySettings(const XTRXMIMOSettings& settings, bool force) // Tx + if ((m_settings.m_txDevSampleRate != settings.m_txDevSampleRate) || force) { + reverseAPIKeys.append("txDevSampleRate"); + } if ((m_settings.m_log2HardInterp != settings.m_log2HardInterp) || force) { reverseAPIKeys.append("log2HardInterp"); } - if ((m_settings.m_devSampleRate != settings.m_devSampleRate) + if ((m_settings.m_txDevSampleRate != settings.m_txDevSampleRate) || (m_settings.m_log2HardInterp != settings.m_log2HardInterp) || force) { forwardChangeTxDSP = true; @@ -817,15 +829,6 @@ bool XTRXMIMO::applySettings(const XTRXMIMOSettings& settings, bool force) } } - if ((m_settings.m_devSampleRate != settings.m_devSampleRate) - || (m_settings.m_log2SoftInterp != settings.m_log2SoftInterp) || force) - { - unsigned int fifoRate = std::max( - (unsigned int) settings.m_devSampleRate / (1<isRunning()) // { @@ -925,26 +930,27 @@ bool XTRXMIMO::applySettings(const XTRXMIMOSettings& settings, bool force) // rxThreadWasRunning = true; // } - double master = (settings.m_log2HardDecim == 0) ? 0 : (settings.m_devSampleRate * 4 * (1 << settings.m_log2HardDecim)); + bool success = m_deviceShared.m_dev->setSamplerate( + m_settings.m_rxDevSampleRate, + m_settings.m_log2HardDecim, + m_settings.m_log2HardInterp, + false + ); - if (m_deviceShared.m_dev->setSamplerate(settings.m_devSampleRate, - master, //(settings.m_devSampleRate<getActualInputRate(); + m_settings.m_txDevSampleRate = m_deviceShared.m_dev->getActualOutputRate(); + m_settings.m_log2HardDecim = getLog2HardDecim(); + m_settings.m_log2HardInterp = getLog2HardInterp(); - qDebug("XTRXMIMO::applySettings: sample rate set to %f with oversampling of %d", - m_deviceShared.m_dev->getActualInputRate(), - 1 << getLog2HardDecim()); - } + qDebug("XTRXMIMO::applySettings: sample rate set %s to Rx:%f Tx:%f with decimation of %d and interpolation of %d", + success ? "unchanged" : "changed", + m_settings.m_rxDevSampleRate, + m_settings.m_txDevSampleRate, + 1 << m_settings.m_log2HardDecim, + 1 << m_settings.m_log2HardInterp); // if (rxThreadWasRunning) { // m_sourceThread->startWork(); @@ -955,20 +961,20 @@ bool XTRXMIMO::applySettings(const XTRXMIMOSettings& settings, bool force) { if (xtrx_tune_rx_bandwidth(m_deviceShared.m_dev->getDevice(), XTRX_CH_A, - settings.m_lpfBWRx0, + m_settings.m_lpfBWRx0, 0) < 0) { - qCritical("XTRXMIMO::applySettings: could not set Rx0 LPF to %f Hz", settings.m_lpfBWRx0); + qCritical("XTRXMIMO::applySettings: could not set Rx0 LPF to %f Hz", m_settings.m_lpfBWRx0); } else { - qDebug("XTRXMIMO::applySettings: Rx0 LPF set to %f Hz", settings.m_lpfBWRx0); + qDebug("XTRXMIMO::applySettings: Rx0 LPF set to %f Hz", m_settings.m_lpfBWRx0); } if (xtrx_tune_rx_bandwidth(m_deviceShared.m_dev->getDevice(), XTRX_CH_B, - settings.m_lpfBWRx1, + m_settings.m_lpfBWRx1, 0) < 0) { - qCritical("XTRXMIMO::applySettings: could not set Rx1 LPF to %f Hz", settings.m_lpfBWRx1); + qCritical("XTRXMIMO::applySettings: could not set Rx1 LPF to %f Hz", m_settings.m_lpfBWRx1); } else { - qDebug("XTRXMIMO::applySettings: Rx1 LPF set to %f Hz", settings.m_lpfBWRx1); + qDebug("XTRXMIMO::applySettings: Rx1 LPF set to %f Hz", m_settings.m_lpfBWRx1); } } @@ -981,9 +987,9 @@ bool XTRXMIMO::applySettings(const XTRXMIMOSettings& settings, bool force) qint64 deviceCenterFrequency = DeviceSampleSource::calculateDeviceCenterFrequency( rxXlatedDeviceCenterFrequency, 0, - settings.m_log2SoftDecim, + m_settings.m_log2SoftDecim, DeviceSampleSource::FC_POS_CENTER, - settings.m_devSampleRate, + m_settings.m_rxDevSampleRate, DeviceSampleSource::FrequencyShiftScheme::FSHIFT_STD, false); setRxDeviceCenterFrequency(m_deviceShared.m_dev->getDevice(), deviceCenterFrequency, 0); @@ -999,25 +1005,25 @@ bool XTRXMIMO::applySettings(const XTRXMIMOSettings& settings, bool force) if (xtrx_tune_ex(m_deviceShared.m_dev->getDevice(), XTRX_TUNE_BB_RX, XTRX_CH_AB, - (settings.m_ncoEnableRx) ? settings.m_ncoFrequencyRx : 0, + (m_settings.m_ncoEnableRx) ? m_settings.m_ncoFrequencyRx : 0, nullptr) < 0) { qCritical("XTRXMIMO::applySettings: could not %s and set Rx NCO to %d Hz", - settings.m_ncoEnableRx ? "enable" : "disable", - settings.m_ncoFrequencyRx); + m_settings.m_ncoEnableRx ? "enable" : "disable", + m_settings.m_ncoFrequencyRx); } else { qDebug("XTRXMIMO::applySettings: %sd and set NCO Rx to %d Hz", - settings.m_ncoEnableRx ? "enable" : "disable", - settings.m_ncoFrequencyRx); + m_settings.m_ncoEnableRx ? "enable" : "disable", + m_settings.m_ncoFrequencyRx); } } } // Post Tx - if (doTxChangeSampleRate && (settings.m_devSampleRate != 0)) + if (doTxChangeSampleRate && !doRxChangeSampleRate && (m_settings.m_txDevSampleRate != 0)) { // if (m_sinkThread && m_sinkThread->isRunning()) // { @@ -1025,26 +1031,27 @@ bool XTRXMIMO::applySettings(const XTRXMIMOSettings& settings, bool force) // txThreadWasRunning = true; // } - double master = (settings.m_log2HardInterp == 0) ? 0 : (settings.m_devSampleRate * 4 * (1 << settings.m_log2HardInterp)); + bool success = m_deviceShared.m_dev->setSamplerate( + m_settings.m_txDevSampleRate, + m_settings.m_log2HardDecim, + m_settings.m_log2HardInterp, + true + ); - if (m_deviceShared.m_dev->setSamplerate(settings.m_devSampleRate, - master, //(settings.m_devSampleRate<getActualInputRate(); + m_settings.m_txDevSampleRate = m_deviceShared.m_dev->getActualOutputRate(); + m_settings.m_log2HardDecim = getLog2HardDecim(); + m_settings.m_log2HardInterp = getLog2HardInterp(); - qDebug("XTRXMIMO::applySettings: sample rate set to %f with oversampling of %d", - m_deviceShared.m_dev->getActualOutputRate(), - 1 << getLog2HardInterp()); - } + qDebug("XTRXMIMO::applySettings: sample rate set %s to Rx:%f Tx:%f with decimation of %d and interpolation of %d", + success ? "unchanged" : "changed", + m_settings.m_rxDevSampleRate, + m_settings.m_txDevSampleRate, + 1 << m_settings.m_log2HardDecim, + 1 << m_settings.m_log2HardInterp); // if (txThreadWasRunning) { // m_sinkThread->startWork(); @@ -1055,20 +1062,20 @@ bool XTRXMIMO::applySettings(const XTRXMIMOSettings& settings, bool force) { if (xtrx_tune_tx_bandwidth(m_deviceShared.m_dev->getDevice(), XTRX_CH_A, - settings.m_lpfBWTx0, + m_settings.m_lpfBWTx0, 0) < 0) { - qCritical("XTRXMIMO::applySettings: could not set Tx0 LPF to %f Hz", settings.m_lpfBWTx0); + qCritical("XTRXMIMO::applySettings: could not set Tx0 LPF to %f Hz", m_settings.m_lpfBWTx0); } else { - qDebug("XTRXMIMO::applySettings: Tx0 LPF set to %f Hz", settings.m_lpfBWTx0); + qDebug("XTRXMIMO::applySettings: Tx0 LPF set to %f Hz", m_settings.m_lpfBWTx0); } if (xtrx_tune_tx_bandwidth(m_deviceShared.m_dev->getDevice(), XTRX_CH_B, - settings.m_lpfBWTx1, + m_settings.m_lpfBWTx1, 0) < 0) { - qCritical("XTRXMIMO::applySettings: could not set Tx1 LPF to %f Hz", settings.m_lpfBWTx1); + qCritical("XTRXMIMO::applySettings: could not set Tx1 LPF to %f Hz", m_settings.m_lpfBWTx1); } else { - qDebug("XTRXMIMO::applySettings: Tx1 LPF set to %f Hz", settings.m_lpfBWTx1); + qDebug("XTRXMIMO::applySettings: Tx1 LPF set to %f Hz", m_settings.m_lpfBWTx1); } } @@ -1083,7 +1090,7 @@ bool XTRXMIMO::applySettings(const XTRXMIMOSettings& settings, bool force) 0, settings.m_log2SoftInterp, DeviceSampleSink::FC_POS_CENTER, - settings.m_devSampleRate, + m_settings.m_txDevSampleRate, false); setTxDeviceCenterFrequency(m_deviceShared.m_dev->getDevice(), deviceCenterFrequency, 0); } @@ -1098,22 +1105,27 @@ bool XTRXMIMO::applySettings(const XTRXMIMOSettings& settings, bool force) if (xtrx_tune_ex(m_deviceShared.m_dev->getDevice(), XTRX_TUNE_BB_TX, XTRX_CH_AB, - (settings.m_ncoEnableTx) ? settings.m_ncoFrequencyTx : 0, + (m_settings.m_ncoEnableTx) ? m_settings.m_ncoFrequencyTx : 0, nullptr) < 0) { qCritical("XTRXMIMO::applySettings: could not %s and set Tx NCO to %d Hz", - settings.m_ncoEnableTx ? "enable" : "disable", - settings.m_ncoFrequencyTx); + m_settings.m_ncoEnableTx ? "enable" : "disable", + m_settings.m_ncoFrequencyTx); } else { qDebug("XTRXMIMO::applySettings: %sd and set Tx NCO to %d Hz", - settings.m_ncoEnableTx ? "enable" : "disable", - settings.m_ncoFrequencyTx); + m_settings.m_ncoEnableTx ? "enable" : "disable", + m_settings.m_ncoFrequencyTx); } } } + unsigned int fifoRate = std::max( + (unsigned int) m_settings.m_txDevSampleRate / (1<push(report); } + + int sampleRate = m_settings.m_rxDevSampleRate/(1<getDeviceEngineInputMessageQueue()->push(notifRx0); + DSPMIMOSignalNotification *notifRx1 = new DSPMIMOSignalNotification(sampleRate, m_settings.m_rxCenterFrequency + ncoShift, true, 1); + m_deviceAPI->getDeviceEngineInputMessageQueue()->push(notifRx1); + + sampleRate = m_settings.m_txDevSampleRate/(1<getDeviceEngineInputMessageQueue()->push(notifTx0); + DSPMIMOSignalNotification *notifTx1 = new DSPMIMOSignalNotification(sampleRate, m_settings.m_txCenterFrequency + ncoShift, false, 1); + m_deviceAPI->getDeviceEngineInputMessageQueue()->push(notifTx1); } - 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 (forwardChangeRxDSP) + // { + // int sampleRate = m_settings.m_rxDevSampleRate/(1<getDeviceEngineInputMessageQueue()->push(notif0); + // DSPMIMOSignalNotification *notif1 = new DSPMIMOSignalNotification(sampleRate, m_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); - } + // if (forwardChangeTxDSP) + // { + // int sampleRate = m_settings.m_txDevSampleRate/(1<getDeviceEngineInputMessageQueue()->push(notif0); + // DSPMIMOSignalNotification *notif1 = new DSPMIMOSignalNotification(sampleRate, m_settings.m_txCenterFrequency + ncoShift, false, 1); + // m_deviceAPI->getDeviceEngineInputMessageQueue()->push(notif1); + // } - m_settings = settings; return true; } diff --git a/plugins/samplemimo/xtrxmimo/xtrxmimo.h b/plugins/samplemimo/xtrxmimo/xtrxmimo.h index 48033907f..d8b4c84b7 100644 --- a/plugins/samplemimo/xtrxmimo/xtrxmimo.h +++ b/plugins/samplemimo/xtrxmimo/xtrxmimo.h @@ -235,7 +235,8 @@ public: virtual bool handleMessage(const Message& message); - uint32_t getDevSampleRate() const; + uint32_t getRxDevSampleRate() const; + uint32_t getTxDevSampleRate() const; uint32_t getLog2HardDecim() const; uint32_t getLog2HardInterp() const; double getClockGen() const; diff --git a/plugins/samplemimo/xtrxmimo/xtrxmimogui.cpp b/plugins/samplemimo/xtrxmimo/xtrxmimogui.cpp index 3af743488..7e3dff707 100644 --- a/plugins/samplemimo/xtrxmimo/xtrxmimogui.cpp +++ b/plugins/samplemimo/xtrxmimo/xtrxmimogui.cpp @@ -217,7 +217,10 @@ bool XTRXMIMOGUI::handleMessage(const Message& message) } else if (XTRXMIMO::MsgReportClockGenChange::match(message)) { - m_settings.m_devSampleRate = m_xtrxMIMO->getDevSampleRate(); + m_settings.m_rxDevSampleRate = m_xtrxMIMO->getRxDevSampleRate(); + m_settings.m_txDevSampleRate = m_xtrxMIMO->getTxDevSampleRate(); + m_settings.m_log2HardDecim = m_xtrxMIMO->getLog2HardDecim(); + m_settings.m_log2HardInterp = m_xtrxMIMO->getLog2HardInterp(); blockApplySettings(true); displaySettings(); @@ -284,6 +287,7 @@ void XTRXMIMOGUI::displaySettings() if (m_rxElseTx) { setRxCenterFrequencyDisplay(); + updateADCRate(); ui->dcOffset->setChecked(m_settings.m_dcBlock); ui->iqImbalance->setChecked(m_settings.m_iqCorrection); @@ -292,9 +296,6 @@ void XTRXMIMOGUI::displaySettings() ui->antenna->setCurrentIndex((int) m_settings.m_antennaPathRx); ui->ncoEnable->setChecked(m_settings.m_ncoEnableRx); - setNCODisplay(); - updateADCRate(); - if (m_streamIndex == 0) { ui->lpf->setValue(m_settings.m_lpfBWRx0 / 1000); @@ -351,15 +352,13 @@ void XTRXMIMOGUI::displaySettings() else { setTxCenterFrequencyDisplay(); + updateDACRate(); ui->swDecim->setCurrentIndex(m_settings.m_log2SoftInterp); ui->hwDecim->setCurrentIndex(m_settings.m_log2HardInterp); ui->antenna->setCurrentIndex((int) m_settings.m_antennaPathTx); ui->ncoEnable->setChecked(m_settings.m_ncoEnableTx); - updateDACRate(); - setNCODisplay(); - if (m_streamIndex == 0) { ui->lpf->setValue(m_settings.m_lpfBWTx0 / 1000); @@ -375,12 +374,16 @@ void XTRXMIMOGUI::displaySettings() ui->gainText->setText(tr("%1").arg(m_settings.m_gainTx1)); } } + + setNCODisplay(); } void XTRXMIMOGUI::displaySampleRate() { float minF, maxF, stepF; m_xtrxMIMO->getSRRange(minF, maxF, stepF); + uint32_t devSampleRate = m_rxElseTx ? m_settings.m_rxDevSampleRate : m_settings.m_txDevSampleRate; + uint32_t log2Soft = m_rxElseTx ? m_settings.m_log2SoftDecim : m_settings.m_log2SoftInterp; ui->sampleRate->blockSignals(true); @@ -389,21 +392,21 @@ void XTRXMIMOGUI::displaySampleRate() ui->sampleRateMode->setStyleSheet("QToolButton { background:rgb(60,60,60); }"); ui->sampleRateMode->setText("SR"); ui->sampleRate->setValueRange(8, (uint32_t) minF, (uint32_t) maxF); - ui->sampleRate->setValue(m_settings.m_devSampleRate); + ui->sampleRate->setValue(devSampleRate); ui->sampleRate->setToolTip("Device to host sample rate (S/s)"); ui->deviceRateText->setToolTip("Baseband sample rate (S/s)"); - uint32_t basebandSampleRate = m_settings.m_devSampleRate/(1<deviceRateText->setText(tr("%1k").arg(QString::number(basebandSampleRate / 1000.0f, 'g', 5))); } else { ui->sampleRateMode->setStyleSheet("QToolButton { background:rgb(50,50,50); }"); ui->sampleRateMode->setText("BB"); - ui->sampleRate->setValueRange(8, (uint32_t) minF/(1<sampleRate->setValue(m_settings.m_devSampleRate/(1<sampleRate->setValueRange(8, (uint32_t) minF/(1<sampleRate->setValue(devSampleRate/(1<sampleRate->setToolTip("Baseband sample rate (S/s)"); ui->deviceRateText->setToolTip("Device to host sample rate (S/s)"); - ui->deviceRateText->setText(tr("%1k").arg(QString::number(m_settings.m_devSampleRate / 1000.0f, 'g', 5))); + ui->deviceRateText->setText(tr("%1k").arg(QString::number(devSampleRate / 1000.0f, 'g', 5))); } ui->sampleRate->blockSignals(false); @@ -415,7 +418,7 @@ void XTRXMIMOGUI::setNCODisplay() if (m_rxElseTx) { - int ncoHalfRange = (m_settings.m_devSampleRate * (1<<(m_settings.m_log2HardDecim)))/2; + int ncoHalfRange = (m_settings.m_rxDevSampleRate * (1<<(m_settings.m_log2HardDecim)))/2; ui->ncoFrequency->setValueRange( false, 8, @@ -427,7 +430,7 @@ void XTRXMIMOGUI::setNCODisplay() } else { - int ncoHalfRange = (m_settings.m_devSampleRate * (1<<(m_settings.m_log2HardInterp)))/2; + int ncoHalfRange = (m_settings.m_txDevSampleRate * (1<<(m_settings.m_log2HardInterp)))/2; ui->ncoFrequency->setValueRange( false, 8, @@ -784,23 +787,16 @@ void XTRXMIMOGUI::on_extClock_clicked() void XTRXMIMOGUI::on_hwDecim_currentIndexChanged(int index) { - if ((index <0) || (index > 5)) { + if ((index <0) || (index > 6)) { return; } - - if (m_rxElseTx) - { + if (m_rxElseTx) { m_settings.m_log2HardDecim = index; - updateADCRate(); - } - else - { + } else { m_settings.m_log2HardInterp = index; - updateDACRate(); } - setNCODisplay(); sendSettings(); } @@ -817,9 +813,9 @@ void XTRXMIMOGUI::on_swDecim_currentIndexChanged(int index) m_settings.m_log2SoftDecim = index; if (m_sampleRateMode) { - m_settings.m_devSampleRate = ui->sampleRate->getValueNew(); + m_settings.m_rxDevSampleRate = ui->sampleRate->getValueNew(); } else { - m_settings.m_devSampleRate = ui->sampleRate->getValueNew() * (1 << m_settings.m_log2SoftDecim); + m_settings.m_rxDevSampleRate = ui->sampleRate->getValueNew() * (1 << m_settings.m_log2SoftDecim); } } else @@ -827,9 +823,9 @@ void XTRXMIMOGUI::on_swDecim_currentIndexChanged(int index) m_settings.m_log2SoftInterp = index; if (m_sampleRateMode) { - m_settings.m_devSampleRate = ui->sampleRate->getValueNew(); + m_settings.m_txDevSampleRate = ui->sampleRate->getValueNew(); } else { - m_settings.m_devSampleRate = ui->sampleRate->getValueNew() * (1 << m_settings.m_log2SoftInterp); + m_settings.m_txDevSampleRate = ui->sampleRate->getValueNew() * (1 << m_settings.m_log2SoftInterp); } } @@ -847,25 +843,20 @@ void XTRXMIMOGUI::on_sampleRate_changed(quint64 value) if (m_rxElseTx) { if (m_sampleRateMode) { - m_settings.m_devSampleRate = value; + m_settings.m_rxDevSampleRate = value; } else { - m_settings.m_devSampleRate = value * (1 << m_settings.m_log2SoftDecim); + m_settings.m_rxDevSampleRate = value * (1 << m_settings.m_log2SoftDecim); } - - updateADCRate(); } else { if (m_sampleRateMode) { - m_settings.m_devSampleRate = value; + m_settings.m_txDevSampleRate = value; } else { - m_settings.m_devSampleRate = value * (1 << m_settings.m_log2SoftInterp); + m_settings.m_txDevSampleRate = value * (1 << m_settings.m_log2SoftInterp); } - - updateDACRate(); } - setNCODisplay(); sendSettings(); } diff --git a/plugins/samplemimo/xtrxmimo/xtrxmimogui.ui b/plugins/samplemimo/xtrxmimo/xtrxmimogui.ui index 978e8877e..e6669ec0e 100644 --- a/plugins/samplemimo/xtrxmimo/xtrxmimogui.ui +++ b/plugins/samplemimo/xtrxmimo/xtrxmimogui.ui @@ -639,6 +639,11 @@ 32 + + + 64 + + diff --git a/plugins/samplemimo/xtrxmimo/xtrxmimosettings.cpp b/plugins/samplemimo/xtrxmimo/xtrxmimosettings.cpp index 5d66e70ca..e2af8c2d1 100644 --- a/plugins/samplemimo/xtrxmimo/xtrxmimosettings.cpp +++ b/plugins/samplemimo/xtrxmimo/xtrxmimosettings.cpp @@ -26,7 +26,6 @@ XTRXMIMOSettings::XTRXMIMOSettings() void XTRXMIMOSettings::resetToDefaults() { // common - m_devSampleRate = 5e6; m_extClock = false; m_extClockFreq = 0; // Auto m_fileRecordName = ""; @@ -35,6 +34,7 @@ void XTRXMIMOSettings::resetToDefaults() m_reverseAPIPort = 8888; m_reverseAPIDeviceIndex = 0; // Rx + m_rxDevSampleRate = 5e6; m_rxCenterFrequency = 435000*1000; m_log2HardDecim = 2; m_dcBlock = false; @@ -60,6 +60,7 @@ void XTRXMIMOSettings::resetToDefaults() m_pgaGainRx1 = 16; m_pwrmodeRx1 = 4; // Tx + m_txDevSampleRate = 5e6; m_txCenterFrequency = 435000*1000; m_log2HardInterp = 2; m_log2SoftInterp = 4; @@ -81,7 +82,6 @@ QByteArray XTRXMIMOSettings::serialize() const SimpleSerializer s(1); // common - s.writeDouble(1, m_devSampleRate); s.writeBool(2, m_extClock); s.writeU32(3, m_extClockFreq); s.writeString(4, m_fileRecordName); @@ -97,6 +97,7 @@ QByteArray XTRXMIMOSettings::serialize() const s.writeBool(24, m_ncoEnableRx); s.writeS32(25, m_ncoFrequencyRx); s.writeS32(26, (int) m_antennaPathRx); + s.writeDouble(27, m_rxDevSampleRate); // Rx0 s.writeFloat(30, m_lpfBWRx0); s.writeU32(31, m_gainRx0); @@ -119,6 +120,7 @@ QByteArray XTRXMIMOSettings::serialize() const s.writeBool(72, m_ncoEnableTx); s.writeS32(73, m_ncoFrequencyTx); s.writeS32(74, (int) m_antennaPathTx); + s.writeDouble(75, m_txDevSampleRate); // Tx0 s.writeFloat(80, m_lpfBWTx0); s.writeU32(81, m_gainTx0); @@ -147,7 +149,6 @@ bool XTRXMIMOSettings::deserialize(const QByteArray& data) uint32_t uintval; // common - d.readDouble(1, &m_devSampleRate, 5e6); d.readBool(2, &m_extClock, false); d.readU32(3, &m_extClockFreq, 0); d.readString(4, &m_fileRecordName, ""); @@ -166,10 +167,11 @@ bool XTRXMIMOSettings::deserialize(const QByteArray& data) d.readU32(21, &m_log2SoftDecim, 0); d.readBool(22, &m_dcBlock, false); d.readBool(23, &m_iqCorrection, false); - d.readBool(32, &m_ncoEnableRx, false); - d.readS32(33, &m_ncoFrequencyRx, 0); - d.readS32(24, &intval, 0); + d.readBool(24, &m_ncoEnableRx, false); + d.readS32(25, &m_ncoFrequencyRx, 0); + d.readS32(26, &intval, 0); m_antennaPathRx = (RxAntenna) intval; + d.readDouble(27, &m_rxDevSampleRate, 5e6); // Rx0 d.readFloat(30, &m_lpfBWRx0, 1.5e6); d.readU32(31, &m_gainRx0, 50); @@ -189,20 +191,21 @@ bool XTRXMIMOSettings::deserialize(const QByteArray& data) d.readU32(57, &m_pgaGainRx1, 16); d.readU32(58, &m_pwrmodeRx1, 4); // Tx - d.readU32(20, &m_log2HardInterp, 2); + d.readU32(70, &m_log2HardInterp, 2); d.readU32(71, &m_log2SoftInterp, 0); d.readS32(72, &intval, 0); - d.readBool(82, &m_ncoEnableTx, true); - d.readS32(83, &m_ncoFrequencyTx, 500000); + d.readBool(73, &m_ncoEnableTx, true); + d.readS32(74, &m_ncoFrequencyTx, 500000); m_antennaPathTx = (TxAntenna) intval; + d.readDouble(75, &m_txDevSampleRate, 5e6); // Tx0 d.readFloat(80, &m_lpfBWTx0, 1.5e6); d.readU32(81, &m_gainTx0, 20); - d.readU32(84, &m_pwrmodeTx0, 4); + d.readU32(82, &m_pwrmodeTx0, 4); // Tx1 d.readFloat(90, &m_lpfBWTx1, 1.5e6); d.readU32(91, &m_gainTx1, 20); - d.readU32(94, &m_pwrmodeTx1, 4); + d.readU32(92, &m_pwrmodeTx1, 4); return true; } diff --git a/plugins/samplemimo/xtrxmimo/xtrxmimosettings.h b/plugins/samplemimo/xtrxmimo/xtrxmimosettings.h index 6735e5303..c832becae 100644 --- a/plugins/samplemimo/xtrxmimo/xtrxmimosettings.h +++ b/plugins/samplemimo/xtrxmimo/xtrxmimosettings.h @@ -42,7 +42,6 @@ struct XTRXMIMOSettings } TxAntenna; // common - double m_devSampleRate; bool m_extClock; //!< True if external clock source uint32_t m_extClockFreq; //!< Frequency (Hz) of external clock source QString m_fileRecordName; @@ -53,9 +52,10 @@ struct XTRXMIMOSettings uint16_t m_reverseAPIPort; uint16_t m_reverseAPIDeviceIndex; // Rx - uint64_t m_rxCenterFrequency; + double m_rxDevSampleRate; uint32_t m_log2HardDecim; uint32_t m_log2SoftDecim; + uint64_t m_rxCenterFrequency; bool m_dcBlock; bool m_iqCorrection; bool m_ncoEnableRx; //!< Enable TSP NCO and mixing @@ -78,9 +78,10 @@ struct XTRXMIMOSettings uint32_t m_pgaGainRx1; //!< Manual PGA gain uint32_t m_pwrmodeRx1; // Tx - uint64_t m_txCenterFrequency; + double m_txDevSampleRate; uint32_t m_log2HardInterp; uint32_t m_log2SoftInterp; + uint64_t m_txCenterFrequency; bool m_ncoEnableTx; //!< Enable TSP NCO and mixing int m_ncoFrequencyTx; //!< Actual NCO frequency (the resulting frequency with mixing is displayed) TxAntenna m_antennaPathTx;