1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2026-06-02 06:04:39 -04:00

LimeSDR: handle clock source change in source and sink

This commit is contained in:
f4exb
2017-11-04 02:18:16 +01:00
parent 465416ee19
commit 2ec8270e99
10 changed files with 206 additions and 2 deletions
@@ -538,6 +538,19 @@ bool LimeSDRInput::handleMessage(const Message& message)
return true;
}
else if (DeviceLimeSDRShared::MsgReportClockSourceChange::match(message))
{
DeviceLimeSDRShared::MsgReportClockSourceChange& report = (DeviceLimeSDRShared::MsgReportClockSourceChange&) message;
m_settings.m_extClock = report.getExtClock();
m_settings.m_extClockFreq = report.getExtClockFeq();
DeviceLimeSDRShared::MsgReportClockSourceChange *reportToGUI = DeviceLimeSDRShared::MsgReportClockSourceChange::create(
m_settings.m_extClock, m_settings.m_extClockFreq);
getMessageQueueToGUI()->push(reportToGUI);
return true;
}
else if (MsgGetStreamInfo::match(message))
{
// qDebug() << "LimeSDRInput::handleMessage: MsgGetStreamInfo";
@@ -653,6 +666,7 @@ bool LimeSDRInput::applySettings(const LimeSDRInputSettings& settings, bool forc
bool forwardChangeOwnDSP = false;
bool forwardChangeRxDSP = false;
bool forwardChangeAllDSP = false;
bool forwardClockSource = false;
bool ownThreadWasRunning = false;
bool doCalibration = false;
bool setAntennaAuto = false;
@@ -972,6 +986,28 @@ bool LimeSDRInput::applySettings(const LimeSDRInputSettings& settings, bool forc
}
}
if ((m_settings.m_extClock != settings.m_extClock) ||
(m_settings.m_extClockFreq != settings.m_extClockFreq) || force)
{
if (DeviceLimeSDR::setClockSource(m_deviceShared.m_deviceParams->getDevice(),
settings.m_extClock,
settings.m_extClockFreq))
{
forwardClockSource = true;
doCalibration = true;
qDebug("LimeSDRInput::applySettings: clock set to %s (Ext: %d Hz)",
settings.m_extClock ? "external" : "internal",
settings.m_extClockFreq);
}
else
{
qCritical("LimeSDRInput::applySettings: could not set clock to %s (Ext: %d Hz)",
settings.m_extClock ? "external" : "internal",
settings.m_extClockFreq);
}
}
m_settings = settings;
double clockGenFreqAfter;
@@ -1086,6 +1122,31 @@ bool LimeSDRInput::applySettings(const LimeSDRInputSettings& settings, bool forc
m_deviceAPI->getDeviceEngineInputMessageQueue()->push(notif);
}
if (forwardClockSource)
{
// send to source buddies
const std::vector<DeviceSourceAPI*>& sourceBuddies = m_deviceAPI->getSourceBuddies();
std::vector<DeviceSourceAPI*>::const_iterator itSource = sourceBuddies.begin();
for (; itSource != sourceBuddies.end(); ++itSource)
{
DeviceLimeSDRShared::MsgReportClockSourceChange *report = DeviceLimeSDRShared::MsgReportClockSourceChange::create(
m_settings.m_extClock, m_settings.m_extClockFreq);
(*itSource)->getSampleSourceInputMessageQueue()->push(report);
}
// send to sink buddies
const std::vector<DeviceSinkAPI*>& sinkBuddies = m_deviceAPI->getSinkBuddies();
std::vector<DeviceSinkAPI*>::const_iterator itSink = sinkBuddies.begin();
for (; itSink != sinkBuddies.end(); ++itSink)
{
DeviceLimeSDRShared::MsgReportClockSourceChange *report = DeviceLimeSDRShared::MsgReportClockSourceChange::create(
m_settings.m_extClock, m_settings.m_extClockFreq);
(*itSink)->getSampleSinkInputMessageQueue()->push(report);
}
}
qDebug() << "LimeSDRInput::applySettings: center freq: " << m_settings.m_centerFrequency << " Hz"
<< " device stream sample rate: " << m_settings.m_devSampleRate << "S/s"
<< " sample rate with soft decimation: " << m_settings.m_devSampleRate/(1<<m_settings.m_log2SoftDecim) << "S/s"
@@ -1095,7 +1156,9 @@ bool LimeSDRInput::applySettings(const LimeSDRInputSettings& settings, bool forc
<< " m_lpfFIREnable: " << m_settings.m_lpfFIREnable
<< " m_ncoEnable: " << m_settings.m_ncoEnable
<< " m_ncoFrequency: " << m_settings.m_ncoFrequency
<< " m_antennaPath: " << m_settings.m_antennaPath;
<< " m_antennaPath: " << m_settings.m_antennaPath
<< " m_extClock: " << m_settings.m_extClock
<< " m_extClockFreq: " << m_settings.m_extClockFreq;
return true;
}