summaryrefslogtreecommitdiffstats
path: root/src/DabMod.cpp
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2017-02-10 11:31:05 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2017-02-10 11:31:05 +0100
commit51afbb4f9d0009b88de6cb065bbbb25a4c97f711 (patch)
treedf0163a2387e1424ebe104439333ad09361bfed6 /src/DabMod.cpp
parent245e62aed2fd55ef3b6569e5c0b8466f5aa72cbd (diff)
downloaddabmod-51afbb4f9d0009b88de6cb065bbbb25a4c97f711.tar.gz
dabmod-51afbb4f9d0009b88de6cb065bbbb25a4c97f711.tar.bz2
dabmod-51afbb4f9d0009b88de6cb065bbbb25a4c97f711.zip
Add support for SoapySDR
Diffstat (limited to 'src/DabMod.cpp')
-rw-r--r--src/DabMod.cpp111
1 files changed, 66 insertions, 45 deletions
diff --git a/src/DabMod.cpp b/src/DabMod.cpp
index 44951d7..9cb25a3 100644
--- a/src/DabMod.cpp
+++ b/src/DabMod.cpp
@@ -39,6 +39,9 @@
#if defined(HAVE_OUTPUT_UHD)
# include "OutputUHD.h"
#endif
+#if defined(HAVE_SOAPYSDR)
+# include "OutputSoapy.h"
+#endif
#include "OutputZeroMQ.h"
#include "InputReader.h"
#include "PcDebug.h"
@@ -140,6 +143,7 @@ int launch_modulator(int argc, char* argv[])
int useFileOutput = 0;
std::string fileOutputFormat = "complexf";
int useUHDOutput = 0;
+ int useSoapyOutput = 0;
size_t outputRate = 2048000;
size_t clockRate = 0;
@@ -171,6 +175,10 @@ int launch_modulator(int argc, char* argv[])
OutputUHDConfig outputuhd_conf;
#endif
+#if defined(HAVE_SOAPYSDR)
+ OutputSoapyConfig outputsoapy_conf;
+#endif
+
modulator_data m;
// To handle the timestamp offset of the modulator
@@ -312,6 +320,9 @@ int launch_modulator(int argc, char* argv[])
#if defined(HAVE_OUTPUT_UHD)
"output_uhd " <<
#endif
+#if defined(HAVE_SOAPYSDR)
+ "output_soapysdr " <<
+#endif
#if defined(__FAST_MATH__)
"fast-math" <<
#endif
@@ -485,50 +496,7 @@ int launch_modulator(int argc, char* argv[])
throw std::runtime_error("Configuration error");
}
else if (outputuhd_conf.frequency == 0) {
- double freq;
- if (chan == "5A") freq = 174928000;
- else if (chan == "5B") freq = 176640000;
- else if (chan == "5C") freq = 178352000;
- else if (chan == "5D") freq = 180064000;
- else if (chan == "6A") freq = 181936000;
- else if (chan == "6B") freq = 183648000;
- else if (chan == "6C") freq = 185360000;
- else if (chan == "6D") freq = 187072000;
- else if (chan == "7A") freq = 188928000;
- else if (chan == "7B") freq = 190640000;
- else if (chan == "7C") freq = 192352000;
- else if (chan == "7D") freq = 194064000;
- else if (chan == "8A") freq = 195936000;
- else if (chan == "8B") freq = 197648000;
- else if (chan == "8C") freq = 199360000;
- else if (chan == "8D") freq = 201072000;
- else if (chan == "9A") freq = 202928000;
- else if (chan == "9B") freq = 204640000;
- else if (chan == "9C") freq = 206352000;
- else if (chan == "9D") freq = 208064000;
- else if (chan == "10A") freq = 209936000;
- else if (chan == "10B") freq = 211648000;
- else if (chan == "10C") freq = 213360000;
- else if (chan == "10D") freq = 215072000;
- else if (chan == "11A") freq = 216928000;
- else if (chan == "11B") freq = 218640000;
- else if (chan == "11C") freq = 220352000;
- else if (chan == "11D") freq = 222064000;
- else if (chan == "12A") freq = 223936000;
- else if (chan == "12B") freq = 225648000;
- else if (chan == "12C") freq = 227360000;
- else if (chan == "12D") freq = 229072000;
- else if (chan == "13A") freq = 230784000;
- else if (chan == "13B") freq = 232496000;
- else if (chan == "13C") freq = 234208000;
- else if (chan == "13D") freq = 235776000;
- else if (chan == "13E") freq = 237488000;
- else if (chan == "13F") freq = 239200000;
- else {
- std::cerr << " UHD output: channel " << chan << " does not exist in table\n";
- throw std::out_of_range("UHD channel selection error");
- }
- outputuhd_conf.frequency = freq;
+ outputuhd_conf.frequency = parseChannel(chan);
}
else if (outputuhd_conf.frequency != 0 && chan != "") {
std::cerr << " UHD output: cannot define both frequency and channel.\n";
@@ -558,6 +526,31 @@ int launch_modulator(int argc, char* argv[])
useUHDOutput = 1;
}
#endif
+#if defined(HAVE_SOAPYSDR)
+ else if (output_selected == "soapysdr") {
+ outputsoapy_conf.device = pt.get("soapyoutput.device", "");
+ outputsoapy_conf.masterClockRate = pt.get<long>("soapyoutput.master_clock_rate", 0);
+
+ outputsoapy_conf.txgain = pt.get("soapyoutput.txgain", 0.0);
+ outputsoapy_conf.frequency = pt.get<double>("soapyoutput.frequency", 0);
+ std::string chan = pt.get<std::string>("soapyoutput.channel", "");
+ outputsoapy_conf.dabMode = dabMode;
+
+ if (outputsoapy_conf.frequency == 0 && chan == "") {
+ std::cerr << " soapy output enabled, but neither frequency nor channel defined.\n";
+ throw std::runtime_error("Configuration error");
+ }
+ else if (outputsoapy_conf.frequency == 0) {
+ outputsoapy_conf.frequency = parseChannel(chan);
+ }
+ else if (outputsoapy_conf.frequency != 0 && chan != "") {
+ std::cerr << " soapy output: cannot define both frequency and channel.\n";
+ throw std::runtime_error("Configuration error");
+ }
+
+ useSoapyOutput = 1;
+ }
+#endif
#if defined(HAVE_ZEROMQ)
else if (output_selected == "zmq") {
outputName = pt.get<std::string>("zmqoutput.listen");
@@ -649,7 +642,7 @@ int launch_modulator(int argc, char* argv[])
throw std::invalid_argument("Invalid command line options");
}
- if (!useFileOutput && !useUHDOutput && !useZeroMQOutput) {
+ if (!useFileOutput && !useUHDOutput && !useZeroMQOutput && !useSoapyOutput) {
etiLog.level(error) << "Output not specified";
fprintf(stderr, "Must specify output !");
throw std::runtime_error("Configuration error");
@@ -679,6 +672,15 @@ int launch_modulator(int argc, char* argv[])
outputuhd_conf.pps_src.c_str());
}
#endif
+#if defined(HAVE_SOAPYSDR)
+ else if (useSoapyOutput) {
+ fprintf(stderr, " SoapySDR\n"
+ " Device: %s\n"
+ " master_clock_rate: %ld\n",
+ outputsoapy_conf.device.c_str(),
+ outputsoapy_conf.masterClockRate);
+ }
+#endif
else if (useZeroMQOutput) {
fprintf(stderr, " ZeroMQ\n"
" Listening on: %s\n"
@@ -763,6 +765,15 @@ int launch_modulator(int argc, char* argv[])
rcs.enrol((OutputUHD*)output.get());
}
#endif
+#if defined(HAVE_SOAPYSDR)
+ else if (useSoapyOutput) {
+ /* We normalise the same way as for the UHD output */
+ normalise = 1.0f / normalise_factor;
+ outputsoapy_conf.sampleRate = outputRate;
+ output = make_shared<OutputSoapy>(outputsoapy_conf);
+ rcs.enrol((OutputSoapy*)output.get());
+ }
+#endif
#if defined(HAVE_ZEROMQ)
else if (useZeroMQOutput) {
/* We normalise the same way as for the UHD output */
@@ -812,6 +823,11 @@ int launch_modulator(int argc, char* argv[])
((OutputUHD*)output.get())->setETISource(modulator->getEtiSource());
}
#endif
+#if defined(HAVE_SOAPYSDR)
+ if (useSoapyOutput) {
+ ((OutputSoapy*)output.get())->setETISource(modulator->getEtiSource());
+ }
+#endif
size_t framecount = 0;
@@ -863,6 +879,11 @@ int launch_modulator(int argc, char* argv[])
((OutputUHD*)output.get())->setETISource(modulator->getEtiSource());
}
#endif
+#if defined(HAVE_SOAPYSDR)
+ if (useSoapyOutput) {
+ ((OutputSoapy*)output.get())->setETISource(modulator->getEtiSource());
+ }
+#endif
m.inputReader->PrintInfo();