summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias P. Braendli (think) <matthias@mpb.li>2012-08-16 18:56:43 +0200
committerMatthias P. Braendli (think) <matthias@mpb.li>2012-08-16 18:56:43 +0200
commit63f6e31cad0276352dd508394742b3161dde77bf (patch)
treeca071abf8a14479b507e10b717dbd9d5727a39ee /src
parent06fe89bd86fc709908c5882a2c48d03fc0977a25 (diff)
downloaddabmod-63f6e31cad0276352dd508394742b3161dde77bf.tar.gz
dabmod-63f6e31cad0276352dd508394742b3161dde77bf.tar.bz2
dabmod-63f6e31cad0276352dd508394742b3161dde77bf.zip
crc-dabmod: UHD remote control supports mutingr3
Diffstat (limited to 'src')
-rw-r--r--src/DabMod.cpp24
-rw-r--r--src/OutputUHD.cpp29
-rw-r--r--src/OutputUHD.h6
-rw-r--r--src/RemoteControl.h8
4 files changed, 60 insertions, 7 deletions
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