summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Rondeau <tom@trondeau.com>2014-06-25 17:42:05 -0400
committerTom Rondeau <tom@trondeau.com>2014-06-25 17:42:05 -0400
commit0b5f9ebf537ea1d40aac5355fd0f8c4089632610 (patch)
tree0f26cec4073c04b0833793419cf4ca06efb92045
parent9d4d472e93aeb77f3e808499215a2f07d563a83c (diff)
digital: adding a rotate_phase message for the constellation_receiver to adjust the phase of the constellation.
Addresses Issue #599.
-rw-r--r--gr-digital/grc/digital_constellation_receiver_cb.xml6
-rw-r--r--gr-digital/lib/constellation_receiver_cb_impl.cc24
-rw-r--r--gr-digital/lib/constellation_receiver_cb_impl.h13
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 e6a1461c38..134e027759 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 c4fe1e08bd..01a920174c 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 6247deb801..90482e2cc5 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);