1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-22 16:08:39 -05:00

Merge pull request #954 from fventuri/fix_RfUpdateErrors_in_sdrplayv3

Fix rf update errors in sdrplayv3
This commit is contained in:
Edouard Griffiths 2021-07-07 00:05:15 +02:00 committed by GitHub
commit 6a5a65a1ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 36 additions and 1 deletions

View File

@ -464,8 +464,11 @@ bool SDRPlayV3Input::applySettings(const SDRPlayV3Settings& settings, bool forwa
m_devParams->rxChannelA->tunerParams.bwType = SDRPlayV3Bandwidths::getBandwidthEnum(settings.m_bandwidthIndex);
else
m_devParams->rxChannelB->tunerParams.bwType = SDRPlayV3Bandwidths::getBandwidthEnum(settings.m_bandwidthIndex);
m_sdrPlayThread->resetRfChanged();
if ((err = sdrplay_api_Update(m_dev->dev, m_dev->tuner, sdrplay_api_Update_Tuner_BwType, sdrplay_api_Update_Ext1_None)) != sdrplay_api_Success)
qCritical() << "SDRPlayV3Input::applySettings: could not set bandwidth: " << sdrplay_api_GetErrorString(err);
if (!m_sdrPlayThread->waitForRfChanged())
qCritical() << "SDRPlayV3Input::applySettings: could not set bandwidth: Rf update timed out";
}
}
@ -479,8 +482,11 @@ bool SDRPlayV3Input::applySettings(const SDRPlayV3Settings& settings, bool forwa
m_devParams->rxChannelA->tunerParams.ifType = SDRPlayV3IF::getIFEnum(settings.m_ifFrequencyIndex);
else
m_devParams->rxChannelB->tunerParams.ifType = SDRPlayV3IF::getIFEnum(settings.m_ifFrequencyIndex);
m_sdrPlayThread->resetRfChanged();
if ((err = sdrplay_api_Update(m_dev->dev, m_dev->tuner, sdrplay_api_Update_Tuner_IfType, sdrplay_api_Update_Ext1_None)) != sdrplay_api_Success)
qCritical() << "SDRPlayV3Input::applySettings: could not set IF frequency: " << sdrplay_api_GetErrorString(err);
if (!m_sdrPlayThread->waitForRfChanged())
qCritical() << "SDRPlayV3Input::applySettings: could not set IF frequency: Rf update timed out";
}
}
@ -714,9 +720,15 @@ bool SDRPlayV3Input::setDeviceCenterFrequency(quint64 freq_hz)
m_devParams->rxChannelA->tunerParams.rfFreq.rfHz = (double)freq_hz;
else
m_devParams->rxChannelB->tunerParams.rfFreq.rfHz = (double)freq_hz;
m_sdrPlayThread->resetRfChanged();
if ((err = sdrplay_api_Update(m_dev->dev, m_dev->tuner, sdrplay_api_Update_Tuner_Frf, sdrplay_api_Update_Ext1_None)) != sdrplay_api_Success)
{
qWarning("SDRPlayV3Input::setDeviceCenterFrequency: could not frequency to %llu Hz", freq_hz);
qWarning("SDRPlayV3Input::setDeviceCenterFrequency: could not set frequency to %llu Hz", freq_hz);
return false;
}
else if (!m_sdrPlayThread->waitForRfChanged())
{
qWarning() << "SDRPlayV3Input::setDeviceCenterFrequency: could not set frequency: Rf update timed out";
return false;
}
else

View File

@ -18,6 +18,8 @@
#include <stdio.h>
#include <errno.h>
#include <chrono>
#include <thread>
#include "sdrplayv3thread.h"
#include "dsp/samplesinkfifo.h"
@ -77,6 +79,18 @@ void SDRPlayV3Thread::setFcPos(int fcPos)
m_fcPos = fcPos;
}
void SDRPlayV3Thread::resetRfChanged()
{
m_rfChanged = 0;
}
bool SDRPlayV3Thread::waitForRfChanged()
{
for (unsigned int i = 0; i < m_rfChangedTimeout && m_rfChanged == 0; i++)
std::this_thread::sleep_for(std::chrono::milliseconds(1));
return m_rfChanged != 0;
}
// Don't really need a thread here - just using same structure as other plugins
void SDRPlayV3Thread::run()
{
@ -111,6 +125,9 @@ void SDRPlayV3Thread::callbackHelper(short *xi, short *xq, sdrplay_api_StreamCbP
SDRPlayV3Thread* thread = (SDRPlayV3Thread*) ctx;
qint16 iq[8192];
if (params->rfChanged)
thread->m_rfChanged = params->rfChanged;
if (thread->m_running)
{
if (numSamples > 8192)

View File

@ -41,6 +41,9 @@ public:
void setLog2Decimation(unsigned int log2_decim);
void setFcPos(int fcPos);
void resetRfChanged();
bool waitForRfChanged();
private:
QMutex m_startWaitMutex;
QWaitCondition m_startWaiter;
@ -54,6 +57,9 @@ private:
unsigned int m_log2Decim;
int m_fcPos;
int m_rfChanged;
static const unsigned int m_rfChangedTimeout = 500;
Decimators<qint32, qint16, SDR_RX_SAMP_SZ, 16, true> m_decimatorsIQ;
void run();