diff options
author | Ben Reynwar | 2011-01-30 09:50:36 -0700 |
---|---|---|
committer | Ben Reynwar | 2011-01-30 09:50:36 -0700 |
commit | d1d4c8fd9dcf852cef9c274363182209c6761145 (patch) | |
tree | 54ddbd617c5ffffbbfc4e766f2d2281669919a73 /gnuradio-core/src/lib/general | |
parent | f6547e103e6cae44ff2a81b0f83675ccc897f2e9 (diff) | |
parent | 023167ca8a85ab597f9e59302733f71809a8afbd (diff) | |
download | gnuradio-d1d4c8fd9dcf852cef9c274363182209c6761145.tar.gz gnuradio-d1d4c8fd9dcf852cef9c274363182209c6761145.tar.bz2 gnuradio-d1d4c8fd9dcf852cef9c274363182209c6761145.zip |
Merged upstream from next
Diffstat (limited to 'gnuradio-core/src/lib/general')
45 files changed, 906 insertions, 222 deletions
diff --git a/gnuradio-core/src/lib/general/Makefile.am b/gnuradio-core/src/lib/general/Makefile.am index 861c82c28..fad2536bf 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 \ @@ -99,7 +102,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 \ @@ -177,7 +179,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 \ @@ -190,6 +195,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 \ @@ -347,7 +353,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 \ @@ -360,8 +369,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 \ @@ -488,5 +497,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 47cc3b7fa..7e845cb21 100644 --- a/gnuradio-core/src/lib/general/general.i +++ b/gnuradio-core/src/lib/general/general.i @@ -53,7 +53,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> @@ -143,6 +143,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" @@ -175,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" @@ -266,3 +270,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.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_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_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_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_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); |