From 5013e77f24b94254d4ce37a7ac13d1d4f034e509 Mon Sep 17 00:00:00 2001 From: f4exb Date: Tue, 28 Aug 2018 23:31:07 +0200 Subject: [PATCH] SDRdaemmon: channel source: allow passing of data address and port at startup --- sdrdaemon/channel/sdrdaemonchannelsource.cpp | 26 +++++++++++--------- sdrdaemon/channel/sdrdaemonchannelsource.h | 5 ++-- sdrdaemon/sdrdaemonmain.cpp | 1 + 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/sdrdaemon/channel/sdrdaemonchannelsource.cpp b/sdrdaemon/channel/sdrdaemonchannelsource.cpp index f8e28081f..8d6131eae 100644 --- a/sdrdaemon/channel/sdrdaemonchannelsource.cpp +++ b/sdrdaemon/channel/sdrdaemonchannelsource.cpp @@ -44,9 +44,7 @@ SDRDaemonChannelSource::SDRDaemonChannelSource(DeviceSinkAPI *deviceAPI) : m_deviceAPI(deviceAPI), m_sourceThread(0), m_running(false), - m_samplesCount(0), - m_dataAddress("127.0.0.1"), - m_dataPort(9090) + m_samplesCount(0) { setObjectName(m_channelId); @@ -84,7 +82,7 @@ void SDRDaemonChannelSource::start() m_sourceThread = new SDRDaemonChannelSourceThread(&m_dataQueue); m_sourceThread->startStop(true); - m_sourceThread->dataBind(m_dataAddress, m_dataPort); + m_sourceThread->dataBind(m_settings.m_dataAddress, m_settings.m_dataPort); m_running = true; } @@ -102,6 +100,16 @@ void SDRDaemonChannelSource::stop() m_running = false; } +void SDRDaemonChannelSource::setDataLink(const QString& dataAddress, uint16_t dataPort) +{ + SDRDaemonChannelSourceSettings settings = m_settings; + settings.m_dataAddress = dataAddress; + settings.m_dataPort = dataPort; + + MsgConfigureSDRDaemonChannelSource *msg = MsgConfigureSDRDaemonChannelSource::create(settings, false); + m_inputMessageQueue.push(msg); +} + bool SDRDaemonChannelSource::handleMessage(const Message& cmd __attribute__((unused))) { if (UpChannelizer::MsgChannelizerNotification::match(cmd)) @@ -161,20 +169,16 @@ void SDRDaemonChannelSource::applySettings(const SDRDaemonChannelSourceSettings& bool change = false; - if ((m_settings.m_dataAddress != settings.m_dataAddress) || force) - { - m_dataAddress = settings.m_dataAddress; + if ((m_settings.m_dataAddress != settings.m_dataAddress) || force) { change = true; } - if ((m_settings.m_dataPort != settings.m_dataPort) || force) - { - m_dataPort = settings.m_dataPort; + if ((m_settings.m_dataPort != settings.m_dataPort) || force) { change = true; } if (change && m_sourceThread) { - m_sourceThread->dataBind(m_dataAddress, m_dataPort); + m_sourceThread->dataBind(settings.m_dataAddress, settings.m_dataPort); } m_settings = settings; diff --git a/sdrdaemon/channel/sdrdaemonchannelsource.h b/sdrdaemon/channel/sdrdaemonchannelsource.h index 7b2438014..f61c5cca1 100644 --- a/sdrdaemon/channel/sdrdaemonchannelsource.h +++ b/sdrdaemon/channel/sdrdaemonchannelsource.h @@ -80,6 +80,8 @@ public: virtual QByteArray serialize() const; virtual bool deserialize(const QByteArray& data); + void setDataLink(const QString& dataAddress, uint16_t dataPort); + static const QString m_channelIdURI; static const QString m_channelId; @@ -96,9 +98,6 @@ private: SDRDaemonChannelSourceSettings m_settings; uint64_t m_samplesCount; - QString m_dataAddress; - uint16_t m_dataPort; - CM256::cm256_block m_cm256DescriptorBlocks[2*SDRDaemonNbOrginalBlocks]; //!< CM256 decoder descriptors (block addresses and block indexes) SDRDaemonMetaDataFEC m_currentMeta; diff --git a/sdrdaemon/sdrdaemonmain.cpp b/sdrdaemon/sdrdaemonmain.cpp index 963388adf..17492a076 100644 --- a/sdrdaemon/sdrdaemonmain.cpp +++ b/sdrdaemon/sdrdaemonmain.cpp @@ -107,6 +107,7 @@ SDRDaemonMain::SDRDaemonMain(qtwebapp::LoggerWithFile *logger, const SDRDaemonPa info.noquote(); info << msg; m_channelSource = new SDRDaemonChannelSource(m_deviceSinkAPI); + m_channelSource->setDataLink(parser.getDataAddress(), parser.getDataPort()); } else {