From 35f7124a749acfa437e94475b31dd0bc98c0b474 Mon Sep 17 00:00:00 2001 From: f4exb Date: Tue, 18 Apr 2017 00:50:03 +0200 Subject: [PATCH] LimeSDR input: debug (2) --- devices/limesdr/devicelimesdrparam.cpp | 18 +++++----- .../limesdrinput/limesdrinput.cpp | 33 ++++++++++++------- .../limesdrinput/limesdrinputgui.cpp | 12 ++++--- .../limesdrinput/limesdrinputgui.ui | 7 ++-- .../limesdrinput/limesdrinputplugin.cpp | 24 +++++--------- 5 files changed, 53 insertions(+), 41 deletions(-) diff --git a/devices/limesdr/devicelimesdrparam.cpp b/devices/limesdr/devicelimesdrparam.cpp index e4f174a97..bea5cca0d 100644 --- a/devices/limesdr/devicelimesdrparam.cpp +++ b/devices/limesdr/devicelimesdrparam.cpp @@ -19,13 +19,15 @@ bool DeviceLimeSDRParams::open(lms_info_str_t deviceStr) { - if (LMS_Open(&m_dev, deviceStr, 0)) + qDebug("DeviceLimeSDRParams::open: serial: %s", (const char *) deviceStr); + + if (LMS_Open(&m_dev, deviceStr, 0) < 0) { qDebug() << "DeviceLimeSDRParams::open: cannot open device " << deviceStr; return false; } - if (LMS_Init(m_dev) != 0) + if (LMS_Init(m_dev) < 0) { qDebug() << "DeviceLimeSDRParams::open: cannot init device " << deviceStr; return false; @@ -55,37 +57,37 @@ bool DeviceLimeSDRParams::open(lms_info_str_t deviceStr) qDebug() << "DeviceLimeSDRParams::open: " << n << " Tx channels for device " << deviceStr; } - if (LMS_GetLPFBWRange(m_dev, LMS_CH_RX, &m_lpfRangeRx) != 0) + if (LMS_GetLPFBWRange(m_dev, LMS_CH_RX, &m_lpfRangeRx) < 0) { qDebug() << "DeviceLimeSDRParams::open: cannot get the Rx LPF range for device " << deviceStr; return false; } - if (LMS_GetLPFBWRange(m_dev, LMS_CH_TX, &m_lpfRangeTx) != 0) + if (LMS_GetLPFBWRange(m_dev, LMS_CH_TX, &m_lpfRangeTx) < 0) { qDebug() << "DeviceLimeSDRParams::open: cannot get the Tx LPF range for device " << deviceStr; return false; } - if (LMS_GetLOFrequencyRange(m_dev, LMS_CH_RX, &m_lpfRangeRx) != 0) + if (LMS_GetLOFrequencyRange(m_dev, LMS_CH_RX, &m_loRangeRx) < 0) { qDebug() << "DeviceLimeSDRParams::open: cannot get the Rx LO range for device " << deviceStr; return false; } - if (LMS_GetLOFrequencyRange(m_dev, LMS_CH_TX, &m_lpfRangeTx) != 0) + if (LMS_GetLOFrequencyRange(m_dev, LMS_CH_TX, &m_loRangeTx) < 0) { qDebug() << "DeviceLimeSDRParams::open: cannot get the Tx LO range for device " << deviceStr; return false; } - if (LMS_GetSampleRateRange(m_dev, LMS_CH_RX, &m_srRangeRx) != 0) + if (LMS_GetSampleRateRange(m_dev, LMS_CH_RX, &m_srRangeRx) < 0) { qDebug() << "DeviceLimeSDRParams::open: cannot get the Rx sample rate range for device " << deviceStr; return false; } - if (LMS_GetSampleRateRange(m_dev, LMS_CH_TX, &m_srRangeTx) != 0) + if (LMS_GetSampleRateRange(m_dev, LMS_CH_TX, &m_srRangeTx) < 0) { qDebug() << "DeviceLimeSDRParams::open: cannot get the Tx sample rate range for device " << deviceStr; return false; diff --git a/plugins/samplesource/limesdrinput/limesdrinput.cpp b/plugins/samplesource/limesdrinput/limesdrinput.cpp index 49127d370..4f45758d8 100644 --- a/plugins/samplesource/limesdrinput/limesdrinput.cpp +++ b/plugins/samplesource/limesdrinput/limesdrinput.cpp @@ -240,6 +240,7 @@ void LimeSDRInput::getLORange(float& minF, float& maxF, float& stepF) const minF = range.min; maxF = range.max; stepF = range.step; + qDebug("LimeSDRInput::getLORange: min: %f max: %f step: %f", range.min, range.max, range.step); } void LimeSDRInput::getSRRange(float& minF, float& maxF, float& stepF) const @@ -248,26 +249,31 @@ void LimeSDRInput::getSRRange(float& minF, float& maxF, float& stepF) const minF = range.min; maxF = range.max; stepF = range.step; + qDebug("LimeSDRInput::getSRRange: min: %f max: %f step: %f", range.min, range.max, range.step); } void LimeSDRInput::getLPRange(float& minF, float& maxF, float& stepF) const { lms_range_t range = m_deviceShared.m_deviceParams->m_lpfRangeRx; + float step = range.step < 1000.0f ? 1000.0 : range.step; minF = range.min; maxF = range.max; - stepF = range.step; + stepF = step; + qDebug("LimeSDRInput::getLPRange: min: %f max: %f step: %f", range.min, range.max, range.step); } int LimeSDRInput::getLPIndex(float lpfBW) const { lms_range_t range = m_deviceShared.m_deviceParams->m_lpfRangeRx; - return (int) ((lpfBW - range.min) / range.step); + float step = range.step < 1000.0f ? 1000.0 : range.step; + return (int) ((lpfBW - range.min) / step); } float LimeSDRInput::getLPValue(int index) const { lms_range_t range = m_deviceShared.m_deviceParams->m_lpfRangeRx; - return range.min + index * range.step; + float step = range.step < 1000.0f ? 1000.0 : range.step; + return index * step; } uint32_t LimeSDRInput::getHWLog2Decim() const @@ -309,8 +315,6 @@ bool LimeSDRInput::applySettings(const LimeSDRInputSettings& settings, bool forc bool forwardChangeAllDSP = false; // QMutexLocker mutexLocker(&m_mutex); - qDebug() << "LimeSDRInput::applySettings"; - if ((m_settings.m_dcBlock != settings.m_dcBlock) || force) { m_settings.m_dcBlock = settings.m_dcBlock; @@ -380,10 +384,10 @@ bool LimeSDRInput::applySettings(const LimeSDRInputSettings& settings, bool forc if (m_deviceShared.m_deviceParams->getDevice() != 0) { - if (LMS_SetLPF(m_deviceShared.m_deviceParams->getDevice(), + if (LMS_SetLPFBW(m_deviceShared.m_deviceParams->getDevice(), LMS_CH_RX, m_deviceShared.m_channel, - m_settings.m_lpfBW)) + m_settings.m_lpfBW) < 0) { qCritical("LimeSDRInput::applySettings: could not set LPF to %f Hz", m_settings.m_lpfBW); } @@ -406,7 +410,7 @@ bool LimeSDRInput::applySettings(const LimeSDRInputSettings& settings, bool forc LMS_CH_RX, m_deviceShared.m_channel, m_settings.m_lpfFIREnable, - m_settings.m_lpfFIRBW)) + m_settings.m_lpfFIRBW) < 0) { qCritical("LimeSDRInput::applySettings: could %s and set LPF FIR to %f Hz", m_settings.m_lpfFIREnable ? "enable" : "disable", @@ -435,16 +439,21 @@ bool LimeSDRInput::applySettings(const LimeSDRInputSettings& settings, bool forc if ((m_settings.m_centerFrequency != settings.m_centerFrequency) || force) { + m_settings.m_centerFrequency = settings.m_centerFrequency; forwardChangeRxDSP = true; - if (m_deviceShared.m_deviceParams->getDevice() != NULL) + if (m_deviceShared.m_deviceParams->getDevice() != 0) { if (LMS_SetLOFrequency(m_deviceShared.m_deviceParams->getDevice(), LMS_CH_RX, m_deviceShared.m_channel, // same for both channels anyway but switches antenna port automatically - m_settings.m_centerFrequency ) != 0) + m_settings.m_centerFrequency ) < 0) { - qDebug("LimeSDRInput::applySettings: LMS_SetLOFrequency(%lu) failed", m_settings.m_centerFrequency); + qCritical("LimeSDRInput::applySettings: could not set frequency to %lu", m_settings.m_centerFrequency); + } + else + { + qDebug("LimeSDRInput::applySettings: frequency set to %lu", m_settings.m_centerFrequency); } } } @@ -506,7 +515,7 @@ bool LimeSDRInput::applySettings(const LimeSDRInputSettings& settings, bool forc qDebug() << "LimeSDRInput::applySettings: center freq: " << m_settings.m_centerFrequency << " Hz" << " device sample rate: " << m_settings.m_devSampleRate << "S/s" - << " Actual sample rate: " << m_settings.m_devSampleRate/(1<lpf->setMinimum(minLP); ui->lpf->setMaximum(maxLP); + ui->lpFIR->setColorMapper(ColorMapper(ColorMapper::ReverseGold)); + ui->lpFIR->setValueRange(5, 1U, 56000U); + ui->channelNumberText->setText(tr("#%1").arg(m_limeSDRInput->getChannelIndex())); connect(&m_updateTimer, SIGNAL(timeout()), this, SLOT(updateHardware())); @@ -200,11 +203,11 @@ void LimeSDRInputGUI::displaySettings() ui->hwDecim->setCurrentIndex(m_settings.m_log2HardDecim); ui->swDecim->setCurrentIndex(m_settings.m_log2SoftDecim); - ui->lpf->setValue(m_limeSDRInput->getLPIndex(m_settings.m_lpfFIRBW)); - ui->lpfText->setText(tr("%1k").arg(QString::number(m_settings.m_lpfFIRBW / 1000.0f, 'f', 0))); + ui->lpf->setValue(m_limeSDRInput->getLPIndex(m_settings.m_lpfBW)); + ui->lpfText->setText(tr("%1k").arg(QString::number(m_settings.m_lpfBW / 1000.0f, 'f', 0))); ui->lpFIREnable->setChecked(m_settings.m_lpfFIREnable); - ui->sampleRate->setValue(m_settings.m_lpfFIRBW); + ui->lpFIR->setValue(m_settings.m_lpfFIRBW / 1000); ui->gain->setValue(m_settings.m_gain); ui->gainText->setText(tr("%1dB").arg(m_settings.m_gain)); @@ -334,6 +337,7 @@ void LimeSDRInputGUI::on_swDecim_currentIndexChanged(int index) void LimeSDRInputGUI::on_lpf_valueChanged(int value) { m_settings.m_lpfBW = m_limeSDRInput->getLPValue(value); + ui->lpfText->setText(tr("%1k").arg(QString::number(m_settings.m_lpfBW / 1000.0f, 'f', 0))); sendSettings(); } @@ -345,7 +349,7 @@ void LimeSDRInputGUI::on_lpFIREnable_toggled(bool checked) void LimeSDRInputGUI::on_lpFIR_changed(quint64 value) { - m_settings.m_lpfFIRBW = value; + m_settings.m_lpfFIRBW = value * 1000; sendSettings(); } diff --git a/plugins/samplesource/limesdrinput/limesdrinputgui.ui b/plugins/samplesource/limesdrinput/limesdrinputgui.ui index 01d7c5903..daf79c919 100644 --- a/plugins/samplesource/limesdrinput/limesdrinputgui.ui +++ b/plugins/samplesource/limesdrinput/limesdrinputgui.ui @@ -6,7 +6,7 @@ 0 0 - 310 + 340 265 @@ -18,7 +18,7 @@ - 310 + 340 250 @@ -456,6 +456,9 @@ Analog lowpass filter bandwidth (kHz) + + 1 + Qt::Horizontal diff --git a/plugins/samplesource/limesdrinput/limesdrinputplugin.cpp b/plugins/samplesource/limesdrinput/limesdrinputplugin.cpp index dc070f57c..7f6a5be86 100644 --- a/plugins/samplesource/limesdrinput/limesdrinputplugin.cpp +++ b/plugins/samplesource/limesdrinput/limesdrinputplugin.cpp @@ -80,22 +80,16 @@ PluginInterface::SamplingDevices LimeSDRInputPlugin::enumSampleSources() { for (int i = 0; i < nbDevices; i++) { - std::string serial; + std::string serial("N/D"); + findSerial((const char *) deviceList[i], serial); - if (findSerial((const char *) deviceList[i], serial)) - { - qDebug("LimeSDRInputPlugin::enumSampleSources: device #%d: %s", i, (char *) deviceList[i]); - QString displayedName(QString("LimeSDR[%1] %2").arg(i).arg(serial.c_str())); - result.append(SamplingDevice(displayedName, - m_hardwareID, - m_deviceTypeID, - QString(serial.c_str()), - i)); - } - else - { - qDebug("LimeSDRInputPlugin::enumSampleSources: device #%d: cannot find serial in %s", i, (char *) deviceList[i]); - } + qDebug("LimeSDRInputPlugin::enumSampleSources: device #%d: %s", i, (char *) deviceList[i]); + QString displayedName(QString("LimeSDR[%1] %2").arg(i).arg(serial.c_str())); + result.append(SamplingDevice(displayedName, + m_hardwareID, + m_deviceTypeID, + QString(deviceList[i]), + i)); } }