summaryrefslogtreecommitdiff
path: root/gnuradio-core
diff options
context:
space:
mode:
Diffstat (limited to 'gnuradio-core')
-rw-r--r--gnuradio-core/src/lib/general/CMakeLists.txt2
-rw-r--r--gnuradio-core/src/lib/general/general.i4
-rw-r--r--gnuradio-core/src/lib/general/gr_head.h1
-rw-r--r--gnuradio-core/src/lib/general/gr_head.i1
-rw-r--r--gnuradio-core/src/lib/general/gr_keep_m_in_n.cc85
-rw-r--r--gnuradio-core/src/lib/general/gr_keep_m_in_n.h62
-rw-r--r--gnuradio-core/src/lib/general/gr_keep_m_in_n.i35
-rw-r--r--gnuradio-core/src/lib/general/gr_pack_k_bits_bb.cc69
-rw-r--r--gnuradio-core/src/lib/general/gr_pack_k_bits_bb.h56
-rw-r--r--gnuradio-core/src/lib/general/gr_pack_k_bits_bb.i34
-rw-r--r--gnuradio-core/src/lib/gengen/CMakeLists.txt1
-rw-r--r--gnuradio-core/src/lib/gengen/gr_vector_insert_X.cc.t100
-rw-r--r--gnuradio-core/src/lib/gengen/gr_vector_insert_X.h.t61
-rw-r--r--gnuradio-core/src/lib/gengen/gr_vector_insert_X.i.t37
-rw-r--r--gnuradio-core/src/lib/gengen/gr_vector_source_X.h.t1
-rw-r--r--gnuradio-core/src/lib/gengen/gr_vector_source_X.i.t3
-rwxr-xr-xgnuradio-core/src/python/gnuradio/gr/qa_vector_insert.py58
17 files changed, 609 insertions, 1 deletions
diff --git a/gnuradio-core/src/lib/general/CMakeLists.txt b/gnuradio-core/src/lib/general/CMakeLists.txt
index 0ad55e38a..ab9b870aa 100644
--- a/gnuradio-core/src/lib/general/CMakeLists.txt
+++ b/gnuradio-core/src/lib/general/CMakeLists.txt
@@ -228,6 +228,7 @@ set(gr_core_general_triple_threats
gr_interleaved_short_to_complex
gr_iqcomp_cc
gr_keep_one_in_n
+ gr_keep_m_in_n
gr_kludge_copy
gr_lfsr_32k_source_s
gr_map_bb
@@ -285,6 +286,7 @@ set(gr_core_general_triple_threats
gr_vector_to_stream
gr_vector_to_streams
gr_unpack_k_bits_bb
+ gr_pack_k_bits_bb
gr_descrambler_bb
gr_scrambler_bb
gr_probe_density_b
diff --git a/gnuradio-core/src/lib/general/general.i b/gnuradio-core/src/lib/general/general.i
index 54d9a8670..0696addbd 100644
--- a/gnuradio-core/src/lib/general/general.i
+++ b/gnuradio-core/src/lib/general/general.i
@@ -37,6 +37,7 @@
#include <gr_stream_to_vector.h>
#include <gr_vector_to_stream.h>
#include <gr_keep_one_in_n.h>
+#include <gr_keep_m_in_n.h>
#include <gr_fft_vcc.h>
#include <gr_fft_vfc.h>
#include <gr_float_to_int.h>
@@ -100,6 +101,7 @@
#include <gr_test_types.h>
#include <gr_test.h>
#include <gr_unpack_k_bits_bb.h>
+#include <gr_pack_k_bits_bb.h>
#include <gr_diff_phasor_cc.h>
#include <gr_diff_encoder_bb.h>
#include <gr_diff_decoder_bb.h>
@@ -155,6 +157,7 @@
%include "gr_stream_to_vector.i"
%include "gr_vector_to_stream.i"
%include "gr_keep_one_in_n.i"
+%include "gr_keep_m_in_n.i"
%include "gr_fft_vcc.i"
%include "gr_fft_vfc.i"
%include "gr_float_to_int.i"
@@ -218,6 +221,7 @@
%include "gr_test_types.h"
%include "gr_test.i"
%include "gr_unpack_k_bits_bb.i"
+%include "gr_pack_k_bits_bb.i"
%include "gr_diff_phasor_cc.i"
%include "gr_diff_encoder_bb.i"
%include "gr_diff_decoder_bb.i"
diff --git a/gnuradio-core/src/lib/general/gr_head.h b/gnuradio-core/src/lib/general/gr_head.h
index 17dd737f0..4471d75ea 100644
--- a/gnuradio-core/src/lib/general/gr_head.h
+++ b/gnuradio-core/src/lib/general/gr_head.h
@@ -51,6 +51,7 @@ class GR_CORE_API gr_head : public gr_sync_block
gr_vector_void_star &output_items);
void reset() { d_ncopied_items = 0; }
+ void set_length(int nitems) { d_nitems = nitems; }
};
GR_CORE_API gr_head_sptr
diff --git a/gnuradio-core/src/lib/general/gr_head.i b/gnuradio-core/src/lib/general/gr_head.i
index 73feaf181..d59dd176a 100644
--- a/gnuradio-core/src/lib/general/gr_head.i
+++ b/gnuradio-core/src/lib/general/gr_head.i
@@ -28,5 +28,6 @@ class gr_head : public gr_block {
gr_head();
public:
void reset();
+ void set_length(int nitems);
};
diff --git a/gnuradio-core/src/lib/general/gr_keep_m_in_n.cc b/gnuradio-core/src/lib/general/gr_keep_m_in_n.cc
new file mode 100644
index 000000000..f17c3e00d
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_keep_m_in_n.cc
@@ -0,0 +1,85 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2010 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 <gr_keep_m_in_n.h>
+#include <gr_io_signature.h>
+#include <string.h>
+#include <stdio.h>
+
+gr_keep_m_in_n_sptr
+gr_make_keep_m_in_n (size_t item_size, int m, int n, int offset)
+{
+ return gnuradio::get_initial_sptr(new gr_keep_m_in_n (item_size, m, n, offset));
+}
+
+
+/*
+*
+* offset = 0, starts with 0th item
+* offset = 1, starts with 1st item, etc...
+*
+* we take m items out of each n
+*/
+gr_keep_m_in_n::gr_keep_m_in_n (size_t item_size, int m, int n, int offset)
+ : gr_sync_block ("keep_m_in_n",
+ gr_make_io_signature (1, 1, n*item_size),
+ gr_make_io_signature (1, 1, m*item_size)),
+ d_n(n),
+ d_m(m),
+ d_offset( offset )
+{
+ // sanity checking
+ assert(d_m > 0);
+ assert(d_n > 0);
+ assert(d_m <= d_n);
+ assert(d_offset <= (d_n-d_m));
+}
+
+
+void gr_keep_m_in_n::set_offset(int offset){
+ d_offset = offset;
+}
+
+
+int
+gr_keep_m_in_n::work (int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+{
+ uint8_t* out = (uint8_t*) output_items[0];
+ const uint8_t* in = (const uint8_t*) input_items[0];
+
+ int in_item( input_signature()->sizeof_stream_item(0) );
+ int out_item( output_signature()->sizeof_stream_item(0) );
+ int single_size = in_item/d_n;
+
+ // iterate over data blocks of size {n, input : m, output}
+ for(int i=0; i<noutput_items; i++){
+ memcpy( &out[out_item*i], &in[in_item*i + single_size*d_offset], out_item);
+ }
+
+ return noutput_items;
+}
diff --git a/gnuradio-core/src/lib/general/gr_keep_m_in_n.h b/gnuradio-core/src/lib/general/gr_keep_m_in_n.h
new file mode 100644
index 000000000..f9d5a268b
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_keep_m_in_n.h
@@ -0,0 +1,62 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004 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_KEEP_M_IN_N_H
+#define INCLUDED_GR_KEEP_M_IN_N_H
+
+#include <gr_core_api.h>
+#include <gr_sync_block.h>
+
+class gr_keep_m_in_n;
+typedef boost::shared_ptr<gr_keep_m_in_n> gr_keep_m_in_n_sptr;
+
+GR_CORE_API gr_keep_m_in_n_sptr
+gr_make_keep_m_in_n (size_t item_size, int m, int n, int offset);
+
+
+/*!
+ * \brief decimate a stream, keeping one item out of every n.
+ * \ingroup slicedice_blk
+ */
+class GR_CORE_API gr_keep_m_in_n : public gr_sync_block
+{
+ friend GR_CORE_API gr_keep_m_in_n_sptr
+ gr_make_keep_m_in_n (size_t item_size, int m, int n, int offset);
+
+ int d_n;
+ int d_m;
+ int d_count;
+ int d_offset;
+
+ protected:
+ gr_keep_m_in_n (size_t item_size, int m, int n, int offset);
+
+ public:
+ int work (int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+
+ void set_offset(int offset);
+
+};
+
+#endif /* INCLUDED_GR_KEEP_M_IN_N_H */
diff --git a/gnuradio-core/src/lib/general/gr_keep_m_in_n.i b/gnuradio-core/src/lib/general/gr_keep_m_in_n.i
new file mode 100644
index 000000000..cb5c63683
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_keep_m_in_n.i
@@ -0,0 +1,35 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004 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.
+ */
+
+GR_SWIG_BLOCK_MAGIC(gr,keep_m_in_n)
+
+gr_keep_m_in_n_sptr
+gr_make_keep_m_in_n (size_t itemsize, int m, int n, int offset);
+
+class gr_keep_m_in_n : public gr_sync_block
+{
+ protected:
+ gr_keep_m_in_n (size_t itemsize, int m, int n, int offset);
+ public:
+ void set_offset(int offset);
+
+};
diff --git a/gnuradio-core/src/lib/general/gr_pack_k_bits_bb.cc b/gnuradio-core/src/lib/general/gr_pack_k_bits_bb.cc
new file mode 100644
index 000000000..0237a4d69
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_pack_k_bits_bb.cc
@@ -0,0 +1,69 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2005,2010 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.
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gr_pack_k_bits_bb.h>
+#include <gr_io_signature.h>
+#include <stdexcept>
+#include <iostream>
+
+gr_pack_k_bits_bb_sptr gr_make_pack_k_bits_bb (unsigned k)
+{
+ return gnuradio::get_initial_sptr(new gr_pack_k_bits_bb (k));
+}
+
+
+gr_pack_k_bits_bb::gr_pack_k_bits_bb (unsigned k)
+ : gr_sync_decimator ("pack_k_bits_bb",
+ gr_make_io_signature (1, 1, sizeof (unsigned char)),
+ gr_make_io_signature (1, 1, sizeof (unsigned char)),
+ k),
+ d_k (k)
+{
+ if (d_k == 0)
+ throw std::out_of_range ("interpolation must be > 0");
+}
+
+gr_pack_k_bits_bb::~gr_pack_k_bits_bb ()
+{
+}
+
+int
+gr_pack_k_bits_bb::work (int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+{
+ const unsigned char *in = (const unsigned char *) input_items[0];
+ unsigned char *out = (unsigned char *) output_items[0];
+
+ for (int i = 0; i < noutput_items; i++){
+ out[i] = 0x00;
+ for (unsigned int j = 0; j < d_k; j++){
+ out[i] |= (0x01 & in[i*d_k+j])<<j;
+ }
+ }
+
+ return noutput_items;
+}
diff --git a/gnuradio-core/src/lib/general/gr_pack_k_bits_bb.h b/gnuradio-core/src/lib/general/gr_pack_k_bits_bb.h
new file mode 100644
index 000000000..00b8f8f13
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_pack_k_bits_bb.h
@@ -0,0 +1,56 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2006 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_PACK_K_BITS_BB_H
+#define INCLUDED_GR_PACK_K_BITS_BB_H
+
+#include <gr_core_api.h>
+#include <gr_sync_decimator.h>
+
+class gr_pack_k_bits_bb;
+typedef boost::shared_ptr<gr_pack_k_bits_bb> gr_pack_k_bits_bb_sptr;
+GR_CORE_API gr_pack_k_bits_bb_sptr gr_make_pack_k_bits_bb (unsigned k);
+
+class gr_pack_k_bits_bb;
+
+/*!
+ * \brief Converts a byte with k relevent bits to k output bytes with 1 bit in the LSB.
+ * \ingroup converter_blk
+ */
+class GR_CORE_API gr_pack_k_bits_bb : public gr_sync_decimator
+{
+ private:
+ friend GR_CORE_API gr_pack_k_bits_bb_sptr gr_make_pack_k_bits_bb (unsigned k);
+
+ gr_pack_k_bits_bb (unsigned k);
+
+ unsigned d_k; // number of relevent bits to pack from k input bytes
+
+ public:
+ ~gr_pack_k_bits_bb ();
+
+ int work (int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+};
+
+#endif
diff --git a/gnuradio-core/src/lib/general/gr_pack_k_bits_bb.i b/gnuradio-core/src/lib/general/gr_pack_k_bits_bb.i
new file mode 100644
index 000000000..4711915d7
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_pack_k_bits_bb.i
@@ -0,0 +1,34 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2006 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.
+ */
+
+GR_SWIG_BLOCK_MAGIC(gr,pack_k_bits_bb)
+
+gr_pack_k_bits_bb_sptr gr_make_pack_k_bits_bb (int k) throw(std::exception);
+
+class gr_pack_k_bits_bb : public gr_sync_decimator
+{
+ private:
+ gr_pack_k_bits_bb (int k);
+
+ public:
+ ~gr_pack_k_bits_bb ();
+};
diff --git a/gnuradio-core/src/lib/gengen/CMakeLists.txt b/gnuradio-core/src/lib/gengen/CMakeLists.txt
index d13776990..22ac1bc58 100644
--- a/gnuradio-core/src/lib/gengen/CMakeLists.txt
+++ b/gnuradio-core/src/lib/gengen/CMakeLists.txt
@@ -82,6 +82,7 @@ endmacro(expand_h_cc_i)
# Invoke macro to generate various sources
########################################################################
expand_h_cc_i(gr_vector_source_X b s i f c)
+expand_h_cc_i(gr_vector_insert_X b)
expand_h_cc_i(gr_vector_sink_X b s i f c)
expand_h_cc_i(gr_noise_source_X s i f c)
expand_h_cc_i(gr_sig_source_X s i f c)
diff --git a/gnuradio-core/src/lib/gengen/gr_vector_insert_X.cc.t b/gnuradio-core/src/lib/gengen/gr_vector_insert_X.cc.t
new file mode 100644
index 000000000..15e19edb0
--- /dev/null
+++ b/gnuradio-core/src/lib/gengen/gr_vector_insert_X.cc.t
@@ -0,0 +1,100 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2008,2010 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.
+ */
+
+// @WARNING@
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <@NAME@.h>
+#include <algorithm>
+#include <gr_io_signature.h>
+#include <stdexcept>
+
+#include <stdio.h>
+
+@NAME@::@NAME@ (const std::vector<@TYPE@> &data, int periodicity, int offset)
+ : gr_block ("@BASE_NAME@",
+ gr_make_io_signature (1, 1, sizeof (@TYPE@)),
+ gr_make_io_signature (1, 1, sizeof (@TYPE@))),
+ d_data (data),
+ d_offset (offset),
+ d_periodicity (periodicity)
+{
+ //printf("INITIAL: periodicity = %d, offset = %d\n", periodicity, offset);
+ // some sanity checks
+ assert(offset < periodicity);
+ assert(offset >= 0);
+ assert(periodicity > data.size());
+}
+
+int
+@NAME@::general_work (int noutput_items,
+ gr_vector_int &ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+{
+ @TYPE@ *out = (@TYPE@ *) output_items[0];
+ const @TYPE@ *in = (const @TYPE@ *) input_items[0];
+
+ int ii(0), oo(0);
+
+ while( (oo < noutput_items) && (ii < ninput_items[0]) ){
+
+ //printf("oo = %d, ii = %d, d_offset = %d, noutput_items = %d, ninput_items[0] = %d", oo, ii, d_offset, noutput_items, ninput_items[0]);
+ //printf(", d_periodicity = %d\n", d_periodicity);
+
+ if( d_offset >= ((int)d_data.size()) ){ // if we are in the copy region
+ int max_copy = std::min( std::min( noutput_items - oo, ninput_items[0] - ii ), d_periodicity - d_offset );
+ //printf("copy %d from input\n", max_copy);
+ memcpy( &out[oo], &in[ii], sizeof(@TYPE@)*max_copy );
+ //printf(" * memcpy returned.\n");
+ ii += max_copy;
+ oo += max_copy;
+ d_offset = (d_offset + max_copy)%d_periodicity;
+
+ } else { // if we are in the insertion region
+ int max_copy = std::min( noutput_items - oo, ((int)d_data.size()) - d_offset );
+ //printf("copy %d from d_data[%d] to out[%d]\n", max_copy, d_offset, oo);
+ memcpy( &out[oo], &d_data[d_offset], sizeof(@TYPE@)*max_copy );
+ //printf(" * memcpy returned.\n");
+ oo += max_copy;
+ d_offset = (d_offset + max_copy)%d_periodicity;
+ //printf(" ## (inelse) oo = %d, d_offset = %d\n", oo, d_offset);
+ }
+
+ //printf(" # exit else, on to next loop.\n");
+ }
+ //printf(" # got out of loop\n");
+
+ //printf("consume = %d, produce = %d\n", ii, oo);
+ consume_each(ii);
+ return oo;
+
+}
+
+@NAME@_sptr
+gr_make_@BASE_NAME@ (const std::vector<@TYPE@> &data, int periodicity, int offset)
+{
+ return gnuradio::get_initial_sptr(new @NAME@ (data, periodicity, offset));
+}
+
diff --git a/gnuradio-core/src/lib/gengen/gr_vector_insert_X.h.t b/gnuradio-core/src/lib/gengen/gr_vector_insert_X.h.t
new file mode 100644
index 000000000..76c6b7a5d
--- /dev/null
+++ b/gnuradio-core/src/lib/gengen/gr_vector_insert_X.h.t
@@ -0,0 +1,61 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2008 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.
+ */
+
+// @WARNING@
+
+#ifndef @GUARD_NAME@
+#define @GUARD_NAME@
+
+#include <gr_core_api.h>
+#include <gr_block.h>
+
+class GR_CORE_API @NAME@;
+typedef boost::shared_ptr<@NAME@> @NAME@_sptr;
+
+/*!
+ * \brief source of @TYPE@'s that gets its data from a vector
+ * \ingroup source_blk
+ */
+
+class @NAME@ : public gr_block {
+ friend GR_CORE_API @NAME@_sptr
+ gr_make_@BASE_NAME@ (const std::vector<@TYPE@> &data, int periodicity, int offset);
+
+ std::vector<@TYPE@> d_data;
+ int d_offset;
+ int d_periodicity;
+
+ @NAME@ (const std::vector<@TYPE@> &data, int periodicity, int offset);
+
+ public:
+ void rewind() {d_offset=0;}
+ virtual int general_work (int noutput_items,
+ gr_vector_int &ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ void set_data(const std::vector<@TYPE@> &data){ d_data = data; rewind(); }
+};
+
+GR_CORE_API @NAME@_sptr
+gr_make_@BASE_NAME@ (const std::vector<@TYPE@> &data, int periodicity, int offset=0);
+
+#endif
diff --git a/gnuradio-core/src/lib/gengen/gr_vector_insert_X.i.t b/gnuradio-core/src/lib/gengen/gr_vector_insert_X.i.t
new file mode 100644
index 000000000..ce951b334
--- /dev/null
+++ b/gnuradio-core/src/lib/gengen/gr_vector_insert_X.i.t
@@ -0,0 +1,37 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2008 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.
+ */
+
+// @WARNING@
+
+GR_SWIG_BLOCK_MAGIC(gr,@BASE_NAME@);
+
+@NAME@_sptr
+gr_make_@BASE_NAME@ (const std::vector<@TYPE@> &data, int periodicity, int offset = 0)
+ throw(std::invalid_argument);
+
+class @NAME@ : public gr_block {
+ public:
+ void rewind();
+ void set_data(const std::vector<@TYPE@> &data);
+ private:
+ @NAME@ (const std::vector<@TYPE@> &data, int periodicity, int offset = 0);
+};
diff --git a/gnuradio-core/src/lib/gengen/gr_vector_source_X.h.t b/gnuradio-core/src/lib/gengen/gr_vector_source_X.h.t
index fe0a77f81..89f07721d 100644
--- a/gnuradio-core/src/lib/gengen/gr_vector_source_X.h.t
+++ b/gnuradio-core/src/lib/gengen/gr_vector_source_X.h.t
@@ -52,6 +52,7 @@ class @NAME@ : public gr_sync_block {
virtual int work (int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items);
+ void set_data(const std::vector<@TYPE@> &data){ d_data = data; rewind(); }
};
GR_CORE_API @NAME@_sptr
diff --git a/gnuradio-core/src/lib/gengen/gr_vector_source_X.i.t b/gnuradio-core/src/lib/gengen/gr_vector_source_X.i.t
index 6c20539ac..c821e12ff 100644
--- a/gnuradio-core/src/lib/gengen/gr_vector_source_X.i.t
+++ b/gnuradio-core/src/lib/gengen/gr_vector_source_X.i.t
@@ -30,7 +30,8 @@ gr_make_@BASE_NAME@ (const std::vector<@TYPE@> &data, bool repeat = false, int v
class @NAME@ : public gr_sync_block {
public:
- void rewind() {d_offset=0;}
+ void rewind();
+ void set_data(const std::vector<@TYPE@> &data);
private:
@NAME@ (const std::vector<@TYPE@> &data, int vlen);
};
diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_vector_insert.py b/gnuradio-core/src/python/gnuradio/gr/qa_vector_insert.py
new file mode 100755
index 000000000..7ab8e701a
--- /dev/null
+++ b/gnuradio-core/src/python/gnuradio/gr/qa_vector_insert.py
@@ -0,0 +1,58 @@
+#!/usr/bin/env python
+#
+# Copyright 2008,2010 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.
+#
+
+from gnuradio import gr, gr_unittest
+import math
+
+class test_vector_insert(gr_unittest.TestCase):
+
+ def setUp (self):
+ self.tb = gr.top_block ()
+
+ def tearDown (self):
+ self.tb = None
+
+ def test_001(self):
+ src_data = [float(x) for x in range(16)]
+ expected_result = tuple(src_data)
+
+ period = 9177;
+ offset = 0;
+
+ src = gr.null_source(1)
+ head = gr.head(1, 10000000);
+ ins = gr.vector_insert_b([1], period, offset);
+ dst = gr.vector_sink_b()
+
+ self.tb.connect(src, head, ins, dst)
+ self.tb.run()
+ result_data = dst.data()
+
+ for i in range(10000):
+ if(i%period == offset):
+ self.assertEqual(1, result_data[i])
+ else:
+ self.assertEqual(0, result_data[i])
+
+if __name__ == '__main__':
+ gr_unittest.run(test_vector_insert, "test_vector_insert.xml")
+