diff options
Diffstat (limited to 'src/DabMod.cpp')
-rw-r--r-- | src/DabMod.cpp | 107 |
1 files changed, 89 insertions, 18 deletions
diff --git a/src/DabMod.cpp b/src/DabMod.cpp index ea6334f..4912bee 100644 --- a/src/DabMod.cpp +++ b/src/DabMod.cpp @@ -38,6 +38,7 @@ #if defined(HAVE_OUTPUT_UHD) # include "OutputUHD.h" #endif +#include "OutputZeroMQ.h" #include "InputReader.h" #include "PcDebug.h" #include "TimestampDecoder.h" @@ -56,11 +57,11 @@ #include <stdexcept> #include <signal.h> -#ifdef HAVE_NETINET_IN_H +#if HAVE_NETINET_IN_H # include <netinet/in.h> #endif -#ifdef HAVE_DECL__MM_MALLOC +#if HAVE_DECL__MM_MALLOC # include <mm_malloc.h> #else # define memalign(a, b) malloc(b) @@ -91,11 +92,11 @@ void printUsage(char* progName, FILE* out = stderr) #endif __DATE__, __TIME__); fprintf(out, "Usage with configuration file:\n"); - fprintf(out, "\t%s -C config_file.ini\n\n", progName); + fprintf(out, "\t%s [-C] config_file.ini\n\n", progName); fprintf(out, "Usage with command line options:\n"); fprintf(out, "\t%s" - " [input]" + " input" " (-f filename | -u uhddevice -F frequency) " " [-G txgain]" " [-o offset]" @@ -137,8 +138,13 @@ void printVersion(FILE *out = stderr) { fprintf(out, "Welcome to %s %s, compiled at %s, %s\n\n", PACKAGE, VERSION, __DATE__, __TIME__); - fprintf(out, "ODR-DabMod is copyright (C) Her Majesty the Queen in Right of Canada,\n" - " 2009, 2010, 2011, 2012 Communications Research Centre (CRC).\n" + fprintf(out, + " ODR-DabMod is copyright (C) Her Majesty the Queen in Right of Canada,\n" + " 2009, 2010, 2011, 2012 Communications Research Centre (CRC),\n" + " and\n" + " Copyright (C) 2014 Matthias P. Braendli, matthias.braendli@mpb.li\n" + "\n" + " http://opendigitalradio.org\n" "\n" " This program is available free of charge and is licensed to you on a\n" " non-exclusive basis; you may not redistribute it.\n" @@ -151,8 +157,10 @@ void printVersion(FILE *out = stderr) " In no event shall CRC be LIABLE for any LOSS, DAMAGE or COST that may be\n" " incurred in connection with the use of this software.\n" "\n" +#if USE_KISS_FFT "ODR-DabMod makes use of the following open source packages:\n" " Kiss FFT v1.2.9 (Revised BSD) - http://kissfft.sourceforge.net/\n" +#endif ); } @@ -166,6 +174,7 @@ int main(int argc, char* argv[]) std::string inputTransport = "file"; std::string outputName; + int useZeroMQOutput = 0; int useFileOutput = 0; int useUHDOutput = 0; @@ -257,7 +266,7 @@ int main(int argc, char* argv[]) break; case 'G': #if defined(HAVE_OUTPUT_UHD) - outputuhd_conf.txgain = (int)strtol(optarg, NULL, 10); + outputuhd_conf.txgain = strtod(optarg, NULL); #endif break; case 'l': @@ -330,11 +339,47 @@ int main(int argc, char* argv[]) #endif << std::endl; + std::cerr << "Using FFT library " << +#if defined(USE_FFTW) + "FFTW" << +#endif +#if defined(USE_KISS_FFT) + "Kiss FFT" << +#endif +#if defined(USE_SIMD) + " (with fft_simd)" << +#endif + "\n"; + + std::cerr << "Compiled with features: " << +#if defined(HAVE_INPUT_ZEROMQ) + "input_zeromq " << +#endif +#if defined(HAVE_OUTPUT_UHD) + "output_uhd " << +#endif +#if defined(HAVE_OUTPUT_ZEROMQ) + "output_zeromq " << +#endif + "\n"; + if (use_configuration_file && use_configuration_cmdline) { fprintf(stderr, "Warning: configuration file and command line parameters are defined:\n\t" "Command line parameters override settings in the configuration file !\n"); } + // No argument given ? You can't be serious ! Show usage. + if (argc == 1) { + printUsage(argv[0]); + goto END_MAIN; + } + + // If only one argument is given, interpret as configuration file name + if (argc == 2) { + use_configuration_file = true; + configuration_file = argv[1]; + } + if (use_configuration_file) { // First read parameters from the file using boost::property_tree::ptree; @@ -415,7 +460,7 @@ int main(int argc, char* argv[]) clockRate = pt.get("modulator.dac_clk_rate", (size_t)0); digitalgain = pt.get("modulator.digital_gain", digitalgain); outputRate = pt.get("modulator.rate", outputRate); - + // FIR Filter parameters: if (pt.get("firfilter.enabled", 0) == 1) { try { @@ -467,7 +512,7 @@ int main(int argc, char* argv[]) "setting type in [uhd] device is deprecated !\n"; } - outputuhd_conf.txgain = pt.get("uhdoutput.txgain", 0); + outputuhd_conf.txgain = pt.get("uhdoutput.txgain", 0.0); outputuhd_conf.frequency = pt.get<double>("uhdoutput.frequency", 0); std::string chan = pt.get<std::string>("uhdoutput.channel", ""); @@ -547,6 +592,12 @@ int main(int argc, char* argv[]) useUHDOutput = 1; } #endif +#if defined(HAVE_OUTPUT_ZEROMQ) + else if (output_selected == "zmq") { + outputName = pt.get<std::string>("zmqoutput.listen"); + useZeroMQOutput = 1; + } +#endif else { std::cerr << "Error: Invalid output defined.\n"; goto END_MAIN; @@ -579,6 +630,7 @@ int main(int argc, char* argv[]) outputuhd_conf.muteNoTimestamps = (pt.get("delaymanagement.mutenotimestamps", 0) == 1); #endif } + if (rcs.get_no_controllers() == 0) { logger.level(warn) << "No Remote-Control started"; rcs.add_controller(new RemoteControllerDummy()); @@ -600,7 +652,7 @@ int main(int argc, char* argv[]) } // Setting ETI input filename - if (inputName == "") { + if (use_configuration_cmdline && inputName == "") { if (optind < argc) { inputName = argv[optind++]; @@ -616,7 +668,7 @@ int main(int argc, char* argv[]) } // Checking unused arguments - if (optind != argc) { + if (use_configuration_cmdline && optind != argc) { fprintf(stderr, "Invalid arguments:"); while (optind != argc) { fprintf(stderr, " %s", argv[optind++]); @@ -628,7 +680,7 @@ int main(int argc, char* argv[]) goto END_MAIN; } - if (!useFileOutput && !useUHDOutput) { + if (!useFileOutput && !useUHDOutput && !useZeroMQOutput) { logger.level(error) << "Output not specified"; fprintf(stderr, "Must specify output !"); goto END_MAIN; @@ -639,8 +691,12 @@ int main(int argc, char* argv[]) fprintf(stderr, " Type: %s\n", inputTransport.c_str()); fprintf(stderr, " Source: %s\n", inputName.c_str()); fprintf(stderr, "Output\n"); + + if (useFileOutput) { + fprintf(stderr, " Name: %s\n", outputName.c_str()); + } #if defined(HAVE_OUTPUT_UHD) - if (useUHDOutput) { + else if (useUHDOutput) { fprintf(stderr, " UHD\n" " Device: %s\n" " Type: %s\n" @@ -649,12 +705,13 @@ int main(int argc, char* argv[]) outputuhd_conf.usrpType.c_str(), outputuhd_conf.masterClockRate); } - else if (useFileOutput) { -#else - if (useFileOutput) { #endif - fprintf(stderr, " Name: %s\n", outputName.c_str()); + else if (useZeroMQOutput) { + fprintf(stderr, " ZeroMQ\n" + " Listening on: %s\n", + outputName.c_str()); } + fprintf(stderr, " Sampling rate: "); if (outputRate > 1000) { if (outputRate > 1000000) { @@ -683,7 +740,13 @@ int main(int argc, char* argv[]) ret = -1; goto END_MAIN; #else - inputZeroMQReader.Open(inputName.substr(4)); + // The URL might start with zmq+tcp:// + if (inputName.substr(0, 4) == "zmq+") { + inputZeroMQReader.Open(inputName.substr(4)); + } + else { + inputZeroMQReader.Open(inputName); + } inputReader = &inputZeroMQReader; #endif } @@ -723,6 +786,14 @@ int main(int argc, char* argv[]) } } #endif +#if defined(HAVE_OUTPUT_ZEROMQ) + else if (useZeroMQOutput) { + /* We normalise the same way as for the UHD output */ + normalise = 1.0f/50000.0f; + + output = new OutputZeroMQ(outputName); + } +#endif flowgraph = new Flowgraph(); data.setLength(6144); |