From 30211815641d2ad8a9ff2674af3d5df85e252533 Mon Sep 17 00:00:00 2001 From: f4exb Date: Tue, 21 Aug 2018 15:18:23 +0200 Subject: [PATCH] SDRdaemon: pass FEC blocks and tx delay from the command line --- sdrdaemon/sdrdaemonmain.cpp | 2 ++ sdrdaemon/sdrdaemonparser.cpp | 41 +++++++++++++++++++++++++++++++++-- sdrdaemon/sdrdaemonparser.h | 6 +++++ 3 files changed, 47 insertions(+), 2 deletions(-) diff --git a/sdrdaemon/sdrdaemonmain.cpp b/sdrdaemon/sdrdaemonmain.cpp index ab51d6ecc..486ba0efb 100644 --- a/sdrdaemon/sdrdaemonmain.cpp +++ b/sdrdaemon/sdrdaemonmain.cpp @@ -130,6 +130,8 @@ SDRDaemonMain::SDRDaemonMain(qtwebapp::LoggerWithFile *logger, const SDRDaemonPa info.noquote(); info << msg; m_channelSink = new SDRDaemonChannelSink(m_deviceSourceAPI); + m_channelSink->setNbBlocksFEC(parser.getNbBlocksFEC()); + m_channelSink->setTxDelay(parser.getTxDelay()); } else { diff --git a/sdrdaemon/sdrdaemonparser.cpp b/sdrdaemon/sdrdaemonparser.cpp index d1c7fc07c..b5faa6482 100644 --- a/sdrdaemon/sdrdaemonparser.cpp +++ b/sdrdaemon/sdrdaemonparser.cpp @@ -54,8 +54,15 @@ SDRDaemonParser::SDRDaemonParser() : "serial"), m_sequenceOption(QStringList() << "i" << "sequence", "Device sequence index in enumeration for the same device type.", - "sequence") - + "sequence"), + m_txDelayOption(QStringList() << "d" << "tx-delay", + "delay between transmission of UDP blocks (ms).", + "txDelay", + "100"), + m_nbBlocksFECOption(QStringList() << "f" << "fec-blocks", + "Number of FEC blocks per frame.", + "nbBlocksFEC", + "8") { m_serverAddress = "127.0.0.1"; m_serverPort = 9091; @@ -64,6 +71,8 @@ SDRDaemonParser::SDRDaemonParser() : m_deviceType = "TestSource"; m_tx = false; m_sequence = 0; + m_txDelay = 100; + m_nbBlocksFEC = 8; m_hasSequence = false; m_hasSerial = false; @@ -79,6 +88,8 @@ SDRDaemonParser::SDRDaemonParser() : m_parser.addOption(m_txOption); m_parser.addOption(m_serialOption); m_parser.addOption(m_sequenceOption); + m_parser.addOption(m_txDelayOption); + m_parser.addOption(m_nbBlocksFECOption); } SDRDaemonParser::~SDRDaemonParser() @@ -195,6 +206,32 @@ void SDRDaemonParser::parse(const QCoreApplication& app) qWarning() << "SDRDaemonParser::parse: sequence invalid. Defaulting to " << m_sequence; } } + + // Tx delay + if (m_parser.isSet(m_txDelayOption)) + { + QString txDelayStr = m_parser.value(m_txDelayOption); + int txDelay = txDelayStr.toInt(&ok); + + if (ok && (txDelay > 0)) { + m_txDelay = txDelay; + } else { + qWarning() << "SDRDaemonParser::parse: Tx delay invalid. Defaulting to " << m_txDelay; + } + } + + // nb FEC blocks + if (m_parser.isSet(m_nbBlocksFECOption)) + { + QString nbBlocksFECStr = m_parser.value(m_nbBlocksFECOption); + int nbBlocksFEC = nbBlocksFECStr.toInt(&ok); + + if (ok && (nbBlocksFEC >= 0) && (nbBlocksFEC < 128)) { + m_nbBlocksFEC = nbBlocksFEC; + } else { + qWarning() << "SDRDaemonParser::parse: Tx number of FEC blocks invalid. Defaulting to " << m_nbBlocksFEC; + } + } } diff --git a/sdrdaemon/sdrdaemonparser.h b/sdrdaemon/sdrdaemonparser.h index fb794ee80..30b23729d 100644 --- a/sdrdaemon/sdrdaemonparser.h +++ b/sdrdaemon/sdrdaemonparser.h @@ -42,6 +42,8 @@ public: bool getTx() const { return m_tx; } const QString& getSerial() const { return m_serial; } uint16_t getSequence() const { return m_sequence; } + int getTxDelay() const { return m_txDelay; } + int getNbBlocksFEC() const { return m_nbBlocksFEC; } bool hasSequence() const { return m_hasSequence; } bool hasSerial() const { return m_hasSerial; } @@ -55,6 +57,8 @@ private: bool m_tx; //!< True for Tx QString m_serial; //!< Serial number of the device uint16_t m_sequence; //!< Sequence of the device for the same type of device in enumeration process + int m_txDelay; //!< Initial delay between transmission of UDP blocks in milliseconds + int m_nbBlocksFEC; //!< Number of FEC blocks per frame; bool m_hasSerial; //!< True if serial was specified bool m_hasSequence; //!< True if sequence was specified @@ -67,6 +71,8 @@ private: QCommandLineOption m_txOption; QCommandLineOption m_serialOption; QCommandLineOption m_sequenceOption; + QCommandLineOption m_txDelayOption; + QCommandLineOption m_nbBlocksFECOption; };