commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] [gnuradio] 13/23: filter: adds a message input port to


From: git
Subject: [Commit-gnuradio] [gnuradio] 13/23: filter: adds a message input port to frequency xlating FIR filter to update the frequency.
Date: Thu, 26 Jun 2014 19:54:44 +0000 (UTC)

This is an automated email from the git hooks/post-receive script.

trondeau pushed a commit to branch master
in repository gnuradio.

commit 9fe2a4a6b7756a5b58e72453970be783bebf3386
Author: Tom Rondeau <address@hidden>
Date:   Thu Jun 26 13:59:19 2014 -0400

    filter: adds a message input port to frequency xlating FIR filter to update 
the frequency.
    
    The FFT version does not have this message port since it's a hierarchical 
block and there isn't an easy way to manage this.
---
 .../grc/filter_freq_xlating_fir_filter_xxx.xml     |  7 +++++
 .../filter/freq_xlating_fir_filter_XXX.h.t         | 11 +++++++-
 .../lib/freq_xlating_fir_filter_XXX_impl.cc.t      | 33 ++++++++++++++++++----
 gr-filter/lib/freq_xlating_fir_filter_XXX_impl.h.t |  6 ++--
 4 files changed, 48 insertions(+), 9 deletions(-)

diff --git a/gr-filter/grc/filter_freq_xlating_fir_filter_xxx.xml 
b/gr-filter/grc/filter_freq_xlating_fir_filter_xxx.xml
index 178a42f..8c8e100 100644
--- a/gr-filter/grc/filter_freq_xlating_fir_filter_xxx.xml
+++ b/gr-filter/grc/filter_freq_xlating_fir_filter_xxx.xml
@@ -86,6 +86,13 @@
                <name>in</name>
                <type>$type.input</type>
        </sink>
+
+       <sink>
+         <name>freq</name>
+         <type>message</type>
+          <optional>1</optional>
+       </sink>
+
        <source>
                <name>out</name>
                <type>$type.output</type>
diff --git a/gr-filter/include/gnuradio/filter/freq_xlating_fir_filter_XXX.h.t 
b/gr-filter/include/gnuradio/filter/freq_xlating_fir_filter_XXX.h.t
index 0174774..d8cb8f9 100644
--- a/gr-filter/include/gnuradio/filter/freq_xlating_fir_filter_XXX.h.t
+++ b/gr-filter/include/gnuradio/filter/freq_xlating_fir_filter_XXX.h.t
@@ -21,7 +21,7 @@
  */
 
 /*
- * WARNING: This file is automatically generated by cmake. 
+ * WARNING: This file is automatically generated by cmake.
  * Any changes made to this file will be overwritten.
  */
 
@@ -49,6 +49,15 @@ namespace gr {
      *
      * Uses a single input array to produce a single output array.
      * Additional inputs and/or outputs are ignored.
+     *
+     * - freq (input):
+     *        Receives a PMT pair: (intern("freq"), double(frequency).
+     *        The block then sets its frequency translation value to
+     *        the new frequency provided by the message. A tag is then
+     *        produced when the new frequency is applied to let
+     *        downstream blocks know when this has taken affect.
+     *        Use the filter's group delay to determine when the
+     *        transients after the change have settled down.
      */
     class FILTER_API @BASE_NAME@ : virtual public sync_decimator
     {
diff --git a/gr-filter/lib/freq_xlating_fir_filter_XXX_impl.cc.t 
b/gr-filter/lib/freq_xlating_fir_filter_XXX_impl.cc.t
index 4d7e269..57fa47f 100644
--- a/gr-filter/lib/freq_xlating_fir_filter_XXX_impl.cc.t
+++ b/gr-filter/lib/freq_xlating_fir_filter_XXX_impl.cc.t
@@ -21,7 +21,7 @@
  */
 
 /*
- * WARNING: This file is automatically generated by cmake. 
+ * WARNING: This file is automatically generated by cmake.
  * Any changes made to this file will be overwritten.
  */
 
@@ -35,7 +35,7 @@
 
 namespace gr {
   namespace filter {
-    
+
     @BASE_NAME@::sptr
     @BASE_NAME@::make(int decimation,
                      const std::vector<@TAP_TYPE@> &taps,
@@ -65,6 +65,11 @@ namespace gr {
 
       set_history(d_proto_taps.size());
       build_composite_fir();
+
+      message_port_register_in(pmt::mp("freq"));
+      set_msg_handler(pmt::mp("freq"),
+                      boost::bind(&@IMPL_NAME@::handle_set_center_freq,
+                                  this, _1));
     }
 
     @IMPL_NAME@::address@hidden@()
@@ -81,8 +86,8 @@ namespace gr {
       //    x(t) -> (mult by -fwT0) -> LPF -> decim -> y(t)
       // We switch things up here to:
       //    x(t) -> BPF -> decim -> (mult by fwT0*decim) -> y(t)
-      // The BPF is the baseband filter (LPF) moved up to the 
-      // center frequency fwT0. We then apply a derotator 
+      // The BPF is the baseband filter (LPF) moved up to the
+      // center frequency fwT0. We then apply a derotator
       // with -fwT0 to downshift the signal to baseband.
 
       float fwT0 = 2 * M_PI * d_center_freq / d_sampling_freq;
@@ -106,7 +111,7 @@ namespace gr {
     {
       return d_center_freq;
     }
-    
+
     void
     @IMPL_NAME@::set_taps(const std::vector<@TAP_TYPE@> &taps)
     {
@@ -120,6 +125,18 @@ namespace gr {
       return d_proto_taps;
     }
 
+    void
+    @IMPL_NAME@::handle_set_center_freq(pmt::pmt_t msg)
+    {
+      if(pmt::is_pair(msg)) {
+        pmt::pmt_t x = pmt::cdr(msg);
+        if(pmt::is_real(x)) {
+          double freq = pmt::to_double(x);
+          set_center_freq(freq*d_sampling_freq);
+        }
+      }
+    }
+
     int
     @IMPL_NAME@::work(int noutput_items,
                      gr_vector_const_void_star &input_items,
@@ -133,6 +150,11 @@ namespace gr {
        set_history(d_proto_taps.size());
        build_composite_fir();
        d_updated = false;
+
+        // Tell downstream items where the frequency change was applied
+        add_item_tag(0, nitems_written(0),
+                     pmt::intern("freq"), pmt::from_double(d_center_freq),
+                     alias_pmt());
        return 0;                    // history requirements may have changed.
       }
 
@@ -147,4 +169,3 @@ namespace gr {
 
   } /* namespace filter */
 } /* namespace gr */
-
diff --git a/gr-filter/lib/freq_xlating_fir_filter_XXX_impl.h.t 
b/gr-filter/lib/freq_xlating_fir_filter_XXX_impl.h.t
index 352593b..bd7aced 100644
--- a/gr-filter/lib/freq_xlating_fir_filter_XXX_impl.h.t
+++ b/gr-filter/lib/freq_xlating_fir_filter_XXX_impl.h.t
@@ -21,7 +21,7 @@
  */
 
 /*
- * WARNING: This file is automatically generated by cmake. 
+ * WARNING: This file is automatically generated by cmake.
  * Any changes made to this file will be overwritten.
  */
 
@@ -45,7 +45,7 @@ namespace gr {
       double                   d_center_freq;
       double                   d_sampling_freq;
       bool                     d_updated;
-      
+
       virtual void build_composite_fir();
     public:
 
@@ -61,6 +61,8 @@ namespace gr {
       void set_taps(const std::vector<@TAP_TYPE@> &taps);
       std::vector<@TAP_TYPE@> taps() const;
 
+      void handle_set_center_freq(pmt::pmt_t msg);
+
       int work(int noutput_items,
               gr_vector_const_void_star &input_items,
               gr_vector_void_star &output_items);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]