From 763175ab552df40376fa35a79e6e43673716b231 Mon Sep 17 00:00:00 2001 From: f4exb Date: Tue, 18 Apr 2017 23:26:30 +0200 Subject: [PATCH] LimeSDR input: suspend thread while changing configuration --- .../limesdrinput/limesdrinput.cpp | 38 ++++++++++++++++++- .../limesdrinput/limesdrinputsettings.cpp | 8 ++-- 2 files changed, 41 insertions(+), 5 deletions(-) diff --git a/plugins/samplesource/limesdrinput/limesdrinput.cpp b/plugins/samplesource/limesdrinput/limesdrinput.cpp index 5649d316e..998e42aff 100644 --- a/plugins/samplesource/limesdrinput/limesdrinput.cpp +++ b/plugins/samplesource/limesdrinput/limesdrinput.cpp @@ -211,7 +211,6 @@ bool LimeSDRInput::start() m_limeSDRInputThread->startWork(); - applySettings(m_settings, true); m_running = true; return true; @@ -322,6 +321,7 @@ bool LimeSDRInput::applySettings(const LimeSDRInputSettings& settings, bool forc bool forwardChangeRxDSP = false; bool forwardChangeAllDSP = false; bool doCalibration = false; + bool threadStopped = false; // QMutexLocker mutexLocker(&m_mutex); if ((m_settings.m_dcBlock != settings.m_dcBlock) || force) @@ -342,6 +342,12 @@ bool LimeSDRInput::applySettings(const LimeSDRInputSettings& settings, bool forc if (m_deviceShared.m_deviceParams->getDevice() != 0) { + if (m_limeSDRInputThread && !threadStopped) + { + m_limeSDRInputThread->stopWork(); + threadStopped = true; + } + if (LMS_SetGaindB(m_deviceShared.m_deviceParams->getDevice(), LMS_CH_RX, m_deviceShared.m_channel, @@ -368,6 +374,12 @@ bool LimeSDRInput::applySettings(const LimeSDRInputSettings& settings, bool forc if (m_deviceShared.m_deviceParams->getDevice() != 0) { + if (m_limeSDRInputThread && !threadStopped) + { + m_limeSDRInputThread->stopWork(); + threadStopped = true; + } + if (LMS_SetSampleRateDir(m_deviceShared.m_deviceParams->getDevice(), LMS_CH_RX, m_settings.m_devSampleRate, @@ -395,6 +407,12 @@ bool LimeSDRInput::applySettings(const LimeSDRInputSettings& settings, bool forc if (m_deviceShared.m_deviceParams->getDevice() != 0) { + if (m_limeSDRInputThread && !threadStopped) + { + m_limeSDRInputThread->stopWork(); + threadStopped = true; + } + if (LMS_SetLPFBW(m_deviceShared.m_deviceParams->getDevice(), LMS_CH_RX, m_deviceShared.m_channel, @@ -418,6 +436,12 @@ bool LimeSDRInput::applySettings(const LimeSDRInputSettings& settings, bool forc if (m_deviceShared.m_deviceParams->getDevice() != 0) { + if (m_limeSDRInputThread && !threadStopped) + { + m_limeSDRInputThread->stopWork(); + threadStopped = true; + } + if (LMS_SetGFIRLPF(m_deviceShared.m_deviceParams->getDevice(), LMS_CH_RX, m_deviceShared.m_channel, @@ -457,6 +481,12 @@ bool LimeSDRInput::applySettings(const LimeSDRInputSettings& settings, bool forc if (m_deviceShared.m_deviceParams->getDevice() != 0) { + if (m_limeSDRInputThread && !threadStopped) + { + m_limeSDRInputThread->stopWork(); + threadStopped = true; + } + 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 @@ -488,6 +518,12 @@ bool LimeSDRInput::applySettings(const LimeSDRInputSettings& settings, bool forc } } + if (threadStopped) + { + m_limeSDRInputThread->startWork(); + threadStopped = false; + } + if (forwardChangeAllDSP) { const std::vector& sourceBuddies = m_deviceAPI->getSourceBuddies(); diff --git a/plugins/samplesource/limesdrinput/limesdrinputsettings.cpp b/plugins/samplesource/limesdrinput/limesdrinputsettings.cpp index c86276a62..052cfadb8 100644 --- a/plugins/samplesource/limesdrinput/limesdrinputsettings.cpp +++ b/plugins/samplesource/limesdrinput/limesdrinputsettings.cpp @@ -25,15 +25,15 @@ LimeSDRInputSettings::LimeSDRInputSettings() void LimeSDRInputSettings::resetToDefaults() { m_centerFrequency = 435000*1000; - m_devSampleRate = 6000000; - m_log2HardDecim = 2; + m_devSampleRate = 5000000; + m_log2HardDecim = 3; m_dcBlock = false; m_iqCorrection = false; m_log2SoftDecim = 0; m_fcPos = FC_POS_CENTER; - m_lpfBW = 1.5e6f; + m_lpfBW = 4.5e6f; m_lpfFIREnable = false; - m_lpfFIRBW = 1.5e6f; + m_lpfFIRBW = 2.5e6f; m_gain = 0; }