diff options
Diffstat (limited to 'src/DabMod.cpp')
-rw-r--r-- | src/DabMod.cpp | 71 |
1 files changed, 56 insertions, 15 deletions
diff --git a/src/DabMod.cpp b/src/DabMod.cpp index f97c05d..278f8ce 100644 --- a/src/DabMod.cpp +++ b/src/DabMod.cpp @@ -56,6 +56,7 @@ #include "output/SDR.h" #include "output/UHD.h" #include "output/Soapy.h" +#include "output/Dexter.h" #include "output/Lime.h" #include "output/BladeRF.h" #include "OutputZeroMQ.h" @@ -114,7 +115,7 @@ enum class run_modulator_state_t { reconfigure // Some sort of change of configuration we cannot handle happened }; -static run_modulator_state_t run_modulator(modulator_data& m); +static run_modulator_state_t run_modulator(const mod_settings_t& mod_settings, modulator_data& m); static void printModSettings(const mod_settings_t& mod_settings) { @@ -151,6 +152,11 @@ static void printModSettings(const mod_settings_t& mod_settings) mod_settings.sdr_device_config.masterClockRate << "\n"; } #endif +#if defined(HAVE_DEXTER) + else if (mod_settings.useDexterOutput) { + ss << " PrecisionWave DEXTER\n"; + } +#endif #if defined(HAVE_LIMESDR) else if (mod_settings.useLimeOutput) { ss << " LimeSDR\n" @@ -192,8 +198,7 @@ static void printModSettings(const mod_settings_t& mod_settings) fprintf(stderr, "%s", ss.str().c_str()); } -static shared_ptr<ModOutput> prepare_output( - mod_settings_t& s) +static shared_ptr<ModOutput> prepare_output(mod_settings_t& s) { shared_ptr<ModOutput> output; @@ -249,6 +254,16 @@ static shared_ptr<ModOutput> prepare_output( rcs.enrol((Output::SDR*)output.get()); } #endif +#if defined(HAVE_DEXTER) + else if (s.useDexterOutput) { + /* We normalise specifically range [-32768; 32767] */ + s.normalise = 32767.0f / normalise_factor; + s.sdr_device_config.sampleRate = s.outputRate; + auto dexterdevice = make_shared<Output::Dexter>(s.sdr_device_config); + output = make_shared<Output::SDR>(s.sdr_device_config, dexterdevice); + rcs.enrol((Output::SDR*)output.get()); + } +#endif #if defined(HAVE_LIMESDR) else if (s.useLimeOutput) { /* We normalise the same way as for the UHD output */ @@ -319,6 +334,7 @@ int launch_modulator(int argc, char* argv[]) mod_settings.useUHDOutput or mod_settings.useZeroMQOutput or mod_settings.useSoapyOutput or + mod_settings.useDexterOutput or mod_settings.useLimeOutput or mod_settings.useBladeRFOutput)) { throw std::runtime_error("Configuration error: Output not specified"); @@ -333,9 +349,9 @@ int launch_modulator(int argc, char* argv[]) mod_settings.fileOutputFormat == "s16")) { format_converter = make_shared<FormatConverter>(mod_settings.fileOutputFormat); } - else if (mod_settings.useBladeRFOutput) { - format_converter = make_shared<FormatConverter>(mod_settings.BladeRFOutputFormat); - } + else if (mod_settings.useBladeRFOutput or mod_settings.useDexterOutput) { + format_converter = make_shared<FormatConverter>("s16"); + } auto output = prepare_output(mod_settings); @@ -410,6 +426,10 @@ int launch_modulator(int argc, char* argv[]) if (format_converter) { flowgraph.connect(modulator, format_converter); flowgraph.connect(format_converter, output); + + if (auto o = dynamic_pointer_cast<Output::SDR>(output)) { + o->set_sample_size(format_converter->get_format_size()); + } } else { flowgraph.connect(modulator, output); @@ -419,7 +439,7 @@ int launch_modulator(int argc, char* argv[]) etiLog.level(info) << inputReader->GetPrintableInfo(); } - run_modulator_state_t st = run_modulator(m); + run_modulator_state_t st = run_modulator(mod_settings, m); etiLog.log(trace, "DABMOD,run_modulator() = %d", st); switch (st) { @@ -489,12 +509,13 @@ struct zmq_input_timeout : public std::exception } }; -static run_modulator_state_t run_modulator(modulator_data& m) +static run_modulator_state_t run_modulator(const mod_settings_t& mod_settings, modulator_data& m) { auto ret = run_modulator_state_t::failure; try { int last_eti_fct = -1; auto last_frame_received = chrono::steady_clock::now(); + frame_timestamp ts; Buffer data; if (m.inputReader) { data.setLength(6144); @@ -568,6 +589,7 @@ static run_modulator_state_t run_modulator(modulator_data& m) fct = m.etiReader->getFct(); fp = m.etiReader->getFp(); + ts = m.ediInput->ediReader.getTimestamp(); } else if (m.ediInput) { while (running and not m.ediInput->ediReader.isFrameReady()) { @@ -596,9 +618,10 @@ static run_modulator_state_t run_modulator(modulator_data& m) fct = m.ediInput->ediReader.getFct(); fp = m.ediInput->ediReader.getFp(); + ts = m.ediInput->ediReader.getTimestamp(); } - const unsigned expected_fct = (last_eti_fct + 1) % 250; + bool fct_good = false; if (last_eti_fct == -1) { if (fp != 0) { // Do not start the flowgraph before we get to FP 0 @@ -609,19 +632,37 @@ static run_modulator_state_t run_modulator(modulator_data& m) continue; } else { - last_eti_fct = fct; - m.framecount++; - m.flowgraph->run(); + fct_good = true; } } - else if (fct == expected_fct) { + else { + const unsigned expected_fct = (last_eti_fct + 1) % 250; + if (fct == expected_fct) { + fct_good = true; + } + else { + etiLog.level(info) << "ETI FCT discontinuity, expected " << + expected_fct << " received " << fct; + if (m.ediInput) { + m.ediInput->ediReader.clearFrame(); + } + return run_modulator_state_t::again; + } + } + + // timestamp is good if we run unsynchronised, or if it's in the future + bool ts_good = not mod_settings.sdr_device_config.enableSync or + (ts.timestamp_valid and ts.offset_to_system_time() > 0); + + if (fct_good and ts_good) { last_eti_fct = fct; m.framecount++; m.flowgraph->run(); } else { - etiLog.level(info) << "ETI FCT discontinuity, expected " << - expected_fct << " received " << fct; + etiLog.level(warn) << "Skipping frame " << fct << " FCT " << + (fct_good ? "good" : "bad") << " TS " << + (ts_good ? "good" : "bad"); if (m.ediInput) { m.ediInput->ediReader.clearFrame(); } |