summaryrefslogtreecommitdiff
path: root/gnuradio-core/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'gnuradio-core/src/lib')
-rw-r--r--gnuradio-core/src/lib/filter/CMakeLists.txt3
-rw-r--r--gnuradio-core/src/lib/filter/dotprod_ccf_armv7_a.c2
-rw-r--r--gnuradio-core/src/lib/filter/dotprod_fff_armv7_a.c2
-rw-r--r--gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc1
-rw-r--r--gnuradio-core/src/lib/filter/gr_pfb_decimator_ccf.cc1
-rw-r--r--gnuradio-core/src/lib/filter/gr_pfb_synthesizer_ccf.cc1
-rw-r--r--gnuradio-core/src/lib/general/CMakeLists.txt13
-rw-r--r--gnuradio-core/src/lib/general/general.i12
-rw-r--r--gnuradio-core/src/lib/general/gr_add_ff.cc2
-rw-r--r--gnuradio-core/src/lib/general/gr_annotator_raw.cc106
-rw-r--r--gnuradio-core/src/lib/general/gr_annotator_raw.h69
-rw-r--r--gnuradio-core/src/lib/general/gr_annotator_raw.i26
-rw-r--r--gnuradio-core/src/lib/general/gr_char_to_float.cc2
-rw-r--r--gnuradio-core/src/lib/general/gr_char_to_short.cc2
-rw-r--r--gnuradio-core/src/lib/general/gr_complex_to_xxx.cc12
-rw-r--r--gnuradio-core/src/lib/general/gr_conjugate_cc.cc2
-rw-r--r--gnuradio-core/src/lib/general/gr_endian_swap.cc101
-rw-r--r--gnuradio-core/src/lib/general/gr_endian_swap.h57
-rw-r--r--gnuradio-core/src/lib/general/gr_endian_swap.i31
-rw-r--r--gnuradio-core/src/lib/general/gr_float_to_char.cc2
-rw-r--r--gnuradio-core/src/lib/general/gr_float_to_int.cc2
-rw-r--r--gnuradio-core/src/lib/general/gr_float_to_short.cc2
-rw-r--r--gnuradio-core/src/lib/general/gr_head.h3
-rw-r--r--gnuradio-core/src/lib/general/gr_head.i3
-rw-r--r--gnuradio-core/src/lib/general/gr_int_to_float.cc2
-rw-r--r--gnuradio-core/src/lib/general/gr_keep_m_in_n.cc98
-rw-r--r--gnuradio-core/src/lib/general/gr_keep_m_in_n.h67
-rw-r--r--gnuradio-core/src/lib/general/gr_keep_m_in_n.i35
-rw-r--r--gnuradio-core/src/lib/general/gr_multiply_cc.cc6
-rw-r--r--gnuradio-core/src/lib/general/gr_multiply_conjugate_cc.cc6
-rw-r--r--gnuradio-core/src/lib/general/gr_multiply_const_cc.cc6
-rw-r--r--gnuradio-core/src/lib/general/gr_multiply_const_ff.cc6
-rw-r--r--gnuradio-core/src/lib/general/gr_multiply_ff.cc2
-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/general/gr_short_to_char.cc2
-rw-r--r--gnuradio-core/src/lib/general/gr_short_to_float.cc2
-rw-r--r--gnuradio-core/src/lib/general/gr_skiphead.cc4
-rw-r--r--gnuradio-core/src/lib/general/gr_tag_debug.cc100
-rw-r--r--gnuradio-core/src/lib/general/gr_tag_debug.h85
-rw-r--r--gnuradio-core/src/lib/general/gr_tag_debug.i35
-rw-r--r--gnuradio-core/src/lib/general/gr_vector_map.cc117
-rw-r--r--gnuradio-core/src/lib/general/gr_vector_map.h83
-rw-r--r--gnuradio-core/src/lib/general/gr_vector_map.i28
-rw-r--r--gnuradio-core/src/lib/gengen/CMakeLists.txt3
-rw-r--r--gnuradio-core/src/lib/gengen/Makefile.gen333
-rw-r--r--gnuradio-core/src/lib/gengen/gr_sig_source_X.cc.t7
-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.t3
-rw-r--r--gnuradio-core/src/lib/gengen/gr_vector_source_X.i.t5
-rw-r--r--gnuradio-core/src/lib/io/CMakeLists.txt1
-rw-r--r--gnuradio-core/src/lib/io/gr_message_burst_source.cc144
-rw-r--r--gnuradio-core/src/lib/io/gr_message_burst_source.h71
-rw-r--r--gnuradio-core/src/lib/io/gr_message_burst_source.i38
-rw-r--r--gnuradio-core/src/lib/io/gr_tagged_file_sink.cc2
-rw-r--r--gnuradio-core/src/lib/io/gr_udp_source.cc10
-rw-r--r--gnuradio-core/src/lib/io/gri_wavfile.cc136
-rw-r--r--gnuradio-core/src/lib/io/gri_wavfile.h27
-rw-r--r--gnuradio-core/src/lib/io/io.i2
-rw-r--r--gnuradio-core/src/lib/runtime/CMakeLists.txt23
-rw-r--r--gnuradio-core/src/lib/runtime/gr_basic_block.cc4
-rw-r--r--gnuradio-core/src/lib/runtime/gr_basic_block.h20
-rw-r--r--gnuradio-core/src/lib/runtime/gr_basic_block.i6
-rw-r--r--gnuradio-core/src/lib/runtime/gr_block_executor.cc2
-rw-r--r--gnuradio-core/src/lib/runtime/gr_flat_flowgraph.cc16
-rw-r--r--gnuradio-core/src/lib/runtime/gr_top_block.i2
-rw-r--r--gnuradio-core/src/lib/swig/CMakeLists.txt5
-rw-r--r--gnuradio-core/src/lib/swig/gnuradio.i3
-rw-r--r--gnuradio-core/src/lib/swig/gr_swig_block_magic.i10
72 files changed, 1866 insertions, 505 deletions
diff --git a/gnuradio-core/src/lib/filter/CMakeLists.txt b/gnuradio-core/src/lib/filter/CMakeLists.txt
index facaff764..088d3376d 100644
--- a/gnuradio-core/src/lib/filter/CMakeLists.txt
+++ b/gnuradio-core/src/lib/filter/CMakeLists.txt
@@ -210,6 +210,9 @@ elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)")
${CMAKE_CURRENT_SOURCE_DIR}/qa_dotprod_powerpc.cc
)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm")
+ if(have_mfpu_neon)
+ add_definitions(-DHAVE_MFPU_NEON)
+ endif()
list(APPEND gnuradio_core_sources
${CMAKE_CURRENT_SOURCE_DIR}/sysconfig_armv7_a.cc
${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_sysconfig_armv7_a.cc
diff --git a/gnuradio-core/src/lib/filter/dotprod_ccf_armv7_a.c b/gnuradio-core/src/lib/filter/dotprod_ccf_armv7_a.c
index e7c6b266e..c125b49b3 100644
--- a/gnuradio-core/src/lib/filter/dotprod_ccf_armv7_a.c
+++ b/gnuradio-core/src/lib/filter/dotprod_ccf_armv7_a.c
@@ -37,7 +37,7 @@ gr_p2_round_down(size_t x, size_t pow2)
}
-#if 0
+#ifndef HAVE_MFPU_NEON
void
dotprod_ccf_armv7_a(const float *a, const float *b, float *res, size_t n)
diff --git a/gnuradio-core/src/lib/filter/dotprod_fff_armv7_a.c b/gnuradio-core/src/lib/filter/dotprod_fff_armv7_a.c
index 68c448b35..23bbef033 100644
--- a/gnuradio-core/src/lib/filter/dotprod_fff_armv7_a.c
+++ b/gnuradio-core/src/lib/filter/dotprod_fff_armv7_a.c
@@ -37,7 +37,7 @@ gr_p2_round_down(size_t x, size_t pow2)
}
-#if 0
+#ifndef HAVE_MFPU_NEON
float
dotprod_fff_armv7_a(const float *a, const float *b, size_t n)
diff --git a/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc b/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc
index cb7c93962..a8cb849e2 100644
--- a/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc
+++ b/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc
@@ -96,6 +96,7 @@ gr_pfb_channelizer_ccf::gr_pfb_channelizer_ccf (unsigned int numchans,
gr_pfb_channelizer_ccf::~gr_pfb_channelizer_ccf ()
{
+ delete d_fft;
delete [] d_idxlut;
for(unsigned int i = 0; i < d_numchans; i++) {
diff --git a/gnuradio-core/src/lib/filter/gr_pfb_decimator_ccf.cc b/gnuradio-core/src/lib/filter/gr_pfb_decimator_ccf.cc
index c973daf82..e563daa51 100644
--- a/gnuradio-core/src/lib/filter/gr_pfb_decimator_ccf.cc
+++ b/gnuradio-core/src/lib/filter/gr_pfb_decimator_ccf.cc
@@ -69,6 +69,7 @@ gr_pfb_decimator_ccf::gr_pfb_decimator_ccf (unsigned int decim,
gr_pfb_decimator_ccf::~gr_pfb_decimator_ccf ()
{
+ delete d_fft;
for(unsigned int i = 0; i < d_rate; i++) {
delete d_filters[i];
}
diff --git a/gnuradio-core/src/lib/filter/gr_pfb_synthesizer_ccf.cc b/gnuradio-core/src/lib/filter/gr_pfb_synthesizer_ccf.cc
index 9910a1851..cd01aaff5 100644
--- a/gnuradio-core/src/lib/filter/gr_pfb_synthesizer_ccf.cc
+++ b/gnuradio-core/src/lib/filter/gr_pfb_synthesizer_ccf.cc
@@ -74,6 +74,7 @@ gr_pfb_synthesizer_ccf::gr_pfb_synthesizer_ccf
gr_pfb_synthesizer_ccf::~gr_pfb_synthesizer_ccf ()
{
+ delete d_fft;
for(unsigned int i = 0; i < d_twox*d_numchans; i++) {
delete d_filters[i];
}
diff --git a/gnuradio-core/src/lib/general/CMakeLists.txt b/gnuradio-core/src/lib/general/CMakeLists.txt
index 207d85c4c..3cf7f74e4 100644
--- a/gnuradio-core/src/lib/general/CMakeLists.txt
+++ b/gnuradio-core/src/lib/general/CMakeLists.txt
@@ -37,6 +37,10 @@ ADD_FILE_DEPENDENCIES(${CMAKE_CURRENT_SOURCE_DIR}/gr_fxpt.cc
${CMAKE_CURRENT_BINARY_DIR}/sine_table.h
)
+add_custom_target(general_generated DEPENDS
+ ${CMAKE_CURRENT_BINARY_DIR}/sine_table.h
+)
+
########################################################################
# Handle the generated constants
########################################################################
@@ -48,9 +52,6 @@ message(STATUS "Loading build date ${BUILD_DATE} into gr_constants...")
message(STATUS "Loading version ${VERSION} into gr_constants...")
-file(TO_NATIVE_PATH "${CMAKE_INSTALL_PREFIX}/${GR_CONF_DIR}" SYSCONFDIR)
-file(TO_NATIVE_PATH "${CMAKE_INSTALL_PREFIX}/${GR_PKG_CONF_DIR}" GR_PREFSDIR)
-
#double escape for windows backslash path separators
string(REPLACE "\\" "\\\\" prefix ${prefix})
string(REPLACE "\\" "\\\\" SYSCONFDIR ${SYSCONFDIR})
@@ -206,6 +207,7 @@ set(gr_core_general_triple_threats
gr_deinterleave
gr_delay
gr_encode_ccsds_27_bb
+ gr_endian_swap
gr_fake_channel_coder_pp
gr_feedforward_agc_cc
gr_feval
@@ -228,6 +230,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
@@ -281,16 +284,20 @@ set(gr_core_general_triple_threats
gr_transcendental
gr_uchar_to_float
gr_vco_f
+ gr_vector_map
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
gr_annotator_alltoall
gr_annotator_1to1
+ gr_annotator_raw
gr_burst_tagger
gr_correlate_access_code_tag_bb
+ gr_tag_debug
)
foreach(file_tt ${gr_core_general_triple_threats})
diff --git a/gnuradio-core/src/lib/general/general.i b/gnuradio-core/src/lib/general/general.i
index cd8c279c9..790549c4d 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>
@@ -59,6 +60,7 @@
#include <gr_complex_to_interleaved_short.h>
#include <gr_interleaved_short_to_complex.h>
//#include <gr_endianness.h>
+#include <gr_endian_swap.h>
#include <gr_firdes.h>
#include <gr_interleave.h>
#include <gr_deinterleave.h>
@@ -100,6 +102,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>
@@ -133,10 +136,13 @@
#include <complex_vec_test.h>
#include <gr_annotator_alltoall.h>
#include <gr_annotator_1to1.h>
+#include <gr_annotator_raw.h>
#include <gr_burst_tagger.h>
#include <gr_cpm.h>
#include <gr_correlate_access_code_tag_bb.h>
#include <gr_add_ff.h>
+#include <gr_vector_map.h>
+#include <gr_tag_debug.h>
%}
%include "gri_control_loop.i"
@@ -154,6 +160,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"
@@ -175,6 +182,7 @@
%include "gr_complex_to_xxx.i"
%include "gr_complex_to_interleaved_short.i"
//%include "gr_endianness.i"
+%include "gr_endian_swap.i"
%include "gr_interleaved_short_to_complex.i"
%include "gr_firdes.i"
%include "gr_interleave.i"
@@ -217,6 +225,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"
@@ -250,7 +259,10 @@
%include "complex_vec_test.i"
%include "gr_annotator_alltoall.i"
%include "gr_annotator_1to1.i"
+%include "gr_annotator_raw.i"
%include "gr_burst_tagger.i"
%include "gr_cpm.i"
%include "gr_correlate_access_code_tag_bb.i"
%include "gr_add_ff.i"
+%include "gr_vector_map.i"
+%include "gr_tag_debug.i"
diff --git a/gnuradio-core/src/lib/general/gr_add_ff.cc b/gnuradio-core/src/lib/general/gr_add_ff.cc
index 2e45673d3..5f6676bb7 100644
--- a/gnuradio-core/src/lib/general/gr_add_ff.cc
+++ b/gnuradio-core/src/lib/general/gr_add_ff.cc
@@ -42,7 +42,7 @@ gr_add_ff::gr_add_ff (size_t vlen)
{
const int alignment_multiple =
volk_get_alignment() / sizeof(float);
- set_alignment(alignment_multiple);
+ set_alignment(std::max(1,alignment_multiple));
}
int
diff --git a/gnuradio-core/src/lib/general/gr_annotator_raw.cc b/gnuradio-core/src/lib/general/gr_annotator_raw.cc
new file mode 100644
index 000000000..d3dcce73a
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_annotator_raw.cc
@@ -0,0 +1,106 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 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_annotator_raw.h>
+#include <gr_io_signature.h>
+#include <string.h>
+#include <iostream>
+#include <iomanip>
+#include <stdexcept>
+
+using namespace pmt;
+
+gr_annotator_raw_sptr
+gr_make_annotator_raw(size_t sizeof_stream_item)
+{
+ return gnuradio::get_initial_sptr(new gr_annotator_raw
+ (sizeof_stream_item));
+}
+
+gr_annotator_raw::gr_annotator_raw(size_t sizeof_stream_item)
+ : gr_sync_block("annotator_raw",
+ gr_make_io_signature(1, 1, sizeof_stream_item),
+ gr_make_io_signature(1, 1, sizeof_stream_item)),
+ d_itemsize(sizeof_stream_item)
+{
+ set_tag_propagation_policy(TPP_ONE_TO_ONE);
+ set_relative_rate(1.0);
+}
+
+void gr_annotator_raw::add_tag(uint64_t offset, pmt_t key, pmt_t val)
+{
+ gruel::scoped_lock l(d_mutex);
+
+ gr_tag_t tag;
+ tag.srcid = pmt::pmt_intern(name());
+ tag.key = key;
+ tag.value = val;
+ tag.offset = offset;
+
+ // add our new tag
+ d_queued_tags.push_back(tag);
+ // make sure our tags are in offset order
+ std::sort(d_queued_tags.begin(), d_queued_tags.end(),
+ gr_tag_t::offset_compare);
+ // make sure we are not adding an item in the past!
+ if(tag.offset > nitems_read(0)) {
+ throw std::runtime_error("gr_annotator_raw::add_tag: item added too far in the past\n.");
+ }
+}
+
+gr_annotator_raw::~gr_annotator_raw()
+{
+}
+
+int
+gr_annotator_raw::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+{
+ gruel::scoped_lock l(d_mutex);
+
+ const char *in = (const char*)input_items[0];
+ char *out = (char*)output_items[0];
+
+ uint64_t start_N = nitems_read(0);
+ uint64_t end_N = start_N + (uint64_t)(noutput_items);
+
+ // locate queued tags that fall in this range and insert them when appropriate
+ std::vector<gr_tag_t>::iterator i = d_queued_tags.begin();
+ while( i != d_queued_tags.end() ) {
+ if( (*i).offset >= start_N && (*i).offset < end_N) {
+ add_item_tag(0, (*i).offset,(*i).key, (*i).value, (*i).srcid);
+ i = d_queued_tags.erase(i);
+ }
+ else {
+ break;
+ }
+ }
+
+ // copy data across
+ memcpy(out, in, noutput_items*d_itemsize);
+ return noutput_items;
+}
diff --git a/gnuradio-core/src/lib/general/gr_annotator_raw.h b/gnuradio-core/src/lib/general/gr_annotator_raw.h
new file mode 100644
index 000000000..8a6c3f6c0
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_annotator_raw.h
@@ -0,0 +1,69 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 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.
+ */
+
+#ifndef INCLUDED_GR_ANNOTATOR_RAW_H
+#define INCLUDED_GR_ANNOTATOR_RAW_H
+
+#include <gr_core_api.h>
+#include <gr_sync_block.h>
+#include <gruel/pmt.h>
+#include <gruel/thread.h>
+
+class gr_annotator_raw;
+typedef boost::shared_ptr<gr_annotator_raw> gr_annotator_raw_sptr;
+
+// public constructor
+GR_CORE_API gr_annotator_raw_sptr
+gr_make_annotator_raw(size_t sizeof_stream_item);
+
+/*!
+ * \brief raw stream annotator testing block.
+ *
+ * This block creates arbitrary tags to be sent downstream
+ * blocks to be sent are set manually via accessor methods and are sent only once.
+ *
+ * This block is intended for testing of tag related blocks
+ */
+class GR_CORE_API gr_annotator_raw : public gr_sync_block
+{
+ public:
+ ~gr_annotator_raw();
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+
+ // insert a tag to be added
+ void add_tag(uint64_t offset, pmt::pmt_t key, pmt::pmt_t val);
+
+protected:
+ gr_annotator_raw(size_t sizeof_stream_item);
+
+ private:
+ size_t d_itemsize;
+ std::vector<gr_tag_t> d_queued_tags;
+ gruel::mutex d_mutex;
+
+ friend GR_CORE_API gr_annotator_raw_sptr
+ gr_make_annotator_raw(size_t sizeof_stream_item);
+};
+
+#endif
diff --git a/gnuradio-core/src/lib/general/gr_annotator_raw.i b/gnuradio-core/src/lib/general/gr_annotator_raw.i
new file mode 100644
index 000000000..85777ef5d
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_annotator_raw.i
@@ -0,0 +1,26 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2010-2011 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,annotator_raw);
+
+%include <pmt_swig.i>
+%include <gr_annotator_raw.h>
diff --git a/gnuradio-core/src/lib/general/gr_char_to_float.cc b/gnuradio-core/src/lib/general/gr_char_to_float.cc
index aec7ad852..f63aa5b16 100644
--- a/gnuradio-core/src/lib/general/gr_char_to_float.cc
+++ b/gnuradio-core/src/lib/general/gr_char_to_float.cc
@@ -42,7 +42,7 @@ gr_char_to_float::gr_char_to_float (size_t vlen, float scale)
{
const int alignment_multiple =
volk_get_alignment() / sizeof(float);
- set_alignment(alignment_multiple);
+ set_alignment(std::max(1,alignment_multiple));
}
float
diff --git a/gnuradio-core/src/lib/general/gr_char_to_short.cc b/gnuradio-core/src/lib/general/gr_char_to_short.cc
index c20d6cd88..bb9bd8909 100644
--- a/gnuradio-core/src/lib/general/gr_char_to_short.cc
+++ b/gnuradio-core/src/lib/general/gr_char_to_short.cc
@@ -42,7 +42,7 @@ gr_char_to_short::gr_char_to_short (size_t vlen)
{
const int alignment_multiple =
volk_get_alignment() / sizeof(char);
- set_alignment(alignment_multiple);
+ set_alignment(std::max(1,alignment_multiple));
}
int
diff --git a/gnuradio-core/src/lib/general/gr_complex_to_xxx.cc b/gnuradio-core/src/lib/general/gr_complex_to_xxx.cc
index 3b1fbf9ac..cdf6d7f3a 100644
--- a/gnuradio-core/src/lib/general/gr_complex_to_xxx.cc
+++ b/gnuradio-core/src/lib/general/gr_complex_to_xxx.cc
@@ -45,7 +45,7 @@ gr_complex_to_float::gr_complex_to_float (unsigned int vlen)
{
const int alignment_multiple =
volk_get_alignment() / sizeof(float);
- set_alignment(alignment_multiple);
+ set_alignment(std::max(1,alignment_multiple));
}
int
@@ -106,7 +106,7 @@ gr_complex_to_real::gr_complex_to_real (unsigned int vlen)
{
const int alignment_multiple =
volk_get_alignment() / sizeof(float);
- set_alignment(alignment_multiple);
+ set_alignment(std::max(1,alignment_multiple));
}
int
@@ -146,7 +146,7 @@ gr_complex_to_imag::gr_complex_to_imag (unsigned int vlen)
{
const int alignment_multiple =
volk_get_alignment() / sizeof(float);
- set_alignment(alignment_multiple);
+ set_alignment(std::max(1,alignment_multiple));
}
int
@@ -186,7 +186,7 @@ gr_complex_to_mag::gr_complex_to_mag (unsigned int vlen)
{
const int alignment_multiple =
volk_get_alignment() / sizeof(float);
- set_alignment(alignment_multiple);
+ set_alignment(std::max(1,alignment_multiple));
}
int
@@ -220,7 +220,7 @@ gr_complex_to_mag_squared::gr_complex_to_mag_squared (unsigned int vlen)
{
const int alignment_multiple =
volk_get_alignment() / sizeof(float);
- set_alignment(alignment_multiple);
+ set_alignment(std::max(1,alignment_multiple));
}
int
@@ -258,7 +258,7 @@ gr_complex_to_arg::gr_complex_to_arg (unsigned int vlen)
{
const int alignment_multiple =
volk_get_alignment() / sizeof(float);
- set_alignment(alignment_multiple);
+ set_alignment(std::max(1,alignment_multiple));
}
int
diff --git a/gnuradio-core/src/lib/general/gr_conjugate_cc.cc b/gnuradio-core/src/lib/general/gr_conjugate_cc.cc
index aaa7f490c..94ac3e162 100644
--- a/gnuradio-core/src/lib/general/gr_conjugate_cc.cc
+++ b/gnuradio-core/src/lib/general/gr_conjugate_cc.cc
@@ -43,7 +43,7 @@ gr_conjugate_cc::gr_conjugate_cc ()
{
const int alignment_multiple =
volk_get_alignment() / sizeof(gr_complex);
- set_alignment(alignment_multiple);
+ set_alignment(std::max(1,alignment_multiple));
}
int
diff --git a/gnuradio-core/src/lib/general/gr_endian_swap.cc b/gnuradio-core/src/lib/general/gr_endian_swap.cc
new file mode 100644
index 000000000..8bea0ca30
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_endian_swap.cc
@@ -0,0 +1,101 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2010,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 <gr_endian_swap.h>
+#include <gr_io_signature.h>
+#include <volk/volk.h>
+
+gr_endian_swap_sptr
+gr_make_endian_swap (size_t item_size_bytes)
+{
+ return gnuradio::get_initial_sptr(new gr_endian_swap (item_size_bytes));
+}
+
+gr_endian_swap::gr_endian_swap (size_t item_size_bytes)
+ : gr_sync_block ("gr_endian_swap",
+ gr_make_io_signature (1, 1, item_size_bytes),
+ gr_make_io_signature (1, 1, item_size_bytes))
+{
+ const int alignment_multiple = volk_get_alignment();
+ set_alignment(std::max(1,alignment_multiple));
+}
+
+int
+gr_endian_swap::work (int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+{
+ const char *in = (const char *) input_items[0];
+ char *out = (char *) output_items[0];
+
+ int nbytes( output_signature()->sizeof_stream_item(0) );
+ if(is_unaligned()) {
+ switch(nbytes){
+ case 1:
+ memcpy(out,in,noutput_items);
+ break;
+ case 2:
+ memcpy(out,in,2*noutput_items);
+ volk_16u_byteswap_u((uint16_t*)out,noutput_items);
+ break;
+ case 4:
+ memcpy(out,in,4*noutput_items);
+ volk_32u_byteswap_u((uint32_t*)out,noutput_items);
+ break;
+ case 8:
+ memcpy(out,in,8*noutput_items);
+ volk_64u_byteswap_u((uint64_t*)out,noutput_items);
+ break;
+ default:
+ throw std::runtime_error("itemsize is not valid for gr_endian_swap!");
+ }
+ } else {
+ switch(nbytes){
+ case 1:
+ memcpy(out,in,noutput_items);
+ break;
+ case 2:
+ memcpy(out,in,2*noutput_items);
+ volk_16u_byteswap_a((uint16_t*)out,noutput_items);
+ break;
+ case 4:
+ memcpy(out,in,4*noutput_items);
+ volk_32u_byteswap_a((uint32_t*)out,noutput_items);
+ break;
+ case 8:
+ memcpy(out,in,8*noutput_items);
+ volk_64u_byteswap_a((uint64_t*)out,noutput_items);
+ break;
+ default:
+ throw std::runtime_error("itemsize is not valid for gr_endian_swap!");
+ }
+ }
+
+ return noutput_items;
+}
+
+
+
diff --git a/gnuradio-core/src/lib/general/gr_endian_swap.h b/gnuradio-core/src/lib/general/gr_endian_swap.h
new file mode 100644
index 000000000..0baa3f338
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_endian_swap.h
@@ -0,0 +1,57 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,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_ENDIAN_SWAP_H
+#define INCLUDED_GR_ENDIAN_SWAP_H
+
+#include <gr_core_api.h>
+#include <gr_sync_block.h>
+
+class gr_endian_swap;
+typedef boost::shared_ptr<gr_endian_swap> gr_endian_swap_sptr;
+
+GR_CORE_API gr_endian_swap_sptr
+gr_make_endian_swap (size_t item_size_bytes=1);
+
+/*!
+ * \brief Convert stream of items into thier byte swapped version
+ *
+ * \param item_size_bytes number of bytes per item, 1=no-op,2=uint16_t,4=uint32_t,8=uint64_t
+ */
+
+class GR_CORE_API gr_endian_swap : public gr_sync_block
+{
+ private:
+ friend GR_CORE_API gr_endian_swap_sptr
+ gr_make_endian_swap (size_t item_size_bytes);
+ gr_endian_swap (size_t item_size_bytes);
+
+ size_t item_size_bytes;
+
+ public:
+ virtual int work (int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+};
+
+
+#endif /* INCLUDED_GR_ENDIAN_SWAP_H */
diff --git a/gnuradio-core/src/lib/general/gr_endian_swap.i b/gnuradio-core/src/lib/general/gr_endian_swap.i
new file mode 100644
index 000000000..6058b9de7
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_endian_swap.i
@@ -0,0 +1,31 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,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.
+ */
+
+GR_SWIG_BLOCK_MAGIC(gr,endian_swap)
+
+gr_endian_swap_sptr
+gr_make_endian_swap (size_t bytes_per_item=1);
+
+class gr_endian_swap : public gr_sync_block
+{
+public:
+};
diff --git a/gnuradio-core/src/lib/general/gr_float_to_char.cc b/gnuradio-core/src/lib/general/gr_float_to_char.cc
index 3602ad745..d67ded3ea 100644
--- a/gnuradio-core/src/lib/general/gr_float_to_char.cc
+++ b/gnuradio-core/src/lib/general/gr_float_to_char.cc
@@ -42,7 +42,7 @@ gr_float_to_char::gr_float_to_char (size_t vlen, float scale)
{
const int alignment_multiple =
volk_get_alignment() / sizeof(char);
- set_alignment(alignment_multiple);
+ set_alignment(std::max(1,alignment_multiple));
}
float
diff --git a/gnuradio-core/src/lib/general/gr_float_to_int.cc b/gnuradio-core/src/lib/general/gr_float_to_int.cc
index bd3cd6a3b..43b851895 100644
--- a/gnuradio-core/src/lib/general/gr_float_to_int.cc
+++ b/gnuradio-core/src/lib/general/gr_float_to_int.cc
@@ -43,7 +43,7 @@ gr_float_to_int::gr_float_to_int (size_t vlen, float scale)
{
const int alignment_multiple =
volk_get_alignment() / sizeof(int);
- set_alignment(alignment_multiple);
+ set_alignment(std::max(1,alignment_multiple));
}
float
diff --git a/gnuradio-core/src/lib/general/gr_float_to_short.cc b/gnuradio-core/src/lib/general/gr_float_to_short.cc
index 07995c99a..ab720168b 100644
--- a/gnuradio-core/src/lib/general/gr_float_to_short.cc
+++ b/gnuradio-core/src/lib/general/gr_float_to_short.cc
@@ -42,7 +42,7 @@ gr_float_to_short::gr_float_to_short (size_t vlen, float scale)
{
const int alignment_multiple =
volk_get_alignment() / sizeof(short);
- set_alignment(alignment_multiple);
+ set_alignment(std::max(1,alignment_multiple));
}
float
diff --git a/gnuradio-core/src/lib/general/gr_head.h b/gnuradio-core/src/lib/general/gr_head.h
index 17dd737f0..48415892d 100644
--- a/gnuradio-core/src/lib/general/gr_head.h
+++ b/gnuradio-core/src/lib/general/gr_head.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2004,2009 Free Software Foundation, Inc.
+ * Copyright 2004,2009,2012 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -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..11f3331d4 100644
--- a/gnuradio-core/src/lib/general/gr_head.i
+++ b/gnuradio-core/src/lib/general/gr_head.i
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2004,2009 Free Software Foundation, Inc.
+ * Copyright 2004,2009,2012 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -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_int_to_float.cc b/gnuradio-core/src/lib/general/gr_int_to_float.cc
index a28485305..a7fb24dc6 100644
--- a/gnuradio-core/src/lib/general/gr_int_to_float.cc
+++ b/gnuradio-core/src/lib/general/gr_int_to_float.cc
@@ -42,7 +42,7 @@ gr_int_to_float::gr_int_to_float (size_t vlen, float scale)
{
const int alignment_multiple =
volk_get_alignment() / sizeof(float);
- set_alignment(alignment_multiple);
+ set_alignment(std::max(1,alignment_multiple));
}
int
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..1becbfa11
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_keep_m_in_n.cc
@@ -0,0 +1,98 @@
+/* -*- 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 <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_block("keep_m_in_n",
+ gr_make_io_signature(1, 1, item_size),
+ gr_make_io_signature(1, 1, item_size)),
+ d_n(n),
+ d_m(m),
+ d_offset(offset),
+ d_itemsize(item_size)
+{
+ // sanity checking
+ assert(d_m > 0);
+ assert(d_n > 0);
+ assert(d_m <= d_n);
+ assert(d_offset <= (d_n-d_m));
+
+ set_output_multiple(m);
+}
+
+
+void
+gr_keep_m_in_n::forecast(int noutput_items, gr_vector_int &ninput_items_required)
+{
+ ninput_items_required[0] = d_n*(noutput_items/d_m);
+}
+
+void
+gr_keep_m_in_n::set_offset(int offset)
+{
+ d_offset = offset;
+}
+
+int
+gr_keep_m_in_n::general_work(int noutput_items,
+ gr_vector_int &ninput_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];
+
+ // iterate over data blocks of size {n, input : m, output}
+ int blks = std::min(noutput_items/d_m, ninput_items[0]/d_n);
+ for(int i=0; i<blks; i++) {
+ // set up copy pointers
+ const uint8_t* iptr = &in[(i*d_n + d_offset)*d_itemsize];
+ uint8_t* optr = &out[i*d_m*d_itemsize];
+ // perform copy
+ memcpy( optr, iptr, d_m*d_itemsize );
+ }
+
+ consume_each(d_n);
+ return d_m;
+}
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..c6bf40ecf
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_keep_m_in_n.h
@@ -0,0 +1,67 @@
+/* -*- 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_GR_KEEP_M_IN_N_H
+#define INCLUDED_GR_KEEP_M_IN_N_H
+
+#include <gr_core_api.h>
+#include <gr_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_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;
+ int d_itemsize;
+
+ protected:
+ gr_keep_m_in_n (size_t item_size, int m, int n, int offset);
+ void forecast (int noutput_items, gr_vector_int &ninput_items_required);
+
+ public:
+ 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_offset(int offset);
+ void set_n(int n){ d_n = n; }
+ void set_m(int m){ d_m = m; }
+
+};
+
+#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..f280c0248
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_keep_m_in_n.i
@@ -0,0 +1,35 @@
+/* -*- 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.
+ */
+
+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_multiply_cc.cc b/gnuradio-core/src/lib/general/gr_multiply_cc.cc
index 32c44a19e..4a3751419 100644
--- a/gnuradio-core/src/lib/general/gr_multiply_cc.cc
+++ b/gnuradio-core/src/lib/general/gr_multiply_cc.cc
@@ -40,9 +40,9 @@ gr_multiply_cc::gr_multiply_cc (size_t vlen)
gr_make_io_signature (1, 1, sizeof (gr_complex)*vlen)),
d_vlen(vlen)
{
- const int alignment_multiple =
- volk_get_alignment() / sizeof(gr_complex);
- set_alignment(alignment_multiple);
+ const int alignment_multiple =
+ volk_get_alignment() / sizeof(gr_complex);
+ set_alignment(std::max(1,alignment_multiple));
}
int
diff --git a/gnuradio-core/src/lib/general/gr_multiply_conjugate_cc.cc b/gnuradio-core/src/lib/general/gr_multiply_conjugate_cc.cc
index 53ede2eed..0c5fb4a92 100644
--- a/gnuradio-core/src/lib/general/gr_multiply_conjugate_cc.cc
+++ b/gnuradio-core/src/lib/general/gr_multiply_conjugate_cc.cc
@@ -40,9 +40,9 @@ gr_multiply_conjugate_cc::gr_multiply_conjugate_cc (size_t vlen)
gr_make_io_signature (1, 1, sizeof (gr_complex)*vlen)),
d_vlen(vlen)
{
- const int alignment_multiple =
- volk_get_alignment() / sizeof(gr_complex);
- set_alignment(alignment_multiple);
+ const int alignment_multiple =
+ volk_get_alignment() / sizeof(gr_complex);
+ set_alignment(std::max(1,alignment_multiple));
}
int
diff --git a/gnuradio-core/src/lib/general/gr_multiply_const_cc.cc b/gnuradio-core/src/lib/general/gr_multiply_const_cc.cc
index 359ab6ba0..bd4511937 100644
--- a/gnuradio-core/src/lib/general/gr_multiply_const_cc.cc
+++ b/gnuradio-core/src/lib/general/gr_multiply_const_cc.cc
@@ -40,9 +40,9 @@ gr_multiply_const_cc::gr_multiply_const_cc (gr_complex k, size_t vlen)
gr_make_io_signature (1, 1, sizeof (gr_complex)*vlen)),
d_k(k), d_vlen(vlen)
{
- const int alignment_multiple =
- volk_get_alignment() / sizeof(gr_complex);
- set_alignment(alignment_multiple);
+ const int alignment_multiple =
+ volk_get_alignment() / sizeof(gr_complex);
+ set_alignment(std::max(1,alignment_multiple));
}
gr_complex
diff --git a/gnuradio-core/src/lib/general/gr_multiply_const_ff.cc b/gnuradio-core/src/lib/general/gr_multiply_const_ff.cc
index 263f06610..16ba39df9 100644
--- a/gnuradio-core/src/lib/general/gr_multiply_const_ff.cc
+++ b/gnuradio-core/src/lib/general/gr_multiply_const_ff.cc
@@ -40,9 +40,9 @@ gr_multiply_const_ff::gr_multiply_const_ff (float k, size_t vlen)
gr_make_io_signature (1, 1, sizeof (float)*vlen)),
d_k(k), d_vlen(vlen)
{
- const int alignment_multiple =
- volk_get_alignment() / sizeof(float);
- set_alignment(alignment_multiple);
+ const int alignment_multiple =
+ volk_get_alignment() / sizeof(float);
+ set_alignment(std::max(1,alignment_multiple));
}
float
diff --git a/gnuradio-core/src/lib/general/gr_multiply_ff.cc b/gnuradio-core/src/lib/general/gr_multiply_ff.cc
index f764a71e8..bb7bd0755 100644
--- a/gnuradio-core/src/lib/general/gr_multiply_ff.cc
+++ b/gnuradio-core/src/lib/general/gr_multiply_ff.cc
@@ -42,7 +42,7 @@ gr_multiply_ff::gr_multiply_ff (size_t vlen)
{
const int alignment_multiple =
volk_get_alignment() / sizeof(float);
- set_alignment(alignment_multiple);
+ set_alignment(std::max(1,alignment_multiple));
}
int
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..0ea0c9e38
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_pack_k_bits_bb.cc
@@ -0,0 +1,69 @@
+/* -*- 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.
+ */
+
+#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])<<(d_k-j-1);
+ }
+ }
+
+ 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..8e1508c78
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_pack_k_bits_bb.h
@@ -0,0 +1,56 @@
+/* -*- 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_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 stream of bytes with 1 bit in the LSB to a byte with k relevent bits.
+ * \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..6ae2095ec
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_pack_k_bits_bb.i
@@ -0,0 +1,34 @@
+/* -*- 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.
+ */
+
+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/general/gr_short_to_char.cc b/gnuradio-core/src/lib/general/gr_short_to_char.cc
index 9d6c41406..8c146a351 100644
--- a/gnuradio-core/src/lib/general/gr_short_to_char.cc
+++ b/gnuradio-core/src/lib/general/gr_short_to_char.cc
@@ -42,7 +42,7 @@ gr_short_to_char::gr_short_to_char (size_t vlen)
{
const int alignment_multiple =
volk_get_alignment() / sizeof(char);
- set_alignment(alignment_multiple);
+ set_alignment(std::max(1,alignment_multiple));
}
int
diff --git a/gnuradio-core/src/lib/general/gr_short_to_float.cc b/gnuradio-core/src/lib/general/gr_short_to_float.cc
index 960cf644d..093d6024f 100644
--- a/gnuradio-core/src/lib/general/gr_short_to_float.cc
+++ b/gnuradio-core/src/lib/general/gr_short_to_float.cc
@@ -42,7 +42,7 @@ gr_short_to_float::gr_short_to_float (size_t vlen, float scale)
{
const int alignment_multiple =
volk_get_alignment() / sizeof(float);
- set_alignment(alignment_multiple);
+ set_alignment(std::max(1,alignment_multiple));
}
float
diff --git a/gnuradio-core/src/lib/general/gr_skiphead.cc b/gnuradio-core/src/lib/general/gr_skiphead.cc
index c887376e4..7b441bea9 100644
--- a/gnuradio-core/src/lib/general/gr_skiphead.cc
+++ b/gnuradio-core/src/lib/general/gr_skiphead.cc
@@ -43,14 +43,14 @@ gr_make_skiphead (size_t itemsize, uint64_t nitems_to_skip)
int
gr_skiphead::general_work(int noutput_items,
- gr_vector_int &ninput_items_ignored,
+ gr_vector_int &ninput_items_,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
const char *in = (const char *) input_items[0];
char *out = (char *) output_items[0];
- int ninput_items = noutput_items; // we've got at least this many input items
+ int ninput_items = std::min(ninput_items_[0], noutput_items);
int ii = 0; // input index
while (ii < ninput_items){
diff --git a/gnuradio-core/src/lib/general/gr_tag_debug.cc b/gnuradio-core/src/lib/general/gr_tag_debug.cc
new file mode 100644
index 000000000..c4031f438
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_tag_debug.cc
@@ -0,0 +1,100 @@
+/* -*- 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 <gr_tag_debug.h>
+#include <gr_io_signature.h>
+#include <iostream>
+#include <iomanip>
+
+gr_tag_debug_sptr
+gr_make_tag_debug(size_t sizeof_stream_item, const std::string &name)
+{
+ return gnuradio::get_initial_sptr
+ (new gr_tag_debug(sizeof_stream_item, name));
+}
+
+gr_tag_debug::gr_tag_debug(size_t sizeof_stream_item, const std::string &name)
+ : gr_sync_block("tag_debug",
+ gr_make_io_signature(1, -1, sizeof_stream_item),
+ gr_make_io_signature(0, 0, 0)),
+ d_name(name), d_display(true)
+{
+}
+
+std::vector<gr_tag_t>
+gr_tag_debug::current_tags()
+{
+ gruel::scoped_lock l(d_mutex);
+ return d_tags;
+}
+
+void
+gr_tag_debug::set_display(bool d)
+{
+ gruel::scoped_lock l(d_mutex);
+ d_display = d;
+}
+
+int
+gr_tag_debug::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+{
+ gruel::scoped_lock l(d_mutex);
+
+ if(d_display) {
+ std::cout << std::endl
+ << "----------------------------------------------------------------------";
+ std::cout << std::endl << "Tag Debug: " << d_name << std::endl;
+ }
+
+ uint64_t abs_N, end_N;
+ for(size_t i = 0; i < input_items.size(); i++) {
+ abs_N = nitems_read(i);
+ end_N = abs_N + (uint64_t)(noutput_items);
+
+ d_tags.clear();
+ get_tags_in_range(d_tags, i, abs_N, end_N);
+
+ if(d_display) {
+ std::cout << "Input Stream: " << i << std::endl;
+ for(d_tags_itr = d_tags.begin(); d_tags_itr != d_tags.end(); d_tags_itr++) {
+ std::cout << std::setw(10) << "Offset: " << d_tags_itr->offset
+ << std::setw(10) << "Source: " << pmt::pmt_symbol_to_string(d_tags_itr->srcid)
+ << std::setw(10) << "Key: " << pmt::pmt_symbol_to_string(d_tags_itr->key)
+ << std::setw(10) << "Value: ";
+ pmt::pmt_print(d_tags_itr->value);
+ }
+ }
+ }
+
+ if(d_display) {
+ std::cout << "----------------------------------------------------------------------";
+ std::cout << std::endl;
+ }
+
+ return noutput_items;
+}
diff --git a/gnuradio-core/src/lib/general/gr_tag_debug.h b/gnuradio-core/src/lib/general/gr_tag_debug.h
new file mode 100644
index 000000000..57578884a
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_tag_debug.h
@@ -0,0 +1,85 @@
+/* -*- 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_GR_TAG_DEBUG_H
+#define INCLUDED_GR_TAG_DEBUG_H
+
+#include <gr_core_api.h>
+#include <gr_sync_block.h>
+#include <gruel/thread.h>
+#include <stddef.h>
+
+class gr_tag_debug;
+typedef boost::shared_ptr<gr_tag_debug> gr_tag_debug_sptr;
+
+GR_CORE_API gr_tag_debug_sptr
+gr_make_tag_debug(size_t sizeof_stream_item, const std::string &name);
+
+/*!
+ * \brief Bit bucket that prints out any tag received.
+ * \ingroup sink_blk
+ *
+ * This block collects all tags sent to it on all input ports and
+ * displays them to stdout in a formatted way. The \p name parameter
+ * is used to identify which debug sink generated the tag, so when
+ * connecting a block to this debug sink, an appropriate name is
+ * something that identifies the input block.
+ *
+ * This block otherwise acts as a NULL sink in that items from the
+ * input stream are ignored. It is designed to be able to attach to
+ * any block and watch all tags streaming out of that block for
+ * debugging purposes.
+ *
+ * The tags from the last call to this work function are stored and
+ * can be retrieved using the function 'current_tags'.
+ */
+class GR_CORE_API gr_tag_debug : public gr_sync_block
+{
+ private:
+ friend GR_CORE_API gr_tag_debug_sptr
+ gr_make_tag_debug(size_t sizeof_stream_item, const std::string &name);
+ gr_tag_debug(size_t sizeof_stream_item, const std::string &name);
+
+ std::string d_name;
+ std::vector<gr_tag_t> d_tags;
+ std::vector<gr_tag_t>::iterator d_tags_itr;
+ bool d_display;
+ gruel::mutex d_mutex;
+
+ public:
+ /*!
+ * \brief Returns a vector of gr_tag_t items as of the last call to
+ * work.
+ */
+ std::vector<gr_tag_t> current_tags();
+
+ /*!
+ * \brief Set the display of tags to stdout on/off.
+ */
+ void set_display(bool d);
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+};
+
+#endif /* INCLUDED_GR_TAG_DEBUG_H */
diff --git a/gnuradio-core/src/lib/general/gr_tag_debug.i b/gnuradio-core/src/lib/general/gr_tag_debug.i
new file mode 100644
index 000000000..3af1bdcfe
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_tag_debug.i
@@ -0,0 +1,35 @@
+/* -*- 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.
+ */
+
+GR_SWIG_BLOCK_MAGIC(gr,tag_debug)
+
+%include <gr_tags.i>
+
+gr_tag_debug_sptr
+gr_make_tag_debug(size_t sizeof_stream_item, const std::string &name);
+
+class gr_tag_debug : public gr_sync_block
+{
+public:
+ std::vector<gr_tag_t> current_tags();
+ void set_display(bool d);
+};
diff --git a/gnuradio-core/src/lib/general/gr_vector_map.cc b/gnuradio-core/src/lib/general/gr_vector_map.cc
new file mode 100644
index 000000000..2a13efb06
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_vector_map.cc
@@ -0,0 +1,117 @@
+/* -*- 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 <gr_vector_map.h>
+#include <gr_io_signature.h>
+#include <string.h>
+
+std::vector<int>
+get_in_sizeofs(size_t item_size, std::vector<size_t> in_vlens)
+{
+ std::vector<int> in_sizeofs;
+ for(unsigned int i = 0; i < in_vlens.size(); i++) {
+ in_sizeofs.push_back(in_vlens[i]*item_size);
+ }
+ return in_sizeofs;
+}
+
+std::vector<int>
+get_out_sizeofs(size_t item_size,
+ std::vector< std::vector< std::vector<size_t> > > mapping)
+{
+ std::vector<int> out_sizeofs;
+ for(unsigned int i = 0; i < mapping.size(); i++) {
+ out_sizeofs.push_back(mapping[i].size()*item_size);
+ }
+ return out_sizeofs;
+}
+
+gr_vector_map_sptr
+gr_make_vector_map (size_t item_size, std::vector<size_t> in_vlens,
+ std::vector< std::vector< std::vector<size_t> > > mapping)
+{
+ return gnuradio::get_initial_sptr(new gr_vector_map(item_size,
+ in_vlens,
+ mapping));
+}
+
+gr_vector_map::gr_vector_map(size_t item_size, std::vector<size_t> in_vlens,
+ std::vector< std::vector< std::vector<size_t> > > mapping)
+ : gr_sync_block("vector_map",
+ gr_make_io_signaturev(in_vlens.size(), in_vlens.size(),
+ get_in_sizeofs(item_size, in_vlens)),
+ gr_make_io_signaturev(mapping.size(), mapping.size(),
+ get_out_sizeofs(item_size, mapping))),
+ d_item_size(item_size), d_in_vlens(in_vlens)
+{
+ set_mapping(mapping);
+}
+
+void
+gr_vector_map::set_mapping(std::vector< std::vector< std::vector<size_t> > > mapping) {
+ // Make sure the contents of the mapping vectors are possible.
+ for(unsigned int i=0; i<mapping.size(); i++) {
+ for(unsigned int j=0; j<mapping[i].size(); j++) {
+ if(mapping[i][j].size() != 2) {
+ throw std::runtime_error("Mapping must be of the form (out_mapping_stream1, out_mapping_stream2, ...), where out_mapping_stream1 is of the form (mapping_element1, mapping_element2, ...), where mapping_element1 is of the form (input_stream, input_element). This error is raised because a mapping_element vector does not contain exactly 2 items.");
+ }
+ unsigned int s = mapping[i][j][0];
+ unsigned int index = mapping[i][j][1];
+ if(s >= d_in_vlens.size()) {
+ throw std::runtime_error("Stream numbers in mapping must be less than the number of input streams.");
+ }
+ if((index < 0) || (index >= d_in_vlens[s])) {
+ throw std::runtime_error ("Indices in mapping must be greater than 0 and less than the input vector lengths.");
+ }
+ }
+ }
+ gruel::scoped_lock guard(d_mutex);
+ d_mapping = mapping;
+}
+
+int
+gr_vector_map::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+{
+ const char **inv = (const char **) &input_items[0];
+ char **outv = (char **) &output_items[0];
+
+ for(unsigned int n = 0; n < (unsigned int)(noutput_items); n++) {
+ for(unsigned int i = 0; i < d_mapping.size(); i++) {
+ unsigned int out_vlen = d_mapping[i].size();
+ for(unsigned int j = 0; j < out_vlen; j++) {
+ unsigned int s = d_mapping[i][j][0];
+ unsigned int k = d_mapping[i][j][1];
+ memcpy(outv[i] + out_vlen*d_item_size*n +
+ d_item_size*j, inv[s] + d_in_vlens[s]*d_item_size*n +
+ k*d_item_size, d_item_size);
+ }
+ }
+ }
+
+ return noutput_items;
+}
diff --git a/gnuradio-core/src/lib/general/gr_vector_map.h b/gnuradio-core/src/lib/general/gr_vector_map.h
new file mode 100644
index 000000000..f5492b1e3
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_vector_map.h
@@ -0,0 +1,83 @@
+/* -*- 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_GR_VECTOR_MAP_H
+#define INCLUDED_GR_VECTOR_MAP_H
+
+#include <vector>
+#include <gr_core_api.h>
+#include <gr_sync_interpolator.h>
+#include <gruel/thread.h>
+
+class gr_vector_map;
+typedef boost::shared_ptr<gr_vector_map> gr_vector_map_sptr;
+
+GR_CORE_API gr_vector_map_sptr
+gr_make_vector_map (size_t item_size, std::vector<size_t> in_vlens,
+ std::vector< std::vector< std::vector<size_t> > > mapping);
+
+/*!
+ * \brief Maps elements from a set of input vectors to a set of output vectors.
+ *
+ * If in[i] is the input vector in the i'th stream then the output
+ * vector in the j'th stream is:
+ *
+ * out[j][k] = in[mapping[j][k][0]][mapping[j][k][1]]
+ *
+ * That is mapping is of the form (out_stream1_mapping,
+ * out_stream2_mapping, ...) and out_stream1_mapping is of the form
+ * (element1_mapping, element2_mapping, ...) and element1_mapping is
+ * of the form (in_stream, in_element).
+ *
+ * \param item_size (integer) size of vector elements
+ *
+ * \param in_vlens (vector of integers) number of elements in each
+ * input vector
+ *
+ * \param mapping (vector of vectors of vectors of integers) how to
+ * map elements from input to output vectors
+ *
+ * \ingroup slicedice_blk
+ */
+class GR_CORE_API gr_vector_map : public gr_sync_block
+{
+ friend GR_CORE_API gr_vector_map_sptr
+ gr_make_vector_map(size_t item_size, std::vector<size_t> in_vlens,
+ std::vector< std::vector< std::vector<size_t> > > mapping);
+ size_t d_item_size;
+ std::vector<size_t> d_in_vlens;
+ std::vector< std::vector< std::vector<size_t> > > d_mapping;
+ gruel::mutex d_mutex; // mutex to protect set/work access
+
+ protected:
+ gr_vector_map(size_t item_size, std::vector<size_t> in_vlens,
+ std::vector< std::vector< std::vector<size_t> > > mapping);
+
+ public:
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+
+ void set_mapping(std::vector< std::vector< std::vector<size_t> > > mapping);
+};
+
+#endif /* INCLUDED_GR_VECTOR_MAP_H */
diff --git a/gnuradio-core/src/lib/general/gr_vector_map.i b/gnuradio-core/src/lib/general/gr_vector_map.i
new file mode 100644
index 000000000..e9fa3f27e
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_vector_map.i
@@ -0,0 +1,28 @@
+/* -*- 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.
+ */
+
+GR_SWIG_BLOCK_MAGIC(gr, vector_map);
+
+%template() std::vector<size_t>;
+%template() std::vector< std::vector< std::vector<size_t> > >;
+
+%include "gr_vector_map.h"
diff --git a/gnuradio-core/src/lib/gengen/CMakeLists.txt b/gnuradio-core/src/lib/gengen/CMakeLists.txt
index d13776990..b44a47075 100644
--- a/gnuradio-core/src/lib/gengen/CMakeLists.txt
+++ b/gnuradio-core/src/lib/gengen/CMakeLists.txt
@@ -82,13 +82,14 @@ 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)
expand_h_cc_i(gr_probe_signal_X b s i f c)
expand_h_cc_i(gr_probe_signal_vX b s i f c)
-expand_h_cc_i(gr_add_const_XX ss ii ff cc sf)
+expand_h_cc_i(gr_add_const_XX bb ss ii ff cc sf)
expand_h_cc_i(gr_multiply_const_XX ss ii)
expand_h_cc_i(gr_add_XX ss ii cc)
expand_h_cc_i(gr_sub_XX ss ii ff cc)
diff --git a/gnuradio-core/src/lib/gengen/Makefile.gen b/gnuradio-core/src/lib/gengen/Makefile.gen
deleted file mode 100644
index b4a255dc0..000000000
--- a/gnuradio-core/src/lib/gengen/Makefile.gen
+++ /dev/null
@@ -1,333 +0,0 @@
-#
-# This file is machine generated. All edits will be overwritten
-#
-GENERATED_H = \
- gr_add_cc.h \
- gr_add_const_cc.h \
- gr_add_const_ff.h \
- gr_add_const_ii.h \
- gr_add_const_sf.h \
- gr_add_const_ss.h \
- gr_add_const_vcc.h \
- gr_add_const_vff.h \
- gr_add_const_vii.h \
- gr_add_const_vss.h \
- gr_add_ii.h \
- gr_add_ss.h \
- gr_and_bb.h \
- gr_and_const_bb.h \
- gr_and_const_ii.h \
- gr_and_const_ss.h \
- gr_and_ii.h \
- gr_and_ss.h \
- gr_argmax_fs.h \
- gr_argmax_is.h \
- gr_argmax_ss.h \
- gr_chunks_to_symbols_bc.h \
- gr_chunks_to_symbols_bf.h \
- gr_chunks_to_symbols_ic.h \
- gr_chunks_to_symbols_if.h \
- gr_chunks_to_symbols_sc.h \
- gr_chunks_to_symbols_sf.h \
- gr_divide_cc.h \
- gr_divide_ff.h \
- gr_divide_ii.h \
- gr_divide_ss.h \
- gr_integrate_cc.h \
- gr_integrate_ff.h \
- gr_integrate_ii.h \
- gr_integrate_ss.h \
- gr_max_ff.h \
- gr_max_ii.h \
- gr_max_ss.h \
- gr_moving_average_cc.h \
- gr_moving_average_ff.h \
- gr_moving_average_ii.h \
- gr_moving_average_ss.h \
- gr_multiply_const_ii.h \
- gr_multiply_const_ss.h \
- gr_multiply_const_vcc.h \
- gr_multiply_const_vff.h \
- gr_multiply_const_vii.h \
- gr_multiply_const_vss.h \
- gr_multiply_ii.h \
- gr_multiply_ss.h \
- gr_mute_cc.h \
- gr_mute_ff.h \
- gr_mute_ii.h \
- gr_mute_ss.h \
- gr_noise_source_c.h \
- gr_noise_source_f.h \
- gr_noise_source_i.h \
- gr_noise_source_s.h \
- gr_not_bb.h \
- gr_not_ii.h \
- gr_not_ss.h \
- gr_or_bb.h \
- gr_or_ii.h \
- gr_or_ss.h \
- gr_packed_to_unpacked_bb.h \
- gr_packed_to_unpacked_ii.h \
- gr_packed_to_unpacked_ss.h \
- gr_peak_detector_fb.h \
- gr_peak_detector_ib.h \
- gr_peak_detector_sb.h \
- gr_probe_signal_b.h \
- gr_probe_signal_s.h \
- gr_probe_signal_i.h \
- gr_probe_signal_f.h \
- gr_probe_signal_c.h \
- gr_probe_signal_vb.h \
- gr_probe_signal_vs.h \
- gr_probe_signal_vi.h \
- gr_probe_signal_vf.h \
- gr_probe_signal_vc.h \
- gr_sample_and_hold_bb.h \
- gr_sample_and_hold_ff.h \
- gr_sample_and_hold_ii.h \
- gr_sample_and_hold_ss.h \
- gr_sig_source_c.h \
- gr_sig_source_f.h \
- gr_sig_source_i.h \
- gr_sig_source_s.h \
- gr_sub_cc.h \
- gr_sub_ff.h \
- gr_sub_ii.h \
- gr_sub_ss.h \
- gr_unpacked_to_packed_bb.h \
- gr_unpacked_to_packed_ii.h \
- gr_unpacked_to_packed_ss.h \
- gr_vector_sink_b.h \
- gr_vector_sink_c.h \
- gr_vector_sink_f.h \
- gr_vector_sink_i.h \
- gr_vector_sink_s.h \
- gr_vector_source_b.h \
- gr_vector_source_c.h \
- gr_vector_source_f.h \
- gr_vector_source_i.h \
- gr_vector_source_s.h \
- gr_xor_bb.h \
- gr_xor_ii.h \
- gr_xor_ss.h
-
-GENERATED_I = \
- gr_add_cc.i \
- gr_add_const_cc.i \
- gr_add_const_ff.i \
- gr_add_const_ii.i \
- gr_add_const_sf.i \
- gr_add_const_ss.i \
- gr_add_const_vcc.i \
- gr_add_const_vff.i \
- gr_add_const_vii.i \
- gr_add_const_vss.i \
- gr_add_ii.i \
- gr_add_ss.i \
- gr_and_bb.i \
- gr_and_const_bb.i \
- gr_and_const_ii.i \
- gr_and_const_ss.i \
- gr_and_ii.i \
- gr_and_ss.i \
- gr_argmax_fs.i \
- gr_argmax_is.i \
- gr_argmax_ss.i \
- gr_chunks_to_symbols_bc.i \
- gr_chunks_to_symbols_bf.i \
- gr_chunks_to_symbols_ic.i \
- gr_chunks_to_symbols_if.i \
- gr_chunks_to_symbols_sc.i \
- gr_chunks_to_symbols_sf.i \
- gr_divide_cc.i \
- gr_divide_ff.i \
- gr_divide_ii.i \
- gr_divide_ss.i \
- gr_integrate_cc.i \
- gr_integrate_ff.i \
- gr_integrate_ii.i \
- gr_integrate_ss.i \
- gr_max_ff.i \
- gr_max_ii.i \
- gr_max_ss.i \
- gr_moving_average_cc.i \
- gr_moving_average_ff.i \
- gr_moving_average_ii.i \
- gr_moving_average_ss.i \
- gr_multiply_const_ii.i \
- gr_multiply_const_ss.i \
- gr_multiply_const_vcc.i \
- gr_multiply_const_vff.i \
- gr_multiply_const_vii.i \
- gr_multiply_const_vss.i \
- gr_multiply_ii.i \
- gr_multiply_ss.i \
- gr_mute_cc.i \
- gr_mute_ff.i \
- gr_mute_ii.i \
- gr_mute_ss.i \
- gr_noise_source_c.i \
- gr_noise_source_f.i \
- gr_noise_source_i.i \
- gr_noise_source_s.i \
- gr_not_bb.i \
- gr_not_ii.i \
- gr_not_ss.i \
- gr_or_bb.i \
- gr_or_ii.i \
- gr_or_ss.i \
- gr_packed_to_unpacked_bb.i \
- gr_packed_to_unpacked_ii.i \
- gr_packed_to_unpacked_ss.i \
- gr_peak_detector_fb.i \
- gr_peak_detector_ib.i \
- gr_peak_detector_sb.i \
- gr_probe_signal_b.i \
- gr_probe_signal_s.i \
- gr_probe_signal_i.i \
- gr_probe_signal_f.i \
- gr_probe_signal_c.i \
- gr_probe_signal_vb.i \
- gr_probe_signal_vs.i \
- gr_probe_signal_vi.i \
- gr_probe_signal_vf.i \
- gr_probe_signal_vc.i \
- gr_sample_and_hold_bb.i \
- gr_sample_and_hold_ff.i \
- gr_sample_and_hold_ii.i \
- gr_sample_and_hold_ss.i \
- gr_sig_source_c.i \
- gr_sig_source_f.i \
- gr_sig_source_i.i \
- gr_sig_source_s.i \
- gr_sub_cc.i \
- gr_sub_ff.i \
- gr_sub_ii.i \
- gr_sub_ss.i \
- gr_unpacked_to_packed_bb.i \
- gr_unpacked_to_packed_ii.i \
- gr_unpacked_to_packed_ss.i \
- gr_vector_sink_b.i \
- gr_vector_sink_c.i \
- gr_vector_sink_f.i \
- gr_vector_sink_i.i \
- gr_vector_sink_s.i \
- gr_vector_source_b.i \
- gr_vector_source_c.i \
- gr_vector_source_f.i \
- gr_vector_source_i.i \
- gr_vector_source_s.i \
- gr_xor_bb.i \
- gr_xor_ii.i \
- gr_xor_ss.i
-
-GENERATED_CC = \
- gr_add_cc.cc \
- gr_add_const_cc.cc \
- gr_add_const_ff.cc \
- gr_add_const_ii.cc \
- gr_add_const_sf.cc \
- gr_add_const_ss.cc \
- gr_add_const_vcc.cc \
- gr_add_const_vff.cc \
- gr_add_const_vii.cc \
- gr_add_const_vss.cc \
- gr_add_ii.cc \
- gr_add_ss.cc \
- gr_and_bb.cc \
- gr_and_const_bb.cc \
- gr_and_const_ii.cc \
- gr_and_const_ss.cc \
- gr_and_ii.cc \
- gr_and_ss.cc \
- gr_argmax_fs.cc \
- gr_argmax_is.cc \
- gr_argmax_ss.cc \
- gr_chunks_to_symbols_bc.cc \
- gr_chunks_to_symbols_bf.cc \
- gr_chunks_to_symbols_ic.cc \
- gr_chunks_to_symbols_if.cc \
- gr_chunks_to_symbols_sc.cc \
- gr_chunks_to_symbols_sf.cc \
- gr_divide_cc.cc \
- gr_divide_ff.cc \
- gr_divide_ii.cc \
- gr_divide_ss.cc \
- gr_integrate_cc.cc \
- gr_integrate_ff.cc \
- gr_integrate_ii.cc \
- gr_integrate_ss.cc \
- gr_max_ff.cc \
- gr_max_ii.cc \
- gr_max_ss.cc \
- gr_moving_average_cc.cc \
- gr_moving_average_ff.cc \
- gr_moving_average_ii.cc \
- gr_moving_average_ss.cc \
- gr_multiply_const_ii.cc \
- gr_multiply_const_ss.cc \
- gr_multiply_const_vcc.cc \
- gr_multiply_const_vff.cc \
- gr_multiply_const_vii.cc \
- gr_multiply_const_vss.cc \
- gr_multiply_ii.cc \
- gr_multiply_ss.cc \
- gr_mute_cc.cc \
- gr_mute_ff.cc \
- gr_mute_ii.cc \
- gr_mute_ss.cc \
- gr_noise_source_c.cc \
- gr_noise_source_f.cc \
- gr_noise_source_i.cc \
- gr_noise_source_s.cc \
- gr_not_bb.cc \
- gr_not_ii.cc \
- gr_not_ss.cc \
- gr_or_bb.cc \
- gr_or_ii.cc \
- gr_or_ss.cc \
- gr_packed_to_unpacked_bb.cc \
- gr_packed_to_unpacked_ii.cc \
- gr_packed_to_unpacked_ss.cc \
- gr_peak_detector_fb.cc \
- gr_peak_detector_ib.cc \
- gr_peak_detector_sb.cc \
- gr_probe_signal_b.cc \
- gr_probe_signal_s.cc \
- gr_probe_signal_i.cc \
- gr_probe_signal_f.cc \
- gr_probe_signal_c.cc \
- gr_probe_signal_vb.cc \
- gr_probe_signal_vs.cc \
- gr_probe_signal_vi.cc \
- gr_probe_signal_vf.cc \
- gr_probe_signal_vc.cc \
- gr_sample_and_hold_bb.cc \
- gr_sample_and_hold_ff.cc \
- gr_sample_and_hold_ii.cc \
- gr_sample_and_hold_ss.cc \
- gr_sig_source_c.cc \
- gr_sig_source_f.cc \
- gr_sig_source_i.cc \
- gr_sig_source_s.cc \
- gr_sub_cc.cc \
- gr_sub_ff.cc \
- gr_sub_ii.cc \
- gr_sub_ss.cc \
- gr_unpacked_to_packed_bb.cc \
- gr_unpacked_to_packed_ii.cc \
- gr_unpacked_to_packed_ss.cc \
- gr_vector_sink_b.cc \
- gr_vector_sink_c.cc \
- gr_vector_sink_f.cc \
- gr_vector_sink_i.cc \
- gr_vector_sink_s.cc \
- gr_vector_source_b.cc \
- gr_vector_source_c.cc \
- gr_vector_source_f.cc \
- gr_vector_source_i.cc \
- gr_vector_source_s.cc \
- gr_xor_bb.cc \
- gr_xor_ii.cc \
- gr_xor_ss.cc
-
diff --git a/gnuradio-core/src/lib/gengen/gr_sig_source_X.cc.t b/gnuradio-core/src/lib/gengen/gr_sig_source_X.cc.t
index bdd0e810a..6959eac82 100644
--- a/gnuradio-core/src/lib/gengen/gr_sig_source_X.cc.t
+++ b/gnuradio-core/src/lib/gengen/gr_sig_source_X.cc.t
@@ -29,6 +29,7 @@
#include <algorithm>
#include <gr_io_signature.h>
#include <stdexcept>
+#include <algorithm>
#include <gr_complex.h>
@@ -64,8 +65,7 @@ int
case GR_CONST_WAVE:
t = (gr_complex) d_ampl + d_offset;
- for (int i = 0; i < noutput_items; i++) // FIXME unroll
- optr[i] = t;
+ std::fill_n(optr, noutput_items, t);
break;
case GR_SIN_WAVE:
@@ -142,8 +142,7 @@ int
case GR_CONST_WAVE:
t = (@TYPE@) d_ampl + d_offset;
- for (int i = 0; i < noutput_items; i++) // FIXME unroll
- optr[i] = t;
+ std::fill_n(optr, noutput_items, t);
break;
case GR_SIN_WAVE:
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..37963cdfe
--- /dev/null
+++ b/gnuradio-core/src/lib/gengen/gr_vector_insert_X.cc.t
@@ -0,0 +1,100 @@
+/* -*- 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.
+ */
+
+// @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..26f851700
--- /dev/null
+++ b/gnuradio-core/src/lib/gengen/gr_vector_insert_X.h.t
@@ -0,0 +1,61 @@
+/* -*- 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.
+ */
+
+// @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..f3341eec4
--- /dev/null
+++ b/gnuradio-core/src/lib/gengen/gr_vector_insert_X.i.t
@@ -0,0 +1,37 @@
+/* -*- 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.
+ */
+
+// @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..fe02c1346 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
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2004,2008 Free Software Foundation, Inc.
+ * Copyright 2004,2008,2012 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -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..4986c68a3 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
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2004,2008 Free Software Foundation, Inc.
+ * Copyright 2004,2008,2012 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -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/lib/io/CMakeLists.txt b/gnuradio-core/src/lib/io/CMakeLists.txt
index af9d7583c..3dea13396 100644
--- a/gnuradio-core/src/lib/io/CMakeLists.txt
+++ b/gnuradio-core/src/lib/io/CMakeLists.txt
@@ -87,6 +87,7 @@ set(gr_core_io_triple_threats
gr_file_descriptor_source
gr_message_sink
gr_message_source
+ gr_message_burst_source
microtune_xxxx_eval_board
microtune_4702_eval_board
microtune_4937_eval_board
diff --git a/gnuradio-core/src/lib/io/gr_message_burst_source.cc b/gnuradio-core/src/lib/io/gr_message_burst_source.cc
new file mode 100644
index 000000000..e9e2dfd4d
--- /dev/null
+++ b/gnuradio-core/src/lib/io/gr_message_burst_source.cc
@@ -0,0 +1,144 @@
+/* -*- 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 <gr_message_burst_source.h>
+#include <gr_io_signature.h>
+#include <cstdio>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <stdexcept>
+#include <string.h>
+#include <gr_tags.h>
+
+// public constructor that returns a shared_ptr
+
+gr_message_burst_source_sptr
+gr_make_message_burst_source(size_t itemsize, int msgq_limit)
+{
+ return gnuradio::get_initial_sptr(new gr_message_burst_source(itemsize, msgq_limit));
+}
+
+// public constructor that takes existing message queue
+gr_message_burst_source_sptr
+gr_make_message_burst_source(size_t itemsize, gr_msg_queue_sptr msgq)
+{
+ return gnuradio::get_initial_sptr(new gr_message_burst_source(itemsize, msgq));
+}
+
+gr_message_burst_source::gr_message_burst_source (size_t itemsize, int msgq_limit)
+ : gr_sync_block("message_burst_source",
+ gr_make_io_signature(0, 0, 0),
+ gr_make_io_signature(1, 1, itemsize)),
+ d_itemsize(itemsize), d_msgq(gr_make_msg_queue(msgq_limit)), d_msg_offset(0), d_eof(false)
+{
+ std::stringstream id;
+ id << name() << unique_id();
+ d_me = pmt::pmt_string_to_symbol(id.str());
+}
+
+gr_message_burst_source::gr_message_burst_source (size_t itemsize, gr_msg_queue_sptr msgq)
+ : gr_sync_block("message_burst_source",
+ gr_make_io_signature(0, 0, 0),
+ gr_make_io_signature(1, 1, itemsize)),
+ d_itemsize(itemsize), d_msgq(msgq), d_msg_offset(0), d_eof(false)
+{
+ std::stringstream id;
+ id << name() << unique_id();
+ d_me = pmt::pmt_string_to_symbol(id.str());
+}
+
+gr_message_burst_source::~gr_message_burst_source()
+{
+}
+
+int
+gr_message_burst_source::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+{
+ char *out = (char *) output_items[0];
+ int nn = 0;
+
+ uint64_t abs_sample_count = nitems_written(0);
+
+ while (nn < noutput_items){
+ if (d_msg){
+ //
+ // Consume whatever we can from the current message
+ //
+
+ int mm = std::min(noutput_items - nn, (int)((d_msg->length() - d_msg_offset) / d_itemsize));
+ memcpy (out, &(d_msg->msg()[d_msg_offset]), mm * d_itemsize);
+
+ nn += mm;
+ out += mm * d_itemsize;
+ d_msg_offset += mm * d_itemsize;
+ assert(d_msg_offset <= d_msg->length());
+
+ if (d_msg_offset == d_msg->length()){
+ if (d_msg->type() == 1) // type == 1 sets EOF
+ d_eof = true;
+ d_msg.reset();
+ //tag end of burst
+ add_item_tag(0, //stream ID
+ abs_sample_count+nn-1, //sample number
+ pmt::pmt_string_to_symbol("tx_eob"),
+ pmt::pmt_from_bool(1),
+ d_me //block src id
+ );
+ }
+ }
+ else {
+ //
+ // No current message
+ //
+ if (d_msgq->empty_p() && nn > 0){ // no more messages in the queue, return what we've got
+ break;
+ }
+
+ if (d_eof)
+ return -1;
+
+ d_msg = d_msgq->delete_head(); // block, waiting for a message
+ d_msg_offset = 0;
+ //tag start of burst
+ add_item_tag(0, //stream ID
+ abs_sample_count+nn, //sample number
+ pmt::pmt_string_to_symbol("tx_sob"),
+ pmt::pmt_from_bool(1),
+ d_me //block src id
+ );
+
+
+ if ((d_msg->length() % d_itemsize) != 0)
+ throw std::runtime_error("msg length is not a multiple of d_itemsize");
+ }
+ }
+
+ return nn;
+}
diff --git a/gnuradio-core/src/lib/io/gr_message_burst_source.h b/gnuradio-core/src/lib/io/gr_message_burst_source.h
new file mode 100644
index 000000000..63e220113
--- /dev/null
+++ b/gnuradio-core/src/lib/io/gr_message_burst_source.h
@@ -0,0 +1,71 @@
+/* -*- 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_GR_MESSAGE_BURST_SOURCE_H
+#define INCLUDED_GR_MESSAGE_BURST_SOURCE_H
+
+#include <gr_core_api.h>
+#include <gr_sync_block.h>
+#include <gr_message.h>
+#include <gr_msg_queue.h>
+
+class gr_message_burst_source;
+typedef boost::shared_ptr<gr_message_burst_source> gr_message_burst_source_sptr;
+
+GR_CORE_API gr_message_burst_source_sptr gr_make_message_burst_source (size_t itemsize, int msgq_limit=0);
+GR_CORE_API gr_message_burst_source_sptr gr_make_message_burst_source (size_t itemsize, gr_msg_queue_sptr msgq);
+
+/*!
+ * \brief Turn received messages into a stream and tag them for UHD to send.
+ * \ingroup source_blk
+ */
+class GR_CORE_API gr_message_burst_source : public gr_sync_block
+{
+ private:
+ size_t d_itemsize;
+ gr_msg_queue_sptr d_msgq;
+ gr_message_sptr d_msg;
+ unsigned d_msg_offset;
+ bool d_eof;
+
+ pmt::pmt_t d_me;
+
+ friend GR_CORE_API gr_message_burst_source_sptr
+ gr_make_message_burst_source(size_t itemsize, int msgq_limit);
+ friend GR_CORE_API gr_message_burst_source_sptr
+ gr_make_message_burst_source(size_t itemsize, gr_msg_queue_sptr msgq);
+
+ protected:
+ gr_message_burst_source (size_t itemsize, int msgq_limit);
+ gr_message_burst_source (size_t itemsize, gr_msg_queue_sptr msgq);
+
+ public:
+ ~gr_message_burst_source ();
+
+ gr_msg_queue_sptr msgq() const { return d_msgq; }
+
+ int work (int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+};
+
+#endif /* INCLUDED_gr_message_burst_source_H */
diff --git a/gnuradio-core/src/lib/io/gr_message_burst_source.i b/gnuradio-core/src/lib/io/gr_message_burst_source.i
new file mode 100644
index 000000000..f7ad840c2
--- /dev/null
+++ b/gnuradio-core/src/lib/io/gr_message_burst_source.i
@@ -0,0 +1,38 @@
+/* -*- 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.
+ */
+
+GR_SWIG_BLOCK_MAGIC(gr,message_burst_source);
+
+gr_message_burst_source_sptr gr_make_message_burst_source (size_t itemsize, int msgq_limit=0);
+gr_message_burst_source_sptr gr_make_message_burst_source (size_t itemsize, gr_msg_queue_sptr msgq);
+
+class gr_message_burst_source : public gr_sync_block
+{
+ protected:
+ gr_message_burst_source (size_t itemsize, int msgq_limit);
+ gr_message_burst_source (size_t itemsize, gr_msg_queue_sptr msgq);
+
+ public:
+ ~gr_message_burst_source ();
+
+ gr_msg_queue_sptr msgq() const;
+};
diff --git a/gnuradio-core/src/lib/io/gr_tagged_file_sink.cc b/gnuradio-core/src/lib/io/gr_tagged_file_sink.cc
index d69892762..6d642088e 100644
--- a/gnuradio-core/src/lib/io/gr_tagged_file_sink.cc
+++ b/gnuradio-core/src/lib/io/gr_tagged_file_sink.cc
@@ -143,7 +143,7 @@ gr_tagged_file_sink::work (int noutput_items,
std::stringstream filename;
filename.setf(std::ios::fixed, std::ios::floatfield);
filename.precision(8);
- filename << "file" << d_n << "_" << d_timeval << ".dat";
+ filename << "file" << unique_id() << "_" << d_n << "_" << d_timeval << ".dat";
d_n++;
int fd;
diff --git a/gnuradio-core/src/lib/io/gr_udp_source.cc b/gnuradio-core/src/lib/io/gr_udp_source.cc
index af41159ee..eca8e89d0 100644
--- a/gnuradio-core/src/lib/io/gr_udp_source.cc
+++ b/gnuradio-core/src/lib/io/gr_udp_source.cc
@@ -269,8 +269,9 @@ gr_udp_source::work (int noutput_items,
else if(r == 0 ) { // timed out
if( d_wait ) {
// Allow boost thread interrupt, then try again
- boost::this_thread::interruption_point();
- continue;
+ //boost::this_thread::interruption_point();
+ //continue;
+ return 0;
}
else
return -1;
@@ -294,8 +295,9 @@ gr_udp_source::work (int noutput_items,
if( d_wait ) {
// Allow boost thread interrupt, then try again
- boost::this_thread::interruption_point();
- continue;
+ //boost::this_thread::interruption_point();
+ //continue;
+ return 0;
}
else
return -1;
diff --git a/gnuradio-core/src/lib/io/gri_wavfile.cc b/gnuradio-core/src/lib/io/gri_wavfile.cc
index e316a0825..277e6b7b0 100644
--- a/gnuradio-core/src/lib/io/gri_wavfile.cc
+++ b/gnuradio-core/src/lib/io/gri_wavfile.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2004,2008 Free Software Foundation, Inc.
+ * Copyright 2004,2008,2012 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -27,110 +27,45 @@
#include <gri_wavfile.h>
#include <cstring>
#include <stdint.h>
+#include <boost/detail/endian.hpp> //BOOST_BIG_ENDIAN
# define VALID_COMPRESSION_TYPE 0x0001
-// WAV files are always little-endian, so we need some byte switching macros
-
-// FIXME: Use libgruel versions
-
-#ifdef WORDS_BIGENDIAN
-
-#ifdef HAVE_BYTESWAP_H
-#include <byteswap.h>
-#else
-#warning Using non-portable code (likely wrong other than ILP32).
-
-static inline short int
-bswap_16 (unsigned short int x)
-{
- return ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8));
-}
-
-static inline unsigned int
-bswap_32 (unsigned int x)
-{
- return ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) \
- | (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24));
-}
-#endif // HAVE_BYTESWAP_H
-
-static inline uint32_t
-host_to_wav(uint32_t x)
-{
- return bswap_32(x);
-}
-
-static inline uint16_t
-host_to_wav(uint16_t x)
-{
- return bswap_16(x);
-}
-
-static inline int16_t
-host_to_wav(int16_t x)
-{
- return bswap_16(x);
-}
+// Basically, this is the opposite of htonx() and ntohx()
+// Define host to/from worknet (little endian) short and long
+#ifdef BOOST_BIG_ENDIAN
-static inline uint32_t
-wav_to_host(uint32_t x)
-{
- return bswap_32(x);
-}
+ static inline uint16_t __gri_wav_bs16(uint16_t x)
+ {
+ return (x>>8) | (x<<8);
+ }
-static inline uint16_t
-wav_to_host(uint16_t x)
-{
- return bswap_16(x);
-}
+ static inline uint32_t __gri_wav_bs32(uint32_t x)
+ {
+ return (uint32_t(__gri_wav_bs16(uint16_t(x&0xfffful)))<<16) | (__gri_wav_bs16(uint16_t(x>>16)));
+ }
-static inline int16_t
-wav_to_host(int16_t x)
-{
- return bswap_16(x);
-}
+ #define htowl(x) __gri_wav_bs32(x)
+ #define wtohl(x) __gri_wav_bs32(x)
+ #define htows(x) __gri_wav_bs16(x)
+ #define wtohs(x) __gri_wav_bs16(x)
#else
-static inline uint32_t
-host_to_wav(uint32_t x)
-{
- return x;
-}
-
-static inline uint16_t
-host_to_wav(uint16_t x)
-{
- return x;
-}
-
-static inline int16_t
-host_to_wav(int16_t x)
-{
- return x;
-}
-
-static inline uint32_t
-wav_to_host(uint32_t x)
-{
- return x;
-}
-
-static inline uint16_t
-wav_to_host(uint16_t x)
-{
- return x;
-}
-
-static inline int16_t
-wav_to_host(int16_t x)
-{
- return x;
-}
+ #define htowl(x) uint32_t(x)
+ #define wtohl(x) uint32_t(x)
+ #define htows(x) uint16_t(x)
+ #define wtohs(x) uint16_t(x)
-#endif // WORDS_BIGENDIAN
+#endif // BOOST_BIG_ENDIAN
+// WAV files are always little-endian, so we need some byte switching macros
+static inline uint32_t host_to_wav(uint32_t x) { return htowl(x); }
+static inline uint16_t host_to_wav(uint16_t x) { return htows(x); }
+static inline int16_t host_to_wav(int16_t x) { return htows(x); }
+static inline uint32_t wav_to_host(uint32_t x) { return wtohl(x); }
+static inline uint16_t wav_to_host(uint16_t x) { return wtohs(x); }
+static inline int16_t wav_to_host(int16_t x) { return wtohs(x); }
bool
gri_wavheader_parse(FILE *fp,
@@ -225,12 +160,15 @@ gri_wavheader_parse(FILE *fp,
short int
gri_wav_read_sample(FILE *fp, int bytes_per_sample)
{
- int16_t buf = 0;
- size_t fresult;
+ int16_t buf_16bit;
- fresult = fread(&buf, bytes_per_sample, 1, fp);
-
- return (short) wav_to_host(buf);
+ if(!fread(&buf_16bit, bytes_per_sample, 1, fp)) {
+ return 0;
+ }
+ if(bytes_per_sample == 1) {
+ return (short) buf_16bit;
+ }
+ return (short)wav_to_host(buf_16bit);
}
diff --git a/gnuradio-core/src/lib/io/gri_wavfile.h b/gnuradio-core/src/lib/io/gri_wavfile.h
index c757be26b..16280e34a 100644
--- a/gnuradio-core/src/lib/io/gri_wavfile.h
+++ b/gnuradio-core/src/lib/io/gri_wavfile.h
@@ -29,20 +29,15 @@
/*!
* \brief Read signal information from a given WAV file.
*
- * \p fp File pointer to an opened, empty file.
- * \p sample_rate Stores the sample rate [S/s]
- * \p nchans Number of channels
- * \p bytes_per_sample Bytes per sample, can either be 1 or 2 (corresponding to
- * 8 or 16 bit samples, respectively)
- * \p first_sample_pos Number of the first byte containing a sample. Use this
- * with fseek() to jump from the end of the file to the first sample
- * when in repeat mode.
- * \p samples_per_chan Number of samples per channel
- * \p normalize_fac The normalization factor with which you need to divide the
- * integer values of the samples to get them within [-1;1]
- * \p normalize_shift The value by which the sample values need to be shifted
- * after normalization (reason being, 8-bit WAV files store samples as
- * unsigned char and 16-bit as signed short int)
+ * \param[in] fp File pointer to an opened, empty file.
+ * \param[out] sample_rate Stores the sample rate [S/s]
+ * \param[out] nchans Number of channels
+ * \param[out] bytes_per_sample Bytes per sample, can either be 1 or 2 (corresponding o
+ * 8 or 16 bit samples, respectively)
+ * \param[out] first_sample_pos Number of the first byte containing a sample. Use this
+ * with fseek() to jump from the end of the file to the
+ * first sample when in repeat mode.
+ * \param[out] samples_per_chan Number of samples per channel
* \return True on a successful read, false if the file could not be read or is
* not a valid WAV file.
*/
@@ -94,8 +89,8 @@ gri_wav_write_sample(FILE *fp, short int sample, int bytes_per_sample);
* shouldn't happen), you need to fseek() to the end of the file (or
* whereever).
*
- * \p fp File pointer to an open WAV file with a blank header
- * \p byte_count Length of all samples written to the file in bytes.
+ * \param[in] fp File pointer to an open WAV file with a blank header
+ * \param[in] byte_count Length of all samples written to the file in bytes.
*/
bool
gri_wavheader_complete(FILE *fp, unsigned int byte_count);
diff --git a/gnuradio-core/src/lib/io/io.i b/gnuradio-core/src/lib/io/io.i
index eab1346f1..5cd352905 100644
--- a/gnuradio-core/src/lib/io/io.i
+++ b/gnuradio-core/src/lib/io/io.i
@@ -38,6 +38,7 @@
#include <gr_oscope_sink_f.h>
#include <ppio.h>
#include <gr_message_source.h>
+#include <gr_message_burst_source.h>
#include <gr_message_sink.h>
#include <gr_udp_sink.h>
#include <gr_udp_source.h>
@@ -59,6 +60,7 @@
%include "gr_oscope_sink.i"
%include "ppio.i"
%include "gr_message_source.i"
+%include "gr_message_burst_source.i"
%include "gr_message_sink.i"
%include "gr_udp_sink.i"
%include "gr_udp_source.i"
diff --git a/gnuradio-core/src/lib/runtime/CMakeLists.txt b/gnuradio-core/src/lib/runtime/CMakeLists.txt
index 1415ff4c6..5f3672dde 100644
--- a/gnuradio-core/src/lib/runtime/CMakeLists.txt
+++ b/gnuradio-core/src/lib/runtime/CMakeLists.txt
@@ -22,6 +22,29 @@
########################################################################
########################################################################
+# Control availability of vmcircbuf methods.
+# For now, only allows disabling of shm methods, which cause uncatchable
+# segmentation faults on Cygwin with gcc 4.x (x <= 5)
+# Usage:
+# GR_VMCIRCBUF()
+#
+# Will set TRY_SHM_VMCIRCBUF to 1 by default except on Windows machines.
+# Can manually set with -DTRY_SHM_VMCIRCBUF=0|1
+########################################################################
+
+ if(WIN32)
+ OPTION(TRY_SHM_VMCIRCBUF "Try SHM VMCIRCBUF" OFF)
+ else(WIN32)
+ OPTION(TRY_SHM_VMCIRCBUF "Try SHM VMCIRCBUF" ON)
+ endif(WIN32)
+
+ message(STATUS "TRY_SHM_VMCIRCBUF set to ${TRY_SHM_VMCIRCBUF}.")
+
+ if(TRY_SHM_VMCIRCBUF)
+ add_definitions( -DTRY_SHM_VMCIRCBUF )
+ endif(TRY_SHM_VMCIRCBUF)
+
+########################################################################
# Append gnuradio-core library sources
########################################################################
list(APPEND gnuradio_core_sources
diff --git a/gnuradio-core/src/lib/runtime/gr_basic_block.cc b/gnuradio-core/src/lib/runtime/gr_basic_block.cc
index d7263b92d..3d809aa8b 100644
--- a/gnuradio-core/src/lib/runtime/gr_basic_block.cc
+++ b/gnuradio-core/src/lib/runtime/gr_basic_block.cc
@@ -45,7 +45,9 @@ gr_basic_block::gr_basic_block(const std::string &name,
d_input_signature(input_signature),
d_output_signature(output_signature),
d_unique_id(s_next_id++),
- d_color(WHITE)
+ d_color(WHITE),
+ d_max_output_buffer(std::max(output_signature->max_streams(),1), -1),
+ d_min_output_buffer(std::max(output_signature->max_streams(),1), -1)
{
s_ncurrently_allocated++;
}
diff --git a/gnuradio-core/src/lib/runtime/gr_basic_block.h b/gnuradio-core/src/lib/runtime/gr_basic_block.h
index 4d03b878e..4d16014dd 100644
--- a/gnuradio-core/src/lib/runtime/gr_basic_block.h
+++ b/gnuradio-core/src/lib/runtime/gr_basic_block.h
@@ -29,7 +29,9 @@
#include <boost/enable_shared_from_this.hpp>
#include <boost/function.hpp>
#include <gr_msg_accepter.h>
+#include <gr_io_signature.h>
#include <string>
+#include <iostream>
/*!
* \brief The abstract base class for all signal processing blocks.
@@ -73,6 +75,8 @@ protected:
gr_io_signature_sptr d_output_signature;
long d_unique_id;
vcolor d_color;
+ std::vector<long> d_max_output_buffer;
+ std::vector<long> d_min_output_buffer;
gr_basic_block(void){} //allows pure virtual interface sub-classes
@@ -104,7 +108,21 @@ public:
gr_io_signature_sptr input_signature() const { return d_input_signature; }
gr_io_signature_sptr output_signature() const { return d_output_signature; }
gr_basic_block_sptr to_basic_block(); // Needed for Python type coercion
-
+ long max_output_buffer(size_t i){ return d_max_output_buffer.size()>i?d_max_output_buffer[i]:d_max_output_buffer[0]; }
+ void set_max_output_buffer(long max_output_buffer){
+ for(int i=0; i<output_signature()->max_streams(); i++){
+ set_max_output_buffer(max_output_buffer, i);
+ }
+ }
+ void set_max_output_buffer(long max_output_buffer, int port){ d_max_output_buffer[port] = max_output_buffer; }
+ long min_output_buffer(size_t i){ return d_min_output_buffer.size()>i?d_min_output_buffer[i]:d_min_output_buffer[0]; }
+ void set_min_output_buffer(long min_output_buffer){
+ for(int i=0; i<output_signature()->max_streams(); i++){
+ set_min_output_buffer(min_output_buffer, i);
+ }
+ }
+ void set_min_output_buffer(long min_output_buffer, int port){ d_min_output_buffer[port] = min_output_buffer; }
+
/*!
* \brief Confirm that ninputs and noutputs is an acceptable combination.
*
diff --git a/gnuradio-core/src/lib/runtime/gr_basic_block.i b/gnuradio-core/src/lib/runtime/gr_basic_block.i
index e43cc114c..848017dd8 100644
--- a/gnuradio-core/src/lib/runtime/gr_basic_block.i
+++ b/gnuradio-core/src/lib/runtime/gr_basic_block.i
@@ -42,6 +42,12 @@ public:
long unique_id() const;
gr_basic_block_sptr to_basic_block();
bool check_topology (int ninputs, int noutputs);
+ long max_output_buffer(int i);
+ void set_max_output_buffer(long max_output_buffer);
+ void set_max_output_buffer(long max_output_buffer, int port);
+ long min_output_buffer(int i);
+ void set_min_output_buffer(long min_output_buffer);
+ void set_min_output_buffer(long min_output_buffer, int port);
};
%rename(block_ncurrently_allocated) gr_basic_block_ncurrently_allocated;
diff --git a/gnuradio-core/src/lib/runtime/gr_block_executor.cc b/gnuradio-core/src/lib/runtime/gr_block_executor.cc
index 5b24e9f6e..375b58f56 100644
--- a/gnuradio-core/src/lib/runtime/gr_block_executor.cc
+++ b/gnuradio-core/src/lib/runtime/gr_block_executor.cc
@@ -449,6 +449,7 @@ gr_block_executor::run_one_iteration()
// We didn't produce any output even though we called general_work.
// We have (most likely) consumed some input.
+ /*
// If this is a source, it's broken.
if (d->source_p()){
std::cerr << "gr_block_executor: source " << m
@@ -456,6 +457,7 @@ gr_block_executor::run_one_iteration()
// FIXME maybe we ought to raise an exception...
goto were_done;
}
+ */
// Have the caller try again...
return READY_NO_OUTPUT;
diff --git a/gnuradio-core/src/lib/runtime/gr_flat_flowgraph.cc b/gnuradio-core/src/lib/runtime/gr_flat_flowgraph.cc
index 030e2d97d..fb375b0f3 100644
--- a/gnuradio-core/src/lib/runtime/gr_flat_flowgraph.cc
+++ b/gnuradio-core/src/lib/runtime/gr_flat_flowgraph.cc
@@ -114,6 +114,21 @@ gr_flat_flowgraph::allocate_buffer(gr_basic_block_sptr block, int port)
// ensure we have a buffer at least twice their decimation factor*output_multiple
gr_basic_block_vector_t blocks = calc_downstream_blocks(block, port);
+
+ // limit buffer size if indicated
+ if(block->max_output_buffer(port) > 0){
+// std::cout << "constraining output items to " << block->max_output_buffer(port) << "\n";
+ nitems = std::min((long)nitems, (long)block->max_output_buffer(port));
+ nitems -= nitems%grblock->output_multiple();
+ if( nitems < 1 )
+ throw std::runtime_error("problems allocating a buffer with the given max output buffer constraint!");
+ } else if(block->min_output_buffer(port) > 0){
+ nitems = std::max((long)nitems, (long)block->min_output_buffer(port));
+ nitems -= nitems%grblock->output_multiple();
+ if( nitems < 1 )
+ throw std::runtime_error("problems allocating a buffer with the given min output buffer constraint!");
+ }
+
for (gr_basic_block_viter_t p = blocks.begin(); p != blocks.end(); p++) {
gr_block_sptr dgrblock = cast_to_block_sptr(*p);
if (!dgrblock)
@@ -125,6 +140,7 @@ gr_flat_flowgraph::allocate_buffer(gr_basic_block_sptr block, int port)
nitems = std::max(nitems, static_cast<int>(2*(decimation*multiple+history)));
}
+// std::cout << "gr_make_buffer(" << nitems << ", " << item_size << ", " << grblock << "\n";
return gr_make_buffer(nitems, item_size, grblock);
}
diff --git a/gnuradio-core/src/lib/runtime/gr_top_block.i b/gnuradio-core/src/lib/runtime/gr_top_block.i
index 80a1b82ae..6ae4c65a9 100644
--- a/gnuradio-core/src/lib/runtime/gr_top_block.i
+++ b/gnuradio-core/src/lib/runtime/gr_top_block.i
@@ -20,8 +20,6 @@
* Boston, MA 02110-1301, USA.
*/
-%include <gr_top_block.i>
-
class gr_top_block;
typedef boost::shared_ptr<gr_top_block> gr_top_block_sptr;
%template(gr_top_block_sptr) boost::shared_ptr<gr_top_block>;
diff --git a/gnuradio-core/src/lib/swig/CMakeLists.txt b/gnuradio-core/src/lib/swig/CMakeLists.txt
index d3c381b4b..5b740d916 100644
--- a/gnuradio-core/src/lib/swig/CMakeLists.txt
+++ b/gnuradio-core/src/lib/swig/CMakeLists.txt
@@ -43,7 +43,7 @@ set(GR_SWIG_LIBRARIES gnuradio-core)
# X86_64, g++'s resident set size was 650MB!
# ----------------------------------------------------------------
-set(GR_SWIG_TARGET_DEPS gengen_generated filter_generated)
+set(GR_SWIG_TARGET_DEPS general_generated gengen_generated filter_generated pmt_swig)
foreach(what runtime general gengen filter io hier)
SET(GR_SWIG_DOC_FILE ${CMAKE_CURRENT_BINARY_DIR}/${what}_swig_doc.i)
@@ -61,8 +61,11 @@ foreach(what runtime general gengen filter io hier)
DESTINATION ${GR_INCLUDE_DIR}/gnuradio/swig
COMPONENT "core_swig"
)
+ list(APPEND core_swig_deps ${SWIG_MODULE_gnuradio_core_${what}_REAL_NAME})
endforeach(what)
+add_custom_target(core_swig DEPENDS ${core_swig_deps})
+
########################################################################
# Install various files
########################################################################
diff --git a/gnuradio-core/src/lib/swig/gnuradio.i b/gnuradio-core/src/lib/swig/gnuradio.i
index 239223851..3a421ad5d 100644
--- a/gnuradio-core/src/lib/swig/gnuradio.i
+++ b/gnuradio-core/src/lib/swig/gnuradio.i
@@ -20,6 +20,9 @@
* Boston, MA 02110-1301, USA.
*/
+// Disable warning about base class types
+#pragma SWIG nowarn=401
+
////////////////////////////////////////////////////////////////////////
// gnuradio.i
// SWIG interface definition
diff --git a/gnuradio-core/src/lib/swig/gr_swig_block_magic.i b/gnuradio-core/src/lib/swig/gr_swig_block_magic.i
index cdc9fbe49..4016ae772 100644
--- a/gnuradio-core/src/lib/swig/gr_swig_block_magic.i
+++ b/gnuradio-core/src/lib/swig/gr_swig_block_magic.i
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2004,2010 Free Software Foundation, Inc.
+ * Copyright 2004,2010,2012 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -40,3 +40,11 @@ FULL_NAME ## _sptr.__repr__ = lambda self: "<gr_block %s (%d)>" % (self.name(),
%}
%enddef
#endif
+
+%define GR_SWIG_BLOCK_MAGIC2(PKG, BASE_NAME)
+%template(BASE_NAME ## _sptr) boost::shared_ptr<gr:: ## PKG ## :: ## BASE_NAME>;
+%pythoncode %{
+BASE_NAME ## _sptr.__repr__ = lambda self: "<gr_block %s (%d)>" % (self.name(), self.unique_id())
+BASE_NAME = BASE_NAME.make;
+%}
+%enddef