summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2015-09-18 11:43:09 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2015-09-18 11:43:09 +0200
commit19a8c5db77e29b5d8309e1c7589bc3fdc283efae (patch)
treeeb86216f9e157d9a65c5896558939fc9cfcb97e6 /src
parentbdbe6b4f8e9ba8bfd703c6b7e9705ec645c64b78 (diff)
downloaddabmod-19a8c5db77e29b5d8309e1c7589bc3fdc283efae.tar.gz
dabmod-19a8c5db77e29b5d8309e1c7589bc3fdc283efae.tar.bz2
dabmod-19a8c5db77e29b5d8309e1c7589bc3fdc283efae.zip
Keep UHD settings across a modulator restart
Diffstat (limited to 'src')
-rw-r--r--src/OutputUHD.cpp30
-rw-r--r--src/OutputUHD.h19
2 files changed, 27 insertions, 22 deletions
diff --git a/src/OutputUHD.cpp b/src/OutputUHD.cpp
index 3fa7aa9..48ad4c7 100644
--- a/src/OutputUHD.cpp
+++ b/src/OutputUHD.cpp
@@ -105,7 +105,7 @@ bool check_gps_locked(uhd::usrp::multi_usrp::sptr usrp)
OutputUHD::OutputUHD(
- const OutputUHDConfig& config) :
+ OutputUHDConfig& config) :
ModOutput(ModFormat(1), ModFormat(0)),
RemoteControllable("uhd"),
myConf(config),
@@ -117,8 +117,8 @@ OutputUHD::OutputUHD(
myDelayBuf(0)
{
- myMuting = true; // is remote-controllable, and reset by the GPS fix check
- myStaticDelayUs = 0; // is remote-controllable
+ myConf.muting = true; // is remote-controllable, and reset by the GPS fix check
+ myConf.staticDelayUs = 0; // is remote-controllable
// Variables needed for GPS fix check
num_checks_without_gps_fix = 1;
@@ -304,7 +304,7 @@ int OutputUHD::process(Buffer* dataIn, Buffer* dataOut)
{
struct frame_timestamp ts;
- uwd.muting = myMuting;
+ uwd.muting = myConf.muting;
// On the first call, we must do some allocation and we must fill
@@ -318,13 +318,13 @@ int OutputUHD::process(Buffer* dataIn, Buffer* dataOut)
if (num_checks_without_gps_fix == 0) {
set_usrp_time();
gps_fix_verified = true;
- myMuting = false;
+ myConf.muting = false;
}
}
else {
set_usrp_time();
gps_fix_verified = true;
- myMuting = false;
+ myConf.muting = false;
}
}
else if (first_run) {
@@ -408,7 +408,7 @@ int OutputUHD::process(Buffer* dataIn, Buffer* dataOut)
myEtiReader->sourceContainsTimestamp();
// calculate delay
- uint32_t noSampleDelay = (myStaticDelayUs * (myConf.sampleRate / 1000)) / 1000;
+ uint32_t noSampleDelay = (myConf.staticDelayUs * (myConf.sampleRate / 1000)) / 1000;
uint32_t noByteDelay = noSampleDelay * sizeof(complexf);
uint8_t* pInData = (uint8_t*) dataIn->getData();
@@ -925,25 +925,25 @@ void OutputUHD::set_parameter(const string& parameter, const string& value)
myConf.frequency = myUsrp->get_tx_freq();
}
else if (parameter == "muting") {
- ss >> myMuting;
+ ss >> myConf.muting;
}
else if (parameter == "staticdelay") {
int64_t adjust;
ss >> adjust;
if (adjust > (myTFDurationMs * 1000))
{ // reset static delay for values outside range
- myStaticDelayUs = 0;
+ myConf.staticDelayUs = 0;
}
else
{ // the new adjust value is added to the existing delay and the result
// is wrapped around at TF duration
- int newStaticDelayUs = myStaticDelayUs + adjust;
+ int newStaticDelayUs = myConf.staticDelayUs + adjust;
if (newStaticDelayUs > (myTFDurationMs * 1000))
- myStaticDelayUs = newStaticDelayUs - (myTFDurationMs * 1000);
+ myConf.staticDelayUs = newStaticDelayUs - (myTFDurationMs * 1000);
else if (newStaticDelayUs < 0)
- myStaticDelayUs = newStaticDelayUs + (myTFDurationMs * 1000);
+ myConf.staticDelayUs = newStaticDelayUs + (myTFDurationMs * 1000);
else
- myStaticDelayUs = newStaticDelayUs;
+ myConf.staticDelayUs = newStaticDelayUs;
}
}
else {
@@ -964,10 +964,10 @@ const string OutputUHD::get_parameter(const string& parameter) const
ss << myConf.frequency;
}
else if (parameter == "muting") {
- ss << myMuting;
+ ss << myConf.muting;
}
else if (parameter == "staticdelay") {
- ss << myStaticDelayUs;
+ ss << myConf.staticDelayUs;
}
else {
ss << "Parameter '" << parameter <<
diff --git a/src/OutputUHD.h b/src/OutputUHD.h
index c38f151..d55d38e 100644
--- a/src/OutputUHD.h
+++ b/src/OutputUHD.h
@@ -185,7 +185,9 @@ class UHDWorker {
void process_errhandler();
};
-/* This structure is used as initial configuration for OutputUHD */
+/* This structure is used as initial configuration for OutputUHD.
+ * It must also contain all remote-controllable settings, otherwise
+ * they will get lost on a modulator restart. */
struct OutputUHDConfig {
std::string device;
std::string usrpType; // e.g. b100, b200, usrp2
@@ -213,13 +215,19 @@ struct OutputUHDConfig {
/* What to do when the reference clock PLL loses lock */
refclk_lock_loss_behaviour_t refclk_lock_loss_behaviour;
+
+ // muting can only be changed using the remote control
+ bool muting;
+
+ // static delay in microseconds
+ int staticDelayUs;
};
class OutputUHD: public ModOutput, public RemoteControllable {
public:
- OutputUHD(const OutputUHDConfig& config);
+ OutputUHD(OutputUHDConfig& config);
~OutputUHD();
int process(Buffer* dataIn, Buffer* dataOut);
@@ -249,7 +257,7 @@ class OutputUHD: public ModOutput, public RemoteControllable {
OutputUHD& operator=(const OutputUHD& other);
EtiReader *myEtiReader;
- OutputUHDConfig myConf;
+ OutputUHDConfig& myConf;
uhd::usrp::multi_usrp::sptr myUsrp;
std::shared_ptr<boost::barrier> mySyncBarrier;
UHDWorker worker;
@@ -258,16 +266,13 @@ class OutputUHD: public ModOutput, public RemoteControllable {
struct UHDWorkerData uwd;
int activebuffer;
- // muting can only be changed using the remote control
- bool myMuting;
-
private:
// Resize the internal delay buffer according to the dabMode and
// the sample rate.
void SetDelayBuffer(unsigned int dabMode);
// data
- int myStaticDelayUs; // static delay in microseconds
+ // The remote-controllable static delay is in the OutputUHDConfig
int myTFDurationMs; // TF duration in milliseconds
std::vector<complexf> myDelayBuf;
size_t lastLen;