[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 01/08: blocks: add blocks_stream_align to s
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 01/08: blocks: add blocks_stream_align to support acquiring alignment to TSB from an unaligned TSB stream |
Date: |
Wed, 1 Apr 2015 13:00:35 +0000 (UTC) |
This is an automated email from the git hooks/post-receive script.
jcorgan pushed a commit to branch master
in repository gnuradio.
commit d7d7ab7d69818b2a2b9feb4f48c8499b8e654f71
Author: Tim O'Shea <address@hidden>
Date: Fri Feb 13 18:56:46 2015 -0500
blocks: add blocks_stream_align to support acquiring alignment to TSB from
an unaligned TSB stream
---
gr-blocks/grc/blocks_block_tree.xml | 1 +
gr-blocks/grc/blocks_tagged_stream_align.xml | 59 +++++++++++++++
gr-blocks/include/gnuradio/blocks/CMakeLists.txt | 1 +
.../include/gnuradio/blocks/tagged_stream_align.h | 55 ++++++++++++++
gr-blocks/lib/CMakeLists.txt | 1 +
gr-blocks/lib/tagged_stream_align_impl.cc | 86 ++++++++++++++++++++++
gr-blocks/lib/tagged_stream_align_impl.h | 53 +++++++++++++
gr-blocks/swig/blocks_swig5.i | 3 +
8 files changed, 259 insertions(+)
diff --git a/gr-blocks/grc/blocks_block_tree.xml
b/gr-blocks/grc/blocks_block_tree.xml
index eaebe09..383ec87 100644
--- a/gr-blocks/grc/blocks_block_tree.xml
+++ b/gr-blocks/grc/blocks_block_tree.xml
@@ -190,6 +190,7 @@
<block>blocks_tag_gate</block>
<block>blocks_tagged_file_sink</block>
<block>blocks_tagged_stream_mux</block>
+ <block>blocks_tagged_stream_align</block>
<block>blocks_stream_to_tagged_stream</block>
</cat>
<cat>
diff --git a/gr-blocks/grc/blocks_tagged_stream_align.xml
b/gr-blocks/grc/blocks_tagged_stream_align.xml
new file mode 100644
index 0000000..be0238d
--- /dev/null
+++ b/gr-blocks/grc/blocks_tagged_stream_align.xml
@@ -0,0 +1,59 @@
+<block>
+ <name>Tagged Stream Align</name>
+ <key>blocks_tagged_stream_align</key>
+ <import>from gnuradio import blocks</import>
+ <make>blocks.tagged_stream_align($type.size*$vlen, $lengthtagname)</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>Length tag names</name>
+ <key>lengthtagname</key>
+ <value>packet_len</value>
+ <type>string</type>
+ </param>
+ <param>
+ <name>Vector Length</name>
+ <key>vlen</key>
+ <value>1</value>
+ <type>int</type>
+ </param>
+ <sink>
+ <name>in</name>
+ <type>$type</type>
+ <vlen>$vlen</vlen>
+ </sink>
+ <source>
+ <name>out</name>
+ <type>$type</type>
+ <vlen>$vlen</vlen>
+ </source>
+</block>
+
diff --git a/gr-blocks/include/gnuradio/blocks/CMakeLists.txt
b/gr-blocks/include/gnuradio/blocks/CMakeLists.txt
index 662f705..3364423 100644
--- a/gr-blocks/include/gnuradio/blocks/CMakeLists.txt
+++ b/gr-blocks/include/gnuradio/blocks/CMakeLists.txt
@@ -162,6 +162,7 @@ install(FILES
tag_debug.h
tag_gate.h
tagged_file_sink.h
+ tagged_stream_align.h
tagged_stream_mux.h
tagged_stream_multiply_length.h
tagged_stream_to_pdu.h
diff --git a/gr-blocks/include/gnuradio/blocks/tagged_stream_align.h
b/gr-blocks/include/gnuradio/blocks/tagged_stream_align.h
new file mode 100644
index 0000000..9796293
--- /dev/null
+++ b/gr-blocks/include/gnuradio/blocks/tagged_stream_align.h
@@ -0,0 +1,55 @@
+/* -*- 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_TAGGED_STREAM_ALIGN_H
+#define INCLUDED_TAGGED_STREAM_ALIGN_H
+
+#include <gnuradio/blocks/api.h>
+#include <gnuradio/block.h>
+
+namespace gr {
+ namespace blocks {
+
+ /*!
+ * \brief Align a stream to a tagged stream item
+ * \ingroup stream_operators_blk
+ *
+ * \details
+ * Takes an unaligned stream of tagged stream items and aligns to the
first item
+ */
+ class BLOCKS_API tagged_stream_align : virtual public block
+ {
+ public:
+ typedef boost::shared_ptr<tagged_stream_align> sptr;
+
+ /*!
+ * Make a tagged stream align
+ *
+ * \param lengthtagname Length tag key
+ */
+ static sptr make(size_t itemsize, const std::string &lengthtagname);
+ };
+
+ } // namespace blocks
+} // namespace gr
+
+#endif /* INCLUDED_TAGGED_STREAM_ALIGN_H */
+
diff --git a/gr-blocks/lib/CMakeLists.txt b/gr-blocks/lib/CMakeLists.txt
index 32cc7b3..c451a50 100644
--- a/gr-blocks/lib/CMakeLists.txt
+++ b/gr-blocks/lib/CMakeLists.txt
@@ -188,6 +188,7 @@ list(APPEND gr_blocks_sources
tcp_connection.cc
tuntap_pdu_impl.cc
tag_gate_impl.cc
+ tagged_stream_align_impl.cc
tagged_stream_mux_impl.cc
uchar_array_to_float.cc
uchar_to_float_impl.cc
diff --git a/gr-blocks/lib/tagged_stream_align_impl.cc
b/gr-blocks/lib/tagged_stream_align_impl.cc
new file mode 100644
index 0000000..9314bb5
--- /dev/null
+++ b/gr-blocks/lib/tagged_stream_align_impl.cc
@@ -0,0 +1,86 @@
+/* -*- 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 <gnuradio/io_signature.h>
+#include "tagged_stream_align_impl.h"
+
+namespace gr {
+ namespace blocks {
+
+ tagged_stream_align::sptr
+ tagged_stream_align::make(size_t itemsize, const std::string
&lengthtagname)
+ {
+ return gnuradio::get_initial_sptr (new
tagged_stream_align_impl(itemsize, lengthtagname));
+ }
+
+ tagged_stream_align_impl::tagged_stream_align_impl(size_t itemsize, const
std::string &lengthtagname)
+ : block("tagged_stream_align",
+ io_signature::make(1, -1, itemsize),
+ io_signature::make(1, 1, itemsize)),
+ d_itemsize(itemsize),
+ d_lengthtag(pmt::mp(lengthtagname)),
+ d_have_sync(false)
+ {
+ }
+
+ tagged_stream_align_impl::~tagged_stream_align_impl()
+ {
+ }
+
+ int
+ tagged_stream_align_impl::general_work(int noutput_items,
+ gr_vector_int &ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ std::vector<tag_t> tags;
+ if(d_have_sync){
+ int ncp = std::min(noutput_items, ninput_items[0]);
+ get_tags_in_range(tags, 0, nitems_read(0), nitems_read(0) +
noutput_items);
+ for(size_t i=0; i<tags.size(); i++){
+ gr::tag_t t = tags[i];
+ int offset = (nitems_read(0) - nitems_written(0));
+ t.offset -= offset;
+ add_item_tag(0,t);
+ }
+ memcpy(output_items[0], input_items[0], ncp*d_itemsize);
+ consume_each(ncp);
+ return ncp;
+ } else {
+ get_tags_in_range(tags, 0, nitems_read(0), nitems_read(0) +
noutput_items, d_lengthtag);
+ if(tags.size() > 0){
+ d_have_sync = true;
+ consume_each( tags[0].offset - nitems_read(0) );
+ } else {
+ consume_each(ninput_items[0]);
+ }
+ return 0;
+ }
+ }
+
+ } /* namespace blocks */
+} /* namespace gr */
+
diff --git a/gr-blocks/lib/tagged_stream_align_impl.h
b/gr-blocks/lib/tagged_stream_align_impl.h
new file mode 100644
index 0000000..0481f88
--- /dev/null
+++ b/gr-blocks/lib/tagged_stream_align_impl.h
@@ -0,0 +1,53 @@
+/* -*- 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_TAGGED_STREAM_ALIGN_IMPL_H
+#define INCLUDED_TAGGED_STREAM_ALIGN_IMPL_H
+
+#include <vector>
+#include <gnuradio/blocks/tagged_stream_align.h>
+
+namespace gr {
+ namespace blocks {
+
+ class tagged_stream_align_impl : public tagged_stream_align
+ {
+ private:
+ size_t d_itemsize;
+ pmt::pmt_t d_lengthtag;
+ bool d_have_sync;
+
+ public:
+ tagged_stream_align_impl(size_t itemsize, const std::string
&lengthtagname);
+ ~tagged_stream_align_impl();
+
+ int general_work(int noutput_items,
+ gr_vector_int &ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ };
+
+ } // namespace blocks
+} // namespace gr
+
+#endif
+
diff --git a/gr-blocks/swig/blocks_swig5.i b/gr-blocks/swig/blocks_swig5.i
index 497388c..b35492c 100644
--- a/gr-blocks/swig/blocks_swig5.i
+++ b/gr-blocks/swig/blocks_swig5.i
@@ -51,6 +51,7 @@
#include "gnuradio/blocks/sub_ii.h"
#include "gnuradio/blocks/sub_cc.h"
#include "gnuradio/blocks/tag_gate.h"
+#include "gnuradio/blocks/tagged_stream_align.h"
#include "gnuradio/blocks/tagged_stream_mux.h"
#include "gnuradio/blocks/tagged_stream_multiply_length.h"
#include "gnuradio/blocks/tagged_stream_to_pdu.h"
@@ -93,6 +94,7 @@
%include "gnuradio/blocks/sub_ii.h"
%include "gnuradio/blocks/sub_cc.h"
%include "gnuradio/blocks/tag_gate.h"
+%include "gnuradio/blocks/tagged_stream_align.h"
%include "gnuradio/blocks/tagged_stream_mux.h"
%include "gnuradio/blocks/tagged_stream_multiply_length.h"
%include "gnuradio/blocks/tagged_stream_to_pdu.h"
@@ -134,6 +136,7 @@ GR_SWIG_BLOCK_MAGIC2(blocks, sub_ss);
GR_SWIG_BLOCK_MAGIC2(blocks, sub_ii);
GR_SWIG_BLOCK_MAGIC2(blocks, sub_cc);
GR_SWIG_BLOCK_MAGIC2(blocks, tag_gate);
+GR_SWIG_BLOCK_MAGIC2(blocks, tagged_stream_align);
GR_SWIG_BLOCK_MAGIC2(blocks, tagged_stream_mux);
GR_SWIG_BLOCK_MAGIC2(blocks, tagged_stream_multiply_length);
GR_SWIG_BLOCK_MAGIC2(blocks, tagged_stream_to_pdu);
- [Commit-gnuradio] [gnuradio] branch master updated (6168622 -> 7fe6115), git, 2015/04/01
- [Commit-gnuradio] [gnuradio] 01/08: blocks: add blocks_stream_align to support acquiring alignment to TSB from an unaligned TSB stream,
git <=
- [Commit-gnuradio] [gnuradio] 04/08: qtgui: fixed issue with QWT 6 and 6.1 changes., git, 2015/04/01
- [Commit-gnuradio] [gnuradio] 05/08: Merge branch 'maint', git, 2015/04/01
- [Commit-gnuradio] [gnuradio] 03/08: modtool: update manifest based on CGRAN meeting, git, 2015/04/01
- [Commit-gnuradio] [gnuradio] 08/08: Merge remote-tracking branch 'tom/qtgui/timedisplayform_qwt_fix', git, 2015/04/01
- [Commit-gnuradio] [gnuradio] 02/08: blocks: fix tagged_stream_align min/max output items, git, 2015/04/01
- [Commit-gnuradio] [gnuradio] 06/08: Merge remote-tracking branch 'osh/tsb_align', git, 2015/04/01
- [Commit-gnuradio] [gnuradio] 07/08: Merge remote-tracking branch 'nwest/cgran_meeting', git, 2015/04/01