diff options
author | Matthias P. Braendli (think) <matthias@mpb.li> | 2012-08-16 18:56:43 +0200 |
---|---|---|
committer | Matthias P. Braendli (think) <matthias@mpb.li> | 2012-08-16 18:56:43 +0200 |
commit | 63f6e31cad0276352dd508394742b3161dde77bf (patch) | |
tree | ca071abf8a14479b507e10b717dbd9d5727a39ee | |
parent | 06fe89bd86fc709908c5882a2c48d03fc0977a25 (diff) | |
download | dabmod-r3.tar.gz dabmod-r3.tar.bz2 dabmod-r3.zip |
crc-dabmod: UHD remote control supports mutingr3
-rw-r--r-- | doc/example.ini | 10 | ||||
-rw-r--r-- | src/DabMod.cpp | 24 | ||||
-rw-r--r-- | src/OutputUHD.cpp | 29 | ||||
-rw-r--r-- | src/OutputUHD.h | 6 | ||||
-rw-r--r-- | src/RemoteControl.h | 8 |
5 files changed, 67 insertions, 10 deletions
diff --git a/doc/example.ini b/doc/example.ini index 9679449..15a7661 100644 --- a/doc/example.ini +++ b/doc/example.ini @@ -1,9 +1,13 @@ # Sample configuration file for CRC-DABMOD +[remotecontrol] +telnet=1 +telnetport=2121 + [log] -syslog=1 +syslog=0 filelog=1 -filename=dabmod.log +filename=/dev/stderr [input] filename=/dev/stdin @@ -42,7 +46,7 @@ txgain=0 # Used for SFN with the UHD output [delaymanagement] -synchronous=1 +synchronous=0 # choose between fixed and dynamic offset definition management=dynamic diff --git a/src/DabMod.cpp b/src/DabMod.cpp index dbfc885..83fb210 100644 --- a/src/DabMod.cpp +++ b/src/DabMod.cpp @@ -192,8 +192,7 @@ int main(int argc, char* argv[]) InputMemory* input = NULL; ModOutput* output = NULL; - RemoteControllerTelnet rc (2121); - rc.start(); + BaseRemoteController* rc = NULL; Logger logger; @@ -310,6 +309,25 @@ int main(int argc, char* argv[]) read_ini(configuration_file, pt); + // remote controller: + if (pt.get("remotecontrol.telnet", 0) == 1) { + try { + int telnetport = pt.get<int>("remotecontrol.telnetport"); + RemoteControllerTelnet* telnetrc = new RemoteControllerTelnet(telnetport); + telnetrc->start(); + rc = telnetrc; + } + catch (std::exception &e) { + std::cerr << "Error: " << e.what() << "\n"; + std::cerr << " telnet remote control enabled, but no telnetport defined.\n"; + goto END_MAIN; + } + } + else { + rc = new RemoteControllerDummy(); + } + + // input params: if (pt.get("input.loop", 0) == 1) { loop = true; @@ -513,7 +531,7 @@ int main(int argc, char* argv[]) uhdFrequency, uhdTxGain, uhd_enable_sync, uhd_mute_no_timestamps, logger); - ((OutputUHD*)output)->enrol_at(rc); + ((OutputUHD*)output)->enrol_at(*rc); } catch (std::exception& e) { logger(error, "UHD initialisation failed"); diff --git a/src/OutputUHD.cpp b/src/OutputUHD.cpp index 808d0e1..a852c10 100644 --- a/src/OutputUHD.cpp +++ b/src/OutputUHD.cpp @@ -55,7 +55,9 @@ OutputUHD::OutputUHD(const char* device, unsigned sampleRate, device, this); /* register the parameters that can be remote controlled */ - RC_ADD_PARAMETER(txgain, "UHD analog daughterboard TX gain") + 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"); myDevice = device; @@ -96,7 +98,8 @@ OutputUHD::OutputUHD(const char* device, unsigned sampleRate, //set the centre frequency MDEBUG("OutputUHD:Setting freq to %f...\n", myFrequency); myUsrp->set_tx_freq(myFrequency); - MDEBUG("OutputUHD:Actual frequency: %f\n", myUsrp->get_tx_freq()); + myFrequency = myUsrp->get_tx_freq(); + MDEBUG("OutputUHD:Actual frequency: %f\n", myFrequency); myUsrp->set_tx_gain(myTxGain); MDEBUG("OutputUHD:Actual TX Gain: %f ...\n", myUsrp->get_tx_gain()); @@ -177,6 +180,8 @@ int OutputUHD::process(Buffer* dataIn, Buffer* dataOut) { struct frame_timestamp ts; + uwd.muting = myMuting; + // On the first call, we must do some allocation and we must fill // the first buffer // We will only wait on the barrier on the subsequent calls to @@ -370,7 +375,7 @@ void UHDWorker::process(struct UHDWorkerData *uwd) } else { // !uwd->sourceContainsTimestamp - if (uwd->muteNoTimestamps) { + if (uwd->muting || uwd->muteNoTimestamps) { /* There was some error decoding the timestamp */ fprintf(stderr, "UHDOut: Muting sample %d : no timestamp\n", @@ -390,7 +395,7 @@ void UHDWorker::process(struct UHDWorkerData *uwd) MDEBUG("UHDWorker::process:num_tx_samps: %zu.\n", num_tx_samps); */ - while (running && (num_acc_samps < sizeIn)) { + while (running && !uwd->muting && (num_acc_samps < sizeIn)) { size_t samps_to_send = std::min(sizeIn - num_acc_samps, bufsize); //ensure the the last packet has EOB set if the timestamps has been refreshed @@ -517,6 +522,16 @@ void OutputUHD::set_parameter(string parameter, string value) myUsrp->set_tx_gain(myTxGain); #endif } + else if (parameter == "freq") { + ss >> myFrequency; +#if ENABLE_UHD + myUsrp->set_tx_freq(myFrequency); + myFrequency = myUsrp->get_tx_freq(); +#endif + } + else if (parameter == "muting") { + ss >> myMuting; + } else { stringstream ss; ss << "Parameter '" << parameter << "' is not exported by controllable " << get_rc_name(); @@ -530,6 +545,12 @@ string OutputUHD::get_parameter(string parameter) if (parameter == "txgain") { ss << myTxGain; } + else if (parameter == "freq") { + ss << myFrequency; + } + else if (parameter == "muting") { + ss << myMuting; + } else { ss << "Parameter '" << parameter << "' is not exported by controllable " << get_rc_name(); throw ParameterError(ss.str()); diff --git a/src/OutputUHD.h b/src/OutputUHD.h index 28d3f25..b7e570a 100644 --- a/src/OutputUHD.h +++ b/src/OutputUHD.h @@ -102,6 +102,9 @@ struct UHDWorkerData { struct UHDWorkerFrameData frame1; size_t bufsize; // in bytes + // muting set by remote control + bool muting; + // A barrier to synchronise the two threads shared_ptr<barrier> sync_barrier; @@ -187,6 +190,9 @@ class OutputUHD: public ModOutput, public RemoteControllable { bool mute_no_timestamps; bool enable_sync; + // muting can only be changed using the remote control + bool myMuting; + size_t lastLen; }; diff --git a/src/RemoteControl.h b/src/RemoteControl.h index 53fc912..5ffb2fb 100644 --- a/src/RemoteControl.h +++ b/src/RemoteControl.h @@ -216,4 +216,12 @@ class RemoteControllerTelnet : public BaseRemoteController { int port_; }; + +/* The Dummy remote controller does nothing + */ +class RemoteControllerDummy : public BaseRemoteController { + public: + void enrol(RemoteControllable* controllable) {}; +}; + #endif |