summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJörgen Scott <jorgen.scott@gmail.com>2014-12-16 09:23:31 +0100
committerJörgen Scott <jorgen.scott@gmail.com>2014-12-16 09:23:31 +0100
commitf4e359f774eef5ec2a006a431a546e915b27f02b (patch)
tree27aad5426ae25a5abc513aec35434d80979feebb /src
parent855311975814891f531577f90115bfb5fa6ed252 (diff)
downloaddabmod-f4e359f774eef5ec2a006a431a546e915b27f02b.tar.gz
dabmod-f4e359f774eef5ec2a006a431a546e915b27f02b.tar.bz2
dabmod-f4e359f774eef5ec2a006a431a546e915b27f02b.zip
Added static delay via telnet control
Diffstat (limited to 'src')
-rw-r--r--src/.DabMod.cpp.un~bin0 -> 30089 bytes
-rw-r--r--src/.OutputUHD.cpp.un~bin0 -> 67312 bytes
-rw-r--r--src/.OutputUHD.h.un~bin0 -> 13690 bytes
-rw-r--r--src/.TimestampDecoder.cpp.un~bin0 -> 4958 bytes
-rw-r--r--src/DabMod.cpp3
-rw-r--r--src/OutputUHD.cpp56
-rw-r--r--src/OutputUHD.h5
7 files changed, 59 insertions, 5 deletions
diff --git a/src/.DabMod.cpp.un~ b/src/.DabMod.cpp.un~
new file mode 100644
index 0000000..ebbb822
--- /dev/null
+++ b/src/.DabMod.cpp.un~
Binary files differ
diff --git a/src/.OutputUHD.cpp.un~ b/src/.OutputUHD.cpp.un~
new file mode 100644
index 0000000..96f080d
--- /dev/null
+++ b/src/.OutputUHD.cpp.un~
Binary files differ
diff --git a/src/.OutputUHD.h.un~ b/src/.OutputUHD.h.un~
new file mode 100644
index 0000000..5f3e54a
--- /dev/null
+++ b/src/.OutputUHD.h.un~
Binary files differ
diff --git a/src/.TimestampDecoder.cpp.un~ b/src/.TimestampDecoder.cpp.un~
new file mode 100644
index 0000000..01d7cc7
--- /dev/null
+++ b/src/.TimestampDecoder.cpp.un~
Binary files 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 <boost/shared_ptr.hpp>
#include <list>
#include <string>
+#include <zmq.hpp>
#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<complexf> m_delayBuf;
+
size_t lastLen;
};