summaryrefslogtreecommitdiff
path: root/gnuradio-core/src/lib/general
diff options
context:
space:
mode:
authorTom Rondeau2011-06-05 15:36:47 -0400
committerTom Rondeau2011-06-05 15:36:47 -0400
commit233f960474f86bc8cc519ce7257b29d8615c4000 (patch)
tree1a4c846119a01a5a195a9e9ee5b854384b0b6535 /gnuradio-core/src/lib/general
parent024c79a7fb13c08bae7b97079a245f711ecf12a7 (diff)
parenta23a0a46c3bf446cbe09d71bc8e10b061256ef56 (diff)
downloadgnuradio-233f960474f86bc8cc519ce7257b29d8615c4000.tar.gz
gnuradio-233f960474f86bc8cc519ce7257b29d8615c4000.tar.bz2
gnuradio-233f960474f86bc8cc519ce7257b29d8615c4000.zip
Merge branch 'master' into turbo
Diffstat (limited to 'gnuradio-core/src/lib/general')
-rw-r--r--gnuradio-core/src/lib/general/Makefile.am30
-rw-r--r--gnuradio-core/src/lib/general/complex_vec_test.cc82
-rw-r--r--gnuradio-core/src/lib/general/complex_vec_test.h27
-rw-r--r--gnuradio-core/src/lib/general/complex_vec_test.i25
-rw-r--r--gnuradio-core/src/lib/general/general.i14
-rw-r--r--gnuradio-core/src/lib/general/gr_align_on_samplenumbers_ss.i3
-rw-r--r--gnuradio-core/src/lib/general/gr_annotator_1to1.cc107
-rw-r--r--gnuradio-core/src/lib/general/gr_annotator_1to1.h74
-rw-r--r--gnuradio-core/src/lib/general/gr_annotator_1to1.i36
-rw-r--r--gnuradio-core/src/lib/general/gr_annotator_alltoall.cc110
-rw-r--r--gnuradio-core/src/lib/general/gr_annotator_alltoall.h75
-rw-r--r--gnuradio-core/src/lib/general/gr_annotator_alltoall.i36
-rw-r--r--gnuradio-core/src/lib/general/gr_bin_statistics_f.i7
-rw-r--r--gnuradio-core/src/lib/general/gr_burst_tagger.cc83
-rw-r--r--gnuradio-core/src/lib/general/gr_burst_tagger.h56
-rw-r--r--gnuradio-core/src/lib/general/gr_burst_tagger.i31
-rw-r--r--gnuradio-core/src/lib/general/gr_clock_recovery_mm_cc.cc6
-rw-r--r--gnuradio-core/src/lib/general/gr_clock_recovery_mm_cc.i7
-rw-r--r--gnuradio-core/src/lib/general/gr_clock_recovery_mm_ff.i7
-rw-r--r--gnuradio-core/src/lib/general/gr_decode_ccsds_27_fb.cc2
-rw-r--r--gnuradio-core/src/lib/general/gr_feval.i7
-rw-r--r--gnuradio-core/src/lib/general/gr_fft_vcc.i4
-rw-r--r--gnuradio-core/src/lib/general/gr_fft_vfc.cc6
-rw-r--r--gnuradio-core/src/lib/general/gr_fft_vfc.h10
-rw-r--r--gnuradio-core/src/lib/general/gr_fft_vfc.i9
-rw-r--r--gnuradio-core/src/lib/general/gr_firdes.cc2
-rw-r--r--gnuradio-core/src/lib/general/gr_frequency_modulator_fc.cc5
-rw-r--r--gnuradio-core/src/lib/general/gr_frequency_modulator_fc.h4
-rw-r--r--gnuradio-core/src/lib/general/gr_frequency_modulator_fc.i3
-rw-r--r--gnuradio-core/src/lib/general/gr_fxpt.cc5
-rw-r--r--gnuradio-core/src/lib/general/gr_fxpt.h4
-rw-r--r--gnuradio-core/src/lib/general/gr_int_to_float.cc59
-rw-r--r--gnuradio-core/src/lib/general/gr_int_to_float.h51
-rw-r--r--gnuradio-core/src/lib/general/gr_int_to_float.i30
-rw-r--r--gnuradio-core/src/lib/general/gr_keep_one_in_n.cc5
-rw-r--r--gnuradio-core/src/lib/general/gr_math.cc102
-rw-r--r--gnuradio-core/src/lib/general/gr_math.h13
-rw-r--r--gnuradio-core/src/lib/general/gr_mpsk_receiver_cc.h3
-rw-r--r--gnuradio-core/src/lib/general/gr_nop.cc24
-rw-r--r--gnuradio-core/src/lib/general/gr_nop.h23
-rw-r--r--gnuradio-core/src/lib/general/gr_nop.i11
-rw-r--r--gnuradio-core/src/lib/general/gr_null_sink.cc2
-rw-r--r--gnuradio-core/src/lib/general/gr_null_sink.h16
-rw-r--r--gnuradio-core/src/lib/general/gr_null_sink.i11
-rw-r--r--gnuradio-core/src/lib/general/gr_null_source.cc2
-rw-r--r--gnuradio-core/src/lib/general/gr_null_source.h14
-rw-r--r--gnuradio-core/src/lib/general/gr_null_source.i11
-rw-r--r--gnuradio-core/src/lib/general/gr_ofdm_frame_sink.cc2
-rw-r--r--gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.cc2
-rw-r--r--gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.i2
-rw-r--r--gnuradio-core/src/lib/general/gr_throttle.cc136
-rw-r--r--gnuradio-core/src/lib/general/gr_throttle.h33
-rw-r--r--gnuradio-core/src/lib/general/gr_throttle.i13
-rw-r--r--gnuradio-core/src/lib/general/gr_unpack_k_bits_bb.i2
-rw-r--r--gnuradio-core/src/lib/general/gri_fft.cc28
-rw-r--r--gnuradio-core/src/lib/general/qa_gr_fxpt_vco.cc4
56 files changed, 1131 insertions, 345 deletions
diff --git a/gnuradio-core/src/lib/general/Makefile.am b/gnuradio-core/src/lib/general/Makefile.am
index 3d8a42805..2a7a4b025 100644
--- a/gnuradio-core/src/lib/general/Makefile.am
+++ b/gnuradio-core/src/lib/general/Makefile.am
@@ -21,7 +21,9 @@
include $(top_srcdir)/Makefile.common
-AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) $(CPPUNIT_INCLUDES) $(WITH_INCLUDES)
+# $(WITH_INCLUDES) must _always_ be last
+AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) $(CPPUNIT_INCLUDES) \
+ $(FFTW3F_CPPFLAGS) $(GSL_CPPFLAGS) $(WITH_INCLUDES)
noinst_LTLIBRARIES = libgeneral.la libgeneral-qa.la
@@ -29,11 +31,12 @@ BUILT_SOURCES =
# ----------------------------------------------------------------
-EXTRA_DIST = \
+EXTRA_DIST += \
gen_sine_table.py \
gr_constants.cc.in
libgeneral_la_SOURCES = \
+ complex_vec_test.cc \
gr_additive_scrambler_bb.cc \
gr_agc_cc.cc \
gr_agc_ff.cc \
@@ -97,7 +100,6 @@ libgeneral_la_SOURCES = \
gr_lms_dfe_cc.cc \
gr_lms_dfe_ff.cc \
gr_map_bb.cc \
- gr_math.cc \
gr_misc.cc \
gr_mpsk_receiver_cc.cc \
gr_nlog10_ff.cc \
@@ -137,6 +139,7 @@ libgeneral_la_SOURCES = \
gr_rms_cf.cc \
gr_rms_ff.cc \
gr_short_to_float.cc \
+ gr_int_to_float.cc \
gr_simple_correlator.cc \
gr_simple_framer.cc \
gr_simple_squelch_cc.cc \
@@ -175,7 +178,10 @@ libgeneral_la_SOURCES = \
gr_descrambler_bb.cc \
gr_scrambler_bb.cc \
gr_probe_mpsk_snr_c.cc \
- gr_probe_density_b.cc
+ gr_probe_density_b.cc \
+ gr_annotator_alltoall.cc \
+ gr_annotator_1to1.cc \
+ gr_burst_tagger.cc
libgeneral_qa_la_SOURCES = \
qa_general.cc \
@@ -188,6 +194,7 @@ libgeneral_qa_la_SOURCES = \
qa_gri_lfsr.cc
grinclude_HEADERS = \
+ complex_vec_test.h \
gr_additive_scrambler_bb.h \
gr_agc_cc.h \
gr_agc_ff.h \
@@ -295,6 +302,7 @@ grinclude_HEADERS = \
gr_rms_cf.h \
gr_rms_ff.h \
gr_short_to_float.h \
+ gr_int_to_float.h \
gr_simple_correlator.h \
gr_simple_framer.h \
gr_simple_framer_sync.h \
@@ -344,7 +352,10 @@ grinclude_HEADERS = \
gr_descrambler_bb.h \
gr_scrambler_bb.h \
gr_probe_mpsk_snr_c.h \
- gr_probe_density_b.h
+ gr_probe_density_b.h \
+ gr_annotator_alltoall.h \
+ gr_annotator_1to1.h \
+ gr_burst_tagger.h
noinst_HEADERS = \
qa_general.h \
@@ -357,8 +368,8 @@ noinst_HEADERS = \
sine_table.h \
qa_gr_math.h
-if PYTHON
swiginclude_HEADERS = \
+ complex_vec_test.i \
general.i \
gr_additive_scrambler_bb.i \
gr_agc_cc.i \
@@ -409,6 +420,7 @@ swiginclude_HEADERS = \
gr_glfsr_source_b.i \
gr_glfsr_source_f.i \
gr_head.i \
+ gr_int_to_float.i \
gr_interleave.i \
gr_interleaved_short_to_complex.i \
gr_iqcomp_cc.i \
@@ -484,5 +496,7 @@ swiginclude_HEADERS = \
gr_descrambler_bb.i \
gr_scrambler_bb.i \
gr_probe_mpsk_snr_c.i \
- gr_probe_density_b.i
-endif
+ gr_probe_density_b.i \
+ gr_annotator_alltoall.i \
+ gr_annotator_1to1.i \
+ gr_burst_tagger.i
diff --git a/gnuradio-core/src/lib/general/complex_vec_test.cc b/gnuradio-core/src/lib/general/complex_vec_test.cc
new file mode 100644
index 000000000..df25c325e
--- /dev/null
+++ b/gnuradio-core/src/lib/general/complex_vec_test.cc
@@ -0,0 +1,82 @@
+#include <complex_vec_test.h>
+#include <stddef.h>
+
+std::vector<std::complex<float> >
+complex_vec_test0()
+{
+ std::vector<std::complex<float> > r(5);
+
+ for (size_t i = 0; i < r.size(); i++)
+ r[i] = std::complex<float>(i, i);
+
+ return r;
+}
+
+std::vector<std::complex<float> >
+complex_vec_test1(const std::vector<std::complex<float> > &input)
+{
+ std::vector<std::complex<float> > r(input.size());
+
+ for (size_t i = 0; i < input.size(); i++)
+ r[i] = std::complex<float>(input[i].real()+0.5, input[i].imag()-0.5);
+
+ return r;
+}
+
+std::complex<float>
+complex_scalar_test0()
+{
+ return std::complex<float>(5, 5);
+}
+
+std::complex<float>
+complex_scalar_test1(std::complex<float> input)
+{
+ return std::complex<float>(input.real()+0.5, input.imag()-0.5);
+}
+
+
+std::vector<float>
+float_vec_test0()
+{
+ std::vector<float> r(5);
+
+ for (size_t i = 0; i < r.size(); i++)
+ r[i] = (float) i;
+
+ return r;
+}
+
+std::vector<float>
+float_vec_test1(const std::vector<float> &input)
+{
+ std::vector<float> r(input.size());
+
+ for (size_t i = 0; i < input.size(); i++)
+ r[i] = input[i] + 0.5;
+
+ return r;
+}
+
+std::vector<int>
+int_vec_test0()
+{
+ std::vector<int> r(5);
+
+ for (size_t i = 0; i < r.size(); i++)
+ r[i] = (int) i;
+
+ return r;
+}
+
+std::vector<int>
+int_vec_test1(const std::vector<int> &input)
+{
+ std::vector<int> r(input.size());
+
+ for (size_t i = 0; i < input.size(); i++)
+ r[i] = input[i] + 1;
+
+ return r;
+}
+
diff --git a/gnuradio-core/src/lib/general/complex_vec_test.h b/gnuradio-core/src/lib/general/complex_vec_test.h
new file mode 100644
index 000000000..d13dedf63
--- /dev/null
+++ b/gnuradio-core/src/lib/general/complex_vec_test.h
@@ -0,0 +1,27 @@
+#include <vector>
+#include <complex>
+
+std::vector<std::complex<float> >
+complex_vec_test0();
+
+std::vector<std::complex<float> >
+complex_vec_test1(const std::vector<std::complex<float> > &input);
+
+std::complex<float>
+complex_scalar_test0();
+
+std::complex<float>
+complex_scalar_test1(std::complex<float> input);
+
+std::vector<int>
+int_vec_test0();
+
+std::vector<int>
+int_vec_test1(const std::vector<int> &input);
+
+std::vector<float>
+float_vec_test0();
+
+std::vector<float>
+float_vec_test1(const std::vector<float> &input);
+
diff --git a/gnuradio-core/src/lib/general/complex_vec_test.i b/gnuradio-core/src/lib/general/complex_vec_test.i
new file mode 100644
index 000000000..4b95633be
--- /dev/null
+++ b/gnuradio-core/src/lib/general/complex_vec_test.i
@@ -0,0 +1,25 @@
+
+std::vector<std::complex<float> >
+complex_vec_test0();
+
+std::vector<std::complex<float> >
+complex_vec_test1(const std::vector<std::complex<float> > &input);
+
+std::complex<float>
+complex_scalar_test0();
+
+std::complex<float>
+complex_scalar_test1(std::complex<float> input);
+
+std::vector<int>
+int_vec_test0();
+
+std::vector<int>
+int_vec_test1(const std::vector<int> &input);
+
+std::vector<float>
+float_vec_test0();
+
+std::vector<float>
+float_vec_test1(const std::vector<float> &input);
+
diff --git a/gnuradio-core/src/lib/general/general.i b/gnuradio-core/src/lib/general/general.i
index 68cafce2e..e8a18ab19 100644
--- a/gnuradio-core/src/lib/general/general.i
+++ b/gnuradio-core/src/lib/general/general.i
@@ -42,6 +42,7 @@
#include <gr_float_to_char.h>
#include <gr_float_to_uchar.h>
#include <gr_short_to_float.h>
+#include <gr_int_to_float.h>
#include <gr_char_to_float.h>
#include <gr_uchar_to_float.h>
#include <gr_frequency_modulator_fc.h>
@@ -53,7 +54,7 @@
#include <gr_complex_to_xxx.h>
#include <gr_complex_to_interleaved_short.h>
#include <gr_interleaved_short_to_complex.h>
-#include <gr_endianness.h>
+//#include <gr_endianness.h>
#include <gr_firdes.h>
#include <gr_interleave.h>
#include <gr_deinterleave.h>
@@ -141,6 +142,10 @@
#include <gr_copy.h>
#include <gr_fll_band_edge_cc.h>
#include <gr_additive_scrambler_bb.h>
+#include <complex_vec_test.h>
+#include <gr_annotator_alltoall.h>
+#include <gr_annotator_1to1.h>
+#include <gr_burst_tagger.h>
%}
%include "gr_nop.i"
@@ -163,6 +168,7 @@
%include "gr_float_to_char.i"
%include "gr_float_to_uchar.i"
%include "gr_short_to_float.i"
+%include "gr_int_to_float.i"
%include "gr_char_to_float.i"
%include "gr_uchar_to_float.i"
%include "gr_frequency_modulator_fc.i"
@@ -173,7 +179,7 @@
%include "gr_align_on_samplenumbers_ss.i"
%include "gr_complex_to_xxx.i"
%include "gr_complex_to_interleaved_short.i"
-%include "gr_endianness.i"
+//%include "gr_endianness.i"
%include "gr_interleaved_short_to_complex.i"
%include "gr_firdes.i"
%include "gr_interleave.i"
@@ -262,3 +268,7 @@
%include "gr_copy.i"
%include "gr_fll_band_edge_cc.i"
%include "gr_additive_scrambler_bb.i"
+%include "complex_vec_test.i"
+%include "gr_annotator_alltoall.i"
+%include "gr_annotator_1to1.i"
+%include "gr_burst_tagger.i"
diff --git a/gnuradio-core/src/lib/general/gr_align_on_samplenumbers_ss.i b/gnuradio-core/src/lib/general/gr_align_on_samplenumbers_ss.i
index 841613ca6..ea73dd46d 100644
--- a/gnuradio-core/src/lib/general/gr_align_on_samplenumbers_ss.i
+++ b/gnuradio-core/src/lib/general/gr_align_on_samplenumbers_ss.i
@@ -22,7 +22,8 @@
GR_SWIG_BLOCK_MAGIC(gr,align_on_samplenumbers_ss);
-gr_align_on_samplenumbers_ss_sptr gr_make_align_on_samplenumbers_ss(int nchan=2, int align_interval=128);
+gr_align_on_samplenumbers_ss_sptr
+gr_make_align_on_samplenumbers_ss(int nchan=2, int align_interval=128) throw (std::exception);
class gr_align_on_samplenumbers_ss : public gr_block
{
diff --git a/gnuradio-core/src/lib/general/gr_annotator_1to1.cc b/gnuradio-core/src/lib/general/gr_annotator_1to1.cc
new file mode 100644
index 000000000..511b356e5
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_annotator_1to1.cc
@@ -0,0 +1,107 @@
+/* -*- 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_1to1.h>
+#include <gr_io_signature.h>
+#include <string.h>
+#include <iostream>
+#include <iomanip>
+
+gr_annotator_1to1_sptr
+gr_make_annotator_1to1 (int when, size_t sizeof_stream_item)
+{
+ return gnuradio::get_initial_sptr (new gr_annotator_1to1
+ (when, sizeof_stream_item));
+}
+
+gr_annotator_1to1::gr_annotator_1to1 (int when, size_t sizeof_stream_item)
+ : gr_sync_block ("annotator_1to1",
+ gr_make_io_signature (1, -1, sizeof_stream_item),
+ gr_make_io_signature (1, -1, sizeof_stream_item)),
+ d_itemsize(sizeof_stream_item), d_when((uint64_t)when)
+{
+ set_tag_propagation_policy(TPP_ONE_TO_ONE);
+
+ d_tag_counter = 0;
+ set_relative_rate(1.0);
+}
+
+gr_annotator_1to1::~gr_annotator_1to1 ()
+{
+}
+
+int
+gr_annotator_1to1::work (int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+{
+ const float *in = (const float*)input_items[0];
+ float *out = (float*)output_items[0];
+
+ std::stringstream str;
+ str << name() << unique_id();
+
+ uint64_t abs_N = 0;
+ int ninputs = input_items.size();
+ for(int i = 0; i < ninputs; i++) {
+ abs_N = nitems_read(i);
+
+ std::vector<pmt::pmt_t> all_tags;
+ get_tags_in_range(all_tags, i, abs_N, abs_N + noutput_items);
+
+ std::vector<pmt::pmt_t>::iterator itr;
+ for(itr = all_tags.begin(); itr != all_tags.end(); itr++) {
+ d_stored_tags.push_back(*itr);
+ }
+ }
+
+ // Storing the current noutput_items as the value to the "noutput_items" key
+ pmt::pmt_t srcid = pmt::pmt_string_to_symbol(str.str());
+ pmt::pmt_t key = pmt::pmt_string_to_symbol("seq");
+
+ // Work does nothing to the data stream; just copy all inputs to outputs
+ // Adds a new tag when the number of items read is a multiple of d_when
+ abs_N = nitems_read(0);
+ int noutputs = output_items.size();
+ for(int j = 0; j < noutput_items; j++) {
+ // the min() is a hack to make sure this doesn't segfault if there are a
+ // different number of ins and outs. This is specifically designed to test
+ // the 1-to-1 propagation policy.
+ for(int i = 0; i < std::min(noutputs, ninputs); i++) {
+ if(abs_N % d_when == 0) {
+ pmt::pmt_t value = pmt::pmt_from_uint64(d_tag_counter++);
+ add_item_tag(i, abs_N, key, value, srcid);
+ }
+
+ in = (const float*)input_items[i];
+ out = (float*)output_items[i];
+ out[j] = in[j];
+ }
+ abs_N++;
+ }
+
+ return noutput_items;
+}
diff --git a/gnuradio-core/src/lib/general/gr_annotator_1to1.h b/gnuradio-core/src/lib/general/gr_annotator_1to1.h
new file mode 100644
index 000000000..4abc5b051
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_annotator_1to1.h
@@ -0,0 +1,74 @@
+/* -*- 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_1TO1_H
+#define INCLUDED_GR_ANNOTATOR_1TO1_H
+
+#include <gr_sync_block.h>
+
+class gr_annotator_1to1;
+typedef boost::shared_ptr<gr_annotator_1to1> gr_annotator_1to1_sptr;
+
+// public constructor
+gr_annotator_1to1_sptr
+gr_make_annotator_1to1 (int when, size_t sizeof_stream_item);
+
+/*!
+ * \brief 1-to-1 stream annotator testing block. FOR TESTING PURPOSES ONLY.
+ *
+ * This block creates tags to be sent downstream every 10,000 items it sees. The
+ * tags contain the name and ID of the instantiated block, use "seq" as a key,
+ * and have a counter that increments by 1 for every tag produced that is used
+ * as the tag's value. The tags are propagated using the 1-to-1 policy.
+ *
+ * It also stores a copy of all tags it sees flow past it. These tags can be
+ * recalled externally with the data() member.
+ *
+ * This block is only meant for testing and showing how to use the tags.
+ */
+class gr_annotator_1to1 : public gr_sync_block
+{
+ public:
+ ~gr_annotator_1to1 ();
+ int work (int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+
+ std::vector<pmt::pmt_t> data() const
+ {
+ return d_stored_tags;
+ }
+
+protected:
+ gr_annotator_1to1 (int when, size_t sizeof_stream_item);
+
+ private:
+ size_t d_itemsize;
+ uint64_t d_when;
+ uint64_t d_tag_counter;
+ std::vector<pmt::pmt_t> d_stored_tags;
+
+ friend gr_annotator_1to1_sptr
+ gr_make_annotator_1to1 (int when, size_t sizeof_stream_item);
+};
+
+#endif
diff --git a/gnuradio-core/src/lib/general/gr_annotator_1to1.i b/gnuradio-core/src/lib/general/gr_annotator_1to1.i
new file mode 100644
index 000000000..f29ecbf53
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_annotator_1to1.i
@@ -0,0 +1,36 @@
+/* -*- 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.
+ */
+
+GR_SWIG_BLOCK_MAGIC(gr,annotator_1to1);
+
+gr_annotator_1to1_sptr gr_make_annotator_1to1 (int when,
+ size_t sizeof_stream_item);
+
+class gr_annotator_1to1 : public gr_sync_block
+{
+public:
+ std::vector<pmt::pmt_t> data() const;
+
+private:
+ gr_annotator_1to1 (int when, size_t sizeof_stream_item);
+};
+
diff --git a/gnuradio-core/src/lib/general/gr_annotator_alltoall.cc b/gnuradio-core/src/lib/general/gr_annotator_alltoall.cc
new file mode 100644
index 000000000..344fd088b
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_annotator_alltoall.cc
@@ -0,0 +1,110 @@
+/* -*- 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_alltoall.h>
+#include <gr_io_signature.h>
+#include <string.h>
+#include <iostream>
+#include <iomanip>
+
+gr_annotator_alltoall_sptr
+gr_make_annotator_alltoall (int when, size_t sizeof_stream_item)
+{
+ return gnuradio::get_initial_sptr (new gr_annotator_alltoall
+ (when, sizeof_stream_item));
+}
+
+gr_annotator_alltoall::gr_annotator_alltoall (int when,
+ size_t sizeof_stream_item)
+ : gr_sync_block ("annotator_alltoall",
+ gr_make_io_signature (1, -1, sizeof_stream_item),
+ gr_make_io_signature (1, -1, sizeof_stream_item)),
+ d_itemsize(sizeof_stream_item), d_when((uint64_t)when)
+{
+ set_tag_propagation_policy(TPP_ALL_TO_ALL);
+
+ d_tag_counter = 0;
+}
+
+gr_annotator_alltoall::~gr_annotator_alltoall ()
+{
+}
+
+int
+gr_annotator_alltoall::work (int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+{
+ const float *in = (const float *) input_items[0];
+ float *out = (float *) output_items[0];
+
+ std::stringstream str;
+ str << name() << unique_id();
+
+ uint64_t abs_N = 0, end_N;
+ int ninputs = input_items.size();
+ for(int i = 0; i < ninputs; i++) {
+ abs_N = nitems_read(i);
+ end_N = abs_N + (uint64_t)(noutput_items);
+
+ std::vector<pmt::pmt_t> all_tags;
+ get_tags_in_range(all_tags, i, abs_N, end_N);
+
+ std::vector<pmt::pmt_t>::iterator itr;
+ for(itr = all_tags.begin(); itr != all_tags.end(); itr++) {
+ d_stored_tags.push_back(*itr);
+ }
+ }
+
+ // Source ID and key for any tag that might get applied from this block
+ pmt::pmt_t srcid = pmt::pmt_string_to_symbol(str.str());
+ pmt::pmt_t key = pmt::pmt_string_to_symbol("seq");
+
+ // Work does nothing to the data stream; just copy all inputs to outputs
+ // Adds a new tag when the number of items read is a multiple of d_when
+ abs_N = nitems_written(0);
+ int noutputs = output_items.size();
+
+ for(int j = 0; j < noutput_items; j++) {
+ for(int i = 0; i < noutputs; i++) {
+ if(abs_N % d_when == 0) {
+ pmt::pmt_t value = pmt::pmt_from_uint64(d_tag_counter++);
+ add_item_tag(i, abs_N, key, value, srcid);
+ }
+
+ // Sum all of the inputs together for each output. Just 'cause.
+ out = (float*)output_items[i];
+ out[j] = 0;
+ for(int ins = 0; ins < ninputs; ins++) {
+ in = (const float*)input_items[ins];
+ out[j] += in[j];
+ }
+ }
+ abs_N++;
+ }
+
+ return noutput_items;
+}
diff --git a/gnuradio-core/src/lib/general/gr_annotator_alltoall.h b/gnuradio-core/src/lib/general/gr_annotator_alltoall.h
new file mode 100644
index 000000000..e1e51ebf3
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_annotator_alltoall.h
@@ -0,0 +1,75 @@
+/* -*- 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_ALLTOALL_H
+#define INCLUDED_GR_ANNOTATOR_ALLTOALL_H
+
+#include <gr_sync_block.h>
+
+class gr_annotator_alltoall;
+typedef boost::shared_ptr<gr_annotator_alltoall> gr_annotator_alltoall_sptr;
+
+// public constructor
+gr_annotator_alltoall_sptr
+gr_make_annotator_alltoall (int when, size_t sizeof_stream_item);
+
+/*!
+ * \brief All-to-all stream annotator testing block. FOR TESTING PURPOSES ONLY.
+ *
+ * This block creates tags to be sent downstream every 10,000 items it sees. The
+ * tags contain the name and ID of the instantiated block, use "seq" as a key,
+ * and have a counter that increments by 1 for every tag produced that is used
+ * as the tag's value. The tags are propagated using the all-to-all policy.
+ *
+ * It also stores a copy of all tags it sees flow past it. These tags can be
+ * recalled externally with the data() member.
+ *
+ * This block is only meant for testing and showing how to use the tags.
+ */
+class gr_annotator_alltoall : public gr_sync_block
+{
+ public:
+ ~gr_annotator_alltoall ();
+
+ int work (int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+
+ std::vector<pmt::pmt_t> data() const
+ {
+ return d_stored_tags;
+ }
+
+protected:
+ gr_annotator_alltoall (int when, size_t sizeof_stream_item);
+
+ private:
+ size_t d_itemsize;
+ uint64_t d_when;
+ uint64_t d_tag_counter;
+ std::vector<pmt::pmt_t> d_stored_tags;
+
+ friend gr_annotator_alltoall_sptr
+ gr_make_annotator_alltoall (int when, size_t sizeof_stream_item);
+};
+
+#endif
diff --git a/gnuradio-core/src/lib/general/gr_annotator_alltoall.i b/gnuradio-core/src/lib/general/gr_annotator_alltoall.i
new file mode 100644
index 000000000..f9bf6dd9a
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_annotator_alltoall.i
@@ -0,0 +1,36 @@
+/* -*- 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.
+ */
+
+GR_SWIG_BLOCK_MAGIC(gr,annotator_alltoall);
+
+gr_annotator_alltoall_sptr gr_make_annotator_alltoall (int when,
+ size_t sizeof_stream_item);
+
+class gr_annotator_alltoall : public gr_sync_block
+{
+public:
+ std::vector<pmt::pmt_t> data() const;
+
+private:
+ gr_annotator_alltoall (int when, size_t sizeof_stream_item);
+};
+
diff --git a/gnuradio-core/src/lib/general/gr_bin_statistics_f.i b/gnuradio-core/src/lib/general/gr_bin_statistics_f.i
index 5cec882f0..be98a464b 100644
--- a/gnuradio-core/src/lib/general/gr_bin_statistics_f.i
+++ b/gnuradio-core/src/lib/general/gr_bin_statistics_f.i
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2006 Free Software Foundation, Inc.
+ * Copyright 2006,2010 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -19,6 +19,9 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
+// Directors are only supported in Python, Java and C#. gr_feval_dd uses directors
+#ifdef SWIGPYTHON
+
GR_SWIG_BLOCK_MAGIC(gr,bin_statistics_f);
gr_bin_statistics_f_sptr
@@ -40,3 +43,5 @@ private:
public:
~gr_bin_statistics_f();
};
+
+#endif
diff --git a/gnuradio-core/src/lib/general/gr_burst_tagger.cc b/gnuradio-core/src/lib/general/gr_burst_tagger.cc
new file mode 100644
index 000000000..4b3847b08
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_burst_tagger.cc
@@ -0,0 +1,83 @@
+/* -*- 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_burst_tagger.h>
+#include <gr_io_signature.h>
+#include <string.h>
+
+gr_burst_tagger_sptr
+gr_make_burst_tagger(size_t itemsize)
+{
+ return gnuradio::get_initial_sptr(new gr_burst_tagger(itemsize));
+}
+
+gr_burst_tagger::gr_burst_tagger(size_t itemsize)
+ : gr_sync_block ("burst_tagger",
+ gr_make_io_signature2 (2, 2, itemsize, sizeof(short)),
+ gr_make_io_signature (1, 1, itemsize)),
+ d_itemsize(itemsize), d_state(false)
+{
+ std::stringstream str;
+ str << name() << unique_id();
+
+ d_key = pmt::pmt_string_to_symbol("burst");
+ d_id = pmt::pmt_string_to_symbol(str.str());
+}
+
+gr_burst_tagger::~gr_burst_tagger()
+{
+}
+
+int
+gr_burst_tagger::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+{
+ const char *signal = (const char*)input_items[0];
+ const short *trigger = (const short*)input_items[1];
+ char *out = (char*)output_items[0];
+
+ memcpy(out, signal, noutput_items * d_itemsize);
+
+ for(int i = 0; i < noutput_items; i++) {
+ if(trigger[i] > 0) {
+ if(d_state == false) {
+ d_state = true;
+ pmt::pmt_t value = pmt::PMT_T;
+ add_item_tag(0, nitems_written(0)+i, d_key, value, d_id);
+ }
+ }
+ else {
+ if(d_state == true) {
+ d_state = false;
+ pmt::pmt_t value = pmt::PMT_F;
+ add_item_tag(0, nitems_written(0)+i, d_key, value, d_id);
+ }
+ }
+ }
+
+ return noutput_items;
+}
diff --git a/gnuradio-core/src/lib/general/gr_burst_tagger.h b/gnuradio-core/src/lib/general/gr_burst_tagger.h
new file mode 100644
index 000000000..8f814bea0
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_burst_tagger.h
@@ -0,0 +1,56 @@
+/* -*- 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_BURST_TAGGER_H
+#define INCLUDED_GR_BURST_TAGGER_H
+
+#include <gr_sync_block.h>
+
+class gr_burst_tagger;
+typedef boost::shared_ptr<gr_burst_tagger> gr_burst_tagger_sptr;
+
+gr_burst_tagger_sptr gr_make_burst_tagger(size_t itemsize);
+
+/*!
+ * \brief output[i] = input[i]
+ * \ingroup misc_blk
+ *
+ */
+class gr_burst_tagger : public gr_sync_block
+{
+ size_t d_itemsize;
+ bool d_state;
+ pmt::pmt_t d_key;
+ pmt::pmt_t d_id;
+
+ friend gr_burst_tagger_sptr gr_make_burst_tagger(size_t itemsize);
+ gr_burst_tagger(size_t itemsize);
+
+ public:
+ ~gr_burst_tagger();
+
+ 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_burst_tagger.i b/gnuradio-core/src/lib/general/gr_burst_tagger.i
new file mode 100644
index 000000000..ebf1eea8c
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_burst_tagger.i
@@ -0,0 +1,31 @@
+/* -*- 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.
+ */
+
+GR_SWIG_BLOCK_MAGIC(gr,burst_tagger)
+
+gr_burst_tagger_sptr gr_make_burst_tagger(size_t itemsize);
+
+class gr_burst_tagger : public gr_sync_block
+{
+ private:
+ gr_burst_tagger(size_t itemsize);
+};
diff --git a/gnuradio-core/src/lib/general/gr_clock_recovery_mm_cc.cc b/gnuradio-core/src/lib/general/gr_clock_recovery_mm_cc.cc
index 23bbf821f..7c20f7fd9 100644
--- a/gnuradio-core/src/lib/general/gr_clock_recovery_mm_cc.cc
+++ b/gnuradio-core/src/lib/general/gr_clock_recovery_mm_cc.cc
@@ -33,7 +33,7 @@
// Public constructor
-
+static const int FUDGE = 16;
gr_clock_recovery_mm_cc_sptr
gr_make_clock_recovery_mm_cc(float omega, float gain_omega, float mu, float gain_mu,
@@ -78,7 +78,7 @@ gr_clock_recovery_mm_cc::forecast(int noutput_items, gr_vector_int &ninput_items
unsigned ninputs = ninput_items_required.size();
for (unsigned i=0; i < ninputs; i++)
ninput_items_required[i] =
- (int) ceil((noutput_items * d_omega) + d_interp->ntaps());
+ (int) ceil((noutput_items * d_omega) + d_interp->ntaps()) + FUDGE;
}
gr_complex
@@ -111,8 +111,6 @@ gr_clock_recovery_mm_cc::slicer_45deg (gr_complex sample)
algorithm," Electronics Letters, Vol. 31, no. 13, 22 June 1995, pp. 1032 - 1033.
*/
-static const int FUDGE = 16;
-
int
gr_clock_recovery_mm_cc::general_work (int noutput_items,
gr_vector_int &ninput_items,
diff --git a/gnuradio-core/src/lib/general/gr_clock_recovery_mm_cc.i b/gnuradio-core/src/lib/general/gr_clock_recovery_mm_cc.i
index 98d326b28..27eb70b95 100644
--- a/gnuradio-core/src/lib/general/gr_clock_recovery_mm_cc.i
+++ b/gnuradio-core/src/lib/general/gr_clock_recovery_mm_cc.i
@@ -22,9 +22,10 @@
GR_SWIG_BLOCK_MAGIC(gr,clock_recovery_mm_cc);
-gr_clock_recovery_mm_cc_sptr gr_make_clock_recovery_mm_cc (float omega, float gain_omega,
- float mu, float gain_mu,
- float omega_relative_limit);
+gr_clock_recovery_mm_cc_sptr
+gr_make_clock_recovery_mm_cc (float omega, float gain_omega,
+ float mu, float gain_mu,
+ float omega_relative_limit) throw(std::exception);
class gr_clock_recovery_mm_cc : public gr_sync_block
{
diff --git a/gnuradio-core/src/lib/general/gr_clock_recovery_mm_ff.i b/gnuradio-core/src/lib/general/gr_clock_recovery_mm_ff.i
index 4f08aa760..1b2437000 100644
--- a/gnuradio-core/src/lib/general/gr_clock_recovery_mm_ff.i
+++ b/gnuradio-core/src/lib/general/gr_clock_recovery_mm_ff.i
@@ -22,9 +22,10 @@
GR_SWIG_BLOCK_MAGIC(gr,clock_recovery_mm_ff);
-gr_clock_recovery_mm_ff_sptr gr_make_clock_recovery_mm_ff (float omega, float gain_omega,
- float mu, float gain_mu,
- float omega_relative_limit=0.001);
+gr_clock_recovery_mm_ff_sptr
+gr_make_clock_recovery_mm_ff (float omega, float gain_omega,
+ float mu, float gain_mu,
+ float omega_relative_limit=0.001) throw(std::exception);
class gr_clock_recovery_mm_ff : public gr_sync_block
{
diff --git a/gnuradio-core/src/lib/general/gr_decode_ccsds_27_fb.cc b/gnuradio-core/src/lib/general/gr_decode_ccsds_27_fb.cc
index d5425bfc8..c5e1320a3 100644
--- a/gnuradio-core/src/lib/general/gr_decode_ccsds_27_fb.cc
+++ b/gnuradio-core/src/lib/general/gr_decode_ccsds_27_fb.cc
@@ -39,7 +39,7 @@ gr_decode_ccsds_27_fb::gr_decode_ccsds_27_fb()
{
float RATE = 0.5;
float ebn0 = 12.0;
- float esn0 = RATE*pow(10.0, ebn0/10);
+ float esn0 = RATE*pow(10.0, ebn0/10.0);
gen_met(d_mettab, 100, esn0, 0.0, 256);
viterbi_chunks_init(d_state0);
diff --git a/gnuradio-core/src/lib/general/gr_feval.i b/gnuradio-core/src/lib/general/gr_feval.i
index 8594a6fa1..c5522805d 100644
--- a/gnuradio-core/src/lib/general/gr_feval.i
+++ b/gnuradio-core/src/lib/general/gr_feval.i
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2006 Free Software Foundation, Inc.
+ * Copyright 2006,2010 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -43,6 +43,9 @@
*/
+// Directors are only supported in Python, Java and C#
+#ifdef SWIGPYTHON
+
// Enable SWIG directors for these classes
%feature("director") gr_py_feval_dd;
%feature("director") gr_py_feval_cc;
@@ -197,3 +200,5 @@ long gr_feval_ll_example(gr_feval_ll *f, long x);
%rename(feval_example) gr_feval_example;
void gr_feval_example(gr_feval *f);
+
+#endif // SWIGPYTHON
diff --git a/gnuradio-core/src/lib/general/gr_fft_vcc.i b/gnuradio-core/src/lib/general/gr_fft_vcc.i
index 247571374..f35316e70 100644
--- a/gnuradio-core/src/lib/general/gr_fft_vcc.i
+++ b/gnuradio-core/src/lib/general/gr_fft_vcc.i
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2004,2007,2008 Free Software Foundation, Inc.
+ * Copyright 2004,2007,2008,2010 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -23,7 +23,7 @@
GR_SWIG_BLOCK_MAGIC(gr, fft_vcc)
gr_fft_vcc_sptr
-gr_make_fft_vcc (int fft_size, bool forward, const std::vector<float> window, bool shift=false);
+gr_make_fft_vcc (int fft_size, bool forward, const std::vector<float> &window, bool shift=false);
class gr_fft_vcc : public gr_sync_block
{
diff --git a/gnuradio-core/src/lib/general/gr_fft_vfc.cc b/gnuradio-core/src/lib/general/gr_fft_vfc.cc
index 608161efe..561c63740 100644
--- a/gnuradio-core/src/lib/general/gr_fft_vfc.cc
+++ b/gnuradio-core/src/lib/general/gr_fft_vfc.cc
@@ -40,12 +40,12 @@
gr_fft_vfc_sptr
-gr_make_fft_vfc (int fft_size, bool forward, const std::vector<float> window)
+gr_make_fft_vfc (int fft_size, bool forward, const std::vector<float> &window)
{
return gnuradio::get_initial_sptr(new gr_fft_vfc (fft_size, forward, window));
}
-gr_fft_vfc::gr_fft_vfc (int fft_size, bool forward, const std::vector<float> window)
+gr_fft_vfc::gr_fft_vfc (int fft_size, bool forward, const std::vector<float> &window)
: gr_sync_block ("fft_vfc",
gr_make_io_signature (1, 1, fft_size * sizeof (float)),
gr_make_io_signature (1, 1, fft_size * sizeof (gr_complex))),
@@ -107,7 +107,7 @@ gr_fft_vfc::work (int noutput_items,
}
bool
-gr_fft_vfc::set_window(const std::vector<float> window)
+gr_fft_vfc::set_window(const std::vector<float> &window)
{
if(window.size()==0 || window.size()==d_fft_size) {
d_window=window;
diff --git a/gnuradio-core/src/lib/general/gr_fft_vfc.h b/gnuradio-core/src/lib/general/gr_fft_vfc.h
index 054a383ef..074574477 100644
--- a/gnuradio-core/src/lib/general/gr_fft_vfc.h
+++ b/gnuradio-core/src/lib/general/gr_fft_vfc.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2004 Free Software Foundation, Inc.
+ * Copyright 2004,2010 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -31,7 +31,7 @@ class gr_fft_vfc;
typedef boost::shared_ptr<gr_fft_vfc> gr_fft_vfc_sptr;
gr_fft_vfc_sptr
-gr_make_fft_vfc (int fft_size, bool forward, const std::vector<float>);
+gr_make_fft_vfc (int fft_size, bool forward, const std::vector<float> &window);
/*!
* \brief Compute forward FFT. float vector in / complex vector out.
@@ -41,13 +41,13 @@ gr_make_fft_vfc (int fft_size, bool forward, const std::vector<float>);
class gr_fft_vfc : public gr_sync_block
{
friend gr_fft_vfc_sptr
- gr_make_fft_vfc (int fft_size, bool forward, const std::vector<float> window);
+ gr_make_fft_vfc (int fft_size, bool forward, const std::vector<float> &window);
unsigned int d_fft_size;
std::vector<float> d_window;
gri_fft_complex *d_fft;
- gr_fft_vfc (int fft_size, bool forward, const std::vector<float> window);
+ gr_fft_vfc (int fft_size, bool forward, const std::vector<float> &window);
public:
~gr_fft_vfc ();
@@ -55,7 +55,7 @@ class gr_fft_vfc : public gr_sync_block
int work (int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items);
- bool set_window(const std::vector<float> window);
+ bool set_window(const std::vector<float> &window);
};
diff --git a/gnuradio-core/src/lib/general/gr_fft_vfc.i b/gnuradio-core/src/lib/general/gr_fft_vfc.i
index 90c368fe6..149745b58 100644
--- a/gnuradio-core/src/lib/general/gr_fft_vfc.i
+++ b/gnuradio-core/src/lib/general/gr_fft_vfc.i
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2004 Free Software Foundation, Inc.
+ * Copyright 2004,2010 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -23,13 +23,14 @@
GR_SWIG_BLOCK_MAGIC(gr, fft_vfc)
gr_fft_vfc_sptr
-gr_make_fft_vfc (int fft_size, bool forward, const std::vector<float> window);
+gr_make_fft_vfc (int fft_size, bool forward, const std::vector<float> &window)
+throw(std::exception);
class gr_fft_vfc : public gr_sync_block
{
protected:
- gr_fft_vfc (int fft_size, bool forward, const std::vector<float> window);
+ gr_fft_vfc (int fft_size, bool forward, const std::vector<float> &window);
public:
- bool set_window(const std::vector<float> window);
+ bool set_window(const std::vector<float> &window);
};
diff --git a/gnuradio-core/src/lib/general/gr_firdes.cc b/gnuradio-core/src/lib/general/gr_firdes.cc
index 8efeb3438..5d192d67e 100644
--- a/gnuradio-core/src/lib/general/gr_firdes.cc
+++ b/gnuradio-core/src/lib/general/gr_firdes.cc
@@ -574,7 +574,7 @@ gr_firdes::gaussian (double gain,
vector<float> taps(ntaps);
double scale = 0;
double dt = 1.0/spb;
- double s = 1.0/(sqrt(log(2)) / (2*M_PI*bt));
+ double s = 1.0/(sqrt(log(2.0)) / (2*M_PI*bt));
double t0 = -0.5 * ntaps;
double ts;
for(int i=0;i<ntaps;i++)
diff --git a/gnuradio-core/src/lib/general/gr_frequency_modulator_fc.cc b/gnuradio-core/src/lib/general/gr_frequency_modulator_fc.cc
index 0f6f0d719..bff22be25 100644
--- a/gnuradio-core/src/lib/general/gr_frequency_modulator_fc.cc
+++ b/gnuradio-core/src/lib/general/gr_frequency_modulator_fc.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2004,2010 Free Software Foundation, Inc.
+ * Copyright 2004,2010,2011 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -28,6 +28,7 @@
#include <gr_io_signature.h>
#include <gr_sincos.h>
#include <math.h>
+#include <boost/math/special_functions/trunc.hpp>
gr_frequency_modulator_fc_sptr gr_make_frequency_modulator_fc (double sensitivity)
@@ -62,7 +63,7 @@ gr_frequency_modulator_fc::work (int noutput_items,
// to avoid loss of precision in the addition above.
if (fabs (d_phase) > 16 * M_PI){
- double ii = trunc (d_phase / (2 * M_PI));
+ double ii = boost::math::trunc (d_phase / (2 * M_PI));
d_phase = d_phase - (ii * 2 * M_PI);
}
diff --git a/gnuradio-core/src/lib/general/gr_frequency_modulator_fc.h b/gnuradio-core/src/lib/general/gr_frequency_modulator_fc.h
index 4ba05d709..55f8412ce 100644
--- a/gnuradio-core/src/lib/general/gr_frequency_modulator_fc.h
+++ b/gnuradio-core/src/lib/general/gr_frequency_modulator_fc.h
@@ -47,7 +47,9 @@ class gr_frequency_modulator_fc : public gr_sync_block
gr_frequency_modulator_fc (double sensitivity);
public:
-
+ void set_sensitivity(float sens) { d_sensitivity = sens; }
+ float get_sensitivity() { return d_sensitivity; }
+
int work (int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items);
diff --git a/gnuradio-core/src/lib/general/gr_frequency_modulator_fc.i b/gnuradio-core/src/lib/general/gr_frequency_modulator_fc.i
index 612b59026..04d9a41ba 100644
--- a/gnuradio-core/src/lib/general/gr_frequency_modulator_fc.i
+++ b/gnuradio-core/src/lib/general/gr_frequency_modulator_fc.i
@@ -28,4 +28,7 @@ class gr_frequency_modulator_fc : public gr_sync_block
{
private:
gr_frequency_modulator_fc (double sensitivity);
+public:
+ void set_sensitivity(float sens) { d_sensitivity = sens; }
+ float get_sensitivity() { return d_sensitivity; }
};
diff --git a/gnuradio-core/src/lib/general/gr_fxpt.cc b/gnuradio-core/src/lib/general/gr_fxpt.cc
index e752364a5..fae02c71e 100644
--- a/gnuradio-core/src/lib/general/gr_fxpt.cc
+++ b/gnuradio-core/src/lib/general/gr_fxpt.cc
@@ -30,9 +30,8 @@ const float gr_fxpt::s_sine_table[1 << NBITS][2] = {
#include "sine_table.h"
};
-// gcc 4.x fix
-const float gr_fxpt::TWO_TO_THE_31;
-const float gr_fxpt::PI;
+const float gr_fxpt::PI = 3.14159265358979323846;
+const float gr_fxpt::TWO_TO_THE_31 = 2147483648.0;
#if 0
/*
diff --git a/gnuradio-core/src/lib/general/gr_fxpt.h b/gnuradio-core/src/lib/general/gr_fxpt.h
index 520729f8d..c98d31b27 100644
--- a/gnuradio-core/src/lib/general/gr_fxpt.h
+++ b/gnuradio-core/src/lib/general/gr_fxpt.h
@@ -40,8 +40,8 @@ class gr_fxpt
static const int WORDBITS = 32;
static const int NBITS = 10;
static const float s_sine_table[1 << NBITS][2];
- static const float PI = 3.14159265358979323846;
- static const float TWO_TO_THE_31 = 2147483648.0;
+ static const float PI;
+ static const float TWO_TO_THE_31;
public:
static gr_int32
diff --git a/gnuradio-core/src/lib/general/gr_int_to_float.cc b/gnuradio-core/src/lib/general/gr_int_to_float.cc
new file mode 100644
index 000000000..b5a19e5c0
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_int_to_float.cc
@@ -0,0 +1,59 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gr_int_to_float.h>
+#include <gr_io_signature.h>
+
+gr_int_to_float_sptr
+gr_make_int_to_float ()
+{
+ return gnuradio::get_initial_sptr(new gr_int_to_float ());
+}
+
+gr_int_to_float::gr_int_to_float ()
+ : gr_sync_block ("gr_int_to_float",
+ gr_make_io_signature (1, 1, sizeof (int32_t)),
+ gr_make_io_signature (1, 1, sizeof (float)))
+{
+}
+
+int
+gr_int_to_float::work (int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+{
+ const int32_t *in = (const int32_t *) input_items[0];
+ float *out = (float *) output_items[0];
+
+ for(int i=0; i < noutput_items; i++) {
+ out[i] = (float)in[i];
+ }
+
+ return noutput_items;
+}
+
+
+
diff --git a/gnuradio-core/src/lib/general/gr_int_to_float.h b/gnuradio-core/src/lib/general/gr_int_to_float.h
new file mode 100644
index 000000000..cf1223be5
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_int_to_float.h
@@ -0,0 +1,51 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 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.
+ */
+
+#ifndef INCLUDED_GR_INT_TO_FLOAT_H
+#define INCLUDED_GR_INT_TO_FLOAT_H
+
+#include <gr_sync_block.h>
+
+class gr_int_to_float;
+typedef boost::shared_ptr<gr_int_to_float> gr_int_to_float_sptr;
+
+gr_int_to_float_sptr
+gr_make_int_to_float ();
+
+/*!
+ * \brief Convert stream of short to a stream of float
+ * \ingroup converter_blk
+ */
+
+class gr_int_to_float : public gr_sync_block
+{
+ friend gr_int_to_float_sptr gr_make_int_to_float ();
+ gr_int_to_float ();
+
+ public:
+ virtual int work (int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+};
+
+
+#endif /* INCLUDED_GR_INT_TO_FLOAT_H */
diff --git a/gnuradio-core/src/lib/general/gr_int_to_float.i b/gnuradio-core/src/lib/general/gr_int_to_float.i
new file mode 100644
index 000000000..8cb9e35b5
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_int_to_float.i
@@ -0,0 +1,30 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 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,int_to_float)
+
+gr_int_to_float_sptr gr_make_int_to_float ();
+
+class gr_int_to_float : public gr_sync_block
+{
+ gr_int_to_float ();
+};
diff --git a/gnuradio-core/src/lib/general/gr_keep_one_in_n.cc b/gnuradio-core/src/lib/general/gr_keep_one_in_n.cc
index c07e177fe..85495e277 100644
--- a/gnuradio-core/src/lib/general/gr_keep_one_in_n.cc
+++ b/gnuradio-core/src/lib/general/gr_keep_one_in_n.cc
@@ -38,8 +38,9 @@ gr_keep_one_in_n::gr_keep_one_in_n (size_t item_size, int n)
: gr_block ("keep_one_in_n",
gr_make_io_signature (1, 1, item_size),
gr_make_io_signature (1, 1, item_size)),
- d_n (n), d_count(n)
+ d_count(n)
{
+ set_n(n);
}
void
@@ -50,6 +51,8 @@ gr_keep_one_in_n::set_n(int n)
d_n = n;
d_count = n;
+
+ set_relative_rate(1.0 / (float)n);
}
int
diff --git a/gnuradio-core/src/lib/general/gr_math.cc b/gnuradio-core/src/lib/general/gr_math.cc
deleted file mode 100644
index 82dff469c..000000000
--- a/gnuradio-core/src/lib/general/gr_math.cc
+++ /dev/null
@@ -1,102 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2003 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_math.h>
-#include <math.h>
-
-/*
- * Greatest Common Divisor, using Euclid's algorithm.
- * [There are faster algorithms. See Knuth 4.5.2 if you care]
- */
-
-long
-gr_gcd (long m, long n)
-{
- if (m < 0)
- m = -m;
-
- if (n < 0)
- n = -n;
-
- while (n != 0){
- long t = m % n;
- m = n;
- n = t;
- }
-
- return m;
-}
-
-
-/*
- * These really need some configure hacking to figure out the right answer.
- * As a stop gap, try for a macro, and if not that, then try std::
- */
-
-// returns a non-zero value if value is "not-a-number" (NaN), and 0 otherwise
-
-#if defined(isnan) || !defined(CXX_HAS_STD_ISNAN)
-
-int
-gr_isnan (double value)
-{
- return isnan (value);
-}
-
-#else
-
-int
-gr_isnan (double value)
-{
- return std::isnan (value);
-}
-
-#endif
-
-// returns a non-zero value if the value of x has its sign bit set.
-//
-// This is not the same as `x < 0.0', because IEEE 754 floating point
-// allows zero to be signed. The comparison `-0.0 < 0.0' is false, but
-// `gr_signbit (-0.0)' will return a nonzero value.
-
-#ifdef signbit
-
-int
-gr_signbit (double x)
-{
- return signbit (x);
-}
-
-#else
-
-int
-gr_signbit (double x)
-{
- return std::signbit (x);
-}
-
-
-#endif
diff --git a/gnuradio-core/src/lib/general/gr_math.h b/gnuradio-core/src/lib/general/gr_math.h
index ea0f20027..f5935c1da 100644
--- a/gnuradio-core/src/lib/general/gr_math.h
+++ b/gnuradio-core/src/lib/general/gr_math.h
@@ -35,19 +35,6 @@ gr_is_power_of_2(long x)
return x != 0 && (x & (x-1)) == 0;
}
-long gr_gcd (long m, long n);
-
-// returns a non-zero value if value is "not-a-number" (NaN), and 0 otherwise
-int gr_isnan (double value);
-
-// returns a non-zero value if the value of x has its sign bit set.
-//
-// This is not the same as `x < 0.0', because IEEE 754 floating point
-// allows zero to be signed. The comparison `-0.0 < 0.0' is false, but
-// `gr_signbit (-0.0)' will return a nonzero value.
-
-int gr_signbit (double x);
-
/*!
* \brief Fast arc tangent using table lookup and linear interpolation
* \ingroup misc
diff --git a/gnuradio-core/src/lib/general/gr_mpsk_receiver_cc.h b/gnuradio-core/src/lib/general/gr_mpsk_receiver_cc.h
index 024d74ada..f17b68aa0 100644
--- a/gnuradio-core/src/lib/general/gr_mpsk_receiver_cc.h
+++ b/gnuradio-core/src/lib/general/gr_mpsk_receiver_cc.h
@@ -23,6 +23,7 @@
#ifndef INCLUDED_GR_MPSK_RECEIVER_CC_H
#define INCLUDED_GR_MPSK_RECEIVER_CC_H
+#include <gruel/attributes.h>
#include <gr_block.h>
#include <gr_complex.h>
#include <fstream>
@@ -299,7 +300,7 @@ protected:
static const unsigned int DLLEN = 8;
//! delay line plus some length for overflow protection
- gr_complex d_dl[2*DLLEN] __attribute__ ((aligned(8)));
+ __GR_ATTR_ALIGNED(8) gr_complex d_dl[2*DLLEN];
//! index to delay line
unsigned int d_dl_idx;
diff --git a/gnuradio-core/src/lib/general/gr_nop.cc b/gnuradio-core/src/lib/general/gr_nop.cc
index e69c8b340..bd5e4fd81 100644
--- a/gnuradio-core/src/lib/general/gr_nop.cc
+++ b/gnuradio-core/src/lib/general/gr_nop.cc
@@ -25,18 +25,30 @@
#endif
#include <gr_nop.h>
#include <gr_io_signature.h>
+#include <boost/bind.hpp>
+
+gr_nop_sptr
+gr_make_nop (size_t sizeof_stream_item)
+{
+ return gnuradio::get_initial_sptr (new gr_nop (sizeof_stream_item));
+}
gr_nop::gr_nop (size_t sizeof_stream_item)
: gr_block ("nop",
- gr_make_io_signature (0, -1, sizeof_stream_item),
- gr_make_io_signature (0, -1, sizeof_stream_item))
+ gr_make_io_signature (0, -1, sizeof_stream_item),
+ gr_make_io_signature (0, -1, sizeof_stream_item)),
+ d_nmsgs_recvd(0)
{
+ // Arrange to have count_received_msgs called when messages are received.
+ set_msg_handler(boost::bind(&gr_nop::count_received_msgs, this, _1));
}
-gr_block_sptr
-gr_make_nop (size_t sizeof_stream_item)
+// Trivial message handler that just counts them.
+// (N.B., This feature is used in qa_set_msg_handler)
+void
+gr_nop::count_received_msgs(pmt::pmt_t msg)
{
- return gnuradio::get_initial_sptr (new gr_nop (sizeof_stream_item));
+ d_nmsgs_recvd++;
}
int
@@ -51,5 +63,3 @@ gr_nop::general_work (int noutput_items,
return noutput_items;
}
-
-
diff --git a/gnuradio-core/src/lib/general/gr_nop.h b/gnuradio-core/src/lib/general/gr_nop.h
index 60b20c5ab..354c2f9fc 100644
--- a/gnuradio-core/src/lib/general/gr_nop.h
+++ b/gnuradio-core/src/lib/general/gr_nop.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2004 Free Software Foundation, Inc.
+ * Copyright 2004,2010 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -26,24 +26,35 @@
#include <gr_block.h>
#include <stddef.h> // size_t
+class gr_nop;
+typedef boost::shared_ptr<gr_nop> gr_nop_sptr;
+
+gr_nop_sptr
+gr_make_nop (size_t sizeof_stream_item);
+
/*!
* \brief Does nothing. Used for testing only.
* \ingroup misc_blk
*/
class gr_nop : public gr_block
{
- friend gr_block_sptr gr_make_nop (size_t sizeof_stream_item);
-
+ friend gr_nop_sptr gr_make_nop (size_t sizeof_stream_item);
gr_nop (size_t sizeof_stream_item);
+protected:
+ int d_nmsgs_recvd;
+
+ // Method that just counts any received messages.
+ void count_received_msgs(pmt::pmt_t msg);
+
public:
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);
-};
-gr_block_sptr
-gr_make_nop (size_t sizeof_stream_item);
+ int nmsgs_received() const { return d_nmsgs_recvd; }
+
+};
#endif /* INCLUDED_GR_NOP_H */
diff --git a/gnuradio-core/src/lib/general/gr_nop.i b/gnuradio-core/src/lib/general/gr_nop.i
index 8220e5c6c..85354d421 100644
--- a/gnuradio-core/src/lib/general/gr_nop.i
+++ b/gnuradio-core/src/lib/general/gr_nop.i
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2004 Free Software Foundation, Inc.
+ * Copyright 2004,2010 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -20,11 +20,12 @@
* Boston, MA 02110-1301, USA.
*/
-%ignore gr_nop;
+GR_SWIG_BLOCK_MAGIC(gr,nop)
+
+gr_nop_sptr gr_make_nop (size_t sizeof_stream_item);
+
class gr_nop : public gr_block {
- friend gr_block_sptr gr_make_nop (size_t sizeof_stream_item);
+private:
gr_nop (size_t sizeof_stream_item);
};
-%rename(nop) gr_make_nop;
-gr_block_sptr gr_make_nop (size_t sizeof_stream_item);
diff --git a/gnuradio-core/src/lib/general/gr_null_sink.cc b/gnuradio-core/src/lib/general/gr_null_sink.cc
index 0b7f2d9e8..67ef57a46 100644
--- a/gnuradio-core/src/lib/general/gr_null_sink.cc
+++ b/gnuradio-core/src/lib/general/gr_null_sink.cc
@@ -34,7 +34,7 @@ gr_null_sink::gr_null_sink (size_t sizeof_stream_item)
{
}
-gr_block_sptr
+gr_null_sink_sptr
gr_make_null_sink (size_t sizeof_stream_item)
{
return gnuradio::get_initial_sptr (new gr_null_sink (sizeof_stream_item));
diff --git a/gnuradio-core/src/lib/general/gr_null_sink.h b/gnuradio-core/src/lib/general/gr_null_sink.h
index 66df5d138..6d00382a5 100644
--- a/gnuradio-core/src/lib/general/gr_null_sink.h
+++ b/gnuradio-core/src/lib/general/gr_null_sink.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2004 Free Software Foundation, Inc.
+ * Copyright 2004,2010 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -26,15 +26,20 @@
#include <gr_sync_block.h>
#include <stddef.h> // size_t
+class gr_null_sink;
+typedef boost::shared_ptr<gr_null_sink> gr_null_sink_sptr;
+
+gr_null_sink_sptr
+gr_make_null_sink (size_t sizeof_stream_item);
+
+
/*!
* \brief Bit bucket
* \ingroup sink_blk
*/
-
class gr_null_sink : public gr_sync_block
{
- friend gr_block_sptr gr_make_null_sink (size_t sizeof_stream_item);
-
+ friend gr_null_sink_sptr gr_make_null_sink (size_t sizeof_stream_item);
gr_null_sink (size_t sizeof_stream_item);
public:
@@ -45,7 +50,4 @@ class gr_null_sink : public gr_sync_block
};
-gr_block_sptr
-gr_make_null_sink (size_t sizeof_stream_item);
-
#endif /* INCLUDED_GR_NULL_SINK_H */
diff --git a/gnuradio-core/src/lib/general/gr_null_sink.i b/gnuradio-core/src/lib/general/gr_null_sink.i
index fc4bcffda..e739ce118 100644
--- a/gnuradio-core/src/lib/general/gr_null_sink.i
+++ b/gnuradio-core/src/lib/general/gr_null_sink.i
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2004 Free Software Foundation, Inc.
+ * Copyright 2004,2010 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -20,11 +20,12 @@
* Boston, MA 02110-1301, USA.
*/
-%ignore gr_null_sink;
+GR_SWIG_BLOCK_MAGIC(gr,null_sink)
+
+gr_null_sink_sptr gr_make_null_sink (size_t sizeof_stream_item);
+
class gr_null_sink : public gr_sync_block {
- friend gr_block_sptr gr_make_null_sink (size_t sizeof_stream_item);
+private:
gr_null_sink (size_t sizeof_stream_item);
};
-%rename(null_sink) gr_make_null_sink;
-gr_block_sptr gr_make_null_sink (size_t sizeof_stream_item);
diff --git a/gnuradio-core/src/lib/general/gr_null_source.cc b/gnuradio-core/src/lib/general/gr_null_source.cc
index b65c39035..85fd2db4b 100644
--- a/gnuradio-core/src/lib/general/gr_null_source.cc
+++ b/gnuradio-core/src/lib/general/gr_null_source.cc
@@ -35,7 +35,7 @@ gr_null_source::gr_null_source (size_t sizeof_stream_item)
{
}
-gr_block_sptr
+gr_null_source_sptr
gr_make_null_source (size_t sizeof_stream_item)
{
return gnuradio::get_initial_sptr (new gr_null_source (sizeof_stream_item));
diff --git a/gnuradio-core/src/lib/general/gr_null_source.h b/gnuradio-core/src/lib/general/gr_null_source.h
index 63b1939bf..b1a46a195 100644
--- a/gnuradio-core/src/lib/general/gr_null_source.h
+++ b/gnuradio-core/src/lib/general/gr_null_source.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2004 Free Software Foundation, Inc.
+ * Copyright 2004,2010 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -25,14 +25,19 @@
#include <gr_sync_block.h>
+class gr_null_source;
+typedef boost::shared_ptr<gr_null_source> gr_null_source_sptr;
+
+gr_null_source_sptr
+gr_make_null_source (size_t sizeof_stream_item);
+
/*!
* \brief A source of zeros.
* \ingroup source_blk
*/
-
class gr_null_source : public gr_sync_block
{
- friend gr_block_sptr gr_make_null_source (size_t sizeof_stream_item);
+ friend gr_null_source_sptr gr_make_null_source (size_t sizeof_stream_item);
gr_null_source (size_t sizeof_stream_item);
@@ -43,7 +48,4 @@ class gr_null_source : public gr_sync_block
};
-gr_block_sptr
-gr_make_null_source (size_t sizeof_stream_item);
-
#endif /* INCLUDED_GR_NULL_SOURCE_H */
diff --git a/gnuradio-core/src/lib/general/gr_null_source.i b/gnuradio-core/src/lib/general/gr_null_source.i
index f9ddef86f..133161d0a 100644
--- a/gnuradio-core/src/lib/general/gr_null_source.i
+++ b/gnuradio-core/src/lib/general/gr_null_source.i
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2004 Free Software Foundation, Inc.
+ * Copyright 2004,2010 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -20,11 +20,12 @@
* Boston, MA 02110-1301, USA.
*/
-%ignore gr_null_source;
+GR_SWIG_BLOCK_MAGIC(gr,null_source)
+
+gr_null_source_sptr gr_make_null_source (size_t sizeof_stream_item);
+
class gr_null_source : public gr_sync_block {
- friend gr_block_sptr gr_make_null_source (size_t sizeof_stream_item);
+private:
gr_null_source (size_t sizeof_stream_item);
};
-%rename(null_source) gr_make_null_source;
-gr_block_sptr gr_make_null_source (size_t sizeof_stream_item);
diff --git a/gnuradio-core/src/lib/general/gr_ofdm_frame_sink.cc b/gnuradio-core/src/lib/general/gr_ofdm_frame_sink.cc
index 3457370eb..279945766 100644
--- a/gnuradio-core/src/lib/general/gr_ofdm_frame_sink.cc
+++ b/gnuradio-core/src/lib/general/gr_ofdm_frame_sink.cc
@@ -281,7 +281,7 @@ gr_ofdm_frame_sink::set_sym_value_out(const std::vector<gr_complex> &sym_positio
d_sym_position = sym_position;
d_sym_value_out = sym_value_out;
- d_nbits = (unsigned long)ceil(log10(d_sym_value_out.size()) / log10(2.0));
+ d_nbits = (unsigned long)ceil(log10(float(d_sym_value_out.size())) / log10(2.0));
return true;
}
diff --git a/gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.cc b/gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.cc
index 370b029cd..cc4aba0cb 100644
--- a/gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.cc
+++ b/gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.cc
@@ -113,7 +113,7 @@ gr_ofdm_mapper_bcv::gr_ofdm_mapper_bcv (const std::vector<gr_complex> &constella
throw std::invalid_argument("gr_ofdm_mapper_bcv: subcarriers allocated exceeds size of occupied carriers");
}
- d_nbits = (unsigned long)ceil(log10(d_constellation.size()) / log10(2.0));
+ d_nbits = (unsigned long)ceil(log10(float(d_constellation.size())) / log10(2.0));
}
gr_ofdm_mapper_bcv::~gr_ofdm_mapper_bcv(void)
diff --git a/gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.i b/gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.i
index 30c692926..3850220ba 100644
--- a/gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.i
+++ b/gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.i
@@ -26,7 +26,7 @@ gr_ofdm_mapper_bcv_sptr
gr_make_ofdm_mapper_bcv (const std::vector<gr_complex> &constellation,
unsigned int msgq_limit,
unsigned int bits_per_symbol,
- unsigned int fft_length);
+ unsigned int fft_length) throw(std::exception);
class gr_ofdm_mapper_bcv : public gr_sync_block
diff --git a/gnuradio-core/src/lib/general/gr_throttle.cc b/gnuradio-core/src/lib/general/gr_throttle.cc
index 3189e01c0..a24b1da8c 100644
--- a/gnuradio-core/src/lib/general/gr_throttle.cc
+++ b/gnuradio-core/src/lib/general/gr_throttle.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2005,2010 Free Software Foundation, Inc.
+ * Copyright 2005-2011 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -26,92 +26,64 @@
#include <gr_throttle.h>
#include <gr_io_signature.h>
-#include <errno.h>
-#include <stdio.h>
-#include <math.h>
-#include <string.h>
-#ifdef HAVE_TIME_H
-#include <time.h>
-#endif
-#if !defined(HAVE_NANOSLEEP) && defined(HAVE_SSLEEP)
-#include <windows.h>
-#endif
-
+#include <cstring>
+#include <boost/thread/thread.hpp>
-#ifdef HAVE_NANOSLEEP
-void
-gr_nanosleep(struct timespec *ts)
-{
- struct timespec *req = ts;
- struct timespec rem;
- int r = nanosleep(req, &rem);
- while (r < 0 && errno == EINTR){
- req = &rem;
- r = nanosleep(req, &rem);
- }
- if (r < 0)
- perror ("gr_nanosleep");
-}
-#endif
-
-gr_throttle_sptr
-gr_make_throttle(size_t itemsize, double samples_per_sec)
-{
- return gnuradio::get_initial_sptr(new gr_throttle(itemsize, samples_per_sec));
-}
+class gr_throttle_impl : public gr_throttle{
+public:
+ gr_throttle_impl(size_t itemsize):
+ gr_sync_block("throttle",
+ gr_make_io_signature(1, 1, itemsize),
+ gr_make_io_signature(1, 1, itemsize)),
+ d_itemsize(itemsize)
+ {
+ /* NOP */
+ }
-gr_throttle::gr_throttle(size_t itemsize, double samples_per_sec)
- : gr_sync_block("throttle",
- gr_make_io_signature(1, 1, itemsize),
- gr_make_io_signature(1, 1, itemsize)),
- d_itemsize(itemsize), d_samples_per_sec(samples_per_sec),
- d_total_samples(0)
-{
-#ifdef HAVE_GETTIMEOFDAY
- gettimeofday(&d_start, 0);
-#endif
-}
+ void set_sample_rate(double rate){
+ //changing the sample rate performs a reset of state params
+ d_start = boost::get_system_time();
+ d_total_samples = 0;
+ d_samps_per_tick = rate/boost::posix_time::time_duration::ticks_per_second();
+ d_samps_per_us = rate/1e6;
+ }
-gr_throttle::~gr_throttle()
-{
-}
+ int work (
+ int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items
+ ){
+ //calculate the expected number of samples to have passed through
+ boost::system_time now = boost::get_system_time();
+ boost::int64_t ticks = (now - d_start).ticks();
+ uint64_t expected_samps = uint64_t(d_samps_per_tick*ticks);
-int
-gr_throttle::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];
+ //if the expected samples was less, we need to throttle back
+ if (d_total_samples > expected_samps){
+ boost::this_thread::sleep(boost::posix_time::microseconds(
+ long((d_total_samples - expected_samps)/d_samps_per_us)
+ ));
+ }
-#if defined(HAVE_GETTIMEOFDAY)
- //
- // If our average sample rate exceeds our target sample rate,
- // delay long enough to reduce to our target rate.
- //
- struct timeval now;
- gettimeofday(&now, 0);
- long t_usec = now.tv_usec - d_start.tv_usec;
- long t_sec = now.tv_sec - d_start.tv_sec;
- double t = (double)t_sec + (double)t_usec * 1e-6;
- if (t < 1e-6) // avoid unlikely divide by zero
- t = 1e-6;
+ //copy all samples output[i] <= input[i]
+ const char *in = (const char *) input_items[0];
+ char *out = (char *) output_items[0];
+ std::memcpy(out, in, noutput_items * d_itemsize);
+ d_total_samples += noutput_items;
+ return noutput_items;
+ }
- double actual_samples_per_sec = d_total_samples / t;
- if (actual_samples_per_sec > d_samples_per_sec){ // need to delay
- double delay = d_total_samples / d_samples_per_sec - t;
-#ifdef HAVE_NANOSLEEP
- struct timespec ts;
- ts.tv_sec = (time_t)floor(delay);
- ts.tv_nsec = (long)((delay - floor(delay)) * 1e9);
- gr_nanosleep(&ts);
-#elif HAVE_SSLEEP
- Sleep( (DWORD)(delay*1000) );
-#endif
- }
-#endif
+private:
+ boost::system_time d_start;
+ size_t d_itemsize;
+ uint64_t d_total_samples;
+ double d_samps_per_tick, d_samps_per_us;
+};
- memcpy(out, in, noutput_items * d_itemsize);
- d_total_samples += noutput_items;
- return noutput_items;
+gr_throttle::sptr
+gr_make_throttle(size_t itemsize, double samples_per_sec)
+{
+ gr_throttle::sptr throttle(new gr_throttle_impl(itemsize));
+ throttle->set_sample_rate(samples_per_sec);
+ return throttle;
}
diff --git a/gnuradio-core/src/lib/general/gr_throttle.h b/gnuradio-core/src/lib/general/gr_throttle.h
index a1c9773c9..a82821f77 100644
--- a/gnuradio-core/src/lib/general/gr_throttle.h
+++ b/gnuradio-core/src/lib/general/gr_throttle.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2005 Free Software Foundation, Inc.
+ * Copyright 2005-2011 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -23,15 +23,6 @@
#define INCLUDED_GR_THROTTLE_H
#include <gr_sync_block.h>
-#ifdef HAVE_SYS_TIME_H
-#include <sys/time.h>
-#endif
-
-class gr_throttle;
-typedef boost::shared_ptr<gr_throttle> gr_throttle_sptr;
-
-
-gr_throttle_sptr gr_make_throttle(size_t itemsize, double samples_per_sec);
/*!
* \brief throttle flow of samples such that the average rate does not exceed samples_per_sec.
@@ -44,25 +35,15 @@ gr_throttle_sptr gr_make_throttle(size_t itemsize, double samples_per_sec);
* controlling the rate of samples. That should be controlled by a
* source or sink tied to sample clock. E.g., a USRP or audio card.
*/
-class gr_throttle : public gr_sync_block
+class gr_throttle : virtual public gr_sync_block
{
- friend gr_throttle_sptr gr_make_throttle(size_t itemsize, double samples_per_sec);
- size_t d_itemsize;
- double d_samples_per_sec;
- double d_total_samples;
-#ifdef HAVE_SYS_TIME_H
- struct timeval d_start;
-#endif
-
- gr_throttle(size_t itemsize, double samples_per_sec);
-
public:
- ~gr_throttle();
+ typedef boost::shared_ptr<gr_throttle> sptr;
- int work (int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
+ //! Sets the sample rate in samples per second
+ virtual void set_sample_rate(double rate) = 0;
};
-
+
+gr_throttle::sptr gr_make_throttle(size_t itemsize, double samples_per_sec);
#endif /* INCLUDED_GR_THROTTLE_H */
diff --git a/gnuradio-core/src/lib/general/gr_throttle.i b/gnuradio-core/src/lib/general/gr_throttle.i
index 21f7703ef..0b1ec165f 100644
--- a/gnuradio-core/src/lib/general/gr_throttle.i
+++ b/gnuradio-core/src/lib/general/gr_throttle.i
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2005 Free Software Foundation, Inc.
+ * Copyright 2005-2011 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -20,11 +20,10 @@
* Boston, MA 02110-1301, USA.
*/
-GR_SWIG_BLOCK_MAGIC(gr,throttle);
+%{
+#include <gr_throttle.h>
+%}
-gr_throttle_sptr gr_make_throttle (size_t itemsize, double samples_per_sec);
+GR_SWIG_BLOCK_MAGIC(gr,throttle);
-class gr_throttle : public gr_sync_block
-{
- gr_throttle (size_t itemsize, double samples_per_sec);
-};
+%include <gr_throttle.h>
diff --git a/gnuradio-core/src/lib/general/gr_unpack_k_bits_bb.i b/gnuradio-core/src/lib/general/gr_unpack_k_bits_bb.i
index 5f9a8f134..2e9aa406b 100644
--- a/gnuradio-core/src/lib/general/gr_unpack_k_bits_bb.i
+++ b/gnuradio-core/src/lib/general/gr_unpack_k_bits_bb.i
@@ -22,7 +22,7 @@
GR_SWIG_BLOCK_MAGIC(gr,unpack_k_bits_bb)
-gr_unpack_k_bits_bb_sptr gr_make_unpack_k_bits_bb (int k);
+gr_unpack_k_bits_bb_sptr gr_make_unpack_k_bits_bb (int k) throw(std::exception);
class gr_unpack_k_bits_bb : public gr_sync_interpolator
{
diff --git a/gnuradio-core/src/lib/general/gri_fft.cc b/gnuradio-core/src/lib/general/gri_fft.cc
index e535f28c7..f20b15ca0 100644
--- a/gnuradio-core/src/lib/general/gri_fft.cc
+++ b/gnuradio-core/src/lib/general/gri_fft.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2003,2008 Free Software Foundation, Inc.
+ * Copyright 2003,2008,2011 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -21,6 +21,7 @@
*/
#include <gri_fft.h>
+#include <gr_sys_paths.h>
#include <fftw3.h>
#include <gr_complex.h>
#include <stdlib.h>
@@ -29,6 +30,9 @@
#include <cassert>
#include <stdexcept>
+#include <boost/filesystem/operations.hpp>
+#include <boost/filesystem/path.hpp>
+namespace fs = boost::filesystem;
boost::mutex &
gri_fft_planner::mutex()
@@ -38,26 +42,18 @@ gri_fft_planner::mutex()
return s_planning_mutex;
}
-static char *
+static const char *
wisdom_filename ()
{
- static const char *filename = ".gr_fftw_wisdom";
-
- char *home = getenv ("HOME");
- if (home){
- char *p = new char[strlen (home) + strlen (filename) + 2];
- strcpy (p, home);
- strcat (p, "/");
- strcat (p, filename);
- return p;
- }
- return 0;
+ static fs::path path;
+ path = fs::path(gr_appdata_path()) / ".gr_fftw_wisdom";
+ return path.string().c_str();
}
static void
gri_fftw_import_wisdom ()
{
- char *filename = wisdom_filename ();
+ const char *filename = wisdom_filename ();
FILE *fp = fopen (filename, "r");
if (fp != 0){
int r = fftwf_import_wisdom_from_file (fp);
@@ -66,13 +62,12 @@ gri_fftw_import_wisdom ()
fprintf (stderr, "gri_fftw: can't import wisdom from %s\n", filename);
}
}
- delete [] filename;
}
static void
gri_fftw_export_wisdom ()
{
- char *filename = wisdom_filename ();
+ const char *filename = wisdom_filename ();
FILE *fp = fopen (filename, "w");
if (fp != 0){
fftwf_export_wisdom_to_file (fp);
@@ -82,7 +77,6 @@ gri_fftw_export_wisdom ()
fprintf (stderr, "gri_fftw: ");
perror (filename);
}
- delete [] filename;
}
// ----------------------------------------------------------------
diff --git a/gnuradio-core/src/lib/general/qa_gr_fxpt_vco.cc b/gnuradio-core/src/lib/general/qa_gr_fxpt_vco.cc
index 9885b3852..113006a22 100644
--- a/gnuradio-core/src/lib/general/qa_gr_fxpt_vco.cc
+++ b/gnuradio-core/src/lib/general/qa_gr_fxpt_vco.cc
@@ -53,7 +53,7 @@ qa_gr_fxpt_vco::t0 ()
float input[SIN_COS_BLOCK_SIZE];
for (int i = 0; i < SIN_COS_BLOCK_SIZE; i++){
- input[i] = sin(i);
+ input[i] = sin(double(i));
}
for (int i = 0; i < SIN_COS_BLOCK_SIZE; i++){
@@ -85,7 +85,7 @@ qa_gr_fxpt_vco::t1 ()
double max_error = 0;
for (int i = 0; i < SIN_COS_BLOCK_SIZE; i++){
- input[i] = sin(i);
+ input[i] = sin(double(i));
}
ref_vco.cos (ref_block, input, SIN_COS_BLOCK_SIZE, SIN_COS_K, SIN_COS_AMPL);