summaryrefslogtreecommitdiff
path: root/gr-blocks
diff options
context:
space:
mode:
authorJohnathan Corgan <jcorgan@corganenterprises.com>2012-09-04 15:38:17 -0700
committerJohnathan Corgan <jcorgan@corganenterprises.com>2012-09-04 15:38:17 -0700
commit2065177207d9f504fdcd374ed6567379c51c7a06 (patch)
tree65d1cb7b59d63dacc6fba053fca70c82a1bc68a8 /gr-blocks
parent0aec5b7f568b0cfc320a202631757efc247aca6e (diff)
blocks: added gr::blocks::streams_to_stream
Diffstat (limited to 'gr-blocks')
-rw-r--r--gr-blocks/grc/blocks_block_tree.xml1
-rw-r--r--gr-blocks/grc/blocks_streams_to_stream.xml67
-rw-r--r--gr-blocks/include/blocks/CMakeLists.txt1
-rw-r--r--gr-blocks/include/blocks/streams_to_stream.h52
-rw-r--r--gr-blocks/lib/CMakeLists.txt1
-rw-r--r--gr-blocks/lib/streams_to_stream_impl.cc72
-rw-r--r--gr-blocks/lib/streams_to_stream_impl.h44
-rwxr-xr-xgr-blocks/python/qa_pipe_fittings.py3
-rw-r--r--gr-blocks/swig/blocks_swig.i3
9 files changed, 243 insertions, 1 deletions
diff --git a/gr-blocks/grc/blocks_block_tree.xml b/gr-blocks/grc/blocks_block_tree.xml
index 6bd39c4f44..1bcf672b9e 100644
--- a/gr-blocks/grc/blocks_block_tree.xml
+++ b/gr-blocks/grc/blocks_block_tree.xml
@@ -81,5 +81,6 @@
<block>stream_mux.xml</block>
<block>stream_to_streams.xml</block>
<block>stream_to_vector.xml</block>
+ <block>streams_to_stream.xml</block>
</cat>
</cat>
diff --git a/gr-blocks/grc/blocks_streams_to_stream.xml b/gr-blocks/grc/blocks_streams_to_stream.xml
new file mode 100644
index 0000000000..2aa17dbe23
--- /dev/null
+++ b/gr-blocks/grc/blocks_streams_to_stream.xml
@@ -0,0 +1,67 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+##Streams to Stream
+###################################################
+ -->
+<block>
+ <name>Streams to Stream</name>
+ <key>blocks_streams_to_stream</key>
+ <import>from gnuradio import blocks</import>
+ <make>blocks.streams_to_stream($type.size*$vlen, $num_streams)</make>
+ <param>
+ <name>IO Type</name>
+ <key>type</key>
+ <type>enum</type>
+ <option>
+ <name>Complex</name>
+ <key>complex</key>
+ <opt>size:gr.sizeof_gr_complex</opt>
+ </option>
+ <option>
+ <name>Float</name>
+ <key>float</key>
+ <opt>size:gr.sizeof_float</opt>
+ </option>
+ <option>
+ <name>Int</name>
+ <key>int</key>
+ <opt>size:gr.sizeof_int</opt>
+ </option>
+ <option>
+ <name>Short</name>
+ <key>short</key>
+ <opt>size:gr.sizeof_short</opt>
+ </option>
+ <option>
+ <name>Byte</name>
+ <key>byte</key>
+ <opt>size:gr.sizeof_char</opt>
+ </option>
+ </param>
+ <param>
+ <name>Num Streams</name>
+ <key>num_streams</key>
+ <value>2</value>
+ <type>int</type>
+ </param>
+ <param>
+ <name>Vec Length</name>
+ <key>vlen</key>
+ <value>1</value>
+ <type>int</type>
+ </param>
+ <check>$num_streams &gt; 0</check>
+ <check>$vlen &gt;= 1</check>
+ <sink>
+ <name>in</name>
+ <type>$type</type>
+ <vlen>$vlen</vlen>
+ <nports>$num_streams</nports>
+ </sink>
+ <source>
+ <name>out</name>
+ <type>$type</type>
+ <vlen>$vlen</vlen>
+ </source>
+</block>
diff --git a/gr-blocks/include/blocks/CMakeLists.txt b/gr-blocks/include/blocks/CMakeLists.txt
index 1612ea7ec2..d7d13c4e0a 100644
--- a/gr-blocks/include/blocks/CMakeLists.txt
+++ b/gr-blocks/include/blocks/CMakeLists.txt
@@ -123,6 +123,7 @@ install(FILES
stream_mux.h
stream_to_streams.h
stream_to_vector.h
+ streams_to_stream.h
uchar_to_float.h
DESTINATION ${GR_INCLUDE_DIR}/gnuradio/blocks
COMPONENT "blocks_devel"
diff --git a/gr-blocks/include/blocks/streams_to_stream.h b/gr-blocks/include/blocks/streams_to_stream.h
new file mode 100644
index 0000000000..01dcd1be33
--- /dev/null
+++ b/gr-blocks/include/blocks/streams_to_stream.h
@@ -0,0 +1,52 @@
+/* -*- c++ -*- */
+/*
+ * 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_BLOCKS_STREAMS_TO_STREAM_H
+#define INCLUDED_BLOCKS_STREAMS_TO_STREAM_H
+
+#include <blocks/api.h>
+#include <gr_sync_interpolator.h>
+
+namespace gr {
+ namespace blocks {
+
+ /*!
+ * \brief Convert N streams of 1 item into a 1 stream of N items
+ * \ingroup slicedice_blk
+ *
+ * Convert N streams of 1 item into 1 stream of N items.
+ * Repeat ad infinitum.
+ */
+ class BLOCKS_API streams_to_stream : virtual public gr_sync_interpolator
+ {
+ public:
+
+ // gr::blocks::streams_to_stream::sptr
+ typedef boost::shared_ptr<streams_to_stream> sptr;
+
+ static sptr make(size_t itemsize, size_t nstreams);
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_BLOCKS_STREAMS_TO_STREAM_H */
diff --git a/gr-blocks/lib/CMakeLists.txt b/gr-blocks/lib/CMakeLists.txt
index df0fa87af4..504aafaa24 100644
--- a/gr-blocks/lib/CMakeLists.txt
+++ b/gr-blocks/lib/CMakeLists.txt
@@ -160,6 +160,7 @@ list(APPEND gr_blocks_sources
stream_mux_impl.cc
stream_to_streams_impl.cc
stream_to_vector_impl.cc
+ streams_to_stream_impl.cc
uchar_array_to_float.cc
uchar_to_float_impl.cc
)
diff --git a/gr-blocks/lib/streams_to_stream_impl.cc b/gr-blocks/lib/streams_to_stream_impl.cc
new file mode 100644
index 0000000000..09c593e815
--- /dev/null
+++ b/gr-blocks/lib/streams_to_stream_impl.cc
@@ -0,0 +1,72 @@
+/* -*- c++ -*- */
+/*
+ * 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "streams_to_stream_impl.h"
+#include <gr_io_signature.h>
+
+namespace gr {
+ namespace blocks {
+
+ streams_to_stream::sptr streams_to_stream::make(size_t itemsize, size_t nstreams)
+ {
+ return gnuradio::get_initial_sptr(new streams_to_stream_impl(itemsize, nstreams));
+ }
+
+ streams_to_stream_impl::streams_to_stream_impl(size_t itemsize, size_t nstreams)
+ : gr_sync_interpolator ("streams_to_stream",
+ gr_make_io_signature (nstreams, nstreams, itemsize),
+ gr_make_io_signature (1, 1, itemsize),
+ nstreams)
+ {
+ }
+
+ int
+ streams_to_stream_impl::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ size_t itemsize = output_signature()->sizeof_stream_item (0);
+
+ const char **inv = (const char **) &input_items[0];
+ char *out = (char *) output_items[0];
+ int nstreams = input_items.size();
+
+ assert (noutput_items % nstreams == 0);
+ int ni = noutput_items / nstreams;
+
+ for (int i = 0; i < ni; i++){
+ for (int j = 0; j < nstreams; j++){
+ memcpy(out, inv[j], itemsize);
+ out += itemsize;
+ inv[j] += itemsize;
+ }
+ }
+
+ return noutput_items;
+ }
+
+ } /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/streams_to_stream_impl.h b/gr-blocks/lib/streams_to_stream_impl.h
new file mode 100644
index 0000000000..6f686172c9
--- /dev/null
+++ b/gr-blocks/lib/streams_to_stream_impl.h
@@ -0,0 +1,44 @@
+/* -*- c++ -*- */
+/*
+ * 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_STREAMS_TO_STREAM_IMPL_H
+#define INCLUDED_STREAMS_TO_STREAM_IMPL_H
+
+#include <blocks/streams_to_stream.h>
+
+namespace gr {
+ namespace blocks {
+
+ class BLOCKS_API streams_to_stream_impl : public streams_to_stream
+ {
+ public:
+ streams_to_stream_impl(size_t itemsize, size_t nstreams);
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_STREAMS_TO_STREAM_IMPL_H */
diff --git a/gr-blocks/python/qa_pipe_fittings.py b/gr-blocks/python/qa_pipe_fittings.py
index 097856867f..e5335e9798 100755
--- a/gr-blocks/python/qa_pipe_fittings.py
+++ b/gr-blocks/python/qa_pipe_fittings.py
@@ -64,7 +64,7 @@ class test_pipe_fittings(gr_unittest.TestCase):
for d in range(n):
self.assertEqual(expected_results[d], dsts[d].data())
- """
+
def test_002(self):
# Test streams_to_stream (using stream_to_streams).
@@ -87,6 +87,7 @@ class test_pipe_fittings(gr_unittest.TestCase):
self.tb.run()
self.assertEqual(expected_results, dst.data())
+ """
def test_003(self):
#Test streams_to_vector (using stream_to_streams & vector_to_stream).
diff --git a/gr-blocks/swig/blocks_swig.i b/gr-blocks/swig/blocks_swig.i
index 64996f2b2d..d0c97a2d15 100644
--- a/gr-blocks/swig/blocks_swig.i
+++ b/gr-blocks/swig/blocks_swig.i
@@ -101,6 +101,7 @@
#include "blocks/stream_mux.h"
#include "blocks/stream_to_streams.h"
#include "blocks/stream_to_vector.h"
+#include "blocks/streams_to_stream.h"
#include "blocks/sub_ff.h"
#include "blocks/sub_ss.h"
#include "blocks/sub_ii.h"
@@ -184,6 +185,7 @@
%include "blocks/stream_mux.h"
%include "blocks/stream_to_streams.h"
%include "blocks/stream_to_vector.h"
+%include "blocks/streams_to_stream.h"
%include "blocks/sub_ff.h"
%include "blocks/sub_ss.h"
%include "blocks/sub_ii.h"
@@ -266,6 +268,7 @@ GR_SWIG_BLOCK_MAGIC2(blocks, short_to_float);
GR_SWIG_BLOCK_MAGIC2(blocks, stream_mux);
GR_SWIG_BLOCK_MAGIC2(blocks, stream_to_streams);
GR_SWIG_BLOCK_MAGIC2(blocks, stream_to_vector);
+GR_SWIG_BLOCK_MAGIC2(blocks, streams_to_stream);
GR_SWIG_BLOCK_MAGIC2(blocks, sub_ff);
GR_SWIG_BLOCK_MAGIC2(blocks, sub_ss);
GR_SWIG_BLOCK_MAGIC2(blocks, sub_ii);