diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2023-03-03 14:24:27 +0100 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2023-03-03 14:24:27 +0100 |
commit | 89e4bcbcba5883355a9b4777cea2bce0a1afd53d (patch) | |
tree | e4e64194db9d1af0cac724fa63072d756a67a68f /src/output | |
parent | 05d3e26409a8f62c7f55851390d61d953f59489a (diff) | |
download | dabmod-89e4bcbcba5883355a9b4777cea2bce0a1afd53d.tar.gz dabmod-89e4bcbcba5883355a9b4777cea2bce0a1afd53d.tar.bz2 dabmod-89e4bcbcba5883355a9b4777cea2bce0a1afd53d.zip |
Dexter: calculate frame margin from system time
Diffstat (limited to 'src/output')
-rwxr-xr-x | src/output/BladeRF.cpp | 2 | ||||
-rwxr-xr-x | src/output/BladeRF.h | 2 | ||||
-rw-r--r-- | src/output/Dexter.cpp | 24 | ||||
-rw-r--r-- | src/output/Dexter.h | 4 | ||||
-rw-r--r-- | src/output/Lime.cpp | 2 | ||||
-rw-r--r-- | src/output/Lime.h | 2 | ||||
-rw-r--r-- | src/output/SDR.cpp | 6 | ||||
-rw-r--r-- | src/output/SDR.h | 4 | ||||
-rw-r--r-- | src/output/SDRDevice.h | 2 | ||||
-rw-r--r-- | src/output/Soapy.cpp | 2 | ||||
-rw-r--r-- | src/output/Soapy.h | 2 | ||||
-rw-r--r-- | src/output/UHD.cpp | 2 | ||||
-rw-r--r-- | src/output/UHD.h | 2 |
13 files changed, 26 insertions, 30 deletions
diff --git a/src/output/BladeRF.cpp b/src/output/BladeRF.cpp index dd48736..db29898 100755 --- a/src/output/BladeRF.cpp +++ b/src/output/BladeRF.cpp @@ -304,7 +304,7 @@ double BladeRF::get_temperature(void) const } -void BladeRF::transmit_frame(const struct FrameData &frame) // SC16 frames +void BladeRF::transmit_frame(struct FrameData&& frame) // SC16 frames { const size_t num_samples = frame.buf.size() / (2*sizeof(int16_t)); diff --git a/src/output/BladeRF.h b/src/output/BladeRF.h index e048daa..1a63fbf 100755 --- a/src/output/BladeRF.h +++ b/src/output/BladeRF.h @@ -74,7 +74,7 @@ class BladeRF : public Output::SDRDevice virtual double get_txgain(void) const override; virtual void set_bandwidth(double bandwidth) override; virtual double get_bandwidth(void) const override; - virtual void transmit_frame(const struct FrameData& frame) override; + virtual void transmit_frame(struct FrameData&& frame) override; virtual RunStatistics get_run_statistics(void) const override; virtual double get_real_secs(void) const override; diff --git a/src/output/Dexter.cpp b/src/output/Dexter.cpp index 4e24cfb..b6e6700 100644 --- a/src/output/Dexter.cpp +++ b/src/output/Dexter.cpp @@ -2,7 +2,7 @@ Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Her Majesty the Queen in Right of Canada (Communications Research Center Canada) - Copyright (C) 2022 + Copyright (C) 2023 Matthias P. Braendli, matthias.braendli@mpb.li http://opendigitalradio.org @@ -369,7 +369,7 @@ double Dexter::get_temperature(void) const return std::numeric_limits<double>::quiet_NaN(); } -void Dexter::transmit_frame(const struct FrameData& frame) +void Dexter::transmit_frame(struct FrameData&& frame) { if (frame.buf.size() != TRANSMISSION_FRAME_LEN) { etiLog.level(debug) << "Dexter::transmit_frame Expected " << @@ -379,6 +379,8 @@ void Dexter::transmit_frame(const struct FrameData& frame) const bool require_timestamped_tx = (m_conf.enableSync and frame.ts.timestamp_valid); + const double margin_s = frame.ts.offset_to_system_time(); + if (m_buffer == nullptr) { if (require_timestamped_tx) { /* @@ -387,36 +389,28 @@ void Dexter::transmit_frame(const struct FrameData& frame) timeS - m_utc_seconds_at_startup; */ - // 10 because timestamp_pps is represented in 16.384 MHz clocks constexpr uint64_t TIMESTAMP_PPS_PER_DSP_CLOCKS = DSP_CLOCK / 16384000; + // TIMESTAMP_PPS_PER_DSP_CLOCKS=10 because timestamp_pps is represented in 16.384 MHz clocks uint64_t frame_ts_clocks = // at second level ((int64_t)frame.ts.timestamp_sec - (int64_t)m_utc_seconds_at_startup) * DSP_CLOCK + m_clock_count_at_startup + // at subsecond level (uint64_t)frame.ts.timestamp_pps * TIMESTAMP_PPS_PER_DSP_CLOCKS; - long long pps_clks = 0; - int r; - if ((r = iio_device_attr_read_longlong(m_dexter_dsp_tx, "pps_clks", &pps_clks)) != 0) { - etiLog.level(error) << "Failed to get dexter_dsp_tx.pps_clks: " << get_iio_error(r); - } - - const double margin_s = (double)((int64_t)frame_ts_clocks - pps_clks) / DSP_CLOCK; - etiLog.level(debug) << "DEXTER FCT " << frame.ts.fct << " TS CLK " << ((int64_t)frame.ts.timestamp_sec - (int64_t)m_utc_seconds_at_startup) * DSP_CLOCK << " + " << m_clock_count_at_startup << " + " << (uint64_t)frame.ts.timestamp_pps * TIMESTAMP_PPS_PER_DSP_CLOCKS << " = " << - frame_ts_clocks << " DELTA " << - frame_ts_clocks << " - " << pps_clks << " = " << margin_s; + frame_ts_clocks << " DELTA " << margin_s; // Ensure we hand the frame over to HW with a bit of margin - if (margin_s < 0.1) { + if (margin_s < 0.2) { etiLog.level(warn) << "Skip frame short margin " << margin_s; num_late++; return; } + int r; if ((r = iio_device_attr_write_longlong(m_dexter_dsp_tx, "stream0_start_clks", frame_ts_clocks)) != 0) { etiLog.level(warn) << "Skip frame, failed to set dexter_dsp_tx.stream0_start_clks = " << frame_ts_clocks << " : " << get_iio_error(r); num_late++; @@ -428,6 +422,8 @@ void Dexter::transmit_frame(const struct FrameData& frame) channel_up(); } + etiLog.level(debug) << "DEXTER TX " << frame.ts.fct << " TS margin " << margin_s; + if (m_require_timestamp_refresh) { etiLog.level(debug) << "DEXTER REQUIRE REFRESH"; channel_down(); diff --git a/src/output/Dexter.h b/src/output/Dexter.h index 36d0ef7..2bd63b1 100644 --- a/src/output/Dexter.h +++ b/src/output/Dexter.h @@ -2,7 +2,7 @@ Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Her Majesty the Queen in Right of Canada (Communications Research Center Canada) - Copyright (C) 2022 + Copyright (C) 2023 Matthias P. Braendli, matthias.braendli@mpb.li http://opendigitalradio.org @@ -64,7 +64,7 @@ class Dexter : public Output::SDRDevice virtual double get_txgain() const override; virtual void set_bandwidth(double bandwidth) override; virtual double get_bandwidth() const override; - virtual void transmit_frame(const struct FrameData& frame) override; + virtual void transmit_frame(struct FrameData&& frame) override; virtual RunStatistics get_run_statistics() const override; virtual double get_real_secs() const override; diff --git a/src/output/Lime.cpp b/src/output/Lime.cpp index d3e4640..bf466c3 100644 --- a/src/output/Lime.cpp +++ b/src/output/Lime.cpp @@ -389,7 +389,7 @@ float Lime::get_fifo_fill_percent(void) const return m_last_fifo_fill_percent * 100; } -void Lime::transmit_frame(const struct FrameData &frame) +void Lime::transmit_frame(struct FrameData&& frame) { if (not m_device) throw runtime_error("Lime device not set up"); diff --git a/src/output/Lime.h b/src/output/Lime.h index a4603c0..95c5c48 100644 --- a/src/output/Lime.h +++ b/src/output/Lime.h @@ -66,7 +66,7 @@ class Lime : public Output::SDRDevice virtual double get_txgain(void) const override; virtual void set_bandwidth(double bandwidth) override; virtual double get_bandwidth(void) const override; - virtual void transmit_frame(const struct FrameData &frame) override; + virtual void transmit_frame(struct FrameData&& frame) override; virtual RunStatistics get_run_statistics(void) const override; virtual double get_real_secs(void) const override; diff --git a/src/output/SDR.cpp b/src/output/SDR.cpp index 0b3299a..e22617e 100644 --- a/src/output/SDR.cpp +++ b/src/output/SDR.cpp @@ -213,7 +213,7 @@ void SDR::process_thread_entry() } if (m_device) { - handle_frame(frame); + handle_frame(std::move(frame)); } } } @@ -260,7 +260,7 @@ void SDR::sleep_through_frame() t_last_frame += wait_time; } -void SDR::handle_frame(struct FrameData& frame) +void SDR::handle_frame(struct FrameData&& frame) { // Assumes m_device is valid @@ -386,7 +386,7 @@ void SDR::handle_frame(struct FrameData& frame) " TS " << frame.ts.to_string(); } - m_device->transmit_frame(frame); + m_device->transmit_frame(std::move(frame)); } // ======================================= diff --git a/src/output/SDR.h b/src/output/SDR.h index 5c3b599..eb0ed9d 100644 --- a/src/output/SDR.h +++ b/src/output/SDR.h @@ -2,7 +2,7 @@ Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Her Majesty the Queen in Right of Canada (Communications Research Center Canada) - Copyright (C) 2022 + Copyright (C) 2023 Matthias P. Braendli, matthias.braendli@mpb.li http://opendigitalradio.org @@ -69,7 +69,7 @@ class SDR : public ModOutput, public ModMetadata, public RemoteControllable { private: void process_thread_entry(void); - void handle_frame(struct FrameData &frame); + void handle_frame(struct FrameData&& frame); void sleep_through_frame(void); SDRDeviceConfig& m_config; diff --git a/src/output/SDRDevice.h b/src/output/SDRDevice.h index f4b6c34..ffa1a3b 100644 --- a/src/output/SDRDevice.h +++ b/src/output/SDRDevice.h @@ -123,7 +123,7 @@ class SDRDevice { virtual double get_tx_freq(void) const = 0; virtual void set_txgain(double txgain) = 0; virtual double get_txgain(void) const = 0; - virtual void transmit_frame(const struct FrameData& frame) = 0; + virtual void transmit_frame(struct FrameData&& frame) = 0; virtual RunStatistics get_run_statistics(void) const = 0; virtual double get_real_secs(void) const = 0; virtual void set_rxgain(double rxgain) = 0; diff --git a/src/output/Soapy.cpp b/src/output/Soapy.cpp index c2ae88a..8c52546 100644 --- a/src/output/Soapy.cpp +++ b/src/output/Soapy.cpp @@ -272,7 +272,7 @@ double Soapy::get_temperature(void) const return std::numeric_limits<double>::quiet_NaN(); } -void Soapy::transmit_frame(const struct FrameData& frame) +void Soapy::transmit_frame(struct FrameData&& frame) { if (not m_device) throw runtime_error("Soapy device not set up"); diff --git a/src/output/Soapy.h b/src/output/Soapy.h index ca2618b..f3e1ee2 100644 --- a/src/output/Soapy.h +++ b/src/output/Soapy.h @@ -65,7 +65,7 @@ class Soapy : public Output::SDRDevice virtual double get_txgain(void) const override; virtual void set_bandwidth(double bandwidth) override; virtual double get_bandwidth(void) const override; - virtual void transmit_frame(const struct FrameData& frame) override; + virtual void transmit_frame(struct FrameData&& frame) override; virtual RunStatistics get_run_statistics(void) const override; virtual double get_real_secs(void) const override; diff --git a/src/output/UHD.cpp b/src/output/UHD.cpp index 6810249..c325272 100644 --- a/src/output/UHD.cpp +++ b/src/output/UHD.cpp @@ -315,7 +315,7 @@ double UHD::get_bandwidth(void) const return m_usrp->get_tx_bandwidth(); } -void UHD::transmit_frame(const struct FrameData& frame) +void UHD::transmit_frame(struct FrameData&& frame) { const double tx_timeout = 20.0; const size_t sizeIn = frame.buf.size() / sizeof(complexf); diff --git a/src/output/UHD.h b/src/output/UHD.h index 4c1a4f0..164254c 100644 --- a/src/output/UHD.h +++ b/src/output/UHD.h @@ -79,7 +79,7 @@ class UHD : public Output::SDRDevice virtual double get_txgain(void) const override; virtual void set_bandwidth(double bandwidth) override; virtual double get_bandwidth(void) const override; - virtual void transmit_frame(const struct FrameData& frame) override; + virtual void transmit_frame(struct FrameData&& frame) override; virtual RunStatistics get_run_statistics(void) const override; virtual double get_real_secs(void) const override; |