diff options
-rw-r--r-- | gnuradio-core/src/lib/general/gr_keep_one_in_n.cc | 24 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/gr_keep_one_in_n.h | 1 | ||||
-rw-r--r-- | gr-howto-write-a-block/version.sh | 2 | ||||
-rw-r--r-- | gr-noaa/lib/noaa_hrpt_pll_cf.cc | 9 | ||||
-rw-r--r-- | version.sh | 2 |
5 files changed, 31 insertions, 7 deletions
diff --git a/gnuradio-core/src/lib/general/gr_keep_one_in_n.cc b/gnuradio-core/src/lib/general/gr_keep_one_in_n.cc index 85495e277..8bccefa95 100644 --- a/gnuradio-core/src/lib/general/gr_keep_one_in_n.cc +++ b/gnuradio-core/src/lib/general/gr_keep_one_in_n.cc @@ -40,6 +40,12 @@ gr_keep_one_in_n::gr_keep_one_in_n (size_t item_size, int n) gr_make_io_signature (1, 1, item_size)), d_count(n) { + // To avoid bad behavior with using set_relative_rate in this block with + // VERY large values of n, we will keep track of things ourselves. Using + // this to turn off automatic tag propagation, which will be handled + // locally in general_work(). + set_tag_propagation_policy(TPP_DONT); + set_n(n); } @@ -52,7 +58,10 @@ gr_keep_one_in_n::set_n(int n) d_n = n; d_count = n; - set_relative_rate(1.0 / (float)n); + // keep our internal understanding of the relative rate of this block + // don't set the relative rate, though, and we will handle our own + // tag propagation. + d_decim_rate = 1.0/(float)d_n; } int @@ -80,6 +89,19 @@ gr_keep_one_in_n::general_work (int noutput_items, ni++; } + // Because we have set TPP_DONT, we have to propagate the tags here manually. + // Adjustment of the tag sample value is done using the float d_decim_rate. + std::vector<pmt::pmt_t> tags; + std::vector<pmt::pmt_t>::iterator t; + get_tags_in_range(tags, 0, nitems_read(0), nitems_read(0)+ni); + for(t = tags.begin(); t != tags.end(); t++) { + uint64_t newcount = pmt::pmt_to_uint64(pmt::pmt_tuple_ref(*t, 0)); + add_item_tag(0, newcount * d_decim_rate, + pmt::pmt_tuple_ref(*t, 1), + pmt::pmt_tuple_ref(*t, 2), + pmt::pmt_tuple_ref(*t, 3)); + } + consume_each (ni); return no; } diff --git a/gnuradio-core/src/lib/general/gr_keep_one_in_n.h b/gnuradio-core/src/lib/general/gr_keep_one_in_n.h index 337827446..ba573618e 100644 --- a/gnuradio-core/src/lib/general/gr_keep_one_in_n.h +++ b/gnuradio-core/src/lib/general/gr_keep_one_in_n.h @@ -43,6 +43,7 @@ class gr_keep_one_in_n : public gr_block int d_n; int d_count; + float d_decim_rate; protected: gr_keep_one_in_n (size_t item_size, int n); diff --git a/gr-howto-write-a-block/version.sh b/gr-howto-write-a-block/version.sh index 759d52806..05ffe83b4 100644 --- a/gr-howto-write-a-block/version.sh +++ b/gr-howto-write-a-block/version.sh @@ -1,4 +1,4 @@ MAJOR_VERSION=3 API_COMPAT=4 -MINOR_VERSION=1 +MINOR_VERSION=2 MAINT_VERSION=git diff --git a/gr-noaa/lib/noaa_hrpt_pll_cf.cc b/gr-noaa/lib/noaa_hrpt_pll_cf.cc index 08ab1d15f..ba2ce98d5 100644 --- a/gr-noaa/lib/noaa_hrpt_pll_cf.cc +++ b/gr-noaa/lib/noaa_hrpt_pll_cf.cc @@ -67,15 +67,16 @@ noaa_hrpt_pll_cf::work(int noutput_items, for (int i = 0; i < noutput_items; i++) { + // Generate and mix out carrier + float re, im; + gr_sincosf(d_phase, &im, &re); + out[i] = (in[i]*gr_complex(re, -im)).imag(); + // Adjust PLL phase/frequency float error = phase_wrap(gr_fast_atan2f(in[i].imag(), in[i].real()) - d_phase); d_freq = gr_branchless_clip(d_freq + error*d_beta, d_max_offset); d_phase = phase_wrap(d_phase + error*d_alpha + d_freq); - // Generate and mix out carrier - float re, im; - gr_sincosf(d_phase, &im, &re); - out[i] = (in[i]*gr_complex(re, -im)).imag(); } return noutput_items; diff --git a/version.sh b/version.sh index 759d52806..05ffe83b4 100644 --- a/version.sh +++ b/version.sh @@ -1,4 +1,4 @@ MAJOR_VERSION=3 API_COMPAT=4 -MINOR_VERSION=1 +MINOR_VERSION=2 MAINT_VERSION=git |