From d1061a3c2f84130e95ff148cec4ece049466080f Mon Sep 17 00:00:00 2001 From: f4exb Date: Wed, 20 Sep 2017 18:25:54 +0200 Subject: [PATCH] LimeSDR: Rx/Tx interaction --- devices/plutosdr/deviceplutosdrshared.cpp | 2 ++ devices/plutosdr/deviceplutosdrshared.h | 14 +++++--- .../plutosdroutput/plutosdroutput.cpp | 32 ++++++++++++++++++ .../plutosdroutput/plutosdroutputgui.cpp | 19 ++++++++++- .../plutosdrinput/plutosdrinput.cpp | 33 +++++++++++++++++++ .../plutosdrinput/plutosdrinputgui.cpp | 19 ++++++++++- 6 files changed, 113 insertions(+), 6 deletions(-) diff --git a/devices/plutosdr/deviceplutosdrshared.cpp b/devices/plutosdr/deviceplutosdrshared.cpp index d3d30bc0e..227aeeb61 100644 --- a/devices/plutosdr/deviceplutosdrshared.cpp +++ b/devices/plutosdr/deviceplutosdrshared.cpp @@ -16,5 +16,7 @@ #include "deviceplutosdrshared.h" +MESSAGE_CLASS_DEFINITION(DevicePlutoSDRShared::MsgCrossReportToBuddy, Message) + const float DevicePlutoSDRShared::m_sampleFifoLengthInSeconds = 0.25; const int DevicePlutoSDRShared::m_sampleFifoMinSize = 48000; // 192kS/s knee diff --git a/devices/plutosdr/deviceplutosdrshared.h b/devices/plutosdr/deviceplutosdrshared.h index bf3411b03..211da350c 100644 --- a/devices/plutosdr/deviceplutosdrshared.h +++ b/devices/plutosdr/deviceplutosdrshared.h @@ -48,34 +48,40 @@ public: uint32_t getLpfFirbw() const { return m_lpfFIRBW; } bool isLpfFirEnable() const { return m_lpfFIREnable; } uint32_t getLpfFiRlog2IntDec() const { return m_lpfFIRlogIntDec; } + int32_t getLoPPMTenths() const { return m_loPPMTenths; } static MsgCrossReportToBuddy *create(uint64_t devSampleRate, bool lpfFIREnable, uint32_t lpfFIRlog2Interp, - uint32_t lpfFIRBW) + uint32_t lpfFIRBW, + int32_t loPPMTenths) { return new MsgCrossReportToBuddy(devSampleRate, lpfFIREnable, lpfFIRlog2Interp, - lpfFIRBW); + lpfFIRBW, + loPPMTenths); } private: MsgCrossReportToBuddy(uint64_t devSampleRate, bool lpfFIREnable, uint32_t lpfFIRlog2IntDec, - uint32_t lpfFIRBW) : + uint32_t lpfFIRBW, + int32_t loPPMTenths) : Message(), m_devSampleRate(devSampleRate), m_lpfFIREnable(lpfFIREnable), m_lpfFIRlogIntDec(lpfFIRlog2IntDec), - m_lpfFIRBW(lpfFIRBW) + m_lpfFIRBW(lpfFIRBW), + m_loPPMTenths(loPPMTenths) { } uint64_t m_devSampleRate; bool m_lpfFIREnable; uint32_t m_lpfFIRlogIntDec; uint32_t m_lpfFIRBW; + int32_t m_loPPMTenths; }; DevicePlutoSDRParams *m_deviceParams; //!< unique hardware device parameters diff --git a/plugins/samplesink/plutosdroutput/plutosdroutput.cpp b/plugins/samplesink/plutosdroutput/plutosdroutput.cpp index 430839baa..c9c6424ff 100644 --- a/plugins/samplesink/plutosdroutput/plutosdroutput.cpp +++ b/plugins/samplesink/plutosdroutput/plutosdroutput.cpp @@ -128,6 +128,17 @@ bool PlutoSDROutput::handleMessage(const Message& message) return true; } + else if (DevicePlutoSDRShared::MsgCrossReportToBuddy::match(message)) // message from buddy + { + DevicePlutoSDRShared::MsgCrossReportToBuddy& conf = (DevicePlutoSDRShared::MsgCrossReportToBuddy&) message; + m_settings.m_devSampleRate = conf.getDevSampleRate(); + m_settings.m_lpfFIRlog2Interp = conf.getLpfFiRlog2IntDec(); + m_settings.m_lpfFIRBW = conf.getLpfFirbw(); + m_settings.m_LOppmTenths = conf.getLoPPMTenths(); + PlutoSDROutputSettings newSettings = m_settings; + newSettings.m_lpfFIREnable = conf.isLpfFirEnable(); + applySettings(newSettings); + } else { return false; @@ -391,6 +402,27 @@ bool PlutoSDROutput::applySettings(const PlutoSDROutputSettings& settings, bool if (forwardChangeOtherDSP) { qDebug("PlutoSDROutput::applySettings: forwardChangeOtherDSP"); + + const std::vector& sourceBuddies = m_deviceAPI->getSourceBuddies(); + std::vector::const_iterator itSource = sourceBuddies.begin(); + + for (; itSource != sourceBuddies.end(); ++itSource) + { + DevicePlutoSDRShared::MsgCrossReportToBuddy *msg = DevicePlutoSDRShared::MsgCrossReportToBuddy::create( + settings.m_devSampleRate, + settings.m_lpfFIREnable, + settings.m_lpfFIRlog2Interp, + settings.m_lpfFIRBW, + settings.m_LOppmTenths); + + if ((*itSource)->getSampleSourceGUIMessageQueue()) + { + DevicePlutoSDRShared::MsgCrossReportToBuddy *msgToGUI = new DevicePlutoSDRShared::MsgCrossReportToBuddy(*msg); + (*itSource)->getSampleSourceGUIMessageQueue()->push(msgToGUI); + } + + (*itSource)->getSampleSourceInputMessageQueue()->push(msg); + } } if (forwardChangeOwnDSP) diff --git a/plugins/samplesink/plutosdroutput/plutosdroutputgui.cpp b/plugins/samplesink/plutosdroutput/plutosdroutputgui.cpp index c52f83c21..cd81c7aa0 100644 --- a/plugins/samplesink/plutosdroutput/plutosdroutputgui.cpp +++ b/plugins/samplesink/plutosdroutput/plutosdroutputgui.cpp @@ -130,7 +130,24 @@ bool PlutoSDROutputGUI::deserialize(const QByteArray& data) bool PlutoSDROutputGUI::handleMessage(const Message& message __attribute__((unused))) { - return false; + if (DevicePlutoSDRShared::MsgCrossReportToBuddy::match(message)) // message from buddy + { + DevicePlutoSDRShared::MsgCrossReportToBuddy& conf = (DevicePlutoSDRShared::MsgCrossReportToBuddy&) message; + m_settings.m_devSampleRate = conf.getDevSampleRate(); + m_settings.m_lpfFIRlog2Interp = conf.getLpfFiRlog2IntDec(); + m_settings.m_lpfFIRBW = conf.getLpfFirbw(); + m_settings.m_LOppmTenths = conf.getLoPPMTenths(); + m_settings.m_lpfFIREnable = conf.isLpfFirEnable(); + blockApplySettings(true); + displaySettings(); + blockApplySettings(false); + + return true; + } + else + { + return false; + } } void PlutoSDROutputGUI::on_startStop_toggled(bool checked) diff --git a/plugins/samplesource/plutosdrinput/plutosdrinput.cpp b/plugins/samplesource/plutosdrinput/plutosdrinput.cpp index e9e043547..c54049b74 100644 --- a/plugins/samplesource/plutosdrinput/plutosdrinput.cpp +++ b/plugins/samplesource/plutosdrinput/plutosdrinput.cpp @@ -150,6 +150,17 @@ bool PlutoSDRInput::handleMessage(const Message& message) return true; } + else if (DevicePlutoSDRShared::MsgCrossReportToBuddy::match(message)) // message from buddy + { + DevicePlutoSDRShared::MsgCrossReportToBuddy& conf = (DevicePlutoSDRShared::MsgCrossReportToBuddy&) message; + m_settings.m_devSampleRate = conf.getDevSampleRate(); + m_settings.m_lpfFIRlog2Decim = conf.getLpfFiRlog2IntDec(); + m_settings.m_lpfFIRBW = conf.getLpfFirbw(); + m_settings.m_LOppmTenths = conf.getLoPPMTenths(); + PlutoSDRInputSettings newSettings = m_settings; + newSettings.m_lpfFIREnable = conf.isLpfFirEnable(); + applySettings(newSettings); + } else { return false; @@ -438,7 +449,29 @@ bool PlutoSDRInput::applySettings(const PlutoSDRInputSettings& settings, bool fo // TODO: forward changes to other (Tx) DSP if (forwardChangeOtherDSP) { + qDebug("PlutoSDRInput::applySettings: forwardChangeOtherDSP"); + + const std::vector& sinkBuddies = m_deviceAPI->getSinkBuddies(); + std::vector::const_iterator itSink = sinkBuddies.begin(); + + for (; itSink != sinkBuddies.end(); ++itSink) + { + DevicePlutoSDRShared::MsgCrossReportToBuddy *msg = DevicePlutoSDRShared::MsgCrossReportToBuddy::create( + settings.m_devSampleRate, + settings.m_lpfFIREnable, + settings.m_lpfFIRlog2Decim, + settings.m_lpfFIRBW, + settings.m_LOppmTenths); + + if ((*itSink)->getSampleSinkGUIMessageQueue()) + { + DevicePlutoSDRShared::MsgCrossReportToBuddy *msgToGUI = new DevicePlutoSDRShared::MsgCrossReportToBuddy(*msg); + (*itSink)->getSampleSinkGUIMessageQueue()->push(msgToGUI); + } + + (*itSink)->getSampleSinkInputMessageQueue()->push(msg); + } } if (forwardChangeOwnDSP) diff --git a/plugins/samplesource/plutosdrinput/plutosdrinputgui.cpp b/plugins/samplesource/plutosdrinput/plutosdrinputgui.cpp index 809e042f8..0c36059e6 100644 --- a/plugins/samplesource/plutosdrinput/plutosdrinputgui.cpp +++ b/plugins/samplesource/plutosdrinput/plutosdrinputgui.cpp @@ -130,7 +130,24 @@ bool PlutoSDRInputGui::deserialize(const QByteArray& data) bool PlutoSDRInputGui::handleMessage(const Message& message __attribute__((unused))) { - return false; + if (DevicePlutoSDRShared::MsgCrossReportToBuddy::match(message)) // message from buddy + { + DevicePlutoSDRShared::MsgCrossReportToBuddy& conf = (DevicePlutoSDRShared::MsgCrossReportToBuddy&) message; + m_settings.m_devSampleRate = conf.getDevSampleRate(); + m_settings.m_lpfFIRlog2Decim = conf.getLpfFiRlog2IntDec(); + m_settings.m_lpfFIRBW = conf.getLpfFirbw(); + m_settings.m_LOppmTenths = conf.getLoPPMTenths(); + m_settings.m_lpfFIREnable = conf.isLpfFirEnable(); + blockApplySettings(true); + displaySettings(); + blockApplySettings(false); + + return true; + } + else + { + return false; + } } void PlutoSDRInputGui::on_startStop_toggled(bool checked)