diff --git a/include/gnuradio/iqtlabs/retune_fft.h b/include/gnuradio/iqtlabs/retune_fft.h index d44e38dd..a16df43e 100644 --- a/include/gnuradio/iqtlabs/retune_fft.h +++ b/include/gnuradio/iqtlabs/retune_fft.h @@ -238,6 +238,10 @@ class IQTLABS_API retune_fft : virtual public gr::block { const std::string &description, uint64_t rotate_secs, bool pre_fft, bool tag_now, bool low_power_hold_down, bool slew_rx_time, uint64_t peak_fft_range); + virtual double get_freq_start(void) = 0; + virtual double get_freq_end(void) = 0; + virtual double get_tune_freq(void) = 0; + virtual bool get_stare_mode(void) = 0; }; } // namespace iqtlabs diff --git a/include/gnuradio/iqtlabs/retune_pre_fft.h b/include/gnuradio/iqtlabs/retune_pre_fft.h index 9f753618..92bb39a9 100644 --- a/include/gnuradio/iqtlabs/retune_pre_fft.h +++ b/include/gnuradio/iqtlabs/retune_pre_fft.h @@ -236,6 +236,10 @@ class IQTLABS_API retune_pre_fft : virtual public gr::block { uint64_t skip_tune_step_fft, const std::string &tuning_ranges, bool tag_now, bool low_power_hold_down, bool slew_rx_time); + virtual double get_freq_start(void) = 0; + virtual double get_freq_end(void) = 0; + virtual double get_tune_freq(void) = 0; + virtual bool get_stare_mode(void) = 0; }; } // namespace iqtlabs diff --git a/lib/retune_fft_impl.h b/lib/retune_fft_impl.h index a223a58f..8a3cdb89 100644 --- a/lib/retune_fft_impl.h +++ b/lib/retune_fft_impl.h @@ -267,6 +267,10 @@ class retune_fft_impl : public retune_fft, base_impl, retuner_impl { gr_vector_const_void_star &input_items, gr_vector_void_star &output_items); bool stop(); + double get_freq_start(void) override { return freq_start_; }; + double get_freq_end(void) override { return freq_end_; }; + double get_tune_freq(void) override { return tune_freq_; }; + bool get_stare_mode(void) override { return stare_mode_; }; }; } // namespace iqtlabs diff --git a/lib/retune_pre_fft_impl.h b/lib/retune_pre_fft_impl.h index ff010786..96f9debc 100644 --- a/lib/retune_pre_fft_impl.h +++ b/lib/retune_pre_fft_impl.h @@ -241,6 +241,10 @@ class retune_pre_fft_impl : public retune_pre_fft, base_impl, retuner_impl { int general_work(int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items); + double get_freq_start(void) override { return freq_start_; }; + double get_freq_end(void) override { return freq_end_; }; + double get_tune_freq(void) override { return tune_freq_; }; + bool get_stare_mode(void) override { return stare_mode_; }; }; } // namespace iqtlabs diff --git a/lib/retuner_impl.cc b/lib/retuner_impl.cc index 57c9b4d3..f4be9b29 100644 --- a/lib/retuner_impl.cc +++ b/lib/retuner_impl.cc @@ -237,11 +237,16 @@ retuner_impl::retuner_impl(COUNT_T samp_rate, COUNT_T tune_jitter_hz, void retuner_impl::add_range_(COUNT_T freq_start, COUNT_T freq_end) { // TODO: this could be a vector of steps that could be retuned to // in random order each time, to implement a frequency hopping scanner. - COUNT_T steps = (freq_end - freq_start) / tune_step_hz_ + 1; - if (steps > 1) { - ++steps; + if (freq_end == 0) { + freq_end = freq_start + tune_step_hz_; + tuning_ranges_.push_back({freq_start, freq_end, 1}); + } else { + COUNT_T steps = (freq_end - freq_start) / tune_step_hz_ + 1; + if (steps > 1) { + ++steps; + } + tuning_ranges_.push_back({freq_start, freq_end, steps}); } - tuning_ranges_.push_back({freq_start, freq_end, steps}); } std::string retuner_impl::describe_ranges_() { @@ -267,7 +272,7 @@ bool retuner_impl::need_retune_(COUNT_T n) { void retuner_impl::parse_tuning_ranges_(const std::string &tuning_ranges) { if (tuning_ranges.length() == 0) { - if (freq_end_ <= freq_start_) { + if (freq_end_ && freq_end_ <= freq_start_) { throw std::invalid_argument( "invalid freq_start/freq_end (end must be greater than start)"); } diff --git a/python/iqtlabs/bindings/docstrings/retune_fft_pydoc_template.h b/python/iqtlabs/bindings/docstrings/retune_fft_pydoc_template.h index 46bfb367..8ff7ce44 100644 --- a/python/iqtlabs/bindings/docstrings/retune_fft_pydoc_template.h +++ b/python/iqtlabs/bindings/docstrings/retune_fft_pydoc_template.h @@ -19,9 +19,24 @@ static const char *__doc_gr_iqtlabs_retune_fft = R"doc()doc"; - static const char *__doc_gr_iqtlabs_retune_fft_retune_fft = R"doc()doc"; + static const char *__doc_gr_iqtlabs_retune_fft_retune_fft_0 = R"doc()doc"; + + + static const char *__doc_gr_iqtlabs_retune_fft_retune_fft_1 = R"doc()doc"; static const char *__doc_gr_iqtlabs_retune_fft_make = R"doc()doc"; + + static const char *__doc_gr_iqtlabs_retune_fft_get_freq_start = R"doc()doc"; + + + static const char *__doc_gr_iqtlabs_retune_fft_get_freq_end = R"doc()doc"; + + + static const char *__doc_gr_iqtlabs_retune_fft_get_tune_freq = R"doc()doc"; + + + static const char *__doc_gr_iqtlabs_retune_fft_get_stare_mode = R"doc()doc"; + diff --git a/python/iqtlabs/bindings/docstrings/retune_pre_fft_pydoc_template.h b/python/iqtlabs/bindings/docstrings/retune_pre_fft_pydoc_template.h index 0874f02a..9ade6f7c 100644 --- a/python/iqtlabs/bindings/docstrings/retune_pre_fft_pydoc_template.h +++ b/python/iqtlabs/bindings/docstrings/retune_pre_fft_pydoc_template.h @@ -19,9 +19,24 @@ static const char *__doc_gr_iqtlabs_retune_pre_fft = R"doc()doc"; - static const char *__doc_gr_iqtlabs_retune_pre_fft_retune_pre_fft = R"doc()doc"; + static const char *__doc_gr_iqtlabs_retune_pre_fft_retune_pre_fft_0 = R"doc()doc"; + + + static const char *__doc_gr_iqtlabs_retune_pre_fft_retune_pre_fft_1 = R"doc()doc"; static const char *__doc_gr_iqtlabs_retune_pre_fft_make = R"doc()doc"; + + static const char *__doc_gr_iqtlabs_retune_pre_fft_get_freq_start = R"doc()doc"; + + + static const char *__doc_gr_iqtlabs_retune_pre_fft_get_freq_end = R"doc()doc"; + + + static const char *__doc_gr_iqtlabs_retune_pre_fft_get_tune_freq = R"doc()doc"; + + + static const char *__doc_gr_iqtlabs_retune_pre_fft_get_stare_mode = R"doc()doc"; + diff --git a/python/iqtlabs/bindings/retune_fft_python.cc b/python/iqtlabs/bindings/retune_fft_python.cc index 422299e5..e50e4c9f 100644 --- a/python/iqtlabs/bindings/retune_fft_python.cc +++ b/python/iqtlabs/bindings/retune_fft_python.cc @@ -14,7 +14,7 @@ /* BINDTOOL_GEN_AUTOMATIC(0) */ /* BINDTOOL_USE_PYGCCXML(0) */ /* BINDTOOL_HEADER_FILE(retune_fft.h) */ -/* BINDTOOL_HEADER_FILE_HASH(cff45390851d866fe94d901964d4c8e3) */ +/* BINDTOOL_HEADER_FILE_HASH(43b2cd7ea0524e4efbb2e67aec9f6453) */ /***********************************************************************************/ #include @@ -65,6 +65,30 @@ void bind_retune_fft(py::module& m) + + + .def("get_freq_start",&retune_fft::get_freq_start, + D(retune_fft,get_freq_start) + ) + + + + .def("get_freq_end",&retune_fft::get_freq_end, + D(retune_fft,get_freq_end) + ) + + + + .def("get_tune_freq",&retune_fft::get_tune_freq, + D(retune_fft,get_tune_freq) + ) + + + + .def("get_stare_mode",&retune_fft::get_stare_mode, + D(retune_fft,get_stare_mode) + ) + ; diff --git a/python/iqtlabs/bindings/retune_pre_fft_python.cc b/python/iqtlabs/bindings/retune_pre_fft_python.cc index b33b7569..34156c3c 100644 --- a/python/iqtlabs/bindings/retune_pre_fft_python.cc +++ b/python/iqtlabs/bindings/retune_pre_fft_python.cc @@ -14,7 +14,7 @@ /* BINDTOOL_GEN_AUTOMATIC(0) */ /* BINDTOOL_USE_PYGCCXML(0) */ /* BINDTOOL_HEADER_FILE(retune_pre_fft.h) */ -/* BINDTOOL_HEADER_FILE_HASH(d9cffb6f149f14f3c3f25e4ffbc910db) */ +/* BINDTOOL_HEADER_FILE_HASH(265b0d93aae52b3c826e485fd6b36c16) */ /***********************************************************************************/ #include @@ -57,6 +57,30 @@ void bind_retune_pre_fft(py::module& m) + + + .def("get_freq_start",&retune_pre_fft::get_freq_start, + D(retune_pre_fft,get_freq_start) + ) + + + + .def("get_freq_end",&retune_pre_fft::get_freq_end, + D(retune_pre_fft,get_freq_end) + ) + + + + .def("get_tune_freq",&retune_pre_fft::get_tune_freq, + D(retune_pre_fft,get_tune_freq) + ) + + + + .def("get_stare_mode",&retune_pre_fft::get_stare_mode, + D(retune_pre_fft,get_stare_mode) + ) + ; diff --git a/python/iqtlabs/qa_retune_fft.py b/python/iqtlabs/qa_retune_fft.py index 9f50cea8..2d1593df 100755 --- a/python/iqtlabs/qa_retune_fft.py +++ b/python/iqtlabs/qa_retune_fft.py @@ -538,6 +538,57 @@ def test_retune_fft_roll(self): self.retune_fft(fft_roll=True, stare=True) +class qa_getters(gr_unittest.TestCase): + def test_pre_getter(self): + iqtlabs_retune_pre_fft_0 = retune_pre_fft( + nfft=1024, + samp_rate=int(1e6), + tune_jitter_hz=0, + fft_batch_size=1, + tag="rx_freq", + freq_start=int(1e6), + freq_end=0, + tune_step_hz=int(1e6), + tune_step_fft=256, + skip_tune_step_fft=0, + tuning_ranges="", + tag_now=False, + low_power_hold_down=False, + slew_rx_time=False, + ) + self.assertTrue(iqtlabs_retune_pre_fft_0.get_stare_mode()) + self.assertEqual(1.5e6, iqtlabs_retune_pre_fft_0.get_tune_freq()) + + def test_getter(self): + iqtlabs_retune_fft_0 = retune_fft( + tag="rx_freq", + nfft=1024, + samp_rate=int(1e6), + tune_jitter_hz=0, + freq_start=int(1e6), + freq_end=0, + tune_step_hz=int(1e6), + tune_step_fft=256, + skip_tune_step_fft=0, + fft_min=0, + fft_max=1e9, + sdir="", + write_step_fft=0, + bucket_range=1, + tuning_ranges="", + description="a text description", + rotate_secs=3600, + pre_fft=True, + tag_now=False, + low_power_hold_down=False, + slew_rx_time=False, + peak_fft_range=0, + ) + self.assertTrue(iqtlabs_retune_fft_0.get_stare_mode()) + self.assertEqual(1.5e6, iqtlabs_retune_fft_0.get_tune_freq()) + + if __name__ == "__main__": gr_unittest.run(qa_retune_fft_no_roll) gr_unittest.run(qa_retune_fft_roll) + gr_unittest.run(qa_getters)