Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added msg many to one to combine msg ports

  • Loading branch information...
commit 122fbb086b91d1b4043ad77b8e5f45b07ac7b5e6 1 parent 8c6b7ea
@guruofquality authored
View
1  grc/CMakeLists.txt
@@ -47,6 +47,7 @@ list(APPEND grc_sources
extras_packet_deframer.xml
extras_stream_selector.xml
extras_pmt_rpc.xml
+ extras_msg_many_to_one.xml
)
install(
View
1  grc/extras_block_tree.xml
@@ -50,5 +50,6 @@
<block>extras_uhd_amsg_source</block>
<block>extras_decim_fir</block>
<block>extras_pmt_rpc</block>
+ <block>extras_msg_many_to_one</block>
</cat>
</cat>
View
25 grc/extras_msg_many_to_one.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0"?>
+<block>
+ <name>Extras: Msg M21</name>
+ <key>extras_msg_many_to_one</key>
+ <import>import gnuradio.extras as gr_extras</import>
+ <make>gr_extras.msg_many_to_one($num_inputs)</make>
+ <param>
+ <name>Num Inputs</name>
+ <key>num_inputs</key>
+ <value>2</value>
+ <type>int</type>
+ </param>
+ <sink>
+ <name>in</name>
+ <type></type>
+ <nports>$num_inputs</nports>
+ </sink>
+ <source>
+ <name>out</name>
+ <type></type>
+ </source>
+ <doc>
+The message many to one block combines messages from several inputs.
+ </doc>
+</block>
View
1  include/gnuradio/extras/CMakeLists.txt
@@ -47,6 +47,7 @@ list(APPEND include_sources
socket_to_blob.h
stream_to_blob.h
tuntap.h
+ msg_many_to_one.h
)
install(
View
39 include/gnuradio/extras/msg_many_to_one.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2012 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef INCLUDED_GR_EXTRAS_MSG_MANY_TO_ONE_H
+#define INCLUDED_GR_EXTRAS_MSG_MANY_TO_ONE_H
+
+#include <gnuradio/extras/api.h>
+#include <gnuradio/block.h>
+
+namespace gnuradio{ namespace extras{
+
+class GR_EXTRAS_API msg_many_to_one : virtual public block{
+public:
+ typedef boost::shared_ptr<msg_many_to_one> sptr;
+
+ static sptr make(const size_t num_inputs);
+};
+
+}}
+
+#endif /* INCLUDED_GR_EXTRAS_MSG_MANY_TO_ONE_H */
View
1  lib/CMakeLists.txt
@@ -56,6 +56,7 @@ list(APPEND gr_extras_sources
socket_to_blob.cc
stream_to_blob.cc
tuntap.cc
+ msg_many_to_one.cc
)
list(APPEND gr_extras_libs
View
68 lib/msg_many_to_one.cc
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2012 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <gnuradio/extras/msg_many_to_one.h>
+#include <gr_io_signature.h>
+#include <boost/foreach.hpp>
+
+using namespace gnuradio::extras;
+
+class msg_many_to_one_impl : public msg_many_to_one
+{
+public:
+ msg_many_to_one_impl(const size_t num_inputs):
+ block(
+ "message many to one",
+ gr_make_io_signature(num_inputs, num_inputs, 1),
+ gr_make_io_signature(1, 1, 1)
+ )
+ {
+ _tags.reserve(1024); //something reasonably large so we dont malloc
+ }
+
+ int work(
+ const InputItems &input_items,
+ const OutputItems &output_items
+ ){
+ std::vector<gr_tag_t> tags;
+ for (size_t i = 0; i < input_items.size(); i++)
+ {
+ const uint64_t nread = this->nitems_read(i); //number of items read on port i
+
+ //read all tags associated with port i for items in this work function
+ this->get_tags_in_range(_tags, i, nread, nread+input_items[i].size());
+
+ BOOST_FOREACH(const gr_tag_t &tag, _tags)
+ {
+ this->add_item_tag(0, tag);
+ }
+ }
+
+ return output_items[0].size();
+ }
+
+ std::vector<gr_tag_t> _tags;
+};
+
+msg_many_to_one::sptr msg_many_to_one::make(const size_t num_inputs)
+{
+ return gnuradio::get_initial_sptr(new msg_many_to_one_impl(num_inputs));
+}
View
3  swig/extras_blobs.i
@@ -30,6 +30,7 @@
#include <gnuradio/extras/socket_to_blob.h>
#include <gnuradio/extras/stream_to_blob.h>
#include <gnuradio/extras/tuntap.h>
+#include <gnuradio/extras/msg_many_to_one.h>
%}
%include <gnuradio/extras/blob_to_filedes.h>
@@ -39,6 +40,7 @@
%include <gnuradio/extras/socket_to_blob.h>
%include <gnuradio/extras/stream_to_blob.h>
%include <gnuradio/extras/tuntap.h>
+%include <gnuradio/extras/msg_many_to_one.h>
////////////////////////////////////////////////////////////////////////
// block magic
@@ -51,3 +53,4 @@ GR_EXTRAS_SWIG_BLOCK_FACTORY(filedes_to_blob)
GR_EXTRAS_SWIG_BLOCK_FACTORY(socket_to_blob)
GR_EXTRAS_SWIG_BLOCK_FACTORY(stream_to_blob)
GR_EXTRAS_SWIG_BLOCK_FACTORY(tuntap)
+GR_EXTRAS_SWIG_BLOCK_FACTORY(msg_many_to_one)
Please sign in to comment.
Something went wrong with that request. Please try again.