commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] [gnuradio] 04/23: blocks: adding a message port to the


From: git
Subject: [Commit-gnuradio] [gnuradio] 04/23: blocks: adding a message port to the copy block to enable/disable copy.
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 9d4d472e93aeb77f3e808499215a2f07d563a83c
Author: Tom Rondeau <address@hidden>
Date:   Tue Jun 24 18:37:19 2014 -0400

    blocks: adding a message port to the copy block to enable/disable copy.
---
 gr-blocks/grc/blocks_copy.xml |  5 +++++
 gr-blocks/lib/copy_impl.cc    | 12 ++++++++++++
 gr-blocks/lib/copy_impl.h     |  2 ++
 3 files changed, 19 insertions(+)

diff --git a/gr-blocks/grc/blocks_copy.xml b/gr-blocks/grc/blocks_copy.xml
index 55c4b34..4d505d9 100644
--- a/gr-blocks/grc/blocks_copy.xml
+++ b/gr-blocks/grc/blocks_copy.xml
@@ -67,6 +67,11 @@ self.$(id).set_enabled($enabled)</make>
                <type>$type</type>
                <vlen>$vlen</vlen>
        </sink>
+       <sink>
+               <name>en</name>
+               <type>message</type>
+               <optional>1</optional>
+       </sink>
        <source>
                <name>out</name>
                <type>$type</type>
diff --git a/gr-blocks/lib/copy_impl.cc b/gr-blocks/lib/copy_impl.cc
index 564ea09..0284836 100644
--- a/gr-blocks/lib/copy_impl.cc
+++ b/gr-blocks/lib/copy_impl.cc
@@ -45,6 +45,9 @@ namespace gr {
         d_itemsize(itemsize),
         d_enabled(true)
     {
+      message_port_register_in(pmt::mp("en"));
+      set_msg_handler(pmt::mp("en"),
+                      boost::bind(&copy_impl::handle_enable, this, _1));
     }
 
     copy_impl::~copy_impl()
@@ -52,6 +55,15 @@ namespace gr {
     }
 
     void
+    copy_impl::handle_enable(pmt::pmt_t msg)
+    {
+      if(pmt::is_bool(msg)) {
+        bool en = pmt::to_bool(msg);
+        d_enabled = en;
+      }
+    }
+
+    void
     copy_impl::forecast(int noutput_items, gr_vector_int 
&ninput_items_required)
     {
       unsigned ninputs = ninput_items_required.size();
diff --git a/gr-blocks/lib/copy_impl.h b/gr-blocks/lib/copy_impl.h
index 5f3c81a..925efb2 100644
--- a/gr-blocks/lib/copy_impl.h
+++ b/gr-blocks/lib/copy_impl.h
@@ -41,6 +41,8 @@ namespace gr {
       void forecast(int noutput_items, gr_vector_int &ninput_items_required);
       bool check_topology(int ninputs, int noutputs);
 
+      void handle_enable(pmt::pmt_t msg);
+
       void set_enabled(bool enable) { d_enabled = enable; }
       bool enabled() const { return d_enabled;}
 



reply via email to

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