From 9ca1180a2940438f1de443d75392a26dfd5d2f70 Mon Sep 17 00:00:00 2001 From: Josh Bailey Date: Sun, 18 Feb 2024 08:25:45 +0000 Subject: [PATCH] fix and test full frequency range coverage. --- lib/retuner_impl.cc | 7 +++++-- python/iqtlabs/qa_retune_fft.py | 2 ++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/retuner_impl.cc b/lib/retuner_impl.cc index 0121188b..83da895f 100644 --- a/lib/retuner_impl.cc +++ b/lib/retuner_impl.cc @@ -234,7 +234,9 @@ retuner_impl::retuner_impl(uint64_t samp_rate, uint64_t tune_jitter_hz, } void retuner_impl::add_range_(uint64_t freq_start, uint64_t freq_end) { - uint64_t steps = (freq_end - freq_start) / tune_step_hz_ + 1; + // TODO: this could be a vector of steps that could be retuned to + // in random order each time, to implement a frequency hopping scanner. + uint64_t steps = (freq_end - freq_start) / tune_step_hz_ + 2; tuning_ranges_.push_back({freq_start, freq_end, steps}); } @@ -293,10 +295,11 @@ void retuner_impl::parse_tuning_ranges_(const std::string &tuning_ranges) { } } stare_mode_ = tuning_ranges_[0].steps == 1; - tune_freq_ = tuning_ranges_[0].freq_start; if (stare_mode_) { tune_freq_ += (tuning_ranges_[0].freq_end - tuning_ranges_[0].freq_start) / 2; + } else { + tune_freq_ = tuning_ranges_[0].freq_start; } } diff --git a/python/iqtlabs/qa_retune_fft.py b/python/iqtlabs/qa_retune_fft.py index b1bc242b..66d154a1 100755 --- a/python/iqtlabs/qa_retune_fft.py +++ b/python/iqtlabs/qa_retune_fft.py @@ -466,6 +466,8 @@ def retune_fft(self, fft_roll): all_df = pd.DataFrame(records)[["t", "f", "v"]] all_df["v"] = all_df["v"].round(1) all_df = all_df.sort_values(["t", "f", "v"]) + self.assertEqual(all_df["f"].max(), freq_end) + self.assertEqual(all_df["f"].min(), freq_start) for _, df in all_df.groupby("t"): # must have plausible unscaled dB value