summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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
-rw-r--r--gr-digital/grc/digital_mpsk_receiver_cc.xml13
-rw-r--r--gr-digital/grc/digital_ofdm_insert_preamble.xml6
-rw-r--r--gr-digital/include/digital_ofdm_insert_preamble.h4
-rw-r--r--gr-digital/lib/digital_ofdm_insert_preamble.cc18
-rw-r--r--gr-digital/swig/digital_ofdm_insert_preamble.i2
-rw-r--r--grc/blocks/block_tree.xml3
-rw-r--r--grc/blocks/gr_keep_m_in_n.xml74
-rw-r--r--grc/blocks/gr_pack_k_bits_bb.xml30
-rw-r--r--grc/blocks/gr_vector_insert_x.xml80
26 files changed, 831 insertions, 9 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")
+
diff --git a/gr-digital/grc/digital_mpsk_receiver_cc.xml b/gr-digital/grc/digital_mpsk_receiver_cc.xml
index ab7e5c209..bd738fccc 100644
--- a/gr-digital/grc/digital_mpsk_receiver_cc.xml
+++ b/gr-digital/grc/digital_mpsk_receiver_cc.xml
@@ -7,7 +7,7 @@
<block>
<name>MPSK Receiver</name>
<key>digital_mpsk_receiver_cc</key>
- <import>from gnuradio import digital</import>
+ <import>from gnuradio import digital;import cmath</import>
<make>digital.mpsk_receiver_cc($M, $theta, $w, $fmin, $fmax, $mu, $gain_mu, $omega, $gain_omega, $omega_relative_limit)</make>
<callback>set_loop_bandwidth($w)</callback>
<callback>set_mu($mu)</callback>
@@ -17,51 +17,61 @@
<param>
<name>M</name>
<key>M</key>
+ <value>4</value>
<type>int</type>
</param>
<param>
<name>Theta</name>
<key>theta</key>
+ <value>0</value>
<type>real</type>
</param>
<param>
<name>Loop Bandwidth</name>
<key>w</key>
+ <value>cmath.pi/100.0</value>
<type>real</type>
</param>
<param>
<name>Min Freq</name>
<key>fmin</key>
+ <value>-0.5</value>
<type>real</type>
</param>
<param>
<name>Max Freq</name>
<key>fmax</key>
+ <value>0.5</value>
<type>real</type>
</param>
<param>
<name>Mu</name>
<key>mu</key>
+ <value>0.25</value>
<type>real</type>
</param>
<param>
<name>Gain Mu</name>
<key>gain_mu</key>
+ <value>0.01</value>
<type>real</type>
</param>
<param>
<name>Omega</name>
<key>omega</key>
+ <value>2</value>
<type>real</type>
</param>
<param>
<name>Gain Omega</name>
<key>gain_omega</key>
+ <value>0.001</value>
<type>real</type>
</param>
<param>
<name>Omega Relative Limit</name>
<key>omega_relative_limit</key>
+ <value>0.001</value>
<type>real</type>
</param>
<sink>
@@ -72,4 +82,5 @@
<name>out</name>
<type>complex</type>
</source>
+
</block>
diff --git a/gr-digital/grc/digital_ofdm_insert_preamble.xml b/gr-digital/grc/digital_ofdm_insert_preamble.xml
index 33a93058f..9ad8fa793 100644
--- a/gr-digital/grc/digital_ofdm_insert_preamble.xml
+++ b/gr-digital/grc/digital_ofdm_insert_preamble.xml
@@ -48,10 +48,16 @@
<sink>
<name>flag</name>
<type>byte</type>
+ <optional>1</optional>
</sink>
<source>
<name>out</name>
<type>complex</type>
<vlen>$fft_length</vlen>
</source>
+ <source>
+ <name>flag</name>
+ <type>byte</type>
+ <optional>1</optional>
+ </source>
</block>
diff --git a/gr-digital/include/digital_ofdm_insert_preamble.h b/gr-digital/include/digital_ofdm_insert_preamble.h
index 6f9dae5d6..fa44558ad 100644
--- a/gr-digital/include/digital_ofdm_insert_preamble.h
+++ b/gr-digital/include/digital_ofdm_insert_preamble.h
@@ -88,18 +88,20 @@ private:
int d_pending_flag;
void enter_idle();
- void enter_preamble();
void enter_first_payload();
void enter_payload();
public:
~digital_ofdm_insert_preamble();
+ void enter_preamble();
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 forecast (int noutput_items, gr_vector_int &ninput_items_required);
+
};
#endif /* INCLUDED_DIGITAL_OFDM_INSERT_PREAMBLE_H */
diff --git a/gr-digital/lib/digital_ofdm_insert_preamble.cc b/gr-digital/lib/digital_ofdm_insert_preamble.cc
index a46133643..d94425f31 100644
--- a/gr-digital/lib/digital_ofdm_insert_preamble.cc
+++ b/gr-digital/lib/digital_ofdm_insert_preamble.cc
@@ -41,7 +41,7 @@ digital_ofdm_insert_preamble::digital_ofdm_insert_preamble
(int fft_length,
const std::vector<std::vector<gr_complex> > &preamble)
: gr_block("ofdm_insert_preamble",
- gr_make_io_signature2(2, 2,
+ gr_make_io_signature2(1, 2,
sizeof(gr_complex)*fft_length,
sizeof(char)),
gr_make_io_signature2(1, 2,
@@ -67,15 +67,21 @@ digital_ofdm_insert_preamble::~digital_ofdm_insert_preamble()
{
}
+void digital_ofdm_insert_preamble::forecast (int noutput_items, gr_vector_int &ninput_items_required){
+ ninput_items_required[0] = noutput_items;
+}
+
int
digital_ofdm_insert_preamble::general_work (int noutput_items,
gr_vector_int &ninput_items_v,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
- int ninput_items = std::min(ninput_items_v[0], ninput_items_v[1]);
+ int ninput_items = ninput_items_v.size()==2?std::min(ninput_items_v[0], ninput_items_v[1]):ninput_items_v[0];
const gr_complex *in_sym = (const gr_complex *) input_items[0];
- const unsigned char *in_flag = (const unsigned char *) input_items[1];
+ const unsigned char *in_flag = 0;
+ if (input_items.size() == 2)
+ in_flag = (const unsigned char *) input_items[1];
gr_complex *out_sym = (gr_complex *) output_items[0];
unsigned char *out_flag = 0;
@@ -97,14 +103,14 @@ digital_ofdm_insert_preamble::general_work (int noutput_items,
while (no < noutput_items && ni < ninput_items){
switch(d_state){
case ST_IDLE:
- if (in_flag[ni] & 0x1) // this is first symbol of new payload
+ if (in_flag && in_flag[ni] & 0x1) // this is first symbol of new payload
enter_preamble();
else
ni++; // eat one input symbol
break;
case ST_PREAMBLE:
- assert(in_flag[ni] & 0x1);
+ assert(!in_flag || in_flag[ni] & 0x1);
if (d_nsymbols_output >= (int) d_preamble.size()){
// we've output all the preamble
enter_first_payload();
@@ -133,7 +139,7 @@ digital_ofdm_insert_preamble::general_work (int noutput_items,
break;
case ST_PAYLOAD:
- if (in_flag[ni] & 0x1){ // this is first symbol of a new payload
+ if (in_flag && in_flag[ni] & 0x1){ // this is first symbol of a new payload
enter_preamble();
break;
}
diff --git a/gr-digital/swig/digital_ofdm_insert_preamble.i b/gr-digital/swig/digital_ofdm_insert_preamble.i
index 5f7b16369..0273c7fa7 100644
--- a/gr-digital/swig/digital_ofdm_insert_preamble.i
+++ b/gr-digital/swig/digital_ofdm_insert_preamble.i
@@ -32,4 +32,6 @@ class digital_ofdm_insert_preamble : public gr_block
protected:
digital_ofdm_insert_preamble(int fft_length,
const std::vector<std::vector<gr_complex> > &preamble);
+ public:
+ void enter_preamble();
};
diff --git a/grc/blocks/block_tree.xml b/grc/blocks/block_tree.xml
index 18bc050ba..0b0b6854e 100644
--- a/grc/blocks/block_tree.xml
+++ b/grc/blocks/block_tree.xml
@@ -61,6 +61,7 @@
<block>gr_fft_vxx</block>
<block>blks2_logpwrfft_x</block>
+ <block>gr_vector_insert_x</block>
</cat>
<cat>
<name>Type Conversions</name>
@@ -114,6 +115,7 @@
<block>gr_unpacked_to_packed_xx</block>
<block>gr_packed_to_unpacked_xx</block>
<block>gr_unpack_k_bits_bb</block>
+ <block>gr_pack_k_bits_bb</block>
<block>gr_chunks_to_symbols_xx</block>
<block>gr_map_bb</block>
</cat>
@@ -183,6 +185,7 @@
<block>blks2_rational_resampler_xxx</block>
<block>gr_fractional_interpolator_xx</block>
<block>gr_keep_one_in_n</block>
+ <block>gr_keep_m_in_n</block>
<block>gr_moving_average_xx</block>
<block>gr_iqcomp_cc</block>
<block>gr_dc_blocker</block>
diff --git a/grc/blocks/gr_keep_m_in_n.xml b/grc/blocks/gr_keep_m_in_n.xml
new file mode 100644
index 000000000..a63ef47a6
--- /dev/null
+++ b/grc/blocks/gr_keep_m_in_n.xml
@@ -0,0 +1,74 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+##Keep M in N
+###################################################
+ -->
+<block>
+ <name>Keep M in N</name>
+ <key>gr_keep_m_in_n</key>
+ <import>from gnuradio import gr</import>
+ <make>gr.keep_m_in_n($type.size, $m, $n, $offset)</make>
+ <callback>set_offset($offset)</callback>
+ <param>
+ <name>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>M</name>
+ <key>m</key>
+ <value>1</value>
+ <type>int</type>
+ </param>
+ <param>
+ <name>N</name>
+ <key>n</key>
+ <value>2</value>
+ <type>int</type>
+ </param>
+ <param>
+ <name>initial offset</name>
+ <key>offset</key>
+ <value>0</value>
+ <type>int</type>
+ </param>
+ <check>$n &gt; 0</check>
+ <check>$m &gt; 0</check>
+ <check>$m &lt; $n</check>
+ <sink>
+ <name>in</name>
+ <type>$type</type>
+ <vlen>$n</vlen>
+ </sink>
+ <source>
+ <name>out</name>
+ <type>$type</type>
+ <vlen>$m</vlen>
+ </source>
+</block>
diff --git a/grc/blocks/gr_pack_k_bits_bb.xml b/grc/blocks/gr_pack_k_bits_bb.xml
new file mode 100644
index 000000000..34e64a5d9
--- /dev/null
+++ b/grc/blocks/gr_pack_k_bits_bb.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+##Pack K Bits
+###################################################
+ -->
+<block>
+ <name>Pack K Bits</name>
+ <key>gr_pack_k_bits_bb</key>
+ <import>from gnuradio import gr</import>
+ <make>gr.pack_k_bits_bb($k)</make>
+ <param>
+ <name>K</name>
+ <key>k</key>
+ <type>int</type>
+ </param>
+ <sink>
+ <name>in</name>
+ <type>byte</type>
+ </sink>
+ <source>
+ <name>out</name>
+ <type>byte</type>
+ </source>
+
+ <doc>
+ Pack K unpacked bits (one bit per byte) into a single packed byte containing k bits and 8 - k zeros.
+ </doc>
+
+</block>
diff --git a/grc/blocks/gr_vector_insert_x.xml b/grc/blocks/gr_vector_insert_x.xml
new file mode 100644
index 000000000..f9ce1f654
--- /dev/null
+++ b/grc/blocks/gr_vector_insert_x.xml
@@ -0,0 +1,80 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+##Vector Source
+###################################################
+ -->
+<block>
+ <name>Vector Insert</name>
+ <key>gr_vector_insert_x</key>
+ <import>from gnuradio import gr</import>
+ <make>gr.vector_insert_$(type.fcn)($vector, $period, $offset)</make>
+ <param>
+ <name>Output Type</name>
+ <key>type</key>
+ <type>enum</type>
+ <option>
+ <name>Byte</name>
+ <key>byte</key>
+ <opt>fcn:b</opt>
+ <opt>vec_type:int_vector</opt>
+ </option>
+ <option>
+ <name>Complex</name>
+ <key>complex</key>
+ <opt>fcn:c</opt>
+ <opt>vec_type:complex_vector</opt>
+ </option>
+ <option>
+ <name>Float</name>
+ <key>float</key>
+ <opt>fcn:f</opt>
+ <opt>vec_type:real_vector</opt>
+ </option>
+ <option>
+ <name>Int</name>
+ <key>int</key>
+ <opt>fcn:i</opt>
+ <opt>vec_type:int_vector</opt>
+ </option>
+ <option>
+ <name>Short</name>
+ <key>short</key>
+ <opt>fcn:s</opt>
+ <opt>vec_type:int_vector</opt>
+ </option>
+ </param>
+ <param>
+ <name>Vector</name>
+ <key>vector</key>
+ <value>0, 0, 0</value>
+ <type>$type.vec_type</type>
+ </param>
+ <param>
+ <name>Periodicity</name>
+ <key>period</key>
+ <value>100</value>
+ <type>int</type>
+ </param>
+ <param>
+ <name>Offset</name>
+ <key>offset</key>
+ <value>0</value>
+ <type>int</type>
+ </param>
+ <sink>
+ <name>in</name>
+ <type>$type</type>
+ </sink>
+ <source>
+ <name>out</name>
+ <type>$type</type>
+ </source>
+
+ <doc>
+ Periodicity, the length of the periodicity at which the vector should be inserted at the output.
+ (i.e. one vector for every N output items)
+
+ Offset sepcifies where in the cycle period we should begin at.
+ </doc>
+</block>