From 0847a8464c7fe8b2dc873f9c783f7101fd08ca1f Mon Sep 17 00:00:00 2001 From: f4exb Date: Wed, 19 Apr 2017 01:04:57 +0200 Subject: [PATCH] LimeSDR input: fixed message passing between buddies --- .../limesdrinput/limesdrinput.cpp | 38 +++++++++++++++++-- .../limesdrinput/limesdrinputgui.cpp | 6 +-- 2 files changed, 37 insertions(+), 7 deletions(-) diff --git a/plugins/samplesource/limesdrinput/limesdrinput.cpp b/plugins/samplesource/limesdrinput/limesdrinput.cpp index e0868a558..db4758a0f 100644 --- a/plugins/samplesource/limesdrinput/limesdrinput.cpp +++ b/plugins/samplesource/limesdrinput/limesdrinput.cpp @@ -65,6 +65,8 @@ bool LimeSDRInput::openDevice() // if there is a channel left take the first available if (m_deviceAPI->getSourceBuddies().size() > 0) // look source sibling first { + qDebug("LimeSDRInput::openDevice: look in Rx buddies"); + DeviceSourceAPI *sourceBuddy = m_deviceAPI->getSourceBuddies()[0]; m_deviceShared = *((DeviceLimeSDRShared *) sourceBuddy->getBuddySharedPtr()); // copy shared data DeviceLimeSDRParams *deviceParams = m_deviceShared.m_deviceParams; // get device parameters @@ -74,11 +76,21 @@ bool LimeSDRInput::openDevice() qCritical("LimeSDRInput::openDevice: cannot get device parameters from Rx buddy"); return false; // the device params should have been created by the buddy } + else + { + qDebug("LimeSDRInput::openDevice: getting device parameters from Rx buddy"); + } if (m_deviceAPI->getSourceBuddies().size() == deviceParams->m_nbRxChannels) { + qCritical("LimeSDRInput::openDevice: no more Rx channels available in device"); return false; // no more Rx channels available in device } + else + { + qDebug("LimeSDRInput::openDevice: at least one more Rx channel is available in device"); + } + // look for unused channel number char *busyChannels = new char[deviceParams->m_nbRxChannels]; memset(busyChannels, 0, deviceParams->m_nbRxChannels); @@ -106,6 +118,8 @@ bool LimeSDRInput::openDevice() // take the first Rx channel else if (m_deviceAPI->getSinkBuddies().size() > 0) // then sink { + qDebug("LimeSDRInput::openDevice: look in Tx buddies"); + DeviceSinkAPI *sinkBuddy = m_deviceAPI->getSinkBuddies()[0]; m_deviceShared = *((DeviceLimeSDRShared *) sinkBuddy->getBuddySharedPtr()); // copy parameters @@ -114,6 +128,10 @@ bool LimeSDRInput::openDevice() qCritical("LimeSDRInput::openDevice: cannot get device parameters from Tx buddy"); return false; // the device params should have been created by the buddy } + else + { + qDebug("LimeSDRInput::openDevice: getting device parameters from Tx buddy"); + } m_deviceShared.m_channel = 0; // take first channel } @@ -122,6 +140,8 @@ bool LimeSDRInput::openDevice() // take the first Rx channel else { + qDebug("LimeSDRInput::openDevice: open device here"); + m_deviceShared.m_deviceParams = new DeviceLimeSDRParams(); char serial[256]; strcpy(serial, qPrintable(m_deviceAPI->getSampleSourceSerial())); @@ -138,6 +158,10 @@ bool LimeSDRInput::openDevice() qCritical("LimeSDRInput::openDevice: cannot enable Rx channel %lu", m_deviceShared.m_channel); return false; } + else + { + qDebug("LimeSDRInput::openDevice: Rx channel %lu enabled", m_deviceShared.m_channel); + } return true; } @@ -305,7 +329,7 @@ bool LimeSDRInput::handleMessage(const Message& message) else if (MsgSetReferenceConfig::match(message)) { MsgSetReferenceConfig& conf = (MsgSetReferenceConfig&) message; - qDebug() << "LimeSDRInput::handleMessage: MsgSetReferenceLimeSDR"; + qDebug() << "LimeSDRInput::handleMessage: MsgSetReferenceConfig"; m_settings = conf.getSettings(); return true; } @@ -526,6 +550,8 @@ bool LimeSDRInput::applySettings(const LimeSDRInputSettings& settings, bool forc if (forwardChangeAllDSP) { + qDebug("LimeSDRInput::applySettings: forward change to all buddies"); + const std::vector& sourceBuddies = m_deviceAPI->getSourceBuddies(); std::vector::const_iterator itSource = sourceBuddies.begin(); int sampleRate = m_settings.m_devSampleRate/(1<getDeviceInputMessageQueue()->push(report); + (*itSource)->getDeviceOutputMessageQueue()->push(report); } // send to sink buddies @@ -558,11 +584,13 @@ bool LimeSDRInput::applySettings(const LimeSDRInputSettings& settings, bool forc m_settings.m_centerFrequency, m_settings.m_devSampleRate, m_settings.m_log2HardDecim); - (*itSink)->getDeviceInputMessageQueue()->push(report); + (*itSink)->getDeviceOutputMessageQueue()->push(report); } } else if (forwardChangeRxDSP) { + qDebug("LimeSDRInput::applySettings: forward change to Rx buddies"); + const std::vector& sourceBuddies = m_deviceAPI->getSourceBuddies(); std::vector::const_iterator it = sourceBuddies.begin(); int sampleRate = m_settings.m_devSampleRate/(1<getDeviceInputMessageQueue()->push(report); + (*it)->getDeviceOutputMessageQueue()->push(report); } } else if (forwardChangeOwnDSP) { + qDebug("LimeSDRInput::applySettings: forward change to self only"); + int sampleRate = m_settings.m_devSampleRate/(1<getDeviceInputMessageQueue()->push(notif); diff --git a/plugins/samplesource/limesdrinput/limesdrinputgui.cpp b/plugins/samplesource/limesdrinput/limesdrinputgui.cpp index 6962a157e..c794c0d04 100644 --- a/plugins/samplesource/limesdrinput/limesdrinputgui.cpp +++ b/plugins/samplesource/limesdrinput/limesdrinputgui.cpp @@ -166,7 +166,7 @@ void LimeSDRInputGUI::handleMessagesToGUI() { LimeSDRInput::MsgReportLimeSDRToGUI *report = (LimeSDRInput::MsgReportLimeSDRToGUI *) message; - m_settings.m_centerFrequency = report->getCenterFrequency() / 1000; + m_settings.m_centerFrequency = report->getCenterFrequency(); m_settings.m_devSampleRate = report->getSampleRate(); m_settings.m_log2HardDecim = report->getLog2HardDecim(); @@ -174,8 +174,8 @@ void LimeSDRInputGUI::handleMessagesToGUI() displaySettings(); blockApplySettings(false); - LimeSDRInput::MsgSetReferenceConfig* message = LimeSDRInput::MsgSetReferenceConfig::create(m_settings); - m_sampleSource->getInputMessageQueue()->push(message); + LimeSDRInput::MsgSetReferenceConfig* conf = LimeSDRInput::MsgSetReferenceConfig::create(m_settings); + m_sampleSource->getInputMessageQueue()->push(conf); delete message; }