commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] [gnuradio] 05/23: digital: adding a rotate_phase messa


From: git
Subject: [Commit-gnuradio] [gnuradio] 05/23: digital: adding a rotate_phase message for the constellation_receiver to adjust the phase of the constellation.
Date: Thu, 26 Jun 2014 19:54:43 +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 0b5f9ebf537ea1d40aac5355fd0f8c4089632610
Author: Tom Rondeau <address@hidden>
Date:   Wed Jun 25 17:42:05 2014 -0400

    digital: adding a rotate_phase message for the constellation_receiver to 
adjust the phase of the constellation.
    
    Addresses Issue #599.
---
 .../grc/digital_constellation_receiver_cb.xml      |  6 ++++++
 gr-digital/lib/constellation_receiver_cb_impl.cc   | 24 ++++++++++++++++++----
 gr-digital/lib/constellation_receiver_cb_impl.h    | 13 ++++++++++++
 3 files changed, 39 insertions(+), 4 deletions(-)

diff --git a/gr-digital/grc/digital_constellation_receiver_cb.xml 
b/gr-digital/grc/digital_constellation_receiver_cb.xml
index e6a1461..134e027 100644
--- a/gr-digital/grc/digital_constellation_receiver_cb.xml
+++ b/gr-digital/grc/digital_constellation_receiver_cb.xml
@@ -40,6 +40,12 @@
                 <optional>1</optional>
        </sink>
 
+       <sink>
+               <name>rotate_phase</name>
+               <type>message</type>
+                <optional>1</optional>
+       </sink>
+
        <source>
                <name>out</name>
                <type>byte</type>
diff --git a/gr-digital/lib/constellation_receiver_cb_impl.cc 
b/gr-digital/lib/constellation_receiver_cb_impl.cc
index c4fe1e0..01a9201 100644
--- a/gr-digital/lib/constellation_receiver_cb_impl.cc
+++ b/gr-digital/lib/constellation_receiver_cb_impl.cc
@@ -60,11 +60,17 @@ namespace gr {
     {
       if(d_constellation->dimensionality() != 1)
         throw std::runtime_error("This receiver only works with constellations 
of dimension 1.");
+
       message_port_register_in(pmt::mp("set_constellation"));
       set_msg_handler(
         pmt::mp("set_constellation"),
         boost::bind(&constellation_receiver_cb_impl::handle_set_constellation,
                     this, _1));
+
+      message_port_register_in(pmt::mp("rotate_phase"));
+      set_msg_handler(pmt::mp("rotate_phase"),
+                      
boost::bind(&constellation_receiver_cb_impl::handle_rotate_phase,
+                                  this, _1));
     }
 
     constellation_receiver_cb_impl::~constellation_receiver_cb_impl()
@@ -96,12 +102,22 @@ namespace gr {
     void
     constellation_receiver_cb_impl::handle_set_constellation(pmt::pmt_t 
constellation_pmt)
     {
-      boost::any constellation_any = pmt::any_ref(constellation_pmt);
-      constellation_sptr constellation = boost::any_cast<constellation_sptr>(
-        constellation_any);
-      set_constellation(constellation);
+      if(pmt::is_any(constellation_pmt)) {
+        boost::any constellation_any = pmt::any_ref(constellation_pmt);
+        constellation_sptr constellation = boost::any_cast<constellation_sptr>(
+          constellation_any);
+        set_constellation(constellation);
+      }
     }
 
+    void
+    constellation_receiver_cb_impl::handle_rotate_phase(pmt::pmt_t rotation)
+    {
+      if(pmt::is_real(rotation)) {
+        double phase = pmt::to_double(rotation);
+        d_phase += phase;
+      }
+    }
 
     void
     constellation_receiver_cb_impl::set_constellation(constellation_sptr 
constellation)
diff --git a/gr-digital/lib/constellation_receiver_cb_impl.h 
b/gr-digital/lib/constellation_receiver_cb_impl.h
index 6247deb..90482e2 100644
--- a/gr-digital/lib/constellation_receiver_cb_impl.h
+++ b/gr-digital/lib/constellation_receiver_cb_impl.h
@@ -58,8 +58,21 @@ namespace gr {
       //! Typically used when we receive a tag with values for these.
       void set_phase_freq(float phase, float freq);
 
+      /*!
+       * Message handler port to receiver a new constellation.
+       * constellation_pmt is a pmt_any; constellation objects have
+       * an as_pmt function that can be used for this purpose.
+       */
       void handle_set_constellation(pmt::pmt_t constellation_pmt);
 
+      /*!
+       * Message handler port to update the phase of the rotator. The
+       * phase should be a real number (float or double) that is added
+       * to the current phase. So we can rotate the constellation by
+       * 90 degress by passing a value of pmt::from_double(M_PI/2).
+       */
+      void handle_rotate_phase(pmt::pmt_t rotation);
+
       //! Set the constellation used.
       //! Typically used when we receive a tag with a value for this.
       void set_constellation(constellation_sptr constellation);



reply via email to

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