From f4e359f774eef5ec2a006a431a546e915b27f02b Mon Sep 17 00:00:00 2001 From: Jörgen Scott Date: Tue, 16 Dec 2014 09:23:31 +0100 Subject: Added static delay via telnet control --- src/.DabMod.cpp.un~ | Bin 0 -> 30089 bytes src/.OutputUHD.cpp.un~ | Bin 0 -> 67312 bytes src/.OutputUHD.h.un~ | Bin 0 -> 13690 bytes src/.TimestampDecoder.cpp.un~ | Bin 0 -> 4958 bytes src/DabMod.cpp | 3 +++ src/OutputUHD.cpp | 56 +++++++++++++++++++++++++++++++++++++++--- src/OutputUHD.h | 5 +++- 7 files changed, 59 insertions(+), 5 deletions(-) create mode 100644 src/.DabMod.cpp.un~ create mode 100644 src/.OutputUHD.cpp.un~ create mode 100644 src/.OutputUHD.h.un~ create mode 100644 src/.TimestampDecoder.cpp.un~ (limited to 'src') diff --git a/src/.DabMod.cpp.un~ b/src/.DabMod.cpp.un~ new file mode 100644 index 0000000..ebbb822 Binary files /dev/null and b/src/.DabMod.cpp.un~ differ diff --git a/src/.OutputUHD.cpp.un~ b/src/.OutputUHD.cpp.un~ new file mode 100644 index 0000000..96f080d Binary files /dev/null and b/src/.OutputUHD.cpp.un~ differ diff --git a/src/.OutputUHD.h.un~ b/src/.OutputUHD.h.un~ new file mode 100644 index 0000000..5f3e54a Binary files /dev/null and b/src/.OutputUHD.h.un~ differ diff --git a/src/.TimestampDecoder.cpp.un~ b/src/.TimestampDecoder.cpp.un~ new file mode 100644 index 0000000..01d7cc7 Binary files /dev/null and b/src/.TimestampDecoder.cpp.un~ differ diff --git a/src/DabMod.cpp b/src/DabMod.cpp index 14c7c4b..ee21ed4 100644 --- a/src/DabMod.cpp +++ b/src/DabMod.cpp @@ -363,6 +363,9 @@ int main(int argc, char* argv[]) } } + //std::string zmqCtrlEndpoint = pt.get("remotecontrol.zmqctrlendpoint", ""); + //std::cout << "ZmqCtrlEndpoint: " << zmqCtrlEndpoint << std::endl; + // input params: if (pt.get("input.loop", 0) == 1) { loop = true; diff --git a/src/OutputUHD.cpp b/src/OutputUHD.cpp index b44cd3f..8713042 100644 --- a/src/OutputUHD.cpp +++ b/src/OutputUHD.cpp @@ -53,10 +53,12 @@ OutputUHD::OutputUHD( // Since we don't know the buffer size, we cannot initialise // the buffers at object initialisation. first_run(true), - activebuffer(1) + activebuffer(1), + m_delayBuf(196608) { myMuting = 0; // is remote-controllable + myStaticDelay = 0; // is remote-controllable std::stringstream device; device << myConf.device; @@ -81,7 +83,9 @@ OutputUHD::OutputUHD( /* register the parameters that can be remote controlled */ RC_ADD_PARAMETER(txgain, "UHD analog daughterboard TX gain"); RC_ADD_PARAMETER(freq, "UHD transmission frequency"); - RC_ADD_PARAMETER(muting, "mute the output by stopping the transmitter"); + RC_ADD_PARAMETER(muting, "Mute the output by stopping the transmitter"); + RC_ADD_PARAMETER(staticdelay, "Set static delay (uS) between 0 and 96000"); + RC_ADD_PARAMETER(iqbalance, "Set I/Q balance between 0 and 1.0"); uhd::set_thread_priority_safe(); @@ -229,6 +233,10 @@ OutputUHD::~OutputUHD() { MDEBUG("OutputUHD::~OutputUHD() @ %p\n", this); worker.stop(); + if (!first_run) { + free(uwd.frame0.buf); + free(uwd.frame1.buf); + } } int OutputUHD::process(Buffer* dataIn, Buffer* dataOut) @@ -283,14 +291,35 @@ int OutputUHD::process(Buffer* dataIn, Buffer* dataOut) uwd.sourceContainsTimestamp = myConf.enableSync && myEtiReader->sourceContainsTimestamp(); + // calculate delay + uint32_t noSampleDelay = (myStaticDelay * 2048) / 1000; + uint32_t noByteDelay = noSampleDelay * sizeof(complexf); + + uint8_t* pInData = (uint8_t*) dataIn->getData(); if (activebuffer == 0) { - memcpy(uwd.frame0.buf, dataIn->getData(), uwd.bufsize); + uint8_t *pTmp = (uint8_t*) uwd.frame0.buf; + // copy remain from delaybuf + memcpy(pTmp, &m_delayBuf[0], noByteDelay); + // copy new data + memcpy(&pTmp[noByteDelay], pInData, uwd.bufsize - noByteDelay); + // copy remaining data to delay buf + memcpy(&m_delayBuf[0], &pInData[uwd.bufsize - noByteDelay], noByteDelay); + + //memcpy(uwd.frame0.buf, dataIn->getData(), uwd.bufsize); uwd.frame0.ts = ts; uwd.frame0.fct = myEtiReader->getFCT(); } else if (activebuffer == 1) { - memcpy(uwd.frame1.buf, dataIn->getData(), uwd.bufsize); + uint8_t *pTmp = (uint8_t*) uwd.frame1.buf; + // copy remain from delaybuf + memcpy(pTmp, &m_delayBuf[0], noByteDelay); + // copy new data + memcpy(&pTmp[noByteDelay], pInData, uwd.bufsize - noByteDelay); + // copy remaining data to delay buf + memcpy(&m_delayBuf[0], &pInData[uwd.bufsize - noByteDelay], noByteDelay); + + //memcpy(uwd.frame1.buf, dataIn->getData(), uwd.bufsize); uwd.frame1.ts = ts; uwd.frame1.fct = myEtiReader->getFCT(); @@ -591,6 +620,22 @@ void OutputUHD::set_parameter(const string& parameter, const string& value) else if (parameter == "muting") { ss >> myMuting; } + else if (parameter == "staticdelay") { + int adjust; + ss >> adjust; + int newStaticDelay = myStaticDelay + adjust; + if (newStaticDelay > 96000) + myStaticDelay = newStaticDelay - 96000; + else if (newStaticDelay < 0) + myStaticDelay = newStaticDelay + 96000; + else + myStaticDelay = newStaticDelay; + } + else if (parameter == "iqbalance") { + ss >> myConf.frequency; + myUsrp->set_tx_freq(myConf.frequency); + myConf.frequency = myUsrp->get_tx_freq(); + } else { stringstream ss; ss << "Parameter '" << parameter @@ -611,6 +656,9 @@ const string OutputUHD::get_parameter(const string& parameter) const else if (parameter == "muting") { ss << myMuting; } + else if (parameter == "staticdelay") { + ss << myStaticDelay; + } else { ss << "Parameter '" << parameter << "' is not exported by controllable " << get_rc_name(); diff --git a/src/OutputUHD.h b/src/OutputUHD.h index 69e5b20..f50807d 100644 --- a/src/OutputUHD.h +++ b/src/OutputUHD.h @@ -48,6 +48,7 @@ DESCRIPTION: #include #include #include +#include #include "Log.h" #include "ModOutput.h" @@ -220,7 +221,9 @@ class OutputUHD: public ModOutput, public RemoteControllable { // muting can only be changed using the remote control bool myMuting; - + int myStaticDelay; + std::vector m_delayBuf; + size_t lastLen; }; -- cgit v1.2.3