diff options
753 files changed, 12894 insertions, 17965 deletions
diff --git a/docs/doxygen/Doxyfile.in b/docs/doxygen/Doxyfile.in index 86cf2fc96f..ccd647134b 100644 --- a/docs/doxygen/Doxyfile.in +++ b/docs/doxygen/Doxyfile.in @@ -581,19 +581,6 @@ EXCLUDE = @abs_top_builddir@/docs/doxygen/html \ @abs_top_builddir@/docs/doxygen/other/doxypy.py \ @abs_top_builddir@/dtools \ @abs_top_builddir@/gnuradio-core/src/lib/bug_work_around_6.cc \ - @abs_top_builddir@/gnuradio-core/src/lib/filter/assembly.h \ - @abs_top_builddir@/gnuradio-core/src/lib/filter/generate_all.py \ - @abs_top_builddir@/gnuradio-core/src/lib/filter/generate_gr_fir_XXX.py \ - @abs_top_builddir@/gnuradio-core/src/lib/filter/generate_gr_fir_filter_XXX.py \ - @abs_top_builddir@/gnuradio-core/src/lib/filter/generate_gr_fir_sysconfig.py \ - @abs_top_builddir@/gnuradio-core/src/lib/filter/generate_gr_fir_sysconfig_generic.py \ - @abs_top_builddir@/gnuradio-core/src/lib/filter/generate_gr_fir_util.py \ - @abs_top_builddir@/gnuradio-core/src/lib/filter/generate_gr_freq_xlating_fir_filter_XXX.py \ - @abs_top_builddir@/gnuradio-core/src/lib/filter/generate_gr_interp_fir_filter_XXX.py \ - @abs_top_builddir@/gnuradio-core/src/lib/filter/generate_gr_rational_resampler_base_XXX.py \ - @abs_top_builddir@/gnuradio-core/src/lib/filter/generate_utils.py \ - @abs_top_builddir@/gnuradio-core/src/lib/filter/gr_altivec.h \ - @abs_top_builddir@/gnuradio-core/src/lib/filter/sse_debug.h \ @abs_top_builddir@/gnuradio-core/src/lib/gengen/generate_all.py \ @abs_top_builddir@/gnuradio-core/src/lib/gengen/generate_common.py \ @abs_top_builddir@/gnuradio-core/src/lib/missing/bug_work_around_8.cc \ diff --git a/docs/doxygen/other/main_page.dox b/docs/doxygen/other/main_page.dox index f9e335061c..deb6f8ebf8 100644 --- a/docs/doxygen/other/main_page.dox +++ b/docs/doxygen/other/main_page.dox @@ -80,7 +80,7 @@ them. self.src = analog.noise_source_c(gr.GR_GAUSSIAN, amp) self.flt = filter.fir_filter_ccf(1, taps) - self.snk = gr.null_sink(gr.sizeof_gr_complex) + self.snk = blocks.null_sink(gr.sizeof_gr_complex) self.connect(self.src, self.flt, self.snk) @@ -226,7 +226,7 @@ class mytb(gr.top_block): self.src1 = analog.noise_source_c(analog.GR_GAUSSIAN, 1) self.add = blocks.add_cc() self.sub = blocks.sub_cc() - self.head = gr.head(gr.sizeof_gr_complex, 1000000) + self.head = blocks.head(gr.sizeof_gr_complex, 1000000) self.snk = blocks.file_sink(gr.sizeof_gr_complex, "output.32fc") self.connect(self.src0, (self.add,0)) @@ -281,7 +281,7 @@ class mytb(gr.top_block): self.src1 = analog.noise_source_c(analog.GR_GAUSSIAN, 1) self.add = blocks.add_cc() self.sub = blocks.sub_cc() - self.head = gr.head(gr.sizeof_gr_complex, 1000000) + self.head = blocks.head(gr.sizeof_gr_complex, 1000000) self.snk = blocks.file_sink(gr.sizeof_gr_complex, "output.32fc") self.connect(self.src0, (self.add,0)) diff --git a/docs/sphinx/gnuradio_sphinx.py b/docs/sphinx/gnuradio_sphinx.py index 06a3150c49..f1e16481ba 100644 --- a/docs/sphinx/gnuradio_sphinx.py +++ b/docs/sphinx/gnuradio_sphinx.py @@ -138,8 +138,8 @@ class OldBlockDocumenter(FunctionDocumenter): """ Specialized Documenter subclass for gnuradio blocks. - It merges together the documentation for the generator function (e.g. gr.head) - with the wrapped sptr (e.g. gr.gr_head_sptr) to keep the documentation + It merges together the documentation for the generator function (e.g. blocks.head) + with the wrapped sptr (e.g. gr::blocks::head::sptr) to keep the documentation tidier. """ objtype = 'oldblock' diff --git a/docs/sphinx/source/gr/coding_blk.rst b/docs/sphinx/source/gr/coding_blk.rst deleted file mode 100644 index da8cacf2b4..0000000000 --- a/docs/sphinx/source/gr/coding_blk.rst +++ /dev/null @@ -1,5 +0,0 @@ -gnuradio.gr: Information Coding and Decoding -============================================ - -.. autooldblock:: gnuradio.gr.fake_channel_encoder_pp -.. autooldblock:: gnuradio.gr.fake_channel_decoder_pp diff --git a/docs/sphinx/source/gr/index.rst b/docs/sphinx/source/gr/index.rst index bd43888ec7..777ec7fa68 100644 --- a/docs/sphinx/source/gr/index.rst +++ b/docs/sphinx/source/gr/index.rst @@ -15,19 +15,6 @@ Top Block and Hierarchical Block Base Classes gnuradio.gr.top_block gnuradio.gr.hier_block2 -Signal Sources -^^^^^^^^^^^^^^ - -.. autosummary:: - :nosignatures: - - gnuradio.gr.lfsr_32k_source_s - gnuradio.gr.null_source - gnuradio.gr.vector_source_b - gnuradio.gr.vector_source_c - gnuradio.gr.vector_source_f - gnuradio.gr.vector_source_i - gnuradio.gr.vector_source_s Signal Sinks ^^^^^^^^^^^^ @@ -35,50 +22,10 @@ Signal Sinks .. autosummary:: :nosignatures: - gnuradio.gr.check_counting_s - gnuradio.gr.check_lfsr_32k_s - gnuradio.gr.null_sink - gnuradio.gr.vector_sink_b - gnuradio.gr.vector_sink_c - gnuradio.gr.vector_sink_f - gnuradio.gr.vector_sink_i - gnuradio.gr.vector_sink_s gnuradio.gr.histo_sink_f gnuradio.gr.oscope_sink_f -Information Coding and Decoding -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -.. autosummary:: - :nosignatures: - - gnuradio.gr.fake_channel_encoder_pp - gnuradio.gr.fake_channel_decoder_pp - - - -Miscellaneous Blocks -^^^^^^^^^^^^^^^^^^^^ - -.. autosummary:: - :nosignatures: - - gnuradio.gr.copy - gnuradio.gr.kludge_copy - gnuradio.gr.nop - gnuradio.gr.pa_2x2_phase_combiner - gnuradio.gr.channel_model - -Slicing and Dicing Streams -^^^^^^^^^^^^^^^^^^^^^^^^^^ - -.. autosummary:: - :nosignatures: - - gnuradio.gr.head - gnuradio.gr.skiphead - Miscellaneous ------------- diff --git a/docs/sphinx/source/gr/misc_blk.rst b/docs/sphinx/source/gr/misc_blk.rst deleted file mode 100644 index a4dcc58a2d..0000000000 --- a/docs/sphinx/source/gr/misc_blk.rst +++ /dev/null @@ -1,8 +0,0 @@ -gnuradio.gr: Miscellaneous Blocks -================================= - -.. autooldblock:: gnuradio.gr.copy -.. autooldblock:: gnuradio.gr.kludge_copy -.. autooldblock:: gnuradio.gr.nop -.. autooldblock:: gnuradio.gr.pa_2x2_phase_combiner -.. autooldblock:: gnuradio.gr.channel_model diff --git a/docs/sphinx/source/gr/sink_blk.rst b/docs/sphinx/source/gr/sink_blk.rst index 1e82765456..06fea4dcf9 100644 --- a/docs/sphinx/source/gr/sink_blk.rst +++ b/docs/sphinx/source/gr/sink_blk.rst @@ -1,13 +1,5 @@ gnuradio.gr: Signal Sinks ========================= -.. autooldblock:: gnuradio.gr.check_counting_s -.. autooldblock:: gnuradio.gr.check_lfsr_32k_s -.. autooldblock:: gnuradio.gr.null_sink -.. autooldblock:: gnuradio.gr.vector_sink_b -.. autooldblock:: gnuradio.gr.vector_sink_c -.. autooldblock:: gnuradio.gr.vector_sink_f -.. autooldblock:: gnuradio.gr.vector_sink_i -.. autooldblock:: gnuradio.gr.vector_sink_s .. autooldblock:: gnuradio.gr.histo_sink_f .. autooldblock:: gnuradio.gr.oscope_sink_f diff --git a/docs/sphinx/source/gr/slicedice_blk.rst b/docs/sphinx/source/gr/slicedice_blk.rst deleted file mode 100644 index 9ade1667d5..0000000000 --- a/docs/sphinx/source/gr/slicedice_blk.rst +++ /dev/null @@ -1,5 +0,0 @@ -gnuradio.gr: Slicing and Dicing Streams -======================================= - -.. autooldblock:: gnuradio.gr.head -.. autooldblock:: gnuradio.gr.skiphead diff --git a/docs/sphinx/source/gr/source_blk.rst b/docs/sphinx/source/gr/source_blk.rst deleted file mode 100644 index 1ef77349f6..0000000000 --- a/docs/sphinx/source/gr/source_blk.rst +++ /dev/null @@ -1,11 +0,0 @@ -gnuradio.gr: Signal Sources -=========================== - -.. autooldblock:: gnuradio.gr.lfsr_32k_source_s -.. autooldblock:: gnuradio.gr.null_source -.. autooldblock:: gnuradio.gr.vector_source_b -.. autooldblock:: gnuradio.gr.vector_source_c -.. autooldblock:: gnuradio.gr.vector_source_f -.. autooldblock:: gnuradio.gr.vector_source_i -.. autooldblock:: gnuradio.gr.vector_source_s - diff --git a/gnuradio-core/CMakeLists.txt b/gnuradio-core/CMakeLists.txt index 3b50bcf6a1..3dcffa2184 100644 --- a/gnuradio-core/CMakeLists.txt +++ b/gnuradio-core/CMakeLists.txt @@ -49,12 +49,9 @@ GR_SET_GLOBAL(GNURADIO_CORE_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/src/lib/runtime ${CMAKE_CURRENT_BINARY_DIR}/src/lib/general ${CMAKE_CURRENT_SOURCE_DIR}/src/lib/general - ${CMAKE_CURRENT_BINARY_DIR}/src/lib/gengen - ${CMAKE_CURRENT_SOURCE_DIR}/src/lib/gengen ${CMAKE_CURRENT_BINARY_DIR}/src/lib/filter ${CMAKE_CURRENT_SOURCE_DIR}/src/lib/filter ${CMAKE_CURRENT_SOURCE_DIR}/src/lib/missing - ${CMAKE_CURRENT_SOURCE_DIR}/src/lib/io ${CMAKE_CURRENT_BINARY_DIR}/src/lib/swig ${CMAKE_CURRENT_SOURCE_DIR}/src/lib/swig ${CMAKE_CURRENT_SOURCE_DIR}/src/lib/hier diff --git a/gnuradio-core/src/examples/CMakeLists.txt b/gnuradio-core/src/examples/CMakeLists.txt index 532c658083..b90a5542df 100644 --- a/gnuradio-core/src/examples/CMakeLists.txt +++ b/gnuradio-core/src/examples/CMakeLists.txt @@ -20,8 +20,3 @@ add_subdirectory(mp-sched) add_subdirectory(network) add_subdirectory(volk_benchmark) - -if(ENABLE_GR_CTRLPORT) -add_subdirectory(ctrlport) -endif(ENABLE_GR_CTRLPORT) - diff --git a/gnuradio-core/src/examples/mp-sched/affinity_set.py b/gnuradio-core/src/examples/mp-sched/affinity_set.py index 8b032acd83..eee88cd34e 100755 --- a/gnuradio-core/src/examples/mp-sched/affinity_set.py +++ b/gnuradio-core/src/examples/mp-sched/affinity_set.py @@ -7,6 +7,7 @@ from gnuradio import eng_notation from gnuradio import gr from gnuradio import blocks +from gnuradio import filter from gnuradio.eng_option import eng_option from gnuradio.filter import firdes from optparse import OptionParser @@ -27,21 +28,21 @@ class affinity_set(gr.top_block): ################################################## vec_len = 1 self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*vec_len, samp_rate) - self.gr_null_source_0 = gr.null_source(gr.sizeof_gr_complex*vec_len) - self.gr_null_sink_0 = gr.null_sink(gr.sizeof_gr_complex*vec_len) - self.gr_filt_0 = gr.fir_filter_ccc(1, 40000*[0.2+0.3j,]) - self.gr_filt_1 = gr.fir_filter_ccc(1, 40000*[0.2+0.3j,]) + self.blocks_null_source_0 = blocks.null_source(gr.sizeof_gr_complex*vec_len) + self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex*vec_len) + self.filter_filt_0 = filter.fir_filter_ccc(1, 40000*[0.2+0.3j,]) + self.filter_filt_1 = filter.fir_filter_ccc(1, 40000*[0.2+0.3j,]) - self.gr_filt_0.set_processor_affinity([0,]) - self.gr_filt_1.set_processor_affinity([0,1]) + self.filter_filt_0.set_processor_affinity([0,]) + self.filter_filt_1.set_processor_affinity([0,1]) ################################################## # Connections ################################################## - self.connect((self.gr_null_source_0, 0), (self.blocks_throttle_0, 0)) + self.connect((self.blocks_null_source_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.gr_filt_0, 0)) - self.connect((self.gr_filt_0, 0), (self.gr_filt_1, 0)) - self.connect((self.gr_filt_1, 0), (self.gr_null_sink_0, 0)) + self.connect((self.filter_filt_0, 0), (self.gr_filt_1, 0)) + self.connect((self.filter_filt_1, 0), (self.blocks_null_sink_0, 0)) # QT sink close method reimplementation diff --git a/gnuradio-core/src/examples/mp-sched/synthetic.py b/gnuradio-core/src/examples/mp-sched/synthetic.py index 5ce1b5eb89..6f0bb85da8 100755 --- a/gnuradio-core/src/examples/mp-sched/synthetic.py +++ b/gnuradio-core/src/examples/mp-sched/synthetic.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2008 Free Software Foundation, Inc. +# Copyright 2008,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -20,6 +20,7 @@ # from gnuradio import gr, gru, eng_notation, blks2 +from gnuradio import blocks from gnuradio.eng_option import eng_option from optparse import OptionParser import os @@ -28,8 +29,8 @@ import os class pipeline(gr.hier_block2): def __init__(self, nstages, ntaps=256): """ - Create a pipeline of nstages of gr.fir_filter_fff's connected in serial - terminating in a gr.null_sink. + Create a pipeline of nstages of filter.fir_filter_fff's connected in serial + terminating in a blocks.null_sink. """ gr.hier_block2.__init__(self, "pipeline", gr.io_signature(1, 1, gr.sizeof_float), @@ -37,11 +38,11 @@ class pipeline(gr.hier_block2): taps = ntaps*[1.0/ntaps] upstream = self for i in range(nstages): - op = gr.fir_filter_fff(1, taps) + op = filter.fir_filter_fff(1, taps) self.connect(upstream, op) upstream = op - self.connect(upstream, gr.null_sink(gr.sizeof_float)) + self.connect(upstream, blocks.null_sink(gr.sizeof_float)) class top(gr.top_block): @@ -75,8 +76,8 @@ class top(gr.top_block): # Something vaguely like floating point ops self.flop = 2 * ntaps * options.npipelines * options.nstages * options.nsamples - src = gr.null_source(gr.sizeof_float) - head = gr.head(gr.sizeof_float, int(options.nsamples)) + src = blocks.null_source(gr.sizeof_float) + head = blocks.head(gr.sizeof_float, int(options.nsamples)) self.connect(src, head) for n in range(options.npipelines): diff --git a/gnuradio-core/src/examples/mp-sched/wfm_rcv_pll_to_wav.py b/gnuradio-core/src/examples/mp-sched/wfm_rcv_pll_to_wav.py index 2f638e26ec..7cf3210b0e 100755 --- a/gnuradio-core/src/examples/mp-sched/wfm_rcv_pll_to_wav.py +++ b/gnuradio-core/src/examples/mp-sched/wfm_rcv_pll_to_wav.py @@ -68,7 +68,7 @@ class wfm_rx_block (gr.top_block): 0.1, # passband ripple 60) # stopband attenuation #print len(chan_filt_coeffs) - chan_filt = gr.fir_filter_ccf (chanfilt_decim, chan_filt_coeffs) + chan_filt = filter.fir_filter_ccf (chanfilt_decim, chan_filt_coeffs) #self.guts = analog.wfm_rcv (demod_rate, audio_decimation) diff --git a/gnuradio-core/src/examples/network/vector_source.py b/gnuradio-core/src/examples/network/vector_source.py index b960a6d96a..568425fd50 100755 --- a/gnuradio-core/src/examples/network/vector_source.py +++ b/gnuradio-core/src/examples/network/vector_source.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2006,2010 Free Software Foundation, Inc. +# Copyright 2006,2010,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -29,7 +29,7 @@ class vector_source(gr.top_block): def __init__(self, host, port, pkt_size, eof): gr.top_block.__init__(self, "vector_source") data = [i*0.01 for i in range(1000)] - vec = gr.vector_source_f(data, True) + vec = blocks.vector_source_f(data, True) udp = blocks.udp_sink(gr.sizeof_float, host, port, pkt_size, eof=eof) self.connect(vec, udp) diff --git a/gnuradio-core/src/examples/volk_benchmark/volk_test_funcs.py b/gnuradio-core/src/examples/volk_benchmark/volk_test_funcs.py index 0ce25fcc6a..0f2c84100a 100644 --- a/gnuradio-core/src/examples/volk_benchmark/volk_test_funcs.py +++ b/gnuradio-core/src/examples/volk_benchmark/volk_test_funcs.py @@ -1,6 +1,7 @@ #!/usr/bin/env python from gnuradio import gr +from gnuradio import blocks import math, sys, os, time try: @@ -119,13 +120,13 @@ class helper(gr.top_block): self.op = op self.srcs = [] self.snks = [] - self.head = gr.head(isizeof, N) + self.head = blocks.head(isizeof, N) for n in xrange(nsrcs): - self.srcs.append(gr.null_source(isizeof)) + self.srcs.append(blocks.null_source(isizeof)) for n in xrange(nsnks): - self.snks.append(gr.null_sink(osizeof)) + self.snks.append(blocks.null_sink(osizeof)) self.connect(self.srcs[0], self.head, (self.op,0)) diff --git a/gnuradio-core/src/lib/CMakeLists.txt b/gnuradio-core/src/lib/CMakeLists.txt index 72b9f9bdeb..c72be94db5 100644 --- a/gnuradio-core/src/lib/CMakeLists.txt +++ b/gnuradio-core/src/lib/CMakeLists.txt @@ -27,10 +27,7 @@ include(${CMAKE_CURRENT_SOURCE_DIR}/ConfigChecks.cmake) ######################################################################## GR_INCLUDE_SUBDIRECTORY(missing) GR_INCLUDE_SUBDIRECTORY(runtime) -GR_INCLUDE_SUBDIRECTORY(filter) GR_INCLUDE_SUBDIRECTORY(general) -GR_INCLUDE_SUBDIRECTORY(gengen) -GR_INCLUDE_SUBDIRECTORY(io) list(APPEND gnuradio_core_sources bug_work_around_6.cc) list(APPEND test_gnuradio_core_sources bug_work_around_6.cc) diff --git a/gnuradio-core/src/lib/filter/CMakeLists.txt b/gnuradio-core/src/lib/filter/CMakeLists.txt deleted file mode 100644 index a185b06bd5..0000000000 --- a/gnuradio-core/src/lib/filter/CMakeLists.txt +++ /dev/null @@ -1,39 +0,0 @@ -# Copyright 2010-2011 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. - -######################################################################## -# This file included, use CMake directory variables -######################################################################## - -######################################################################## -# Append gnuradio-core library sources -######################################################################## -list(APPEND gnuradio_core_sources - ${CMAKE_CURRENT_SOURCE_DIR}/gr_sincos.c -) - -######################################################################## -# Install runtime headers -######################################################################## -install(FILES - ${CMAKE_CURRENT_SOURCE_DIR}/gr_rotator.h - ${CMAKE_CURRENT_SOURCE_DIR}/gr_sincos.h - DESTINATION ${GR_INCLUDE_DIR}/gnuradio - COMPONENT "core_devel" -) diff --git a/gnuradio-core/src/lib/filter/gr_rotator.h b/gnuradio-core/src/lib/filter/gr_rotator.h deleted file mode 100644 index 77946dd397..0000000000 --- a/gnuradio-core/src/lib/filter/gr_rotator.h +++ /dev/null @@ -1,54 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2003,2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef _GR_ROTATOR_H_ -#define _GR_ROTATOR_H_ - -#include <gr_core_api.h> -#include <gr_complex.h> - -class /*GR_CORE_API*/ gr_rotator { - gr_complex d_phase; - gr_complex d_phase_incr; - unsigned int d_counter; - - public: - gr_rotator () : d_phase (1), d_phase_incr (1), d_counter(0) { } - - void set_phase (gr_complex phase) { d_phase = phase / abs(phase); } - void set_phase_incr (gr_complex incr) { d_phase_incr = incr / abs(incr); } - - gr_complex rotate (gr_complex in){ - d_counter++; - - gr_complex z = in * d_phase; // rotate in by phase - d_phase *= d_phase_incr; // incr our phase (complex mult == add phases) - - if ((d_counter % 512) == 0) - d_phase /= abs(d_phase); // Normalize to ensure multiplication is rotation - - return z; - } - -}; - -#endif /* _GR_ROTATOR_H_ */ diff --git a/gnuradio-core/src/lib/filter/qa_rotator.cc b/gnuradio-core/src/lib/filter/qa_rotator.cc deleted file mode 100644 index b722f32c43..0000000000 --- a/gnuradio-core/src/lib/filter/qa_rotator.cc +++ /dev/null @@ -1,81 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002,2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <gruel/attributes.h> -#include <cppunit/TestAssert.h> -#include <qa_rotator.h> -#include <analog/rotator.h> -#include <stdio.h> -#include <cmath> -#include <gr_expj.h> - -namespace gr { - namespace analog { - - // error vector magnitude - __GR_ATTR_UNUSED static float - error_vector_mag(gr_complex a, gr_complex b) - { - return abs(a-b); - } - - void - qa_rotator::t1() - { - static const unsigned int N = 100000; - - rotator r; - - double phase_incr = 2*M_PI / 1003; - double phase = 0; - - // Old code: We increment then return the rotated value, thus we - // need to start one tick back - // r.set_phase(gr_complex(1,0) * conj(gr_expj(phase_incr))); - - r.set_phase(gr_complex(1,0)); - r.set_phase_incr(gr_expj(phase_incr)); - - for(unsigned i = 0; i < N; i++) { - gr_complex expected = gr_expj(phase); - gr_complex actual = r.rotate(gr_complex(1, 0)); - -#if 0 - float evm = error_vector_mag(expected, actual); - printf("[%6d] expected: (%8.6f, %8.6f) actual: (%8.6f, %8.6f) evm: %8.6f\n", - i, expected.real(), expected.imag(), actual.real(), actual.imag(), evm); -#endif - - CPPUNIT_ASSERT_COMPLEXES_EQUAL(expected, actual, 0.0001); - - phase += phase_incr; - if(phase >= 2*M_PI) - phase -= 2*M_PI; - } - } - - } /* namespace analog */ -} /* namespace gr */ diff --git a/gnuradio-core/src/lib/general/CMakeLists.txt b/gnuradio-core/src/lib/general/CMakeLists.txt index e3dc18520b..d85039fe60 100644 --- a/gnuradio-core/src/lib/general/CMakeLists.txt +++ b/gnuradio-core/src/lib/general/CMakeLists.txt @@ -22,6 +22,26 @@ ######################################################################## ######################################################################## +# Handle the generated sine table +######################################################################## +add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/sine_table.h + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/gen_sine_table.py + COMMAND ${PYTHON_EXECUTABLE} + ${CMAKE_CURRENT_SOURCE_DIR}/gen_sine_table.py > + ${CMAKE_CURRENT_BINARY_DIR}/sine_table.h +) + +include(AddFileDependencies) +ADD_FILE_DEPENDENCIES(${CMAKE_CURRENT_SOURCE_DIR}/gr_fxpt.cc + ${CMAKE_CURRENT_BINARY_DIR}/sine_table.h +) + +add_custom_target(general_generated DEPENDS + ${CMAKE_CURRENT_BINARY_DIR}/sine_table.h +) + +######################################################################## # Handle the generated constants ######################################################################## execute_process(COMMAND ${PYTHON_EXECUTABLE} -c @@ -50,9 +70,11 @@ list(APPEND gnuradio_core_sources ${CMAKE_CURRENT_BINARY_DIR}/gr_constants.cc) list(APPEND gnuradio_core_sources ${CMAKE_CURRENT_SOURCE_DIR}/gr_circular_file.cc ${CMAKE_CURRENT_SOURCE_DIR}/gr_fast_atan2f.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gr_fxpt.cc ${CMAKE_CURRENT_SOURCE_DIR}/gr_misc.cc ${CMAKE_CURRENT_SOURCE_DIR}/gr_random.cc ${CMAKE_CURRENT_SOURCE_DIR}/gr_reverse.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gr_sincos.c ${CMAKE_CURRENT_SOURCE_DIR}/gri_debugger_hook.cc ${CMAKE_CURRENT_SOURCE_DIR}/malloc16.c ) @@ -63,7 +85,11 @@ list(APPEND gnuradio_core_sources list(APPEND test_gnuradio_core_sources ${CMAKE_CURRENT_SOURCE_DIR}/qa_general.cc ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_circular_file.cc + ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_fxpt.cc + ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_fxpt_nco.cc + ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_fxpt_vco.cc ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_math.cc + ${CMAKE_CURRENT_SOURCE_DIR}/qa_sincos.cc ) ######################################################################## @@ -73,15 +99,20 @@ install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/gr_core_api.h ${CMAKE_CURRENT_SOURCE_DIR}/gr_circular_file.h ${CMAKE_CURRENT_SOURCE_DIR}/gr_constants.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_endianness.h ${CMAKE_CURRENT_SOURCE_DIR}/gr_expj.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_fxpt.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_fxpt_nco.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_fxpt_vco.h ${CMAKE_CURRENT_SOURCE_DIR}/gr_math.h ${CMAKE_CURRENT_SOURCE_DIR}/gr_misc.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_nco.h ${CMAKE_CURRENT_SOURCE_DIR}/gr_random.h ${CMAKE_CURRENT_SOURCE_DIR}/gr_reverse.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_sincos.h ${CMAKE_CURRENT_SOURCE_DIR}/gr_test_types.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_vco.h ${CMAKE_CURRENT_SOURCE_DIR}/gri_debugger_hook.h - ${CMAKE_CURRENT_SOURCE_DIR}/gri_lfsr_15_1_0.h - ${CMAKE_CURRENT_SOURCE_DIR}/gri_lfsr_32k.h ${CMAKE_CURRENT_SOURCE_DIR}/malloc16.h ${CMAKE_CURRENT_SOURCE_DIR}/random.h DESTINATION ${GR_INCLUDE_DIR}/gnuradio @@ -105,39 +136,11 @@ endif(ENABLE_PYTHON) ######################################################################## set(gr_core_general_triple_threats complex_vec_test - gr_align_on_samplenumbers_ss gr_block_gateway - gr_check_counting_s - gr_check_lfsr_32k_s - gr_copy - gr_endian_swap - gr_fake_channel_coder_pp gr_feval - gr_head - gr_iqcomp_cc - gr_kludge_copy - gr_lfsr_32k_source_s - gr_nop - gr_null_sink - gr_null_source - gr_pa_2x2_phase_combiner gr_prefs - gr_skiphead gr_test - gr_vector_map - gr_annotator_alltoall - gr_annotator_1to1 - gr_annotator_raw -) - -if(ENABLE_GR_CTRLPORT) -ADD_DEFINITIONS(-DGR_CTRLPORT) -list(APPEND gr_core_general_triple_threats - gr_ctrlport_probe_c - gr_ctrlport_probe2_c ) -endif(ENABLE_GR_CTRLPORT) - foreach(file_tt ${gr_core_general_triple_threats}) list(APPEND gnuradio_core_sources ${CMAKE_CURRENT_SOURCE_DIR}/${file_tt}.cc) @@ -146,3 +149,11 @@ foreach(file_tt ${gr_core_general_triple_threats}) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${file_tt}.i DESTINATION ${GR_INCLUDE_DIR}/gnuradio/swig COMPONENT "core_swig") endif(ENABLE_PYTHON) endforeach(file_tt ${gr_core_general_triple_threats}) + +CHECK_CXX_SOURCE_COMPILES(" + #define _GNU_SOURCE + #include <math.h> + int main(){double x, sin, cos; sincos(x, &sin, &cos); return 0;} + " HAVE_SINCOS +) +GR_ADD_COND_DEF(HAVE_SINCOS) diff --git a/gnuradio-core/src/lib/general/README b/gnuradio-core/src/lib/general/README deleted file mode 100644 index 5fa18d7f64..0000000000 --- a/gnuradio-core/src/lib/general/README +++ /dev/null @@ -1,98 +0,0 @@ -Files beginning with Gr* define classes that inherit from VrSigProc. -These are high level signal processing modules that can be glued -together in your signal processing chain. - -All the others are either lower level routines which implement the -functionality of the Gr* modules, but are easier to test (fewer -dependencies), or they are general purpose. - -gr_fir_???.{h,cc}, where ??? are in F, S or C are low level Finite -Impulse Response Filters. These turn out to be where the bulk of the -cycles are burned in many applications. The ??? suffix specifies the -input type, output type and tap type of the arguments. We've -implemented the most frequently used ones. - -[Once upon a time this stuff was done with templates -(gr_fir<iType,oType,tapType>), but this turned out to be a headache. -The code appeared to trigger a bug in GCC where we were getting -multiple definitions of unrelated stuff when we started subclassing -partially specialized templates. It was also not obvious as to to -what combinations of iType, oType and tapType actually worked. We're -now explicit, and the world is a safer place to live...] - -The top level routines for FIR filtering are: - - GrFIRfilterFFF : Float input, Float output, Float taps - -- general purpose - - GrFIRfilterCCF : Complex input, Complex output, Float taps - -- applying real filter to a complex signal - - GrFIRfilterFCC : Float input, Complex output, Complex taps - -- applying complex filter to float input - - GrFIRfilterSCC : Short input, Complex output, Complex taps - -- applying complex filter to short input. Quantizes complex - coefficients to 16 bits and uses MMX or SSE2 as appropriate - - -The combination of down conversion (frequency translation) and channel -selection (filtering) is performed with: - - GrFreqXlatingFIRfilterSFC : Short input, Float taps, Complex baseband output - -- quantizes complex coefficents to 16 bits and uses MMX or - SSE2 (128-bit MMX) as appropriate [optimization to be done]. - - GrFreqXlatingFIRfilterFFC : Float input, Float taps, Complex baseband output - -- 3dnow or SSE as appropriate. - - -[ The stuff described from here down is used to implement the routines - above. This info is only relevant to those who are hacking the internals ] - - -A bit of indirection is involved in selecting the fastest -implementation for any given platform. The lower level classes -gr_fir_FFF.h, gr_fir_CCF, gr_fir_FCC and gr_fir_SCC have i/o -signatures similar to the high level clases above. These -should be considered the abstract base classes that you -work with. Note that they are not actually abstract (they've got a -default implementation; this might be considered a bug), but they -should not be directly instantiated by user code. - -Instead of directly instantiating a gr_fir_FFF, for example, your code -should actually: - - #include <gr_fir_util.h> - - // let the system pick the best implementation for you - gr_fir_FFF *filter = gr_fir_util::create_gr_fir_FFF (my_taps); - -Clear? The same for all the other gr_fir_XXX's. - - - -Performance hacking can be done by subclassing the appropriate -base class. For example, on the x86 platform, there are two -additional classes derived from gr_fir_FFF, gr_fir_FFF_sse and -gr_fir_FFF_3dnow. These classes are then made available to the rest -of the system by virtue of being added to gr_fir_sysconfig_x86.cc, -along with any guards (CPUID checks) needed to ensure that only -compatible code is executed on the current hardware. - - -TO DO ------- - -* Move all the machine specific code to a subdirectory, then have -configure symlink to the right directory. This will allow us to build on -any platform without choking. There is generic code for all routines, -only the machine dependent speedup will be lacking. - -* Add an interface to gr_fir_util that will return a vector of all -valid constructors with descriptive names for each i/o signature. -This will allow the test code and benchmarking code to be blissfully -ignorant of what platform they're running on. The actual building of -the vectors should be done bottom up through the gr_fir_sysconfig -hierarchy. - diff --git a/gnuradio-core/src/lib/general/general.i b/gnuradio-core/src/lib/general/general.i index bcf4392bb4..68b963702c 100644 --- a/gnuradio-core/src/lib/general/general.i +++ b/gnuradio-core/src/lib/general/general.i @@ -22,69 +22,20 @@ %{ -#include <gr_nop.h> -#include <gr_null_sink.h> -#include <gr_null_source.h> -#include <gr_head.h> -#include <gr_skiphead.h> -#include <gr_check_counting_s.h> -#include <gr_lfsr_32k_source_s.h> -#include <gr_check_lfsr_32k_s.h> -#include <gr_align_on_samplenumbers_ss.h> -//#include <gr_endianness.h> -#include <gr_endian_swap.h> -#include <gr_fake_channel_coder_pp.h> -#include <gr_pa_2x2_phase_combiner.h> -#include <gr_kludge_copy.h> #include <gr_prefs.h> #include <gr_constants.h> #include <gr_test_types.h> #include <gr_test.h> #include <gr_feval.h> -#include <gr_copy.h> #include <complex_vec_test.h> -#include <gr_annotator_alltoall.h> -#include <gr_annotator_1to1.h> -#include <gr_annotator_raw.h> -#include <gr_vector_map.h> +#include <gr_endianness.h> %} -%include "gr_nop.i" -%include "gr_null_sink.i" -%include "gr_null_source.i" -%include "gr_head.i" -%include "gr_skiphead.i" -%include "gr_check_counting_s.i" -%include "gr_lfsr_32k_source_s.i" -%include "gr_check_lfsr_32k_s.i" -%include "gr_align_on_samplenumbers_ss.i" -//%include "gr_endianness.i" -%include "gr_endian_swap.i" -%include "gr_fake_channel_coder_pp.i" -%include "gr_pa_2x2_phase_combiner.i" -%include "gr_kludge_copy.i" %include "gr_prefs.i" %include "gr_constants.i" %include "gr_test_types.h" %include "gr_test.i" %include "gr_feval.i" -%include "gr_copy.i" %include "complex_vec_test.i" -%include "gr_annotator_alltoall.i" -%include "gr_annotator_1to1.i" -%include "gr_annotator_raw.i" -%include "gr_vector_map.i" %include "gr_block_gateway.i" - - -#ifdef GR_CTRLPORT - -%{ -#include <gr_ctrlport_probe_c.h> -#include <gr_ctrlport_probe2_c.h> -%} - -%include "gr_ctrlport_probe_c.i" -%include "gr_ctrlport_probe2_c.i" - -#endif /* GR_CTRLPORT */ +%include "gr_endianness.h" diff --git a/gnuradio-core/src/lib/general/general_generated.i b/gnuradio-core/src/lib/general/general_generated.i deleted file mode 100644 index c3f67e0d47..0000000000 --- a/gnuradio-core/src/lib/general/general_generated.i +++ /dev/null @@ -1,26 +0,0 @@ -// -// This file is machine generated. All edits will be overwritten -// -%{ -#include <gr_vector_sink_b.h> -#include <gr_vector_sink_c.h> -#include <gr_vector_sink_f.h> -#include <gr_vector_sink_i.h> -#include <gr_vector_sink_s.h> -#include <gr_vector_source_b.h> -#include <gr_vector_source_c.h> -#include <gr_vector_source_f.h> -#include <gr_vector_source_i.h> -#include <gr_vector_source_s.h> -%} - -%include <gr_vector_sink_b.i> -%include <gr_vector_sink_c.i> -%include <gr_vector_sink_f.i> -%include <gr_vector_sink_i.i> -%include <gr_vector_sink_s.i> -%include <gr_vector_source_b.i> -%include <gr_vector_source_c.i> -%include <gr_vector_source_f.i> -%include <gr_vector_source_i.i> -%include <gr_vector_source_s.i> diff --git a/gnuradio-core/src/lib/general/gr_align_on_samplenumbers_ss.cc b/gnuradio-core/src/lib/general/gr_align_on_samplenumbers_ss.cc deleted file mode 100644 index 4728533964..0000000000 --- a/gnuradio-core/src/lib/general/gr_align_on_samplenumbers_ss.cc +++ /dev/null @@ -1,464 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_align_on_samplenumbers_ss.h> -#include <gr_io_signature.h> -#include <assert.h> -#include <stdexcept> -#include <string.h> -#include <cstdio> - -//define ALIGN_ADVANCED_IMPLEMENTATION to have an alternative implementation of the align algoritm which exactly follows the align_interval spec. -//It is more resource intensive, less tested and probably not needed -//define ALIGN_ADVANCED_IMPLEMENTATION - -//define DEBUG_TOCONSUME to see debug messages about the synchronisation part of this block -//define DEBUG_TOCONSUME -#ifdef DEBUG_TOCONSUME -#define tcPrintf if(dprint) printf -#else -#define tcPrintf //printf -#endif - -#define ePrintf printf - -gr_align_on_samplenumbers_ss_sptr -gr_make_align_on_samplenumbers_ss (int nchan, int align_interval) -{ - return gnuradio::get_initial_sptr(new gr_align_on_samplenumbers_ss (nchan,align_interval)); -} - -gr_align_on_samplenumbers_ss::gr_align_on_samplenumbers_ss (int nchan,int align_interval) - : gr_block ("align_on_samplenumbers_ss", - gr_make_io_signature (2, -1, sizeof (short)), //2, -1 - gr_make_io_signature (2, -1, sizeof (short))), //2,-1 - d_align_interval (align_interval), - d_nchan(nchan), - d_ninputs(0) -{ - if (d_align_interval<0) - set_output_multiple (d_nchan*2); - else - { - set_output_multiple (d_align_interval*d_nchan*2); - } - -} - -gr_align_on_samplenumbers_ss::~gr_align_on_samplenumbers_ss() -{ - -} -void -gr_align_on_samplenumbers_ss::forecast (int noutput_items, gr_vector_int &ninput_items_required) -{ - //assert (0 == noutput_items % d_align_interval); - unsigned ninputs = ninput_items_required.size(); - for (unsigned int i = 0; i < ninputs; i++) - ninput_items_required[i] = std::max(noutput_items*d_nchan*2+ history() - 1,1024*d_nchan*2+ history() - 1);//TODO include the diffs found in determine input_items_required -} - -bool -gr_align_on_samplenumbers_ss::check_topology (int ninputs, int noutputs) -{ - bool result=true; - if(noutputs!=ninputs) - { - result=false; - ePrintf("gr_align_on_samplenumbers_ss: ERROR noutputs %i != ninputs %i\n",noutputs,ninputs); - } - if(d_nchan<2) - { - result=false; - ePrintf("gr_align_on_samplenumbers_ss: ERROR nchan %i<2 \n",d_nchan); - } - if((int)d_ninputs!=ninputs) - { - //Only resize and reset the status if there really changed something - //Don't reset the status if the user just called stop() and start(), although maybe we should. - d_state.resize(ninputs); - d_ninputs=ninputs; - for(unsigned int i=0;i<d_ninputs;i++) - { - d_state[i].sync_found=false; - d_state[i].sync_end_found=false; - } - d_in_presync=false; - } - return result; -} - -#ifdef ALIGN_ADVANCED_IMPLEMENTATION -int -gr_align_on_samplenumbers_ss::general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ -#ifdef DEBUG_TOCONSUME - static int dcount=0; - bool dprint=false; - dcount++; - if(dcount>200) - { - dcount=0; - dprint=true; - } -#endif - const size_t item_size = output_signature()->sizeof_stream_item (0); - const unsigned ninputs = input_items.size(); - const unsigned noutputs = output_items.size(); - - int align_interval=d_align_interval*2*d_nchan; - if(d_align_interval<0) - { - //align once per noutput_items - align_interval=noutput_items; - align_interval=align_interval/(2*d_nchan); - align_interval=align_interval*(2*d_nchan); - } - - int min_ninput_items=noutput_items;//numeric_limits<int>::max(); - int noutput_items_produced=0; - for(unsigned int i=0;i<ninputs;i++) - { - d_state[i].ninput_items=ninput_items[i]; - d_state[i].ninput_items_used=0; - min_ninput_items=std::min(ninput_items[i],min_ninput_items); - } - for(int j=0;j<noutput_items-align_interval+1;j+=align_interval) - { - int common_end; - if(min_ninput_items>=align_interval) - common_end=align_interval; - else - { - common_end=min_ninput_items/(d_nchan*2); - common_end=common_end*(d_nchan*2); - } - if (common_end<=0) break; - - bool all_diffs_zero=true; - //bool sync_found=false; - int diff_comp_end_max=0; - for(unsigned int i=0;i<ninputs;i++) - { - unsigned short * uin=&(((unsigned short*)input_items[i])[d_state[i].ninput_items_used]); - unsigned int x_high16bits = uin[0]; - unsigned int x_low16bits = uin[1]; - d_state[i].ucounter_begin = x_high16bits<<16 | x_low16bits; - d_state[i].diff=d_state[0].ucounter_begin-d_state[i].ucounter_begin;//Result is a signed value,Will wrap around on 32 bit boundary - int common_last=std::max(common_end-d_nchan*2,0); - x_high16bits = uin[d_nchan*2]; - x_low16bits = uin[d_nchan*2+1]; - unsigned int ucounter_begin2 = x_high16bits<<16 | x_low16bits; -#ifdef DEBUG_TOCONSUME - if((d_state[i].ucounter_begin+1)!=(ucounter_begin2)) - if(ucounter_begin2==0) - ePrintf("SYNC counters are 0\n"); - else - ePrintf("Error: counter not continuous.\n ucounter_begin[%i]=%i +1 != ucounter_begin2=%i\n",i,d_state[i].ucounter_begin,ucounter_begin2); -#endif - x_high16bits = uin[common_last]; - x_low16bits = uin[common_last+1]; - d_state[i].ucounter_end = x_high16bits<<16 | x_low16bits; - d_state[i].diff_end=d_state[0].ucounter_end-d_state[i].ucounter_end;//Result is a signed value,Will wrap around on 32 bit boundary - d_state[i].diff_comp_end=d_state[i].ucounter_end-d_state[0].ucounter_end; - diff_comp_end_max=std::max(d_state[i].diff_comp_end,diff_comp_end_max); -#ifdef DEBUG_TOCONSUME - if(d_state[i].diff>256000000 || d_state[i].diff_end>256000000 || d_state[i].diff_comp_end>256000000) - { - tcPrintf("diff[%i]=%i diff_end=%i diff_comp_end=%i\n",i,d_state[i].diff,d_state[i].diff_end,d_state[i].diff_comp_end); - } -#endif - all_diffs_zero=all_diffs_zero && (0==d_state[i].diff_end); - if(d_state[i].ucounter_end<d_state[i].ucounter_begin+(unsigned)(common_last/(d_nchan*2))) //(unsigned)(common_last/(d_nchan*2))) - { - //printf("sync 1 ");// found ucounter_end[%i]=%i ucounter_begin[%i]=%i \n",i,d_state[i].ucounter_end,i,d_state[i].ucounter_begin); - //sync_found=true;//sync_found or 32 bit counter wraparound (0xffffffff -> 0x00000000) - if(!d_in_presync) - { -#ifdef DEBUG_TOCONSUME - printf("presync START with %i\n",i); -#endif - for(unsigned int k=0;k<ninputs;k++) - { - d_state[k].sync_found=false; - d_state[i].sync_end_found=false; - } - d_in_presync=true; - d_state[i].sync_found=true; - } else - { - //d_in_presync=true; -#ifdef DEBUG_TOCONSUME - if(d_state[i].sync_found) - printf("presync CONTINUE with %i\n",i); - else - printf("presync NEXT with %i\n",i); -#endif - d_state[i].sync_found=true; - d_state[i].sync_end_found=false; - } - } else - { - if(d_in_presync && d_state[i].sync_found) - { - d_state[i].sync_end_found=true; - bool all_syncs_found=true; - for(unsigned int k=0;k<ninputs;k++) - all_syncs_found=all_syncs_found && d_state[k].sync_end_found; - d_in_presync=!all_syncs_found; - if(!d_in_presync) - { - for(unsigned int k=0;k<ninputs;k++) - { - d_state[k].sync_found=false; - d_state[i].sync_end_found=false; - } -#ifdef DEBUG_TOCONSUME - printf("presync END\n"); -#endif - } - } - } - } - if(d_in_presync || all_diffs_zero) - { - for(unsigned int i=0;i<ninputs;i++) - { - memcpy(&(((unsigned short*)output_items[i])[j]),&(((const unsigned short*)input_items[i])[d_state[i].ninput_items_used]),common_end*item_size); - //consume(i,common_end); - d_state[i].ninput_items-=common_end; - d_state[i].ninput_items_used+=common_end; - min_ninput_items=std::min(d_state[i].ninput_items,min_ninput_items); -#ifdef DEBUG_TOCONSUME - if(common_end<256) - tcPrintf("common_end %i\n",common_end); -#endif - } - //min_ninput_items-=common_end; - noutput_items_produced+=common_end; - //return common_end; - } else - { - //printf("sync 2"); - for(unsigned int i=0;i<ninputs;i++) - { - int toconsume=std::min((d_state[i].diff_end+diff_comp_end_max)*d_nchan*2,d_state[i].ninput_items); - toconsume=toconsume/(d_nchan*2); - toconsume=toconsume*(d_nchan*2); - d_state[i].ninput_items-=toconsume; - d_state[i].ninput_items_used+=toconsume; - min_ninput_items=std::min(d_state[i].ninput_items,min_ninput_items); -#ifdef DEBUG_TOCONSUME - static int toconsume_counter=0; - toconsume_counter++; - //if(toconsume_counter>10) - { - tcPrintf("toconsume=%i diff_end[%i]*d_nchan*2=%i diff_comp_end_max*d_nchan*2=%i ninput_items[%i]=%i\n",toconsume,i,d_state[i].diff_end*d_nchan*2,diff_comp_end_max*d_nchan*2,i,ninput_items[i]); - toconsume_counter=0; - } -#endif - //printf("toconsume[%i]=%i\n",i,toconsume); - //consume(i,toconsume);//skip the difference in samplenumber items - } - //return 0; - } - } - for(unsigned int i=0;i<ninputs;i++) - consume(i,d_state[i].ninput_items_used); -#ifdef DEBUG_TOCONSUME - if(noutput_items_produced<256) - tcPrintf("noutput_items_produced %i\n",noutput_items_produced); -#endif - return noutput_items_produced; -} - - -#else /*ALIGN_ADVANCED_IMPLEMENTATION*/ -int -gr_align_on_samplenumbers_ss::general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ -#ifdef DEBUG_TOCONSUME - static int dcount=0; - bool dprint=false; - dcount++; - if(dcount>2000) - { - dcount=0; - dprint=true; - } -#endif - const size_t item_size = output_signature()->sizeof_stream_item (0); - const unsigned ninputs = input_items.size(); - - int common_end=noutput_items; - //int diff_min=INT_MAX; - //int diff_max=INT_MIN; - for(unsigned int i=0;i<ninputs;i++) - { - unsigned short * uin=(unsigned short*)input_items[i]; - unsigned int x_high16bits = uin[0]; - unsigned int x_low16bits = uin[1]; - d_state[i].ucounter_begin = x_high16bits<<16 | x_low16bits; - d_state[i].diff=d_state[0].ucounter_end-d_state[i].ucounter_end;//Result is a signed value,Will wrap around on 32 bit boundary - x_high16bits = uin[d_nchan*2]; - x_low16bits = uin[d_nchan*2+1]; - unsigned int ucounter_begin2 = x_high16bits<<16 | x_low16bits; - if((d_state[i].ucounter_begin+1)!=(ucounter_begin2)){ - if(ucounter_begin2==0) - { -#ifdef DEBUG_TOCONSUME - ePrintf("SYNC counters are 0\n"); -#endif - } - else - { - ePrintf("Error: counter not continuous.\n ucounter_begin[%i]=%i +1 != ucounter_begin2=%i\n",i,d_state[i].ucounter_begin,ucounter_begin2); - } - } - - //diff_comp[i]=ucounter[i]-ucounter[0]; - //diff_min=std::min(diff[i],diff_min); - //diff_max=std::max(diff[i],diff_max); - common_end=std::max(std::min(ninput_items[i],common_end),0); - } - common_end=common_end/(d_nchan*2); - common_end=common_end*(d_nchan*2); -#ifdef DEBUG_TOCONSUME - if(common_end<d_nchan*2) - { - printf(" common_end %i\n",common_end); - for(int j=0;j<ninputs;j++) - printf("ninput_items[%i]=%i\n",j,ninput_items[j]); - } -#endif - bool all_diffs_zero=true; - bool sync_found=false; - int diff_comp_end_max=0; - for(unsigned int i=0;i<ninputs;i++) - { - unsigned short * uin=(unsigned short*)input_items[i]; - int common_last=common_end-(d_nchan*2); - unsigned int x_high16bits = uin[common_last]; - unsigned int x_low16bits = uin[common_last+1]; - d_state[i].ucounter_end = x_high16bits<<16 | x_low16bits; - d_state[i].diff_end=d_state[0].ucounter_end-d_state[i].ucounter_end;//Result is a signed value,Will wrap around on 32 bit boundary - d_state[i].diff_comp_end=d_state[i].ucounter_end-d_state[0].ucounter_end; - //diff_end_min=std::min(diff_end[i],diff_end_min); - //diff_end_max=std::max(diff_end[i],diff_end_max); - diff_comp_end_max=std::max(d_state[i].diff_comp_end,diff_comp_end_max); -#ifdef DEBUG_TOCONSUME - if(d_state[i].diff_end!=d_state[i].diff) - { - //samples_lost_or_syncstart=true; - printf("Us%i %i %i ",i,d_state[i].diff_end,d_state[i].diff); - } -#endif - all_diffs_zero=all_diffs_zero && (0==d_state[i].diff_end); - if((d_state[i].ucounter_end<d_state[i].ucounter_begin+(unsigned)(common_last/(d_nchan*2))) || (0==d_state[i].ucounter_end) || (0==d_state[i].ucounter_begin)) //(unsigned)(common_last/(d_nchan*2))) - { - sync_found=true;//sync_found or 32 bit counter wraparound (0xffffffff -> 0x00000000) -#ifdef DEBUG_TOCONSUME - tcPrintf("SYNC diff_end[%i]=%i ucounter_end[%i]=%i ucounter_begin[%i]=%i \n",i,d_state[i].diff_end,i,d_state[i].ucounter_end,i,d_state[i].ucounter_begin); - tcPrintf("ucounter_end=%i < %i = ucounter_begin+(unsigned)(common_last/(d_nchan*2) \n",d_state[i].ucounter_end,d_state[i].ucounter_begin+(unsigned)(common_last/(d_nchan*2))); - - printf("ucounter_end[%i]=%i ucounter_begin[%i]=%i\n",i,d_state[i].ucounter_end,i,d_state[i].ucounter_begin); - int expected_sync_position=common_last - d_state[i].ucounter_end*(d_nchan*2); - if(0==uin[expected_sync_position] && 0==uin[expected_sync_position+1]) - { - printf("sync found on input %i at position %i \n",i,expected_sync_position); - //sync_start[i]=expected_sync_position; - } else - { - printf("sync found on input %i position unclear, expected at %i value there %i\n",i,expected_sync_position,uin[expected_sync_position]<<16 | uin[expected_sync_position+1]); - //sync_start[i]=-1; - } - } else - { - tcPrintf("NOsync diff_end[%i]=%i ucounter_end[%i]=%i ucounter_begin[%i]=%i \n",i,d_state[i].diff_end,i,d_state[i].ucounter_end,i,d_state[i].ucounter_begin); -#endif - } - } - bool problem=false; - for(unsigned int i=0;i<ninputs;i++) - if((d_state[i].diff_end+diff_comp_end_max) >0x4000000) - { - problem=true; - ePrintf("Warning: counter diff greater as 64 Million\n"); - ePrintf(" You might want to swap master and slave.\n"); - ePrintf(" i=%i,d_state[i].diff_end+diff_comp_end_max=%i,d_state[i].diff_end=%i,diff_comp_end_max=%i,ucounter[i]=%i,ucounter[0]=%i\n", - i,d_state[i].diff_end+diff_comp_end_max,d_state[i].diff_end,diff_comp_end_max,d_state[i].ucounter_end,d_state[0].ucounter_end); - //ePrintf(" toconsume=%i\n",toconsume); - } - if(sync_found || all_diffs_zero || problem) - { -#ifdef DEBUG_TOCONSUME - if(all_diffs_zero) tcPrintf("ZERO\n"); - if(sync_found) tcPrintf("SYNC\n"); -#endif - for(unsigned int i=0;i<ninputs;i++) - { - memcpy(output_items[i],input_items[i],common_end*item_size); - consume(i,common_end); -#ifdef DEBUG_TOCONSUME - if(common_end<256) - tcPrintf("common_end %i\n",common_end); -#endif - } - return common_end; - } else - { - //int minconsume=0;//common_end/(2*d_nchan*2); - //min_consume=min_consume*d_nchan*2; - for(unsigned int i=0;i<ninputs;i++) - { - int toconsume=std::min((d_state[i].diff_end+diff_comp_end_max)*d_nchan*2,ninput_items[i]); - toconsume=toconsume/(d_nchan*2); - toconsume=toconsume*(d_nchan*2); -#ifdef DEBUG_TOCONSUME - //printf("dcount %i\n",dcount); - static int toconsume_counter=0; - toconsume_counter++; - //if(toconsume_counter>10) - { - tcPrintf("toconsume=%i diff_end[[%i]*d_nchan*2=%i diff_comp_end_max)*d_nchan*2=%i ninput_items[%i]=%i\n", - toconsume,i,d_state[i].diff_end*d_nchan*2,diff_comp_end_max*d_nchan*2,i,ninput_items[i]); - toconsume_counter=0; - } -#endif - consume(i,toconsume);//skip the difference in samplenumber items - //printf("toconsume%i %i diff_comp_end_max %i diff_end[[%i] %i\n",i,toconsume,diff_comp_end_max,i,d_state[i].diff_end); - } - return 0; - } - return -1;//Should never come here -} -#endif /*ALIGN_ADVANCED_IMPLEMENTATION*/ diff --git a/gnuradio-core/src/lib/general/gr_align_on_samplenumbers_ss.h b/gnuradio-core/src/lib/general/gr_align_on_samplenumbers_ss.h deleted file mode 100644 index 1b71a3f4bc..0000000000 --- a/gnuradio-core/src/lib/general/gr_align_on_samplenumbers_ss.h +++ /dev/null @@ -1,92 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 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_ALIGN_ON_SAMPLE_NUMBERS_SS_H -#define INCLUDED_GR_ALIGN_ON_SAMPLE_NUMBERS_SS_H - -#include <gr_core_api.h> -#include <gr_block.h> - -/*! - * \brief align several complex short (interleaved short) input channels with corresponding unsigned 32 bit sample_counters (provided as interleaved 16 bit values) - * \ingroup misc - * \param number of complex_short input channels (including the 32 bit counting channel) - * \param align_interval is after how much samples (minimally) the sample-alignement is refreshed. Default is 128. - * A bigger value means less processing power but also requests more buffer space, which has a maximum. - * Decrease the align_interval if you get an error like: - * "sched: <gr_block align_on_samplenumbers_ss (0)> is requesting more input data than we can provide. - * ninput_items_required = 32768 - * max_possible_items_available = 16383 - * If this is a filter, consider reducing the number of taps." - * \ingroup block - * Pay attention on how you connect this block. - * It expects a minimum of 2 usrp_source_s with nchan number of channels and FPGA_MODE_COUNTING_32BIT enabled. - * This means that the first complex_short channel on every input is an interleaved 32 bit counter. - * The samples are aligned by dropping samples untill the samplenumbers match. - */ -class gr_align_on_samplenumbers_ss; -typedef boost::shared_ptr<gr_align_on_samplenumbers_ss> gr_align_on_samplenumbers_ss_sptr; - -GR_CORE_API gr_align_on_samplenumbers_ss_sptr gr_make_align_on_samplenumbers_ss (int nchan=2, int align_interval=128); - - - - -class GR_CORE_API gr_align_on_samplenumbers_ss : public gr_block -{ - int d_align_interval; - int d_sample_counter; - int d_nchan; - bool d_in_presync; - unsigned int d_ninputs; - class GR_CORE_API align_state { - public: - unsigned int ucounter_end; - unsigned int ucounter_begin; - int diff; - int diff_comp; - int diff_end; - int diff_comp_end; - bool sync_found; - bool sync_end_found; - int ninput_items; - int ninput_items_used; - }; - std::vector<align_state> d_state; - - friend GR_CORE_API gr_align_on_samplenumbers_ss_sptr gr_make_align_on_samplenumbers_ss (int nchan,int align_interval); - gr_align_on_samplenumbers_ss (int nchan,int align_interval); - - public: - ~gr_align_on_samplenumbers_ss(); - bool check_topology (int ninputs, int noutputs); - void forecast (int noutput_items, - gr_vector_int &ninput_items_required); - - int general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - - -#endif /* INCLUDED_GR_ALIGN_ON_SAMPLE_NUMBERS_SS_H */ 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 deleted file mode 100644 index 471f743010..0000000000 --- a/gnuradio-core/src/lib/general/gr_align_on_samplenumbers_ss.i +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 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,align_on_samplenumbers_ss); - -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 -{ - public: - ~gr_align_on_samplenumbers_ss (); - private: - gr_align_on_samplenumbers_ss (int nchan,int align_interval); -}; diff --git a/gnuradio-core/src/lib/general/gr_annotator_1to1.cc b/gnuradio-core/src/lib/general/gr_annotator_1to1.cc deleted file mode 100644 index 1178bdc34f..0000000000 --- a/gnuradio-core/src/lib/general/gr_annotator_1to1.cc +++ /dev/null @@ -1,107 +0,0 @@ -/* -*- 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<gr_tag_t> all_tags; - get_tags_in_range(all_tags, i, abs_N, abs_N + noutput_items); - - std::vector<gr_tag_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::string_to_symbol(str.str()); - pmt::pmt_t key = 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::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 deleted file mode 100644 index 57e5720141..0000000000 --- a/gnuradio-core/src/lib/general/gr_annotator_1to1.h +++ /dev/null @@ -1,75 +0,0 @@ -/* -*- 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_core_api.h> -#include <gr_sync_block.h> - -class gr_annotator_1to1; -typedef boost::shared_ptr<gr_annotator_1to1> gr_annotator_1to1_sptr; - -// public constructor -GR_CORE_API 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_CORE_API 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<gr_tag_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<gr_tag_t> d_stored_tags; - - friend GR_CORE_API 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 deleted file mode 100644 index 2637b8d277..0000000000 --- a/gnuradio-core/src/lib/general/gr_annotator_1to1.i +++ /dev/null @@ -1,25 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010-2011 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,annotator_1to1); - -%include <gr_annotator_1to1.h> diff --git a/gnuradio-core/src/lib/general/gr_annotator_alltoall.cc b/gnuradio-core/src/lib/general/gr_annotator_alltoall.cc deleted file mode 100644 index d8b7e2db7e..0000000000 --- a/gnuradio-core/src/lib/general/gr_annotator_alltoall.cc +++ /dev/null @@ -1,110 +0,0 @@ -/* -*- 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<gr_tag_t> all_tags; - get_tags_in_range(all_tags, i, abs_N, end_N); - - std::vector<gr_tag_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::string_to_symbol(str.str()); - pmt::pmt_t key = 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::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 deleted file mode 100644 index deb5874a49..0000000000 --- a/gnuradio-core/src/lib/general/gr_annotator_alltoall.h +++ /dev/null @@ -1,76 +0,0 @@ -/* -*- 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_core_api.h> -#include <gr_sync_block.h> - -class gr_annotator_alltoall; -typedef boost::shared_ptr<gr_annotator_alltoall> gr_annotator_alltoall_sptr; - -// public constructor -GR_CORE_API 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_CORE_API 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<gr_tag_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<gr_tag_t> d_stored_tags; - - friend GR_CORE_API 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 deleted file mode 100644 index 35190a3d1b..0000000000 --- a/gnuradio-core/src/lib/general/gr_annotator_alltoall.i +++ /dev/null @@ -1,25 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010-2011 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,annotator_alltoall); - -%include <gr_annotator_alltoall.h> diff --git a/gnuradio-core/src/lib/general/gr_annotator_raw.cc b/gnuradio-core/src/lib/general/gr_annotator_raw.cc deleted file mode 100644 index c3aecdd938..0000000000 --- a/gnuradio-core/src/lib/general/gr_annotator_raw.cc +++ /dev/null @@ -1,106 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_annotator_raw.h> -#include <gr_io_signature.h> -#include <string.h> -#include <iostream> -#include <iomanip> -#include <stdexcept> - -using namespace pmt; - -gr_annotator_raw_sptr -gr_make_annotator_raw(size_t sizeof_stream_item) -{ - return gnuradio::get_initial_sptr(new gr_annotator_raw - (sizeof_stream_item)); -} - -gr_annotator_raw::gr_annotator_raw(size_t sizeof_stream_item) - : gr_sync_block("annotator_raw", - gr_make_io_signature(1, 1, sizeof_stream_item), - gr_make_io_signature(1, 1, sizeof_stream_item)), - d_itemsize(sizeof_stream_item) -{ - set_tag_propagation_policy(TPP_ONE_TO_ONE); - set_relative_rate(1.0); -} - -void gr_annotator_raw::add_tag(uint64_t offset, pmt_t key, pmt_t val) -{ - gruel::scoped_lock l(d_mutex); - - gr_tag_t tag; - tag.srcid = pmt::intern(name()); - tag.key = key; - tag.value = val; - tag.offset = offset; - - // add our new tag - d_queued_tags.push_back(tag); - // make sure our tags are in offset order - std::sort(d_queued_tags.begin(), d_queued_tags.end(), - gr_tag_t::offset_compare); - // make sure we are not adding an item in the past! - if(tag.offset > nitems_read(0)) { - throw std::runtime_error("gr_annotator_raw::add_tag: item added too far in the past\n."); - } -} - -gr_annotator_raw::~gr_annotator_raw() -{ -} - -int -gr_annotator_raw::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - gruel::scoped_lock l(d_mutex); - - const char *in = (const char*)input_items[0]; - char *out = (char*)output_items[0]; - - uint64_t start_N = nitems_read(0); - uint64_t end_N = start_N + (uint64_t)(noutput_items); - - // locate queued tags that fall in this range and insert them when appropriate - std::vector<gr_tag_t>::iterator i = d_queued_tags.begin(); - while( i != d_queued_tags.end() ) { - if( (*i).offset >= start_N && (*i).offset < end_N) { - add_item_tag(0, (*i).offset,(*i).key, (*i).value, (*i).srcid); - i = d_queued_tags.erase(i); - } - else { - break; - } - } - - // copy data across - memcpy(out, in, noutput_items*d_itemsize); - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_annotator_raw.h b/gnuradio-core/src/lib/general/gr_annotator_raw.h deleted file mode 100644 index 02d0619081..0000000000 --- a/gnuradio-core/src/lib/general/gr_annotator_raw.h +++ /dev/null @@ -1,69 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_ANNOTATOR_RAW_H -#define INCLUDED_GR_ANNOTATOR_RAW_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <gr_tags.h> -#include <gruel/thread.h> - -class gr_annotator_raw; -typedef boost::shared_ptr<gr_annotator_raw> gr_annotator_raw_sptr; - -// public constructor -GR_CORE_API gr_annotator_raw_sptr -gr_make_annotator_raw(size_t sizeof_stream_item); - -/*! - * \brief raw stream annotator testing block. - * - * This block creates arbitrary tags to be sent downstream - * blocks to be sent are set manually via accessor methods and are sent only once. - * - * This block is intended for testing of tag related blocks - */ -class GR_CORE_API gr_annotator_raw : public gr_sync_block -{ - public: - ~gr_annotator_raw(); - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - // insert a tag to be added - void add_tag(uint64_t offset, pmt::pmt_t key, pmt::pmt_t val); - -protected: - gr_annotator_raw(size_t sizeof_stream_item); - - private: - size_t d_itemsize; - std::vector<gr_tag_t> d_queued_tags; - gruel::mutex d_mutex; - - friend GR_CORE_API gr_annotator_raw_sptr - gr_make_annotator_raw(size_t sizeof_stream_item); -}; - -#endif diff --git a/gnuradio-core/src/lib/general/gr_annotator_raw.i b/gnuradio-core/src/lib/general/gr_annotator_raw.i deleted file mode 100644 index 4a58fe7c79..0000000000 --- a/gnuradio-core/src/lib/general/gr_annotator_raw.i +++ /dev/null @@ -1,26 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010-2011 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,annotator_raw); - -%include <gr_tags.i> -%include <gr_annotator_raw.h> diff --git a/gnuradio-core/src/lib/general/gr_check_counting_s.cc b/gnuradio-core/src/lib/general/gr_check_counting_s.cc deleted file mode 100644 index c3288f4813..0000000000 --- a/gnuradio-core/src/lib/general/gr_check_counting_s.cc +++ /dev/null @@ -1,190 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_check_counting_s.h> -#include <gr_io_signature.h> -#include <stdlib.h> -#include <stdio.h> - -gr_check_counting_s_sptr -gr_make_check_counting_s (bool do_32bit) -{ - return gnuradio::get_initial_sptr(new gr_check_counting_s (do_32bit)); -} - -gr_check_counting_s::gr_check_counting_s (bool do_32bit) - : gr_sync_block ("gr_check_counting", - gr_make_io_signature (1, 1, sizeof (short)), - gr_make_io_signature (0, 0, 0)), - d_state(SEARCHING), d_history (0), d_current_count (0), d_current_count_32bit(0), - d_total_errors (0), d_total_shorts (0), - d_do_32bit(do_32bit) -{ - enter_SEARCHING (); -} - -int -gr_check_counting_s::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - unsigned short *in = (unsigned short *) input_items[0]; - if(d_do_32bit) - return check_32bit(noutput_items,in); - else - return check_16bit(noutput_items,in); -} - -int -gr_check_counting_s::check_16bit (int noutput_items, - unsigned short * in) -{ - for (int i = 0; i < noutput_items; i++){ - unsigned short x = in[i]; - - switch (d_state){ - - case SEARCHING: - if (x == d_current_count){ - right (); - log_error (d_current_count, x); - d_current_count = d_current_count + 1; - if (right_three_times ()) - enter_LOCKED (); - } - else { - wrong (); - log_error (d_current_count, x); - d_current_count = x + 1; - } - break; - - case LOCKED: - if (x == d_current_count){ - right (); - d_current_count = d_current_count + 1; - } - else { - wrong (); - log_error (d_current_count, x); - d_current_count = d_current_count + 1; - if (wrong_three_times ()) - enter_SEARCHING (); - } - break; - - default: - abort (); - } - - d_total_shorts++; - } - - return noutput_items; -} - -int -gr_check_counting_s::check_32bit (int noutput_items, - unsigned short * in) -{ - - for (int i = 0; i < noutput_items-1; i+=2){ - unsigned int x_high16bits = in[i]; - unsigned int x_low16bits = in[i+1]; - unsigned int x = x_high16bits<<16 | x_low16bits; - - switch (d_state){ - - case SEARCHING: - if (x == d_current_count_32bit){ - right (); - log_error_32bit (d_current_count_32bit, x); - d_current_count_32bit = d_current_count_32bit + 1; - if (right_three_times ()) - enter_LOCKED (); - } - else { - wrong (); - log_error_32bit (d_current_count_32bit, x); - d_current_count_32bit = x + 1; - } - break; - - case LOCKED: - if (x == d_current_count_32bit){ - right (); - d_current_count_32bit = d_current_count_32bit + 1; - } - else { - wrong (); - log_error_32bit (d_current_count_32bit, x); - d_current_count_32bit = d_current_count_32bit + 1; - if (wrong_three_times ()) - enter_SEARCHING (); - } - break; - - default: - abort (); - } - - d_total_shorts++; - } - - return noutput_items; -} - -void -gr_check_counting_s::enter_SEARCHING () -{ - d_state = SEARCHING; - fprintf (stdout, "gr_check_counting: enter_SEARCHING at offset %8ld (0x%08lx)\n", - d_total_shorts, d_total_shorts); -} - -void -gr_check_counting_s::enter_LOCKED () -{ - d_state = LOCKED; - fprintf (stdout, "gr_check_counting: enter_LOCKED at offset %8ld (0x%08lx)\n", - d_total_shorts, d_total_shorts); -} - -void -gr_check_counting_s::log_error (unsigned short expected, unsigned short actual) -{ - fprintf (stdout, -"gr_check_counting: expected %5d (0x%04x) got %5d (0x%04x) offset %8ld (0x%08lx)\n", - expected, expected, actual, actual, d_total_shorts, d_total_shorts); -} - -void -gr_check_counting_s::log_error_32bit (unsigned int expected, unsigned int actual) -{ - fprintf (stdout, -"gr_check_counting: expected %10d (0x%08x) got %10d (0x%08x) offset %8ld (0x%08lx)\n", - expected, expected, actual, actual, d_total_shorts, d_total_shorts); -} diff --git a/gnuradio-core/src/lib/general/gr_check_counting_s.h b/gnuradio-core/src/lib/general/gr_check_counting_s.h deleted file mode 100644 index 996fa3259f..0000000000 --- a/gnuradio-core/src/lib/general/gr_check_counting_s.h +++ /dev/null @@ -1,89 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef INCLUDED_GR_CHECK_COUNTING_S_H -#define INCLUDED_GR_CHECK_COUNTING_S_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gr_check_counting_s; -typedef boost::shared_ptr<gr_check_counting_s> gr_check_counting_s_sptr; - -GR_CORE_API gr_check_counting_s_sptr gr_make_check_counting_s (bool do_32bit=false); - -/*! - * \brief sink that checks if its input stream consists of a counting sequence. - * \param do_32bit expect an interleaved 32 bit counter in stead of 16 bit counter (default false) - * \ingroup sink_blk - * - * This sink is typically used to test the USRP "Counting Mode" or "Counting mode 32 bit". - */ -class GR_CORE_API gr_check_counting_s : public gr_sync_block -{ - friend GR_CORE_API gr_check_counting_s_sptr gr_make_check_counting_s (bool do_32bit); - - enum state { - SEARCHING, // searching for synchronization - LOCKED // is locked - }; - - state d_state; - unsigned int d_history; // bitmask of decisions - unsigned short d_current_count; - unsigned int d_current_count_32bit; - - long d_total_errors; - long d_total_shorts; - bool d_do_32bit; - - gr_check_counting_s (bool do_32bit); - - void enter_SEARCHING (); - void enter_LOCKED (); - - void right (){ - d_history = (d_history << 1) | 0x1; - } - - void wrong (){ - d_history = (d_history << 1) | 0x0; - d_total_errors++; - } - - bool right_three_times () { return (d_history & 0x7) == 0x7; } - bool wrong_three_times () { return (d_history & 0x7) == 0x0; } - - void log_error (unsigned short expected, unsigned short actual); - void log_error_32bit (unsigned int expected, unsigned int actual); - - int check_32bit (int noutput_items, unsigned short * in); - int check_16bit (int noutput_items, unsigned short * in); - - public: - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - - -#endif /* INCLUDED_GR_CHECK_COUNTING_S_H */ diff --git a/gnuradio-core/src/lib/general/gr_check_counting_s.i b/gnuradio-core/src/lib/general/gr_check_counting_s.i deleted file mode 100644 index 0275dad9db..0000000000 --- a/gnuradio-core/src/lib/general/gr_check_counting_s.i +++ /dev/null @@ -1,31 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,check_counting_s) - -gr_check_counting_s_sptr gr_make_check_counting_s (bool do_32bit=false); - -class gr_check_counting_s : public gr_sync_block -{ - private: - gr_check_counting_s (bool do_32bit); -}; diff --git a/gnuradio-core/src/lib/general/gr_check_lfsr_32k_s.cc b/gnuradio-core/src/lib/general/gr_check_lfsr_32k_s.cc deleted file mode 100644 index 088b8c38ae..0000000000 --- a/gnuradio-core/src/lib/general/gr_check_lfsr_32k_s.cc +++ /dev/null @@ -1,169 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_check_lfsr_32k_s.h> -#include <gr_io_signature.h> -#include <stdlib.h> -#include <stdio.h> - -gr_check_lfsr_32k_s_sptr -gr_make_check_lfsr_32k_s () -{ - return gnuradio::get_initial_sptr(new gr_check_lfsr_32k_s ()); -} - -gr_check_lfsr_32k_s::gr_check_lfsr_32k_s () - : gr_sync_block ("gr_check_lfsr_32k", - gr_make_io_signature (1, 1, sizeof (short)), - gr_make_io_signature (0, 0, 0)), - d_state(SEARCHING), d_history (0), d_ntotal (0), d_nright (0), - d_runlength (0), d_index(0) -{ - gri_lfsr_32k lfsr; - - for (int i = 0; i < BUFSIZE; i++) - d_buffer[i] = lfsr.next_short (); - - enter_SEARCHING (); -} - -int -gr_check_lfsr_32k_s::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - unsigned short *in = (unsigned short *) input_items[0]; - - for (int i = 0; i < noutput_items; i++){ - unsigned short x = in[i]; - unsigned short expected; - - switch (d_state){ - - case MATCH0: - if (x == d_buffer[0]) - enter_MATCH1 (); - break; - - case MATCH1: - if (x == d_buffer[1]) - enter_MATCH2 (); - else - enter_MATCH0 (); - break; - - case MATCH2: - if (x == d_buffer[2]) - enter_LOCKED (); - else - enter_MATCH0 (); - break; - - case LOCKED: - expected = d_buffer[d_index]; - d_index = d_index + 1; - if (d_index >= BUFSIZE) - d_index = 0; - - if (x == expected) - right (); - else { - wrong (); - log_error (expected, x); - if (wrong_three_times ()) - enter_SEARCHING (); - } - break; - - default: - abort (); - } - - d_ntotal++; - } - - return noutput_items; -} - -void -gr_check_lfsr_32k_s::enter_SEARCHING () -{ - d_state = SEARCHING; - wrong (); // reset history - wrong (); - wrong (); - - d_runlength = 0; - d_index = 0; // reset LFSR to beginning - - if (0) - fprintf (stdout, "gr_check_lfsr_32k: enter_SEARCHING at offset %8ld (0x%08lx)\n", - d_ntotal, d_ntotal); - - enter_MATCH0 (); -} - -void -gr_check_lfsr_32k_s::enter_MATCH0 () -{ - d_state = MATCH0; -} - -void -gr_check_lfsr_32k_s::enter_MATCH1 () -{ - d_state = MATCH1; -} - -void -gr_check_lfsr_32k_s::enter_MATCH2 () -{ - d_state = MATCH2; -} - -void -gr_check_lfsr_32k_s::enter_LOCKED () -{ - d_state = LOCKED; - right (); // setup history - right (); - right (); - - d_index = 3; // already matched first 3 items - - if (0) - fprintf (stdout, "gr_check_lfsr_32k: enter_LOCKED at offset %8ld (0x%08lx)\n", - d_ntotal, d_ntotal); -} - -void -gr_check_lfsr_32k_s::log_error (unsigned short expected, unsigned short actual) -{ - if (0) - fprintf (stdout, - "gr_check_lfsr_32k: expected %5d (0x%04x) got %5d (0x%04x) offset %8ld (0x%08lx)\n", - expected, expected, actual, actual, d_ntotal, d_ntotal); -} diff --git a/gnuradio-core/src/lib/general/gr_check_lfsr_32k_s.h b/gnuradio-core/src/lib/general/gr_check_lfsr_32k_s.h deleted file mode 100644 index 2f980b427b..0000000000 --- a/gnuradio-core/src/lib/general/gr_check_lfsr_32k_s.h +++ /dev/null @@ -1,103 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef INCLUDED_GR_CHECK_LFSR_32K_S_H -#define INCLUDED_GR_CHECK_LFSR_32K_S_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <gri_lfsr_32k.h> - - -class gr_check_lfsr_32k_s; -typedef boost::shared_ptr<gr_check_lfsr_32k_s> gr_check_lfsr_32k_s_sptr; - -GR_CORE_API gr_check_lfsr_32k_s_sptr gr_make_check_lfsr_32k_s (); - -/*! - * \brief sink that checks if its input stream consists of a lfsr_32k sequence. - * \ingroup sink_blk - * - * This sink is typically used along with gr_lfsr_32k_source_s to test - * the USRP using its digital loopback mode. - */ -class GR_CORE_API gr_check_lfsr_32k_s : public gr_sync_block -{ - friend GR_CORE_API gr_check_lfsr_32k_s_sptr gr_make_check_lfsr_32k_s (); - - enum state { - SEARCHING, // searching for synchronization - MATCH0, - MATCH1, - MATCH2, - LOCKED // is locked - }; - - state d_state; - unsigned int d_history; // bitmask of decisions - - long d_ntotal; // total number of shorts - long d_nright; // # of correct shorts - long d_runlength; // # of correct shorts in a row - - static const int BUFSIZE = 2048 - 1; // ensure pattern isn't packet aligned - int d_index; - unsigned short d_buffer[BUFSIZE]; - - - gr_check_lfsr_32k_s (); - - void enter_SEARCHING (); - void enter_MATCH0 (); - void enter_MATCH1 (); - void enter_MATCH2 (); - void enter_LOCKED (); - - void right (){ - d_history = (d_history << 1) | 0x1; - d_nright++; - d_runlength++; - } - - void wrong (){ - d_history = (d_history << 1) | 0x0; - d_runlength = 0; - } - - bool right_three_times () { return (d_history & 0x7) == 0x7; } - bool wrong_three_times () { return (d_history & 0x7) == 0x0; } - - void log_error (unsigned short expected, unsigned short actual); - - public: - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - long ntotal () const { return d_ntotal; } - long nright () const { return d_nright; } - long runlength () const { return d_runlength; } - -}; - - -#endif /* INCLUDED_GR_CHECK_LFSR_32K_S_H */ diff --git a/gnuradio-core/src/lib/general/gr_check_lfsr_32k_s.i b/gnuradio-core/src/lib/general/gr_check_lfsr_32k_s.i deleted file mode 100644 index 34d4a0b0c1..0000000000 --- a/gnuradio-core/src/lib/general/gr_check_lfsr_32k_s.i +++ /dev/null @@ -1,36 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,check_lfsr_32k_s) - -gr_check_lfsr_32k_s_sptr gr_make_check_lfsr_32k_s (); - -class gr_check_lfsr_32k_s : public gr_sync_block -{ - private: - gr_check_lfsr_32k_s (); - -public: - long ntotal () const; - long nright () const; - long runlength () const; -}; diff --git a/gnuradio-core/src/lib/general/gr_copy.cc b/gnuradio-core/src/lib/general/gr_copy.cc deleted file mode 100644 index 0a6f721f94..0000000000 --- a/gnuradio-core/src/lib/general/gr_copy.cc +++ /dev/null @@ -1,71 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2009 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_copy.h> -#include <gr_io_signature.h> -#include <string.h> - -gr_copy_sptr -gr_make_copy(size_t itemsize) -{ - return gnuradio::get_initial_sptr(new gr_copy(itemsize)); -} - -gr_copy::gr_copy(size_t itemsize) - : gr_block ("copy", - gr_make_io_signature (1, 1, itemsize), - gr_make_io_signature (1, 1, itemsize)), - d_itemsize(itemsize), - d_enabled(true) -{ -} - -bool -gr_copy::check_topology(int ninputs, int noutputs) -{ - return ninputs == noutputs; -} - -int -gr_copy::general_work(int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const uint8_t *in = (const uint8_t *) input_items[0]; - uint8_t *out = (uint8_t *) output_items[0]; - - int n = std::min<int>(ninput_items[0], noutput_items); - int j = 0; - - if (d_enabled) { - memcpy(out, in, n*d_itemsize); - j = n; - } - - consume_each(n); - return j; -} diff --git a/gnuradio-core/src/lib/general/gr_copy.h b/gnuradio-core/src/lib/general/gr_copy.h deleted file mode 100644 index b0769fa2b1..0000000000 --- a/gnuradio-core/src/lib/general/gr_copy.h +++ /dev/null @@ -1,63 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2009 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_COPY_H -#define INCLUDED_GR_COPY_H - -#include <gr_core_api.h> -#include <gr_block.h> - -class gr_copy; -typedef boost::shared_ptr<gr_copy> gr_copy_sptr; - -GR_CORE_API gr_copy_sptr gr_make_copy(size_t itemsize); - -/*! - * \brief output[i] = input[i] - * \ingroup misc_blk - * - * When enabled (default), this block copies its input to its output. - * When disabled, this block drops its input on the floor. - * - */ -class GR_CORE_API gr_copy : public gr_block -{ - size_t d_itemsize; - bool d_enabled; - - friend GR_CORE_API gr_copy_sptr gr_make_copy(size_t itemsize); - gr_copy(size_t itemsize); - - public: - - bool check_topology(int ninputs, int noutputs); - - void set_enabled(bool enable) { d_enabled = enable; } - bool enabled() const { return d_enabled;} - - int general_work(int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif diff --git a/gnuradio-core/src/lib/general/gr_copy.i b/gnuradio-core/src/lib/general/gr_copy.i deleted file mode 100644 index 12ddce6aaf..0000000000 --- a/gnuradio-core/src/lib/general/gr_copy.i +++ /dev/null @@ -1,36 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2009 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,copy) - -gr_copy_sptr gr_make_copy(size_t itemsize); - -class gr_copy : public gr_block -{ - private: - gr_copy(size_t itemsize); - -public: - - void set_enabled(bool enabled); - bool enabled(); -}; diff --git a/gnuradio-core/src/lib/general/gr_ctrlport_probe2_c.cc b/gnuradio-core/src/lib/general/gr_ctrlport_probe2_c.cc deleted file mode 100644 index ca6667a214..0000000000 --- a/gnuradio-core/src/lib/general/gr_ctrlport_probe2_c.cc +++ /dev/null @@ -1,156 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_ctrlport_probe2_c.h> -#include <gr_io_signature.h> - -gr_ctrlport_probe2_c_sptr -gr_make_ctrlport_probe2_c(const std::string &id, - const std::string &desc, int len) -{ - return gnuradio::get_initial_sptr - (new gr_ctrlport_probe2_c(id, desc, len)); -} - -gr_ctrlport_probe2_c::gr_ctrlport_probe2_c(const std::string &id, - const std::string &desc, int len) - : gr_sync_block("probe2_c", - gr_make_io_signature(1, 1, sizeof(gr_complex)), - gr_make_io_signature(0, 0, 0)), - d_id(id), d_desc(desc), d_len(len) -{ - set_length(len); -} - -gr_ctrlport_probe2_c::~gr_ctrlport_probe2_c() -{ -} - -void -gr_ctrlport_probe2_c::forecast(int noutput_items, gr_vector_int &ninput_items_required) -{ - // make sure all inputs have noutput_items available - unsigned ninputs = ninput_items_required.size(); - for(unsigned i = 0; i < ninputs; i++) - ninput_items_required[i] = d_len; -} - -// boost::shared_mutex mutex_buffer; -// mutable boost::mutex mutex_notify; -// boost::condition_variable condition_buffer_ready; -std::vector<gr_complex> -gr_ctrlport_probe2_c::get() -{ - mutex_buffer.lock(); - d_buffer.clear(); - mutex_buffer.unlock(); - - // wait for condition - boost::mutex::scoped_lock lock(mutex_notify); - condition_buffer_ready.wait(lock); - - mutex_buffer.lock(); - std::vector<gr_complex> buf_copy = d_buffer; - assert(buf_copy.size() == d_len); - mutex_buffer.unlock(); - - return buf_copy; -} - -void -gr_ctrlport_probe2_c::set_length(int len) -{ - if(len > 8191) { - std::cerr << "probe2_c: length " << len - << " exceeds maximum buffer size of 8191" << std::endl; - len = 8191; - } - - d_len = len; - d_buffer.reserve(d_len); -} - -int -gr_ctrlport_probe2_c::length() const -{ - return (int)d_len; -} - -int -gr_ctrlport_probe2_c::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const gr_complex *in = (const gr_complex*)input_items[0]; - - // copy samples to get buffer if we need samples - mutex_buffer.lock(); - if(d_buffer.size() < d_len) { - // copy smaller of remaining buffer space and num inputs to work() - int num_copy = std::min( (int)(d_len - d_buffer.size()), noutput_items ); - - // TODO: convert this to a copy operator for speed... - for(int i = 0; i < num_copy; i++) { - d_buffer.push_back(in[i]); - } - - // notify the waiting get() if we fill up the buffer - if(d_buffer.size() == d_len) { - condition_buffer_ready.notify_one(); - } - } - mutex_buffer.unlock(); - - return noutput_items; -} - -void -gr_ctrlport_probe2_c::setup_rpc() -{ -#ifdef GR_CTRLPORT - int len = static_cast<int>(d_len); - d_rpc_vars.push_back( - rpcbasic_sptr(new rpcbasic_register_get<gr_ctrlport_probe2_c, std::vector<std::complex<float> > >( - alias(), d_id.c_str(), &gr_ctrlport_probe2_c::get, - pmt::make_c32vector(0,-2), - pmt::make_c32vector(0,2), - pmt::make_c32vector(0,0), - "volts", d_desc.c_str(), RPC_PRIVLVL_MIN, - DISPXY | DISPOPTSCATTER))); - - d_rpc_vars.push_back( - rpcbasic_sptr(new rpcbasic_register_get<gr_ctrlport_probe2_c, int>( - alias(), "length", &gr_ctrlport_probe2_c::length, - pmt::mp(1), pmt::mp(10*len), pmt::mp(len), - "samples", "get vector length", RPC_PRIVLVL_MIN, DISPNULL))); - - d_rpc_vars.push_back( - rpcbasic_sptr(new rpcbasic_register_set<gr_ctrlport_probe2_c, int>( - alias(), "length", &gr_ctrlport_probe2_c::set_length, - pmt::mp(1), pmt::mp(10*len), pmt::mp(len), - "samples", "set vector length", RPC_PRIVLVL_MIN, DISPNULL))); -#endif /* GR_CTRLPORT */ -} diff --git a/gnuradio-core/src/lib/general/gr_ctrlport_probe2_c.h b/gnuradio-core/src/lib/general/gr_ctrlport_probe2_c.h deleted file mode 100644 index 0920c0f4e8..0000000000 --- a/gnuradio-core/src/lib/general/gr_ctrlport_probe2_c.h +++ /dev/null @@ -1,72 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_CTRLPORT_PROBE2_C_H -#define INCLUDED_CTRLPORT_PROBE2_C_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <rpcregisterhelpers.h> -#include <boost/thread/shared_mutex.hpp> - -class gr_ctrlport_probe2_c; -typedef boost::shared_ptr<gr_ctrlport_probe2_c> gr_ctrlport_probe2_c_sptr; - -GR_CORE_API gr_ctrlport_probe2_c_sptr -gr_make_ctrlport_probe2_c(const std::string &id, const std::string &desc, int len); - -class GR_CORE_API gr_ctrlport_probe2_c : public gr_sync_block -{ - private: - friend GR_CORE_API gr_ctrlport_probe2_c_sptr gr_make_ctrlport_probe2_c - (const std::string &id, const std::string &desc, int len); - - gr_ctrlport_probe2_c(const std::string &id, const std::string &desc, int len); - - std::string d_id; - std::string d_desc; - size_t d_len; - boost::shared_mutex mutex_buffer; - mutable boost::mutex mutex_notify; - boost::condition_variable condition_buffer_ready; - - std::vector<gr_complex> d_buffer; - - public: - ~gr_ctrlport_probe2_c(); - - void setup_rpc(); - - void forecast(int noutput_items, gr_vector_int &ninput_items_required); - - std::vector<gr_complex> get(); - - void set_length(int len); - int length() const; - - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_CTRLPORT_PROBE2_C_H */ - diff --git a/gnuradio-core/src/lib/general/gr_ctrlport_probe2_c.i b/gnuradio-core/src/lib/general/gr_ctrlport_probe2_c.i deleted file mode 100644 index 18858595ea..0000000000 --- a/gnuradio-core/src/lib/general/gr_ctrlport_probe2_c.i +++ /dev/null @@ -1,36 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,ctrlport_probe2_c) - -gr_ctrlport_probe2_c_sptr -gr_make_ctrlport_probe2_c(const std::string &id, const std::string &desc, int len); - -class gr_ctrlport_probe2_c : public gr_sync_block -{ -public: - ~gr_ctrlport_probe2_c(); - std::vector<gr_complex> get(); - void set_length(int len); - int length() const; -}; - diff --git a/gnuradio-core/src/lib/general/gr_ctrlport_probe_c.cc b/gnuradio-core/src/lib/general/gr_ctrlport_probe_c.cc deleted file mode 100644 index 253d4c380e..0000000000 --- a/gnuradio-core/src/lib/general/gr_ctrlport_probe_c.cc +++ /dev/null @@ -1,96 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_ctrlport_probe_c.h> -#include <gr_io_signature.h> - -gr_ctrlport_probe_c_sptr -gr_make_ctrlport_probe_c(const std::string &id, - const std::string &desc) -{ - return gnuradio::get_initial_sptr - (new gr_ctrlport_probe_c(id, desc)); -} - - -gr_ctrlport_probe_c::gr_ctrlport_probe_c(const std::string &id, - const std::string &desc) - : gr_sync_block("probe_c", - gr_make_io_signature(1, 1, sizeof(gr_complex)), - gr_make_io_signature(0, 0, 0)), - d_id(id), d_desc(desc), d_ptr(NULL), d_ptrLen(0) -{ -} - -gr_ctrlport_probe_c::~gr_ctrlport_probe_c() -{ -} - -std::vector<gr_complex> -gr_ctrlport_probe_c::get() -{ - if(d_ptr != NULL && d_ptrLen > 0) { - ptrlock.lock(); - std::vector<gr_complex> vec(d_ptr, d_ptr+d_ptrLen); - ptrlock.unlock(); - return vec; - } - else { - std::vector<gr_complex> vec; - return vec; - } -} - -int -gr_ctrlport_probe_c::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const gr_complex *in = (const gr_complex*)input_items[0]; - - // keep reference to symbols - ptrlock.lock(); - d_ptr = in; - d_ptrLen = noutput_items; - ptrlock.unlock(); - - return noutput_items; -} - -void -gr_ctrlport_probe_c::setup_rpc() -{ -#ifdef GR_CTRLPORT - d_rpc_vars.push_back( - rpcbasic_sptr(new rpcbasic_register_get<gr_ctrlport_probe_c, std::vector<std::complex<float> > >( - alias(), d_id.c_str(), &gr_ctrlport_probe_c::get, - pmt::make_c32vector(0,-2), - pmt::make_c32vector(0,2), - pmt::make_c32vector(0,0), - "volts", d_desc.c_str(), RPC_PRIVLVL_MIN, - DISPXY | DISPOPTSCATTER))); -#endif /* GR_CTRLPORT */ -} diff --git a/gnuradio-core/src/lib/general/gr_ctrlport_probe_c.i b/gnuradio-core/src/lib/general/gr_ctrlport_probe_c.i deleted file mode 100644 index cd4c521cb0..0000000000 --- a/gnuradio-core/src/lib/general/gr_ctrlport_probe_c.i +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,ctrlport_probe_c) - -gr_ctrlport_probe_c_sptr -gr_make_ctrlport_probe_c(const std::string &id, const std::string &desc); - -class gr_ctrlport_probe_c : public gr_sync_block -{ -public: - ~gr_ctrlport_probe_c(); - std::vector<gr_complex> get(); -}; - diff --git a/gnuradio-core/src/lib/general/gr_endian_swap.cc b/gnuradio-core/src/lib/general/gr_endian_swap.cc deleted file mode 100644 index 8bea0ca30d..0000000000 --- a/gnuradio-core/src/lib/general/gr_endian_swap.cc +++ /dev/null @@ -1,101 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010,2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_endian_swap.h> -#include <gr_io_signature.h> -#include <volk/volk.h> - -gr_endian_swap_sptr -gr_make_endian_swap (size_t item_size_bytes) -{ - return gnuradio::get_initial_sptr(new gr_endian_swap (item_size_bytes)); -} - -gr_endian_swap::gr_endian_swap (size_t item_size_bytes) - : gr_sync_block ("gr_endian_swap", - gr_make_io_signature (1, 1, item_size_bytes), - gr_make_io_signature (1, 1, item_size_bytes)) -{ - const int alignment_multiple = volk_get_alignment(); - set_alignment(std::max(1,alignment_multiple)); -} - -int -gr_endian_swap::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const char *in = (const char *) input_items[0]; - char *out = (char *) output_items[0]; - - int nbytes( output_signature()->sizeof_stream_item(0) ); - if(is_unaligned()) { - switch(nbytes){ - case 1: - memcpy(out,in,noutput_items); - break; - case 2: - memcpy(out,in,2*noutput_items); - volk_16u_byteswap_u((uint16_t*)out,noutput_items); - break; - case 4: - memcpy(out,in,4*noutput_items); - volk_32u_byteswap_u((uint32_t*)out,noutput_items); - break; - case 8: - memcpy(out,in,8*noutput_items); - volk_64u_byteswap_u((uint64_t*)out,noutput_items); - break; - default: - throw std::runtime_error("itemsize is not valid for gr_endian_swap!"); - } - } else { - switch(nbytes){ - case 1: - memcpy(out,in,noutput_items); - break; - case 2: - memcpy(out,in,2*noutput_items); - volk_16u_byteswap_a((uint16_t*)out,noutput_items); - break; - case 4: - memcpy(out,in,4*noutput_items); - volk_32u_byteswap_a((uint32_t*)out,noutput_items); - break; - case 8: - memcpy(out,in,8*noutput_items); - volk_64u_byteswap_a((uint64_t*)out,noutput_items); - break; - default: - throw std::runtime_error("itemsize is not valid for gr_endian_swap!"); - } - } - - return noutput_items; -} - - - diff --git a/gnuradio-core/src/lib/general/gr_endian_swap.i b/gnuradio-core/src/lib/general/gr_endian_swap.i deleted file mode 100644 index 6058b9de77..0000000000 --- a/gnuradio-core/src/lib/general/gr_endian_swap.i +++ /dev/null @@ -1,31 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,endian_swap) - -gr_endian_swap_sptr -gr_make_endian_swap (size_t bytes_per_item=1); - -class gr_endian_swap : public gr_sync_block -{ -public: -}; diff --git a/gnuradio-core/src/lib/gengen/gr_endianness.h b/gnuradio-core/src/lib/general/gr_endianness.h index c4ecb1383e..c4ecb1383e 100644 --- a/gnuradio-core/src/lib/gengen/gr_endianness.h +++ b/gnuradio-core/src/lib/general/gr_endianness.h diff --git a/gnuradio-core/src/lib/general/gr_fake_channel_coder_pp.cc b/gnuradio-core/src/lib/general/gr_fake_channel_coder_pp.cc deleted file mode 100644 index c1c3883c56..0000000000 --- a/gnuradio-core/src/lib/general/gr_fake_channel_coder_pp.cc +++ /dev/null @@ -1,113 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_fake_channel_coder_pp.h> -#include <gr_io_signature.h> -#include <string.h> -#include <stdexcept> -#include <string.h> - -static const int PAD_VAL = 0xAA; - -gr_fake_channel_encoder_pp_sptr -gr_make_fake_channel_encoder_pp(int input_vlen, int output_vlen) -{ - return gnuradio::get_initial_sptr(new gr_fake_channel_encoder_pp(input_vlen, - output_vlen)); -} - -gr_fake_channel_encoder_pp::gr_fake_channel_encoder_pp(int input_vlen, int output_vlen) - : gr_sync_block("fake_channel_encoder_pp", - gr_make_io_signature(1, 1, input_vlen * sizeof(unsigned char)), - gr_make_io_signature(1, 1, output_vlen * sizeof(unsigned char))), - d_input_vlen(input_vlen), d_output_vlen(output_vlen) -{ - if (input_vlen <= 0 || output_vlen <= 0 || input_vlen > output_vlen) - throw std::invalid_argument("gr_fake_channel_encoder_pp"); -} - -gr_fake_channel_encoder_pp::~gr_fake_channel_encoder_pp() -{ -} - -int -gr_fake_channel_encoder_pp::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const unsigned char *in = (const unsigned char *) input_items[0]; - unsigned char *out = (unsigned char *) output_items[0]; - int npad = d_output_vlen - d_input_vlen; - - for (int i = 0; i < noutput_items; i++){ - memcpy(out, in, d_input_vlen); - memset(out + d_input_vlen, PAD_VAL, npad); - in += d_input_vlen; - out += d_output_vlen; - } - - return noutput_items; -} - -// ------------------------------------------------------------------------ - -gr_fake_channel_decoder_pp_sptr -gr_make_fake_channel_decoder_pp(int input_vlen, int output_vlen) -{ - return gnuradio::get_initial_sptr(new gr_fake_channel_decoder_pp(input_vlen, - output_vlen)); -} - -gr_fake_channel_decoder_pp::gr_fake_channel_decoder_pp(int input_vlen, int output_vlen) - : gr_sync_block("fake_channel_decoder_pp", - gr_make_io_signature(1, 1, input_vlen * sizeof(unsigned char)), - gr_make_io_signature(1, 1, output_vlen * sizeof(unsigned char))), - d_input_vlen(input_vlen), d_output_vlen(output_vlen) -{ - if (input_vlen <= 0 || output_vlen <= 0 || output_vlen > input_vlen) - throw std::invalid_argument("gr_fake_channel_decoder_pp"); -} - -gr_fake_channel_decoder_pp::~gr_fake_channel_decoder_pp() -{ -} - -int -gr_fake_channel_decoder_pp::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const unsigned char *in = (const unsigned char *) input_items[0]; - unsigned char *out = (unsigned char *) output_items[0]; - - for (int i = 0; i < noutput_items; i++){ - memcpy(out, in, d_output_vlen); - in += d_input_vlen; - out += d_output_vlen; - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_fake_channel_coder_pp.h b/gnuradio-core/src/lib/general/gr_fake_channel_coder_pp.h deleted file mode 100644 index 45808752d3..0000000000 --- a/gnuradio-core/src/lib/general/gr_fake_channel_coder_pp.h +++ /dev/null @@ -1,91 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 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_FAKE_CHANNEL_CODER_PP_H -#define INCLUDED_GR_FAKE_CHANNEL_CODER_PP_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gr_fake_channel_encoder_pp; -typedef boost::shared_ptr<gr_fake_channel_encoder_pp> gr_fake_channel_encoder_pp_sptr; - -GR_CORE_API gr_fake_channel_encoder_pp_sptr -gr_make_fake_channel_encoder_pp(int input_vlen, int output_vlen); - -/*! - * \brief pad packet with alternating 1,0 pattern. - * \ingroup coding_blk - * - * input: stream of byte vectors; output: stream of byte vectors - */ -class GR_CORE_API gr_fake_channel_encoder_pp : public gr_sync_block -{ - int d_input_vlen; - int d_output_vlen; - - gr_fake_channel_encoder_pp(int input_vlen, int output_vlen); - - friend GR_CORE_API gr_fake_channel_encoder_pp_sptr - gr_make_fake_channel_encoder_pp(int input_vlen, int output_vlen); - -public: - ~gr_fake_channel_encoder_pp(); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -// ------------------------------------------------------------------------ - -class gr_fake_channel_decoder_pp; -typedef boost::shared_ptr<gr_fake_channel_decoder_pp> gr_fake_channel_decoder_pp_sptr; - -GR_CORE_API gr_fake_channel_decoder_pp_sptr -gr_make_fake_channel_decoder_pp(int input_vlen, int output_vlen); - -/*! - * \brief remove fake padding from packet - * \ingroup coding_blk - * - * input: stream of byte vectors; output: stream of byte vectors - */ -class GR_CORE_API gr_fake_channel_decoder_pp : public gr_sync_block -{ - int d_input_vlen; - int d_output_vlen; - - gr_fake_channel_decoder_pp(int input_vlen, int output_vlen); - - friend GR_CORE_API gr_fake_channel_decoder_pp_sptr - gr_make_fake_channel_decoder_pp(int input_vlen, int output_vlen); - -public: - ~gr_fake_channel_decoder_pp(); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_GR_FAKE_CHANNEL_CODER_PP_H */ diff --git a/gnuradio-core/src/lib/general/gr_fake_channel_coder_pp.i b/gnuradio-core/src/lib/general/gr_fake_channel_coder_pp.i deleted file mode 100644 index 123c84e473..0000000000 --- a/gnuradio-core/src/lib/general/gr_fake_channel_coder_pp.i +++ /dev/null @@ -1,53 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 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,fake_channel_encoder_pp) - -gr_fake_channel_encoder_pp_sptr -gr_make_fake_channel_encoder_pp(int input_vlen, - int output_vlen - ) throw(std::invalid_argument); - -class gr_fake_channel_encoder_pp : public gr_sync_block -{ - gr_fake_channel_encoder_pp(int input_vlen, int output_vlen); - -public: - ~gr_fake_channel_encoder_pp(); -}; - -// ------------------------------------------------------------------------ - -GR_SWIG_BLOCK_MAGIC(gr,fake_channel_decoder_pp) - -gr_fake_channel_decoder_pp_sptr -gr_make_fake_channel_decoder_pp(int input_vlen, - int output_vlen - ) throw(std::invalid_argument); - -class gr_fake_channel_decoder_pp : public gr_sync_block -{ - gr_fake_channel_decoder_pp(int input_vlen, int output_vlen); - -public: - ~gr_fake_channel_decoder_pp(); -}; diff --git a/gnuradio-core/src/lib/io/sdr_1000.i b/gnuradio-core/src/lib/general/gr_fxpt.cc index c9b1ef5609..2ea8520e6b 100644 --- a/gnuradio-core/src/lib/io/sdr_1000.i +++ b/gnuradio-core/src/lib/general/gr_fxpt.cc @@ -20,17 +20,16 @@ * Boston, MA 02110-1301, USA. */ -const int L_EXT = 0; -const int L_BAND = 1; -const int L_DDS0 = 2; -const int L_DDS1 = 3; +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif -class sdr_1000_base { -public: +#include <gr_fxpt.h> - sdr_1000_base (int which_pp); - ~sdr_1000_base (); - - void reset (); - void write_latch (int which, int value, int mask); +const float gr_fxpt::s_sine_table[1 << NBITS][2] = { +#include "sine_table.h" }; + +const float gr_fxpt::PI = 3.14159265358979323846; +const float gr_fxpt::TWO_TO_THE_31 = 2147483648.0; + diff --git a/gnuradio-core/src/lib/general/gr_fxpt.h b/gnuradio-core/src/lib/general/gr_fxpt.h new file mode 100644 index 0000000000..9de6c0c18a --- /dev/null +++ b/gnuradio-core/src/lib/general/gr_fxpt.h @@ -0,0 +1,104 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ +#ifndef INCLUDED_GR_FXPT_H +#define INCLUDED_GR_FXPT_H + +#include <gr_core_api.h> +#include <gr_types.h> + +/*! + * \brief fixed point sine and cosine and friends. + * \ingroup misc + * + * fixed pt radians + * --------- -------- + * -2**31 -pi + * 0 0 + * 2**31-1 pi - epsilon + * + */ +class GR_CORE_API 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; + static const float TWO_TO_THE_31; +public: + + static gr_int32 + float_to_fixed (float x) + { + // Fold x into -PI to PI. + int d = (int)floor(x/2/PI+0.5); + x -= d*2*PI; + // And convert to an integer. + return (gr_int32) ((float) x * TWO_TO_THE_31 / PI); + } + + static float + fixed_to_float (gr_int32 x) + { + return x * (PI / TWO_TO_THE_31); + } + + /*! + * \brief Given a fixed point angle x, return float sine (x) + */ + static float + sin (gr_int32 x) + { + gr_uint32 ux = x; + int index = ux >> (WORDBITS - NBITS); + return s_sine_table[index][0] * (ux >> 1) + s_sine_table[index][1]; + } + + /* + * \brief Given a fixed point angle x, return float cosine (x) + */ + static float + cos (gr_int32 x) + { + gr_uint32 ux = x + 0x40000000; + int index = ux >> (WORDBITS - NBITS); + return s_sine_table[index][0] * (ux >> 1) + s_sine_table[index][1]; + } + + /* + * \brief Given a fixedpoint angle x, return float cos(x) and sin (x) + */ + static void sincos(gr_int32 x, float *s, float *c) + { + gr_uint32 ux = x; + int sin_index = ux >> (WORDBITS - NBITS); + *s = s_sine_table[sin_index][0] * (ux >> 1) + s_sine_table[sin_index][1]; + + ux = x + 0x40000000; + int cos_index = ux >> (WORDBITS - NBITS); + *c = s_sine_table[cos_index][0] * (ux >> 1) + s_sine_table[cos_index][1]; + + return; + } + +}; + +#endif /* INCLUDED_GR_FXPT_H */ diff --git a/gnuradio-core/src/lib/general/gr_fxpt_nco.h b/gnuradio-core/src/lib/general/gr_fxpt_nco.h new file mode 100644 index 0000000000..9defa083da --- /dev/null +++ b/gnuradio-core/src/lib/general/gr_fxpt_nco.h @@ -0,0 +1,153 @@ +/* -*- c++ -*- */ +/* + * Copyright 2002,2004 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ +#ifndef INCLUDED_GR_FXPT_NCO_H +#define INCLUDED_GR_FXPT_NCO_H + +#include <gr_core_api.h> +#include <gr_fxpt.h> +#include <gr_complex.h> + +/*! + * \brief Numerically Controlled Oscillator (NCO) + * \ingroup misc + */ +class /*GR_CORE_API*/ gr_fxpt_nco { + gr_uint32 d_phase; + gr_int32 d_phase_inc; + +public: + gr_fxpt_nco () : d_phase (0), d_phase_inc (0) {} + + ~gr_fxpt_nco () {} + + // radians + void set_phase (float angle) { + d_phase = gr_fxpt::float_to_fixed (angle); + } + + void adjust_phase (float delta_phase) { + d_phase += gr_fxpt::float_to_fixed (delta_phase); + } + + // angle_rate is in radians / step + void set_freq (float angle_rate){ + d_phase_inc = gr_fxpt::float_to_fixed (angle_rate); + } + + // angle_rate is a delta in radians / step + void adjust_freq (float delta_angle_rate) + { + d_phase_inc += gr_fxpt::float_to_fixed (delta_angle_rate); + } + + // increment current phase angle + + void step () + { + d_phase += d_phase_inc; + } + + void step (int n) + { + d_phase += d_phase_inc * n; + } + + // units are radians / step + float get_phase () const { return gr_fxpt::fixed_to_float (d_phase); } + float get_freq () const { return gr_fxpt::fixed_to_float (d_phase_inc); } + + // compute sin and cos for current phase angle + void sincos (float *sinx, float *cosx) const + { + *sinx = gr_fxpt::sin (d_phase); + *cosx = gr_fxpt::cos (d_phase); + } + + // compute cos and sin for a block of phase angles + void sincos (gr_complex *output, int noutput_items, double ampl=1.0) + { + for (int i = 0; i < noutput_items; i++){ + output[i] = gr_complex(gr_fxpt::cos (d_phase) * ampl, gr_fxpt::sin (d_phase) * ampl); + step (); + } + } + + // compute sin for a block of phase angles + void sin (float *output, int noutput_items, double ampl=1.0) + { + for (int i = 0; i < noutput_items; i++){ + output[i] = (float)(gr_fxpt::sin (d_phase) * ampl); + step (); + } + } + + // compute cos for a block of phase angles + void cos (float *output, int noutput_items, double ampl=1.0) + { + for (int i = 0; i < noutput_items; i++){ + output[i] = (float)(gr_fxpt::cos (d_phase) * ampl); + step (); + } + } + + // compute sin for a block of phase angles + void sin (short *output, int noutput_items, double ampl=1.0) + { + for (int i = 0; i < noutput_items; i++){ + output[i] = (short)(gr_fxpt::sin (d_phase) * ampl); + step (); + } + } + + // compute cos for a block of phase angles + void cos (short *output, int noutput_items, double ampl=1.0) + { + for (int i = 0; i < noutput_items; i++){ + output[i] = (short)(gr_fxpt::cos (d_phase) * ampl); + step (); + } + } + + // compute sin for a block of phase angles + void sin (int *output, int noutput_items, double ampl=1.0) + { + for (int i = 0; i < noutput_items; i++){ + output[i] = (int)(gr_fxpt::sin (d_phase) * ampl); + step (); + } + } + + // compute cos for a block of phase angles + void cos (int *output, int noutput_items, double ampl=1.0) + { + for (int i = 0; i < noutput_items; i++){ + output[i] = (int)(gr_fxpt::cos (d_phase) * ampl); + step (); + } + } + + // compute cos or sin for current phase angle + float cos () const { return gr_fxpt::cos (d_phase); } + float sin () const { return gr_fxpt::sin (d_phase); } +}; + +#endif /* INCLUDED_GR_FXPT_NCO_H */ diff --git a/gnuradio-core/src/lib/general/gr_fxpt_vco.h b/gnuradio-core/src/lib/general/gr_fxpt_vco.h new file mode 100644 index 0000000000..13be2526bd --- /dev/null +++ b/gnuradio-core/src/lib/general/gr_fxpt_vco.h @@ -0,0 +1,73 @@ +/* -*- c++ -*- */ +/* + * Copyright 2002,2004,2005 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_FXPT_VCO_H +#define INCLUDED_GR_FXPT_VCO_H + +#include <gr_core_api.h> +#include <gr_fxpt.h> +#include <gr_complex.h> + +/*! + * \brief Voltage Controlled Oscillator (VCO) + * \ingroup misc + */ +class /*GR_CORE_API*/ gr_fxpt_vco { + gr_int32 d_phase; + +public: + gr_fxpt_vco () : d_phase (0) {} + + ~gr_fxpt_vco () {} + + // radians + void set_phase (float angle) { + d_phase = gr_fxpt::float_to_fixed (angle); + } + + void adjust_phase (float delta_phase) { + d_phase += gr_fxpt::float_to_fixed (delta_phase); + } + + float get_phase () const { return gr_fxpt::fixed_to_float (d_phase); } + + // compute sin and cos for current phase angle + void sincos (float *sinx, float *cosx) const + { + *sinx = gr_fxpt::sin (d_phase); + *cosx = gr_fxpt::cos (d_phase); + } + + // compute a block at a time + void cos (float *output, const float *input, int noutput_items, float k, float ampl = 1.0) + { + for (int i = 0; i < noutput_items; i++){ + output[i] = (float)(gr_fxpt::cos (d_phase) * ampl); + adjust_phase(input[i] * k); + } + } + + // compute cos or sin for current phase angle + float cos () const { return gr_fxpt::cos (d_phase); } + float sin () const { return gr_fxpt::sin (d_phase); } +}; + +#endif /* INCLUDED_GR_FXPT_VCO_H */ diff --git a/gnuradio-core/src/lib/general/gr_head.cc b/gnuradio-core/src/lib/general/gr_head.cc deleted file mode 100644 index 1726888113..0000000000 --- a/gnuradio-core/src/lib/general/gr_head.cc +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2009 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_head.h> -#include <gr_io_signature.h> -#include <string.h> -#include <iostream> - -gr_head::gr_head (size_t sizeof_stream_item, unsigned long long nitems) - : gr_sync_block ("head", - gr_make_io_signature (1, 1, sizeof_stream_item), - gr_make_io_signature (1, 1, sizeof_stream_item)), - d_nitems (nitems), d_ncopied_items (0) -{ -} - -gr_head_sptr -gr_make_head (size_t sizeof_stream_item, unsigned long long nitems) -{ - return gnuradio::get_initial_sptr(new gr_head (sizeof_stream_item, nitems)); -} - -int -gr_head::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - if (d_ncopied_items >= d_nitems) - return -1; // Done! - - unsigned n = std::min (d_nitems - d_ncopied_items, (unsigned long long) noutput_items); - - if (n == 0) - return 0; - - memcpy (output_items[0], input_items[0], n * input_signature()->sizeof_stream_item (0)); - d_ncopied_items += n; - - return n; -} diff --git a/gnuradio-core/src/lib/general/gr_head.h b/gnuradio-core/src/lib/general/gr_head.h deleted file mode 100644 index 48415892dd..0000000000 --- a/gnuradio-core/src/lib/general/gr_head.h +++ /dev/null @@ -1,61 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2009,2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_HEAD_H -#define INCLUDED_GR_HEAD_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <stddef.h> // size_t - -class gr_head; -typedef boost::shared_ptr<gr_head> gr_head_sptr; - -/*! - * \brief copies the first N items to the output then signals done - * \ingroup slicedice_blk - * - * Useful for building test cases - */ - -class GR_CORE_API gr_head : public gr_sync_block -{ - friend GR_CORE_API gr_head_sptr gr_make_head (size_t sizeof_stream_item, unsigned long long nitems); - gr_head (size_t sizeof_stream_item, unsigned long long nitems); - - unsigned long long d_nitems; - unsigned long long d_ncopied_items; - - public: - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - void reset() { d_ncopied_items = 0; } - void set_length(int nitems) { d_nitems = nitems; } -}; - -GR_CORE_API gr_head_sptr -gr_make_head (size_t sizeof_stream_item, unsigned long long nitems); - - -#endif /* INCLUDED_GR_HEAD_H */ diff --git a/gnuradio-core/src/lib/general/gr_head.i b/gnuradio-core/src/lib/general/gr_head.i deleted file mode 100644 index 11f3331d47..0000000000 --- a/gnuradio-core/src/lib/general/gr_head.i +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2009,2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,head); - -gr_head_sptr gr_make_head(size_t sizeof_stream_item, unsigned long long nitems); - -class gr_head : public gr_block { - gr_head(); -public: - void reset(); - void set_length(int nitems); -}; - diff --git a/gnuradio-core/src/lib/general/gr_iqcomp_cc.cc b/gnuradio-core/src/lib/general/gr_iqcomp_cc.cc deleted file mode 100644 index 599b25b728..0000000000 --- a/gnuradio-core/src/lib/general/gr_iqcomp_cc.cc +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_iqcomp_cc.h> -#include <gr_io_signature.h> - -gr_iqcomp_cc_sptr -gr_make_iqcomp_cc (float mu) -{ - return gnuradio::get_initial_sptr(new gr_iqcomp_cc (mu)); -} - -gr_iqcomp_cc::gr_iqcomp_cc (float mu) - : gr_sync_block ("iqcomp_cc", - gr_make_io_signature (1, 1, sizeof (gr_complex)), - gr_make_io_signature (1, 1, sizeof (gr_complex))), - d_mu (mu) -{ - d_wi=0.0; - d_wq=0.0; -} - -int -gr_iqcomp_cc::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const gr_complex *iptr = (gr_complex *) input_items[0]; - // gr_complex *optr = (gr_complex *) output_items[0]; - - for(int i = 0 ; i < noutput_items ; i++) { - float i_out = iptr[i].real() - iptr[i].imag() * d_wq; - float q_out = iptr[i].imag() - iptr[i].real() * d_wi; - d_wi += d_mu * q_out * iptr[i].real(); - d_wq += d_mu * i_out * iptr[i].imag(); - } - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_kludge_copy.cc b/gnuradio-core/src/lib/general/gr_kludge_copy.cc deleted file mode 100644 index f6a8d8af68..0000000000 --- a/gnuradio-core/src/lib/general/gr_kludge_copy.cc +++ /dev/null @@ -1,64 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_kludge_copy.h> -#include <gr_io_signature.h> -#include <string.h> - -gr_kludge_copy_sptr -gr_make_kludge_copy(size_t itemsize) -{ - return gnuradio::get_initial_sptr(new gr_kludge_copy(itemsize)); -} - -gr_kludge_copy::gr_kludge_copy(size_t itemsize) - : gr_sync_block ("kludge_copy", - gr_make_io_signature (1, -1, itemsize), - gr_make_io_signature (1, -1, itemsize)), - d_itemsize(itemsize) -{ -} - -bool -gr_kludge_copy::check_topology(int ninputs, int noutputs) -{ - return ninputs == noutputs; -} - -int -gr_kludge_copy::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]; - - int ninputs = input_items.size(); - for (int i = 0; i < ninputs; i++){ - memcpy(out[i], in[i], noutput_items * d_itemsize); - } - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_kludge_copy.h b/gnuradio-core/src/lib/general/gr_kludge_copy.h deleted file mode 100644 index 0bcf144699..0000000000 --- a/gnuradio-core/src/lib/general/gr_kludge_copy.h +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_KLUDGE_COPY_H -#define INCLUDED_GR_KLUDGE_COPY_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gr_kludge_copy; -typedef boost::shared_ptr<gr_kludge_copy> gr_kludge_copy_sptr; - -GR_CORE_API gr_kludge_copy_sptr gr_make_kludge_copy(size_t itemsize); - -/*! - * \brief output[i] = input[i] - * \ingroup misc_blk - * - * This is a short term kludge to work around a problem with the hierarchical block impl. - */ -class GR_CORE_API gr_kludge_copy : public gr_sync_block -{ - size_t d_itemsize; - - friend GR_CORE_API gr_kludge_copy_sptr gr_make_kludge_copy(size_t itemsize); - gr_kludge_copy(size_t itemsize); - - public: - - bool check_topology(int ninputs, int noutputs); - - 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_kludge_copy.i b/gnuradio-core/src/lib/general/gr_kludge_copy.i deleted file mode 100644 index 7ff2b57365..0000000000 --- a/gnuradio-core/src/lib/general/gr_kludge_copy.i +++ /dev/null @@ -1,31 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,kludge_copy) - -gr_kludge_copy_sptr gr_make_kludge_copy(size_t itemsize); - -class gr_kludge_copy : public gr_sync_block -{ - private: - gr_kludge_copy(size_t itemsize); -}; diff --git a/gnuradio-core/src/lib/general/gr_lfsr_32k_source_s.cc b/gnuradio-core/src/lib/general/gr_lfsr_32k_source_s.cc deleted file mode 100644 index c9a8742486..0000000000 --- a/gnuradio-core/src/lib/general/gr_lfsr_32k_source_s.cc +++ /dev/null @@ -1,70 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <gr_lfsr_32k_source_s.h> -#include <gr_io_signature.h> -#include <stdexcept> - - -gr_lfsr_32k_source_s_sptr -gr_make_lfsr_32k_source_s () -{ - return gnuradio::get_initial_sptr(new gr_lfsr_32k_source_s ()); -} - - -gr_lfsr_32k_source_s::gr_lfsr_32k_source_s () - : gr_sync_block ("lfsr_32k_source_s", - gr_make_io_signature (0, 0, 0), - gr_make_io_signature (1, 1, sizeof (short))), - d_index (0) -{ - gri_lfsr_32k lfsr; - - for (int i = 0; i < BUFSIZE; i++) - d_buffer[i] = lfsr.next_short (); -} - -int -gr_lfsr_32k_source_s::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - short *out = (short *) output_items[0]; - short *buf = d_buffer; - int index = d_index; - - for (int i = 0; i < noutput_items; i++){ - out[i] = buf[index]; - // index = (index + 1) & (BUFSIZE - 1); - index = index + 1; - if (index >= BUFSIZE) - index = 0; - } - - d_index = index; - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_lfsr_32k_source_s.h b/gnuradio-core/src/lib/general/gr_lfsr_32k_source_s.h deleted file mode 100644 index db107652ad..0000000000 --- a/gnuradio-core/src/lib/general/gr_lfsr_32k_source_s.h +++ /dev/null @@ -1,61 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_LFSR_32K_SOURCE_S_H -#define INCLUDED_GR_LFSR_32K_SOURCE_S_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <gri_lfsr_32k.h> - -class gr_lfsr_32k_source_s; -typedef boost::shared_ptr<gr_lfsr_32k_source_s> gr_lfsr_32k_source_s_sptr; - -GR_CORE_API gr_lfsr_32k_source_s_sptr gr_make_lfsr_32k_source_s (); - -/*! - * \brief LFSR pseudo-random source with period of 2^15 bits (2^11 shorts) - * \ingroup source_blk - * - * This source is typically used along with gr_check_lfsr_32k_s to test - * the USRP using its digital loopback mode. - */ -class GR_CORE_API gr_lfsr_32k_source_s : public gr_sync_block -{ - friend GR_CORE_API gr_lfsr_32k_source_s_sptr gr_make_lfsr_32k_source_s (); - - - static const int BUFSIZE = 2048 - 1; // ensure pattern isn't packet aligned - int d_index; - short d_buffer[BUFSIZE]; - - gr_lfsr_32k_source_s (); - - public: - - virtual 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_lfsr_32k_source_s.i b/gnuradio-core/src/lib/general/gr_lfsr_32k_source_s.i deleted file mode 100644 index c2dc1c61b7..0000000000 --- a/gnuradio-core/src/lib/general/gr_lfsr_32k_source_s.i +++ /dev/null @@ -1,31 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,lfsr_32k_source_s); - -gr_lfsr_32k_source_s_sptr gr_make_lfsr_32k_source_s (); - -class gr_lfsr_32k_source_s : public gr_sync_block -{ - private: - gr_lfsr_32k_source_s (); -}; diff --git a/gnuradio-core/src/lib/general/gr_nco.h b/gnuradio-core/src/lib/general/gr_nco.h new file mode 100644 index 0000000000..fb51106aab --- /dev/null +++ b/gnuradio-core/src/lib/general/gr_nco.h @@ -0,0 +1,198 @@ +/* -*- c++ -*- */ +/* + * Copyright 2002 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 _GR_NCO_H_ +#define _GR_NCO_H_ + + +#include <vector> +#include <gr_sincos.h> +#include <cmath> +#include <gr_complex.h> + +/*! + * \brief base class template for Numerically Controlled Oscillator (NCO) + * \ingroup misc + */ + + +//FIXME Eventually generalize this to fixed point + +template<class o_type, class i_type> +class gr_nco { +public: + gr_nco () : phase (0), phase_inc(0) {} + + virtual ~gr_nco () {} + + // radians + void set_phase (double angle) { + phase = angle; + } + + void adjust_phase (double delta_phase) { + phase += delta_phase; + } + + + // angle_rate is in radians / step + void set_freq (double angle_rate){ + phase_inc = angle_rate; + } + + // angle_rate is a delta in radians / step + void adjust_freq (double delta_angle_rate) + { + phase_inc += delta_angle_rate; + } + + // increment current phase angle + + void step () + { + phase += phase_inc; + if (fabs (phase) > M_PI){ + + while (phase > M_PI) + phase -= 2*M_PI; + + while (phase < -M_PI) + phase += 2*M_PI; + } + } + + void step (int n) + { + phase += phase_inc * n; + if (fabs (phase) > M_PI){ + + while (phase > M_PI) + phase -= 2*M_PI; + + while (phase < -M_PI) + phase += 2*M_PI; + } + } + + // units are radians / step + double get_phase () const { return phase; } + double get_freq () const { return phase_inc; } + + // compute sin and cos for current phase angle + void sincos (float *sinx, float *cosx) const; + + // compute cos or sin for current phase angle + float cos () const { return std::cos (phase); } + float sin () const { return std::sin (phase); } + + // compute a block at a time + void sin (float *output, int noutput_items, double ampl = 1.0); + void cos (float *output, int noutput_items, double ampl = 1.0); + void sincos (gr_complex *output, int noutput_items, double ampl = 1.0); + void sin (short *output, int noutput_items, double ampl = 1.0); + void cos (short *output, int noutput_items, double ampl = 1.0); + void sin (int *output, int noutput_items, double ampl = 1.0); + void cos (int *output, int noutput_items, double ampl = 1.0); + +protected: + double phase; + double phase_inc; +}; + +template<class o_type, class i_type> +void +gr_nco<o_type,i_type>::sincos (float *sinx, float *cosx) const +{ + gr_sincosf (phase, sinx, cosx); +} + +template<class o_type, class i_type> +void +gr_nco<o_type,i_type>::sin (float *output, int noutput_items, double ampl) +{ + for (int i = 0; i < noutput_items; i++){ + output[i] = (float)(sin () * ampl); + step (); + } +} + +template<class o_type, class i_type> +void +gr_nco<o_type,i_type>::cos (float *output, int noutput_items, double ampl) +{ + for (int i = 0; i < noutput_items; i++){ + output[i] = (float)(cos () * ampl); + step (); + } +} + +template<class o_type, class i_type> +void +gr_nco<o_type,i_type>::sin (short *output, int noutput_items, double ampl) +{ + for (int i = 0; i < noutput_items; i++){ + output[i] = (short)(sin() * ampl); + step (); + } +} + +template<class o_type, class i_type> +void +gr_nco<o_type,i_type>::cos (short *output, int noutput_items, double ampl) +{ + for (int i = 0; i < noutput_items; i++){ + output[i] = (short)(cos () * ampl); + step (); + } +} + +template<class o_type, class i_type> +void +gr_nco<o_type,i_type>::sin (int *output, int noutput_items, double ampl) +{ + for (int i = 0; i < noutput_items; i++){ + output[i] = (int)(sin () * ampl); + step (); + } +} + +template<class o_type, class i_type> +void +gr_nco<o_type,i_type>::cos (int *output, int noutput_items, double ampl) +{ + for (int i = 0; i < noutput_items; i++){ + output[i] = (int)(cos () * ampl); + step (); + } +} + +template<class o_type, class i_type> +void +gr_nco<o_type,i_type>::sincos (gr_complex *output, int noutput_items, double ampl) +{ + for (int i = 0; i < noutput_items; i++){ + float cosx, sinx; + sincos (&sinx, &cosx); + output[i] = gr_complex(cosx * ampl, sinx * ampl); + step (); + } +} +#endif /* _NCO_H_ */ diff --git a/gnuradio-core/src/lib/general/gr_nop.cc b/gnuradio-core/src/lib/general/gr_nop.cc deleted file mode 100644 index 164f3ba8dd..0000000000 --- a/gnuradio-core/src/lib/general/gr_nop.cc +++ /dev/null @@ -1,92 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <gr_nop.h> -#include <gr_io_signature.h> -#include <boost/bind.hpp> - -#ifdef GR_CTRLPORT -#include <rpcregisterhelpers.h> -#endif - -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)), - d_nmsgs_recvd(0), d_ctrlport_test(0) -{ - // Arrange to have count_received_msgs called when messages are received. - message_port_register_in(pmt::mp("port")); - set_msg_handler(pmt::mp("port"), boost::bind(&gr_nop::count_received_msgs, this, _1)); -} - -// 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) -{ - d_nmsgs_recvd++; -} - -int -gr_nop::general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - // eat any input that's available - for (unsigned i = 0; i < ninput_items.size (); i++) - consume (i, ninput_items[i]); - - return noutput_items; -} - -void -gr_nop::setup_rpc() -{ -#ifdef GR_CTRLPORT - d_rpc_vars.push_back( - rpcbasic_sptr(new rpcbasic_register_get<gr_nop, int>( - alias(), "test", - &gr_nop::ctrlport_test, - pmt::mp(-256), pmt::mp(255), pmt::mp(0), - "", "Simple testing variable", - RPC_PRIVLVL_MIN, DISPNULL))); - - d_rpc_vars.push_back( - rpcbasic_sptr(new rpcbasic_register_set<gr_nop, int>( - alias(), "test", - &gr_nop::set_ctrlport_test, - pmt::mp(-256), pmt::mp(255), pmt::mp(0), - "", "Simple testing variable", - RPC_PRIVLVL_MIN, DISPNULL))); -#endif /* GR_CTRLPORT */ -} diff --git a/gnuradio-core/src/lib/general/gr_nop.h b/gnuradio-core/src/lib/general/gr_nop.h deleted file mode 100644 index 5f1cb13a02..0000000000 --- a/gnuradio-core/src/lib/general/gr_nop.h +++ /dev/null @@ -1,67 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_NOP_H -#define INCLUDED_GR_NOP_H - -#include <gr_core_api.h> -#include <gr_block.h> -#include <stddef.h> // size_t - -class gr_nop; -typedef boost::shared_ptr<gr_nop> gr_nop_sptr; - -GR_CORE_API gr_nop_sptr -gr_make_nop (size_t sizeof_stream_item); - -/*! - * \brief Does nothing. Used for testing only. - * \ingroup misc_blk - */ -class GR_CORE_API gr_nop : public gr_block -{ - friend GR_CORE_API gr_nop_sptr gr_make_nop (size_t sizeof_stream_item); - gr_nop (size_t sizeof_stream_item); - - std::vector<boost::any> d_rpc_vars; - void setup_rpc(); - -protected: - int d_nmsgs_recvd; - int d_ctrlport_test; - - // 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); - - int nmsgs_received() const { return d_nmsgs_recvd; } - - int ctrlport_test() { return d_ctrlport_test; } - void set_ctrlport_test(int x) { d_ctrlport_test = x; } -}; - -#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 deleted file mode 100644 index 73ffa93630..0000000000 --- a/gnuradio-core/src/lib/general/gr_nop.i +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,nop) - -gr_nop_sptr gr_make_nop (size_t sizeof_stream_item); - -class gr_nop : public gr_block { -public: - int ctrlport_test(); - void set_ctrlport_test(int x); -private: - gr_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 deleted file mode 100644 index 1836655024..0000000000 --- a/gnuradio-core/src/lib/general/gr_null_sink.cc +++ /dev/null @@ -1,49 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_null_sink.h> -#include <gr_io_signature.h> - -gr_null_sink::gr_null_sink (size_t sizeof_stream_item) - : gr_sync_block ("null_sink", - gr_make_io_signature (1, 1, sizeof_stream_item), - gr_make_io_signature (0, 0, 0)) -{ -} - -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)); -} - -int -gr_null_sink::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_null_source.i b/gnuradio-core/src/lib/general/gr_null_source.i deleted file mode 100644 index 120a59999c..0000000000 --- a/gnuradio-core/src/lib/general/gr_null_source.i +++ /dev/null @@ -1,31 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -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 { -private: - gr_null_source (size_t sizeof_stream_item); -}; - diff --git a/gnuradio-core/src/lib/general/gr_ofdm_bpsk_demapper.cc b/gnuradio-core/src/lib/general/gr_ofdm_bpsk_demapper.cc deleted file mode 100644 index 2b718e5ce2..0000000000 --- a/gnuradio-core/src/lib/general/gr_ofdm_bpsk_demapper.cc +++ /dev/null @@ -1,97 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,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_ofdm_bpsk_demapper.h> -#include <gr_io_signature.h> - -gr_ofdm_bpsk_demapper_sptr -gr_make_ofdm_bpsk_demapper (unsigned int occupied_carriers) -{ - return gnuradio::get_initial_sptr(new gr_ofdm_bpsk_demapper (occupied_carriers)); -} - -gr_ofdm_bpsk_demapper::gr_ofdm_bpsk_demapper (unsigned occupied_carriers) - : gr_block ("ofdm_bpsk_demapper", - gr_make_io_signature (1, 1, sizeof(gr_complex)*occupied_carriers), - gr_make_io_signature (1, 1, sizeof(unsigned char))), - d_occupied_carriers(occupied_carriers), - d_byte_offset(0), d_partial_byte(0) -{ -} - -gr_ofdm_bpsk_demapper::~gr_ofdm_bpsk_demapper(void) -{ -} - -unsigned char gr_ofdm_bpsk_demapper::slicer(gr_complex x) -{ - return (unsigned char)(x.real() > 0 ? 1 : 0); -} - -void -gr_ofdm_bpsk_demapper::forecast (int noutput_items, gr_vector_int &ninput_items_required) -{ - unsigned ninputs = ninput_items_required.size (); - for (unsigned i = 0; i < ninputs; i++) - ninput_items_required[i] = 1; -} - -int -gr_ofdm_bpsk_demapper::general_work(int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const gr_complex *in = (const gr_complex *)input_items[0]; - unsigned char *out = (unsigned char *) output_items[0]; - - unsigned int i=0, bytes_produced=0; - - while(i < d_occupied_carriers) { - - while((d_byte_offset < 8) && (i < d_occupied_carriers)) { - //fprintf(stderr, "%f+j%f\n", in[i].real(), in[i].imag()); - d_partial_byte |= slicer(in[i++]) << (d_byte_offset++); - } - - if(d_byte_offset == 8) { - out[bytes_produced++] = d_partial_byte; - d_byte_offset = 0; - d_partial_byte = 0; - } - } - -#if 0 -printf("demod out: "); - for(i = 0; i < bytes_produced; i++) { - printf("%4x", out[i]); - } - printf(" \tlen: %d\n", i); -#endif - - consume_each(1); - return bytes_produced; -} diff --git a/gnuradio-core/src/lib/general/gr_ofdm_bpsk_demapper.h b/gnuradio-core/src/lib/general/gr_ofdm_bpsk_demapper.h deleted file mode 100644 index d69d427edb..0000000000 --- a/gnuradio-core/src/lib/general/gr_ofdm_bpsk_demapper.h +++ /dev/null @@ -1,69 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_OFDM_BPSK_DEMAPPER_H -#define INCLUDED_GR_OFDM_BPSK_DEMAPPER_H - - -#include <gr_core_api.h> -#include <gr_block.h> -#include <vector> - -class gr_ofdm_bpsk_demapper; -typedef boost::shared_ptr<gr_ofdm_bpsk_demapper> gr_ofdm_bpsk_demapper_sptr; - -GR_CORE_API gr_ofdm_bpsk_demapper_sptr -gr_make_ofdm_bpsk_demapper (unsigned int occupied_carriers); - - -/*! - * \brief take a vector of complex constellation points in from an FFT - * and demodulate to a stream of bits. Simple BPSK version. - * \ingroup ofdm_blk - */ -class GR_CORE_API gr_ofdm_bpsk_demapper : public gr_block -{ - friend GR_CORE_API gr_ofdm_bpsk_demapper_sptr - gr_make_ofdm_bpsk_demapper (unsigned int occupied_carriers); - - protected: - gr_ofdm_bpsk_demapper (unsigned int occupied_carriers); - - private: - unsigned char slicer(gr_complex x); - - unsigned int d_occupied_carriers; - unsigned int d_byte_offset; - unsigned char d_partial_byte; - - void forecast(int noutput_items, gr_vector_int &ninput_items_required); - - public: - ~gr_ofdm_bpsk_demapper(void); - int general_work(int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - - -#endif diff --git a/gnuradio-core/src/lib/general/gr_ofdm_bpsk_demapper.i b/gnuradio-core/src/lib/general/gr_ofdm_bpsk_demapper.i deleted file mode 100644 index e58a4e40c5..0000000000 --- a/gnuradio-core/src/lib/general/gr_ofdm_bpsk_demapper.i +++ /dev/null @@ -1,40 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#include <vector> - -GR_SWIG_BLOCK_MAGIC(gr,ofdm_bpsk_demapper) - -gr_ofdm_bpsk_demapper_sptr -gr_make_ofdm_bpsk_demapper (unsigned int occupied_carriers); - -class gr_ofdm_bpsk_demapper : public gr_sync_decimator -{ - protected: - gr_ofdm_bpsk_demapper (unsigned int occupied_carriers); - - public: - int general_work(int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; diff --git a/gnuradio-core/src/lib/general/gr_ofdm_frame_sink2.cc b/gnuradio-core/src/lib/general/gr_ofdm_frame_sink2.cc deleted file mode 100644 index eb12327565..0000000000 --- a/gnuradio-core/src/lib/general/gr_ofdm_frame_sink2.cc +++ /dev/null @@ -1,374 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2008,2010,2011 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_ofdm_frame_sink2.h> -#include <gr_io_signature.h> -#include <gr_expj.h> -#include <gr_math.h> -#include <math.h> -#include <cstdio> -#include <stdexcept> -#include <iostream> -#include <string.h> -#include <gr_constellation.h> - -#define VERBOSE 0 - -inline void -gr_ofdm_frame_sink2::enter_search() -{ - if (VERBOSE) - fprintf(stderr, "@ enter_search\n"); - - d_state = STATE_SYNC_SEARCH; - -} - -inline void -gr_ofdm_frame_sink2::enter_have_sync() -{ - if (VERBOSE) - fprintf(stderr, "@ enter_have_sync\n"); - - d_state = STATE_HAVE_SYNC; - - // clear state of demapper - d_byte_offset = 0; - d_partial_byte = 0; - - d_header = 0; - d_headerbytelen_cnt = 0; - - // Resetting PLL - d_freq = 0.0; - d_phase = 0.0; - fill(d_dfe.begin(), d_dfe.end(), gr_complex(1.0,0.0)); -} - -inline void -gr_ofdm_frame_sink2::enter_have_header() -{ - d_state = STATE_HAVE_HEADER; - - // header consists of two 16-bit shorts in network byte order - // payload length is lower 12 bits - // whitener offset is upper 4 bits - d_packetlen = (d_header >> 16) & 0x0fff; - d_packet_whitener_offset = (d_header >> 28) & 0x000f; - d_packetlen_cnt = 0; - - if (VERBOSE) - fprintf(stderr, "@ enter_have_header (payload_len = %d) (offset = %d)\n", - d_packetlen, d_packet_whitener_offset); -} - - -unsigned int gr_ofdm_frame_sink2::demapper(const gr_complex *in, - unsigned char *out) -{ - unsigned int i=0, bytes_produced=0; - gr_complex carrier; - - carrier=gr_expj(d_phase); - - gr_complex accum_error = 0.0; - //while(i < d_occupied_carriers) { - while(i < d_subcarrier_map.size()) { - if(d_nresid > 0) { - d_partial_byte |= d_resid; - d_byte_offset += d_nresid; - d_nresid = 0; - d_resid = 0; - } - - //while((d_byte_offset < 8) && (i < d_occupied_carriers)) { - while((d_byte_offset < 8) && (i < d_subcarrier_map.size())) { - //gr_complex sigrot = in[i]*carrier*d_dfe[i]; - gr_complex sigrot = in[d_subcarrier_map[i]]*carrier*d_dfe[i]; - - if(d_derotated_output != NULL){ - d_derotated_output[i] = sigrot; - } - - unsigned char bits = d_constell->decision_maker(&sigrot); - - gr_complex closest_sym = d_constell->points()[bits]; - - accum_error += sigrot * conj(closest_sym); - - // FIX THE FOLLOWING STATEMENT - if (norm(sigrot)> 0.001) d_dfe[i] += d_eq_gain*(closest_sym/sigrot-d_dfe[i]); - - i++; - - if((8 - d_byte_offset) >= d_nbits) { - d_partial_byte |= bits << (d_byte_offset); - d_byte_offset += d_nbits; - } - else { - d_nresid = d_nbits-(8-d_byte_offset); - int mask = ((1<<(8-d_byte_offset))-1); - d_partial_byte |= (bits & mask) << d_byte_offset; - d_resid = bits >> (8-d_byte_offset); - d_byte_offset += (d_nbits - d_nresid); - } - //printf("demod symbol: %.4f + j%.4f bits: %x partial_byte: %x byte_offset: %d resid: %x nresid: %d\n", - // in[i-1].real(), in[i-1].imag(), bits, d_partial_byte, d_byte_offset, d_resid, d_nresid); - } - - if(d_byte_offset == 8) { - //printf("demod byte: %x \n\n", d_partial_byte); - out[bytes_produced++] = d_partial_byte; - d_byte_offset = 0; - d_partial_byte = 0; - } - } - //std::cerr << "accum_error " << accum_error << std::endl; - - float angle = arg(accum_error); - - d_freq = d_freq - d_freq_gain*angle; - d_phase = d_phase + d_freq - d_phase_gain*angle; - if (d_phase >= 2*M_PI) d_phase -= 2*M_PI; - if (d_phase <0) d_phase += 2*M_PI; - - //if(VERBOSE) - // std::cerr << angle << "\t" << d_freq << "\t" << d_phase << "\t" << std::endl; - - return bytes_produced; -} - - -gr_ofdm_frame_sink2_sptr -gr_make_ofdm_frame_sink2(gr_constellation_sptr constell, - gr_msg_queue_sptr target_queue, unsigned int occupied_carriers, - float phase_gain, float freq_gain) -{ - return gnuradio::get_initial_sptr(new gr_ofdm_frame_sink2(constell, - target_queue, occupied_carriers, - phase_gain, freq_gain)); -} - - -gr_ofdm_frame_sink2::gr_ofdm_frame_sink2(gr_constellation_sptr constell, - gr_msg_queue_sptr target_queue, unsigned int occupied_carriers, - float phase_gain, float freq_gain) - : gr_sync_block ("ofdm_frame_sink2", - gr_make_io_signature2 (2, 2, sizeof(gr_complex)*occupied_carriers, sizeof(char)), - gr_make_io_signature (1, 1, sizeof(gr_complex)*occupied_carriers)), - d_constell(constell), - d_target_queue(target_queue), d_occupied_carriers(occupied_carriers), - d_byte_offset(0), d_partial_byte(0), - d_resid(0), d_nresid(0),d_phase(0),d_freq(0),d_phase_gain(phase_gain),d_freq_gain(freq_gain), - d_eq_gain(0.05) -{ - if (d_constell->dimensionality() != 1) - throw std::runtime_error ("This receiver only works with constellations of dimension 1."); - - std::string carriers = "FE7F"; - - // A bit hacky to fill out carriers to occupied_carriers length - int diff = (d_occupied_carriers - 4*carriers.length()); - while(diff > 7) { - carriers.insert(0, "f"); - carriers.insert(carriers.length(), "f"); - diff -= 8; - } - - // if there's extras left to be processed - // divide remaining to put on either side of current map - // all of this is done to stick with the concept of a carrier map string that - // can be later passed by the user, even though it'd be cleaner to just do this - // on the carrier map itself - int diff_left=0; - int diff_right=0; - - // dictionary to convert from integers to ascii hex representation - char abc[16] = {'0', '1', '2', '3', '4', '5', '6', '7', - '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; - if(diff > 0) { - char c[2] = {0,0}; - - diff_left = (int)ceil((float)diff/2.0f); // number of carriers to put on the left side - c[0] = abc[(1 << diff_left) - 1]; // convert to bits and move to ASCI integer - carriers.insert(0, c); - - diff_right = diff - diff_left; // number of carriers to put on the right side - c[0] = abc[0xF^((1 << diff_right) - 1)]; // convert to bits and move to ASCI integer - carriers.insert(carriers.length(), c); - } - - // It seemed like such a good idea at the time... - // because we are only dealing with the occupied_carriers - // at this point, the diff_left in the following compensates - // for any offset from the 0th carrier introduced - unsigned int i,j,k; - for(i = 0; i < (d_occupied_carriers/4)+diff_left; i++) { - char c = carriers[i]; - for(j = 0; j < 4; j++) { - k = (strtol(&c, NULL, 16) >> (3-j)) & 0x1; - if(k) { - d_subcarrier_map.push_back(4*i + j - diff_left); - } - } - } - - // make sure we stay in the limit currently imposed by the occupied_carriers - if(d_subcarrier_map.size() > d_occupied_carriers) { - throw std::invalid_argument("gr_ofdm_mapper_bcv: subcarriers allocated exceeds size of occupied carriers"); - } - - d_bytes_out = new unsigned char[d_occupied_carriers]; - d_dfe.resize(occupied_carriers); - fill(d_dfe.begin(), d_dfe.end(), gr_complex(1.0,0.0)); - - d_nbits = d_constell->bits_per_symbol(); - - enter_search(); -} - -gr_ofdm_frame_sink2::~gr_ofdm_frame_sink2 () -{ - delete [] d_bytes_out; -} - - -int -gr_ofdm_frame_sink2::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const gr_complex *in = (const gr_complex *) input_items[0]; - const char *sig = (const char *) input_items[1]; - unsigned int j = 0; - unsigned int bytes=0; - - // If the output is connected, send it the derotated symbols - if(output_items.size() >= 1) - d_derotated_output = (gr_complex *)output_items[0]; - else - d_derotated_output = NULL; - - if (VERBOSE) - fprintf(stderr,">>> Entering state machine\n"); - - switch(d_state) { - - case STATE_SYNC_SEARCH: // Look for flag indicating beginning of pkt - if (VERBOSE) - fprintf(stderr,"SYNC Search, noutput=%d\n", noutput_items); - - if (sig[0]) { // Found it, set up for header decode - enter_have_sync(); - } - break; - - case STATE_HAVE_SYNC: - // only demod after getting the preamble signal; otherwise, the - // equalizer taps will screw with the PLL performance - bytes = demapper(&in[0], d_bytes_out); - - if (VERBOSE) { - if(sig[0]) - printf("ERROR -- Found SYNC in HAVE_SYNC\n"); - fprintf(stderr,"Header Search bitcnt=%d, header=0x%08x\n", - d_headerbytelen_cnt, d_header); - } - - j = 0; - while(j < bytes) { - d_header = (d_header << 8) | (d_bytes_out[j] & 0xFF); - j++; - - if (++d_headerbytelen_cnt == HEADERBYTELEN) { - - if (VERBOSE) - fprintf(stderr, "got header: 0x%08x\n", d_header); - - // we have a full header, check to see if it has been received properly - if (header_ok()){ - enter_have_header(); - - if (VERBOSE) - printf("\nPacket Length: %d\n", d_packetlen); - - while((j < bytes) && (d_packetlen_cnt < d_packetlen)) { - d_packet[d_packetlen_cnt++] = d_bytes_out[j++]; - } - - if(d_packetlen_cnt == d_packetlen) { - gr_message_sptr msg = - gr_make_message(0, d_packet_whitener_offset, 0, d_packetlen); - memcpy(msg->msg(), d_packet, d_packetlen_cnt); - d_target_queue->insert_tail(msg); // send it - msg.reset(); // free it up - - enter_search(); - } - } - else { - enter_search(); // bad header - } - } - } - break; - - case STATE_HAVE_HEADER: - bytes = demapper(&in[0], d_bytes_out); - - if (VERBOSE) { - if(sig[0]) - printf("ERROR -- Found SYNC in HAVE_HEADER at %d, length of %d\n", d_packetlen_cnt, d_packetlen); - fprintf(stderr,"Packet Build\n"); - } - - j = 0; - while(j < bytes) { - d_packet[d_packetlen_cnt++] = d_bytes_out[j++]; - - if (d_packetlen_cnt == d_packetlen){ // packet is filled - // build a message - // NOTE: passing header field as arg1 is not scalable - gr_message_sptr msg = - gr_make_message(0, d_packet_whitener_offset, 0, d_packetlen_cnt); - memcpy(msg->msg(), d_packet, d_packetlen_cnt); - - d_target_queue->insert_tail(msg); // send it - msg.reset(); // free it up - - enter_search(); - break; - } - } - break; - - default: - assert(0); - - } // switch - - return 1; -} diff --git a/gnuradio-core/src/lib/general/gr_ofdm_frame_sink2.h b/gnuradio-core/src/lib/general/gr_ofdm_frame_sink2.h deleted file mode 100644 index a743e8c5a5..0000000000 --- a/gnuradio-core/src/lib/general/gr_ofdm_frame_sink2.h +++ /dev/null @@ -1,121 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,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_OFDM_FRAME_SINK2_H -#define INCLUDED_GR_OFDM_FRAME_SINK2_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <gr_msg_queue.h> -#include <gr_constellation.h> - -class gr_ofdm_frame_sink2; -typedef boost::shared_ptr<gr_ofdm_frame_sink2> gr_ofdm_frame_sink2_sptr; - -GR_CORE_API gr_ofdm_frame_sink2_sptr -gr_make_ofdm_frame_sink2 (gr_constellation_sptr constell, - gr_msg_queue_sptr target_queue, unsigned int occupied_tones, - float phase_gain=0.25, float freq_gain=0.25*0.25/4.0); - -/*! - * \brief Takes an OFDM symbol in, demaps it into bits of 0's and 1's, packs - * them into packets, and sends to to a message queue sink. - * \ingroup sink_blk - * \ingroup ofdm_blk - * - * NOTE: The mod input parameter simply chooses a pre-defined demapper/slicer. Eventually, - * we want to be able to pass in a reference to an object to do the demapping and slicing - * for a given modulation type. - */ -class GR_CORE_API gr_ofdm_frame_sink2 : public gr_sync_block -{ - friend GR_CORE_API gr_ofdm_frame_sink2_sptr - gr_make_ofdm_frame_sink2 (gr_constellation_sptr constell, - gr_msg_queue_sptr target_queue, unsigned int occupied_tones, - float phase_gain, float freq_gain); - - private: - enum state_t {STATE_SYNC_SEARCH, STATE_HAVE_SYNC, STATE_HAVE_HEADER}; - - static const int MAX_PKT_LEN = 4096; - static const int HEADERBYTELEN = 4; - - gr_msg_queue_sptr d_target_queue; // where to send the packet when received - state_t d_state; - unsigned int d_header; // header bits - int d_headerbytelen_cnt; // how many so far - - unsigned char *d_bytes_out; // hold the current bytes produced by the demapper - - unsigned int d_occupied_carriers; - unsigned int d_byte_offset; - unsigned int d_partial_byte; - - unsigned char d_packet[MAX_PKT_LEN]; // assembled payload - int d_packetlen; // length of packet - int d_packet_whitener_offset; // offset into whitener string to use - int d_packetlen_cnt; // how many so far - - gr_complex * d_derotated_output; // Pointer to output stream to send deroated symbols out - - gr_constellation_sptr d_constell; - std::vector<gr_complex> d_dfe; - unsigned int d_nbits; - - unsigned char d_resid; - unsigned int d_nresid; - float d_phase; - float d_freq; - float d_phase_gain; - float d_freq_gain; - float d_eq_gain; - - std::vector<int> d_subcarrier_map; - - protected: - gr_ofdm_frame_sink2(gr_constellation_sptr constell, - gr_msg_queue_sptr target_queue, unsigned int occupied_tones, - float phase_gain, float freq_gain); - - void enter_search(); - void enter_have_sync(); - void enter_have_header(); - - bool header_ok() - { - // confirm that two copies of header info are identical - return ((d_header >> 16) ^ (d_header & 0xffff)) == 0; - } - - unsigned char slicer(const gr_complex x); - unsigned int demapper(const gr_complex *in, - unsigned char *out); - - public: - ~gr_ofdm_frame_sink2(); - - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_GR_OFDM_FRAME_SINK2_H */ diff --git a/gnuradio-core/src/lib/general/gr_ofdm_frame_sink2.i b/gnuradio-core/src/lib/general/gr_ofdm_frame_sink2.i deleted file mode 100644 index 8c04d1e160..0000000000 --- a/gnuradio-core/src/lib/general/gr_ofdm_frame_sink2.i +++ /dev/null @@ -1,39 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,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,ofdm_frame_sink2); - -gr_ofdm_frame_sink2_sptr -gr_make_ofdm_frame_sink2(gr_constellation_sptr constell, - gr_msg_queue_sptr target_queue, unsigned int occupied_tones, - float phase_gain=0.25, float freq_gain=0.25*0.25/4); - -class gr_ofdm_frame_sink2 : public gr_sync_block -{ - protected: - gr_ofdm_frame_sink2(gr_constellation_sptr constell, - gr_msg_queue_sptr target_queue, unsigned int occupied_tones, - float phase_gain, float freq_gain); - - public: - ~gr_ofdm_frame_sink2(); -}; diff --git a/gnuradio-core/src/lib/general/gr_pa_2x2_phase_combiner.cc b/gnuradio-core/src/lib/general/gr_pa_2x2_phase_combiner.cc deleted file mode 100644 index 3187536726..0000000000 --- a/gnuradio-core/src/lib/general/gr_pa_2x2_phase_combiner.cc +++ /dev/null @@ -1,74 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,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_pa_2x2_phase_combiner.h> -#include <gr_io_signature.h> - -gr_pa_2x2_phase_combiner_sptr -gr_make_pa_2x2_phase_combiner() -{ - return gnuradio::get_initial_sptr(new gr_pa_2x2_phase_combiner()); -} - -gr_pa_2x2_phase_combiner::gr_pa_2x2_phase_combiner () - : gr_sync_block ("pa_2x2_phase_combiner", - gr_make_io_signature (1, 1, NM * sizeof (gr_complex)), - gr_make_io_signature (1, 1, sizeof (float))) -{ - set_theta(0); -} - -void -gr_pa_2x2_phase_combiner::set_theta(float theta) -{ - d_theta = theta; - gr_complex j = gr_complex(0,1); - d_phase[0] = exp(j * (float) (M_PI * (sin(theta) + cos(theta)))); - d_phase[1] = exp(j * (float) (M_PI * cos(theta))); - d_phase[2] = exp(j * (float) (M_PI * sin(theta))); - d_phase[3] = exp(j * (float) 0.0); -} - -int -gr_pa_2x2_phase_combiner::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const gr_complex *in = (const gr_complex *) input_items[0]; - gr_complex *out = (gr_complex *) output_items[0]; - - for (int i = 0; i < noutput_items; i++){ - gr_complex acc = 0; - acc += in[0] * d_phase[0]; - acc += in[1] * d_phase[1]; - acc += in[2] * d_phase[2]; - acc += in[3] * d_phase[3]; - out[i] = acc; - in += 4; - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_pa_2x2_phase_combiner.h b/gnuradio-core/src/lib/general/gr_pa_2x2_phase_combiner.h deleted file mode 100644 index d430d154fc..0000000000 --- a/gnuradio-core/src/lib/general/gr_pa_2x2_phase_combiner.h +++ /dev/null @@ -1,63 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef INCLUDED_GR_PA_2X2_PHASE_COMBINER_H -#define INCLUDED_GR_PA_2X2_PHASE_COMBINER_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class gr_pa_2x2_phase_combiner; -typedef boost::shared_ptr<gr_pa_2x2_phase_combiner> gr_pa_2x2_phase_combiner_sptr; - -GR_CORE_API gr_pa_2x2_phase_combiner_sptr gr_make_pa_2x2_phase_combiner (); - -/*! - * \brief pa_2x2 phase combiner - * \ingroup misc_blk - * - * Anntenas are arranged like this: - * - * 2 3 - * 0 1 - * - * dx and dy are lambda/2. - */ -class GR_CORE_API gr_pa_2x2_phase_combiner : public gr_sync_block -{ - static const int NM = 4; - - float d_theta; - gr_complex d_phase[NM]; - - gr_pa_2x2_phase_combiner (); - friend GR_CORE_API gr_pa_2x2_phase_combiner_sptr gr_make_pa_2x2_phase_combiner(); - - public: - float theta() const { return d_theta; } - void set_theta(float theta); - - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_GR_PA_2X2_PHASE_COMBINER_H */ diff --git a/gnuradio-core/src/lib/general/gr_pa_2x2_phase_combiner.i b/gnuradio-core/src/lib/general/gr_pa_2x2_phase_combiner.i deleted file mode 100644 index 2cd373a5e4..0000000000 --- a/gnuradio-core/src/lib/general/gr_pa_2x2_phase_combiner.i +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,pa_2x2_phase_combiner) - -gr_pa_2x2_phase_combiner_sptr gr_make_pa_2x2_phase_combiner(); - -class gr_pa_2x2_phase_combiner : public gr_sync_block -{ - gr_pa_2x2_phase_combiner(); - - public: - float theta() const; - void set_theta(float theta); -}; diff --git a/gnuradio-core/src/lib/filter/gr_sincos.c b/gnuradio-core/src/lib/general/gr_sincos.c index a8d01b0da4..a8d01b0da4 100644 --- a/gnuradio-core/src/lib/filter/gr_sincos.c +++ b/gnuradio-core/src/lib/general/gr_sincos.c diff --git a/gnuradio-core/src/lib/filter/gr_sincos.h b/gnuradio-core/src/lib/general/gr_sincos.h index 516f43437a..516f43437a 100644 --- a/gnuradio-core/src/lib/filter/gr_sincos.h +++ b/gnuradio-core/src/lib/general/gr_sincos.h diff --git a/gnuradio-core/src/lib/general/gr_skiphead.cc b/gnuradio-core/src/lib/general/gr_skiphead.cc deleted file mode 100644 index c93478597b..0000000000 --- a/gnuradio-core/src/lib/general/gr_skiphead.cc +++ /dev/null @@ -1,108 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2007,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_skiphead.h> -#include <gr_io_signature.h> -#include <string.h> - -gr_skiphead::gr_skiphead (size_t itemsize, uint64_t nitems_to_skip) - : gr_block ("skiphead", - gr_make_io_signature(1, 1, itemsize), - gr_make_io_signature(1, 1, itemsize)), - d_nitems_to_skip(nitems_to_skip), d_nitems(0) -{ -} - -gr_skiphead_sptr -gr_make_skiphead (size_t itemsize, uint64_t nitems_to_skip) -{ - return gnuradio::get_initial_sptr(new gr_skiphead (itemsize, nitems_to_skip)); -} - -void -gr_skiphead::set_nitems_to_skip(uint64_t nitems_to_skip) -{ - d_nitems_to_skip = nitems_to_skip; - reset(); -} - -uint64_t -gr_skiphead::nitems_to_skip() const -{ - return d_nitems_to_skip; -} - -uint64_t -gr_skiphead::nitems_skiped() const -{ - return d_nitems; -} - -void -gr_skiphead::reset() -{ - d_nitems = 0; -} - -int -gr_skiphead::general_work(int noutput_items, - gr_vector_int &ninput_items_, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const char *in = (const char *) input_items[0]; - char *out = (char *) output_items[0]; - - int ninput_items = std::min(ninput_items_[0], noutput_items); - int ii = 0; // input index - - while (ii < ninput_items){ - - uint64_t ni_total = ii + d_nitems; // total items processed so far - if (ni_total < d_nitems_to_skip){ // need to skip some more - - int n_to_skip = (int) std::min(d_nitems_to_skip - ni_total, - (uint64_t)(ninput_items - ii)); - ii += n_to_skip; - } - - else { // nothing left to skip. copy away - - int n_to_copy = ninput_items - ii; - if (n_to_copy > 0){ - size_t itemsize = output_signature()->sizeof_stream_item(0); - memcpy(out, in + (ii*itemsize), n_to_copy*itemsize); - } - - d_nitems += ninput_items; - consume_each(ninput_items); - return n_to_copy; - } - } - - d_nitems += ninput_items; - consume_each(ninput_items); - return 0; -} diff --git a/gnuradio-core/src/lib/general/gr_skiphead.h b/gnuradio-core/src/lib/general/gr_skiphead.h deleted file mode 100644 index 710530ff4c..0000000000 --- a/gnuradio-core/src/lib/general/gr_skiphead.h +++ /dev/null @@ -1,80 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 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_SKIPHEAD_H -#define INCLUDED_GR_SKIPHEAD_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <stddef.h> // size_t - -class gr_skiphead; -typedef boost::shared_ptr<gr_skiphead> gr_skiphead_sptr; - -GR_CORE_API gr_skiphead_sptr -gr_make_skiphead (size_t itemsize, uint64_t nitems_to_skip); - - -/*! - * \brief skips the first N items, from then on copies items to the output - * \ingroup slicedice_blk - * - * Useful for building test cases and sources which have metadata or junk at the start - */ - -class GR_CORE_API gr_skiphead : public gr_block -{ - friend GR_CORE_API gr_skiphead_sptr gr_make_skiphead (size_t itemsize, uint64_t nitems_to_skip); - gr_skiphead (size_t itemsize, uint64_t nitems_to_skip); - - uint64_t d_nitems_to_skip; - uint64_t d_nitems; // total items seen - - public: - - /*! - * \brief Sets number of items to skip; resets current skip count to 0. - */ - void set_nitems_to_skip(uint64_t nitems_to_skip); - - /*! - * \brief Gets the number of items to skip. - */ - uint64_t nitems_to_skip() const; - - /*! - * \brief Gets the number of items already skipped. - */ - uint64_t nitems_skiped() const; - - /*! - * \brief Resets number of items skipped to 0. - */ - void reset(); - - int general_work(int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_GR_SKIPHEAD_H */ diff --git a/gnuradio-core/src/lib/general/gr_skiphead.i b/gnuradio-core/src/lib/general/gr_skiphead.i deleted file mode 100644 index 8ab23a77a6..0000000000 --- a/gnuradio-core/src/lib/general/gr_skiphead.i +++ /dev/null @@ -1,35 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2007,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,skiphead); - -gr_skiphead_sptr gr_make_skiphead(size_t itemsize, - uint64_t nitems_to_skip); - -class gr_skiphead : public gr_block -{ -public: - void set_nitems_to_skip(uint64_t nitems_to_skip); - uint64_t nitems_to_skip() const; - uint64_t nitems_skiped() const; - void reset(); -}; diff --git a/gnuradio-core/src/lib/general/gr_vco.h b/gnuradio-core/src/lib/general/gr_vco.h new file mode 100644 index 0000000000..3ceaf15dd4 --- /dev/null +++ b/gnuradio-core/src/lib/general/gr_vco.h @@ -0,0 +1,94 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005 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 _GR_VCO_H_ +#define _GR_VCO_H_ + + +#include <vector> +#include <gr_sincos.h> +#include <cmath> +#include <gr_complex.h> + +/*! + * \brief base class template for Voltage Controlled Oscillator (VCO) + * \ingroup misc + */ + +//FIXME Eventually generalize this to fixed point + +template<class o_type, class i_type> +class gr_vco { +public: + gr_vco () : d_phase (0) {} + + virtual ~gr_vco () {} + + // radians + void set_phase (double angle) { + d_phase = angle; + } + + void adjust_phase (double delta_phase) { + d_phase += delta_phase; + if (fabs (d_phase) > M_PI){ + + while (d_phase > M_PI) + d_phase -= 2*M_PI; + + while (d_phase < -M_PI) + d_phase += 2*M_PI; + } + } + + double get_phase () const { return d_phase; } + + // compute sin and cos for current phase angle + void sincos (float *sinx, float *cosx) const; + + // compute cos or sin for current phase angle + float cos () const { return std::cos (d_phase); } + float sin () const { return std::sin (d_phase); } + + // compute a block at a time + void cos (float *output, const float *input, int noutput_items, double k, double ampl = 1.0); + +protected: + double d_phase; +}; + +template<class o_type, class i_type> +void +gr_vco<o_type,i_type>::sincos (float *sinx, float *cosx) const +{ + gr_sincosf (d_phase, sinx, cosx); +} + +template<class o_type, class i_type> +void +gr_vco<o_type,i_type>::cos (float *output, const float *input, int noutput_items, double k, double ampl) +{ + for (int i = 0; i < noutput_items; i++){ + output[i] = cos() * ampl; + adjust_phase(input[i] * k); + } +} +#endif /* _GR_VCO_H_ */ diff --git a/gnuradio-core/src/lib/general/gr_vector_map.cc b/gnuradio-core/src/lib/general/gr_vector_map.cc deleted file mode 100644 index 2a13efb06d..0000000000 --- a/gnuradio-core/src/lib/general/gr_vector_map.cc +++ /dev/null @@ -1,117 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_vector_map.h> -#include <gr_io_signature.h> -#include <string.h> - -std::vector<int> -get_in_sizeofs(size_t item_size, std::vector<size_t> in_vlens) -{ - std::vector<int> in_sizeofs; - for(unsigned int i = 0; i < in_vlens.size(); i++) { - in_sizeofs.push_back(in_vlens[i]*item_size); - } - return in_sizeofs; -} - -std::vector<int> -get_out_sizeofs(size_t item_size, - std::vector< std::vector< std::vector<size_t> > > mapping) -{ - std::vector<int> out_sizeofs; - for(unsigned int i = 0; i < mapping.size(); i++) { - out_sizeofs.push_back(mapping[i].size()*item_size); - } - return out_sizeofs; -} - -gr_vector_map_sptr -gr_make_vector_map (size_t item_size, std::vector<size_t> in_vlens, - std::vector< std::vector< std::vector<size_t> > > mapping) -{ - return gnuradio::get_initial_sptr(new gr_vector_map(item_size, - in_vlens, - mapping)); -} - -gr_vector_map::gr_vector_map(size_t item_size, std::vector<size_t> in_vlens, - std::vector< std::vector< std::vector<size_t> > > mapping) - : gr_sync_block("vector_map", - gr_make_io_signaturev(in_vlens.size(), in_vlens.size(), - get_in_sizeofs(item_size, in_vlens)), - gr_make_io_signaturev(mapping.size(), mapping.size(), - get_out_sizeofs(item_size, mapping))), - d_item_size(item_size), d_in_vlens(in_vlens) -{ - set_mapping(mapping); -} - -void -gr_vector_map::set_mapping(std::vector< std::vector< std::vector<size_t> > > mapping) { - // Make sure the contents of the mapping vectors are possible. - for(unsigned int i=0; i<mapping.size(); i++) { - for(unsigned int j=0; j<mapping[i].size(); j++) { - if(mapping[i][j].size() != 2) { - throw std::runtime_error("Mapping must be of the form (out_mapping_stream1, out_mapping_stream2, ...), where out_mapping_stream1 is of the form (mapping_element1, mapping_element2, ...), where mapping_element1 is of the form (input_stream, input_element). This error is raised because a mapping_element vector does not contain exactly 2 items."); - } - unsigned int s = mapping[i][j][0]; - unsigned int index = mapping[i][j][1]; - if(s >= d_in_vlens.size()) { - throw std::runtime_error("Stream numbers in mapping must be less than the number of input streams."); - } - if((index < 0) || (index >= d_in_vlens[s])) { - throw std::runtime_error ("Indices in mapping must be greater than 0 and less than the input vector lengths."); - } - } - } - gruel::scoped_lock guard(d_mutex); - d_mapping = mapping; -} - -int -gr_vector_map::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const char **inv = (const char **) &input_items[0]; - char **outv = (char **) &output_items[0]; - - for(unsigned int n = 0; n < (unsigned int)(noutput_items); n++) { - for(unsigned int i = 0; i < d_mapping.size(); i++) { - unsigned int out_vlen = d_mapping[i].size(); - for(unsigned int j = 0; j < out_vlen; j++) { - unsigned int s = d_mapping[i][j][0]; - unsigned int k = d_mapping[i][j][1]; - memcpy(outv[i] + out_vlen*d_item_size*n + - d_item_size*j, inv[s] + d_in_vlens[s]*d_item_size*n + - k*d_item_size, d_item_size); - } - } - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_vector_map.h b/gnuradio-core/src/lib/general/gr_vector_map.h deleted file mode 100644 index f5492b1e3a..0000000000 --- a/gnuradio-core/src/lib/general/gr_vector_map.h +++ /dev/null @@ -1,83 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_VECTOR_MAP_H -#define INCLUDED_GR_VECTOR_MAP_H - -#include <vector> -#include <gr_core_api.h> -#include <gr_sync_interpolator.h> -#include <gruel/thread.h> - -class gr_vector_map; -typedef boost::shared_ptr<gr_vector_map> gr_vector_map_sptr; - -GR_CORE_API gr_vector_map_sptr -gr_make_vector_map (size_t item_size, std::vector<size_t> in_vlens, - std::vector< std::vector< std::vector<size_t> > > mapping); - -/*! - * \brief Maps elements from a set of input vectors to a set of output vectors. - * - * If in[i] is the input vector in the i'th stream then the output - * vector in the j'th stream is: - * - * out[j][k] = in[mapping[j][k][0]][mapping[j][k][1]] - * - * That is mapping is of the form (out_stream1_mapping, - * out_stream2_mapping, ...) and out_stream1_mapping is of the form - * (element1_mapping, element2_mapping, ...) and element1_mapping is - * of the form (in_stream, in_element). - * - * \param item_size (integer) size of vector elements - * - * \param in_vlens (vector of integers) number of elements in each - * input vector - * - * \param mapping (vector of vectors of vectors of integers) how to - * map elements from input to output vectors - * - * \ingroup slicedice_blk - */ -class GR_CORE_API gr_vector_map : public gr_sync_block -{ - friend GR_CORE_API gr_vector_map_sptr - gr_make_vector_map(size_t item_size, std::vector<size_t> in_vlens, - std::vector< std::vector< std::vector<size_t> > > mapping); - size_t d_item_size; - std::vector<size_t> d_in_vlens; - std::vector< std::vector< std::vector<size_t> > > d_mapping; - gruel::mutex d_mutex; // mutex to protect set/work access - - protected: - gr_vector_map(size_t item_size, std::vector<size_t> in_vlens, - std::vector< std::vector< std::vector<size_t> > > mapping); - - public: - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - void set_mapping(std::vector< std::vector< std::vector<size_t> > > mapping); -}; - -#endif /* INCLUDED_GR_VECTOR_MAP_H */ diff --git a/gnuradio-core/src/lib/general/gr_vector_map.i b/gnuradio-core/src/lib/general/gr_vector_map.i deleted file mode 100644 index e9fa3f27e5..0000000000 --- a/gnuradio-core/src/lib/general/gr_vector_map.i +++ /dev/null @@ -1,28 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr, vector_map); - -%template() std::vector<size_t>; -%template() std::vector< std::vector< std::vector<size_t> > >; - -%include "gr_vector_map.h" diff --git a/gnuradio-core/src/lib/general/gri_lfsr_32k.h b/gnuradio-core/src/lib/general/gri_lfsr_32k.h deleted file mode 100644 index e84512b9a6..0000000000 --- a/gnuradio-core/src/lib/general/gri_lfsr_32k.h +++ /dev/null @@ -1,80 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GRI_LFSR_32k_H -#define INCLUDED_GRI_LFSR_32k_H - -#include <gr_core_api.h> -#include <gri_lfsr_15_1_0.h> - -/*! - * \brief generate pseudo-random sequence of length 32768 bits. - * \ingroup misc - * - * This is based on gri_lfsr_15_1_0 with an extra 0 added at the end - * of the sequence. - */ - -class GR_CORE_API gri_lfsr_32k { - gri_lfsr_15_1_0 d_lfsr; - unsigned int d_count; - - public: - gri_lfsr_32k () { reset (); } - - void reset (){ - d_lfsr.reset (); - d_count = 0; - } - - int next_bit (){ - if (d_count == 32767){ - d_count = 0; - return 0; - } - d_count++; - return d_lfsr.next_bit (); - } - - int next_byte (){ - int v = 0; - for (int i = 0; i < 8; i++){ - v >>= 1; - if (next_bit ()) - v |= 0x80; - } - return v; - } - - int next_short (){ - int v = 0; - for (int i = 0; i < 16; i++){ - v >>= 1; - if (next_bit ()) - v |= 0x8000; - } - return v; - } - -}; - -#endif /* INCLUDED_GRI_LFSR_32k_H */ diff --git a/gnuradio-core/src/lib/general/qa_general.cc b/gnuradio-core/src/lib/general/qa_general.cc index e2328c2cb2..121551b050 100644 --- a/gnuradio-core/src/lib/general/qa_general.cc +++ b/gnuradio-core/src/lib/general/qa_general.cc @@ -27,7 +27,11 @@ #include <qa_general.h> #include <qa_gr_circular_file.h> +#include <qa_gr_fxpt.h> +#include <qa_gr_fxpt_nco.h> +#include <qa_gr_fxpt_vco.h> #include <qa_gr_math.h> +#include <qa_sincos.h> CppUnit::TestSuite * qa_general::suite () @@ -35,7 +39,11 @@ qa_general::suite () CppUnit::TestSuite *s = new CppUnit::TestSuite ("general"); s->addTest (qa_gr_circular_file::suite ()); + s->addTest (qa_gr_fxpt::suite ()); + s->addTest (qa_gr_fxpt_nco::suite ()); + s->addTest (qa_gr_fxpt_vco::suite ()); s->addTest (qa_gr_math::suite ()); + s->addTest(gr::analog::qa_sincos::suite()); return s; } diff --git a/gnuradio-core/src/lib/general/qa_gr_fxpt.cc b/gnuradio-core/src/lib/general/qa_gr_fxpt.cc new file mode 100644 index 0000000000..7eac0d8964 --- /dev/null +++ b/gnuradio-core/src/lib/general/qa_gr_fxpt.cc @@ -0,0 +1,103 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif +#include <qa_gr_fxpt.h> +#include <gr_fxpt.h> +#include <cppunit/TestAssert.h> +#include <iostream> +#include <stdio.h> +#include <unistd.h> +#include <math.h> + +static const float SIN_COS_TOLERANCE = 1e-5; + +void +qa_gr_fxpt::t0 () +{ + CPPUNIT_ASSERT_DOUBLES_EQUAL (M_PI/2, gr_fxpt::fixed_to_float (0x40000000), SIN_COS_TOLERANCE); + CPPUNIT_ASSERT_DOUBLES_EQUAL (0.0, gr_fxpt::fixed_to_float (0x00000000), SIN_COS_TOLERANCE); + CPPUNIT_ASSERT_DOUBLES_EQUAL (-M_PI, gr_fxpt::fixed_to_float (0x80000000), SIN_COS_TOLERANCE); + + if (0){ + /* + * These are disabled because of some precision issues. + * + * Different compilers seem to have different opinions on whether + * the calulations are done single or double (or extended) + * precision. Any of the answers are fine for our real purpose, but + * sometimes the answer is off by a few bits at the bottom. + * Hence, the disabled check. + */ + CPPUNIT_ASSERT_EQUAL ((gr_int32) 0x40000000, gr_fxpt::float_to_fixed (M_PI/2)); + CPPUNIT_ASSERT_EQUAL ((gr_int32) 0, gr_fxpt::float_to_fixed (0)); + CPPUNIT_ASSERT_EQUAL ((gr_int32) 0x80000000, gr_fxpt::float_to_fixed (-M_PI)); + } +} + +void +qa_gr_fxpt::t1 () +{ + + CPPUNIT_ASSERT_DOUBLES_EQUAL ( 0, gr_fxpt::sin (0x00000000), SIN_COS_TOLERANCE); + CPPUNIT_ASSERT_DOUBLES_EQUAL ( 0.707106781, gr_fxpt::sin (0x20000000), SIN_COS_TOLERANCE); + CPPUNIT_ASSERT_DOUBLES_EQUAL ( 1, gr_fxpt::sin (0x40000000), SIN_COS_TOLERANCE); + CPPUNIT_ASSERT_DOUBLES_EQUAL ( 0.707106781, gr_fxpt::sin (0x60000000), SIN_COS_TOLERANCE); + CPPUNIT_ASSERT_DOUBLES_EQUAL ( 0, gr_fxpt::sin (0x7fffffff), SIN_COS_TOLERANCE); + CPPUNIT_ASSERT_DOUBLES_EQUAL ( 0, gr_fxpt::sin (0x80000000), SIN_COS_TOLERANCE); + CPPUNIT_ASSERT_DOUBLES_EQUAL ( 0, gr_fxpt::sin (0x80000001), SIN_COS_TOLERANCE); + CPPUNIT_ASSERT_DOUBLES_EQUAL (-1, gr_fxpt::sin (-0x40000000), SIN_COS_TOLERANCE); + CPPUNIT_ASSERT_DOUBLES_EQUAL (-0.707106781, gr_fxpt::sin (-0x20000000), SIN_COS_TOLERANCE); + + + for (float p = -M_PI; p < M_PI; p += 2 * M_PI / 3600){ + float expected = sin (p); + float actual = gr_fxpt::sin (gr_fxpt::float_to_fixed (p)); + CPPUNIT_ASSERT_DOUBLES_EQUAL (expected, actual, SIN_COS_TOLERANCE); + } +} + +void +qa_gr_fxpt::t2 () +{ + for (float p = -M_PI; p < M_PI; p += 2 * M_PI / 3600){ + float expected = cos (p); + float actual = gr_fxpt::cos (gr_fxpt::float_to_fixed (p)); + CPPUNIT_ASSERT_DOUBLES_EQUAL (expected, actual, SIN_COS_TOLERANCE); + } +} + +void +qa_gr_fxpt::t3 () +{ + for (float p = -M_PI; p < M_PI; p += 2 * M_PI / 3600){ + float expected_sin = sin (p); + float expected_cos = cos (p); + float actual_sin; + float actual_cos; + gr_fxpt::sincos (gr_fxpt::float_to_fixed (p), &actual_sin, &actual_cos); + CPPUNIT_ASSERT_DOUBLES_EQUAL (expected_sin, actual_sin, SIN_COS_TOLERANCE); + CPPUNIT_ASSERT_DOUBLES_EQUAL (expected_cos, actual_cos, SIN_COS_TOLERANCE); + } +} diff --git a/gr-blocks/lib/qa_fxpt.h b/gnuradio-core/src/lib/general/qa_gr_fxpt.h index 7a9e2a86ed..72211563e7 100644 --- a/gr-blocks/lib/qa_fxpt.h +++ b/gnuradio-core/src/lib/general/qa_gr_fxpt.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2013 Free Software Foundation, Inc. + * Copyright 2004 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -19,27 +19,28 @@ * the Free Software Foundation, Inc., 51 Franklin Street, * Boston, MA 02110-1301, USA. */ - #ifndef INCLUDED_QA_GR_FXPT_H #define INCLUDED_QA_GR_FXPT_H + #include <cppunit/extensions/HelperMacros.h> #include <cppunit/TestCase.h> -class qa_fxpt : public CppUnit::TestCase -{ - CPPUNIT_TEST_SUITE(qa_fxpt); - CPPUNIT_TEST(t0); - CPPUNIT_TEST(t1); - CPPUNIT_TEST(t2); - CPPUNIT_TEST(t3); - CPPUNIT_TEST_SUITE_END(); +class qa_gr_fxpt : public CppUnit::TestCase { + + CPPUNIT_TEST_SUITE (qa_gr_fxpt); + CPPUNIT_TEST (t0); + CPPUNIT_TEST (t1); + CPPUNIT_TEST (t2); + CPPUNIT_TEST (t3); + CPPUNIT_TEST_SUITE_END (); private: - void t0(); - void t1(); - void t2(); - void t3(); + void t0 (); + void t1 (); + void t2 (); + void t3 (); + }; #endif /* INCLUDED_QA_GR_FXPT_H */ diff --git a/gnuradio-core/src/lib/general/qa_gr_fxpt_nco.cc b/gnuradio-core/src/lib/general/qa_gr_fxpt_nco.cc new file mode 100644 index 0000000000..6f208eac80 --- /dev/null +++ b/gnuradio-core/src/lib/general/qa_gr_fxpt_nco.cc @@ -0,0 +1,119 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif +#include <qa_gr_fxpt_nco.h> +#include <gr_fxpt_nco.h> +#include <gr_nco.h> +#include <cppunit/TestAssert.h> +#include <iostream> +#include <stdio.h> +#include <unistd.h> +#include <math.h> + +static const float SIN_COS_TOLERANCE = 1e-5; + +//static const float SIN_COS_FREQ = 5003; +static const float SIN_COS_FREQ = 4096; + +static const int SIN_COS_BLOCK_SIZE = 100000; + +static double max_d(double a, double b) +{ + return fabs(a) > fabs(b) ? a : b; +} + +void +qa_gr_fxpt_nco::t0 () +{ + gr_nco<float,float> ref_nco; + gr_fxpt_nco new_nco; + double max_error = 0, max_phase_error = 0; + + ref_nco.set_freq ((float)(2 * M_PI / SIN_COS_FREQ)); + new_nco.set_freq ((float)(2 * M_PI / SIN_COS_FREQ)); + + CPPUNIT_ASSERT_DOUBLES_EQUAL (ref_nco.get_freq(), new_nco.get_freq(), SIN_COS_TOLERANCE); + + for (int i = 0; i < SIN_COS_BLOCK_SIZE; i++){ + float ref_sin = ref_nco.sin (); + float new_sin = new_nco.sin (); + //printf ("i = %6d\n", i); + CPPUNIT_ASSERT_DOUBLES_EQUAL (ref_sin, new_sin, SIN_COS_TOLERANCE); + + max_error = max_d (max_error, ref_sin-new_sin); + + float ref_cos = ref_nco.cos (); + float new_cos = new_nco.cos (); + CPPUNIT_ASSERT_DOUBLES_EQUAL (ref_cos, new_cos, SIN_COS_TOLERANCE); + + max_error = max_d (max_error, ref_cos-new_cos); + + ref_nco.step (); + new_nco.step (); + + CPPUNIT_ASSERT_DOUBLES_EQUAL (ref_nco.get_phase(), new_nco.get_phase(), SIN_COS_TOLERANCE); + + max_phase_error = max_d (max_phase_error, ref_nco.get_phase()-new_nco.get_phase()); + } + // printf ("Fxpt max error %.9f, max phase error %.9f\n", max_error, max_phase_error); +} + +void +qa_gr_fxpt_nco::t1 () +{ + gr_nco<float,float> ref_nco; + gr_fxpt_nco new_nco; + gr_complex ref_block[SIN_COS_BLOCK_SIZE]; + gr_complex new_block[SIN_COS_BLOCK_SIZE]; + double max_error = 0; + + ref_nco.set_freq ((float)(2 * M_PI / SIN_COS_FREQ)); + new_nco.set_freq ((float)(2 * M_PI / SIN_COS_FREQ)); + + CPPUNIT_ASSERT_DOUBLES_EQUAL (ref_nco.get_freq(), new_nco.get_freq(), SIN_COS_TOLERANCE); + + ref_nco.sincos ((gr_complex*)ref_block, SIN_COS_BLOCK_SIZE); + new_nco.sincos ((gr_complex*)new_block, SIN_COS_BLOCK_SIZE); + + for (int i = 0; i < SIN_COS_BLOCK_SIZE; i++){ + CPPUNIT_ASSERT_DOUBLES_EQUAL (ref_block[i].real(), new_block[i].real(), SIN_COS_TOLERANCE); + max_error = max_d (max_error, ref_block[i].real()-new_block[i].real()); + + CPPUNIT_ASSERT_DOUBLES_EQUAL (ref_block[i].imag(), new_block[i].imag(), SIN_COS_TOLERANCE); + max_error = max_d (max_error, ref_block[i].imag()-new_block[i].imag()); + } + CPPUNIT_ASSERT_DOUBLES_EQUAL (ref_nco.get_phase(), new_nco.get_phase(), SIN_COS_TOLERANCE); + // printf ("Fxpt max error %.9f, max phase error %.9f\n", max_error, max_phase_error); +} + +void +qa_gr_fxpt_nco::t2 () +{ +} + +void +qa_gr_fxpt_nco::t3 () +{ +} diff --git a/gr-blocks/lib/qa_fxpt_nco.h b/gnuradio-core/src/lib/general/qa_gr_fxpt_nco.h index ac4e5d2ade..8998922bbb 100644 --- a/gr-blocks/lib/qa_fxpt_nco.h +++ b/gnuradio-core/src/lib/general/qa_gr_fxpt_nco.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2013 Free Software Foundation, Inc. + * Copyright 2004 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -19,27 +19,28 @@ * the Free Software Foundation, Inc., 51 Franklin Street, * Boston, MA 02110-1301, USA. */ - #ifndef INCLUDED_QA_GR_FXPT_NCO_H #define INCLUDED_QA_GR_FXPT_NCO_H + #include <cppunit/extensions/HelperMacros.h> #include <cppunit/TestCase.h> -class qa_fxpt_nco : public CppUnit::TestCase -{ - CPPUNIT_TEST_SUITE(qa_fxpt_nco); - CPPUNIT_TEST(t0); - CPPUNIT_TEST(t1); - CPPUNIT_TEST(t2); - CPPUNIT_TEST(t3); - CPPUNIT_TEST_SUITE_END(); +class qa_gr_fxpt_nco : public CppUnit::TestCase { + + CPPUNIT_TEST_SUITE (qa_gr_fxpt_nco); + CPPUNIT_TEST (t0); + CPPUNIT_TEST (t1); + CPPUNIT_TEST (t2); + CPPUNIT_TEST (t3); + CPPUNIT_TEST_SUITE_END (); private: - void t0(); - void t1(); - void t2(); - void t3(); + void t0 (); + void t1 (); + void t2 (); + void t3 (); + }; #endif /* INCLUDED_QA_GR_FXPT_NCO_H */ diff --git a/gnuradio-core/src/lib/general/qa_gr_fxpt_vco.cc b/gnuradio-core/src/lib/general/qa_gr_fxpt_vco.cc new file mode 100644 index 0000000000..5b6993a30c --- /dev/null +++ b/gnuradio-core/src/lib/general/qa_gr_fxpt_vco.cc @@ -0,0 +1,110 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2005 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 <qa_gr_fxpt_vco.h> +#include <gr_fxpt_vco.h> +#include <gr_vco.h> +#include <cppunit/TestAssert.h> +#include <iostream> +#include <stdio.h> +#include <unistd.h> +#include <math.h> + +static const float SIN_COS_TOLERANCE = 1e-5; + +static const float SIN_COS_K = 0.42; +static const float SIN_COS_AMPL = 0.8; + +static const int SIN_COS_BLOCK_SIZE = 100000; + +static double max_d(double a, double b) +{ + return fabs(a) > fabs(b) ? a : b; +} + +void +qa_gr_fxpt_vco::t0 () +{ + gr_vco<float,float> ref_vco; + gr_fxpt_vco new_vco; + double max_error = 0, max_phase_error = 0; + float input[SIN_COS_BLOCK_SIZE]; + + for (int i = 0; i < SIN_COS_BLOCK_SIZE; i++){ + input[i] = sin(double(i)); + } + + for (int i = 0; i < SIN_COS_BLOCK_SIZE; i++){ + float ref_cos = ref_vco.cos (); + float new_cos = new_vco.cos (); + CPPUNIT_ASSERT_DOUBLES_EQUAL (ref_cos, new_cos, SIN_COS_TOLERANCE); + + max_error = max_d (max_error, ref_cos-new_cos); + + ref_vco.adjust_phase (input[i]); + new_vco.adjust_phase (input[i]); + + CPPUNIT_ASSERT_DOUBLES_EQUAL (ref_vco.get_phase(), new_vco.get_phase(), SIN_COS_TOLERANCE); + + max_phase_error = max_d (max_phase_error, ref_vco.get_phase()-new_vco.get_phase()); + } + // printf ("Fxpt max error %.9f, max phase error %.9f\n", max_error, max_phase_error); +} + + +void +qa_gr_fxpt_vco::t1 () +{ + gr_vco<float,float> ref_vco; + gr_fxpt_vco new_vco; + float ref_block[SIN_COS_BLOCK_SIZE]; + float new_block[SIN_COS_BLOCK_SIZE]; + float input[SIN_COS_BLOCK_SIZE]; + double max_error = 0; + + for (int i = 0; i < SIN_COS_BLOCK_SIZE; i++){ + input[i] = sin(double(i)); + } + + ref_vco.cos (ref_block, input, SIN_COS_BLOCK_SIZE, SIN_COS_K, SIN_COS_AMPL); + new_vco.cos (new_block, input, SIN_COS_BLOCK_SIZE, SIN_COS_K, SIN_COS_AMPL); + + for (int i = 0; i < SIN_COS_BLOCK_SIZE; i++){ + CPPUNIT_ASSERT_DOUBLES_EQUAL (ref_block[i], new_block[i], SIN_COS_TOLERANCE); + max_error = max_d (max_error, ref_block[i]-new_block[i]); + } + CPPUNIT_ASSERT_DOUBLES_EQUAL (ref_vco.get_phase(), new_vco.get_phase(), SIN_COS_TOLERANCE); + // printf ("Fxpt max error %.9f, max phase error %.9f\n", max_error, ref_vco.get_phase()-new_vco.get_phase()); +} + +void +qa_gr_fxpt_vco::t2 () +{ +} + +void +qa_gr_fxpt_vco::t3 () +{ +} diff --git a/gnuradio-core/src/lib/runtime/qa_block_tags.h b/gnuradio-core/src/lib/general/qa_gr_fxpt_vco.h index 039d345cdf..fab8022e36 100644 --- a/gnuradio-core/src/lib/runtime/qa_block_tags.h +++ b/gnuradio-core/src/lib/general/qa_gr_fxpt_vco.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2010 Free Software Foundation, Inc. + * Copyright 2004,2005 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -19,23 +19,20 @@ * the Free Software Foundation, Inc., 51 Franklin Street, * Boston, MA 02110-1301, USA. */ +#ifndef INCLUDED_QA_GR_FXPT_VCO_H +#define INCLUDED_QA_GR_FXPT_VCO_H -#ifndef INCLUDED_QA_BLOCK_TAGS_H -#define INCLUDED_QA_BLOCK_TAGS_H #include <cppunit/extensions/HelperMacros.h> #include <cppunit/TestCase.h> -#include <stdexcept> -class qa_block_tags : public CppUnit::TestCase { +class qa_gr_fxpt_vco : public CppUnit::TestCase { - CPPUNIT_TEST_SUITE (qa_block_tags); + CPPUNIT_TEST_SUITE (qa_gr_fxpt_vco); CPPUNIT_TEST (t0); CPPUNIT_TEST (t1); CPPUNIT_TEST (t2); CPPUNIT_TEST (t3); - CPPUNIT_TEST (t4); - //CPPUNIT_TEST (t5); CPPUNIT_TEST_SUITE_END (); private: @@ -43,10 +40,9 @@ class qa_block_tags : public CppUnit::TestCase { void t1 (); void t2 (); void t3 (); - void t4 (); - //void t5 (); }; +#endif /* INCLUDED_QA_GR_FXPT_VCO_H */ + -#endif /* INCLUDED_QA_BLOCK_TAGS_H */ diff --git a/gr-analog/lib/qa_sincos.cc b/gnuradio-core/src/lib/general/qa_sincos.cc index 62642c1171..0066ff6b92 100644 --- a/gr-analog/lib/qa_sincos.cc +++ b/gnuradio-core/src/lib/general/qa_sincos.cc @@ -25,7 +25,7 @@ #endif #include <qa_sincos.h> -#include <analog/sincos.h> +#include <gr_sincos.h> #include <gruel/attributes.h> #include <cppunit/TestAssert.h> #include <cmath> @@ -45,7 +45,7 @@ namespace gr { c_sin = sin(x); c_cos = cos(x); - analog::sincos(x, &gr_sin, &gr_cos); + gr_sincos(x, &gr_sin, &gr_cos); CPPUNIT_ASSERT_DOUBLES_EQUAL(c_sin, gr_sin, 0.0001); CPPUNIT_ASSERT_DOUBLES_EQUAL(c_cos, gr_cos, 0.0001); @@ -64,7 +64,7 @@ namespace gr { c_sin = sinf(x); c_cos = cosf(x); - analog::sincosf(x, &gr_sin, &gr_cos); + gr_sincosf(x, &gr_sin, &gr_cos); CPPUNIT_ASSERT_DOUBLES_EQUAL(c_sin, gr_sin, 0.0001); CPPUNIT_ASSERT_DOUBLES_EQUAL(c_cos, gr_cos, 0.0001); diff --git a/gr-analog/lib/qa_sincos.h b/gnuradio-core/src/lib/general/qa_sincos.h index f18e879dd8..f18e879dd8 100644 --- a/gr-analog/lib/qa_sincos.h +++ b/gnuradio-core/src/lib/general/qa_sincos.h diff --git a/gnuradio-core/src/lib/gengen/CMakeLists.txt b/gnuradio-core/src/lib/gengen/CMakeLists.txt deleted file mode 100644 index 45834ced5f..0000000000 --- a/gnuradio-core/src/lib/gengen/CMakeLists.txt +++ /dev/null @@ -1,143 +0,0 @@ -# Copyright 2010-2011 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. - -######################################################################## -# This file included, use CMake directory variables -######################################################################## -include(GrPython) - -######################################################################## -# generate the python helper script which calls into the build utils -######################################################################## -file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/generate_helper.py " -#!${PYTHON_EXECUTABLE} - -import sys, os, re -sys.path.append('${GR_CORE_PYTHONPATH}') -os.environ['srcdir'] = '${CMAKE_CURRENT_SOURCE_DIR}' -os.chdir('${CMAKE_CURRENT_BINARY_DIR}') - -if __name__ == '__main__': - import build_utils - root, inp = sys.argv[1:3] - for sig in sys.argv[3:]: - name = re.sub ('X+', sig, root) - d = build_utils.standard_dict(name, sig) - build_utils.expand_template(d, inp) - -") - -######################################################################## -# generation helper macro to generate various files from template -######################################################################## -macro(expand_h_cc_i root) - - foreach(ext h cc i) - #make a list of all the generated files - unset(expanded_files_${ext}) - foreach(sig ${ARGN}) - string(REGEX REPLACE "X+" ${sig} name ${root}) - list(APPEND expanded_files_${ext} ${CMAKE_CURRENT_BINARY_DIR}/${name}.${ext}) - endforeach(sig) - - #create a command to generate the files - add_custom_command( - OUTPUT ${expanded_files_${ext}} - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${root}.${ext}.t - COMMAND ${PYTHON_EXECUTABLE} ${PYTHON_DASH_B} - ${CMAKE_CURRENT_BINARY_DIR}/generate_helper.py - ${root} ${root}.${ext}.t ${ARGN} - ) - endforeach(ext) - - #make source files depends on headers to force generation - set_source_files_properties(${expanded_files_cc} - PROPERTIES OBJECT_DEPENDS "${expanded_files_h}" - ) - - #install rules for the generated cc, h, and i files - list(APPEND generated_gengen_sources ${expanded_files_cc}) - list(APPEND generated_gengen_includes ${expanded_files_h}) - list(APPEND generated_gengen_swigs ${expanded_files_i}) - -endmacro(expand_h_cc_i) - -######################################################################## -# Invoke macro to generate various sources -######################################################################## -expand_h_cc_i(gr_vector_source_X b s i f c) -expand_h_cc_i(gr_vector_insert_X b) -expand_h_cc_i(gr_vector_sink_X b s i f c) - -add_custom_target(gengen_generated DEPENDS - ${generated_gengen_includes} - ${generated_gengen_swigs} -) - -######################################################################## -# Create the master gengen swig include files -######################################################################## -set(generated_index ${CMAKE_CURRENT_BINARY_DIR}/gengen_generated.i.in) -file(WRITE ${generated_index} " -// -// This file is machine generated. All edits will be overwritten -// -") - -file(APPEND ${generated_index} "%{\n") -foreach(swig_file ${generated_gengen_swigs}) - get_filename_component(name ${swig_file} NAME_WE) - file(APPEND ${generated_index} "#include<${name}.h>\n") -endforeach(swig_file) -file(APPEND ${generated_index} "%}\n") - -foreach(swig_file ${generated_gengen_swigs}) - get_filename_component(name ${swig_file} NAME) - file(APPEND ${generated_index} "%include<${name}>\n") -endforeach(swig_file) - -execute_process( - COMMAND ${CMAKE_COMMAND} -E copy_if_different - ${generated_index} ${CMAKE_CURRENT_BINARY_DIR}/gengen_generated.i -) - -######################################################################## -# Handle the generated sources + a few non-generated ones -######################################################################## -list(APPEND gnuradio_core_sources - ${generated_gengen_sources} -) - -install(FILES - ${generated_gengen_includes} - ${CMAKE_CURRENT_SOURCE_DIR}/gr_endianness.h - DESTINATION ${GR_INCLUDE_DIR}/gnuradio - COMPONENT "core_devel" -) - -if(ENABLE_PYTHON) - install(FILES - ${generated_gengen_swigs} - ${CMAKE_CURRENT_SOURCE_DIR}/gr_endianness.i - ${CMAKE_CURRENT_SOURCE_DIR}/gengen.i - ${CMAKE_CURRENT_BINARY_DIR}/gengen_generated.i - DESTINATION ${GR_INCLUDE_DIR}/gnuradio/swig - COMPONENT "core_swig" - ) -endif(ENABLE_PYTHON) diff --git a/gnuradio-core/src/lib/gengen/generate_common.py b/gnuradio-core/src/lib/gengen/generate_common.py deleted file mode 100755 index 68913f9a75..0000000000 --- a/gnuradio-core/src/lib/gengen/generate_common.py +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2004,2006,2007,2008,2009 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -from build_utils import expand_template, standard_dict -from build_utils_codes import * - -import re - - -# sources and sinks -ss_signatures = ['s', 'i', 'f', 'c'] - -ss_roots = [ - 'gr_vector_source_X', - 'gr_vector_sink_X', - ] - -# regular blocks -reg_signatures = ['ss', 'ii', 'ff', 'cc'] - - -def expand_h_cc_i (root, sig): - # root looks like 'gr_vector_sink_X' - name = re.sub ('X+', sig, root) - d = standard_dict (name, sig) - expand_template (d, root + '.h.t') - expand_template (d, root + '.cc.t') - expand_template (d, root + '.i.t') - - -def generate (): - expand_h_cc_i ('gr_vector_sink_X', 'b') - expand_h_cc_i ('gr_vector_source_X', 'b') - for r in ss_roots: - for s in ss_signatures: - expand_h_cc_i (r, s) - -if __name__ == '__main__': - generate () - - diff --git a/gnuradio-core/src/lib/gengen/gr_endianness.i b/gnuradio-core/src/lib/gengen/gr_endianness.i deleted file mode 100644 index 572b7a42fb..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_endianness.i +++ /dev/null @@ -1,23 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -%include <gr_endianness.h> diff --git a/gnuradio-core/src/lib/gengen/gr_vector_insert_X.cc.t b/gnuradio-core/src/lib/gengen/gr_vector_insert_X.cc.t deleted file mode 100644 index 20968afe22..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_vector_insert_X.cc.t +++ /dev/null @@ -1,100 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <@NAME@.h> -#include <algorithm> -#include <gr_io_signature.h> -#include <stdexcept> - -#include <stdio.h> - -@NAME@::@NAME@(const std::vector<@TYPE@> &data, int periodicity, int offset) - : gr_block("@BASE_NAME@", - gr_make_io_signature (1, 1, sizeof(@TYPE@)), - gr_make_io_signature (1, 1, sizeof(@TYPE@))), - d_data(data), - d_offset(offset), - d_periodicity(periodicity) -{ - //printf("INITIAL: periodicity = %d, offset = %d\n", periodicity, offset); - // some sanity checks - assert(offset < periodicity); - assert(offset >= 0); - assert((size_t)periodicity > data.size()); -} - -int -@NAME@::general_work(int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - @TYPE@ *out = (@TYPE@ *)output_items[0]; - const @TYPE@ *in = (const @TYPE@ *)input_items[0]; - - int ii(0), oo(0); - - while((oo < noutput_items) && (ii < ninput_items[0])) { - - //printf("oo = %d, ii = %d, d_offset = %d, noutput_items = %d, ninput_items[0] = %d", oo, ii, d_offset, noutput_items, ninput_items[0]); - //printf(", d_periodicity = %d\n", d_periodicity); - - if(d_offset >= ((int)d_data.size())) { // if we are in the copy region - int max_copy = std::min( std::min( noutput_items - oo, ninput_items[0] - ii ), d_periodicity - d_offset ); - //printf("copy %d from input\n", max_copy); - memcpy( &out[oo], &in[ii], sizeof(@TYPE@)*max_copy ); - //printf(" * memcpy returned.\n"); - ii += max_copy; - oo += max_copy; - d_offset = (d_offset + max_copy)%d_periodicity; - - } - else { // if we are in the insertion region - int max_copy = std::min( noutput_items - oo, ((int)d_data.size()) - d_offset ); - //printf("copy %d from d_data[%d] to out[%d]\n", max_copy, d_offset, oo); - memcpy( &out[oo], &d_data[d_offset], sizeof(@TYPE@)*max_copy ); - //printf(" * memcpy returned.\n"); - oo += max_copy; - d_offset = (d_offset + max_copy)%d_periodicity; - //printf(" ## (inelse) oo = %d, d_offset = %d\n", oo, d_offset); - } - - //printf(" # exit else, on to next loop.\n"); - } - //printf(" # got out of loop\n"); - - //printf("consume = %d, produce = %d\n", ii, oo); - consume_each(ii); - return oo; -} - -@NAME@_sptr -gr_make_@BASE_NAME@ (const std::vector<@TYPE@> &data, int periodicity, int offset) -{ - return gnuradio::get_initial_sptr(new @NAME@ (data, periodicity, offset)); -} - diff --git a/gnuradio-core/src/lib/gengen/gr_vector_insert_X.h.t b/gnuradio-core/src/lib/gengen/gr_vector_insert_X.h.t deleted file mode 100644 index 26f851700d..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_vector_insert_X.h.t +++ /dev/null @@ -1,61 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -#ifndef @GUARD_NAME@ -#define @GUARD_NAME@ - -#include <gr_core_api.h> -#include <gr_block.h> - -class GR_CORE_API @NAME@; -typedef boost::shared_ptr<@NAME@> @NAME@_sptr; - -/*! - * \brief source of @TYPE@'s that gets its data from a vector - * \ingroup source_blk - */ - -class @NAME@ : public gr_block { - friend GR_CORE_API @NAME@_sptr - gr_make_@BASE_NAME@(const std::vector<@TYPE@> &data, int periodicity, int offset); - - std::vector<@TYPE@> d_data; - int d_offset; - int d_periodicity; - - @NAME@(const std::vector<@TYPE@> &data, int periodicity, int offset); - - public: - void rewind() {d_offset=0;} - virtual int general_work(int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - void set_data(const std::vector<@TYPE@> &data){ d_data = data; rewind(); } -}; - -GR_CORE_API @NAME@_sptr -gr_make_@BASE_NAME@(const std::vector<@TYPE@> &data, int periodicity, int offset=0); - -#endif diff --git a/gnuradio-core/src/lib/gengen/gr_vector_sink_X.cc.t b/gnuradio-core/src/lib/gengen/gr_vector_sink_X.cc.t deleted file mode 100644 index 2b8207c027..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_vector_sink_X.cc.t +++ /dev/null @@ -1,73 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2008,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <@NAME@.h> -#include <algorithm> -#include <gr_io_signature.h> -#include <iostream> - - -@NAME@::@NAME@ (int vlen) - : gr_sync_block ("@BASE_NAME@", - gr_make_io_signature (1, 1, sizeof (@TYPE@) * vlen), - gr_make_io_signature (0, 0, 0)), - d_vlen(vlen) -{ -} - -int -@NAME@::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - @TYPE@ *iptr = (@TYPE@ *) input_items[0]; - for (int i = 0; i < noutput_items * d_vlen; i++) - d_data.push_back (iptr[i]); - std::vector<gr_tag_t> tags; - get_tags_in_range(tags, 0, nitems_read(0), nitems_read(0) + noutput_items); - d_tags.insert(d_tags.end(), tags.begin(), tags.end()); - return noutput_items; -} - - -@NAME@_sptr -gr_make_@BASE_NAME@ (int vlen) -{ - return gnuradio::get_initial_sptr(new @NAME@ (vlen)); -} - -std::vector<@TYPE@> -@NAME@::data () const -{ - return d_data; -} - -std::vector<gr_tag_t> -@NAME@::tags () const -{ - return d_tags; -} diff --git a/gnuradio-core/src/lib/gengen/gr_vector_source_X.cc.t b/gnuradio-core/src/lib/gengen/gr_vector_source_X.cc.t deleted file mode 100644 index 19272ee24b..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_vector_source_X.cc.t +++ /dev/null @@ -1,124 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2008,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <@NAME@.h> -#include <algorithm> -#include <gr_io_signature.h> -#include <stdexcept> - -@NAME@::@NAME@ (const std::vector<@TYPE@> &data, bool repeat, int vlen, const std::vector<gr_tag_t> &tags) - : gr_sync_block ("@BASE_NAME@", - gr_make_io_signature (0, 0, 0), - gr_make_io_signature (1, 1, sizeof (@TYPE@) * vlen)), - d_data (data), - d_repeat (repeat), - d_offset (0), - d_vlen (vlen), - d_tags (tags), - d_tagpos (0) -{ - if (tags.size() == 0) { - d_settags = 0; - } else { - d_settags = 1; - set_output_multiple(data.size() / vlen); - } - if ((data.size() % vlen) != 0) - throw std::invalid_argument("data length must be a multiple of vlen"); -} - -void -@NAME@::set_data (const std::vector<@TYPE@> &data, const std::vector<gr_tag_t> &tags){ - d_data = data; - d_tags = tags; - rewind(); - if (tags.size() == 0) { - d_settags = false; - } else { - d_settags = true; - } -} - -int -@NAME@::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - @TYPE@ *optr = (@TYPE@ *) output_items[0]; - - if (d_repeat){ - unsigned int size = d_data.size (); - unsigned int offset = d_offset; - if (size == 0) - return -1; - - if (d_settags) { - int n_outputitems_per_vector = d_data.size() / d_vlen; - for (int i = 0; i < noutput_items; i += n_outputitems_per_vector) { - // FIXME do proper vector copy - memcpy((void *) optr, (const void *) &d_data[0], size * sizeof (@TYPE@)); - optr += size; - for (unsigned t = 0; t < d_tags.size(); t++) { - add_item_tag(0, nitems_written(0)+i+d_tags[t].offset, d_tags[t].key, d_tags[t].value); - } - } - } else { - for (int i = 0; i < noutput_items*d_vlen; i++){ - optr[i] = d_data[offset++]; - if (offset >= size) { - offset = 0; - } - } - } - - - d_offset = offset; - return noutput_items; - } else { - if (d_offset >= d_data.size ()) - return -1; // Done! - - unsigned n = std::min ((unsigned) d_data.size () - d_offset, - (unsigned) noutput_items*d_vlen); - for (unsigned i = 0; i < n; i++) { - optr[i] = d_data[d_offset + i]; - } - for (unsigned t = 0; t < d_tags.size(); t++) { - if ((d_tags[t].offset >= d_offset) && (d_tags[t].offset < d_offset+n)) - add_item_tag(0, d_tags[t].offset, d_tags[t].key, d_tags[t].value); - } - d_offset += n; - return n/d_vlen; - } -} - -@NAME@_sptr -gr_make_@BASE_NAME@ (const std::vector<@TYPE@> &data, bool repeat, int vlen, const std::vector<gr_tag_t> &tags) -{ - return gnuradio::get_initial_sptr(new @NAME@ (data, repeat, vlen, tags)); -} - diff --git a/gnuradio-core/src/lib/gengen/gr_vector_source_X.h.t b/gnuradio-core/src/lib/gengen/gr_vector_source_X.h.t deleted file mode 100644 index 041cc47a45..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_vector_source_X.h.t +++ /dev/null @@ -1,64 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2008,2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -#ifndef @GUARD_NAME@ -#define @GUARD_NAME@ - -#include <gr_core_api.h> -#include <gr_sync_block.h> - -class GR_CORE_API @NAME@; -typedef boost::shared_ptr<@NAME@> @NAME@_sptr; - -/*! - * \brief source of @TYPE@'s that gets its data from a vector - * \ingroup source_blk - */ - -class @NAME@ : public gr_sync_block { - friend GR_CORE_API @NAME@_sptr - gr_make_@BASE_NAME@ (const std::vector<@TYPE@> &data, bool repeat, int vlen, const std::vector<gr_tag_t> &tags); - - std::vector<@TYPE@> d_data; - bool d_repeat; - unsigned int d_offset; - int d_vlen; - bool d_settags; - std::vector<gr_tag_t> d_tags; - unsigned int d_tagpos; - - @NAME@ (const std::vector<@TYPE@> &data, bool repeat, int vlen, const std::vector<gr_tag_t> &tags); - - public: - void rewind() {d_offset=0;} - virtual int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - void set_data(const std::vector<@TYPE@> &data, const std::vector<gr_tag_t> &tags = std::vector<gr_tag_t>()); -}; - -GR_CORE_API @NAME@_sptr -gr_make_@BASE_NAME@ (const std::vector<@TYPE@> &data, bool repeat = false, int vlen = 1, const std::vector<gr_tag_t> &tags = std::vector<gr_tag_t>()); - -#endif diff --git a/gnuradio-core/src/lib/gengen/gr_vector_source_X.i.t b/gnuradio-core/src/lib/gengen/gr_vector_source_X.i.t deleted file mode 100644 index 1f1479f947..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_vector_source_X.i.t +++ /dev/null @@ -1,37 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2008,2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -// @WARNING@ - -GR_SWIG_BLOCK_MAGIC(gr,@BASE_NAME@); - -@NAME@_sptr -gr_make_@BASE_NAME@ (const std::vector<@TYPE@> &data, bool repeat = false, int vlen = 1, const std::vector<gr_tag_t> &tags=std::vector<gr_tag_t>()) - throw(std::invalid_argument); - -class @NAME@ : public gr_sync_block { - public: - void rewind(); - void set_data(const std::vector<@TYPE@> &data, const std::vector<gr_tag_t> &tags = std::vector<gr_tag_t>()); - private: - @NAME@ (const std::vector<@TYPE@> &data, bool repeat, int vlen, const std::vector<gr_tag_t> &tags); -}; diff --git a/gnuradio-core/src/lib/io/CMakeLists.txt b/gnuradio-core/src/lib/io/CMakeLists.txt deleted file mode 100644 index 7aeea798cd..0000000000 --- a/gnuradio-core/src/lib/io/CMakeLists.txt +++ /dev/null @@ -1,94 +0,0 @@ -# Copyright 2010-2011 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. - -######################################################################## -# This file included, use CMake directory variables -######################################################################## - -######################################################################## -# Append gnuradio-core library sources -######################################################################## -list(APPEND gnuradio_core_sources - ${CMAKE_CURRENT_SOURCE_DIR}/gr_histo_sink_f.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gr_oscope_guts.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gr_oscope_sink_f.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gr_oscope_sink_x.cc - ${CMAKE_CURRENT_SOURCE_DIR}/i2c.cc - ${CMAKE_CURRENT_SOURCE_DIR}/i2c_bitbang.cc - ${CMAKE_CURRENT_SOURCE_DIR}/i2c_bbio.cc - ${CMAKE_CURRENT_SOURCE_DIR}/i2c_bbio_pp.cc - ${CMAKE_CURRENT_SOURCE_DIR}/microtune_4702.cc - ${CMAKE_CURRENT_SOURCE_DIR}/microtune_4937.cc - ${CMAKE_CURRENT_SOURCE_DIR}/microtune_xxxx.cc - ${CMAKE_CURRENT_SOURCE_DIR}/ppio_ppdev.cc -) - -######################################################################## -# Install runtime headers -######################################################################## -install(FILES - ${CMAKE_CURRENT_SOURCE_DIR}/gr_histo_sink_f.h - ${CMAKE_CURRENT_SOURCE_DIR}/gr_oscope_guts.h - ${CMAKE_CURRENT_SOURCE_DIR}/gr_oscope_sink_f.h - ${CMAKE_CURRENT_SOURCE_DIR}/gr_oscope_sink_x.h - ${CMAKE_CURRENT_SOURCE_DIR}/gr_trigger_mode.h - ${CMAKE_CURRENT_SOURCE_DIR}/i2c.h - ${CMAKE_CURRENT_SOURCE_DIR}/i2c_bitbang.h - ${CMAKE_CURRENT_SOURCE_DIR}/i2c_bbio.h - ${CMAKE_CURRENT_SOURCE_DIR}/i2c_bbio_pp.h - ${CMAKE_CURRENT_SOURCE_DIR}/microtune_4702.h - ${CMAKE_CURRENT_SOURCE_DIR}/microtune_4937.h - ${CMAKE_CURRENT_SOURCE_DIR}/microtune_eval_board_defs.h - ${CMAKE_CURRENT_SOURCE_DIR}/microtune_xxxx.h - ${CMAKE_CURRENT_SOURCE_DIR}/ppio_ppdev.h - DESTINATION ${GR_INCLUDE_DIR}/gnuradio - COMPONENT "core_devel" -) - -######################################################################## -# Install swig headers -######################################################################## -if(ENABLE_PYTHON) -install(FILES - ${CMAKE_CURRENT_SOURCE_DIR}/io.i - ${CMAKE_CURRENT_SOURCE_DIR}/gr_histo_sink.i - ${CMAKE_CURRENT_SOURCE_DIR}/gr_oscope_sink.i - DESTINATION ${GR_INCLUDE_DIR}/gnuradio/swig - COMPONENT "core_swig" -) -endif(ENABLE_PYTHON) - -######################################################################## -# Handle triple-threat files that have cc, h, and i -######################################################################## -set(gr_core_io_triple_threats - microtune_xxxx_eval_board - microtune_4702_eval_board - microtune_4937_eval_board - ppio - sdr_1000 -) - -foreach(file_tt ${gr_core_io_triple_threats}) - list(APPEND gnuradio_core_sources ${CMAKE_CURRENT_SOURCE_DIR}/${file_tt}.cc) - install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${file_tt}.h DESTINATION ${GR_INCLUDE_DIR}/gnuradio COMPONENT "core_devel") - if(ENABLE_PYTHON) - install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${file_tt}.i DESTINATION ${GR_INCLUDE_DIR}/gnuradio/swig COMPONENT "core_swig") - endif(ENABLE_PYTHON) -endforeach(file_tt ${gr_core_io_triple_threats}) diff --git a/gnuradio-core/src/lib/io/gr_histo_sink.i b/gnuradio-core/src/lib/io/gr_histo_sink.i deleted file mode 100644 index 14079e1907..0000000000 --- a/gnuradio-core/src/lib/io/gr_histo_sink.i +++ /dev/null @@ -1,39 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009 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,histo_sink_f) - -gr_histo_sink_f_sptr gr_make_histo_sink_f (gr_msg_queue_sptr msgq); - -class gr_histo_sink_f : public gr_sync_block -{ -public: - ~gr_histo_sink_f (void); - - unsigned int get_frame_size(void); - unsigned int get_num_bins(void); - - void set_frame_size(unsigned int frame_size); - void set_num_bins(unsigned int num_bins); - -}; diff --git a/gnuradio-core/src/lib/io/gr_histo_sink_f.cc b/gnuradio-core/src/lib/io/gr_histo_sink_f.cc deleted file mode 100644 index fc0c12ce64..0000000000 --- a/gnuradio-core/src/lib/io/gr_histo_sink_f.cc +++ /dev/null @@ -1,165 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009,2010,2011 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_histo_sink_f.h> -#include <gr_io_signature.h> -#include <boost/math/special_functions/round.hpp> - -static float get_clean_num(float num){ - if (num == 0) return 0; - /* extract sign and exponent from num */ - int sign = (num < 0) ? -1 : 1; num = fabs(num); - float exponent = floor(log10(num)); - /* search for closest number with base 1, 2, 5, 10 */ - float closest_num = 10*pow(10, exponent); - if (fabs(num - 1*pow(10, exponent)) < fabs(num - closest_num)) - closest_num = 1*pow(10, exponent); - if (fabs(num - 2*pow(10, exponent)) < fabs(num - closest_num)) - closest_num = 2*pow(10, exponent); - if (fabs(num - 5*pow(10, exponent)) < fabs(num - closest_num)) - closest_num = 5*pow(10, exponent); - return sign*closest_num; -} - -gr_histo_sink_f_sptr -gr_make_histo_sink_f (gr_msg_queue_sptr msgq) -{ - return gnuradio::get_initial_sptr(new gr_histo_sink_f (msgq)); -} - -gr_histo_sink_f::gr_histo_sink_f (gr_msg_queue_sptr msgq) - : gr_sync_block ("histo_sink_f", gr_make_io_signature (1, 1, sizeof (float)), gr_make_io_signature (0, 0, 0)), - d_msgq (msgq), d_num_bins(11), d_frame_size(1000), d_sample_count(0), d_bins(NULL), d_samps(NULL) -{ - //allocate arrays and clear - set_num_bins(d_num_bins); - set_frame_size(d_frame_size); -} - -gr_histo_sink_f::~gr_histo_sink_f (void) -{ - delete [] d_samps; - delete [] d_bins; -} - -int -gr_histo_sink_f::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]; - gruel::scoped_lock guard(d_mutex); // hold mutex for duration of this function - for (unsigned int i = 0; i < (unsigned int)noutput_items; i++){ - d_samps[d_sample_count] = in[i]; - d_sample_count++; - /* processed a frame? */ - if (d_sample_count == d_frame_size){ - send_frame(); - clear(); - } - } - return noutput_items; -} - -void -gr_histo_sink_f::send_frame(void){ - /* output queue full, drop the data */ - if (d_msgq->full_p()) return; - /* find the minimum and maximum */ - float minimum = d_samps[0]; - float maximum = d_samps[0]; - for (unsigned int i = 0; i < d_frame_size; i++){ - if (d_samps[i] < minimum) minimum = d_samps[i]; - if (d_samps[i] > maximum) maximum = d_samps[i]; - } - minimum = get_clean_num(minimum); - maximum = get_clean_num(maximum); - if (minimum == maximum || minimum > maximum) return; //useless data or screw up? - /* load the bins */ - int index; - float bin_width = (maximum - minimum)/(d_num_bins-1); - for (unsigned int i = 0; i < d_sample_count; i++){ - index = boost::math::iround((d_samps[i] - minimum)/bin_width); - /* ensure the index range in case a small floating point error is involed */ - if (index < 0) index = 0; - if (index >= (int)d_num_bins) index = d_num_bins-1; - d_bins[index]++; - } - /* Build a message to hold the output records */ - gr_message_sptr msg = gr_make_message(0, minimum, maximum, d_num_bins*sizeof(float)); - float *out = (float *)msg->msg(); // get pointer to raw message buffer - /* normalize the bins and put into message */ - for (unsigned int i = 0; i < d_num_bins; i++){ - out[i] = ((float)d_bins[i])/d_frame_size; - } - /* send the message */ - d_msgq->handle(msg); -} - -void -gr_histo_sink_f::clear(void){ - d_sample_count = 0; - /* zero the bins */ - for (unsigned int i = 0; i < d_num_bins; i++){ - d_bins[i] = 0; - } -} - -/************************************************** - * Getters - **************************************************/ -unsigned int -gr_histo_sink_f::get_frame_size(void){ - return d_frame_size; -} - -unsigned int -gr_histo_sink_f::get_num_bins(void){ - return d_num_bins; -} - -/************************************************** - * Setters - **************************************************/ -void -gr_histo_sink_f::set_frame_size(unsigned int frame_size){ - gruel::scoped_lock guard(d_mutex); // hold mutex for duration of this function - d_frame_size = frame_size; - /* allocate a new sample array */ - delete [] d_samps; - d_samps = new float[d_frame_size]; - clear(); -} - -void -gr_histo_sink_f::set_num_bins(unsigned int num_bins){ - gruel::scoped_lock guard(d_mutex); // hold mutex for duration of this function - d_num_bins = num_bins; - /* allocate a new bin array */ - delete [] d_bins; - d_bins = new unsigned int[d_num_bins]; - clear(); -} diff --git a/gnuradio-core/src/lib/io/gr_histo_sink_f.h b/gnuradio-core/src/lib/io/gr_histo_sink_f.h deleted file mode 100644 index 934066ba20..0000000000 --- a/gnuradio-core/src/lib/io/gr_histo_sink_f.h +++ /dev/null @@ -1,71 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009 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_HISTO_SINK_F_H -#define INCLUDED_GR_HISTO_SINK_F_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <gr_msg_queue.h> -#include <gruel/thread.h> - -class gr_histo_sink_f; -typedef boost::shared_ptr<gr_histo_sink_f> gr_histo_sink_f_sptr; - -GR_CORE_API gr_histo_sink_f_sptr gr_make_histo_sink_f (gr_msg_queue_sptr msgq); - -/*! - * \brief Histogram module. - * \ingroup sink_blk - */ -class GR_CORE_API gr_histo_sink_f : public gr_sync_block -{ -private: - gr_msg_queue_sptr d_msgq; - unsigned int d_num_bins; - unsigned int d_frame_size; - unsigned int d_sample_count; - unsigned int *d_bins; - float *d_samps; - gruel::mutex d_mutex; - - friend GR_CORE_API gr_histo_sink_f_sptr gr_make_histo_sink_f (gr_msg_queue_sptr msgq); - gr_histo_sink_f (gr_msg_queue_sptr msgq); - void send_frame(void); - void clear(void); - -public: - ~gr_histo_sink_f (void); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - unsigned int get_frame_size(void); - unsigned int get_num_bins(void); - - void set_frame_size(unsigned int frame_size); - void set_num_bins(unsigned int num_bins); - -}; - -#endif /* INCLUDED_GR_HISTO_SINK_F_H */ diff --git a/gnuradio-core/src/lib/io/gr_oscope_guts.cc b/gnuradio-core/src/lib/io/gr_oscope_guts.cc deleted file mode 100644 index a5ea3002a9..0000000000 --- a/gnuradio-core/src/lib/io/gr_oscope_guts.cc +++ /dev/null @@ -1,437 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2003,2005 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_oscope_guts.h> -#include <stdexcept> -#include <stdio.h> -#include <algorithm> -#include <unistd.h> -#include <math.h> -#include <assert.h> - -/* - * Bad performance if it's large, and flaky triggering if it's too small - */ -static const int OUTPUT_RECORD_SIZE = 1024; // Must be power of 2 - -/* - * For (slow-updated) STRIPCHART triggering, we make the record size larger, since we - * potentially want to be able to "see" hours of data. This works as long as the - * update rates to a STRIPCHART are low, which they generally are--that's rather what - * a stripchart is all about! - */ -static const int SCHART_MULT = 8; - - -static inline int -wrap_bi (int buffer_index, int mx) // wrap buffer index -{ - return buffer_index & (mx - 1); -} - -static inline int -incr_bi (int buffer_index, int mx) // increment buffer index -{ - return wrap_bi (buffer_index + 1, mx); -} - -static inline int -decr_bi (int buffer_index, int mx) // decrement buffer index -{ - return wrap_bi (buffer_index - 1, mx); -} - -gr_oscope_guts::gr_oscope_guts (double sample_rate, gr_msg_queue_sptr msgq) - : d_nchannels (1), - d_msgq (msgq), - d_trigger_mode (gr_TRIG_MODE_AUTO), - d_trigger_slope (gr_TRIG_SLOPE_POS), - d_trigger_channel (0), - d_sample_rate (sample_rate), - d_update_rate (20), - d_trigger_level (0), - d_obi (0), - d_state (HOLD_OFF), - d_decimator_count (0), - d_decimator_count_init (1), - d_hold_off_count (0), - d_hold_off_count_init (OUTPUT_RECORD_SIZE/2-1), - d_pre_trigger_count (0), - d_post_trigger_count (0), - d_post_trigger_count_init (OUTPUT_RECORD_SIZE/2) -{ - for (int i = 0; i < MAX_CHANNELS; i++) - d_buffer[i] = 0; - - for (int i = 0; i < MAX_CHANNELS; i++){ - d_buffer[i] = new float [OUTPUT_RECORD_SIZE*SCHART_MULT]; - for (int j = 0; j < OUTPUT_RECORD_SIZE*SCHART_MULT; j++) - d_buffer[i][j] = 0.0; - } - - // be sure buffer is full before first write - enter_hold_off (); - update_rate_or_decimation_changed (); -} - -gr_oscope_guts::~gr_oscope_guts () -{ - for (int i = 0; i < MAX_CHANNELS; i++) - delete [] d_buffer[i]; -} - -// MANIPULATORS - -// \p channel_data points to nchannels float values. These are the values -// for each channel at this sample time. - -void -gr_oscope_guts::process_sample (const float *channel_data) -{ - d_decimator_count--; - if (d_decimator_count > 0) - return; - - d_decimator_count = d_decimator_count_init; - - if (d_trigger_mode != gr_TRIG_MODE_STRIPCHART) - { - for (int i = 0; i < d_nchannels; i++) - d_buffer[i][d_obi] = channel_data[i]; // copy data into buffer - - switch (d_state){ - case HOLD_OFF: - d_hold_off_count--; - if (d_hold_off_count <= 0) - enter_look_for_trigger (); - break; - - case LOOK_FOR_TRIGGER: - if (found_trigger ()) - enter_post_trigger (); - break; - - case POST_TRIGGER: - d_post_trigger_count--; - if (d_post_trigger_count <= 0){ - write_output_records (); - enter_hold_off (); - } - break; - - default: - assert (0); - } - - d_obi = incr_bi (d_obi, OUTPUT_RECORD_SIZE); - } - else - { - for (int i = 0; i < d_nchannels; i++) - { - for (int j = (OUTPUT_RECORD_SIZE*SCHART_MULT)-1; j > 0; j--) - { - d_buffer[i][j] = d_buffer[i][j-1]; - } - d_buffer[i][0] = channel_data[i]; - } - d_trigger_off = 0; - write_output_records(); - } -} - -/* - * Functions called on state entry - */ - -void -gr_oscope_guts::enter_hold_off () -{ - d_state = HOLD_OFF; - d_hold_off_count = d_hold_off_count_init; -} - -void -gr_oscope_guts::enter_look_for_trigger () -{ - d_pre_trigger_count = 0; - d_state = LOOK_FOR_TRIGGER; -} - -void -gr_oscope_guts::enter_post_trigger () -{ - d_state = POST_TRIGGER; - d_post_trigger_count = d_post_trigger_count_init; - //ensure that the trigger offset is no more than than half a sample - if (d_trigger_off > .5) d_trigger_off -= 1; - else d_post_trigger_count--; -} - -// ---------------------------------------------------------------- -// returns true if trigger found - -bool -gr_oscope_guts::found_trigger () -{ - int mx = d_trigger_mode == gr_TRIG_MODE_STRIPCHART ? OUTPUT_RECORD_SIZE*SCHART_MULT : - OUTPUT_RECORD_SIZE; - - float prev_sample = d_buffer[d_trigger_channel][decr_bi(d_obi, mx)]; - float new_sample = d_buffer[d_trigger_channel][d_obi]; - - switch (d_trigger_mode){ - - case gr_TRIG_MODE_AUTO: //too many samples without a trigger - d_pre_trigger_count++; - if (d_pre_trigger_count > OUTPUT_RECORD_SIZE/2) return true; - - case gr_TRIG_MODE_NORM: //look for trigger - switch (d_trigger_slope){ - - case gr_TRIG_SLOPE_POS: //trigger point in pos slope? - if (new_sample < d_trigger_level || prev_sample >= d_trigger_level) return false; - break; - - case gr_TRIG_SLOPE_NEG: //trigger point in neg slope? - if (new_sample > d_trigger_level || prev_sample <= d_trigger_level) return false; - break; - } - - //calculate the trigger offset in % sample - d_trigger_off = (d_trigger_level - prev_sample)/(new_sample - prev_sample); - return true; - - case gr_TRIG_MODE_FREE: //free run mode, always trigger - d_trigger_off = 0; - return true; - - default: - assert (0); - return false; - } -} - -// ---------------------------------------------------------------- -// write output records (duh!) - -void -gr_oscope_guts::write_output_records () -{ - int mx; - - mx = d_trigger_mode == gr_TRIG_MODE_STRIPCHART ? - OUTPUT_RECORD_SIZE*SCHART_MULT : OUTPUT_RECORD_SIZE; - - // if the output queue if full, drop the data like its hot. - if (d_msgq->full_p()) - return; - // Build a message to hold the output records - gr_message_sptr msg = - gr_make_message(0, // msg type - d_nchannels, // arg1 for other side - mx, // arg2 for other side - ((d_nchannels * mx) + 1) * sizeof(float)); // sizeof payload - - float *out = (float *)msg->msg(); // get pointer to raw message buffer - - for (int ch = 0; ch < d_nchannels; ch++){ - // note that d_obi + 1 points at the oldest sample in the buffer - for (int i = 0; i < mx; i++){ - out[i] = d_buffer[ch][wrap_bi(d_obi + 1 + i, mx)]; - } - out += mx; - } - //Set the last sample as the trigger offset: - // The non gl scope sink will not look at this last sample. - // The gl scope sink will use this last sample as an offset. - out[0] = d_trigger_off; - d_msgq->handle(msg); // send the msg -} - -// ---------------------------------------------------------------- - -bool -gr_oscope_guts::set_update_rate (double update_rate) -{ - d_update_rate = std::min (std::max (1./10., update_rate), d_sample_rate); - update_rate_or_decimation_changed (); - return true; -} - -bool -gr_oscope_guts::set_decimation_count (int decimator_count) -{ - decimator_count = std::max (1, decimator_count); - d_decimator_count_init = decimator_count; - update_rate_or_decimation_changed (); - return true; -} - -bool -gr_oscope_guts::set_sample_rate(double sample_rate) -{ - d_sample_rate = sample_rate; - return set_update_rate(update_rate()); -} - - -void -gr_oscope_guts::update_rate_or_decimation_changed () -{ - d_hold_off_count_init = - (int) rint (d_sample_rate / d_update_rate / d_decimator_count_init); -} - -bool -gr_oscope_guts::set_trigger_channel (int channel) -{ - if (channel >= 0 && channel < d_nchannels){ - d_trigger_channel = channel; - trigger_changed (); - return true; - } - - return false; -} - -bool -gr_oscope_guts::set_trigger_mode (gr_trigger_mode mode) -{ - d_trigger_mode = mode; - trigger_changed (); - return true; -} - -bool -gr_oscope_guts::set_trigger_slope (gr_trigger_slope slope) -{ - d_trigger_slope = slope; - trigger_changed (); - return true; -} - -bool -gr_oscope_guts::set_trigger_level (double trigger_level) -{ - d_trigger_level = trigger_level; - trigger_changed (); - return true; -} - -bool -gr_oscope_guts::set_trigger_level_auto () -{ - // find the level 1/2 way between the min and the max - - float min_v = d_buffer[d_trigger_channel][0]; - float max_v = d_buffer[d_trigger_channel][0]; - - for (int i = 1; i < OUTPUT_RECORD_SIZE; i++){ - min_v = std::min (min_v, d_buffer[d_trigger_channel][i]); - max_v = std::max (max_v, d_buffer[d_trigger_channel][i]); - } - return set_trigger_level((min_v + max_v) * 0.5); -} - -bool -gr_oscope_guts::set_num_channels(int nchannels) -{ - if (nchannels > 0 && nchannels <= MAX_CHANNELS){ - d_nchannels = nchannels; - return true; - } - return false; -} - - -void -gr_oscope_guts::trigger_changed () -{ - enter_look_for_trigger (); -} - -// ACCESSORS - -int -gr_oscope_guts::num_channels () const -{ - return d_nchannels; -} - -double -gr_oscope_guts::sample_rate () const -{ - return d_sample_rate; -} - -double -gr_oscope_guts::update_rate () const -{ - return d_update_rate; -} - -int -gr_oscope_guts::get_decimation_count () const -{ - return d_decimator_count_init; -} - -int -gr_oscope_guts::get_trigger_channel () const -{ - return d_trigger_channel; -} - -gr_trigger_mode -gr_oscope_guts::get_trigger_mode () const -{ - return d_trigger_mode; -} - -gr_trigger_slope -gr_oscope_guts::get_trigger_slope () const -{ - return d_trigger_slope; -} - -double -gr_oscope_guts::get_trigger_level () const -{ - return d_trigger_level; -} - -int -gr_oscope_guts::get_samples_per_output_record () const -{ - int mx; - - mx = OUTPUT_RECORD_SIZE; - if (d_trigger_mode == gr_TRIG_MODE_STRIPCHART) - { - mx = OUTPUT_RECORD_SIZE*SCHART_MULT; - } - return mx; -} diff --git a/gnuradio-core/src/lib/io/gr_oscope_guts.h b/gnuradio-core/src/lib/io/gr_oscope_guts.h deleted file mode 100644 index bc9513c7e7..0000000000 --- a/gnuradio-core/src/lib/io/gr_oscope_guts.h +++ /dev/null @@ -1,123 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2003,2005 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_OSCOPE_GUTS_H -#define INCLUDED_GR_OSCOPE_GUTS_H - -#include <gr_core_api.h> -#include <gr_trigger_mode.h> -#include <gr_msg_queue.h> - -/*! - * \brief guts of oscilloscope trigger and buffer module - * - * This module processes sets of samples provided the \p process_sample - * method. When appropriate given the updateRate, sampleRate and - * trigger conditions, process_sample will periodically write output - * records of captured data to output_fd. For each trigger event, - * nchannels records will be written. Each record consists of - * get_samples_per_output_record binary floats. The trigger instant - * occurs at the 1/2 way point in the buffer. Thus, output records - * consist of 50% pre-trigger data and 50% post-trigger data. - */ - -class GR_CORE_API gr_oscope_guts { -public: - static const int MAX_CHANNELS = 8; -private: - enum scope_state { HOLD_OFF, LOOK_FOR_TRIGGER, POST_TRIGGER }; - - int d_nchannels; // how many channels - gr_msg_queue_sptr d_msgq; // message queue we stuff output records into - gr_trigger_mode d_trigger_mode; - gr_trigger_slope d_trigger_slope; - int d_trigger_channel; // which channel to watch for trigger condition - double d_sample_rate; // input sample rate in Hz - double d_update_rate; // approx freq to produce an output record (Hz) - double d_trigger_level; - - int d_obi; // output buffer index - float *d_buffer[MAX_CHANNELS]; - - scope_state d_state; - int d_decimator_count; - int d_decimator_count_init; - int d_hold_off_count; - int d_hold_off_count_init; - int d_pre_trigger_count; - int d_post_trigger_count; - int d_post_trigger_count_init; - float d_trigger_off; //%sample trigger is off - - // NOT IMPLEMENTED - gr_oscope_guts (const gr_oscope_guts &rhs); // no copy constructor - gr_oscope_guts &operator= (const gr_oscope_guts &rhs); // no assignment operator - - void trigger_changed (); - void update_rate_or_decimation_changed (); - bool found_trigger (); // returns true if found - void write_output_records (); - - void enter_hold_off (); // called on state entry - void enter_look_for_trigger (); - void enter_post_trigger (); - -public: - // CREATORS - gr_oscope_guts (double sample_rate, gr_msg_queue_sptr msgq); - ~gr_oscope_guts (); - - // MANIPULATORS - - /*! - * \p channel_data points to nchannels float values. These are the values - * for each channel at this sample time. - */ - void process_sample (const float *channel_data); - - bool set_update_rate (double update_rate); - bool set_decimation_count (int decimation_count); - bool set_trigger_channel (int channel); - bool set_trigger_mode (gr_trigger_mode mode); - bool set_trigger_slope (gr_trigger_slope slope); - bool set_trigger_level (double trigger_level); - bool set_trigger_level_auto (); // set to 50% level - bool set_sample_rate(double sample_rate); - bool set_num_channels(int nchannels); - - - // ACCESSORS - int num_channels () const; - double sample_rate () const; - double update_rate () const; - int get_decimation_count () const; - int get_trigger_channel () const; - gr_trigger_mode get_trigger_mode () const; - gr_trigger_slope get_trigger_slope () const; - double get_trigger_level () const; - - // # of samples written to each output record. - int get_samples_per_output_record () const; -}; - -#endif /* INCLUDED_GR_OSCOPE_GUTS_H */ diff --git a/gnuradio-core/src/lib/io/gr_oscope_sink.i b/gnuradio-core/src/lib/io/gr_oscope_sink.i deleted file mode 100644 index 3d7072ed45..0000000000 --- a/gnuradio-core/src/lib/io/gr_oscope_sink.i +++ /dev/null @@ -1,77 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -%include gr_trigger_mode.h - -// GR_SWIG_BLOCK_MAGIC(gr,oscope_sink_x) - -%ignore gr_oscope_sink_x; -class gr_oscope_sink_x : public gr_sync_block -{ - protected: - gr_oscope_sink_x (const std::string name, - gr_io_signature_sptr input_sig, - double sample_rate); - - public: - ~gr_oscope_sink_x (); - - bool set_update_rate (double update_rate); - bool set_decimation_count (int decimation_count); - bool set_trigger_channel (int channel); - bool set_trigger_mode (gr_trigger_mode mode); - bool set_trigger_slope (gr_trigger_slope slope); - bool set_trigger_level (double trigger_level); - bool set_trigger_level_auto (); // set to 50% level - bool set_sample_rate(double sample_rate); - - // ACCESSORS - int num_channels () const; - double sample_rate () const; - double update_rate () const; - int get_decimation_count () const; - int get_trigger_channel () const; - gr_trigger_mode get_trigger_mode () const; - gr_trigger_slope get_trigger_slope () const; - double get_trigger_level () const; - - // # of samples written to each output record. - int get_samples_per_output_record () const; -}; - -// ---------------------------------------------------------------- - -GR_SWIG_BLOCK_MAGIC(gr,oscope_sink_f) - -gr_oscope_sink_f_sptr -gr_make_oscope_sink_f (double sample_rate, gr_msg_queue_sptr msgq); - -class gr_oscope_sink_f : public gr_oscope_sink_x -{ -private: - gr_oscope_sink_f (double sample_rate, gr_msg_queue_sptr msgq); - -public: - ~gr_oscope_sink_f (); -}; - -// ---------------------------------------------------------------- diff --git a/gnuradio-core/src/lib/io/gr_oscope_sink_f.cc b/gnuradio-core/src/lib/io/gr_oscope_sink_f.cc deleted file mode 100644 index 493a25e81e..0000000000 --- a/gnuradio-core/src/lib/io/gr_oscope_sink_f.cc +++ /dev/null @@ -1,78 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2003,2004,2005,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_oscope_sink_f.h> -#include <gr_io_signature.h> -#include <gr_oscope_guts.h> - - -gr_oscope_sink_f_sptr -gr_make_oscope_sink_f (double sampling_rate, gr_msg_queue_sptr msgq) -{ - return gnuradio::get_initial_sptr(new gr_oscope_sink_f (sampling_rate, msgq)); -} - - -gr_oscope_sink_f::gr_oscope_sink_f (double sampling_rate, gr_msg_queue_sptr msgq) - : gr_oscope_sink_x ("oscope_sink_f", - gr_make_io_signature (1, gr_oscope_guts::MAX_CHANNELS, sizeof (float)), - sampling_rate), - d_msgq(msgq) -{ - d_guts = new gr_oscope_guts (d_sampling_rate, d_msgq); -} - - -bool -gr_oscope_sink_f::check_topology (int ninputs, int noutputs) -{ - return d_guts->set_num_channels(ninputs); -} - - -gr_oscope_sink_f::~gr_oscope_sink_f () -{ -} - -int -gr_oscope_sink_f::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - int ni = input_items.size (); - float tmp[gr_oscope_guts::MAX_CHANNELS]; - - for (int i = 0; i < noutput_items; i++){ - - // FIXME for now, copy the data. Fix later if reqd - for (int ch = 0; ch < ni; ch++) - tmp[ch] = ((const float *) input_items[ch])[i]; - - d_guts->process_sample (tmp); - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/io/gr_oscope_sink_f.h b/gnuradio-core/src/lib/io/gr_oscope_sink_f.h deleted file mode 100644 index 8d434d2bc4..0000000000 --- a/gnuradio-core/src/lib/io/gr_oscope_sink_f.h +++ /dev/null @@ -1,63 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2003,2004,2005 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_OSCOPE_SINK_F_H -#define INCLUDED_GR_OSCOPE_SINK_F_H - -#include <gr_core_api.h> -#include <gr_oscope_sink_x.h> -#include <gr_msg_queue.h> - -class gr_oscope_sink_f; -typedef boost::shared_ptr<gr_oscope_sink_x> gr_oscope_sink_f_sptr; - -GR_CORE_API gr_oscope_sink_f_sptr gr_make_oscope_sink_f (double sampling_rate, gr_msg_queue_sptr msgq); - - -/*! - * \brief Building block for python oscilloscope module. - * \ingroup sink_blk - * - * Accepts multiple float streams. - */ -class GR_CORE_API gr_oscope_sink_f : public gr_oscope_sink_x -{ -private: - friend GR_CORE_API gr_oscope_sink_f_sptr - gr_make_oscope_sink_f (double sampling_rate, gr_msg_queue_sptr msgq); - - gr_oscope_sink_f (double sampling_rate, gr_msg_queue_sptr msgq); - - gr_msg_queue_sptr d_msgq; - - public: - ~gr_oscope_sink_f (); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - bool check_topology (int ninputs, int noutputs); -}; - -#endif /* INCLUDED_GR_OSCOPE_SINK_F_H */ - diff --git a/gnuradio-core/src/lib/io/gr_oscope_sink_x.cc b/gnuradio-core/src/lib/io/gr_oscope_sink_x.cc deleted file mode 100644 index 9580dbf6a3..0000000000 --- a/gnuradio-core/src/lib/io/gr_oscope_sink_x.cc +++ /dev/null @@ -1,156 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2003,2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_oscope_sink_x.h> -#include <gr_io_signature.h> -#include <gr_oscope_guts.h> - - -gr_oscope_sink_x::gr_oscope_sink_x (const std::string name, - gr_io_signature_sptr input_sig, - double sampling_rate) - : gr_sync_block (name, input_sig, gr_make_io_signature (0, 0, 0)), - d_sampling_rate (sampling_rate), d_guts (0) -{ -} - -gr_oscope_sink_x::~gr_oscope_sink_x () -{ - delete d_guts; -} - -// ---------------------------------------------------------------- - -bool -gr_oscope_sink_x::set_update_rate (double update_rate) -{ - return d_guts->set_update_rate (update_rate); -} - -bool -gr_oscope_sink_x::set_decimation_count (int decimation_count) -{ - return d_guts->set_decimation_count (decimation_count); -} - -bool -gr_oscope_sink_x::set_trigger_channel (int channel) -{ - return d_guts->set_trigger_channel (channel); -} - -bool -gr_oscope_sink_x::set_trigger_mode (gr_trigger_mode mode) -{ - return d_guts->set_trigger_mode (mode); -} - -bool -gr_oscope_sink_x::set_trigger_slope (gr_trigger_slope slope) -{ - return d_guts->set_trigger_slope (slope); -} - -bool -gr_oscope_sink_x::set_trigger_level (double trigger_level) -{ - return d_guts->set_trigger_level (trigger_level); -} - - -bool -gr_oscope_sink_x::set_trigger_level_auto () -{ - return d_guts->set_trigger_level_auto (); -} - -bool -gr_oscope_sink_x::set_sample_rate (double sample_rate) -{ - return d_guts->set_sample_rate (sample_rate); -} - -bool -gr_oscope_sink_x::set_num_channels (int nchannels) -{ - return d_guts->set_num_channels (nchannels); -} - -// ACCESSORS - -int -gr_oscope_sink_x::num_channels () const -{ - return d_guts->num_channels (); -} - -double -gr_oscope_sink_x::sample_rate () const -{ - return d_guts->sample_rate (); -} - -double -gr_oscope_sink_x::update_rate () const -{ - return d_guts->update_rate (); -} - -int -gr_oscope_sink_x::get_decimation_count () const -{ - return d_guts->get_decimation_count (); -} - -int -gr_oscope_sink_x::get_trigger_channel () const -{ - return d_guts->get_trigger_channel (); -} - -gr_trigger_mode -gr_oscope_sink_x::get_trigger_mode () const -{ - return d_guts->get_trigger_mode (); -} - -gr_trigger_slope -gr_oscope_sink_x::get_trigger_slope () const -{ - return d_guts->get_trigger_slope (); -} - -double -gr_oscope_sink_x::get_trigger_level () const -{ - return d_guts->get_trigger_level (); -} - -int -gr_oscope_sink_x::get_samples_per_output_record () const -{ - return d_guts->get_samples_per_output_record (); -} diff --git a/gnuradio-core/src/lib/io/gr_oscope_sink_x.h b/gnuradio-core/src/lib/io/gr_oscope_sink_x.h deleted file mode 100644 index 153d0937ab..0000000000 --- a/gnuradio-core/src/lib/io/gr_oscope_sink_x.h +++ /dev/null @@ -1,77 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2003,2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_OSCOPE_SINK_X_H -#define INCLUDED_GR_OSCOPE_SINK_X_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <gr_trigger_mode.h> - -class gr_oscope_guts; - -/*! - * \brief Abstract class for python oscilloscope module. - * \ingroup sink_blk - * - * Don't instantiate this. Use gr_oscope_sink_f or gr_oscope_sink_c instead. - */ -class GR_CORE_API gr_oscope_sink_x : public gr_sync_block -{ -protected: - double d_sampling_rate; - gr_oscope_guts *d_guts; - - gr_oscope_sink_x (const std::string name, - gr_io_signature_sptr input_sig, - double sampling_rate); - -public: - ~gr_oscope_sink_x (); - - bool set_update_rate (double update_rate); - bool set_decimation_count (int decimation_count); - bool set_trigger_channel (int channel); - bool set_trigger_mode (gr_trigger_mode mode); - bool set_trigger_slope (gr_trigger_slope slope); - bool set_trigger_level (double trigger_level); - bool set_trigger_level_auto (); // set to 50% level - bool set_sample_rate(double sample_rate); - bool set_num_channels (int nchannels); - - - // ACCESSORS - int num_channels () const; - double sample_rate () const; - double update_rate () const; - int get_decimation_count () const; - int get_trigger_channel () const; - gr_trigger_mode get_trigger_mode () const; - gr_trigger_slope get_trigger_slope () const; - double get_trigger_level () const; - - // # of samples written to each output record. - int get_samples_per_output_record () const; - -}; - -#endif /* INCLUDED_GR_OSCOPE_SINK_X_H */ diff --git a/gnuradio-core/src/lib/io/i2c.cc b/gnuradio-core/src/lib/io/i2c.cc deleted file mode 100644 index 02dd47b53e..0000000000 --- a/gnuradio-core/src/lib/io/i2c.cc +++ /dev/null @@ -1,28 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2001,2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#include "i2c.h" - -i2c::~i2c () -{ - // NOP -} diff --git a/gnuradio-core/src/lib/io/i2c_bbio.cc b/gnuradio-core/src/lib/io/i2c_bbio.cc deleted file mode 100644 index ddd00290d0..0000000000 --- a/gnuradio-core/src/lib/io/i2c_bbio.cc +++ /dev/null @@ -1,29 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2001,2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#include "i2c_bbio.h" - -i2c_bbio::~i2c_bbio () -{ - // NOP -} - diff --git a/gnuradio-core/src/lib/io/i2c_bbio_pp.cc b/gnuradio-core/src/lib/io/i2c_bbio_pp.cc deleted file mode 100644 index 382bb6b378..0000000000 --- a/gnuradio-core/src/lib/io/i2c_bbio_pp.cc +++ /dev/null @@ -1,87 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2001,2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#include "i2c_bbio_pp.h" -#include "microtune_eval_board_defs.h" - -i2c_bbio_pp::i2c_bbio_pp (ppio_sptr pp) -{ - d_pp = pp; - d_pp->lock (); - d_pp->write_control (d_pp->read_control () & ~UT_CP_MUST_BE_ZERO); // output, no interrupts - d_pp->unlock (); -} - -i2c_bbio_sptr -make_i2c_bbio_pp (ppio_sptr pp) -{ - return i2c_bbio_sptr (new i2c_bbio_pp (pp)); -} - -void -i2c_bbio_pp::set_scl (bool state) -{ - int r = d_pp->read_control(); - - if (!state){ // active low - d_pp->write_control (r | UT_CP_TUNER_SCL); - } - else { - d_pp->write_control (r & ~UT_CP_TUNER_SCL); - } - d_pp->read_control (); // use for 1us delay - d_pp->read_control (); // use for 1us delay -} - -void -i2c_bbio_pp::set_sda (bool state) -{ - int r = d_pp->read_data (); - - if (!state){ // active low - d_pp->write_data (r | UT_DP_TUNER_SDA_OUT); - } - else { - d_pp->write_data (r & ~UT_DP_TUNER_SDA_OUT); - } - d_pp->read_data (); // use for 1us delay - d_pp->read_data (); // use for 1us delay -} - -bool -i2c_bbio_pp::get_sda () -{ - int r = d_pp->read_status (); - return (r & UT_SP_TUNER_SDA_IN) == 0; // eval board has an inverter on it -} - -void -i2c_bbio_pp::lock () -{ - d_pp->lock (); -} - -void -i2c_bbio_pp::unlock () -{ - d_pp->unlock (); -} diff --git a/gnuradio-core/src/lib/io/i2c_bbio_pp.h b/gnuradio-core/src/lib/io/i2c_bbio_pp.h deleted file mode 100644 index 2391bc1fc0..0000000000 --- a/gnuradio-core/src/lib/io/i2c_bbio_pp.h +++ /dev/null @@ -1,57 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2001,2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_I2C_BBIO_PP_H -#define INCLUDED_I2C_BBIO_PP_H - -#include <gr_core_api.h> -#include "i2c_bbio.h" -#include "ppio.h" - -/*! - * \brief concrete class that bit bangs eval board i2c bus using parallel port - * - * \ingroup base - * This class talks to the i2c bus on the microtune eval board using - * the parallel port. This works for both the 4937 and 4702 boards. - */ -class GR_CORE_API i2c_bbio_pp : public i2c_bbio { - friend GR_CORE_API i2c_bbio_sptr make_i2c_bbio_pp (ppio_sptr pp); - i2c_bbio_pp (ppio_sptr pp); - - public: - - virtual void set_scl (bool state); - virtual void set_sda (bool state); - virtual bool get_sda (); - - virtual void lock (); - virtual void unlock (); - - private: - ppio_sptr d_pp; -}; - -GR_CORE_API i2c_bbio_sptr make_i2c_bbio_pp (ppio_sptr pp); - - -#endif /* INCLUDED_I2C_BBIO_PP_H */ diff --git a/gnuradio-core/src/lib/io/i2c_bitbang.cc b/gnuradio-core/src/lib/io/i2c_bitbang.cc deleted file mode 100644 index eb801c68f5..0000000000 --- a/gnuradio-core/src/lib/io/i2c_bitbang.cc +++ /dev/null @@ -1,144 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2001,2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#include "i2c_bitbang.h" - -i2c_bitbang::i2c_bitbang (i2c_bbio_sptr io) -{ - d_io = io; - d_io->lock (); - - stop (); // get bus in known state - - d_io->unlock (); -} - -i2c_sptr -make_i2c_bitbang (i2c_bbio_sptr io) -{ - return i2c_sptr (new i2c_bitbang (io)); -} - - -// start: -// entry: SCL = 1, SDA = 1 -// exit: SCL = 0, SDA = 0 - -void -i2c_bitbang::start () -{ - set_sda (1); - set_scl (1); - set_sda (0); // SDA high -> low while SCL high - set_scl (0); -} - - -// stop: -// entry: SCL = X, SDA = X -// exit: SCL = 1, SDA = 1 - -void -i2c_bitbang::stop () -{ - set_scl (0); - set_sda (0); - set_scl (1); - set_sda (1); // SDA low -> high while SCL high -} - - -// write_bit: -// entry: SCL = 0, SDA = X -// exit: SCL = 0, SDA = X - -void -i2c_bitbang::write_bit (bool bit) -{ - set_sda (bit); - set_scl (1); - set_scl (0); -} - - -// write_byte: -// entry: SCL = 0, SDA = X -// exit: SCL = 0, SDA = 1 - -bool -i2c_bitbang::write_byte (char t) -{ - int i; - bool ack_bit; - - for (i = 0; i < 8; i++){ - write_bit (t & 0x80); - t <<= 1; - } - - // clock #9. This is the ACK bit. - - set_sda (1); // tristate SDA - set_scl (1); - ack_bit = get_sda (); // slave should pull SDA line low - set_scl (0); - - return ack_bit == 0; -} - - -// write: the high level entry point... -// entry: SCL = 1, SDA = 1 -// exit: SCL = 1, SDA = 1 - -bool -i2c_bitbang::write (int addr, const unsigned char *buf, int nbytes) -{ - bool ok = true; - - d_io->lock (); - start (); - ok = write_byte ((addr << 1) | 0); // addr plus "read opcode" - - for (int i = 0; i < nbytes; i++) - ok &= write_byte (buf[i]); - - stop (); - d_io->unlock (); - return ok; -} - - -// read: the high level entry point... -// entry: SCL = 1, SDA = 1 -// exit: SCL = 1, SDA = 1 - -int -i2c_bitbang::read (int addr, unsigned char *buf, int max_bytes) -{ - d_io->lock (); - - // FIXME - - d_io->unlock (); - return -1; -} diff --git a/gnuradio-core/src/lib/io/i2c_bitbang.h b/gnuradio-core/src/lib/io/i2c_bitbang.h deleted file mode 100644 index 1d6fe5044e..0000000000 --- a/gnuradio-core/src/lib/io/i2c_bitbang.h +++ /dev/null @@ -1,65 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2001,2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_I2C_BITBANG_H -#define INCLUDED_I2C_BITBANG_H - -#include <gr_core_api.h> -#include <i2c.h> -#include <i2c_bbio.h> - -/*! - * \brief class for controlling i2c bus - * \ingroup base - */ -class GR_CORE_API i2c_bitbang : public i2c { - friend GR_CORE_API i2c_sptr make_i2c_bitbang (i2c_bbio_sptr io); - i2c_bitbang (i2c_bbio_sptr io); - - public: - ~i2c_bitbang () {} - - //! \returns true iff successful - bool write (int addr, const unsigned char *buf, int nbytes); - - //! \returns number of bytes read or -1 if error - int read (int addr, unsigned char *buf, int max_bytes); - - -private: - void start (); - void stop (); - void write_bit (bool bit); - bool write_byte (char byte); - - void set_sda (bool bit) { d_io->set_sda (bit); } - void set_scl (bool bit) { d_io->set_scl (bit); } - bool get_sda () { return d_io->get_sda (); } - - i2c_bbio_sptr d_io; -}; - -GR_CORE_API i2c_sptr make_i2c_bitbang (i2c_bbio_sptr io); - -#endif /* INCLUDED_I2C_BITBANG_H */ - - diff --git a/gnuradio-core/src/lib/io/io.i b/gnuradio-core/src/lib/io/io.i deleted file mode 100644 index 6cd3e06f47..0000000000 --- a/gnuradio-core/src/lib/io/io.i +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2007 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_histo_sink_f.h> -#include <microtune_4702_eval_board.h> -#include <microtune_4937_eval_board.h> -#include <sdr_1000.h> -#include <gr_oscope_sink_x.h> -#include <gr_oscope_sink_f.h> -#include <ppio.h> -%} - -%include "gr_histo_sink.i" -%include "microtune_xxxx_eval_board.i" -%include "microtune_4702_eval_board.i" -%include "microtune_4937_eval_board.i" -%include "sdr_1000.i" -%include "gr_oscope_sink.i" -%include "ppio.i" - - diff --git a/gnuradio-core/src/lib/io/microtune_4702.cc b/gnuradio-core/src/lib/io/microtune_4702.cc deleted file mode 100644 index 3ec072d51b..0000000000 --- a/gnuradio-core/src/lib/io/microtune_4702.cc +++ /dev/null @@ -1,183 +0,0 @@ -/* -*- c++-*- */ -/* - * Copyright 2001,2003,2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#include "microtune_4702.h" -#include <stdlib.h> -#include <stdio.h> -#include "i2c.h" - -static const double FIRST_IF = 36.00e6; - -// The tuner internally has 3 bands: VHF Low, VHF High & UHF. -// These are the recommened boundaries -static const double VHF_High_takeover = 174e6; -static const double UHF_takeover = 470e6; - -static int PLL_I2C_ADDR = 0x60; - -static unsigned char -control_byte_1 (bool prescaler, int reference_divisor) -{ - int c = 0x80; - //Note: Last two divider bits (bits 2 and 3 of this byte) determined later - if (prescaler) - c |= 0x10; - - switch (reference_divisor){ - case 2: - c |= 0x00; break; - case 4: - c |= 0x01; break; - case 8: - c |= 0x02; break; - case 16: - c |= 0x03; break; - case 32: - c |= 0x04; break; - case 64: - c |= 0x05; break; - case 128: - c |= 0x06; break; - case 256: - c |= 0x07; break; - case 24: - c |= 0x08; break; - case 5: - c |= 0x09; break; - case 10: - c |= 0x0A; break; - case 20: - c |= 0x0B; break; - case 40: - c |= 0x0C; break; - case 80: - c |= 0x0D; break; - case 160: - c |= 0x0E; break; - case 320: - c |= 0x0F; break; - default: - abort (); - } - return c; -} - -static unsigned char -control_byte_2 (double target_freq) -{ - int c; - - if (target_freq < VHF_High_takeover) // VHF low - c = 0x8E; - - else if (target_freq < UHF_takeover){ // VHF high - c = 0x05; - if (target_freq < 390e6) - c |= 0x40; - else - c |= 0x80; - } - else { // UHF - c = 0x03; - if (target_freq < 750e6) - c |= 0x80; - else - c |= 0xC0; - } - - return c; -} - - -microtune_4702::microtune_4702 (i2c_sptr i2c, int i2c_addr) -{ - d_i2c = i2c; - d_i2c_addr = i2c_addr; - d_reference_divider = 320; - d_prescaler = false; -} - -microtune_4702::~microtune_4702 () -{ - // nop -} - -/*! - * \brief select RF frequency to be tuned to output frequency. - * \p target_freq is the requested frequency in Hz, \p actual_freq - * is set to the actual frequency tuned. It takes about 100 ms - * for the PLL to settle. - * - * \returns true iff sucessful. - */ -bool -microtune_4702::set_RF_freq (double target_freq, double *p_actual_freq) -{ - unsigned char buf[4]; - - double target_f_osc = target_freq + FIRST_IF; - - double f_ref = 4e6 / d_reference_divider; - - //int divisor = (int) ((target_f_osc + (f_ref * 4)) / (f_ref * 8)); - - long int divisor = (long int) (target_f_osc / f_ref); - double actual_freq = (f_ref * divisor) - FIRST_IF; - if (p_actual_freq != 0) - *p_actual_freq = actual_freq; - - if ((divisor & ~0x1ffff) != 0) // >17 bit divisor - return false; - - buf[0] = ((divisor & 0x07f00) >> 8) & 0xff; // DB1 - buf[1] = divisor & 0xff; // DB2 - buf[2] = control_byte_1 (d_prescaler, d_reference_divider); - buf[2] = buf[2] | (((divisor & 0x18000) >> 10) & 0xff); - buf[3] = control_byte_2 (target_freq); - - printf ("%x\n", PLL_I2C_ADDR); -//#if 0 - printf ("set_RF_freq: target: %g MHz actual: %g MHz %02x %02x %02x %02x\n", - target_freq/1e6, actual_freq/1e6, buf[0], buf[1], buf[2], buf[3]); -//#endif - - return d_i2c->write (d_i2c_addr, buf, sizeof (buf)); -} - -/*! - * \returns true iff PLL is locked - */ -bool -microtune_4702::pll_locked_p () -{ - // FIXME - return true; -} - -/*! - * \returns the output frequency of the tuner in Hz. - */ -double -microtune_4702::get_output_freq () -{ - return FIRST_IF; -} diff --git a/gnuradio-core/src/lib/io/microtune_4702.h b/gnuradio-core/src/lib/io/microtune_4702.h deleted file mode 100644 index ccc66db71e..0000000000 --- a/gnuradio-core/src/lib/io/microtune_4702.h +++ /dev/null @@ -1,71 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2001,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. - */ - -#ifndef INCLUDED_MICROTUNE_4702_H -#define INCLUDED_MICROTUNE_4702_H - -#include <gr_core_api.h> -#include <microtune_xxxx.h> - -/*! - * \brief class for controlling microtune 4702 tuner module - * \ingroup hardware - */ - -class GR_CORE_API microtune_4702 : public microtune_xxxx { -public: - microtune_4702 (i2c_sptr i2c, int i2c_addr); - - virtual ~microtune_4702 (); - - /*! - * \brief select RF frequency to be tuned to output frequency. - * \p freq is the requested frequency in Hz, \p actual_freq - * is set to the actual frequency tuned. It takes about 100 ms - * for the PLL to settle. - * - * \returns true iff sucessful. - */ - bool set_RF_freq (double freq, double *actual_freq); - - /*! - * \returns true iff PLL is locked - */ - bool pll_locked_p (); - - /*! - * \returns the output frequency of the tuner in Hz. - */ - double get_output_freq (); - - private: - - i2c_sptr d_i2c; - int d_i2c_addr; - int d_reference_divider; - bool d_prescaler; /* if set, higher charge pump current: - faster tuning, worse phase noise - for distance < 10kHz to the carrier */ -}; - -#endif /* INCLUDED_MICROTUNE_4702_H */ - diff --git a/gnuradio-core/src/lib/io/microtune_4702_eval_board.cc b/gnuradio-core/src/lib/io/microtune_4702_eval_board.cc deleted file mode 100644 index f6c68726b5..0000000000 --- a/gnuradio-core/src/lib/io/microtune_4702_eval_board.cc +++ /dev/null @@ -1,88 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2001,2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#include "microtune_4702_eval_board.h" -#include "microtune_eval_board_defs.h" -#include "ppio.h" -#include "microtune_4702.h" - -static const int TUNER_I2C_ADDR = 0x60; - -microtune_4702_eval_board::microtune_4702_eval_board (int which_pp) - : microtune_xxxx_eval_board (which_pp) -{ - d_tuner = new microtune_4702 (d_i2c, TUNER_I2C_ADDR); -} - -microtune_4702_eval_board::~microtune_4702_eval_board () -{ - // default is OK -} - -static const float RF_MIN_V = 1.0; // RF AGC control voltages -static const float RF_MAX_V = 4.0; -static const float IF_MIN_V = 2.0; // IF AGC control voltages -static const float IF_MAX_V = 4.0; - -static const float MIN_AGC = 0; // bottom of synthetic range -static const float MAX_AGC = 1000; // top of synthetic range - -static const float CUTOVER_POINT = 667; - - -// linear is in the range MIN_AGC to MAX_AGC - -static float -linear_to_RF_AGC_voltage (float linear) -{ - if (linear >= CUTOVER_POINT) - return RF_MAX_V; - - float slope = (RF_MAX_V - RF_MIN_V) / CUTOVER_POINT; - return RF_MIN_V + linear * slope; -} - -static float -linear_to_IF_AGC_voltage (float linear) -{ - if (linear < CUTOVER_POINT) - return IF_MIN_V; - - float slope = (IF_MAX_V - IF_MIN_V) / (MAX_AGC - CUTOVER_POINT); - return IF_MIN_V + (linear - CUTOVER_POINT) * slope; -} - -void -microtune_4702_eval_board::set_AGC (float v) -{ - if (v < MIN_AGC) - v = MIN_AGC; - - if (v > MAX_AGC) - v = MAX_AGC; - - float rf_agc_voltage = linear_to_RF_AGC_voltage (v); - float if_agc_voltage = linear_to_IF_AGC_voltage (v); - - set_RF_AGC_voltage (rf_agc_voltage); - set_IF_AGC_voltage (if_agc_voltage); -} diff --git a/gnuradio-core/src/lib/io/microtune_4702_eval_board.h b/gnuradio-core/src/lib/io/microtune_4702_eval_board.h deleted file mode 100644 index d866a4b943..0000000000 --- a/gnuradio-core/src/lib/io/microtune_4702_eval_board.h +++ /dev/null @@ -1,49 +0,0 @@ -/* -*- C++ -*- */ -/* - * Copyright 2001,2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_MICROTUNE_4702_EVAL_BOARD_H -#define INCLUDED_MICROTUNE_4702_EVAL_BOARD_H - -#include <gr_core_api.h> -#include "microtune_xxxx_eval_board.h" - -/*! - * \brief control microtune 4702 eval board - * \ingroup hardware - */ - -class GR_CORE_API microtune_4702_eval_board : public microtune_xxxx_eval_board { -public: - microtune_4702_eval_board (int which_pp = 0); - ~microtune_4702_eval_board (); - - /*! - * \brief set RF and IF AGC levels together (scale [0, 1000]) - * - * This provides a simple linear interface for adjusting both - * the RF and IF gain in consort. This is the easy to use interface. - * 0 corresponds to minimum gain. 1000 corresponds to maximum gain. - */ - virtual void set_AGC (float value_0_1000); -}; - -#endif /* INCLUDED_MICROTUNE_4702_EVAL_BOARD_H */ diff --git a/gnuradio-core/src/lib/io/microtune_4702_eval_board.i b/gnuradio-core/src/lib/io/microtune_4702_eval_board.i deleted file mode 100644 index fc085a9756..0000000000 --- a/gnuradio-core/src/lib/io/microtune_4702_eval_board.i +++ /dev/null @@ -1,36 +0,0 @@ -/* -*- C++ -*- */ -/* - * Copyright 2001,2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -class microtune_4702_eval_board : public microtune_xxxx_eval_board { -public: - microtune_4702_eval_board (int which_pp = 0); - ~microtune_4702_eval_board (); - - /*! - * \brief set RF and IF AGC levels together (scale [0, 1000]) - * - * This provides a simple linear interface for adjusting both - * the RF and IF gain in consort. This is the easy to use interface. - * 0 corresponds to minimum gain. 1000 corresponds to maximum gain. - */ - virtual void set_AGC (float value_0_1000); -}; diff --git a/gnuradio-core/src/lib/io/microtune_4937.cc b/gnuradio-core/src/lib/io/microtune_4937.cc deleted file mode 100644 index 72ddd4bb62..0000000000 --- a/gnuradio-core/src/lib/io/microtune_4937.cc +++ /dev/null @@ -1,146 +0,0 @@ -/* -*- c++-*- */ -/* - * Copyright 2001,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. - */ - -#include "microtune_4937.h" -#include <stdlib.h> -#include <stdio.h> -#include <i2c.h> - -static const double first_IF = 43.75e6; - -// The tuner internally has 3 bands: VHF Low, VHF High & UHF. -// These are the recommened boundaries -static const double VHF_High_takeover = 158e6; -static const double UHF_takeover = 464e6; - - -static unsigned char -control_byte_1 (bool fast_tuning_p, int reference_divisor) -{ - int c = 0x88; - - if (fast_tuning_p) - c |= 0x40; - - switch (reference_divisor){ - case 512: - c |= 0x3 << 1; break; - case 640: - c |= 0x0 << 1; break; - case 1024: - c |= 0x1 << 1; break; - default: - abort (); - } - return c; -} - -static unsigned char -control_byte_2 (double target_freq, bool shutdown_tx_PGA) -{ - int c; - - if (target_freq < VHF_High_takeover) // VHF low - c = 0xa0; - else if (target_freq < UHF_takeover) // VHF high - c = 0x90; - else // UHF - c = 0x30; - - if (shutdown_tx_PGA) - c |= 0x08; - - return c; -} - -microtune_4937::microtune_4937 (i2c_sptr i2c, int i2c_addr) -{ - d_i2c = i2c; - d_i2c_addr = i2c_addr; - d_reference_divider = 640; - d_fast_tuning_p = false; -} - -microtune_4937::~microtune_4937 () -{ - // nop -} - -/*! - * \brief select RF frequency to be tuned to output frequency. - * \p target_freq is the requested frequency in Hz, \p actual_freq - * is set to the actual frequency tuned. It takes about 100 ms - * for the PLL to settle. - * - * \returns true iff sucessful. - */ -bool -microtune_4937::set_RF_freq (double target_freq, double *p_actual_freq) -{ - unsigned char buf[4]; - - double target_f_osc = target_freq + first_IF; - - double f_ref = 4e6 / d_reference_divider; - - // f_osc = f_ref * 8 * divisor - // divisor = f_osc / (f_ref * 8) - - int divisor = (int) ((target_f_osc + (f_ref * 4)) / (f_ref * 8)); - double actual_freq = (f_ref * 8 * divisor) - first_IF; - if (p_actual_freq != 0) - *p_actual_freq = actual_freq; - - if ((divisor & ~0x7fff) != 0) // 15 bit divisor - return false; - - buf[0] = (divisor >> 8) & 0xff; // DB1 - buf[1] = divisor & 0xff; // DB2 - buf[2] = control_byte_1 (d_fast_tuning_p, d_reference_divider); - buf[3] = control_byte_2 (target_freq, true); - -#if 0 - printf ("set_RF_freq: target: %g MHz actual: %g MHz %02x %02x %02x %02x\n", - target_freq/1e6, actual_freq/1e6, buf[0], buf[1], buf[2], buf[3]); -#endif - - return d_i2c->write (d_i2c_addr, buf, 4); -} - -/*! - * \returns true iff PLL is locked - */ -bool -microtune_4937::pll_locked_p () -{ - // FIXME - return true; -} - -/*! - * \returns the output frequency of the tuner in Hz. - */ -double -microtune_4937::get_output_freq () -{ - return 5.75e6; // 3x7702 -} diff --git a/gnuradio-core/src/lib/io/microtune_4937.h b/gnuradio-core/src/lib/io/microtune_4937.h deleted file mode 100644 index be8657c950..0000000000 --- a/gnuradio-core/src/lib/io/microtune_4937.h +++ /dev/null @@ -1,68 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2001,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. - */ - -#ifndef INCLUDED_MICROTUNE_4937_H -#define INCLUDED_MICROTUNE_4937_H - -#include <gr_core_api.h> -#include <microtune_xxxx.h> - -/*! - * \brief class for controlling microtune 4937 tuner module - * \ingroup hardware - */ -class GR_CORE_API microtune_4937 : public microtune_xxxx { -public: - microtune_4937 (i2c_sptr i2c, int i2c_addr = 0x61); - virtual ~microtune_4937 (); - - /*! - * \brief select RF frequency to be tuned to output frequency. - * \p freq is the requested frequency in Hz, \p actual_freq - * is set to the actual frequency tuned. It takes about 100 ms - * for the PLL to settle. - * - * \returns true iff sucessful. - */ - bool set_RF_freq (double freq, double *actual_freq); - - /*! - * \returns true iff PLL is locked - */ - bool pll_locked_p (); - - /*! - * \returns the output frequency (IF center freq) of the tuner in Hz. - */ - double get_output_freq (); - - private: - - i2c_sptr d_i2c; - int d_i2c_addr; - int d_reference_divider; - bool d_fast_tuning_p; /* if set, higher charge pump current: - faster tuning, worse phase noise - for distance < 10kHz to the carrier */ -}; - -#endif /* INCLUDED_MICROTUNE_4937_H */ diff --git a/gnuradio-core/src/lib/io/microtune_4937_eval_board.cc b/gnuradio-core/src/lib/io/microtune_4937_eval_board.cc deleted file mode 100644 index a25b8addfb..0000000000 --- a/gnuradio-core/src/lib/io/microtune_4937_eval_board.cc +++ /dev/null @@ -1,97 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2001,2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#include "microtune_4937_eval_board.h" -#include "microtune_eval_board_defs.h" -#include "ppio.h" -#include "microtune_4937.h" - -static const int TUNER_I2C_ADDR = 0x61; - -microtune_4937_eval_board::microtune_4937_eval_board (int which_pp) - : microtune_xxxx_eval_board (which_pp) -{ - d_tuner = new microtune_4937 (d_i2c, TUNER_I2C_ADDR); - - // disable upstream amplifier - d_ppio->lock (); - int t = d_ppio->read_data (); - t &= ~(UT_DP_TX_ENABLE | UT_DP_TX_SDA | UT_DP_TX_SCL); - t |= UT_DP_TX_AS; - d_ppio->write_data (t); - d_ppio->unlock (); -} - -microtune_4937_eval_board::~microtune_4937_eval_board () -{ - // Default action is OK -} - - -static const float RF_MIN_V = 1.5; // RF AGC control voltages -static const float RF_MAX_V = 4.0; -static const float IF_MIN_V = 2.0; // IF AGC control voltages -static const float IF_MAX_V = 4.0; - -static const float MIN_AGC = 0; // bottom of synthetic range -static const float MAX_AGC = 1000; // top of synthetic range - -static const float CUTOVER_POINT = 667; - - -// linear is in the range MIN_AGC to MAX_AGC - -static float -linear_to_RF_AGC_voltage (float linear) -{ - if (linear >= CUTOVER_POINT) - return RF_MAX_V; - - float slope = (RF_MAX_V - RF_MIN_V) / CUTOVER_POINT; - return RF_MIN_V + linear * slope; -} - -static float -linear_to_IF_AGC_voltage (float linear) -{ - if (linear < CUTOVER_POINT) - return IF_MIN_V; - - float slope = (IF_MAX_V - IF_MIN_V) / (MAX_AGC - CUTOVER_POINT); - return IF_MIN_V + (linear - CUTOVER_POINT) * slope; -} - -void -microtune_4937_eval_board::set_AGC (float v) -{ - if (v < MIN_AGC) - v = MIN_AGC; - - if (v > MAX_AGC) - v = MAX_AGC; - - float rf_agc_voltage = linear_to_RF_AGC_voltage (v); - float if_agc_voltage = linear_to_IF_AGC_voltage (v); - - set_RF_AGC_voltage (rf_agc_voltage); - set_IF_AGC_voltage (if_agc_voltage); -} diff --git a/gnuradio-core/src/lib/io/microtune_4937_eval_board.h b/gnuradio-core/src/lib/io/microtune_4937_eval_board.h deleted file mode 100644 index 3abd9084ef..0000000000 --- a/gnuradio-core/src/lib/io/microtune_4937_eval_board.h +++ /dev/null @@ -1,50 +0,0 @@ -/* -*- C++ -*- */ -/* - * Copyright 2001,2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_MICROTUNE_4937_EVAL_BOARD_H -#define INCLUDED_MICROTUNE_4937_EVAL_BOARD_H - -#include <gr_core_api.h> -#include "microtune_xxxx_eval_board.h" - -/*! - * \brief control microtune 4937 eval board - * \ingroup hardware - */ - -class GR_CORE_API microtune_4937_eval_board : public microtune_xxxx_eval_board { -public: - microtune_4937_eval_board (int which_pp = 0); - ~microtune_4937_eval_board (); - - /*! - * \brief set RF and IF AGC levels together (scale [0, 1000]) - * - * This provides a simple linear interface for adjusting both - * the RF and IF gain in consort. This is the easy to use interface. - * 0 corresponds to minimum gain. 1000 corresponds to maximum gain. - */ - virtual void set_AGC (float value_0_1000); -}; - - -#endif /* INCLUDED_MICROTUNE_4937_EVAL_BOARD_H */ diff --git a/gnuradio-core/src/lib/io/microtune_4937_eval_board.i b/gnuradio-core/src/lib/io/microtune_4937_eval_board.i deleted file mode 100644 index e261416f78..0000000000 --- a/gnuradio-core/src/lib/io/microtune_4937_eval_board.i +++ /dev/null @@ -1,36 +0,0 @@ -/* -*- C++ -*- */ -/* - * Copyright 2001,2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -class microtune_4937_eval_board : public microtune_xxxx_eval_board { -public: - microtune_4937_eval_board (int which_pp = 0); - ~microtune_4937_eval_board (); - - /*! - * \brief set RF and IF AGC levels together (scale [0, 1000]) - * - * This provides a simple linear interface for adjusting both - * the RF and IF gain in consort. This is the easy to use interface. - * 0 corresponds to minimum gain. 1000 corresponds to maximum gain. - */ - virtual void set_AGC (float value_0_1000); -}; diff --git a/gnuradio-core/src/lib/io/microtune_eval_board.i b/gnuradio-core/src/lib/io/microtune_eval_board.i deleted file mode 100644 index f77ef47b4b..0000000000 --- a/gnuradio-core/src/lib/io/microtune_eval_board.i +++ /dev/null @@ -1,95 +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. - */ - -/* - * SWIG interface defs for Microtune 4937 and eval board with Eric's daughterboard - */ - -/*! - * \brief abstract class for controlling microtune 4937 tuner module - */ -class microtune_4937 { -public: - microtune_4937 (); - - virtual ~microtune_4937 (); - - // returns actual freq or 0 if error (easier interface for SWIG) - double set_RF_freq (double freq); - - /*! - * \returns true iff PLL is locked - */ - bool pll_locked_p (); - - /*! - * \returns the output frequency (IF center freq) of the tuner in Hz. - */ - double get_output_freq (); - - - private: - //! \returns true iff successful - virtual bool i2c_write (int addr, const unsigned char *buf, int nbytes) = 0; - - //! \returns number of bytes read or -1 if error - virtual int i2c_read (int addr, unsigned char *buf, int max_bytes) = 0; - - int d_reference_divider; - bool d_fast_tuning_p; /* if set, higher charge pump current: - faster tuning, worse phase noise - for distance < 10kHz to the carrier */ -}; - -/*! - * \brief concrete class for controlling microtune 4937 eval board attached to parallel port - */ -class microtune_eval_board : public microtune_4937 { -public: - microtune_eval_board (int which_pp = 0); - ~microtune_eval_board (); - - //! is the eval board present? - bool board_present_p (); - - /*! - * \brief set RF and IF AGC control voltages ([0, 5] volts) - */ - void set_RF_AGC_voltage (float volts); - void set_IF_AGC_voltage (float volts); - - /*! - * \brief set RF and IF AGC levels together (scale [0, 1000]) - * - * This provides a simple linear interface for adjusting both - * the RF and IF gain in consort. This is the easy to use interface. - * 0 corresponds to minimum gain. 1000 corresponds to maximum gain. - */ - void set_AGC (float value_0_1000); - -private: - //! \returns true iff successful - virtual bool i2c_write (int addr, const unsigned char *buf, int nbytes); - - //! \returns number of bytes read or -1 if error - virtual int i2c_read (int addr, unsigned char *buf, int max_bytes); -}; diff --git a/gnuradio-core/src/lib/io/microtune_eval_board_defs.h b/gnuradio-core/src/lib/io/microtune_eval_board_defs.h deleted file mode 100644 index 61c52364f3..0000000000 --- a/gnuradio-core/src/lib/io/microtune_eval_board_defs.h +++ /dev/null @@ -1,71 +0,0 @@ -/* -*-C-*- -******************************************************************************* -* -* File: microtune_eval_board_defs.h -* Description: defines for parallel port control of eval board -* -******************************************************************************* -*/ - -/* - * Copyright 2001 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 _MICROTUNE_EVAL_BOARD_DEFS_H_ -#define _MICROTUNE_EVAL_BOARD_DEFS_H_ - -/* - * The Microtune 4937DI5 cable modem tuner eval board is controlled - * by bit banging the PC parallel port. This file defines the relevant - * bits. - * - * The parallel port has an 8 bit data port (output), - * an 8 bit control port (output) and - * an 8 bit status port (input). - * - * Not all bits of the control and status ports may be arbitrarily used. - */ - - -// parallel port data port constants (output) - -static const int UT_DP_TX_SDA = 0x01; // upstream control bus -static const int UT_DP_TX_SCL = 0x02; // upstream control bus -static const int UT_DP_TX_AS = 0x04; // upstream control bus -static const int UT_DP_TX_ENABLE = 0x08; // upstream h/w enable -// bits 4,5,6 not used -static const int UT_DP_TUNER_SDA_OUT = 0x80; // tuner i2c bus data - -// parallel port control port constants (output) - -static const int UT_CP_TUNER_SCL = 0x08; // tuner i2c bus clock -static const int UT_CP_MUST_BE_ZERO = 0xf0; // must be zero - -// parallel port status port constants (input) - -// bits 0,1,2 not used -static const int UT_SP_TUNER_SCL_LOOP_BACK= 0x08; // inverted SCL loop back -static const int UT_SP_SHOULD_BE_ZERO = 0x10; // reads as zero -static const int UT_SP_SHOULD_BE_ONE = 0x20; // reads as one -// bit 6 not used -static const int UT_SP_TUNER_SDA_IN = 0x80; - - -#endif /* _MICROTUNE_EVAL_BOARD_DEFS_H_ */ diff --git a/gnuradio-core/src/lib/io/microtune_xxxx.cc b/gnuradio-core/src/lib/io/microtune_xxxx.cc deleted file mode 100644 index 3d55f534a0..0000000000 --- a/gnuradio-core/src/lib/io/microtune_xxxx.cc +++ /dev/null @@ -1,41 +0,0 @@ -/* -*- c++-*- */ -/* - * Copyright 2001,2003,2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#include "microtune_xxxx.h" - -microtune_xxxx::~microtune_xxxx () -{ - // nop -} - -double -microtune_xxxx::set_RF_freq (double target_freq) -{ - double actual_freq = 0.0; - - if (set_RF_freq (target_freq, &actual_freq)) - return actual_freq; - - return 0.0; -} - - diff --git a/gnuradio-core/src/lib/io/microtune_xxxx.h b/gnuradio-core/src/lib/io/microtune_xxxx.h deleted file mode 100644 index b2646d39f9..0000000000 --- a/gnuradio-core/src/lib/io/microtune_xxxx.h +++ /dev/null @@ -1,66 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2001,2003,2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_MICROTUNE_XXXX_H -#define INCLUDED_MICROTUNE_XXXX_H - -#include <gr_core_api.h> -#include <boost/shared_ptr.hpp> - -class i2c; -typedef boost::shared_ptr<i2c> i2c_sptr; - -/*! - * \brief abstract class for controlling microtune {4937,4702} tuner modules - * \ingroup base - */ -class GR_CORE_API microtune_xxxx { -public: - microtune_xxxx () {} - virtual ~microtune_xxxx (); - - /*! - * \brief select RF frequency to be tuned to output frequency. - * \p freq is the requested frequency in Hz, \p actual_freq - * is set to the actual frequency tuned. It takes about 100 ms - * for the PLL to settle. - * - * \returns true iff sucessful. - */ - virtual bool set_RF_freq (double freq, double *actual_freq) = 0; - - // returns actual freq or 0 if error (easier interface for SWIG) - double set_RF_freq (double freq); - - /*! - * \returns true iff PLL is locked - */ - virtual bool pll_locked_p () = 0; - - /*! - * \returns the output frequency (IF center freq) of the tuner in Hz. - */ - virtual double get_output_freq () = 0; - -}; - -#endif /* INCLUDED_MICROTUNE_XXXX_H */ diff --git a/gnuradio-core/src/lib/io/microtune_xxxx_eval_board.cc b/gnuradio-core/src/lib/io/microtune_xxxx_eval_board.cc deleted file mode 100644 index 35600ff066..0000000000 --- a/gnuradio-core/src/lib/io/microtune_xxxx_eval_board.cc +++ /dev/null @@ -1,144 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2001,2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include "microtune_xxxx_eval_board.h" -#include "microtune_eval_board_defs.h" -#include "microtune_xxxx.h" -#include "ppio.h" -#include "i2c_bitbang.h" -#include "i2c_bbio_pp.h" -#include <cmath> - -static int AGC_DAC_I2C_ADDR = 0x2C; - -microtune_xxxx_eval_board::microtune_xxxx_eval_board (int which_pp) -{ - d_ppio = make_ppio (which_pp); - d_i2c = make_i2c_bitbang (make_i2c_bbio_pp (d_ppio)); - d_tuner = 0; -} - -microtune_xxxx_eval_board::~microtune_xxxx_eval_board () -{ - delete d_tuner; - d_tuner = 0; -} - - -//! is the eval board present? -bool -microtune_xxxx_eval_board::board_present_p () -{ - bool result = true; - d_ppio->lock (); - - int t = d_ppio->read_status (); - if ((t & UT_SP_SHOULD_BE_ZERO) != 0 - || (t & UT_SP_SHOULD_BE_ONE) != UT_SP_SHOULD_BE_ONE) - result = false; - - // could also see if SCL is looped back or not, but that seems like overkill - - d_ppio->unlock (); - return result; -} - -/* - * ---------------------------------------------------------------- - * AGC stuff - * - * We're using a MAX518 8-bit 5V dual dac for setting the AGC's - * ---------------------------------------------------------------- - */ -void -microtune_xxxx_eval_board::write_dac (int which, int value) -{ - unsigned char cmd[2]; - cmd[0] = which & 1; - cmd[1] = value; - d_i2c->write (AGC_DAC_I2C_ADDR, cmd, sizeof (cmd)); -} - -void -microtune_xxxx_eval_board::write_both_dacs (int value0, int value1) -{ - unsigned char cmd[4]; - cmd[0] = 0; - cmd[1] = value0; - cmd[2] = 1; - cmd[3] = value1; - d_i2c->write (AGC_DAC_I2C_ADDR, cmd, sizeof (cmd)); -} - -static int scale_volts (float volts) -{ - int n; - n = (int) rint (volts * (256 / 5.0)); - if (n < 0) - n = 0; - if (n > 255) - n = 255; - - return n; -} - -void -microtune_xxxx_eval_board::set_RF_AGC_voltage (float volts) -{ - write_dac (0, scale_volts (volts)); -} - -void -microtune_xxxx_eval_board::set_IF_AGC_voltage (float volts) -{ - write_dac (1, scale_volts (volts)); -} - -// delegate to tuner - -bool -microtune_xxxx_eval_board::set_RF_freq (double freq, double *actual_freq) -{ - return d_tuner->set_RF_freq (freq, actual_freq); -} - -double -microtune_xxxx_eval_board::set_RF_freq (double freq) -{ - return d_tuner->set_RF_freq (freq); -} - -bool -microtune_xxxx_eval_board::pll_locked_p () -{ - return d_tuner->pll_locked_p (); -} - -double -microtune_xxxx_eval_board::get_output_freq () -{ - return d_tuner->get_output_freq (); -} diff --git a/gnuradio-core/src/lib/io/microtune_xxxx_eval_board.h b/gnuradio-core/src/lib/io/microtune_xxxx_eval_board.h deleted file mode 100644 index 7fd784ade3..0000000000 --- a/gnuradio-core/src/lib/io/microtune_xxxx_eval_board.h +++ /dev/null @@ -1,98 +0,0 @@ -/* -*- C++ -*- */ -/* - * Copyright 2001,2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_MICROTUNE_XXXX_EVAL_BOARD_H -#define INCLUDED_MICROTUNE_XXXX_EVAL_BOARD_H - -#include <gr_core_api.h> -#include <boost/shared_ptr.hpp> - -class microtune_xxxx; - -class ppio; -typedef boost::shared_ptr<ppio> ppio_sptr; - -class i2c; -typedef boost::shared_ptr<i2c> i2c_sptr; - -/*! - * \brief abstract class for controlling microtune xxxx eval board - * \ingroup hardware - */ -class GR_CORE_API microtune_xxxx_eval_board { -public: - microtune_xxxx_eval_board (int which_pp = 0); - virtual ~microtune_xxxx_eval_board (); - - //! is the eval board present? - bool board_present_p (); - - /*! - * \brief set RF and IF AGC control voltages ([0, 5] volts) - */ - void set_RF_AGC_voltage (float volts); - void set_IF_AGC_voltage (float volts); - - /*! - * \brief set RF and IF AGC levels together (scale [0, 1000]) - * - * This provides a simple linear interface for adjusting both - * the RF and IF gain in consort. This is the easy to use interface. - * 0 corresponds to minimum gain. 1000 corresponds to maximum gain. - */ - virtual void set_AGC (float value_0_1000) = 0; - - /*! - * \brief select RF frequency to be tuned to output frequency. - * \p freq is the requested frequency in Hz, \p actual_freq - * is set to the actual frequency tuned. It takes about 100 ms - * for the PLL to settle. - * - * \returns true iff sucessful. - */ - bool set_RF_freq (double freq, double *actual_freq); - - // returns actual freq or 0 if error (easier interface for SWIG) - double set_RF_freq (double freq); - - /*! - * \returns true iff PLL is locked - */ - bool pll_locked_p (); - - /*! - * \returns the output frequency (IF center freq) of the tuner in Hz. - */ - double get_output_freq (); - - -private: - void write_dac (int which, int value); - void write_both_dacs (int val0, int val1); - -protected: - ppio_sptr d_ppio; - i2c_sptr d_i2c; - microtune_xxxx *d_tuner; -}; - -#endif /* INCLUDED_MICROTUNE_XXXX_EVAL_BOARD_H */ diff --git a/gnuradio-core/src/lib/io/microtune_xxxx_eval_board.i b/gnuradio-core/src/lib/io/microtune_xxxx_eval_board.i deleted file mode 100644 index 8a8a597427..0000000000 --- a/gnuradio-core/src/lib/io/microtune_xxxx_eval_board.i +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -class microtune_xxxx_eval_board { -public: - microtune_xxxx_eval_board (int which_pp = 0); - virtual ~microtune_xxxx_eval_board (); - - //! is the eval board present? - bool board_present_p (); - - /*! - * \brief set RF and IF AGC control voltages ([0, 5] volts) - */ - void set_RF_AGC_voltage (float volts); - void set_IF_AGC_voltage (float volts); - - /*! - * \brief set RF and IF AGC levels together (scale [0, 1000]) - * - * This provides a simple linear interface for adjusting both - * the RF and IF gain in consort. This is the easy to use interface. - * 0 corresponds to minimum gain. 1000 corresponds to maximum gain. - */ - virtual void set_AGC (float value_0_1000) = 0; - - // returns actual freq or 0 if error (easier interface for SWIG) - double set_RF_freq (double freq); - - /*! - * \returns true iff PLL is locked - */ - bool pll_locked_p (); - - /*! - * \returns the output frequency (IF center freq) of the tuner in Hz. - */ - double get_output_freq (); -}; diff --git a/gnuradio-core/src/lib/io/ppio.cc b/gnuradio-core/src/lib/io/ppio.cc deleted file mode 100644 index a5edc539ca..0000000000 --- a/gnuradio-core/src/lib/io/ppio.cc +++ /dev/null @@ -1,39 +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. - */ - -#include <ppio.h> -#include <ppio_ppdev.h> - -ppio::~ppio () -{ -} - -// Factory method. -// -// Right now, we've only got one subclass we like. If there were more, -// we'd instantiate the "right one" here. - -ppio_sptr -make_ppio (int which_pp) -{ - return make_ppio_ppdev (which_pp); -} diff --git a/gnuradio-core/src/lib/io/ppio.h b/gnuradio-core/src/lib/io/ppio.h deleted file mode 100644 index d99f7bf79a..0000000000 --- a/gnuradio-core/src/lib/io/ppio.h +++ /dev/null @@ -1,63 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2001,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. - */ - -#ifndef INCLUDED_PPIO_H -#define INCLUDED_PPIO_H - -#include <gr_core_api.h> -#include <boost/shared_ptr.hpp> - -class ppio; -typedef boost::shared_ptr<ppio> ppio_sptr; - - -/*! - * \brief abstract class that provides low level access to parallel port bits - * \ingroup hardware - */ - -class GR_CORE_API ppio { - public: - ppio () {} - virtual ~ppio (); - - virtual void write_data (unsigned char v) = 0; - virtual unsigned char read_data () = 0; - virtual void write_control (unsigned char v) = 0; - virtual unsigned char read_control () = 0; - virtual unsigned char read_status () = 0; - - virtual void lock () = 0; - virtual void unlock () = 0; -}; - -/*! - * \brief Factory method. - * - * Split out from class to make life easier for SWIG - */ - -GR_CORE_API ppio_sptr make_ppio (int which_pp); - - -#endif /* INCLUDED_PPIO_H */ - diff --git a/gnuradio-core/src/lib/io/ppio.i b/gnuradio-core/src/lib/io/ppio.i deleted file mode 100644 index 6b95dcf888..0000000000 --- a/gnuradio-core/src/lib/io/ppio.i +++ /dev/null @@ -1,48 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -class ppio; -typedef boost::shared_ptr<ppio> ppio_sptr; - -%template(ppio_sptr) boost::shared_ptr<ppio>; - -/*! - * \brief abstract class that provides low level access to parallel port bits - */ - -class ppio { - public: - ppio () {} - virtual ~ppio (); - - virtual void write_data (unsigned char v) = 0; - virtual unsigned char read_data () = 0; - virtual void write_control (unsigned char v) = 0; - virtual unsigned char read_control () = 0; - virtual unsigned char read_status () = 0; - - virtual void lock () = 0; - virtual void unlock () = 0; -}; - - -ppio_sptr make_ppio (int which_pp); diff --git a/gnuradio-core/src/lib/io/ppio_ppdev.cc b/gnuradio-core/src/lib/io/ppio_ppdev.cc deleted file mode 100644 index f528459585..0000000000 --- a/gnuradio-core/src/lib/io/ppio_ppdev.cc +++ /dev/null @@ -1,321 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2001,2003,2004,2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <ppio_ppdev.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <stdlib.h> -#include <iostream> -#include <errno.h> -#include <stdio.h> -#include <stdexcept> -#if defined(HAVE_LINUX_PPDEV_H) -#include <sys/ioctl.h> -#include <linux/ppdev.h> -#include <linux/parport.h> -#include <sstream> -#elif defined(HAVE_DEV_PPBUS_PPI_H) -#include <sys/ioctl.h> -#include <dev/ppbus/ppi.h> -#include <dev/ppbus/ppbconf.h> -#include <sstream> -#else -// #warn "ppio_ppdev is not functional on this platform" -#endif - -// These control port bits are active low. -// We toggle them so that this weirdness doesn't get get propagated -// through our interface. - -static int CP_ACTIVE_LOW_BITS = 0x0B; - -// These status port bits are active low. -// We toggle them so that this weirdness doesn't get get propagated -// through our interface. - -static int SP_ACTIVE_LOW_BITS = 0x80; - -#if defined(HAVE_LINUX_PPDEV_H) - -// The real Linux code... - -ppio_ppdev::ppio_ppdev (int which) -{ - std::ostringstream filename; - filename << "/dev/parport" << which; - const char *c_filename = filename.str().c_str(); - - if ((d_fd = open (c_filename, O_RDWR)) < 0){ - int my_errno = errno; - perror (c_filename); - if (my_errno == ENOENT){ - std::cerr << "Does the device file " << c_filename << " exist?\n"; - std::cerr << "If not, as root execute: \n"; - std::cerr << " # mknod " << c_filename << " c 99 0\n"; - std::cerr << " # chmod 666 " << c_filename << std::endl; - } - throw std::runtime_error ("open"); - } - - int mode = IEEE1284_MODE_COMPAT; - if (ioctl (d_fd, PPSETMODE, &mode) != 0){ - perror ("ppio_ppdev: PPSETMODE"); - close (d_fd); - throw std::runtime_error ("PPSETMODE"); - } -} - -ppio_ppdev::~ppio_ppdev () -{ - close (d_fd); -} - - -void -ppio_ppdev::write_data (unsigned char v) -{ - if (ioctl (d_fd, PPWDATA, &v) != 0){ - perror ("ppio_ppdev: PPWDATA"); - throw std::runtime_error ("PPWDATA"); - } -} - -unsigned char -ppio_ppdev::read_data () -{ - unsigned char v; - - if (ioctl (d_fd, PPRDATA, &v) != 0){ - perror ("ppio_ppdev: PPRDATA"); - throw std::runtime_error ("PPRDATA"); - } - return v; -} - -void -ppio_ppdev::write_control (unsigned char v) -{ - unsigned char ctrl = v ^ CP_ACTIVE_LOW_BITS; - if (ioctl (d_fd, PPWCONTROL, &ctrl) != 0){ - perror ("ppio_ppdev: PPWCONTROL"); - throw std::runtime_error ("PPWCONTROL"); - } -} - -unsigned char -ppio_ppdev::read_control () -{ - unsigned char ctrl; - if (ioctl (d_fd, PPRCONTROL, &ctrl) != 0){ - perror ("ppio_ppdev: PPRCONTROL"); - throw std::runtime_error ("PPRCONTROL"); - } - - return ctrl ^ CP_ACTIVE_LOW_BITS; -} - -unsigned char -ppio_ppdev::read_status () -{ - unsigned char status; - if (ioctl (d_fd, PPRSTATUS, &status) != 0){ - perror ("ppio_ppdev: PPRSTATUS"); - throw std::runtime_error ("PPRSTATUS"); - } - - return status ^ SP_ACTIVE_LOW_BITS; -} - -void -ppio_ppdev::lock () -{ - if (ioctl (d_fd, PPCLAIM) != 0){ - perror ("ppio_ppdev: PPCLAIM"); - throw std::runtime_error ("PPCLAIM"); - } -} - -void -ppio_ppdev::unlock () -{ - if (ioctl (d_fd, PPRELEASE) != 0){ - perror ("ppio_ppdev: PPRELEASE"); - throw std::runtime_error ("PPRELEASE"); - } -} - -#elif defined(HAVE_DEV_PPBUS_PPI_H) - -// The real FreeBSD code... (Could work on other BSDs as well) - -ppio_ppdev::ppio_ppdev (int which) -{ - std::ostringstream filename; - filename << "/dev/ppi" << which; - const char *c_filename = filename.str().c_str(); - if ((d_fd = open (c_filename, O_RDWR)) < 0){ - int my_errno = errno; - perror (c_filename); - throw std::runtime_error ("open"); - } - -#if 0 - int mode = IEEE1284_MODE_COMPAT; - if (ioctl (d_fd, PPSETMODE, &mode) != 0){ - perror ("ppio_ppdev: PPSETMODE"); - close (d_fd); - throw std::runtime_error ("PPSETMODE"); - } -#endif -} - -ppio_ppdev::~ppio_ppdev () -{ - close (d_fd); -} - - -void -ppio_ppdev::write_data (unsigned char v) -{ - if (ioctl (d_fd, PPISDATA, &v) != 0){ - perror ("ppio_ppdev: PPISDATA"); - throw std::runtime_error ("PPISDATA"); - } -} - -unsigned char -ppio_ppdev::read_data () -{ - unsigned char v; - - if (ioctl (d_fd, PPIGDATA, &v) != 0){ - perror ("ppio_ppdev: PPIGDATA"); - throw std::runtime_error ("PPIGDATA"); - } - return v; -} - -void -ppio_ppdev::write_control (unsigned char v) -{ - unsigned char ctrl = v ^ CP_ACTIVE_LOW_BITS; - if (ioctl (d_fd, PPISCTRL, &ctrl) != 0){ - perror ("ppio_ppdev: PPISCTRL"); - throw std::runtime_error ("PPISCTRL"); - } -} - -unsigned char -ppio_ppdev::read_control () -{ - unsigned char ctrl; - if (ioctl (d_fd, PPIGCTRL, &ctrl) != 0){ - perror ("ppio_ppdev: PPIGCTRL"); - throw std::runtime_error ("PPIGCTRL"); - } - - return ctrl ^ CP_ACTIVE_LOW_BITS; -} - -unsigned char -ppio_ppdev::read_status () -{ - unsigned char status; - if (ioctl (d_fd, PPIGSTATUS, &status) != 0){ - perror ("ppio_ppdev: PPIGSTATUS"); - throw std::runtime_error ("PPIGSTATUS"); - } - return status ^ SP_ACTIVE_LOW_BITS; -} - -void -ppio_ppdev::lock () -{ -} - -void -ppio_ppdev::unlock () -{ -} -#else -/* Apparently, non real code */ - -ppio_ppdev::ppio_ppdev (int which) -{ - std::cerr << "ppio_ppdev: Not implemented on this platform\n"; - throw std::runtime_error ("not implmeneted"); -} - -ppio_ppdev::~ppio_ppdev () -{ -} - -void -ppio_ppdev::write_data (unsigned char v) -{ -} - -unsigned char -ppio_ppdev::read_data () -{ - return 0; -} - -void -ppio_ppdev::write_control (unsigned char v) -{ -} - -unsigned char -ppio_ppdev::read_control () -{ - return 0; -} - -unsigned char -ppio_ppdev::read_status () -{ - return 0; -} - -void -ppio_ppdev::lock () -{ -} - -void -ppio_ppdev::unlock () -{ -} - -#endif - -ppio_ppdev_sptr -make_ppio_ppdev (int which) -{ - return ppio_ppdev_sptr (new ppio_ppdev (which)); -} diff --git a/gnuradio-core/src/lib/io/ppio_ppdev.h b/gnuradio-core/src/lib/io/ppio_ppdev.h deleted file mode 100644 index 1f86d7e047..0000000000 --- a/gnuradio-core/src/lib/io/ppio_ppdev.h +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2001,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. - */ - -#ifndef INCLUDED_PPIO_PPDEV_H -#define INCLUDED_PPIO_PPDEV_H - -#include <gr_core_api.h> -#include <ppio.h> - -class ppio_ppdev; -typedef boost::shared_ptr<ppio_ppdev> ppio_ppdev_sptr; - -/*! - * \brief access to parallel port bits using the linux ppdev interface - * \ingroup hardware - */ - -class GR_CORE_API ppio_ppdev : public ppio { - friend GR_CORE_API ppio_ppdev_sptr make_ppio_ppdev (int which = 0); - ppio_ppdev (int which = 0); - - public: - virtual ~ppio_ppdev (); - - virtual void write_data (unsigned char v); - virtual unsigned char read_data (); - virtual void write_control (unsigned char v); - virtual unsigned char read_control (); - virtual unsigned char read_status (); - - virtual void lock (); - virtual void unlock (); - - private: - int d_fd; -}; - -ppio_ppdev_sptr -make_ppio_ppdev (int which); - - -#endif /* INCLUDED_PPIO_PPDEV_H */ - diff --git a/gnuradio-core/src/lib/io/sdr_1000.cc b/gnuradio-core/src/lib/io/sdr_1000.cc deleted file mode 100644 index a8c2555e0e..0000000000 --- a/gnuradio-core/src/lib/io/sdr_1000.cc +++ /dev/null @@ -1,65 +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. - */ - -#include <sdr_1000.h> -#include <ppio.h> - -sdr_1000_base::sdr_1000_base (int which_pp) -{ - d_ppio = make_ppio (which_pp); - d_shadow[0] = 0; - d_shadow[1] = 0; - d_shadow[2] = 0; - d_shadow[3] = 0; - reset (); -} - -sdr_1000_base::~sdr_1000_base () -{ -} - -void -sdr_1000_base::reset () -{ - d_ppio->lock (); - d_ppio->write_control (0x0F); - d_ppio->unlock (); - write_latch (L_EXT, 0x00, 0xff); - write_latch (L_BAND, 0x00, 0xff); - write_latch (L_DDS0, 0x80, 0xff); // hold DDS in reset - write_latch (L_DDS1, 0x00, 0xff); -} - - -void -sdr_1000_base::write_latch (int which, int value, int mask) -{ - if (!(0 <= which && which <= 3)) - return; - - d_ppio->lock (); - d_shadow[which] = (d_shadow[which] & ~mask) | (value & mask); - d_ppio->write_data (d_shadow[which]); - d_ppio->write_control (0x0F ^ (1 << which)); - d_ppio->write_control (0x0F); - d_ppio->unlock (); -} diff --git a/gnuradio-core/src/lib/runtime/CMakeLists.txt b/gnuradio-core/src/lib/runtime/CMakeLists.txt index a322d1b998..f3982f53cd 100644 --- a/gnuradio-core/src/lib/runtime/CMakeLists.txt +++ b/gnuradio-core/src/lib/runtime/CMakeLists.txt @@ -110,17 +110,9 @@ endif(ENABLE_GR_CTRLPORT) # Append gnuradio-core test sources ######################################################################## list(APPEND test_gnuradio_core_sources - ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_block.cc - ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_hier_block2.cc - ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_hier_block2_derived.cc ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_buffer.cc - ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_flowgraph.cc - ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_top_block.cc ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_io_signature.cc ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_vmcircbuf.cc - ${CMAKE_CURRENT_SOURCE_DIR}/qa_block_tags.cc - ${CMAKE_CURRENT_SOURCE_DIR}/qa_runtime.cc - ${CMAKE_CURRENT_SOURCE_DIR}/qa_set_msg_handler.cc ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_logger.cc ) diff --git a/gnuradio-core/src/lib/runtime/gr_basic_block.h b/gnuradio-core/src/lib/runtime/gr_basic_block.h index 31081698c7..66fb72d87e 100644 --- a/gnuradio-core/src/lib/runtime/gr_basic_block.h +++ b/gnuradio-core/src/lib/runtime/gr_basic_block.h @@ -301,9 +301,9 @@ class GR_CORE_API gr_basic_block : public gr_msg_accepter, public boost::enable_ * void msg_handler(pmt::pmt msg); * </pre> * - * (You may want to use boost::bind to massage your callable into the - * correct form. See gr_nop.{h,cc} for an example that sets up a class - * method as the callback.) + * (You may want to use boost::bind to massage your callable into + * the correct form. See gr::blocks::nop for an example that sets + * up a class method as the callback.) * * Blocks that desire to handle messages must call this method in their * constructors to register the handler that will be invoked when messages diff --git a/gnuradio-core/src/lib/runtime/gr_top_block.h b/gnuradio-core/src/lib/runtime/gr_top_block.h index 694e9575b4..9634b53f3c 100644 --- a/gnuradio-core/src/lib/runtime/gr_top_block.h +++ b/gnuradio-core/src/lib/runtime/gr_top_block.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2007,2008,2009 Free Software Foundation, Inc. + * Copyright 2007-2009 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -83,7 +83,7 @@ public: /*! * Wait for a flowgraph to complete. Flowgraphs complete when * either (1) all blocks indicate that they are done (typically only - * when using blocks.file_source, or gr.head, or (2) after stop() has been + * when using blocks.file_source, or blocks.head, or (2) after stop() has been * called to request shutdown. Calling wait on a top_block that is * not running IS NOT an error (wait returns w/o blocking). */ diff --git a/gnuradio-core/src/lib/runtime/qa_runtime.cc b/gnuradio-core/src/lib/runtime/qa_runtime.cc index 62c95ef5c4..f02fbd7d66 100644 --- a/gnuradio-core/src/lib/runtime/qa_runtime.cc +++ b/gnuradio-core/src/lib/runtime/qa_runtime.cc @@ -32,14 +32,8 @@ #include <qa_runtime.h> #include <qa_gr_vmcircbuf.h> #include <qa_gr_io_signature.h> -#include <qa_gr_block.h> -#include <qa_gr_flowgraph.h> #include <qa_gr_logger.h> -#include <qa_gr_top_block.h> -#include <qa_gr_hier_block2.h> -#include <qa_gr_hier_block2_derived.h> #include <qa_gr_buffer.h> -#include <qa_block_tags.h> #include <qa_set_msg_handler.h> CppUnit::TestSuite * diff --git a/gnuradio-core/src/lib/runtime/test_shared_block_ptr.cc b/gnuradio-core/src/lib/runtime/test_shared_block_ptr.cc index bb4e863222..0a391c1354 100644 --- a/gnuradio-core/src/lib/runtime/test_shared_block_ptr.cc +++ b/gnuradio-core/src/lib/runtime/test_shared_block_ptr.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004 Free Software Foundation, Inc. + * Copyright 2004,2013 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -21,16 +21,16 @@ */ #include <gr_shared_block_sptr.h> -#include <gr_vector_source_i.h> +#include <blocks/vector_source_i.h> gr_block_sptr -foo (gr_vector_source_i_sptr s) +foo (gr::blocks::vector_source_i::sptr s) { return gr_block_sptr (s); } -typedef gr_shared_block_sptr<gr_vector_source_i> gr_vector_source_i_ptrX; -//typedef boost::shared_ptr<gr_vector_source_i> gr_vector_source_i_ptrX; +typedef gr_shared_block_sptr<gr::blocks::vector_source_i> gr_vector_source_i_ptrX; +//typedef boost::shared_ptr<gr::blocks::vector_source_i> gr_vector_source_i_ptrX; gr_vector_source_i_ptrX bar (gr_vector_source_i *s) diff --git a/gnuradio-core/src/lib/swig/CMakeLists.txt b/gnuradio-core/src/lib/swig/CMakeLists.txt index 2132e2ca09..f098597df0 100644 --- a/gnuradio-core/src/lib/swig/CMakeLists.txt +++ b/gnuradio-core/src/lib/swig/CMakeLists.txt @@ -58,9 +58,9 @@ link_directories(${Boost_LIBRARY_DIRS}) # ---------------------------------------------------------------- set(GR_SWIG_TARGET_DEPS gnuradio_core_generated_sources - general_generated gengen_generated filter_generated pmt_swig) + general_generated filter_generated pmt_swig) -foreach(what runtime general gengen io) +foreach(what runtime general) SET(GR_SWIG_DOC_FILE ${CMAKE_CURRENT_BINARY_DIR}/${what}_swig_doc.i) SET(GR_SWIG_DOC_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../${what} ${CMAKE_CURRENT_BINARY_DIR}/../${what}) GR_SWIG_MAKE(gnuradio_core_${what} gnuradio_core_${what}.i) diff --git a/gnuradio-core/src/lib/swig/gnuradio_core.py b/gnuradio-core/src/lib/swig/gnuradio_core.py index 1fd558a11b..09d00fcdc1 100644 --- a/gnuradio-core/src/lib/swig/gnuradio_core.py +++ b/gnuradio-core/src/lib/swig/gnuradio_core.py @@ -22,5 +22,3 @@ from gnuradio_core_runtime import * from gnuradio_core_general import * -from gnuradio_core_gengen import * -from gnuradio_core_io import * diff --git a/gnuradio-core/src/lib/swig/gnuradio_core_gengen.i b/gnuradio-core/src/lib/swig/gnuradio_core_gengen.i deleted file mode 100644 index b90a5bab3e..0000000000 --- a/gnuradio-core/src/lib/swig/gnuradio_core_gengen.i +++ /dev/null @@ -1,32 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2009,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 this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -%include "gengen_swig_doc.i" - -#ifndef SWIGIMPORTED -%module(directors="1") gnuradio_core_gengen -#endif - - //%feature("autodoc", "1"); // generate python docstrings - -%include "gnuradio.i" // the common stuff - -%include "gengen.i" diff --git a/gnuradio-core/src/lib/swig/gnuradio_core_io.i b/gnuradio-core/src/lib/swig/gnuradio_core_io.i deleted file mode 100644 index 522b12b347..0000000000 --- a/gnuradio-core/src/lib/swig/gnuradio_core_io.i +++ /dev/null @@ -1,32 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2009,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 this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -%include "io_swig_doc.i" - -#ifndef SWIGIMPORTED -%module(directors="1") gnuradio_core_io -#endif - - //%feature("autodoc", "1"); // generate python docstrings - -%include "gnuradio.i" // the common stuff - -%include "io.i" diff --git a/gnuradio-core/src/python/bin/microtune.py b/gnuradio-core/src/python/bin/microtune.py deleted file mode 100755 index fbe743f396..0000000000 --- a/gnuradio-core/src/python/bin/microtune.py +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/env python -# -*- Python -*- - -from gnuradio import gr -from gnuradio.eng_option import eng_option -from gnuradio.wxgui import stdgui, fftsink -from optparse import OptionParser -from gnuradio import eng_notation - - -def main (): - parser = OptionParser (option_class=eng_option) - parser.add_option ("-g", "--gain", type="eng_float", default=-1, - help="set front end gain to GAIN [0,1000]") - parser.add_option ("-f", "--freq", type="eng_float", default=-1, - help="set front end center frequency to FREQ") - parser.add_option ("-t", "--type", type="string", default="4937", - help="select eval board type {4937 or 4702}") - parser.add_option ("-p", "--port", type="int", default=0, - help="parallel port eval board is attached to") - (options, args) = parser.parse_args () - - if options.type == "4937": - front_end = gr.microtune_4937_eval_board (options.port) - elif options.type == "4702": - front_end = gr.microtune_4702_eval_board (options.port) - else: - raise RuntimeError, "Invalid board type. Must be either -t 4937 or -t 4702" - - if options.gain != -1: - front_end.set_AGC (options.gain) - - if options.freq != -1: - if options.freq < 1e6: - options.freq = options.freq * 1e6 - - actual = front_end.set_RF_freq (options.freq) - print "microtune: actual freq = %s" % (eng_notation.num_to_str (actual),) - - -if __name__ == '__main__': - main () diff --git a/gnuradio-core/src/python/gnuradio/ctrlport/GrDataPlotter.py b/gnuradio-core/src/python/gnuradio/ctrlport/GrDataPlotter.py index dfa67feffe..8597ca6497 100644 --- a/gnuradio-core/src/python/gnuradio/ctrlport/GrDataPlotter.py +++ b/gnuradio-core/src/python/gnuradio/ctrlport/GrDataPlotter.py @@ -206,7 +206,7 @@ class GrDataPlotterC(GrDataPlotParent): return snk def get_vecsource(self): - return gr.vector_source_c([]) + return blocks.vector_source_c([]) def get_npts(self): self._npts = self.snk.nsamps() @@ -237,7 +237,7 @@ class GrDataPlotterF(GrDataPlotParent): return snk def get_vecsource(self): - return gr.vector_source_f([]) + return blocks.vector_source_f([]) def get_npts(self): self._npts = self.snk.nsamps() @@ -265,7 +265,7 @@ class GrDataPlotterConst(GrDataPlotParent): return snk def get_vecsource(self): - return gr.vector_source_c([]) + return blocks.vector_source_c([]) def get_npts(self): self._npts = self.snk.nsamps() @@ -304,7 +304,7 @@ class GrDataPlotterPsdC(GrDataPlotParent): return snk def get_vecsource(self): - return gr.vector_source_c([]) + return blocks.vector_source_c([]) def get_npts(self): self._npts = self.snk.fft_size() @@ -337,7 +337,7 @@ class GrDataPlotterPsdF(GrDataPlotParent): return snk def get_vecsource(self): - return gr.vector_source_f([]) + return blocks.vector_source_f([]) def get_npts(self): self._npts = self.snk.fft_size() @@ -367,7 +367,7 @@ class GrTimeRasterF(GrDataPlotParent): return snk def get_vecsource(self): - return gr.vector_source_f([]) + return blocks.vector_source_f([]) def get_npts(self): self._npts = self.snk.num_cols() @@ -396,7 +396,7 @@ class GrTimeRasterB(GrDataPlotParent): return snk def get_vecsource(self): - return gr.vector_source_b([]) + return blocks.vector_source_b([]) def get_npts(self): self._npts = self.snk.num_cols() diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_kludge_copy.py b/gnuradio-core/src/python/gnuradio/gr/qa_kludge_copy.py deleted file mode 100755 index 2a3aa44b1b..0000000000 --- a/gnuradio-core/src/python/gnuradio/gr/qa_kludge_copy.py +++ /dev/null @@ -1,91 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2006,2010 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -from gnuradio import gr, gr_unittest -import math -import random - - -class test_kludge_copy(gr_unittest.TestCase): - - def setUp(self): - self.tb = gr.top_block() - self.rng = random.Random() - self.rng.seed(0) - - def tearDown(self): - del self.tb - del self.rng - - def make_random_int_tuple(self, L): - result = [] - for x in range(L): - result.append(self.rng.randint(int(-1e9), int(+1e9))) - return tuple(result) - - - def test_001(self): - # 1 input stream; 1 output stream - src0_data = self.make_random_int_tuple(16000) - src0 = gr.vector_source_i(src0_data) - op = gr.kludge_copy(gr.sizeof_int) - dst0 = gr.vector_sink_i() - self.tb.connect(src0, op, dst0) - self.tb.run() - dst0_data = dst0.data() - self.assertEqual(src0_data, dst0_data) - - def test_002(self): - # 2 input streams; 2 output streams - src0_data = self.make_random_int_tuple(16000) - src1_data = self.make_random_int_tuple(16000) - src0 = gr.vector_source_i(src0_data) - src1 = gr.vector_source_i(src1_data) - op = gr.kludge_copy(gr.sizeof_int) - dst0 = gr.vector_sink_i() - dst1 = gr.vector_sink_i() - self.tb.connect(src0, (op, 0), dst0) - self.tb.connect(src1, (op, 1), dst1) - self.tb.run() - dst0_data = dst0.data() - dst1_data = dst1.data() - self.assertEqual(src0_data, dst0_data) - self.assertEqual(src1_data, dst1_data) - - # Note: this is disabled due to triggering bug in ticket:181 - # It only occurs with new top block code - def xtest_003(self): - # number of input streams != number of output streams - src0_data = self.make_random_int_tuple(16000) - src1_data = self.make_random_int_tuple(16000) - src0 = gr.vector_source_i(src0_data) - src1 = gr.vector_source_i(src1_data) - op = gr.kludge_copy(gr.sizeof_int) - dst0 = gr.vector_sink_i() - dst1 = gr.vector_sink_i() - self.tb.connect(src0, (op, 0), dst0) - self.tb.connect(src1, (op, 1)) - self.assertRaises(ValueError, self.tb.run) - -if __name__ == '__main__': - gr_unittest.run(test_kludge_copy, "test_kludge_copy.xml") - diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_skiphead.py b/gnuradio-core/src/python/gnuradio/gr/qa_skiphead.py deleted file mode 100755 index 1e730398c7..0000000000 --- a/gnuradio-core/src/python/gnuradio/gr/qa_skiphead.py +++ /dev/null @@ -1,102 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2007,2010 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -from gnuradio import gr, gr_unittest - -class test_skiphead (gr_unittest.TestCase): - - def setUp(self): - self.tb = gr.top_block () - self.src_data = [int(x) for x in range(65536)] - - def tearDown(self): - self.tb = None - - def test_skip_0(self): - skip_cnt = 0 - expected_result = tuple(self.src_data[skip_cnt:]) - src1 = gr.vector_source_i (self.src_data) - op = gr.skiphead (gr.sizeof_int, skip_cnt) - dst1 = gr.vector_sink_i () - self.tb.connect (src1, op, dst1) - self.tb.run () - dst_data = dst1.data () - self.assertEqual (expected_result, dst_data) - - def test_skip_1(self): - skip_cnt = 1 - expected_result = tuple(self.src_data[skip_cnt:]) - src1 = gr.vector_source_i (self.src_data) - op = gr.skiphead (gr.sizeof_int, skip_cnt) - dst1 = gr.vector_sink_i () - self.tb.connect (src1, op, dst1) - self.tb.run () - dst_data = dst1.data () - self.assertEqual (expected_result, dst_data) - - def test_skip_1023(self): - skip_cnt = 1023 - expected_result = tuple(self.src_data[skip_cnt:]) - src1 = gr.vector_source_i (self.src_data) - op = gr.skiphead (gr.sizeof_int, skip_cnt) - dst1 = gr.vector_sink_i () - self.tb.connect (src1, op, dst1) - self.tb.run () - dst_data = dst1.data () - self.assertEqual (expected_result, dst_data) - - def test_skip_6339(self): - skip_cnt = 6339 - expected_result = tuple(self.src_data[skip_cnt:]) - src1 = gr.vector_source_i (self.src_data) - op = gr.skiphead (gr.sizeof_int, skip_cnt) - dst1 = gr.vector_sink_i () - self.tb.connect (src1, op, dst1) - self.tb.run () - dst_data = dst1.data () - self.assertEqual (expected_result, dst_data) - - def test_skip_12678(self): - skip_cnt = 12678 - expected_result = tuple(self.src_data[skip_cnt:]) - src1 = gr.vector_source_i (self.src_data) - op = gr.skiphead (gr.sizeof_int, skip_cnt) - dst1 = gr.vector_sink_i () - self.tb.connect (src1, op, dst1) - self.tb.run () - dst_data = dst1.data () - self.assertEqual (expected_result, dst_data) - - def test_skip_all(self): - skip_cnt = len(self.src_data) - expected_result = tuple(self.src_data[skip_cnt:]) - src1 = gr.vector_source_i (self.src_data) - op = gr.skiphead (gr.sizeof_int, skip_cnt) - dst1 = gr.vector_sink_i () - self.tb.connect (src1, op, dst1) - self.tb.run () - dst_data = dst1.data () - self.assertEqual (expected_result, dst_data) - - -if __name__ == '__main__': - gr_unittest.run(test_skiphead, "test_skiphead.xml") diff --git a/gnuradio-core/src/python/gnuradio/gruimpl/CMakeLists.txt b/gnuradio-core/src/python/gnuradio/gruimpl/CMakeLists.txt index 7d48f35121..d77da24073 100644 --- a/gnuradio-core/src/python/gnuradio/gruimpl/CMakeLists.txt +++ b/gnuradio-core/src/python/gnuradio/gruimpl/CMakeLists.txt @@ -26,10 +26,8 @@ GR_PYTHON_INSTALL(FILES hexint.py listmisc.py mathmisc.py - lmx2306.py msgq_runner.py os_read_exactly.py - sdr_1000.py seq_with_cursor.py socket_stuff.py daemon.py diff --git a/gnuradio-core/src/python/gnuradio/gruimpl/lmx2306.py b/gnuradio-core/src/python/gnuradio/gruimpl/lmx2306.py deleted file mode 100755 index aa4efc3e9c..0000000000 --- a/gnuradio-core/src/python/gnuradio/gruimpl/lmx2306.py +++ /dev/null @@ -1,186 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2004 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -'''Control National LMX2306 based frequency synthesizer''' - -from gnuradio import gr -from gnuradio import eng_notation -from gnuradio.eng_option import eng_option -from optparse import OptionParser - -# bottom two bits of 21 bit word select which register to program - -R_REG = 0x0 -AB_REG = 0x1 -F_REG = 0x2 - -F_counter_reset = (1 << 2) -F_phase_detector_polarity = (1 << 7) - -F_LD_tri_state = (0 << 4) -F_LD_R_divider_output = (4 << 4) -F_LD_N_divider_output = (2 << 4) -F_LD_serial_data_output = (6 << 4) -F_LD_digital_lock_detect = (1 << 4) -F_LD_open_drain = (5 << 4) -F_LD_high = (3 << 4) -F_LD_low = (7 << 4) - -# F_default = F_LD_digital_lock_detect | F_phase_detector_polarity -F_default = F_LD_open_drain | F_phase_detector_polarity - -# -# 4 control pins: -# CE always high -# LE load enable. When LE goes high, data stored in the shift register -# is loaded into one of the three registers -# CLK data is clocked in on the rising edge -# DATA single data bit. Entered MSB first - -DB_CLK = (1 << 0) -DB_DATA = (1 << 1) -DB_LE = (1 << 2) -DB_CE = (1 << 3) - -class lmx2306 (object): - '''Control the National LMX2306 PLL''' - __slots__ = ['pp', 'shadow', 'fosc', 'r', 'step_size', 'verbose'] - def __init__ (self, fosc, step_size, which_pp = 0): - '''FOSC is the frequency of the reference oscillator, - STEP_SIZE is the step between valid frequencies, - WHICH_PP specifies which parallel port to use - ''' - self.pp = gr.make_ppio (which_pp) - self.shadow = DB_CE - self.pp.lock () - self.pp.write_data (self.shadow) - self.pp.unlock () - self.verbose = False - self._set_fosc (fosc) - self._set_step (step_size) - - - def program (self, r, a, b): - if self.verbose: - print "lmx2306: r = %d a = %d b = %d" % (r, a, b) - self.pp.lock () - self._write_word (F_REG | F_default | F_counter_reset) - self._write_word (R_REG | ((r & 0x3fff) << 2)) - self._write_word (AB_REG | ((a & 0x1f) << 2) | ((b & 0x1fff) << 7)) - self._write_word (F_REG | F_default) - self.pp.unlock () - - def set_freq (self, freq): - '''Set the PLL frequency to FREQ - - Return the actual freq value set. It will be rounded down to a - multiple of step_size - ''' - divisor = int (freq / self.step_size) - actual = divisor * self.step_size - (a, b) = self._compute_ab (divisor) - self.program (self.r, a, b) - return actual - - # ---------------------------------------------------------------- - - def _set_fosc (self, ref_oscillator_freq): - self.fosc = ref_oscillator_freq - - def _set_step (self, step_size): - r = int (self.fosc / step_size) - if r * step_size != self.fosc: - raise ValueError, "step_size is not a factor of self.fosc" - if r < 3 or r > 16383: - raise ValueError, "r is out of range" - self.r = r - self.step_size = step_size - - def _compute_ab (self, divisor): - b = divisor / 8 - a = divisor - (b * 8) - if b < 3 or b > 8191 or a > b: - raise ValueError, "Invalid divisor" - return (a, b) - - def _write_word (self, w): - for i in range(21): - if w & (1 << 20): - self._set_DATA_1 () - else: - self._set_DATA_0 () - w = (w << 1) & 0x0ffffff - self._set_CLK_1 () - self._set_CLK_0 () - self._set_LE_1 () - self._set_LE_0 () - - def _set_LE_0 (self): - self.shadow = self.shadow & ~DB_LE - self.pp.write_data (self.shadow) - - def _set_LE_1 (self): - self.shadow = self.shadow | DB_LE - self.pp.write_data (self.shadow) - - def _set_CLK_0 (self): - self.shadow = self.shadow & ~DB_CLK - self.pp.write_data (self.shadow) - - def _set_CLK_1 (self): - self.shadow = self.shadow | DB_CLK - self.pp.write_data (self.shadow) - - def _set_DATA_0 (self): - self.shadow = self.shadow & ~DB_DATA - self.pp.write_data (self.shadow) - - def _set_DATA_1 (self): - self.shadow = self.shadow | DB_DATA - self.pp.write_data (self.shadow) - -if __name__ == '__main__': - parser = OptionParser (option_class=eng_option) - parser.add_option ("-o", "--fosc", type="eng_float", default=32e6, - help="set reference oscillator freq to FREQ", metavar="FREQ") - parser.add_option ("-s", "--step-size", type="eng_float", default=10e3, - help="set the frequency step size to STEP_SIZE") - parser.add_option ("-f", "--freq", type="eng_float", default=430e6, - help="set VCO frequency to FREQ") - parser.add_option ("-v", "--verbose", action="store_true", default=False) - (options, args) = parser.parse_args () - - if options.verbose: - print "fosc = %s step = %s fvco = %s" % ( - eng_notation.num_to_str (options.fosc), - eng_notation.num_to_str (options.step_size), - eng_notation.num_to_str (options.freq)) - - lmx = lmx2306 (options.fosc, options.step_size) - lmx.verbose = options.verbose - - actual = lmx.set_freq (options.freq) - - if options.verbose: - print "fvco_actual = %s delta = %s" % ( - eng_notation.num_to_str (actual), - eng_notation.num_to_str (options.freq - actual)) diff --git a/gnuradio-core/src/python/gnuradio/gruimpl/sdr_1000.py b/gnuradio-core/src/python/gnuradio/gruimpl/sdr_1000.py deleted file mode 100644 index 5192a71554..0000000000 --- a/gnuradio-core/src/python/gnuradio/gruimpl/sdr_1000.py +++ /dev/null @@ -1,84 +0,0 @@ -# -# Copyright 2003,2004 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -from gnuradio import gr - -class sdr_1000 (gr.sdr_1000_base): - "Control the DDS on the SDR-1000" - def __init__(self, pport = 0): - gr.sdr_1000_base.__init__(self, pport) - self.write_latch (3, 0x00, 0xC0) # Reset low, WRS/ low - self.write_reg (0x20, 0x40) - - def write_reg(self, addr, data): - self.write_latch (3, addr & 0x3f, 0x3f) - self.write_latch (2, data, 0xff) - self.write_latch (3, 0x40, 0x40) - self.write_latch (3, 0x00, 0x40) - - def set_freq(self, freq): - self.set_band (freq) - ftw = freq / 200e6; - for i in xrange(6): - word = int(ftw * 256) - ftw = ftw*256 - word - # print (('%d [%02x]') % (i, word)) - self.write_reg (4+i, word) - - def set_band (self, freq): - if freq <= 2.25e6: - band = 0 - elif freq <= 5.5e6: - band = 1 - elif freq <= 11e6: - band = 3 # due to wiring mistake on board - elif freq <= 22e6: - band = 2 # due to wiring mistake on board - elif freq <= 37.5e6: - band = 4 - else: - band = 5 - - self.write_latch (1, 1 << band, 0x3f) - - def set_bit (self, reg, bit, state): - val = 0x00 - if state: val = 1<<bit - self.write_latch (reg, val, 1<<bit) - - def set_tx (self, on = 1): - self.set_bit(1, 6, on) - - def set_rx (self): - self.set_bit(1, 6, 0) - - def set_gain (self, high): - self.set_bit(0, 7, high) - - def set_mute (self, mute = 1): - self.set_bit(1, 7, mute) - - def set_unmute (self): - self.set_bit(1, 7, 0) - - def set_external_pin (self, pin, on = 1): - assert (pin < 8 and pin > 0), "Out of range 1..7" - self.set_bit(0, pin-1, on) diff --git a/gnuradio-core/src/tests/CMakeLists.txt b/gnuradio-core/src/tests/CMakeLists.txt index ef58cf9ef5..7723680dd9 100644 --- a/gnuradio-core/src/tests/CMakeLists.txt +++ b/gnuradio-core/src/tests/CMakeLists.txt @@ -43,7 +43,8 @@ link_directories(${LOG4CPP_LIBRARY_DIRS}) # Build benchmarks and non-registered tests ######################################################################## set(tests_not_run #single source per test - test_runtime.cc + benchmark_nco.cc + benchmark_vco.cc test_general.cc test_vmcircbuf.cc ) diff --git a/gnuradio-core/src/tests/benchmark_nco.cc b/gnuradio-core/src/tests/benchmark_nco.cc new file mode 100644 index 0000000000..20d53e410f --- /dev/null +++ b/gnuradio-core/src/tests/benchmark_nco.cc @@ -0,0 +1,220 @@ +/* -*- c++ -*- */ +/* + * Copyright 2002,2004 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif +#include <stdio.h> +#include <sys/time.h> +#ifdef HAVE_SYS_RESOURCE_H +#include <sys/resource.h> +#endif +#include <unistd.h> +#include <gr_nco.h> +#include <gr_fxpt_nco.h> +#include <string.h> + +#define ITERATIONS 20000000 +#define BLOCK_SIZE (10 * 1000) // fits in cache + +#define FREQ 5003.123 + +static double +timeval_to_double (const struct timeval *tv) +{ + return (double) tv->tv_sec + (double) tv->tv_usec * 1e-6; +} + + +static void +benchmark (void test (float *x, float *y), const char *implementation_name) +{ +#ifdef HAVE_SYS_RESOURCE_H + struct rusage rusage_start; + struct rusage rusage_stop; +#else + double clock_start; + double clock_end; +#endif + float output[2*BLOCK_SIZE]; + float *x = &output[0], *y = &output[BLOCK_SIZE]; + + // touch memory + memset(output, 0, 2*BLOCK_SIZE*sizeof(float)); + + // get starting CPU usage +#ifdef HAVE_SYS_RESOURCE_H + if (getrusage (RUSAGE_SELF, &rusage_start) < 0){ + perror ("getrusage"); + exit (1); + } +#else + clock_start = (double) clock() * (1000000. / CLOCKS_PER_SEC); +#endif + // do the actual work + + test (x, y); + + // get ending CPU usage + +#ifdef HAVE_SYS_RESOURCE_H + if (getrusage (RUSAGE_SELF, &rusage_stop) < 0){ + perror ("getrusage"); + exit (1); + } + + // compute results + + double user = + timeval_to_double (&rusage_stop.ru_utime) + - timeval_to_double (&rusage_start.ru_utime); + + double sys = + timeval_to_double (&rusage_stop.ru_stime) + - timeval_to_double (&rusage_start.ru_stime); + + double total = user + sys; +#else + clock_end = (double) clock () * (1000000. / CLOCKS_PER_SEC); + double total = clock_end - clock_start; +#endif + + printf ("%18s: cpu: %6.3f steps/sec: %10.3e\n", + implementation_name, total, ITERATIONS / total); +} + +// ---------------------------------------------------------------- +// Don't compare the _vec with other functions since memory store's +// are involved. + +void basic_sincos_vec (float *x, float *y) +{ + gr_nco<float,float> nco; + + nco.set_freq (2 * M_PI / FREQ); + + for (int i = 0; i < ITERATIONS/BLOCK_SIZE; i++){ + for (int j = 0; j < BLOCK_SIZE; j++){ + nco.sincos (&x[2*j+1], &x[2*j]); + nco.step (); + } + } +} + +void native_sincos_vec (float *x, float *y) +{ + gr_nco<float,float> nco; + + nco.set_freq (2 * M_PI / FREQ); + + for (int i = 0; i < ITERATIONS/BLOCK_SIZE; i++){ + nco.sincos ((gr_complex*)x, BLOCK_SIZE); + } +} + +void fxpt_sincos_vec (float *x, float *y) +{ + gr_fxpt_nco nco; + + nco.set_freq (2 * M_PI / FREQ); + + for (int i = 0; i < ITERATIONS/BLOCK_SIZE; i++){ + nco.sincos ((gr_complex*)x, BLOCK_SIZE); + } +} + +// ---------------------------------------------------------------- + +void native_sincos (float *x, float *y) +{ + gr_nco<float,float> nco; + + nco.set_freq (2 * M_PI / FREQ); + + for (int i = 0; i < ITERATIONS; i++){ + nco.sincos (x, y); + nco.step (); + } +} + +void fxpt_sincos (float *x, float *y) +{ + gr_fxpt_nco nco; + + nco.set_freq (2 * M_PI / FREQ); + + for (int i = 0; i < ITERATIONS; i++){ + nco.sincos (x, y); + nco.step (); + } +} + +// ---------------------------------------------------------------- + +void native_sin (float *x, float *y) +{ + gr_nco<float,float> nco; + + nco.set_freq (2 * M_PI / FREQ); + + for (int i = 0; i < ITERATIONS; i++){ + *x = nco.sin (); + nco.step (); + } +} + +void fxpt_sin (float *x, float *y) +{ + gr_fxpt_nco nco; + + nco.set_freq (2 * M_PI / FREQ); + + for (int i = 0; i < ITERATIONS; i++){ + *x = nco.sin (); + nco.step (); + } +} + +// ---------------------------------------------------------------- + +void nop_fct (float *x, float *y) +{ +} + +void nop_loop (float *x, float *y) +{ + for (int i = 0; i < ITERATIONS; i++){ + nop_fct (x, y); + } +} + +int +main (int argc, char **argv) +{ + benchmark (nop_loop, "nop loop"); + benchmark (native_sin, "native sine"); + benchmark (fxpt_sin, "fxpt sine"); + benchmark (native_sincos, "native sin/cos"); + benchmark (fxpt_sincos, "fxpt sin/cos"); + benchmark (basic_sincos_vec, "basic sin/cos vec"); + benchmark (native_sincos_vec, "native sin/cos vec"); + benchmark (fxpt_sincos_vec, "fxpt sin/cos vec"); +} diff --git a/gnuradio-core/src/tests/benchmark_vco.cc b/gnuradio-core/src/tests/benchmark_vco.cc new file mode 100644 index 0000000000..3a6ade78c9 --- /dev/null +++ b/gnuradio-core/src/tests/benchmark_vco.cc @@ -0,0 +1,167 @@ +/* -*- c++ -*- */ +/* + * Copyright 2002,2004,2005 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 <stdio.h> +#include <sys/time.h> +#ifdef HAVE_SYS_RESOURCE_H +#include <sys/resource.h> +#endif +#include <unistd.h> +#include <gr_vco.h> +#include <gr_fxpt_vco.h> +#include <string.h> + +#define ITERATIONS 5000000 +#define BLOCK_SIZE (10 * 1000) // fits in cache + +#define FREQ 5003.123 +#define K 4.9999999 +#define AMPLITUDE 2.444444444 + + +static double +timeval_to_double (const struct timeval *tv) +{ + return (double) tv->tv_sec + (double) tv->tv_usec * 1e-6; +} + + +static void +benchmark (void test (float *x, const float *y), const char *implementation_name) +{ +#ifdef HAVE_SYS_RESOURCE_H + struct rusage rusage_start; + struct rusage rusage_stop; +#else + double clock_start; + double clock_end; +#endif + float output[BLOCK_SIZE]; + float input[BLOCK_SIZE]; + + // touch memory + memset(output, 0, BLOCK_SIZE*sizeof(float)); + for (int i = 0; i<BLOCK_SIZE; i++) + input[i] = sin(double(i)); + + // get starting CPU usage +#ifdef HAVE_SYS_RESOURCE_H + if (getrusage (RUSAGE_SELF, &rusage_start) < 0){ + perror ("getrusage"); + exit (1); + } +#else + clock_start = (double) clock() * (1000000. / CLOCKS_PER_SEC); +#endif + // do the actual work + + test (output, input); + + // get ending CPU usage + +#ifdef HAVE_SYS_RESOURCE_H + if (getrusage (RUSAGE_SELF, &rusage_stop) < 0){ + perror ("getrusage"); + exit (1); + } + + // compute results + + double user = + timeval_to_double (&rusage_stop.ru_utime) + - timeval_to_double (&rusage_start.ru_utime); + + double sys = + timeval_to_double (&rusage_stop.ru_stime) + - timeval_to_double (&rusage_start.ru_stime); + + double total = user + sys; +#else + clock_end = (double) clock () * (1000000. / CLOCKS_PER_SEC); + double total = clock_end - clock_start; +#endif + + printf ("%18s: cpu: %6.3f steps/sec: %10.3e\n", + implementation_name, total, ITERATIONS / total); +} + +// ---------------------------------------------------------------- + +void basic_vco (float *output, const float *input) +{ + double phase = 0; + + for (int j = 0; j < ITERATIONS/BLOCK_SIZE; j++){ + for (int i = 0; i < BLOCK_SIZE; i++){ + output[i] = cos(phase) * AMPLITUDE; + phase += input[i] * K; + + while (phase > 2 * M_PI) + phase -= 2 * M_PI; + + while (phase < -2 * M_PI) + phase += 2 * M_PI; + } + } +} + +void native_vco (float *output, const float *input) +{ + gr_vco<float,float> vco; + + for (int j = 0; j < ITERATIONS/BLOCK_SIZE; j++){ + vco.cos(output, input, BLOCK_SIZE, K, AMPLITUDE); + } + } + +void fxpt_vco (float *output, const float *input) +{ + gr_fxpt_vco vco; + + for (int j = 0; j < ITERATIONS/BLOCK_SIZE; j++){ + vco.cos(output, input, BLOCK_SIZE, K, AMPLITUDE); + } +} + +// ---------------------------------------------------------------- + +void nop_fct (float *x, const float *y) +{ +} + +void nop_loop (float *x, const float *y) +{ + for (int i = 0; i < ITERATIONS; i++){ + nop_fct (x, y); + } +} + +int +main (int argc, char **argv) +{ + benchmark (nop_loop, "nop loop"); + benchmark (basic_vco, "basic vco"); + benchmark (native_vco, "native vco"); + benchmark (fxpt_vco, "fxpt vco"); +} diff --git a/gnuradio-core/src/tests/nco_results b/gnuradio-core/src/tests/nco_results new file mode 100644 index 0000000000..5bdf5dd1cb --- /dev/null +++ b/gnuradio-core/src/tests/nco_results @@ -0,0 +1,48 @@ +================================================================ +These are on a 1.4 GHz Pentium M using g++ 3.4.1 +================================================================ + +Default compiler options -O2 + + nop loop: cpu: 0.015 steps/sec: 6.668e+08 + native sine: cpu: 0.900 steps/sec: 1.111e+07 + fxpt sine: cpu: 0.281 steps/sec: 3.559e+07 + native sin/cos: cpu: 1.138 steps/sec: 8.789e+06 + fxpt sin/cos: cpu: 0.550 steps/sec: 1.818e+07 + +-O2 -march=pentium-m -fomit-frame-pointer + + nop loop: cpu: 0.015 steps/sec: 6.668e+08 + native sine: cpu: 0.903 steps/sec: 1.108e+07 + fxpt sine: cpu: 0.271 steps/sec: 3.691e+07 + native sin/cos: cpu: 1.092 steps/sec: 9.159e+06 + fxpt sin/cos: cpu: 0.542 steps/sec: 1.845e+07 + +Inlined fxpt::sin & cos +-O2 -march=pentium-m -fomit-frame-pointer + + nop loop: cpu: 0.015 steps/sec: 6.668e+08 + native sine: cpu: 0.904 steps/sec: 1.106e+07 + fxpt sine: cpu: 0.187 steps/sec: 5.348e+07 + native sin/cos: cpu: 1.091 steps/sec: 9.167e+06 + fxpt sin/cos: cpu: 0.373 steps/sec: 2.681e+07 + +================================================================ +These are on a 1.5 GHz Athon MP 1800+ +================================================================ + +Default compiler options: -O2 + + nop loop: cpu: 0.013 steps/sec: 7.693e+08 + native sine: cpu: 0.733 steps/sec: 1.364e+07 + fxpt sine: cpu: 0.210 steps/sec: 4.763e+07 + native sin/cos: cpu: 1.183 steps/sec: 8.454e+06 + fxpt sin/cos: cpu: 0.420 steps/sec: 2.381e+07 + +-O2 -fomit-frame-pointer -march=athlon-mp + + nop loop: cpu: 0.013 steps/sec: 7.693e+08 + native sine: cpu: 0.679 steps/sec: 1.473e+07 + fxpt sine: cpu: 0.200 steps/sec: 5.001e+07 + native sin/cos: cpu: 1.147 steps/sec: 8.720e+06 + fxpt sin/cos: cpu: 0.444 steps/sec: 2.253e+07 diff --git a/gnuradio-core/src/tests/test_all.cc b/gnuradio-core/src/tests/test_all.cc index fb45cbf8f4..f1fbce4e05 100644 --- a/gnuradio-core/src/tests/test_all.cc +++ b/gnuradio-core/src/tests/test_all.cc @@ -24,7 +24,6 @@ #include <cppunit/XmlOutputter.h> #include <gr_unittests.h> -#include <qa_runtime.h> #include <qa_general.h> // FIXME add atsc back in. @@ -36,7 +35,6 @@ main (int argc, char **argv) std::ofstream xmlfile(get_unittest_path("gnuradio_core_all.xml").c_str()); CppUnit::XmlOutputter *xmlout = new CppUnit::XmlOutputter(&runner.result(), xmlfile); - runner.addTest (qa_runtime::suite ()); runner.addTest (qa_general::suite ()); runner.setOutputter(xmlout); diff --git a/gnuradio-core/src/tests/test_buffers.py b/gnuradio-core/src/tests/test_buffers.py index 2664c136c6..e0abb8b304 100755 --- a/gnuradio-core/src/tests/test_buffers.py +++ b/gnuradio-core/src/tests/test_buffers.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2006 Free Software Foundation, Inc. +# Copyright 2006,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -22,6 +22,7 @@ from gnuradio import gr, gru from gnuradio import audio +from gnuradio import blocks from gnuradio.eng_option import eng_option from optparse import OptionParser @@ -68,7 +69,7 @@ class my_graph(gr.top_block): nsamples=int(sample_rate * seconds) #1 seconds data = sig_source_f(sample_rate, 350, ampl, nsamples) - src0 = gr.vector_source_f(data) + src0 = blocks.vector_source_f(data) # gr.test (const std::string &name=std::string("gr_test"), # int min_inputs=1, int max_inputs=1, unsigned int sizeof_input_item=1, diff --git a/gnuradio-core/src/tests/test_runtime.cc b/gnuradio-core/src/tests/test_runtime.cc deleted file mode 100644 index bd5378332e..0000000000 --- a/gnuradio-core/src/tests/test_runtime.cc +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002,2010,2011 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#include <cppunit/TextTestRunner.h> -#include <cppunit/XmlOutputter.h> - -#include <gr_unittests.h> -#include <qa_runtime.h> - -int -main (int argc, char **argv) -{ - CppUnit::TextTestRunner runner; - std::ofstream xmlfile(get_unittest_path("gnuradio_core_runtime.xml").c_str()); - CppUnit::XmlOutputter *xmlout = new CppUnit::XmlOutputter(&runner.result(), xmlfile); - - runner.addTest (qa_runtime::suite ()); - runner.setOutputter(xmlout); - - bool was_successful = runner.run ("", false); - - return was_successful ? 0 : 1; -} diff --git a/gr-analog/CMakeLists.txt b/gr-analog/CMakeLists.txt index afcbe42d61..8186de0fa9 100644 --- a/gr-analog/CMakeLists.txt +++ b/gr-analog/CMakeLists.txt @@ -32,7 +32,6 @@ GR_REGISTER_COMPONENT("gr-analog" ENABLE_GR_ANALOG ENABLE_GR_CORE ENABLE_GR_FFT ENABLE_GR_FILTER - ENABLE_GR_BLOCKS ) GR_SET_GLOBAL(GR_ANALOG_INCLUDE_DIRS diff --git a/gr-analog/examples/fmtest.py b/gr-analog/examples/fmtest.py index 294fa0d425..327da8eacb 100755 --- a/gr-analog/examples/fmtest.py +++ b/gr-analog/examples/fmtest.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2009,2012 Free Software Foundation, Inc. +# Copyright 2009,2012,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -24,6 +24,7 @@ from gnuradio import gr from gnuradio import blocks from gnuradio import filter from gnuradio import analog +from gnuradio import channels import sys, math, time try: @@ -84,9 +85,9 @@ class fmtest(gr.top_block): self.connect(sig, fm) self.connect(fm, (self.sum, n)) - self.head = gr.head(gr.sizeof_gr_complex, self._nsamples) - self.snk_tx = gr.vector_sink_c() - self.channel = filter.channel_model(0.1) + self.head = blocks.head(gr.sizeof_gr_complex, self._nsamples) + self.snk_tx = blocks.vector_sink_c() + self.channel = channels.channel_model(0.1) self.connect(self.sum, self.head, self.channel, self.snk_tx) @@ -116,7 +117,7 @@ class fmtest(gr.top_block): for i in xrange(self._M): self.fmdet.append(analog.nbfm_rx(self._audio_rate, self._chan_rate)) self.squelch.append(analog.standard_squelch(self._audio_rate*10)) - self.snks.append(gr.vector_sink_f()) + self.snks.append(blocks.vector_sink_f()) self.connect((self.pfb, i), self.fmdet[i], self.squelch[i], self.snks[i]) def num_tx_channels(self): diff --git a/gr-analog/examples/tags/uhd_burst_detector.py b/gr-analog/examples/tags/uhd_burst_detector.py index c0a8d955c2..b1bb15b974 100755 --- a/gr-analog/examples/tags/uhd_burst_detector.py +++ b/gr-analog/examples/tags/uhd_burst_detector.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2012 Free Software Foundation, Inc. +# Copyright 2012,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -55,7 +55,7 @@ class uhd_burst_detector(gr.top_block): # Dummy signaler to collect a burst on known periods data = 1000*[0,] + 1000*[1,] - self.signal = gr.vector_source_s(data, True) + self.signal = blocks.vector_source_s(data, True) # Energy detector to get signal burst ## use squelch to detect energy diff --git a/grc/blocks/blks2_am_demod_cf.xml b/gr-analog/grc/analog_am_demod_cf.xml index 898c613beb..b066882bda 100644 --- a/grc/blocks/blks2_am_demod_cf.xml +++ b/gr-analog/grc/analog_am_demod_cf.xml @@ -6,9 +6,9 @@ --> <block> <name>AM Demod</name> - <key>blks2_am_demod_cf</key> - <import>from gnuradio import blks2</import> - <make>blks2.am_demod_cf( + <key>analog_am_demod_cf</key> + <import>from gnuradio import analog</import> + <make>analog.am_demod_cf( channel_rate=$chan_rate, audio_decim=$audio_decim, audio_pass=$audio_pass, diff --git a/gr-analog/grc/analog_block_tree.xml b/gr-analog/grc/analog_block_tree.xml index 1c4e46c914..fdb6db27ac 100644 --- a/gr-analog/grc/analog_block_tree.xml +++ b/gr-analog/grc/analog_block_tree.xml @@ -46,6 +46,15 @@ <block>analog_frequency_modulator_fc</block> <block>analog_phase_modulator_fc</block> <block>analog_quadrature_demod_cf</block> + <block>analog_nbfm_tx</block> + <block>analog_nbfm_rx</block> + <block>analog_wfm_tx</block> + <block>analog_wfm_rcv</block> + <block>analog_wfm_rcv_pll</block> + <block>analog_am_demod_cf</block> + <block>analog_fm_demod_cf</block> + <block>analog_fm_deemph</block> + <block>analog_fm_preemph</block> </cat> <cat> <name>Sources</name> diff --git a/grc/blocks/blks2_fm_deemph.xml b/gr-analog/grc/analog_fm_deemph.xml index 6f38dab6d0..0fcb5a87d4 100644 --- a/grc/blocks/blks2_fm_deemph.xml +++ b/gr-analog/grc/analog_fm_deemph.xml @@ -6,9 +6,9 @@ --> <block> <name>FM Deemphasis</name> - <key>blks2_fm_deemph</key> - <import>from gnuradio import blks2</import> - <make>blks2.fm_deemph(fs=$samp_rate, tau=$tau)</make> + <key>analog_fm_deemph</key> + <import>from gnuradio import analog</import> + <make>analog.fm_deemph(fs=$samp_rate, tau=$tau)</make> <param> <name>Sample Rate</name> <key>samp_rate</key> diff --git a/grc/blocks/blks2_fm_demod_cf.xml b/gr-analog/grc/analog_fm_demod_cf.xml index 2ce1fb9732..c903ddfc73 100644 --- a/grc/blocks/blks2_fm_demod_cf.xml +++ b/gr-analog/grc/analog_fm_demod_cf.xml @@ -6,9 +6,9 @@ --> <block> <name>FM Demod</name> - <key>blks2_fm_demod_cf</key> - <import>from gnuradio import blks2</import> - <make>blks2.fm_demod_cf( + <key>analog_fm_demod_cf</key> + <import>from gnuradio import analog</import> + <make>analog.fm_demod_cf( channel_rate=$chan_rate, audio_decim=$audio_decim, deviation=$deviation, diff --git a/grc/blocks/blks2_fm_preemph.xml b/gr-analog/grc/analog_fm_preemph.xml index 672a7a7b28..fb898b87f3 100644 --- a/grc/blocks/blks2_fm_preemph.xml +++ b/gr-analog/grc/analog_fm_preemph.xml @@ -6,9 +6,9 @@ --> <block> <name>FM Preemphasis</name> - <key>blks2_fm_preemph</key> - <import>from gnuradio import blks2</import> - <make>blks2.fm_preemph(fs=$samp_rate, tau=$tau)</make> + <key>analog_fm_preemph</key> + <import>from gnuradio import analog</import> + <make>analog.fm_preemph(fs=$samp_rate, tau=$tau)</make> <param> <name>Sample Rate</name> <key>samp_rate</key> diff --git a/grc/blocks/blks2_nbfm_rx.xml b/gr-analog/grc/analog_nbfm_rx.xml index d332b9a6b0..cc690c7b6b 100644 --- a/grc/blocks/blks2_nbfm_rx.xml +++ b/gr-analog/grc/analog_nbfm_rx.xml @@ -6,9 +6,9 @@ --> <block> <name>NBFM Receive</name> - <key>blks2_nbfm_rx</key> - <import>from gnuradio import blks2</import> - <make>blks2.nbfm_rx( + <key>analog_nbfm_rx</key> + <import>from gnuradio import analog</import> + <make>analog.nbfm_rx( audio_rate=$audio_rate, quad_rate=$quad_rate, tau=$tau, diff --git a/grc/blocks/blks2_nbfm_tx.xml b/gr-analog/grc/analog_nbfm_tx.xml index 3aa7ede0e2..b3d3451cf7 100644 --- a/grc/blocks/blks2_nbfm_tx.xml +++ b/gr-analog/grc/analog_nbfm_tx.xml @@ -6,9 +6,9 @@ --> <block> <name>NBFM Transmit</name> - <key>blks2_nbfm_tx</key> - <import>from gnuradio import blks2</import> - <make>blks2.nbfm_tx( + <key>analog_nbfm_tx</key> + <import>from gnuradio import analog</import> + <make>analog.nbfm_tx( audio_rate=$audio_rate, quad_rate=$quad_rate, tau=$tau, diff --git a/grc/blocks/blks2_wfm_rcv.xml b/gr-analog/grc/analog_wfm_rcv.xml index 37fb3ba8c4..ce2abb92de 100644 --- a/grc/blocks/blks2_wfm_rcv.xml +++ b/gr-analog/grc/analog_wfm_rcv.xml @@ -6,9 +6,9 @@ --> <block> <name>WBFM Receive</name> - <key>blks2_wfm_rcv</key> - <import>from gnuradio import blks2</import> - <make>blks2.wfm_rcv( + <key>analog_wfm_rcv</key> + <import>from gnuradio import analog</import> + <make>analog.wfm_rcv( quad_rate=$quad_rate, audio_decimation=$audio_decimation, )</make> diff --git a/grc/blocks/blks2_wfm_rcv_pll.xml b/gr-analog/grc/analog_wfm_rcv_pll.xml index 2771350cfd..db31ed9bee 100644 --- a/grc/blocks/blks2_wfm_rcv_pll.xml +++ b/gr-analog/grc/analog_wfm_rcv_pll.xml @@ -6,9 +6,9 @@ --> <block> <name>WBFM Receive PLL</name> - <key>blks2_wfm_rcv_pll</key> - <import>from gnuradio import blks2</import> - <make>blks2.wfm_rcv_pll( + <key>analog_wfm_rcv_pll</key> + <import>from gnuradio import analog</import> + <make>analog.wfm_rcv_pll( demod_rate=$quad_rate, audio_decimation=$audio_decimation, )</make> diff --git a/grc/blocks/blks2_wfm_tx.xml b/gr-analog/grc/analog_wfm_tx.xml index cff92d8190..0e00f05fb2 100644 --- a/grc/blocks/blks2_wfm_tx.xml +++ b/gr-analog/grc/analog_wfm_tx.xml @@ -6,9 +6,9 @@ --> <block> <name>WBFM Transmit</name> - <key>blks2_wfm_tx</key> - <import>from gnuradio import blks2</import> - <make>blks2.wfm_tx( + <key>analog_wfm_tx</key> + <import>from gnuradio import analog</import> + <make>analog.wfm_tx( audio_rate=$audio_rate, quad_rate=$quad_rate, tau=$tau, diff --git a/gr-analog/include/analog/pll_carriertracking_cc.h b/gr-analog/include/analog/pll_carriertracking_cc.h index 3596429d49..0812d650f0 100644 --- a/gr-analog/include/analog/pll_carriertracking_cc.h +++ b/gr-analog/include/analog/pll_carriertracking_cc.h @@ -24,6 +24,7 @@ #define INCLUDED_ANALOG_PLL_CARRIERTRACKING_CC_H #include <analog/api.h> +#include <blocks/control_loop.h> #include <gr_sync_block.h> namespace gr { @@ -45,7 +46,9 @@ namespace gr { * and should be set around pi/200 -- 2pi/100. \sa * pll_freqdet_cf, pll_carriertracking_cc */ - class ANALOG_API pll_carriertracking_cc : virtual public gr_sync_block + class ANALOG_API pll_carriertracking_cc + : virtual public gr_sync_block, + virtual public blocks::control_loop { public: // gr::analog::pll_carriertracking_cc::sptr diff --git a/gr-analog/include/analog/pll_freqdet_cf.h b/gr-analog/include/analog/pll_freqdet_cf.h index 613e85263f..8ffbc5968e 100644 --- a/gr-analog/include/analog/pll_freqdet_cf.h +++ b/gr-analog/include/analog/pll_freqdet_cf.h @@ -24,6 +24,7 @@ #define INCLUDED_ANALOG_PLL_FREQDET_CF_H #include <analog/api.h> +#include <blocks/control_loop.h> #include <gr_sync_block.h> namespace gr { @@ -44,7 +45,9 @@ namespace gr { * around pi/200 -- 2pi/100. * \sa pll_refout_cc, pll_carriertracking_cc */ - class ANALOG_API pll_freqdet_cf : virtual public gr_sync_block + class ANALOG_API pll_freqdet_cf + : virtual public gr_sync_block, + virtual public blocks::control_loop { public: // gr::analog::pll_freqdet_cf::sptr diff --git a/gr-analog/include/analog/pll_refout_cc.h b/gr-analog/include/analog/pll_refout_cc.h index a18d177e6e..1ba907262e 100644 --- a/gr-analog/include/analog/pll_refout_cc.h +++ b/gr-analog/include/analog/pll_refout_cc.h @@ -24,6 +24,7 @@ #define INCLUDED_ANALOG_PLL_REFOUT_CC_H #include <analog/api.h> +#include <blocks/control_loop.h> #include <gr_sync_block.h> namespace gr { @@ -45,7 +46,9 @@ namespace gr { * and should be set around pi/200 -- 2pi/100. \sa * pll_freqdet_cf, pll_carriertracking_cc */ - class ANALOG_API pll_refout_cc : virtual public gr_sync_block + class ANALOG_API pll_refout_cc + : virtual public gr_sync_block, + virtual public blocks::control_loop { public: // gr::analog::pll_refout_cc::sptr diff --git a/gr-analog/lib/CMakeLists.txt b/gr-analog/lib/CMakeLists.txt index 53cbb00a51..48fbb71b2f 100644 --- a/gr-analog/lib/CMakeLists.txt +++ b/gr-analog/lib/CMakeLists.txt @@ -140,7 +140,6 @@ list(APPEND analog_sources quadrature_demod_cf_impl.cc rail_ff_impl.cc simple_squelch_cc_impl.cc - sincos.cc ) #Add Windows DLL resource file if using MSVC @@ -162,7 +161,6 @@ list(APPEND analog_libs volk gnuradio-core gnuradio-filter - gnuradio-blocks ${Boost_LIBRARIES} ) @@ -184,7 +182,6 @@ if(ENABLE_TESTING) list(APPEND test_gr_analog_sources ${CMAKE_CURRENT_SOURCE_DIR}/test_gr_analog.cc ${CMAKE_CURRENT_SOURCE_DIR}/qa_analog.cc - ${CMAKE_CURRENT_SOURCE_DIR}/qa_sincos.cc ) add_executable(test-gr-analog ${test_gr_analog_sources}) @@ -201,11 +198,3 @@ if(ENABLE_TESTING) GR_ADD_TEST(test_gr_analog test-gr-analog) endif(ENABLE_TESTING) - -CHECK_CXX_SOURCE_COMPILES(" - #define _GNU_SOURCE - #include <math.h> - int main(){double x, sin, cos; sincos(x, &sin, &cos); return 0;} - " HAVE_SINCOS -) -GR_ADD_COND_DEF(HAVE_SINCOS) diff --git a/gr-analog/lib/frequency_modulator_fc_impl.cc b/gr-analog/lib/frequency_modulator_fc_impl.cc index ae8c95d02f..2da7ee15f1 100644 --- a/gr-analog/lib/frequency_modulator_fc_impl.cc +++ b/gr-analog/lib/frequency_modulator_fc_impl.cc @@ -26,7 +26,7 @@ #include "frequency_modulator_fc_impl.h" #include <gr_io_signature.h> -#include <blocks/fxpt.h> +#include <gr_fxpt.h> #include <math.h> #include <boost/math/special_functions/trunc.hpp> @@ -70,8 +70,8 @@ namespace gr { float oi, oq; - int32_t angle = gr::blocks::fxpt::float_to_fixed (d_phase); - gr::blocks::fxpt::sincos(angle, &oq, &oi); + gr_int32 angle = gr_fxpt::float_to_fixed (d_phase); + gr_fxpt::sincos(angle, &oq, &oi); out[i] = gr_complex(oi, oq); } diff --git a/gr-analog/lib/pll_carriertracking_cc_impl.h b/gr-analog/lib/pll_carriertracking_cc_impl.h index 54de4442d1..c809736709 100644 --- a/gr-analog/lib/pll_carriertracking_cc_impl.h +++ b/gr-analog/lib/pll_carriertracking_cc_impl.h @@ -24,13 +24,11 @@ #define INCLUDED_ANALOG_PLL_CARRIERTRACKING_CC_IMPL_H #include <analog/pll_carriertracking_cc.h> -#include <blocks/control_loop.h> namespace gr { namespace analog { - class pll_carriertracking_cc_impl - : public pll_carriertracking_cc, public blocks::control_loop + class pll_carriertracking_cc_impl : public pll_carriertracking_cc { private: float d_locksig,d_lock_threshold; diff --git a/gr-analog/lib/pll_freqdet_cf_impl.h b/gr-analog/lib/pll_freqdet_cf_impl.h index 10bcdc2157..3170d819b6 100644 --- a/gr-analog/lib/pll_freqdet_cf_impl.h +++ b/gr-analog/lib/pll_freqdet_cf_impl.h @@ -24,13 +24,11 @@ #define INCLUDED_ANALOG_PLL_FREQDET_CF_IMPL_H #include <analog/pll_freqdet_cf.h> -#include <blocks/control_loop.h> namespace gr { namespace analog { - class pll_freqdet_cf_impl : - public pll_freqdet_cf, public blocks::control_loop + class pll_freqdet_cf_impl : public pll_freqdet_cf { private: float phase_detector(gr_complex sample,float ref_phase); diff --git a/gr-analog/lib/pll_refout_cc_impl.h b/gr-analog/lib/pll_refout_cc_impl.h index f8572f9b64..1734b6e138 100644 --- a/gr-analog/lib/pll_refout_cc_impl.h +++ b/gr-analog/lib/pll_refout_cc_impl.h @@ -24,13 +24,11 @@ #define INCLUDED_ANALOG_PLL_REFOUT_CC_IMPL_H #include <analog/pll_refout_cc.h> -#include <blocks/control_loop.h> namespace gr { namespace analog { - class pll_refout_cc_impl - : public pll_refout_cc, public blocks::control_loop + class pll_refout_cc_impl : public pll_refout_cc { private: float mod_2pi (float in); diff --git a/gr-analog/lib/qa_analog.cc b/gr-analog/lib/qa_analog.cc index f1e3a45e27..c7c975a3e5 100644 --- a/gr-analog/lib/qa_analog.cc +++ b/gr-analog/lib/qa_analog.cc @@ -26,15 +26,11 @@ */ #include <qa_analog.h> -#include <qa_sincos.h> -#include <qa_rotator.h> CppUnit::TestSuite * qa_gr_analog::suite() { CppUnit::TestSuite *s = new CppUnit::TestSuite("gr-analog"); - s->addTest(gr::analog::qa_sincos::suite()); - return s; } diff --git a/gr-analog/lib/sig_source_X_impl.h.t b/gr-analog/lib/sig_source_X_impl.h.t index 4fed9a060a..50f1791270 100644 --- a/gr-analog/lib/sig_source_X_impl.h.t +++ b/gr-analog/lib/sig_source_X_impl.h.t @@ -27,7 +27,7 @@ #include <analog/@BASE_NAME@.h> #include <gr_sync_block.h> -#include <blocks/fxpt_nco.h> +#include <gr_fxpt_nco.h> namespace gr { namespace analog { @@ -40,7 +40,7 @@ namespace gr { double d_frequency; double d_ampl; @TYPE@ d_offset; - gr::blocks::fxpt_nco d_nco; + gr_fxpt_nco d_nco; public: @IMPL_NAME@(double sampling_freq, gr_waveform_t waveform, diff --git a/gr-analog/lib/sincos.cc b/gr-analog/lib/sincos.cc deleted file mode 100644 index 14ceeb3a29..0000000000 --- a/gr-analog/lib/sincos.cc +++ /dev/null @@ -1,89 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2010,2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#ifndef _GNU_SOURCE -#define _GNU_SOURCE // ask for GNU extensions if available -#endif - -#include <analog/sincos.h> -#include <math.h> - -namespace gr { - namespace analog { - -// ---------------------------------------------------------------- - -#if defined (HAVE_SINCOS) - - void - sincos(double x, double *sinx, double *cosx) - { - ::sincos(x, sinx, cosx); - } - -#else - - void - sincos(double x, double *sinx, double *cosx) - { - *sinx = sin(x); - *cosx = cos(x); - } - -#endif - -// ---------------------------------------------------------------- - -#if defined (HAVE_SINCOSF) - - void - sincosf(float x, float *sinx, float *cosx) - { - sincosf(x, sinx, cosx); - } - -#elif defined (HAVE_SINF) && defined (HAVE_COSF) - - void - sincosf(float x, float *sinx, float *cosx) - { - *sinx = sinf(x); - *cosx = cosf(x); - } - -#else - - void - sincosf(float x, float *sinx, float *cosx) - { - *sinx = sin(x); - *cosx = cos(x); - } - -#endif - - } /* namespace analog */ -} /* namespace gr */ diff --git a/gr-analog/python/CMakeLists.txt b/gr-analog/python/CMakeLists.txt index 44e38621a2..e4d1d0aa74 100644 --- a/gr-analog/python/CMakeLists.txt +++ b/gr-analog/python/CMakeLists.txt @@ -47,6 +47,8 @@ if(ENABLE_TESTING) list(APPEND GR_TEST_PYTHON_DIRS ${CMAKE_BINARY_DIR}/gr-analog/python ${CMAKE_BINARY_DIR}/gr-analog/swig + ${CMAKE_BINARY_DIR}/gr-blocks/python + ${CMAKE_BINARY_DIR}/gr-blocks/swig ${CMAKE_BINARY_DIR}/gr-filter/python ${CMAKE_BINARY_DIR}/gr-filter/swig ) diff --git a/gr-analog/python/qa_agc.py b/gr-analog/python/qa_agc.py index 263f9a647e..0d8a7bfb5d 100755 --- a/gr-analog/python/qa_agc.py +++ b/gr-analog/python/qa_agc.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2004,2007,2010,2012 Free Software Foundation, Inc. +# Copyright 2004,2007,2010,2012,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -22,6 +22,7 @@ from gnuradio import gr, gr_unittest import analog_swig as analog +import blocks_swig as blocks import math class test_agc(gr_unittest.TestCase): @@ -105,8 +106,8 @@ class test_agc(gr_unittest.TestCase): sampling_freq = 100 src1 = analog.sig_source_c(sampling_freq, analog.GR_SIN_WAVE, sampling_freq * 0.10, 100.0) - dst1 = gr.vector_sink_c() - head = gr.head(gr.sizeof_gr_complex, int (5*sampling_freq * 0.10)) + dst1 = blocks.vector_sink_c() + head = blocks.head(gr.sizeof_gr_complex, int (5*sampling_freq * 0.10)) agc = analog.agc_cc(1e-3, 1, 1, 1000) @@ -190,8 +191,8 @@ class test_agc(gr_unittest.TestCase): sampling_freq = 100 src1 = analog.sig_source_f(sampling_freq, analog.GR_SIN_WAVE, sampling_freq * 0.10, 100.0) - dst1 = gr.vector_sink_f () - head = gr.head (gr.sizeof_float, int (5*sampling_freq * 0.10)) + dst1 = blocks.vector_sink_f () + head = blocks.head (gr.sizeof_float, int (5*sampling_freq * 0.10)) agc = analog.agc_ff(1e-3, 1, 1, 1000) @@ -277,8 +278,8 @@ class test_agc(gr_unittest.TestCase): sampling_freq = 100 src1 = analog.sig_source_c(sampling_freq, analog.GR_SIN_WAVE, sampling_freq * 0.10, 100) - dst1 = gr.vector_sink_c() - head = gr.head(gr.sizeof_gr_complex, int(5*sampling_freq * 0.10)) + dst1 = blocks.vector_sink_c() + head = blocks.head(gr.sizeof_gr_complex, int(5*sampling_freq * 0.10)) agc = analog.agc2_cc(1e-2, 1e-3, 1, 1, 1000) @@ -364,8 +365,8 @@ class test_agc(gr_unittest.TestCase): sampling_freq = 100 src1 = analog.sig_source_f(sampling_freq, analog.GR_SIN_WAVE, sampling_freq * 0.10, 100) - dst1 = gr.vector_sink_f() - head = gr.head(gr.sizeof_float, int(5*sampling_freq * 0.10)) + dst1 = blocks.vector_sink_f() + head = blocks.head(gr.sizeof_float, int(5*sampling_freq * 0.10)) agc = analog.agc2_ff(1e-2, 1e-3, 1, 1, 1000) @@ -437,8 +438,8 @@ class test_agc(gr_unittest.TestCase): sampling_freq = 100 src1 = analog.sig_source_c(sampling_freq, analog.GR_SIN_WAVE, sampling_freq * 0.10, 100) - dst1 = gr.vector_sink_c() - head = gr.head(gr.sizeof_gr_complex, int(5*sampling_freq * 0.10)) + dst1 = blocks.vector_sink_c() + head = blocks.head(gr.sizeof_gr_complex, int(5*sampling_freq * 0.10)) agc = analog.agc2_cc(1e-2, 1e-3, 1, 1, 1000) @@ -459,9 +460,9 @@ class test_agc(gr_unittest.TestCase): input_data = 8*(0.0,) + 24*(1.0,) + 24*(0.0,) expected_result = (8+length-1)*(0.0,) + 24*(gain*1.0,) + (0,) - src = gr.vector_source_c(input_data) + src = blocks.vector_source_c(input_data) agc = analog.feedforward_agc_cc(8, 2.0) - dst = gr.vector_sink_c() + dst = blocks.vector_sink_c() self.tb.connect(src, agc, dst) self.tb.run() diff --git a/gr-analog/python/qa_cpfsk.py b/gr-analog/python/qa_cpfsk.py index decf94ea3f..7998d8079d 100755 --- a/gr-analog/python/qa_cpfsk.py +++ b/gr-analog/python/qa_cpfsk.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2012 Free Software Foundation, Inc. +# Copyright 2012,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -22,6 +22,7 @@ from gnuradio import gr, gr_unittest import analog_swig as analog +import blocks_swig as blocks import math class test_cpfsk_bc(gr_unittest.TestCase): @@ -52,9 +53,9 @@ class test_cpfsk_bc(gr_unittest.TestCase): src_data = 10*[0, 1] expected_result = map(lambda x: complex(2*x-1,0), src_data) - src = gr.vector_source_b(src_data) + src = blocks.vector_source_b(src_data) op = analog.cpfsk_bc(2, 1, 2) - dst = gr.vector_sink_c() + dst = blocks.vector_sink_c() self.tb.connect(src, op) self.tb.connect(op, dst) diff --git a/gr-analog/python/qa_ctcss_squelch.py b/gr-analog/python/qa_ctcss_squelch.py index 08d3dbfef8..622cca234f 100755 --- a/gr-analog/python/qa_ctcss_squelch.py +++ b/gr-analog/python/qa_ctcss_squelch.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2012 Free Software Foundation, Inc. +# Copyright 2012,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -22,6 +22,7 @@ from gnuradio import gr, gr_unittest import analog_swig as analog +import blocks_swig as blocks class test_ctcss_squelch(gr_unittest.TestCase): @@ -68,10 +69,10 @@ class test_ctcss_squelch(gr_unittest.TestCase): expected_result = src_data expected_result[0] = 0 - src = gr.vector_source_f(src_data) + src = blocks.vector_source_f(src_data) op = analog.ctcss_squelch_ff(rate, freq, level, length, ramp, gate) - dst = gr.vector_sink_f() + dst = blocks.vector_sink_f() self.tb.connect(src, op) self.tb.connect(op, dst) @@ -90,10 +91,10 @@ class test_ctcss_squelch(gr_unittest.TestCase): gate = False src_data = map(lambda x: float(x)/10.0, range(1, 40)) - src = gr.vector_source_f(src_data) + src = blocks.vector_source_f(src_data) op = analog.ctcss_squelch_ff(rate, freq, level, length, ramp, gate) - dst = gr.vector_sink_f() + dst = blocks.vector_sink_f() self.tb.connect(src, op) self.tb.connect(op, dst) diff --git a/gr-analog/python/qa_dpll.py b/gr-analog/python/qa_dpll.py index 3ef8a6e285..98ddf83eff 100755 --- a/gr-analog/python/qa_dpll.py +++ b/gr-analog/python/qa_dpll.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2012 Free Software Foundation, Inc. +# Copyright 2012,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -22,6 +22,7 @@ from gnuradio import gr, gr_unittest import analog_swig as analog +import blocks_swig as blocks import math class test_dpll_bb(gr_unittest.TestCase): @@ -60,9 +61,9 @@ class test_dpll_bb(gr_unittest.TestCase): src_data = 10*((period-1)*[0,] + [1,]) expected_result = src_data - src = gr.vector_source_b(src_data) + src = blocks.vector_source_b(src_data) op = analog.dpll_bb(period, gain) - dst = gr.vector_sink_b() + dst = blocks.vector_sink_b() self.tb.connect(src, op) self.tb.connect(op, dst) diff --git a/gr-analog/python/qa_fmdet.py b/gr-analog/python/qa_fmdet.py index a76ac1d247..6c99b08803 100755 --- a/gr-analog/python/qa_fmdet.py +++ b/gr-analog/python/qa_fmdet.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2012 Free Software Foundation, Inc. +# Copyright 2012,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -22,6 +22,7 @@ from gnuradio import gr, gr_unittest import analog_swig as analog +import blocks_swig as blocks import math class test_fmdet_cf(gr_unittest.TestCase): @@ -63,9 +64,9 @@ class test_fmdet_cf(gr_unittest.TestCase): def est_fmdet_cf_002(self): N = 100 src = analog.sig_source_c(1, analog.GR_SIN_WAVE, 0.2, 1) - head = gr.head(gr.sizeof_gr_complex, N) + head = blocks.head(gr.sizeof_gr_complex, N) op = analog.fmdet_cf(1, 0.1, 0.3, 0.1) - dst = gr.vector_sink_f() + dst = blocks.vector_sink_f() self.tb.connect(src, head, op) self.tb.connect(op, dst) diff --git a/gr-analog/python/qa_frequency_modulator.py b/gr-analog/python/qa_frequency_modulator.py index b673b3275c..7d6cff3fea 100755 --- a/gr-analog/python/qa_frequency_modulator.py +++ b/gr-analog/python/qa_frequency_modulator.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2004,2007,2010,2012 Free Software Foundation, Inc. +# Copyright 2004,2007,2010,2012,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -22,6 +22,7 @@ from gnuradio import gr, gr_unittest import analog_swig as analog +import blocks_swig as blocks import math def sincos(x): @@ -42,9 +43,9 @@ class test_frequency_modulator(gr_unittest.TestCase): src_data = (1.0/4, 1.0/2, 1.0/4, -1.0/4, -1.0/2, -1/4.0) running_sum = (pi/16, 3*pi/16, pi/4, 3*pi/16, pi/16, 0) expected_result = tuple([sincos(x) for x in running_sum]) - src = gr.vector_source_f(src_data) + src = blocks.vector_source_f(src_data) op = analog.frequency_modulator_fc(sensitivity) - dst = gr.vector_sink_c() + dst = blocks.vector_sink_c() self.tb.connect(src, op) self.tb.connect(op, dst) self.tb.run() diff --git a/gr-analog/python/qa_phase_modulator.py b/gr-analog/python/qa_phase_modulator.py index a9c8c84597..81334177db 100755 --- a/gr-analog/python/qa_phase_modulator.py +++ b/gr-analog/python/qa_phase_modulator.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2012 Free Software Foundation, Inc. +# Copyright 2012,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -22,6 +22,7 @@ from gnuradio import gr, gr_unittest import analog_swig as analog +import blocks_swig as blocks import math def sincos(x): @@ -42,9 +43,9 @@ class test_phase_modulator(gr_unittest.TestCase): src_data = (1.0/4, 1.0/2, 1.0/4, -1.0/4, -1.0/2, -1/4.0) expected_result = tuple([sincos(sensitivity*x) for x in src_data]) - src = gr.vector_source_f(src_data) + src = blocks.vector_source_f(src_data) op = analog.phase_modulator_fc(sensitivity) - dst = gr.vector_sink_c() + dst = blocks.vector_sink_c() self.tb.connect(src, op) self.tb.connect(op, dst) diff --git a/gr-analog/python/qa_plateau_detector_fb.py b/gr-analog/python/qa_plateau_detector_fb.py index 5f8abc74ec..6f330440ef 100755 --- a/gr-analog/python/qa_plateau_detector_fb.py +++ b/gr-analog/python/qa_plateau_detector_fb.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2012 Free Software Foundation, Inc. +# Copyright 2012,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -22,6 +22,7 @@ from gnuradio import gr, gr_unittest import analog_swig as analog +import blocks_swig as blocks class qa_plateau_detector_fb (gr_unittest.TestCase): @@ -36,8 +37,8 @@ class qa_plateau_detector_fb (gr_unittest.TestCase): test_signal = (0, 1, .2, .4, .6, .8, 1, 1, 1, 1, 1, .8, .6, .4, 1, 0) expected_sig = (0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0) # | Center of Plateau - sink = gr.vector_sink_b() - self.tb.connect(gr.vector_source_f(test_signal), analog.plateau_detector_fb(5), sink) + sink = blocks.vector_sink_b() + self.tb.connect(blocks.vector_source_f(test_signal), analog.plateau_detector_fb(5), sink) self.tb.run () self.assertEqual(expected_sig, sink.data()) diff --git a/gr-analog/python/qa_pll_carriertracking.py b/gr-analog/python/qa_pll_carriertracking.py index e383639d49..2a6bb9f0b3 100755 --- a/gr-analog/python/qa_pll_carriertracking.py +++ b/gr-analog/python/qa_pll_carriertracking.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2004,2007,2010-2012 Free Software Foundation, Inc. +# Copyright 2004,2007,2010-2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -22,6 +22,7 @@ from gnuradio import gr, gr_unittest import analog_swig as analog +import blocks_swig as blocks import math class test_pll_carriertracking(gr_unittest.TestCase): @@ -143,8 +144,8 @@ class test_pll_carriertracking(gr_unittest.TestCase): src = analog.sig_source_c(sampling_freq, analog.GR_COS_WAVE, freq, 1.0) pll = analog.pll_carriertracking_cc(loop_bw, maxf, minf) - head = gr.head(gr.sizeof_gr_complex, int (freq)) - dst = gr.vector_sink_c() + head = blocks.head(gr.sizeof_gr_complex, int (freq)) + dst = blocks.vector_sink_c() self.tb.connect(src, pll, head) self.tb.connect(head, dst) diff --git a/gr-analog/python/qa_pll_freqdet.py b/gr-analog/python/qa_pll_freqdet.py index cc8757c965..11f2a9b959 100755 --- a/gr-analog/python/qa_pll_freqdet.py +++ b/gr-analog/python/qa_pll_freqdet.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2004,2007,2010-2012 Free Software Foundation, Inc. +# Copyright 2004,2007,2010-2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -22,6 +22,7 @@ from gnuradio import gr, gr_unittest import analog_swig as analog +import blocks_swig as blocks import math class test_pll_freqdet(gr_unittest.TestCase): @@ -143,8 +144,8 @@ class test_pll_freqdet(gr_unittest.TestCase): src = analog.sig_source_c(sampling_freq, analog.GR_COS_WAVE, freq, 1.0) pll = analog.pll_freqdet_cf(loop_bw, maxf, minf) - head = gr.head(gr.sizeof_float, int (freq)) - dst = gr.vector_sink_f() + head = blocks.head(gr.sizeof_float, int (freq)) + dst = blocks.vector_sink_f() self.tb.connect(src, pll, head) self.tb.connect(head, dst) diff --git a/gr-analog/python/qa_pll_refout.py b/gr-analog/python/qa_pll_refout.py index c63136bc0c..f90e7c3ada 100755 --- a/gr-analog/python/qa_pll_refout.py +++ b/gr-analog/python/qa_pll_refout.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2004,2010,2012 Free Software Foundation, Inc. +# Copyright 2004,2010,2012,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -22,6 +22,7 @@ from gnuradio import gr, gr_unittest import analog_swig as analog +import blocks_swig as blocks import math class test_pll_refout(gr_unittest.TestCase): @@ -143,8 +144,8 @@ class test_pll_refout(gr_unittest.TestCase): src = analog.sig_source_c(sampling_freq, analog.GR_COS_WAVE, freq, 1.0) pll = analog.pll_refout_cc(loop_bw, maxf, minf) - head = gr.head(gr.sizeof_gr_complex, int (freq)) - dst = gr.vector_sink_c() + head = blocks.head(gr.sizeof_gr_complex, int (freq)) + dst = blocks.vector_sink_c() self.tb.connect(src, pll, head) self.tb.connect(head, dst) diff --git a/gr-analog/python/qa_probe_avg_mag_sqrd.py b/gr-analog/python/qa_probe_avg_mag_sqrd.py index 5c6c97e450..930077c9c0 100755 --- a/gr-analog/python/qa_probe_avg_mag_sqrd.py +++ b/gr-analog/python/qa_probe_avg_mag_sqrd.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2012 Free Software Foundation, Inc. +# Copyright 2012,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -22,6 +22,7 @@ from gnuradio import gr, gr_unittest import analog_swig as analog +import blocks_swig as blocks import math def avg_mag_sqrd_c(x, alpha): @@ -52,7 +53,7 @@ class test_probe_avg_mag_sqrd(gr_unittest.TestCase): 6.0+6.0j, 7.0+7.0j, 8.0+8.0j, 9.0+9.0j, 10.0+10.0j] expected_result = avg_mag_sqrd_c(src_data, alpha)[-1] - src = gr.vector_source_c(src_data) + src = blocks.vector_source_c(src_data) op = analog.probe_avg_mag_sqrd_c(0, alpha) self.tb.connect(src, op) @@ -67,9 +68,9 @@ class test_probe_avg_mag_sqrd(gr_unittest.TestCase): 6.0+6.0j, 7.0+7.0j, 8.0+8.0j, 9.0+9.0j, 10.0+10.0j] expected_result = avg_mag_sqrd_c(src_data, alpha)[0:-1] - src = gr.vector_source_c(src_data) + src = blocks.vector_source_c(src_data) op = analog.probe_avg_mag_sqrd_cf(0, alpha) - dst = gr.vector_sink_f() + dst = blocks.vector_sink_f() self.tb.connect(src, op) self.tb.connect(op, dst) @@ -84,7 +85,7 @@ class test_probe_avg_mag_sqrd(gr_unittest.TestCase): 6.0, 7.0, 8.0, 9.0, 10.0] expected_result = avg_mag_sqrd_f(src_data, alpha)[-1] - src = gr.vector_source_f(src_data) + src = blocks.vector_source_f(src_data) op = analog.probe_avg_mag_sqrd_f(0, alpha) self.tb.connect(src, op) diff --git a/gr-analog/python/qa_pwr_squelch.py b/gr-analog/python/qa_pwr_squelch.py index dd42c7fb90..238723ba3c 100755 --- a/gr-analog/python/qa_pwr_squelch.py +++ b/gr-analog/python/qa_pwr_squelch.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2012 Free Software Foundation, Inc. +# Copyright 2012,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -22,6 +22,7 @@ from gnuradio import gr, gr_unittest import analog_swig as analog +import blocks_swig as blocks class test_pwr_squelch(gr_unittest.TestCase): @@ -63,9 +64,9 @@ class test_pwr_squelch(gr_unittest.TestCase): thr = -25 src_data = map(lambda x: float(x)/10.0, range(1, 40)) - src = gr.vector_source_c(src_data) + src = blocks.vector_source_c(src_data) op = analog.pwr_squelch_cc(thr, alpha) - dst = gr.vector_sink_c() + dst = blocks.vector_sink_c() self.tb.connect(src, op) self.tb.connect(op, dst) @@ -109,9 +110,9 @@ class test_pwr_squelch(gr_unittest.TestCase): thr = -25 src_data = map(lambda x: float(x)/10.0, range(1, 40)) - src = gr.vector_source_f(src_data) + src = blocks.vector_source_f(src_data) op = analog.pwr_squelch_ff(thr, alpha) - dst = gr.vector_sink_f() + dst = blocks.vector_sink_f() self.tb.connect(src, op) self.tb.connect(op, dst) diff --git a/gr-analog/python/qa_quadrature_demod.py b/gr-analog/python/qa_quadrature_demod.py index e38ea72a7d..0a92bb12a5 100755 --- a/gr-analog/python/qa_quadrature_demod.py +++ b/gr-analog/python/qa_quadrature_demod.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2012 Free Software Foundation, Inc. +# Copyright 2012,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -22,6 +22,7 @@ from gnuradio import gr, gr_unittest import analog_swig as analog +import blocks_swig as blocks import cmath class test_quadrature_demod(gr_unittest.TestCase): @@ -47,9 +48,9 @@ class test_quadrature_demod(gr_unittest.TestCase): expected_result = [0,] + 199*[1.0] - src = gr.vector_source_c(src_data) + src = blocks.vector_source_c(src_data) op = analog.quadrature_demod_cf(gain) - dst = gr.vector_sink_f() + dst = blocks.vector_sink_f() self.tb.connect(src, op) self.tb.connect(op, dst) diff --git a/gr-analog/python/qa_rail_ff.py b/gr-analog/python/qa_rail_ff.py index 5bcf01c6b7..58ac01d7a6 100755 --- a/gr-analog/python/qa_rail_ff.py +++ b/gr-analog/python/qa_rail_ff.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2012 Free Software Foundation, Inc. +# Copyright 2012,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -22,6 +22,7 @@ from gnuradio import gr, gr_unittest import analog_swig as analog +import blocks_swig as blocks def clip(x, lo, hi): if(x < lo): @@ -63,9 +64,9 @@ class test_rail(gr_unittest.TestCase): src_data = [-2, -1, -0.5, -0.25, 0, 0.25, 0.5, 1, 2] expected_result = map(lambda x: clip(x, lo, hi), src_data) - src = gr.vector_source_f(src_data) + src = blocks.vector_source_f(src_data) op = analog.rail_ff(lo, hi) - dst = gr.vector_sink_f() + dst = blocks.vector_sink_f() self.tb.connect(src, op) self.tb.connect(op, dst) diff --git a/gr-analog/python/qa_sig_source.py b/gr-analog/python/qa_sig_source.py index bc48333ed1..0aa03c7402 100755 --- a/gr-analog/python/qa_sig_source.py +++ b/gr-analog/python/qa_sig_source.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2004,2007,2010,2012 Free Software Foundation, Inc. +# Copyright 2004,2007,2010,2012,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -22,6 +22,7 @@ from gnuradio import gr, gr_unittest import analog_swig as analog +import blocks_swig as blocks import math class test_sig_source(gr_unittest.TestCase): @@ -36,8 +37,8 @@ class test_sig_source(gr_unittest.TestCase): tb = self.tb expected_result = (1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5) src1 = analog.sig_source_f(1e6, analog.GR_CONST_WAVE, 0, 1.5) - op = gr.head(gr.sizeof_float, 10) - dst1 = gr.vector_sink_f() + op = blocks.head(gr.sizeof_float, 10) + dst1 = blocks.vector_sink_f() tb.connect(src1, op) tb.connect(op, dst1) tb.run() @@ -48,8 +49,8 @@ class test_sig_source(gr_unittest.TestCase): tb = self.tb expected_result = (1, 1, 1, 1) src1 = analog.sig_source_i(1e6, analog.GR_CONST_WAVE, 0, 1) - op = gr.head(gr.sizeof_int, 4) - dst1 = gr.vector_sink_i() + op = blocks.head(gr.sizeof_int, 4) + dst1 = blocks.vector_sink_i() tb.connect(src1, op) tb.connect(op, dst1) tb.run() @@ -61,8 +62,8 @@ class test_sig_source(gr_unittest.TestCase): sqrt2 = math.sqrt(2) / 2 expected_result = (0, sqrt2, 1, sqrt2, 0, -sqrt2, -1, -sqrt2, 0) src1 = analog.sig_source_f(8, analog.GR_SIN_WAVE, 1.0, 1.0) - op = gr.head(gr.sizeof_float, 9) - dst1 = gr.vector_sink_f() + op = blocks.head(gr.sizeof_float, 9) + dst1 = blocks.vector_sink_f() tb.connect(src1, op) tb.connect(op, dst1) tb.run() @@ -74,8 +75,8 @@ class test_sig_source(gr_unittest.TestCase): sqrt2 = math.sqrt(2) / 2 expected_result = (1, sqrt2, 0, -sqrt2, -1, -sqrt2, 0, sqrt2, 1) src1 = analog.sig_source_f(8, analog.GR_COS_WAVE, 1.0, 1.0) - op = gr.head(gr.sizeof_float, 9) - dst1 = gr.vector_sink_f() + op = blocks.head(gr.sizeof_float, 9) + dst1 = blocks.vector_sink_f() tb.connect(src1, op) tb.connect(op, dst1) tb.run() @@ -86,8 +87,8 @@ class test_sig_source(gr_unittest.TestCase): tb = self.tb #arg6 is a bit before -PI/2 expected_result = (1j, 1j, 0, 0, 1, 1, 1+0j, 1+1j, 1j) src1 = analog.sig_source_c(8, analog.GR_SQR_WAVE, 1.0, 1.0) - op = gr.head(gr.sizeof_gr_complex, 9) - dst1 = gr.vector_sink_c() + op = blocks.head(gr.sizeof_gr_complex, 9) + dst1 = blocks.vector_sink_c() tb.connect(src1, op) tb.connect(op, dst1) tb.run() @@ -99,8 +100,8 @@ class test_sig_source(gr_unittest.TestCase): expected_result = (1+.5j, .75+.75j, .5+1j, .25+.75j, 0+.5j, .25+.25j, .5+0j, .75+.25j, 1+.5j) src1 = analog.sig_source_c(8, analog.GR_TRI_WAVE, 1.0, 1.0) - op = gr.head(gr.sizeof_gr_complex, 9) - dst1 = gr.vector_sink_c() + op = blocks.head(gr.sizeof_gr_complex, 9) + dst1 = blocks.vector_sink_c() tb.connect(src1, op) tb.connect(op, dst1) tb.run() @@ -112,8 +113,8 @@ class test_sig_source(gr_unittest.TestCase): expected_result = (.5+.25j, .625+.375j, .75+.5j, .875+.625j, 0+.75j, .125+.875j, .25+1j, .375+.125j, .5+.25j) src1 = analog.sig_source_c(8, analog.GR_SAW_WAVE, 1.0, 1.0) - op = gr.head(gr.sizeof_gr_complex, 9) - dst1 = gr.vector_sink_c() + op = blocks.head(gr.sizeof_gr_complex, 9) + dst1 = blocks.vector_sink_c() tb.connect(src1, op) tb.connect(op, dst1) tb.run() @@ -124,8 +125,8 @@ class test_sig_source(gr_unittest.TestCase): tb = self.tb expected_result = (0, 0, 0, 0, 1, 1, 1, 1, 0) src1 = analog.sig_source_f(8, analog.GR_SQR_WAVE, 1.0, 1.0) - op = gr.head(gr.sizeof_float, 9) - dst1 = gr.vector_sink_f() + op = blocks.head(gr.sizeof_float, 9) + dst1 = blocks.vector_sink_f() tb.connect(src1, op) tb.connect(op, dst1) tb.run() @@ -136,8 +137,8 @@ class test_sig_source(gr_unittest.TestCase): tb = self.tb expected_result = (1, .75, .5, .25, 0, .25, .5, .75, 1) src1 = analog.sig_source_f(8, analog.GR_TRI_WAVE, 1.0, 1.0) - op = gr.head(gr.sizeof_float, 9) - dst1 = gr.vector_sink_f() + op = blocks.head(gr.sizeof_float, 9) + dst1 = blocks.vector_sink_f() tb.connect(src1, op) tb.connect(op, dst1) tb.run() @@ -148,8 +149,8 @@ class test_sig_source(gr_unittest.TestCase): tb = self.tb expected_result = (.5, .625, .75, .875, 0, .125, .25, .375, .5) src1 = analog.sig_source_f(8, analog.GR_SAW_WAVE, 1.0, 1.0) - op = gr.head(gr.sizeof_float, 9) - dst1 = gr.vector_sink_f() + op = blocks.head(gr.sizeof_float, 9) + dst1 = blocks.vector_sink_f() tb.connect(src1, op) tb.connect(op, dst1) tb.run() diff --git a/gr-analog/python/qa_simple_squelch.py b/gr-analog/python/qa_simple_squelch.py index 9fa112864f..2bd88e1489 100755 --- a/gr-analog/python/qa_simple_squelch.py +++ b/gr-analog/python/qa_simple_squelch.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2012 Free Software Foundation, Inc. +# Copyright 2012,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -22,6 +22,7 @@ from gnuradio import gr, gr_unittest import analog_swig as analog +import blocks_swig as blocks class test_simple_squelch(gr_unittest.TestCase): @@ -50,9 +51,9 @@ class test_simple_squelch(gr_unittest.TestCase): thr = -25 src_data = map(lambda x: float(x)/10.0, range(1, 40)) - src = gr.vector_source_c(src_data) + src = blocks.vector_source_c(src_data) op = analog.simple_squelch_cc(thr, alpha) - dst = gr.vector_sink_c() + dst = blocks.vector_sink_c() self.tb.connect(src, op) self.tb.connect(op, dst) diff --git a/gr-analog/python/wfm_rcv_fmdet.py b/gr-analog/python/wfm_rcv_fmdet.py index f3627d378d..b7cd1458fb 100644 --- a/gr-analog/python/wfm_rcv_fmdet.py +++ b/gr-analog/python/wfm_rcv_fmdet.py @@ -1,5 +1,5 @@ # -# Copyright 2005,2006,2012 Free Software Foundation, Inc. +# Copyright 2005,2006,2012-2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -132,7 +132,7 @@ class wfm_rcv_fmdet(gr.hier_block2): stereo_rds_filter_coeffs) self.rds_carrier_generator = blocks.multiply_cc(); self.rds_signal_generator = blocks.multiply_cc(); - self_rds_signal_processor = gr.null_sink(gr.sizeof_gr_complex); + self_rds_signal_processor = blocks.null_sink(gr.sizeof_gr_complex); loop_bw = 2*math.pi/100.0 max_freq = -2.0*math.pi*18990/audio_rate; diff --git a/gr-analog/python/wfm_rcv_pll.py b/gr-analog/python/wfm_rcv_pll.py index 7452de731f..282e2b14be 100644 --- a/gr-analog/python/wfm_rcv_pll.py +++ b/gr-analog/python/wfm_rcv_pll.py @@ -1,5 +1,5 @@ # -# Copyright 2005,2006,2012 Free Software Foundation, Inc. +# Copyright 2005,2006,2012-2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -125,7 +125,7 @@ class wfm_rcv_pll(gr.hier_block2): self.rds_carrier_generator = blocks.multiply_cc(); self.rds_signal_generator = blocks.multiply_cc(); - self_rds_signal_processor = gr.null_sink(gr.sizeof_gr_complex); + self_rds_signal_processor = blocks.null_sink(gr.sizeof_gr_complex); loop_bw = 2*math.pi/100.0 max_freq = -2.0*math.pi*18990/audio_rate; diff --git a/gr-analog/swig/CMakeLists.txt b/gr-analog/swig/CMakeLists.txt index 4391e5e09a..eede32c4ec 100644 --- a/gr-analog/swig/CMakeLists.txt +++ b/gr-analog/swig/CMakeLists.txt @@ -24,6 +24,7 @@ include(GrPython) include(GrSwig) set(GR_SWIG_INCLUDE_DIRS + ${GR_BLOCKS_INCLUDE_DIRS} ${GR_ANALOG_INCLUDE_DIRS} ${GR_FILTER_INCLUDE_DIRS} ${GNURADIO_CORE_SWIG_INCLUDE_DIRS} diff --git a/gr-analog/swig/analog_swig.i b/gr-analog/swig/analog_swig.i index 2c6f5a66cb..1f5ea85b55 100644 --- a/gr-analog/swig/analog_swig.i +++ b/gr-analog/swig/analog_swig.i @@ -20,6 +20,7 @@ */ #define ANALOG_API +#define BLOCKS_API %include "gnuradio.i" %include "stdint.i" @@ -28,6 +29,11 @@ %include "analog_swig_doc.i" %{ +#include <blocks/control_loop.h> +%} +%include <blocks/control_loop.h> + +%{ #include "analog/cpm.h" #include "analog/noise_type.h" #include "analog/agc_cc.h" @@ -60,7 +66,6 @@ #include "analog/pwr_squelch_ff.h" #include "analog/quadrature_demod_cf.h" #include "analog/rail_ff.h" -#include "analog/sincos.h" #include "analog/sig_source_s.h" #include "analog/sig_source_i.h" #include "analog/sig_source_f.h" @@ -103,7 +108,6 @@ %include "analog/pwr_squelch_ff.h" %include "analog/quadrature_demod_cf.h" %include "analog/rail_ff.h" -%include "analog/sincos.h" %include "analog/sig_source_s.h" %include "analog/sig_source_i.h" %include "analog/sig_source_f.h" diff --git a/gr-atsc/include/atsc/fpll.h b/gr-atsc/include/atsc/fpll.h index 00d6b1e54e..2bffc327eb 100644 --- a/gr-atsc/include/atsc/fpll.h +++ b/gr-atsc/include/atsc/fpll.h @@ -25,7 +25,7 @@ #include <atsc/api.h> #include <gr_sync_block.h> -#include <blocks/nco.h> +#include <gr_nco.h> #include <filter/single_pole_iir.h> #include <analog/agc.h> #include <stdio.h> @@ -70,7 +70,7 @@ public: double initial_freq; double initial_phase; bool debug_no_update; - blocks::nco<float,float> nco; + gr_nco<float,float> nco; analog::kernel::agc_ff agc; // automatic gain control filter::single_pole_iir<float,float,float> afci; filter::single_pole_iir<float,float,float> afcq; diff --git a/gr-atsc/lib/CMakeLists.txt b/gr-atsc/lib/CMakeLists.txt index b30581be79..df9cc7c396 100644 --- a/gr-atsc/lib/CMakeLists.txt +++ b/gr-atsc/lib/CMakeLists.txt @@ -27,7 +27,6 @@ include_directories( ${GR_FILTER_INCLUDE_DIRS} ${GR_ANALOG_INCLUDE_DIRS} ${GR_FEC_INCLUDE_DIRS} - ${GR_BLOCKS_INCLUDE_DIRS} ${GNURADIO_CORE_INCLUDE_DIRS} ${GRUEL_INCLUDE_DIRS} ${LOG4CPP_INCLUDE_DIRS} @@ -121,7 +120,6 @@ list(APPEND atsc_libs gnuradio-analog gnuradio-core gnuradio-fec - gnuradio-blocks ${Boost_LIBRARIES} ${LOG4CPP_LIBRARIES} ) diff --git a/gr-atsc/python/CMakeLists.txt b/gr-atsc/python/CMakeLists.txt index aaa5bd93c4..ea3524ae18 100644 --- a/gr-atsc/python/CMakeLists.txt +++ b/gr-atsc/python/CMakeLists.txt @@ -45,7 +45,8 @@ install( if(ENABLE_TESTING) list(APPEND GR_TEST_PYTHON_DIRS - ${CMAKE_BINARY_DIR}/gr-atsc/src/lib + ${CMAKE_BINARY_DIR}/gr-atsc/python + ${CMAKE_BINARY_DIR}/gr-atsc/swig ${CMAKE_BINARY_DIR}/gr-blocks/python ${CMAKE_BINARY_DIR}/gr-blocks/swig ) diff --git a/gr-atsc/python/qa_atsc.py b/gr-atsc/python/qa_atsc.py index 507bc8aa47..d17a200cf6 100755 --- a/gr-atsc/python/qa_atsc.py +++ b/gr-atsc/python/qa_atsc.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2004,2006,2007 Free Software Foundation, Inc. +# Copyright 2004,2006,2007,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -21,8 +21,7 @@ # from gnuradio import gr, gr_unittest -import atsc # qa code needs to run without being installed -#from gnuradio import atsc +import atsc_swig as atsc from atsc_utils import * import sys import blocks_swig as blocks @@ -80,7 +79,7 @@ class vector_source_ts(gr.hier_block2): ts: MPEG transport stream. (sequence of ints in [0,255]; len(ts) % 188 == 0) """ - src = gr.vector_source_b(pad_transport_stream(ts)) + src = blocks.vector_source_b(pad_transport_stream(ts)) s2v = blocks.stream_to_vector(gr.sizeof_char, atsc.sizeof_atsc_mpeg_packet) gr.hier_block2.__init__(self, "vector_source_ts", @@ -98,7 +97,7 @@ class vector_sink_ts(gr.hier_block2): """ v2s = blocks.vector_to_stream(gr.sizeof_char, atsc.sizeof_atsc_mpeg_packet) - self.sink = gr.vector_sink_b() + self.sink = blocks.vector_sink_b() gr.hier_block2.__init__(self, "vector_sink_ts", v2s.input_signature(), gr.io_signature(0, 0, 0)) diff --git a/gr-audio/examples/grc/cvsd_sweep.grc b/gr-audio/examples/grc/cvsd_sweep.grc index 496fd4f8e7..00da399da1 100644 --- a/gr-audio/examples/grc/cvsd_sweep.grc +++ b/gr-audio/examples/grc/cvsd_sweep.grc @@ -520,7 +520,7 @@ </param> <param> <key>trig_mode</key> - <value>gr.gr_TRIG_MODE_AUTO</value> + <value>wxgui.TRIG_MODE_AUTO</value> </param> <param> <key>y_axis_label</key> @@ -595,7 +595,7 @@ </param> <param> <key>trig_mode</key> - <value>gr.gr_TRIG_MODE_AUTO</value> + <value>wxgui.TRIG_MODE_AUTO</value> </param> <param> <key>y_axis_label</key> @@ -761,7 +761,7 @@ </param> <param> <key>trig_mode</key> - <value>gr.gr_TRIG_MODE_AUTO</value> + <value>wxgui.TRIG_MODE_AUTO</value> </param> <param> <key>y_axis_label</key> diff --git a/gr-audio/examples/python/audio_to_file.py b/gr-audio/examples/python/audio_to_file.py index 201ec90bf1..6a2cbcb12e 100755 --- a/gr-audio/examples/python/audio_to_file.py +++ b/gr-audio/examples/python/audio_to_file.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2004,2007 Free Software Foundation, Inc. +# Copyright 2004,2007,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -53,7 +53,7 @@ class my_top_block(gr.top_block): if options.nsamples is None: self.connect((src, 0), dst) else: - head = gr.head(gr.sizeof_float, int(options.nsamples)) + head = blocks.head(gr.sizeof_float, int(options.nsamples)) self.connect((src, 0), head, dst) diff --git a/gr-audio/examples/python/dial_tone_wav.py b/gr-audio/examples/python/dial_tone_wav.py index 91bf744c95..82f8cf331d 100755 --- a/gr-audio/examples/python/dial_tone_wav.py +++ b/gr-audio/examples/python/dial_tone_wav.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2004,2005,2007,2008,2012 Free Software Foundation, Inc. +# Copyright 2004,2005,2007,2008,2012,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -54,8 +54,8 @@ class my_top_block(gr.top_block): src0 = analog.sig_source_f(sample_rate, analog.GR_SIN_WAVE, 350, ampl) src1 = analog.sig_source_f(sample_rate, analog.GR_SIN_WAVE, 440, ampl) - head0 = gr.head(gr.sizeof_float, int(options.samples)) - head1 = gr.head(gr.sizeof_float, int(options.samples)) + head0 = blocks.head(gr.sizeof_float, int(options.samples)) + head1 = blocks.head(gr.sizeof_float, int(options.samples)) dst = blocks.wavfile_sink(args[0], 2, int(options.sample_rate), 16) self.connect(src0, head0, (dst, 0)) diff --git a/gr-audio/examples/python/noise.py b/gr-audio/examples/python/noise.py index bba9e83eae..b15065cd4e 100755 --- a/gr-audio/examples/python/noise.py +++ b/gr-audio/examples/python/noise.py @@ -44,7 +44,7 @@ class my_top_block(gr.top_block): sample_rate = int(options.sample_rate) ampl = 0.1 - src = gr.glfsr_source_b(32) # Pseudorandom noise source + src = digital.glfsr_source_b(32) # Pseudorandom noise source b2f = digital.chunks_to_symbols_bf([ampl, -ampl], 1) dst = audio.sink(sample_rate, options.audio_output) self.connect(src, b2f, dst) diff --git a/gr-audio/examples/python/spectrum_inversion.py b/gr-audio/examples/python/spectrum_inversion.py index 63d0c8cc8d..a02d6c5821 100755 --- a/gr-audio/examples/python/spectrum_inversion.py +++ b/gr-audio/examples/python/spectrum_inversion.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2004,2005,2007 Free Software Foundation, Inc. +# Copyright 2004,2005,2007,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -54,7 +54,7 @@ class my_top_block(gr.top_block): dst = audio.sink (sample_rate, options.audio_output) vec1 = [1, -1] - vsource = gr.vector_source_f(vec1, True) + vsource = blocks.vector_source_f(vec1, True) multiply = blocks.multiply_ff() self.connect(src, (multiply, 0)) diff --git a/gr-audio/examples/python/test_resampler.py b/gr-audio/examples/python/test_resampler.py index 0f5544cfa9..94d95fecf3 100755 --- a/gr-audio/examples/python/test_resampler.py +++ b/gr-audio/examples/python/test_resampler.py @@ -22,6 +22,7 @@ from gnuradio import gr, gru from gnuradio import audio +from gnuradio import filter from gnuradio.eng_option import eng_option from optparse import OptionParser @@ -65,7 +66,7 @@ class my_top_block(gr.top_block): ampl = 0.1 src0 = analog.sig_source_f(input_rate, analog.GR_SIN_WAVE, 650, ampl) - rr = blocks.rational_resampler_fff(interp, decim) + rr = filter.rational_resampler_fff(interp, decim) dst = audio.sink(output_rate, options.audio_output) self.connect(src0, rr, (dst, 0)) diff --git a/gr-blocks/CMakeLists.txt b/gr-blocks/CMakeLists.txt index 98f73d2177..c4821da2b8 100644 --- a/gr-blocks/CMakeLists.txt +++ b/gr-blocks/CMakeLists.txt @@ -82,9 +82,9 @@ CPACK_COMPONENT("blocks_swig" ######################################################################## add_subdirectory(include/blocks) add_subdirectory(lib) -if(ENABLE_TESTING) - add_subdirectory(tests) -endif(ENABLE_TESTING) +#if(ENABLE_TESTING) +# add_subdirectory(tests) +#endif(ENABLE_TESTING) if(ENABLE_PYTHON) add_subdirectory(python) add_subdirectory(swig) diff --git a/gr-blocks/examples/CMakeLists.txt b/gr-blocks/examples/CMakeLists.txt index 0f9db57b63..c9829661b6 100644 --- a/gr-blocks/examples/CMakeLists.txt +++ b/gr-blocks/examples/CMakeLists.txt @@ -19,3 +19,7 @@ add_subdirectory(metadata) add_subdirectory(tags) + +if(ENABLE_GR_CTRLPORT) +add_subdirectory(ctrlport) +endif(ENABLE_GR_CTRLPORT) diff --git a/gnuradio-core/src/examples/ctrlport/CMakeLists.txt b/gr-blocks/examples/ctrlport/CMakeLists.txt index 47ef4c225e..47ef4c225e 100644 --- a/gnuradio-core/src/examples/ctrlport/CMakeLists.txt +++ b/gr-blocks/examples/ctrlport/CMakeLists.txt diff --git a/gnuradio-core/src/examples/ctrlport/comparing_resamplers.grc b/gr-blocks/examples/ctrlport/comparing_resamplers.grc index 4ac4af247f..7b90a2066c 100644 --- a/gnuradio-core/src/examples/ctrlport/comparing_resamplers.grc +++ b/gr-blocks/examples/ctrlport/comparing_resamplers.grc @@ -33,7 +33,7 @@ </param> </block> <block> - <key>gr_ctrlport_probe2_c</key> + <key>blocks_ctrlport_probe2_c</key> <param> <key>id</key> <value>probe_arc_resamp</value> @@ -126,7 +126,7 @@ </param> </block> <block> - <key>gr_ctrlport_probe2_c</key> + <key>blocks_ctrlport_probe2_c</key> <param> <key>id</key> <value>probe_frac_interp</value> diff --git a/gnuradio-core/src/examples/ctrlport/pfb_sync_test-qt.grc b/gr-blocks/examples/ctrlport/pfb_sync_test-qt.grc index 31914412bc..c28ed6d71a 100644 --- a/gnuradio-core/src/examples/ctrlport/pfb_sync_test-qt.grc +++ b/gr-blocks/examples/ctrlport/pfb_sync_test-qt.grc @@ -1,46 +1,59 @@ <?xml version='1.0' encoding='ASCII'?> <flow_graph> - <timestamp>Fri Mar 15 17:32:55 2013</timestamp> + <timestamp>Sun Mar 17 21:00:28 2013</timestamp> <block> - <key>variable</key> + <key>options</key> <param> <key>id</key> - <value>sps</value> + <value>pfb_sync_test_qt</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>value</key> - <value>2</value> + <key>title</key> + <value></value> </param> <param> - <key>_coordinate</key> - <value>(105, 126)</value> + <key>author</key> + <value></value> </param> <param> - <key>_rotation</key> - <value>0</value> + <key>description</key> + <value></value> </param> - </block> - <block> - <key>variable</key> <param> - <key>id</key> - <value>samp_rate</value> + <key>window_size</key> + <value>1280,1024</value> </param> <param> - <key>_enabled</key> + <key>generate_options</key> + <value>qt_gui</value> + </param> + <param> + <key>category</key> + <value>Custom</value> + </param> + <param> + <key>run_options</key> + <value>prompt</value> + </param> + <param> + <key>run</key> <value>True</value> </param> <param> - <key>value</key> - <value>300000</value> + <key>max_nouts</key> + <value>0</value> + </param> + <param> + <key>realtime_scheduling</key> + <value></value> </param> <param> <key>_coordinate</key> - <value>(14, 124)</value> + <value>(10, 10)</value> </param> <param> <key>_rotation</key> @@ -48,22 +61,22 @@ </param> </block> <block> - <key>import</key> + <key>variable</key> <param> <key>id</key> - <value>import_0</value> + <value>sps</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>import</key> - <value>import random, math, cmath</value> + <key>value</key> + <value>2</value> </param> <param> <key>_coordinate</key> - <value>(14, 77)</value> + <value>(105, 126)</value> </param> <param> <key>_rotation</key> @@ -71,22 +84,22 @@ </param> </block> <block> - <key>ctrlport_monitor</key> + <key>variable</key> <param> <key>id</key> - <value>ctrlport_monitor_0</value> + <value>samp_rate</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>en</key> - <value>True</value> + <key>value</key> + <value>300000</value> </param> <param> <key>_coordinate</key> - <value>(175, 10)</value> + <value>(14, 124)</value> </param> <param> <key>_rotation</key> @@ -94,34 +107,22 @@ </param> </block> <block> - <key>gr_vector_source_x</key> + <key>import</key> <param> <key>id</key> - <value>gr_vector_source_x_0</value> + <value>import_0</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>type</key> - <value>byte</value> - </param> - <param> - <key>vector</key> - <value>0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50</value> - </param> - <param> - <key>repeat</key> - <value>True</value> - </param> - <param> - <key>vlen</key> - <value>1</value> + <key>import</key> + <value>import random, math, cmath</value> </param> <param> <key>_coordinate</key> - <value>(190, 71)</value> + <value>(14, 77)</value> </param> <param> <key>_rotation</key> @@ -460,7 +461,7 @@ </param> </block> <block> - <key>gr_ctrlport_probe2_c</key> + <key>blocks_ctrlport_probe2_c</key> <param> <key>id</key> <value>received_probe2</value> @@ -546,7 +547,7 @@ </param> </block> <block> - <key>gr_ctrlport_probe2_c</key> + <key>blocks_ctrlport_probe2_c</key> <param> <key>id</key> <value>time_probe2</value> @@ -659,10 +660,10 @@ </param> </block> <block> - <key>gr_null_sink</key> + <key>blocks_null_sink</key> <param> <key>id</key> - <value>gr_null_sink_0</value> + <value>blocks_null_sink_0</value> </param> <param> <key>_enabled</key> @@ -686,7 +687,7 @@ </param> </block> <block> - <key>gr_ctrlport_probe2_c</key> + <key>blocks_ctrlport_probe2_c</key> <param> <key>id</key> <value>phase_probe2</value> @@ -717,58 +718,61 @@ </param> </block> <block> - <key>options</key> + <key>blocks_vector_source_x</key> <param> <key>id</key> - <value>pfb_sync_test_qt</value> + <value>blocks_vector_source_x_0</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>title</key> - <value></value> + <key>type</key> + <value>byte</value> </param> <param> - <key>author</key> - <value></value> + <key>vector</key> + <value>(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50)</value> </param> <param> - <key>description</key> - <value></value> + <key>tags</key> + <value>[]</value> </param> <param> - <key>window_size</key> - <value>1280,1024</value> + <key>repeat</key> + <value>True</value> </param> <param> - <key>generate_options</key> - <value>qt_gui</value> + <key>vlen</key> + <value>1</value> </param> <param> - <key>category</key> - <value>Custom</value> + <key>_coordinate</key> + <value>(190, 71)</value> </param> <param> - <key>run_options</key> - <value>prompt</value> + <key>_rotation</key> + <value>0</value> </param> + </block> + <block> + <key>blocks_ctrlport_monitor</key> <param> - <key>run</key> - <value>True</value> + <key>id</key> + <value>blocks_ctrlport_monitor_0</value> </param> <param> - <key>max_nouts</key> - <value>0</value> + <key>_enabled</key> + <value>True</value> </param> <param> - <key>realtime_scheduling</key> - <value></value> + <key>en</key> + <value>True</value> </param> <param> <key>_coordinate</key> - <value>(10, 10)</value> + <value>(193, 7)</value> </param> <param> <key>_rotation</key> @@ -795,7 +799,7 @@ </connection> <connection> <source_block_id>digital_costas_loop_cc_0</source_block_id> - <sink_block_id>gr_null_sink_0</sink_block_id> + <sink_block_id>blocks_null_sink_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> @@ -824,7 +828,7 @@ <sink_key>0</sink_key> </connection> <connection> - <source_block_id>gr_vector_source_x_0</source_block_id> + <source_block_id>blocks_vector_source_x_0</source_block_id> <sink_block_id>blocks_packed_to_unpacked_xx_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> diff --git a/gnuradio-core/src/examples/ctrlport/pfb_sync_test.grc b/gr-blocks/examples/ctrlport/pfb_sync_test.grc index 5b0bfeb793..06692aad46 100644 --- a/gnuradio-core/src/examples/ctrlport/pfb_sync_test.grc +++ b/gr-blocks/examples/ctrlport/pfb_sync_test.grc @@ -1,6 +1,6 @@ <?xml version='1.0' encoding='ASCII'?> <flow_graph> - <timestamp>Thu Feb 21 19:08:39 2013</timestamp> + <timestamp>Sun Mar 17 21:01:36 2013</timestamp> <block> <key>options</key> <param> @@ -226,10 +226,10 @@ </param> </block> <block> - <key>gr_null_sink</key> + <key>blocks_null_sink</key> <param> <key>id</key> - <value>gr_null_sink_0</value> + <value>blocks_null_sink_0</value> </param> <param> <key>_enabled</key> @@ -500,29 +500,6 @@ </param> </block> <block> - <key>ctrlport_monitor</key> - <param> - <key>id</key> - <value>ctrlport_monitor_0</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>en</key> - <value>True</value> - </param> - <param> - <key>_coordinate</key> - <value>(228, 5)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> <key>blocks_file_source</key> <param> <key>id</key> @@ -623,6 +600,29 @@ <value>0</value> </param> </block> + <block> + <key>blocks_ctrlport_monitor</key> + <param> + <key>id</key> + <value>blocks_ctrlport_monitor_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>en</key> + <value>True</value> + </param> + <param> + <key>_coordinate</key> + <value>(229, 7)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> <connection> <source_block_id>blocks_throttle_0</source_block_id> <sink_block_id>digital_psk_mod_0</sink_block_id> @@ -637,7 +637,7 @@ </connection> <connection> <source_block_id>digital_costas_loop_cc_0</source_block_id> - <sink_block_id>gr_null_sink_0</sink_block_id> + <sink_block_id>blocks_null_sink_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> diff --git a/gr-blocks/examples/metadata/file_metadata_sink.grc b/gr-blocks/examples/metadata/file_metadata_sink.grc index 198b0725f9..4cda1eba39 100644 --- a/gr-blocks/examples/metadata/file_metadata_sink.grc +++ b/gr-blocks/examples/metadata/file_metadata_sink.grc @@ -1,6 +1,6 @@ <?xml version='1.0' encoding='ASCII'?> <flow_graph> - <timestamp>Fri Dec 14 17:09:06 2012</timestamp> + <timestamp>Sun Mar 17 20:44:09 2013</timestamp> <block> <key>options</key> <param> @@ -61,42 +61,77 @@ </param> </block> <block> - <key>gr_sig_source_x</key> + <key>variable_qtgui_range</key> <param> <key>id</key> - <value>gr_sig_source_x_0</value> + <value>qt_samp_rate</value> </param> <param> <key>_enabled</key> - <value>False</value> + <value>True</value> </param> <param> - <key>type</key> - <value>complex</value> + <key>label</key> + <value></value> </param> <param> - <key>samp_rate</key> + <key>value</key> <value>samp_rate</value> </param> <param> - <key>waveform</key> - <value>gr.GR_COS_WAVE</value> + <key>start</key> + <value>200000</value> </param> <param> - <key>freq</key> - <value>1000</value> + <key>stop</key> + <value>5000000</value> </param> <param> - <key>amp</key> - <value>1</value> + <key>step</key> + <value>200000</value> </param> <param> - <key>offset</key> + <key>widget</key> + <value>counter_slider</value> + </param> + <param> + <key>orient</key> + <value>Qt.Horizontal</value> + </param> + <param> + <key>min_len</key> + <value>200</value> + </param> + <param> + <key>gui_hint</key> + <value></value> + </param> + <param> + <key>_coordinate</key> + <value>(330, 259)</value> + </param> + <param> + <key>_rotation</key> <value>0</value> </param> + </block> + <block> + <key>variable</key> + <param> + <key>id</key> + <value>samp_rate</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>200000</value> + </param> <param> <key>_coordinate</key> - <value>(57, 140)</value> + <value>(208, 11)</value> </param> <param> <key>_rotation</key> @@ -104,54 +139,54 @@ </param> </block> <block> - <key>variable_qtgui_range</key> + <key>blocks_file_meta_sink</key> <param> <key>id</key> - <value>qt_samp_rate</value> + <value>blocks_file_meta_sink_0</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>label</key> - <value></value> + <key>file</key> + <value>/tmp/metadat_file.out</value> </param> <param> - <key>value</key> - <value>samp_rate</value> + <key>type</key> + <value>complex</value> </param> <param> - <key>start</key> - <value>200000</value> + <key>samp_rate</key> + <value>samp_rate</value> </param> <param> - <key>stop</key> - <value>5000000</value> + <key>rel_rate</key> + <value>1</value> </param> <param> - <key>step</key> - <value>200000</value> + <key>vlen</key> + <value>1</value> </param> <param> - <key>widget</key> - <value>counter_slider</value> + <key>max_seg_size</key> + <value>1000000</value> </param> <param> - <key>orient</key> - <value>Qt.Horizontal</value> + <key>extra_dict</key> + <value>""</value> </param> <param> - <key>min_len</key> - <value>200</value> + <key>detached</key> + <value>True</value> </param> <param> - <key>gui_hint</key> - <value></value> + <key>unbuffered</key> + <value>False</value> </param> <param> <key>_coordinate</key> - <value>(330, 259)</value> + <value>(569, 124)</value> </param> <param> <key>_rotation</key> @@ -159,22 +194,30 @@ </param> </block> <block> - <key>variable</key> + <key>blocks_head</key> <param> <key>id</key> - <value>samp_rate</value> + <value>blocks_head_0</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>value</key> - <value>200000</value> + <key>type</key> + <value>complex</value> + </param> + <param> + <key>num_items</key> + <value>20000000</value> + </param> + <param> + <key>vlen</key> + <value>1</value> </param> <param> <key>_coordinate</key> - <value>(208, 11)</value> + <value>(309, 172)</value> </param> <param> <key>_rotation</key> @@ -189,7 +232,7 @@ </param> <param> <key>_enabled</key> - <value>True</value> + <value>False</value> </param> <param> <key>type</key> @@ -845,10 +888,10 @@ </param> </block> <block> - <key>gr_head</key> + <key>analog_sig_source_x</key> <param> <key>id</key> - <value>gr_head_0</value> + <value>analog_sig_source_x_0</value> </param> <param> <key>_enabled</key> @@ -859,71 +902,28 @@ <value>complex</value> </param> <param> - <key>num_items</key> - <value>20000000</value> - </param> - <param> - <key>vlen</key> - <value>1</value> - </param> - <param> - <key>_coordinate</key> - <value>(309, 172)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>blocks_file_meta_sink</key> - <param> - <key>id</key> - <value>blocks_file_meta_sink_0</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>file</key> - <value>/tmp/metadat_file.out</value> - </param> - <param> - <key>type</key> - <value>complex</value> - </param> - <param> <key>samp_rate</key> <value>samp_rate</value> </param> <param> - <key>rel_rate</key> - <value>1</value> - </param> - <param> - <key>vlen</key> - <value>1</value> - </param> - <param> - <key>max_seg_size</key> - <value>1000000</value> + <key>waveform</key> + <value>analog.GR_COS_WAVE</value> </param> <param> - <key>extra_dict</key> - <value>""</value> + <key>freq</key> + <value>1000</value> </param> <param> - <key>detached</key> - <value>True</value> + <key>amp</key> + <value>1</value> </param> <param> - <key>unbuffered</key> - <value>False</value> + <key>offset</key> + <value>0</value> </param> <param> <key>_coordinate</key> - <value>(569, 124)</value> + <value>(48, 115)</value> </param> <param> <key>_rotation</key> @@ -931,20 +931,20 @@ </param> </block> <connection> - <source_block_id>gr_sig_source_x_0</source_block_id> - <sink_block_id>gr_head_0</sink_block_id> + <source_block_id>uhd_usrp_source_0</source_block_id> + <sink_block_id>blocks_head_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>uhd_usrp_source_0</source_block_id> - <sink_block_id>gr_head_0</sink_block_id> + <source_block_id>blocks_head_0</source_block_id> + <sink_block_id>blocks_file_meta_sink_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>gr_head_0</source_block_id> - <sink_block_id>blocks_file_meta_sink_0</sink_block_id> + <source_block_id>analog_sig_source_x_0</source_block_id> + <sink_block_id>blocks_head_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> diff --git a/gr-blocks/examples/metadata/file_metadata_vector_sink.grc b/gr-blocks/examples/metadata/file_metadata_vector_sink.grc index 05b7cbc922..ebc4812e56 100644 --- a/gr-blocks/examples/metadata/file_metadata_vector_sink.grc +++ b/gr-blocks/examples/metadata/file_metadata_vector_sink.grc @@ -84,10 +84,10 @@ </param> </block> <block> - <key>gr_vector_source_x</key> + <key>blocks_vector_source_x</key> <param> <key>id</key> - <value>gr_vector_source_x_0</value> + <value>blocks_vector_source_x_0</value> </param> <param> <key>_enabled</key> @@ -119,10 +119,10 @@ </param> </block> <block> - <key>gr_head</key> + <key>blocks_head</key> <param> <key>id</key> - <value>gr_head_0</value> + <value>blocks_head_0</value> </param> <param> <key>_enabled</key> @@ -205,13 +205,13 @@ </param> </block> <connection> - <source_block_id>gr_vector_source_x_0</source_block_id> - <sink_block_id>gr_head_0</sink_block_id> + <source_block_id>blocks_vector_source_x_0</source_block_id> + <sink_block_id>blocks_head_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>gr_head_0</source_block_id> + <source_block_id>blocks_head_0</source_block_id> <sink_block_id>blocks_file_meta_sink_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> diff --git a/gr-blocks/examples/msg_passing/strobe.grc b/gr-blocks/examples/msg_passing/strobe.grc index d9d4ce43cb..e5001a4262 100644 --- a/gr-blocks/examples/msg_passing/strobe.grc +++ b/gr-blocks/examples/msg_passing/strobe.grc @@ -1,46 +1,59 @@ <?xml version='1.0' encoding='ASCII'?> <flow_graph> - <timestamp>Thu Dec 6 11:33:08 2012</timestamp> + <timestamp>Sun Mar 17 20:42:59 2013</timestamp> <block> - <key>variable</key> + <key>options</key> <param> <key>id</key> - <value>samp_rate</value> + <value>strobe</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>value</key> - <value>32000</value> + <key>title</key> + <value></value> </param> <param> - <key>_coordinate</key> - <value>(10, 170)</value> + <key>author</key> + <value></value> </param> <param> - <key>_rotation</key> - <value>0</value> + <key>description</key> + <value></value> </param> - </block> - <block> - <key>gr_pdu_to_tagged_stream</key> <param> - <key>id</key> - <value>gr_pdu_to_tagged_stream_0</value> + <key>window_size</key> + <value>1280, 1024</value> </param> <param> - <key>_enabled</key> + <key>generate_options</key> + <value>no_gui</value> + </param> + <param> + <key>category</key> + <value>Custom</value> + </param> + <param> + <key>run_options</key> + <value>prompt</value> + </param> + <param> + <key>run</key> <value>True</value> </param> <param> - <key>type</key> - <value>byte</value> + <key>max_nouts</key> + <value>0</value> + </param> + <param> + <key>realtime_scheduling</key> + <value></value> </param> <param> <key>_coordinate</key> - <value>(443, 89)</value> + <value>(10, 10)</value> </param> <param> <key>_rotation</key> @@ -48,18 +61,22 @@ </param> </block> <block> - <key>blocks_message_debug</key> + <key>variable</key> <param> <key>id</key> - <value>blocks_message_debug_0</value> + <value>samp_rate</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> + <key>value</key> + <value>32000</value> + </param> + <param> <key>_coordinate</key> - <value>(1049, 176)</value> + <value>(10, 170)</value> </param> <param> <key>_rotation</key> @@ -67,22 +84,18 @@ </param> </block> <block> - <key>gr_tagged_stream_to_pdu</key> + <key>blocks_message_debug</key> <param> <key>id</key> - <value>gr_tagged_stream_to_pdu_0</value> + <value>blocks_message_debug_0</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>type</key> - <value>byte</value> - </param> - <param> <key>_coordinate</key> - <value>(870, 89)</value> + <value>(1049, 176)</value> </param> <param> <key>_rotation</key> @@ -90,10 +103,10 @@ </param> </block> <block> - <key>gr_kludge_copy</key> + <key>blocks_pdu_to_tagged_stream</key> <param> <key>id</key> - <value>gr_kludge_copy_0</value> + <value>blocks_pdu_to_tagged_stream_0</value> </param> <param> <key>_enabled</key> @@ -104,16 +117,8 @@ <value>byte</value> </param> <param> - <key>num_ports</key> - <value>1</value> - </param> - <param> - <key>vlen</key> - <value>1</value> - </param> - <param> <key>_coordinate</key> - <value>(686, 89)</value> + <value>(388, 85)</value> </param> <param> <key>_rotation</key> @@ -124,7 +129,7 @@ <key>blocks_message_strobe</key> <param> <key>id</key> - <value>blocks_message_strobe_0</value> + <value>blocks_message_strobe_0_0</value> </param> <param> <key>_enabled</key> @@ -132,15 +137,15 @@ </param> <param> <key>msg</key> - <value>pmt.intern("TEST")</value> + <value>pmt.cons( pmt.PMT_NIL, pmt.make_u8vector(512,0) )</value> </param> <param> <key>period</key> - <value>1000</value> + <value>750</value> </param> <param> <key>_coordinate</key> - <value>(423, 177)</value> + <value>(95, 95)</value> </param> <param> <key>_rotation</key> @@ -148,26 +153,30 @@ </param> </block> <block> - <key>blocks_message_strobe</key> + <key>blocks_copy</key> <param> <key>id</key> - <value>blocks_message_strobe_0_0</value> + <value>blocks_copy_0</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>msg</key> - <value>pmt.cons( pmt.PMT_NIL, pmt.make_u8vector(512,0) )</value> + <key>type</key> + <value>byte</value> </param> <param> - <key>period</key> - <value>750</value> + <key>enabled</key> + <value>True</value> + </param> + <param> + <key>vlen</key> + <value>1</value> </param> <param> <key>_coordinate</key> - <value>(99, 85)</value> + <value>(629, 81)</value> </param> <param> <key>_rotation</key> @@ -175,58 +184,49 @@ </param> </block> <block> - <key>options</key> + <key>blocks_tagged_stream_to_pdu</key> <param> <key>id</key> - <value>strobe</value> + <value>blocks_tagged_stream_to_pdu_0</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>title</key> - <value></value> - </param> - <param> - <key>author</key> - <value></value> - </param> - <param> - <key>description</key> - <value></value> - </param> - <param> - <key>window_size</key> - <value>1280, 1024</value> + <key>type</key> + <value>byte</value> </param> <param> - <key>generate_options</key> - <value>no_gui</value> + <key>_coordinate</key> + <value>(837, 47)</value> </param> <param> - <key>category</key> - <value>Custom</value> + <key>_rotation</key> + <value>0</value> </param> + </block> + <block> + <key>blocks_message_strobe</key> <param> - <key>run_options</key> - <value>prompt</value> + <key>id</key> + <value>blocks_message_strobe_0</value> </param> <param> - <key>run</key> + <key>_enabled</key> <value>True</value> </param> <param> - <key>max_nouts</key> - <value>0</value> + <key>msg</key> + <value>pmt.intern("TEST")</value> </param> <param> - <key>realtime_scheduling</key> - <value></value> + <key>period</key> + <value>1000</value> </param> <param> <key>_coordinate</key> - <value>(10, 10)</value> + <value>(423, 164)</value> </param> <param> <key>_rotation</key> @@ -234,32 +234,32 @@ </param> </block> <connection> - <source_block_id>blocks_message_strobe_0_0</source_block_id> - <sink_block_id>gr_pdu_to_tagged_stream_0</sink_block_id> + <source_block_id>blocks_message_strobe_0</source_block_id> + <sink_block_id>blocks_message_debug_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>blocks_message_strobe_0</source_block_id> - <sink_block_id>blocks_message_debug_0</sink_block_id> + <source_block_id>blocks_message_strobe_0_0</source_block_id> + <sink_block_id>blocks_pdu_to_tagged_stream_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>gr_tagged_stream_to_pdu_0</source_block_id> + <source_block_id>blocks_tagged_stream_to_pdu_0</source_block_id> <sink_block_id>blocks_message_debug_0</sink_block_id> <source_key>0</source_key> - <sink_key>0</sink_key> + <sink_key>2</sink_key> </connection> <connection> - <source_block_id>gr_kludge_copy_0</source_block_id> - <sink_block_id>gr_tagged_stream_to_pdu_0</sink_block_id> + <source_block_id>blocks_copy_0</source_block_id> + <sink_block_id>blocks_tagged_stream_to_pdu_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>gr_pdu_to_tagged_stream_0</source_block_id> - <sink_block_id>gr_kludge_copy_0</sink_block_id> + <source_block_id>blocks_pdu_to_tagged_stream_0</source_block_id> + <sink_block_id>blocks_copy_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> diff --git a/gr-blocks/examples/tags/test_file_tags.py b/gr-blocks/examples/tags/test_file_tags.py index 92112325b2..cc11cf594e 100755 --- a/gr-blocks/examples/tags/test_file_tags.py +++ b/gr-blocks/examples/tags/test_file_tags.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2011 Free Software Foundation, Inc. +# Copyright 2011,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -34,12 +34,12 @@ def main(): data = scipy.arange(0, 32000, 1).tolist() trig = 100*[0,] + 100*[1,] - src = gr.vector_source_s(data, True) - trigger = gr.vector_source_s(trig, True) + src = blocks.vector_source_s(data, True) + trigger = blocks.vector_source_s(trig, True) thr = blocks.throttle(gr.sizeof_short, 10e3) - ann = gr.annotator_alltoall(1000000, gr.sizeof_short) - tagger = blocks..burst_tagger(gr.sizeof_short) + ann = blocks.annotator_alltoall(1000000, gr.sizeof_short) + tagger = blocks.burst_tagger(gr.sizeof_short) fsnk = blocks.tagged_file_sink(gr.sizeof_short, 1) diff --git a/gr-blocks/grc/CMakeLists.txt b/gr-blocks/grc/CMakeLists.txt index ed66d9e3b2..48cdd5859a 100644 --- a/gr-blocks/grc/CMakeLists.txt +++ b/gr-blocks/grc/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2012 Free Software Foundation, Inc. +# Copyright 2012-2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -19,4 +19,14 @@ ######################################################################## file(GLOB xml_files "*.xml") + +# Force out the controlport GRC blocks if we've disabled it. +if(NOT ENABLE_GR_CTRLPORT) + list(REMOVE_ITEM xml_files + ${CMAKE_CURRENT_SOURCE_DIR}/ctrlport_viewer.xml + ${CMAKE_CURRENT_SOURCE_DIR}/ctrlport_probe_c.xml + ${CMAKE_CURRENT_SOURCE_DIR}/ctrlport_probe2_c.xml + ) +endif(NOT ENABLE_GR_CTRLPORT) + install(FILES ${xml_files} DESTINATION ${GRC_BLOCKS_DIR} COMPONENT "blocks_python") diff --git a/gr-blocks/grc/blocks_block_tree.xml b/gr-blocks/grc/blocks_block_tree.xml index 90d94bdb29..face908df0 100644 --- a/gr-blocks/grc/blocks_block_tree.xml +++ b/gr-blocks/grc/blocks_block_tree.xml @@ -39,6 +39,8 @@ <block>blocks_message_burst_source</block> <block>blocks_udp_source</block> <block>blocks_wavfile_source</block> + <block>blocks_vector_source_x</block> + <block>blocks_null_source</block> </cat> <cat> <name>Sinks (New)</name> @@ -51,6 +53,8 @@ <block>blocks_tagged_file_sink</block> <block>blocks_udp_sink</block> <block>blocks_wavfile_sink</block> + <block>blocks_vector_sink_x</block> + <block>blocks_null_sink</block> </cat> <cat> <name>Math Operations (New) </name> @@ -123,6 +127,8 @@ <block>blocks_stretch_ff</block> <block>blocks_threshold_ff</block> <block>blocks_burst_tagger</block> + <block>blocks_endian_swap</block> + <block>blocks_vector_insert_x</block> </cat> <cat> <name>Misc Conversions (New) </name> @@ -135,6 +141,10 @@ <name>Misc (New) </name> <block>blocks_throttle</block> <block>blocks_probe_rate</block> + <block>blocks_head</block> + <block>blocks_skiphead</block> + <block>blocks_copy</block> + <block>blocks_nop</block> </cat> <cat> <name>Networking</name> diff --git a/grc/blocks/gr_copy.xml b/gr-blocks/grc/blocks_copy.xml index 8b12eaca78..55c4b343d3 100644 --- a/grc/blocks/gr_copy.xml +++ b/gr-blocks/grc/blocks_copy.xml @@ -6,9 +6,9 @@ --> <block> <name>Copy</name> - <key>gr_copy</key> - <import>from gnuradio import gr</import> - <make>gr.copy($type.size*$vlen) + <key>blocks_copy</key> + <import>from gnuradio import blocks</import> + <make>blocks.copy($type.size*$vlen) self.$(id).set_enabled($enabled)</make> <callback>set_enabled($enabled)</callback> <param> diff --git a/grc/blocks/gr_ctrlport_probe2_c.xml b/gr-blocks/grc/blocks_ctrlport_probe2_c.xml index bdf77084dd..34f6dc0f50 100644 --- a/grc/blocks/gr_ctrlport_probe2_c.xml +++ b/gr-blocks/grc/blocks_ctrlport_probe2_c.xml @@ -23,10 +23,10 @@ <block> <name>Ctrlport Complex Probe (fixed len)</name> - <key>gr_ctrlport_probe2_c</key> + <key>blocks_ctrlport_probe2_c</key> <category>Control Port</category> - <import>from gnuradio import gr</import> - <make>gr.ctrlport_probe2_c($name, $desc, $len)</make> + <import>from gnuradio import blocks</import> + <make>blocks.ctrlport_probe2_c($name, $desc, $len)</make> <callback>set_length($len)</callback> <param> diff --git a/grc/blocks/gr_ctrlport_probe_c.xml b/gr-blocks/grc/blocks_ctrlport_probe_c.xml index 17cfdd1466..3b17823931 100644 --- a/grc/blocks/gr_ctrlport_probe_c.xml +++ b/gr-blocks/grc/blocks_ctrlport_probe_c.xml @@ -23,10 +23,10 @@ <block> <name>Ctrlport Complex Probe</name> - <key>gr_ctrlport_probe_c</key> + <key>blocks_ctrlport_probe_c</key> <category>Control Port</category> - <import>from gnuradio import gr</import> - <make>gr.ctrlport_probe_c($name, $desc)</make> + <import>from gnuradio import blocks</import> + <make>blocks.ctrlport_probe_c($name, $desc)</make> <param> <name>Name</name> diff --git a/grc/blocks/gr_ctrlport_viewer.xml b/gr-blocks/grc/blocks_ctrlport_viewer.xml index e7d8d4c2d4..99abd6d4bd 100644 --- a/grc/blocks/gr_ctrlport_viewer.xml +++ b/gr-blocks/grc/blocks_ctrlport_viewer.xml @@ -23,7 +23,7 @@ <block> <name>CtrlPort Monitor</name> - <key>ctrlport_monitor</key> + <key>blocks_ctrlport_monitor</key> <category>Control Port</category> <import>from gnuradio.ctrlport.monitor import *</import> <make>not $en or monitor()</make> diff --git a/grc/blocks/gr_endian_swap.xml b/gr-blocks/grc/blocks_endian_swap.xml index aa564026cd..5fea420664 100644 --- a/grc/blocks/gr_endian_swap.xml +++ b/gr-blocks/grc/blocks_endian_swap.xml @@ -7,9 +7,9 @@ --> <block> <name>Endian Swap</name> - <key>gr_endian_swap</key> - <import>from gnuradio import gr</import> - <make>gr.endian_swap($type.size)</make> + <key>blocks_endian_swap</key> + <import>from gnuradio import blocks</import> + <make>blocks.endian_swap($type.size)</make> <param> <name>IO Type</name> <key>type</key> diff --git a/grc/blocks/gr_head.xml b/gr-blocks/grc/blocks_head.xml index e5ff7f6aad..8b6e67820c 100644 --- a/grc/blocks/gr_head.xml +++ b/gr-blocks/grc/blocks_head.xml @@ -6,9 +6,9 @@ --> <block> <name>Head</name> - <key>gr_head</key> - <import>from gnuradio import gr</import> - <make>gr.head($type.size*$vlen, $num_items)</make> + <key>blocks_head</key> + <import>from gnuradio import blocks</import> + <make>blocks.head($type.size*$vlen, $num_items)</make> <param> <name>Type</name> <key>type</key> diff --git a/grc/blocks/gr_nop.xml b/gr-blocks/grc/blocks_nop.xml index bd884d6b8b..d38c23839d 100644 --- a/grc/blocks/gr_nop.xml +++ b/gr-blocks/grc/blocks_nop.xml @@ -6,9 +6,9 @@ --> <block> <name>Nop</name> - <key>gr_nop</key> - <import>from gnuradio import gr</import> - <make>gr.nop($type.size*$vlen)</make> + <key>blocks_nop</key> + <import>from gnuradio import blocks</import> + <make>blocks.nop($type.size*$vlen)</make> <param> <name>Type</name> <key>type</key> diff --git a/grc/blocks/gr_null_sink.xml b/gr-blocks/grc/blocks_null_sink.xml index ed106b4950..2ae20e619a 100644 --- a/grc/blocks/gr_null_sink.xml +++ b/gr-blocks/grc/blocks_null_sink.xml @@ -6,9 +6,9 @@ --> <block> <name>Null Sink</name> - <key>gr_null_sink</key> - <import>from gnuradio import gr</import> - <make>gr.null_sink($type.size*$vlen)</make> + <key>blocks_null_sink</key> + <import>from gnuradio import blocks</import> + <make>blocks.null_sink($type.size*$vlen)</make> <param> <name>Input Type</name> <key>type</key> diff --git a/grc/blocks/gr_null_source.xml b/gr-blocks/grc/blocks_null_source.xml index 6132eae3cb..01d3905cab 100644 --- a/grc/blocks/gr_null_source.xml +++ b/gr-blocks/grc/blocks_null_source.xml @@ -6,9 +6,9 @@ --> <block> <name>Null Source</name> - <key>gr_null_source</key> - <import>from gnuradio import gr</import> - <make>gr.null_source($type.size*$vlen)</make> + <key>blocks_null_source</key> + <import>from gnuradio import blocks</import> + <make>blocks.null_source($type.size*$vlen)</make> <param> <name>Output Type</name> <key>type</key> diff --git a/grc/blocks/gr_skiphead.xml b/gr-blocks/grc/blocks_skiphead.xml index 0849ad2981..7d90862830 100644 --- a/grc/blocks/gr_skiphead.xml +++ b/gr-blocks/grc/blocks_skiphead.xml @@ -6,9 +6,9 @@ --> <block> <name>Skip Head</name> - <key>gr_skiphead</key> - <import>from gnuradio import gr</import> - <make>gr.skiphead($type.size*$vlen, $num_items)</make> + <key>blocks_skiphead</key> + <import>from gnuradio import blocks</import> + <make>blocks.skiphead($type.size*$vlen, $num_items)</make> <param> <name>Type</name> <key>type</key> diff --git a/grc/blocks/gr_vector_insert_x.xml b/gr-blocks/grc/blocks_vector_insert_x.xml index f9ce1f6544..2bc7ada2e6 100644 --- a/grc/blocks/gr_vector_insert_x.xml +++ b/gr-blocks/grc/blocks_vector_insert_x.xml @@ -6,9 +6,9 @@ --> <block> <name>Vector Insert</name> - <key>gr_vector_insert_x</key> - <import>from gnuradio import gr</import> - <make>gr.vector_insert_$(type.fcn)($vector, $period, $offset)</make> + <key>blocks_vector_insert_x</key> + <import>from gnuradio import blocks</import> + <make>blocks.vector_insert_$(type.fcn)($vector, $period, $offset)</make> <param> <name>Output Type</name> <key>type</key> diff --git a/grc/blocks/gr_vector_sink_x.xml b/gr-blocks/grc/blocks_vector_sink_x.xml index 3bd998698f..7f51731975 100644 --- a/grc/blocks/gr_vector_sink_x.xml +++ b/gr-blocks/grc/blocks_vector_sink_x.xml @@ -6,9 +6,9 @@ --> <block> <name>Vector Sink</name> - <key>gr_vector_sink_x</key> - <import>from gnuradio import gr</import> - <make>gr.vector_sink_$(type.fcn)($vlen)</make> + <key>blocks_vector_sink_x</key> + <import>from gnuradio import blocks</import> + <make>blocks.vector_sink_$(type.fcn)($vlen)</make> <param> <name>Input Type</name> <key>type</key> diff --git a/grc/blocks/gr_vector_source_x.xml b/gr-blocks/grc/blocks_vector_source_x.xml index 992a6a787d..6de3f5b184 100644 --- a/grc/blocks/gr_vector_source_x.xml +++ b/gr-blocks/grc/blocks_vector_source_x.xml @@ -6,10 +6,9 @@ --> <block> <name>Vector Source</name> - <key>gr_vector_source_x</key> - <import>from gnuradio import gr</import> - <make>gr.vector_source_$(type.fcn)($vector, $repeat, $vlen, $tags) - </make> + <key>blocks_vector_source_x</key> + <import>from gnuradio import blocks</import> + <make>blocks.vector_source_$(type.fcn)($vector, $repeat, $vlen, $tags)</make> <param> <name>Output Type</name> <key>type</key> @@ -48,7 +47,7 @@ <param> <name>Vector</name> <key>vector</key> - <value>0, 0, 0</value> + <value>(0, 0, 0)</value> <type>raw</type> </param> <param> diff --git a/gr-blocks/include/blocks/CMakeLists.txt b/gr-blocks/include/blocks/CMakeLists.txt index 0f158ff473..a88eaeeb26 100644 --- a/gr-blocks/include/blocks/CMakeLists.txt +++ b/gr-blocks/include/blocks/CMakeLists.txt @@ -88,6 +88,9 @@ expand_h(sub_XX ss ii ff cc) expand_h(xor_XX bb ss ii) expand_h(packed_to_unpacked_XX bb ss ii) expand_h(unpacked_to_packed_XX bb ss ii) +expand_h(vector_insert_X b s i f c) +expand_h(vector_sink_X b s i f c) +expand_h(vector_source_X b s i f c) add_custom_target(blocks_generated_includes DEPENDS ${generated_includes} @@ -102,18 +105,20 @@ install(FILES control_loop.h count_bits.h file_sink_base.h - fxpt.h - fxpt_nco.h - fxpt_vco.h + lfsr_15_1_0.h + lfsr_32k.h log2_const.h - nco.h - vco.h + rotator.h wavfile.h add_ff.h + annotator_1to1.h + annotator_alltoall.h + annotator_raw.h bin_statistics_f.h burst_tagger.h char_to_float.h char_to_short.h + check_lfsr_32k_s.h complex_to_interleaved_short.h complex_to_float.h complex_to_imag.h @@ -122,8 +127,10 @@ install(FILES complex_to_mag_squared.h complex_to_arg.h conjugate_cc.h + copy.h deinterleave.h delay.h + endian_swap.h file_source.h file_meta_sink.h file_meta_source.h @@ -132,6 +139,7 @@ install(FILES float_to_int.h float_to_short.h float_to_uchar.h + head.h int_to_float.h interleave.h interleaved_short_to_complex.h @@ -148,6 +156,9 @@ install(FILES multiply_const_cc.h multiply_const_ff.h nlog10_ff.h + nop.h + null_sink.h + null_source.h pack_k_bits_bb.h patterned_interleaver.h pdu.h @@ -162,6 +173,7 @@ install(FILES rms_ff.h short_to_char.h short_to_float.h + skiphead.h socket_pdu.h stream_mux.h stream_to_streams.h @@ -182,6 +194,7 @@ install(FILES udp_source.h unpack_k_bits_bb.h vco_f.h + vector_map.h vector_to_stream.h vector_to_streams.h wavfile_sink.h @@ -189,3 +202,12 @@ install(FILES DESTINATION ${GR_INCLUDE_DIR}/gnuradio/blocks COMPONENT "blocks_devel" ) + +if(ENABLE_GR_CTRLPORT) +install(FILES + ctrlport_probe_c.h + ctrlport_probe2_c.h + DESTINATION ${GR_INCLUDE_DIR}/gnuradio/blocks + COMPONENT "blocks_devel" +) +endif(ENABLE_GR_CTRLPORT) diff --git a/gr-blocks/include/blocks/annotator_1to1.h b/gr-blocks/include/blocks/annotator_1to1.h new file mode 100644 index 0000000000..6cc8db6eef --- /dev/null +++ b/gr-blocks/include/blocks/annotator_1to1.h @@ -0,0 +1,60 @@ +/* -*- c++ -*- */ +/* + * Copyright 2010,2013 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 <blocks/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace blocks { + + /*! + * \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 BLOCKS_API annotator_1to1 : virtual public gr_sync_block + { + public: + // gr::blocks::annotator_1to1::sptr + typedef boost::shared_ptr<annotator_1to1> sptr; + + static sptr make(int when, size_t sizeof_stream_item); + + virtual std::vector<gr_tag_t> data() const = 0; + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_ANNOTATOR_1TO1_H */ diff --git a/gr-blocks/include/blocks/annotator_alltoall.h b/gr-blocks/include/blocks/annotator_alltoall.h new file mode 100644 index 0000000000..558aea69ca --- /dev/null +++ b/gr-blocks/include/blocks/annotator_alltoall.h @@ -0,0 +1,61 @@ +/* -*- c++ -*- */ +/* + * Copyright 2010,2013 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 <blocks/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace blocks { + + /*! + * \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 BLOCKS_API annotator_alltoall : virtual public gr_sync_block + { + public: + // gr::blocks::annotator_alltoall::sptr + typedef boost::shared_ptr<annotator_alltoall> sptr; + + static sptr make(int when, size_t sizeof_stream_item); + + virtual std::vector<gr_tag_t> data() const = 0; + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_ANNOTATOR_ALLTOALL_H */ diff --git a/gr-blocks/include/blocks/annotator_raw.h b/gr-blocks/include/blocks/annotator_raw.h new file mode 100644 index 0000000000..ae273c2a46 --- /dev/null +++ b/gr-blocks/include/blocks/annotator_raw.h @@ -0,0 +1,57 @@ +/* -*- c++ -*- */ +/* + * Copyright 2010,2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_GR_ANNOTATOR_RAW_H +#define INCLUDED_GR_ANNOTATOR_RAW_H + +#include <blocks/api.h> +#include <gr_sync_block.h> +#include <gr_tags.h> + +namespace gr { + namespace blocks { + + /*! + * \brief raw stream annotator testing block. + * + * This block creates arbitrary tags to be sent downstream blocks + * to be sent are set manually via accessor methods and are sent + * only once. + * + * This block is intended for testing of tag related blocks + */ + class BLOCKS_API annotator_raw : virtual public gr_sync_block + { + public: + // gr::blocks::annotator_raw::sptr + typedef boost::shared_ptr<annotator_raw> sptr; + + static sptr make(size_t sizeof_stream_item); + + // insert a tag to be added + virtual void add_tag(uint64_t offset, pmt::pmt_t key, pmt::pmt_t val) = 0; + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_ANNOTATOR_RAW_H */ diff --git a/gr-blocks/include/blocks/check_lfsr_32k_s.h b/gr-blocks/include/blocks/check_lfsr_32k_s.h new file mode 100644 index 0000000000..4eba436e80 --- /dev/null +++ b/gr-blocks/include/blocks/check_lfsr_32k_s.h @@ -0,0 +1,56 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2013 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_CHECK_LFSR_32K_S_H +#define INCLUDED_GR_CHECK_LFSR_32K_S_H + +#include <blocks/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace blocks { + + /*! + * \brief sink that checks if its input stream consists of a lfsr_32k sequence. + * \ingroup sink_blk + * + * This sink is typically used along with + * gr::blocks::lfsr_32k_source_s to test the USRP using its + * digital loopback mode. + */ + class BLOCKS_API check_lfsr_32k_s : virtual public gr_sync_block + { + public: + // gr::blocks::check_lfsr_32k_s::sptr + typedef boost::shared_ptr<check_lfsr_32k_s> sptr; + + static sptr make(); + + virtual long ntotal () const = 0; + virtual long nright () const = 0; + virtual long runlength () const = 0; + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_CHECK_LFSR_32K_S_H */ diff --git a/gr-blocks/include/blocks/control_loop.h b/gr-blocks/include/blocks/control_loop.h index 475b28f944..7c09f5915b 100644 --- a/gr-blocks/include/blocks/control_loop.h +++ b/gr-blocks/include/blocks/control_loop.h @@ -99,7 +99,7 @@ namespace gr { * * \param bw (float) new bandwidth */ - void set_loop_bandwidth(float bw); + virtual void set_loop_bandwidth(float bw); /*! * \brief Set the loop damping factor diff --git a/gr-blocks/include/blocks/copy.h b/gr-blocks/include/blocks/copy.h new file mode 100644 index 0000000000..5ed0ea0e92 --- /dev/null +++ b/gr-blocks/include/blocks/copy.h @@ -0,0 +1,54 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006,2009,2013 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_COPY_H +#define INCLUDED_GR_COPY_H + +#include <blocks/api.h> +#include <gr_block.h> + +namespace gr { + namespace blocks { + + /*! + * \brief output[i] = input[i] + * \ingroup misc_blk + * + * When enabled (default), this block copies its input to its + * output. When disabled, this block drops its input on the floor. + */ + class BLOCKS_API copy : virtual public gr_block + { + public: + // gr::blocks::copy::sptr + typedef boost::shared_ptr<copy> sptr; + + static sptr make(size_t itemsize); + + virtual void set_enabled(bool enable) = 0; + virtual bool enabled() const = 0; + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_COPY_H */ diff --git a/gr-blocks/include/blocks/ctrlport_probe2_c.h b/gr-blocks/include/blocks/ctrlport_probe2_c.h new file mode 100644 index 0000000000..9a6034fcca --- /dev/null +++ b/gr-blocks/include/blocks/ctrlport_probe2_c.h @@ -0,0 +1,64 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012-2013 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_CTRLPORT_PROBE2_C_H +#define INCLUDED_CTRLPORT_PROBE2_C_H + +#include <blocks/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace blocks { + + /*! + * \brief A ControlPort probe to export vectors of signals. + * + * This block acts as a sink in the flowgraph but also exports + * vectors of complex samples over ControlPort. This block holds + * the latest \p len number of complex samples so that every query + * by a ControlPort client will get the same length vector. + */ + class BLOCKS_API ctrlport_probe2_c : virtual public gr_sync_block + { + public: + // gr::blocks::ctrlport_probe2_c::sptr + typedef boost::shared_ptr<ctrlport_probe2_c> sptr; + + /*! + * \brief Make a ControlPort probe block. + * \param id A string ID to name the probe over ControlPort. + * \param desc A string describing the probe. + * \param len Number of samples to transmit. + */ + static sptr make(const std::string &id, const std::string &desc, int len); + + virtual std::vector<gr_complex> get() = 0; + + virtual void set_length(int len) = 0; + virtual int length() const = 0; + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_CTRLPORT_PROBE2_C_H */ + diff --git a/gnuradio-core/src/lib/general/gr_ctrlport_probe_c.h b/gr-blocks/include/blocks/ctrlport_probe_c.h index 27666ab597..92fe8c5600 100644 --- a/gnuradio-core/src/lib/general/gr_ctrlport_probe_c.h +++ b/gr-blocks/include/blocks/ctrlport_probe_c.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2012 Free Software Foundation, Inc. + * Copyright 2012-2013 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -23,43 +23,40 @@ #ifndef INCLUDED_CTRLPORT_PROBE_C_H #define INCLUDED_CTRLPORT_PROBE_C_H -#include <gr_core_api.h> +#include <blocks/api.h> #include <gr_sync_block.h> #include <rpcregisterhelpers.h> #include <boost/thread/shared_mutex.hpp> -class gr_ctrlport_probe_c; -typedef boost::shared_ptr<gr_ctrlport_probe_c> gr_ctrlport_probe_c_sptr; - -GR_CORE_API gr_ctrlport_probe_c_sptr -gr_make_ctrlport_probe_c(const std::string &id, const std::string &desc); - -class GR_CORE_API gr_ctrlport_probe_c : public gr_sync_block -{ - private: - friend GR_CORE_API gr_ctrlport_probe_c_sptr gr_make_ctrlport_probe_c - (const std::string &id, const std::string &desc); - - gr_ctrlport_probe_c(const std::string &id, const std::string &desc); - - boost::shared_mutex ptrlock; - - std::string d_id; - std::string d_desc; - const gr_complex* d_ptr; - size_t d_ptrLen; - - public: - ~gr_ctrlport_probe_c(); - - void setup_rpc(); - - std::vector<gr_complex> get(); - - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; +namespace gr { + namespace blocks { + + /*! + * \brief A ControlPort probe to export vectors of signals. + * + * This block acts as a sink in the flowgraph but also exports + * vectors of complex samples over ControlPort. This block simply + * sends the current vector held in the work function when the + * queried by a ControlPort client. + */ + class BLOCKS_API ctrlport_probe_c : virtual public gr_sync_block + { + public: + // gr::blocks::ctrlport_probe_c::sptr + typedef boost::shared_ptr<ctrlport_probe_c> sptr; + + /*! + * \brief Make a ControlPort probe block. + * \param id A string ID to name the probe over ControlPort. + * \param desc A string describing the probe. + */ + static sptr make(const std::string &id, const std::string &desc); + + virtual std::vector<gr_complex> get() = 0; + }; + + } /* namespace blocks */ +} /* namespace gr */ #endif /* INCLUDED_CTRLPORT_GR_CTRLPORT_PROBE_C_H */ diff --git a/gnuradio-core/src/lib/general/gr_endian_swap.h b/gr-blocks/include/blocks/endian_swap.h index 0baa3f3389..4b5a76218e 100644 --- a/gnuradio-core/src/lib/general/gr_endian_swap.h +++ b/gr-blocks/include/blocks/endian_swap.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2012 Free Software Foundation, Inc. + * Copyright 2004,2012,2013 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -23,35 +23,28 @@ #ifndef INCLUDED_GR_ENDIAN_SWAP_H #define INCLUDED_GR_ENDIAN_SWAP_H -#include <gr_core_api.h> +#include <blocks/api.h> #include <gr_sync_block.h> -class gr_endian_swap; -typedef boost::shared_ptr<gr_endian_swap> gr_endian_swap_sptr; - -GR_CORE_API gr_endian_swap_sptr -gr_make_endian_swap (size_t item_size_bytes=1); - -/*! - * \brief Convert stream of items into thier byte swapped version - * - * \param item_size_bytes number of bytes per item, 1=no-op,2=uint16_t,4=uint32_t,8=uint64_t - */ - -class GR_CORE_API gr_endian_swap : public gr_sync_block -{ - private: - friend GR_CORE_API gr_endian_swap_sptr - gr_make_endian_swap (size_t item_size_bytes); - gr_endian_swap (size_t item_size_bytes); - - size_t item_size_bytes; - - public: - virtual int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - +namespace gr { + namespace blocks { + + /*! + * \brief Convert stream of items into thier byte swapped version + * + * \param item_size_bytes number of bytes per item, 1=no-op, + * 2=uint16_t, 4=uint32_t, 8=uint64_t + */ + class BLOCKS_API endian_swap : virtual public gr_sync_block + { + public: + // gr::blocks::endian_swap::sptr + typedef boost::shared_ptr<endian_swap> sptr; + + static sptr make(size_t item_size_bytes=1); + }; + + } /* namespace blocks */ +} /* namespace gr */ #endif /* INCLUDED_GR_ENDIAN_SWAP_H */ diff --git a/gr-blocks/include/blocks/fxpt.h b/gr-blocks/include/blocks/fxpt.h deleted file mode 100644 index 37938eb14a..0000000000 --- a/gr-blocks/include/blocks/fxpt.h +++ /dev/null @@ -1,112 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2013 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_FXPT_H -#define INCLUDED_GR_FXPT_H - -#include <blocks/api.h> -#include <stdint.h> -#include <cmath> - -namespace gr { - namespace blocks { - - /*! - * \brief fixed point sine and cosine and friends. - * \ingroup misc - * - * fixed pt radians - * --------- -------- - * -2**31 -pi - * 0 0 - * 2**31-1 pi - epsilon - * - */ - class BLOCKS_API fxpt - { - private: - static const int WORDBITS = 32; - static const int NBITS = 10; - static const float s_sine_table[1 << NBITS][2]; - static const float PI; - static const float TWO_TO_THE_31; - - public: - - static int32_t - float_to_fixed(float x) - { - // Fold x into -PI to PI. - int d = (int)floor(x/2/PI+0.5); - x -= d*2*PI; - // And convert to an integer. - return (int32_t)((float)x * TWO_TO_THE_31 / PI); - } - - static float - fixed_to_float(int32_t x) - { - return x * (PI / TWO_TO_THE_31); - } - - /*! - * \brief Given a fixed point angle x, return float sine (x) - */ - static float - sin(int32_t x) - { - uint32_t ux = x; - int index = ux >> (WORDBITS - NBITS); - return s_sine_table[index][0] * (ux >> 1) + s_sine_table[index][1]; - } - - /* - * \brief Given a fixed point angle x, return float cosine (x) - */ - static float - cos(int32_t x) - { - uint32_t ux = x + 0x40000000; - int index = ux >> (WORDBITS - NBITS); - return s_sine_table[index][0] * (ux >> 1) + s_sine_table[index][1]; - } - - /* - * \brief Given a fixedpoint angle x, return float cos(x) and sin (x) - */ - static void - sincos(int32_t x, float *s, float *c) - { - uint32_t ux = x; - int sin_index = ux >> (WORDBITS - NBITS); - *s = s_sine_table[sin_index][0] * (ux >> 1) + s_sine_table[sin_index][1]; - - ux = x + 0x40000000; - int cos_index = ux >> (WORDBITS - NBITS); - *c = s_sine_table[cos_index][0] * (ux >> 1) + s_sine_table[cos_index][1]; - } - }; - - } /* namespace blocks */ -} /* namespace gr */ - -#endif /* INCLUDED_GR_FXPT_H */ diff --git a/gr-blocks/include/blocks/fxpt_nco.h b/gr-blocks/include/blocks/fxpt_nco.h deleted file mode 100644 index 7db20fbb3a..0000000000 --- a/gr-blocks/include/blocks/fxpt_nco.h +++ /dev/null @@ -1,168 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002,2004,2013 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_FXPT_NCO_H -#define INCLUDED_GR_FXPT_NCO_H - -#include <blocks/api.h> -#include <blocks/fxpt.h> -#include <gr_complex.h> - -namespace gr { - namespace blocks { - - /*! - * \brief Numerically Controlled Oscillator (NCO) - * \ingroup misc - * - * Calculate sine and cosine based on the current phase. This - * class has multiple ways to calculate sin/cos and when - * requensting a range will increment the phase based on a - * frequency, which can be set using set_freq. Similar interfaces - * to the fxpt_vco can also be used to set or adjust the current - * phase. - */ - class fxpt_nco - { - private: - uint32_t d_phase; - int32_t d_phase_inc; - - public: - fxpt_nco() : d_phase(0), d_phase_inc(0) {} - - ~fxpt_nco() {} - - //! Set the current phase \p angle in radians - void set_phase(float angle) { - d_phase = fxpt::float_to_fixed(angle); - } - - //! Update the current phase in radians by \p delta_phase - void adjust_phase(float delta_phase) { - d_phase += fxpt::float_to_fixed(delta_phase); - } - - //! angle_rate is in radians / step - void set_freq(float angle_rate) { - d_phase_inc = fxpt::float_to_fixed(angle_rate); - } - - //! angle_rate is a delta in radians / step - void adjust_freq(float delta_angle_rate) { - d_phase_inc += fxpt::float_to_fixed(delta_angle_rate); - } - - //! increment current phase angle - void step() { - d_phase += d_phase_inc; - } - - //! increment current phase angle n times - void step(int n) { - d_phase += d_phase_inc * n; - } - - //! units are radians / step - float get_phase() const { return fxpt::fixed_to_float(d_phase); } - float get_freq() const { return fxpt::fixed_to_float(d_phase_inc); } - - //! compute sin and cos for current phase angle - void sincos(float *sinx, float *cosx) const - { - *sinx = fxpt::sin(d_phase); - *cosx = fxpt::cos(d_phase); - } - - //! compute cos and sin for a block of phase angles - void sincos(gr_complex *output, int noutput_items, double ampl=1.0) - { - for(int i = 0; i < noutput_items; i++) { - output[i] = gr_complex(fxpt::cos(d_phase) * ampl, - fxpt::sin(d_phase) * ampl); - step(); - } - } - - //! compute sin for a block of phase angles - void sin(float *output, int noutput_items, double ampl=1.0) - { - for(int i = 0; i < noutput_items; i++) { - output[i] = (float)(fxpt::sin(d_phase) * ampl); - step(); - } - } - - //! compute cos for a block of phase angles - void cos(float *output, int noutput_items, double ampl=1.0) - { - for(int i = 0; i < noutput_items; i++) { - output[i] = (float)(fxpt::cos(d_phase) * ampl); - step(); - } - } - - //! compute sin for a block of phase angles - void sin(short *output, int noutput_items, double ampl=1.0) - { - for(int i = 0; i < noutput_items; i++) { - output[i] = (short)(fxpt::sin(d_phase) * ampl); - step(); - } - } - - //! compute cos for a block of phase angles - void cos(short *output, int noutput_items, double ampl=1.0) - { - for(int i = 0; i < noutput_items; i++) { - output[i] = (short)(fxpt::cos(d_phase) * ampl); - step(); - } - } - - //! compute sin for a block of phase angles - void sin(int *output, int noutput_items, double ampl=1.0) - { - for(int i = 0; i < noutput_items; i++) { - output[i] = (int)(fxpt::sin(d_phase) * ampl); - step(); - } - } - - //! compute cos for a block of phase angles - void cos(int *output, int noutput_items, double ampl=1.0) - { - for(int i = 0; i < noutput_items; i++) { - output[i] = (int)(fxpt::cos(d_phase) * ampl); - step(); - } - } - - //! compute cos or sin for current phase angle - float cos() const { return fxpt::cos(d_phase); } - float sin() const { return fxpt::sin(d_phase); } - }; - - } /* namespace blocks */ -} /* namespace gr */ - -#endif /* INCLUDED_GR_FXPT_NCO_H */ diff --git a/gr-blocks/include/blocks/fxpt_vco.h b/gr-blocks/include/blocks/fxpt_vco.h deleted file mode 100644 index c313a494fb..0000000000 --- a/gr-blocks/include/blocks/fxpt_vco.h +++ /dev/null @@ -1,94 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002,2004,2005,2013 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_FXPT_VCO_H -#define INCLUDED_GR_FXPT_VCO_H - -#include <blocks/api.h> -#include <blocks/fxpt.h> -#include <gr_complex.h> - -namespace gr { - namespace blocks { - - /*! - * \brief Voltage Controlled Oscillator (VCO) - * \ingroup misc - * - * Simple calculations of sine and cosine. Set the phase using - * set_phase or adjust it by some delta using adjust_phase. Sine - * and cosine can be retrieved together with sincos(sinx, cosx) - * where sinx and cosx are the returned values at the current - * phase. They can be retrieved individually using either sin() or - * cos(). - */ - class BLOCKS_API fxpt_vco - { - private: - int32_t d_phase; - - public: - fxpt_vco() : d_phase(0) {} - - ~fxpt_vco() {} - - //! Set the current phase \p angle in radians - void set_phase(float angle) { - d_phase = fxpt::float_to_fixed(angle); - } - - //! Update the current phase in radians by \p delta_phase - void adjust_phase(float delta_phase) { - d_phase += fxpt::float_to_fixed(delta_phase); - } - - //! Get the current phase in radians - float get_phase() const { - return fxpt::fixed_to_float(d_phase); - } - - //! compute sin and cos for current phase angle - void sincos(float *sinx, float *cosx) const - { - *sinx = fxpt::sin(d_phase); - *cosx = fxpt::cos(d_phase); - } - - //! compute a block at a time - void cos(float *output, const float *input, int noutput_items, - float k, float ampl = 1.0) - { - for(int i = 0; i < noutput_items; i++) { - output[i] = (float)(fxpt::cos(d_phase) * ampl); - adjust_phase(input[i] * k); - } - } - - //! compute cos or sin for current phase angle - float cos() const { return fxpt::cos(d_phase); } - float sin() const { return fxpt::sin(d_phase); } - }; - - } /* namespace blocks */ -} /* namespace gr */ - -#endif /* INCLUDED_GR_FXPT_VCO_H */ diff --git a/gr-blocks/include/blocks/head.h b/gr-blocks/include/blocks/head.h new file mode 100644 index 0000000000..cc7d3808e5 --- /dev/null +++ b/gr-blocks/include/blocks/head.h @@ -0,0 +1,55 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2009,2012,2013 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_HEAD_H +#define INCLUDED_GR_HEAD_H + +#include <blocks/api.h> +#include <gr_sync_block.h> +#include <stddef.h> // size_t + +namespace gr { + namespace blocks { + + /*! + * \brief copies the first N items to the output then signals done + * \ingroup slicedice_blk + * + * Useful for building test cases + */ + class BLOCKS_API head : virtual public gr_sync_block + { + public: + // gr::blocks::head::sptr + typedef boost::shared_ptr<head> sptr; + + static sptr make(size_t sizeof_stream_item, + uint64_t nitems); + + virtual void reset() = 0; + virtual void set_length(int nitems) = 0; + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_HEAD_H */ diff --git a/gnuradio-core/src/lib/general/gri_lfsr_15_1_0.h b/gr-blocks/include/blocks/lfsr_15_1_0.h index 578739f7ef..a79ed62eb8 100644 --- a/gnuradio-core/src/lib/general/gri_lfsr_15_1_0.h +++ b/gr-blocks/include/blocks/lfsr_15_1_0.h @@ -23,38 +23,47 @@ #ifndef INCLUDED_GRI_LFSR_15_1_0_H #define INCLUDED_GRI_LFSR_15_1_0_H -#include <gr_core_api.h> +#include <blocks/api.h> -/*! - * \brief Linear Feedback Shift Register using primitive polynomial x^15 + x + 1 - * \ingroup misc - * - * Generates a maximal length pseudo-random sequence of length 2^15 - 1 bits. - */ +namespace gr { + namespace blocks { -class GR_CORE_API gri_lfsr_15_1_0 { - unsigned long d_sr; // shift register + /*! + * \brief Linear Feedback Shift Register using primitive polynomial x^15 + x + 1 + * \ingroup misc + * + * Generates a maximal length pseudo-random sequence of length + * 2^15 - 1 bits. + */ + class BLOCKS_API lfsr_15_1_0 + { + private: + unsigned long d_sr; // shift register - public: + public: + lfsr_15_1_0() { reset(); } - gri_lfsr_15_1_0 () { reset (); } + void reset() { d_sr = 0x7fff; } - void reset () { d_sr = 0x7fff; } + int next_bit() + { + d_sr = ((((d_sr >> 1) ^ d_sr) & 0x1) << 14) | (d_sr >> 1); + return d_sr & 0x1; + } - int next_bit (){ - d_sr = ((((d_sr >> 1) ^ d_sr) & 0x1) << 14) | (d_sr >> 1); - return d_sr & 0x1; - } + int next_byte () + { + int v = 0; + for(int i = 0; i < 8; i++) { + v >>= 1; + if(next_bit ()) + v |= 0x80; + } + return v; + } + }; - int next_byte (){ - int v = 0; - for (int i = 0; i < 8; i++){ - v >>= 1; - if (next_bit ()) - v |= 0x80; - } - return v; - } -}; + } /* namespace blocks */ +} /* namespace gr */ -#endif /* INCLUDED_GRI_LFSR_15_1_0_H */
\ No newline at end of file +#endif /* INCLUDED_GRI_LFSR_15_1_0_H */ diff --git a/gr-blocks/include/blocks/lfsr_32k.h b/gr-blocks/include/blocks/lfsr_32k.h new file mode 100644 index 0000000000..7e70f6512b --- /dev/null +++ b/gr-blocks/include/blocks/lfsr_32k.h @@ -0,0 +1,90 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2013 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_GRI_LFSR_32k_H +#define INCLUDED_GRI_LFSR_32k_H + +#include <blocks/api.h> +#include <blocks/lfsr_15_1_0.h> + +namespace gr { + namespace blocks { + + /*! + * \brief generate pseudo-random sequence of length 32768 bits. + * \ingroup misc + * + * This is based on gri_lfsr_15_1_0 with an extra 0 added at the + * end of the sequence. + */ + class BLOCKS_API lfsr_32k + { + private: + lfsr_15_1_0 d_lfsr; + unsigned int d_count; + + public: + lfsr_32k() { reset (); } + + void reset() + { + d_lfsr.reset(); + d_count = 0; + } + + int next_bit() + { + if(d_count == 32767) { + d_count = 0; + return 0; + } + d_count++; + return d_lfsr.next_bit(); + } + + int next_byte() + { + int v = 0; + for(int i = 0; i < 8; i++) { + v >>= 1; + if(next_bit ()) + v |= 0x80; + } + return v; + } + + int next_short() + { + int v = 0; + for(int i = 0; i < 16; i++) { + v >>= 1; + if(next_bit ()) + v |= 0x8000; + } + return v; + } + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GRI_LFSR_32k_H */ diff --git a/gr-blocks/include/blocks/lfsr_32k_source_s.h b/gr-blocks/include/blocks/lfsr_32k_source_s.h new file mode 100644 index 0000000000..c24cc31b29 --- /dev/null +++ b/gr-blocks/include/blocks/lfsr_32k_source_s.h @@ -0,0 +1,55 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2013 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_LFSR_32K_SOURCE_S_H +#define INCLUDED_GR_LFSR_32K_SOURCE_S_H + +#include <blocks/api.h> +#include <blocks/lfsr_32k.h> +#include <gr_sync_block.h> + +namespace gr { + namespace blocks { + + /*! + * \brief LFSR pseudo-random source with period of 2^15 bits (2^11 shorts) + * \ingroup source_blk + * + * This source is typically used along with gr::blocks::check_lfsr_32k_s to + * test the USRP using its digital loopback mode. + */ + class BLOCKS_API lfsr_32k_source_s : virtual public gr_sync_block + { + public: + // gr::blocks::lfsr_32k_source_s::sptr + typedef boost::shared_ptr<lfsr_32k_source_s> sptr; + + /*! + * \brief Make a LFSR 32k source block. + */ + static sptr make(); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_LFSR_32K_SOURCE_S_H */ diff --git a/gr-blocks/include/blocks/nco.h b/gr-blocks/include/blocks/nco.h deleted file mode 100644 index e6658a3572..0000000000 --- a/gr-blocks/include/blocks/nco.h +++ /dev/null @@ -1,210 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002,2013 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 _GR_NCO_H_ -#define _GR_NCO_H_ - -#include <vector> -#include <gr_sincos.h> -#include <cmath> -#include <gr_complex.h> - -namespace gr { - namespace blocks { - - /*! - * \brief base class template for Numerically Controlled Oscillator (NCO) - * \ingroup misc - * - * Calculate sine and cosine based on the current phase. This - * class has multiple ways to calculate sin/cos and when - * requensting a range will increment the phase based on a - * frequency, which can be set using set_freq. Similar interfaces - * to the fxpt_vco can also be used to set or adjust the current - * phase. - * - * \sa fxpt_nco.h for fixed-point implementation. - */ - template<class o_type, class i_type> - class nco - { - public: - nco() : phase(0), phase_inc(0) {} - - virtual ~nco() {} - - //! Set the current phase \p angle in radians - void set_phase(double angle) { - phase = angle; - } - - //! Update the current phase in radians by \p delta_phase - void adjust_phase(double delta_phase) { - phase += delta_phase; - } - - //! angle_rate is in radians / step - void set_freq(double angle_rate) { - phase_inc = angle_rate; - } - - //! angle_rate is a delta in radians / step - void adjust_freq(double delta_angle_rate) { - phase_inc += delta_angle_rate; - } - - //! increment current phase angle - void step() - { - phase += phase_inc; - if(fabs (phase) > M_PI) { - - while(phase > M_PI) - phase -= 2*M_PI; - - while(phase < -M_PI) - phase += 2*M_PI; - } - } - - //! increment current phase angle n times - void step(int n) - { - phase += phase_inc * n; - if(fabs (phase) > M_PI) { - - while(phase > M_PI) - phase -= 2*M_PI; - - while(phase < -M_PI) - phase += 2*M_PI; - } - } - - //! units are radians / step - double get_phase() const { return phase; } - double get_freq() const { return phase_inc; } - - //! compute sin and cos for current phase angle - void sincos(float *sinx, float *cosx) const; - - //! compute cos or sin for current phase angle - float cos() const { return std::cos (phase); } - float sin() const { return std::sin (phase); } - - //! compute a block at a time - void sin(float *output, int noutput_items, double ampl = 1.0); - void cos(float *output, int noutput_items, double ampl = 1.0); - void sincos(gr_complex *output, int noutput_items, double ampl = 1.0); - void sin(short *output, int noutput_items, double ampl = 1.0); - void cos(short *output, int noutput_items, double ampl = 1.0); - void sin(int *output, int noutput_items, double ampl = 1.0); - void cos(int *output, int noutput_items, double ampl = 1.0); - - protected: - double phase; - double phase_inc; - }; - - template<class o_type, class i_type> - void - nco<o_type,i_type>::sincos(float *sinx, float *cosx) const - { - gr_sincosf(phase, sinx, cosx); - } - - template<class o_type, class i_type> - void - nco<o_type,i_type>::sin(float *output, int noutput_items, double ampl) - { - for(int i = 0; i < noutput_items; i++) { - output[i] = (float)(sin() * ampl); - step(); - } - } - - template<class o_type, class i_type> - void - nco<o_type,i_type>::cos(float *output, int noutput_items, double ampl) - { - for(int i = 0; i < noutput_items; i++){ - output[i] = (float)(cos() * ampl); - step(); - } - } - - template<class o_type, class i_type> - void - nco<o_type,i_type>::sin(short *output, int noutput_items, double ampl) - { - for(int i = 0; i < noutput_items; i++) { - output[i] = (short)(sin() * ampl); - step(); - } - } - - template<class o_type, class i_type> - void - nco<o_type,i_type>::cos(short *output, int noutput_items, double ampl) - { - for(int i = 0; i < noutput_items; i++) { - output[i] = (short)(cos() * ampl); - step(); - } - } - - template<class o_type, class i_type> - void - nco<o_type,i_type>::sin(int *output, int noutput_items, double ampl) - { - for(int i = 0; i < noutput_items; i++) { - output[i] = (int)(sin() * ampl); - step(); - } - } - - template<class o_type, class i_type> - void - nco<o_type,i_type>::cos(int *output, int noutput_items, double ampl) - { - for(int i = 0; i < noutput_items; i++) { - output[i] = (int)(cos() * ampl); - step(); - } - } - - template<class o_type, class i_type> - void - nco<o_type,i_type>::sincos(gr_complex *output, int noutput_items, double ampl) - { - for(int i = 0; i < noutput_items; i++) { - float cosx, sinx; - sincos(&sinx, &cosx); - output[i] = gr_complex(cosx * ampl, sinx * ampl); - step(); - } - } - - } /* namespace blocks */ -} /* namespace gr */ - -#endif /* _NCO_H_ */ diff --git a/gr-blocks/include/blocks/nop.h b/gr-blocks/include/blocks/nop.h new file mode 100644 index 0000000000..a75adad621 --- /dev/null +++ b/gr-blocks/include/blocks/nop.h @@ -0,0 +1,59 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2010,2013 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_NOP_H +#define INCLUDED_GR_NOP_H + +#include <blocks/api.h> +#include <gr_block.h> +#include <stddef.h> // size_t + +namespace gr { + namespace blocks { + + /*! + * \brief Does nothing. Used for testing only. + * \ingroup misc_blk + */ + class BLOCKS_API nop : virtual public gr_block + { + public: + // gr::blocks::nop::sptr + typedef boost::shared_ptr<nop> sptr; + + /*! + * Build a nop block. + * + * \param sizeof_stream_item size of the stream items in bytes. + */ + static sptr make(size_t sizeof_stream_item); + + virtual int nmsgs_received() const = 0; + + virtual int ctrlport_test() const = 0; + virtual void set_ctrlport_test(int x) = 0; + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_NOP_H */ diff --git a/gnuradio-core/src/lib/general/gr_null_sink.h b/gr-blocks/include/blocks/null_sink.h index 7374293295..c13a7552c6 100644 --- a/gnuradio-core/src/lib/general/gr_null_sink.h +++ b/gr-blocks/include/blocks/null_sink.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2010 Free Software Foundation, Inc. + * Copyright 2004,2010,2013 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -23,31 +23,33 @@ #ifndef INCLUDED_GR_NULL_SINK_H #define INCLUDED_GR_NULL_SINK_H -#include <gr_core_api.h> +#include <blocks/api.h> #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_CORE_API gr_null_sink_sptr -gr_make_null_sink (size_t sizeof_stream_item); - -/*! - * \brief Bit bucket - * \ingroup sink_blk - */ -class GR_CORE_API gr_null_sink : public gr_sync_block -{ - friend GR_CORE_API gr_null_sink_sptr gr_make_null_sink (size_t sizeof_stream_item); - gr_null_sink (size_t sizeof_stream_item); - - public: - - virtual int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - -}; +namespace gr { + namespace blocks { + + /*! + * \brief Bit bucket. Use as a termination point when a sink is + * required and we don't want to do anything real. + * \ingroup sink_blk + */ + class BLOCKS_API null_sink : virtual public gr_sync_block + { + public: + // gr::blocks::null_sink::sptr + typedef boost::shared_ptr<null_sink> sptr; + + /*! + * Build a null sink block. + * + * \param sizeof_stream_item size of the stream items in bytes. + */ + static sptr make(size_t sizeof_stream_item); + }; + + } /* namespace blocks */ +} /* namespace gr */ #endif /* INCLUDED_GR_NULL_SINK_H */ diff --git a/gnuradio-core/src/lib/general/gr_null_source.h b/gr-blocks/include/blocks/null_source.h index 1c64e8bd98..904a0c1ba3 100644 --- a/gnuradio-core/src/lib/general/gr_null_source.h +++ b/gr-blocks/include/blocks/null_source.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2010 Free Software Foundation, Inc. + * Copyright 2004,2010,2013 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -23,30 +23,31 @@ #ifndef INCLUDED_GR_NULL_SOURCE_H #define INCLUDED_GR_NULL_SOURCE_H -#include <gr_core_api.h> +#include <blocks/api.h> #include <gr_sync_block.h> -class gr_null_source; -typedef boost::shared_ptr<gr_null_source> gr_null_source_sptr; - -GR_CORE_API gr_null_source_sptr -gr_make_null_source (size_t sizeof_stream_item); - -/*! - * \brief A source of zeros. - * \ingroup source_blk - */ -class GR_CORE_API gr_null_source : public gr_sync_block -{ - friend GR_CORE_API gr_null_source_sptr gr_make_null_source (size_t sizeof_stream_item); - - gr_null_source (size_t sizeof_stream_item); - - public: - virtual int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - -}; +namespace gr { + namespace blocks { + + /*! + * \brief A source of zeros used mainly for testing. + * \ingroup source_blk + */ + class BLOCKS_API null_source : virtual public gr_sync_block + { + public: + // gr::blocks::null_source::sptr + typedef boost::shared_ptr<null_source> sptr; + + /*! + * Build a null source block. + * + * \param sizeof_stream_item size of the stream items in bytes. + */ + static sptr make(size_t sizeof_stream_item); + }; + + } /* namespace blocks */ +} /* namespace gr */ #endif /* INCLUDED_GR_NULL_SOURCE_H */ diff --git a/gr-blocks/include/blocks/rotator.h b/gr-blocks/include/blocks/rotator.h new file mode 100644 index 0000000000..96ece63574 --- /dev/null +++ b/gr-blocks/include/blocks/rotator.h @@ -0,0 +1,63 @@ +/* -*- c++ -*- */ +/* + * Copyright 2003,2008,2013 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 _GR_ROTATOR_H_ +#define _GR_ROTATOR_H_ + +#include <blocks/api.h> +#include <gr_complex.h> + +namespace gr { + namespace blocks { + + class BLOCKS_API rotator + { + private: + gr_complex d_phase; + gr_complex d_phase_incr; + unsigned int d_counter; + + public: + rotator() : d_phase(1), d_phase_incr(1), d_counter(0) + { } + + void set_phase(gr_complex phase) { d_phase = phase / abs(phase); } + void set_phase_incr(gr_complex incr) { d_phase_incr = incr / abs(incr); } + + gr_complex rotate(gr_complex in) + { + d_counter++; + + gr_complex z = in * d_phase; // rotate in by phase + d_phase *= d_phase_incr; // incr our phase (complex mult == add phases) + + if((d_counter % 512) == 0) + d_phase /= abs(d_phase); // Normalize to ensure multiplication is rotation + + return z; + } + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* _GR_ROTATOR_H_ */ diff --git a/gr-blocks/include/blocks/skiphead.h b/gr-blocks/include/blocks/skiphead.h new file mode 100644 index 0000000000..e6745af8ea --- /dev/null +++ b/gr-blocks/include/blocks/skiphead.h @@ -0,0 +1,53 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,2013 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_SKIPHEAD_H +#define INCLUDED_GR_SKIPHEAD_H + +#include <blocks/api.h> +#include <gr_sync_block.h> +#include <stddef.h> // size_t + +namespace gr { + namespace blocks { + + /*! + * \brief skips the first N items, from then on copies items to the output + * \ingroup slicedice_blk + * + * Useful for building test cases and sources which have metadata + * or junk at the start + */ + class BLOCKS_API skiphead : virtual public gr_block + { + public: + // gr::blocks::skiphead::sptr + typedef boost::shared_ptr<skiphead> sptr; + + static sptr make(size_t itemsize, + uint64_t nitems_to_skip); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_SKIPHEAD_H */ diff --git a/gr-blocks/include/blocks/vco.h b/gr-blocks/include/blocks/vco.h deleted file mode 100644 index 4417d588ae..0000000000 --- a/gr-blocks/include/blocks/vco.h +++ /dev/null @@ -1,113 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2013 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 _GR_VCO_H_ -#define _GR_VCO_H_ - -#include <vector> -#include <gr_sincos.h> -#include <cmath> -#include <gr_complex.h> - -namespace gr { - namespace blocks { - - /*! - * \brief base class template for Voltage Controlled Oscillator (VCO) - * \ingroup misc - * - * Simple calculations of sine and cosine. Set the phase using - * set_phase or adjust it by some delta using adjust_phase. Sine - * and cosine can be retrieved together with sincos(sinx, cosx) - * where sinx and cosx are the returned values at the current - * phase. They can be retrieved individually using either sin() or - * cos(). - * - * \sa fxpt_nco.h for fixed-point implementation. - */ - - template<class o_type, class i_type> - class vco - { - public: - vco() : d_phase(0) {} - - virtual ~vco() {} - - //! Set the current phase \p angle in radians - void set_phase(double angle) { - d_phase = angle; - } - - //! Update the current phase in radians by \p delta_phase - void adjust_phase(double delta_phase) { - d_phase += delta_phase; - if(fabs(d_phase) > M_PI) { - - while(d_phase > M_PI) - d_phase -= 2*M_PI; - - while(d_phase < -M_PI) - d_phase += 2*M_PI; - } - } - - //! Get the current phase in radians - double get_phase() const { return d_phase; } - - //! compute sin and cos for current phase angle - void sincos(float *sinx, float *cosx) const; - - //! compute cos or sin for current phase angle - float cos() const { return std::cos(d_phase); } - float sin() const { return std::sin(d_phase); } - - //! compute a block at a time - void cos(float *output, const float *input, int noutput_items, - double k, double ampl = 1.0); - - protected: - double d_phase; - }; - - template<class o_type, class i_type> - void - vco<o_type,i_type>::sincos(float *sinx, float *cosx) const - { - gr_sincosf(d_phase, sinx, cosx); - } - - template<class o_type, class i_type> - void - vco<o_type,i_type>::cos(float *output, const float *input, int noutput_items, - double k, double ampl) - { - for(int i = 0; i < noutput_items; i++) { - output[i] = cos() * ampl; - adjust_phase(input[i] * k); - } - } - - } /* namespace blocks */ -} /* namespace gr */ - -#endif /* _VCO_H_ */ diff --git a/gnuradio-core/src/lib/gengen/gr_vector_insert_X.i.t b/gr-blocks/include/blocks/vector_insert_X.h.t index f3341eec4f..aeb4a5248a 100644 --- a/gnuradio-core/src/lib/gengen/gr_vector_insert_X.i.t +++ b/gr-blocks/include/blocks/vector_insert_X.h.t @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2012 Free Software Foundation, Inc. + * Copyright 2012-2013 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -22,16 +22,33 @@ // @WARNING@ -GR_SWIG_BLOCK_MAGIC(gr,@BASE_NAME@); +#ifndef @GUARD_NAME@ +#define @GUARD_NAME@ -@NAME@_sptr -gr_make_@BASE_NAME@ (const std::vector<@TYPE@> &data, int periodicity, int offset = 0) - throw(std::invalid_argument); +#include <blocks/api.h> +#include <gr_block.h> -class @NAME@ : public gr_block { - public: - void rewind(); - void set_data(const std::vector<@TYPE@> &data); - private: - @NAME@ (const std::vector<@TYPE@> &data, int periodicity, int offset = 0); -}; +namespace gr { + namespace blocks { + + /*! + * \brief source of @TYPE@'s that gets its data from a vector + * \ingroup source_blk + */ + class BLOCKS_API @NAME@ : virtual public gr_block + { + public: + // gr::blocks::@NAME@::sptr + typedef boost::shared_ptr<@NAME@> sptr; + + static sptr make(const std::vector<@TYPE@> &data, + int periodicity, int offset=0); + + virtual void rewind() = 0; + virtual void set_data(const std::vector<@TYPE@> &data) = 0; + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* @GUARD_NAME@ */ diff --git a/gr-blocks/include/blocks/vector_map.h b/gr-blocks/include/blocks/vector_map.h new file mode 100644 index 0000000000..64c8744975 --- /dev/null +++ b/gr-blocks/include/blocks/vector_map.h @@ -0,0 +1,71 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012,2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_GR_VECTOR_MAP_H +#define INCLUDED_GR_VECTOR_MAP_H + +#include <blocks/api.h> +#include <vector> +#include <gr_sync_block.h> + +namespace gr { + namespace blocks { + + /*! + * \brief Maps elements from a set of input vectors to a set of output vectors. + * \ingroup slicedice_blk + * + * If in[i] is the input vector in the i'th stream then the output + * vector in the j'th stream is: + * + * out[j][k] = in[mapping[j][k][0]][mapping[j][k][1]] + * + * That is mapping is of the form (out_stream1_mapping, + * out_stream2_mapping, ...) and out_stream1_mapping is of the + * form (element1_mapping, element2_mapping, ...) and + * element1_mapping is of the form (in_stream, in_element). + */ + class BLOCKS_API vector_map : virtual public gr_sync_block + { + public: + // gr::blocks::vector_map::sptr + typedef boost::shared_ptr<vector_map> sptr; + + /*! + * Build a vector map block. + * + * \param item_size (integer) size of vector elements + * \param in_vlens (vector of integers) number of elements in each + * input vector + * \param mapping (vector of vectors of vectors of integers) how to + * map elements from input to output vectors + */ + static sptr make(size_t item_size, std::vector<size_t> in_vlens, + std::vector< std::vector< std::vector<size_t> > > mapping); + + virtual void set_mapping(std::vector< std::vector< std::vector<size_t> > > mapping) = 0; + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_VECTOR_MAP_H */ diff --git a/gnuradio-core/src/lib/general/gr_iqcomp_cc.h b/gr-blocks/include/blocks/vector_sink_X.h.t index 2f5a44ebfb..d15c795721 100644 --- a/gnuradio-core/src/lib/general/gr_iqcomp_cc.h +++ b/gr-blocks/include/blocks/vector_sink_X.h.t @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004 Free Software Foundation, Inc. + * Copyright 2004,2008,2009,2013 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,36 +20,35 @@ * Boston, MA 02110-1301, USA. */ +// @WARNING@ -#ifndef INCLUDED_GR_IQCOMP_CC_H -#define INCLUDED_GR_IQCOMP_CC_H +#ifndef @GUARD_NAME@ +#define @GUARD_NAME@ -#include <gr_core_api.h> +#include <blocks/api.h> #include <gr_sync_block.h> -class gr_iqcomp_cc; -typedef boost::shared_ptr<gr_iqcomp_cc> gr_iqcomp_cc_sptr; +namespace gr { + namespace blocks { -GR_CORE_API gr_iqcomp_cc_sptr gr_make_iqcomp_cc (float mu); + /*! + * \brief @TYPE@ sink that writes to a vector + * \ingroup sink_blk + */ + class BLOCKS_API @NAME@ : virtual public gr_sync_block + { + public: + // gr::blocks::@NAME@::sptr + typedef boost::shared_ptr<@NAME@> sptr; -/*! - * \brief - * \ingroup misc_blk - */ -class GR_CORE_API gr_iqcomp_cc : public gr_sync_block -{ - friend GR_CORE_API gr_iqcomp_cc_sptr gr_make_iqcomp_cc (float mu); - - float d_mu, d_wi, d_wq; - gr_iqcomp_cc (float mu); + static sptr make(int vlen = 1); - public: - float mu () const { return d_mu; } - void set_mu (float mu) { d_mu = mu; } + virtual void reset() = 0; + virtual std::vector<@TYPE@> data() const = 0; + virtual std::vector<gr_tag_t> tags() const = 0; + }; - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; + } /* namespace blocks */ +} /* namespace gr */ -#endif +#endif /* @GUARD_NAME@ */ diff --git a/gnuradio-core/src/lib/gengen/gr_vector_sink_X.h.t b/gr-blocks/include/blocks/vector_source_X.h.t index b7de1d101c..c68b638e62 100644 --- a/gnuradio-core/src/lib/gengen/gr_vector_sink_X.h.t +++ b/gr-blocks/include/blocks/vector_source_X.h.t @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2008,2009 Free Software Foundation, Inc. + * Copyright 2004,2008,2012-2013 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -25,37 +25,32 @@ #ifndef @GUARD_NAME@ #define @GUARD_NAME@ -#include <gr_core_api.h> +#include <blocks/api.h> #include <gr_sync_block.h> -class @NAME@; -typedef boost::shared_ptr<@NAME@> @NAME@_sptr; +namespace gr { + namespace blocks { -GR_CORE_API @NAME@_sptr -gr_make_@BASE_NAME@ (int vlen = 1); + /*! + * \brief source of @TYPE@'s that gets its data from a vector + * \ingroup source_blk + */ + class BLOCKS_API @NAME@ : virtual public gr_sync_block + { + public: + // gr::blocks::@NAME@::sptr + typedef boost::shared_ptr<@NAME@> sptr; + static sptr make(const std::vector<@TYPE@> &data, + bool repeat=false, int vlen=1, + const std::vector<gr_tag_t> &tags=std::vector<gr_tag_t>()); -/*! - * \brief @TYPE@ sink that writes to a vector - * \ingroup sink_blk - */ + virtual void rewind() = 0; + virtual void set_data(const std::vector<@TYPE@> &data, + const std::vector<gr_tag_t> &tags=std::vector<gr_tag_t>()) = 0; + }; + + } /* namespace blocks */ +} /* namespace gr */ -class GR_CORE_API @NAME@ : public gr_sync_block { - friend GR_CORE_API @NAME@_sptr gr_make_@BASE_NAME@ (int vlen); - std::vector<@TYPE@> d_data; - std::vector<gr_tag_t> d_tags; - int d_vlen; - @NAME@ (int vlen); - - public: - virtual int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - void reset() {d_data.clear();} - void clear() {reset(); } // deprecated - std::vector<@TYPE@> data () const; - std::vector<gr_tag_t> tags () const; -}; - -#endif +#endif /* @GUARD_NAME@ */ diff --git a/gr-blocks/lib/CMakeLists.txt b/gr-blocks/lib/CMakeLists.txt index de73a8a308..ae3523945e 100644 --- a/gr-blocks/lib/CMakeLists.txt +++ b/gr-blocks/lib/CMakeLists.txt @@ -114,6 +114,9 @@ expand_cc_h_impl(sub_XX ss ii ff cc) expand_cc_h_impl(xor_XX bb ss ii) expand_cc_h_impl(packed_to_unpacked_XX bb ss ii) expand_cc_h_impl(unpacked_to_packed_XX bb ss ii) +expand_cc_h_impl(vector_insert_X b s i f c) +expand_cc_h_impl(vector_sink_X b s i f c) +expand_cc_h_impl(vector_source_X b s i f c) ######################################################################## # Setup the include and linker paths @@ -144,13 +147,16 @@ list(APPEND gr_blocks_sources control_loop.cc count_bits.cc file_sink_base.cc - fxpt.cc wavfile.cc add_ff_impl.cc + annotator_1to1_impl.cc + annotator_alltoall_impl.cc + annotator_raw_impl.cc bin_statistics_f_impl.cc burst_tagger_impl.cc char_to_float_impl.cc char_to_short_impl.cc + check_lfsr_32k_s_impl.cc complex_to_interleaved_short_impl.cc complex_to_float_impl.cc complex_to_real_impl.cc @@ -159,8 +165,10 @@ list(APPEND gr_blocks_sources complex_to_mag_squared_impl.cc complex_to_arg_impl.cc conjugate_cc_impl.cc + copy_impl.cc deinterleave_impl.cc delay_impl.cc + endian_swap_impl.cc file_descriptor_sink_impl.cc file_descriptor_source_impl.cc file_sink_impl.cc @@ -174,12 +182,14 @@ list(APPEND gr_blocks_sources float_to_short_impl.cc float_array_to_uchar.cc float_to_uchar_impl.cc + head_impl.cc int_to_float_impl.cc interleave_impl.cc interleaved_short_array_to_complex.cc interleaved_short_to_complex_impl.cc keep_m_in_n_impl.cc keep_one_in_n_impl.cc + lfsr_32k_source_s_impl.cc message_debug_impl.cc message_sink_impl.cc message_source_impl.cc @@ -191,6 +201,9 @@ list(APPEND gr_blocks_sources multiply_const_cc_impl.cc multiply_const_ff_impl.cc nlog10_ff_impl.cc + nop_impl.cc + null_sink_impl.cc + null_source_impl.cc pack_k_bits_bb_impl.cc patterned_interleaver_impl.cc pdu.cc @@ -206,6 +219,7 @@ list(APPEND gr_blocks_sources rms_ff_impl.cc short_to_char_impl.cc short_to_float_impl.cc + skiphead_impl.cc socket_pdu_impl.cc stream_mux_impl.cc stream_pdu_base.cc @@ -228,12 +242,20 @@ list(APPEND gr_blocks_sources udp_source_impl.cc unpack_k_bits_bb_impl.cc vco_f_impl.cc + vector_map_impl.cc vector_to_stream_impl.cc vector_to_streams_impl.cc wavfile_sink_impl.cc wavfile_source_impl.cc ) +if(ENABLE_GR_CTRLPORT) +list(APPEND gr_blocks_sources + ctrlport_probe_c_impl.cc + ctrlport_probe2_c_impl.cc +) +endif(ENABLE_GR_CTRLPORT) + #Add Windows DLL resource file if using MSVC IF(MSVC) include(${CMAKE_SOURCE_DIR}/cmake/Modules/GrVersion.cmake) @@ -268,15 +290,20 @@ GR_LIBRARY_FOO(gnuradio-blocks RUNTIME_COMPONENT "blocks_runtime" DEVEL_COMPONEN if(ENABLE_TESTING) include(GrTest) - include_directories(${CPPUNIT_INCLUDE_DIRS}) + include_directories( + ${GR_FILTER_INCLUDE_DIRS} + ${CPPUNIT_INCLUDE_DIRS}) link_directories(${CPPUNIT_LIBRARY_DIRS}) list(APPEND test_gr_blocks_sources ${CMAKE_CURRENT_SOURCE_DIR}/test_gr_blocks.cc + ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_block.cc + ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_top_block.cc + ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_hier_block2.cc + ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_hier_block2_derived.cc ${CMAKE_CURRENT_SOURCE_DIR}/qa_blocks.cc - ${CMAKE_CURRENT_SOURCE_DIR}/qa_fxpt.cc - ${CMAKE_CURRENT_SOURCE_DIR}/qa_fxpt_nco.cc - ${CMAKE_CURRENT_SOURCE_DIR}/qa_fxpt_vco.cc + ${CMAKE_CURRENT_SOURCE_DIR}/qa_block_tags.cc + ${CMAKE_CURRENT_SOURCE_DIR}/qa_rotator.cc ) add_executable(test-gr-blocks ${test_gr_blocks_sources}) @@ -287,6 +314,7 @@ if(ENABLE_TESTING) test-gr-blocks gnuradio-core gnuradio-blocks + gnuradio-filter ${Boost_LIBRARIES} ${CPPUNIT_LIBRARIES} ) diff --git a/gr-blocks/lib/annotator_1to1_impl.cc b/gr-blocks/lib/annotator_1to1_impl.cc new file mode 100644 index 0000000000..e7f105fc02 --- /dev/null +++ b/gr-blocks/lib/annotator_1to1_impl.cc @@ -0,0 +1,113 @@ +/* -*- c++ -*- */ +/* + * Copyright 2010,2013 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 "annotator_1to1_impl.h" +#include <gr_io_signature.h> +#include <string.h> +#include <iostream> +#include <iomanip> + +namespace gr { + namespace blocks { + + annotator_1to1::sptr + annotator_1to1::make(int when, size_t sizeof_stream_item) + { + return gnuradio::get_initial_sptr + (new annotator_1to1_impl(when, sizeof_stream_item)); + } + + annotator_1to1_impl::annotator_1to1_impl(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); + } + + annotator_1to1_impl::~annotator_1to1_impl() + { + } + + int + annotator_1to1_impl::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<gr_tag_t> all_tags; + get_tags_in_range(all_tags, i, abs_N, abs_N + noutput_items); + + std::vector<gr_tag_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::string_to_symbol(str.str()); + pmt::pmt_t key = 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::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; + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/annotator_1to1_impl.h b/gr-blocks/lib/annotator_1to1_impl.h new file mode 100644 index 0000000000..3306602e2c --- /dev/null +++ b/gr-blocks/lib/annotator_1to1_impl.h @@ -0,0 +1,56 @@ +/* -*- c++ -*- */ +/* + * Copyright 2010,2013 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_IMPL_H +#define INCLUDED_GR_ANNOTATOR_1TO1_IMPL_H + +#include <blocks/annotator_1to1.h> + +namespace gr { + namespace blocks { + + class annotator_1to1_impl : public annotator_1to1 + { + private: + size_t d_itemsize; + uint64_t d_when; + uint64_t d_tag_counter; + std::vector<gr_tag_t> d_stored_tags; + + public: + annotator_1to1_impl(int when, size_t sizeof_stream_item); + ~annotator_1to1_impl(); + + std::vector<gr_tag_t> data() const + { + return d_stored_tags; + } + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_ANNOTATOR_1TO1_IMPL_H */ diff --git a/gr-blocks/lib/annotator_alltoall_impl.cc b/gr-blocks/lib/annotator_alltoall_impl.cc new file mode 100644 index 0000000000..4909f7f820 --- /dev/null +++ b/gr-blocks/lib/annotator_alltoall_impl.cc @@ -0,0 +1,117 @@ +/* -*- c++ -*- */ +/* + * Copyright 2010,2013 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 "annotator_alltoall_impl.h" +#include <gr_io_signature.h> +#include <string.h> +#include <iostream> +#include <iomanip> + +namespace gr { + namespace blocks { + + annotator_alltoall::sptr + annotator_alltoall::make(int when, size_t sizeof_stream_item) + { + return gnuradio::get_initial_sptr + (new annotator_alltoall_impl(when, sizeof_stream_item)); + } + + annotator_alltoall_impl::annotator_alltoall_impl(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; + } + + annotator_alltoall_impl::~annotator_alltoall_impl() + { + } + + int + annotator_alltoall_impl::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<gr_tag_t> all_tags; + get_tags_in_range(all_tags, i, abs_N, end_N); + + std::vector<gr_tag_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::string_to_symbol(str.str()); + pmt::pmt_t key = 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::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; + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/annotator_alltoall_impl.h b/gr-blocks/lib/annotator_alltoall_impl.h new file mode 100644 index 0000000000..24c21948bc --- /dev/null +++ b/gr-blocks/lib/annotator_alltoall_impl.h @@ -0,0 +1,56 @@ +/* -*- c++ -*- */ +/* + * Copyright 2010,2013 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_IMPL_H +#define INCLUDED_GR_ANNOTATOR_ALLTOALL_IMPL_H + +#include <blocks/annotator_alltoall.h> + +namespace gr { + namespace blocks { + + class annotator_alltoall_impl : public annotator_alltoall + { + private: + size_t d_itemsize; + uint64_t d_when; + uint64_t d_tag_counter; + std::vector<gr_tag_t> d_stored_tags; + + public: + annotator_alltoall_impl(int when, size_t sizeof_stream_item); + ~annotator_alltoall_impl(); + + std::vector<gr_tag_t> data() const + { + return d_stored_tags; + } + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_ANNOTATOR_ALLTOALL_IMPL_H */ diff --git a/gr-blocks/lib/annotator_raw_impl.cc b/gr-blocks/lib/annotator_raw_impl.cc new file mode 100644 index 0000000000..fa323f999e --- /dev/null +++ b/gr-blocks/lib/annotator_raw_impl.cc @@ -0,0 +1,113 @@ +/* -*- c++ -*- */ +/* + * Copyright 2010,2013 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 "annotator_raw_impl.h" +#include <gr_io_signature.h> +#include <string.h> +#include <iostream> +#include <iomanip> +#include <stdexcept> + +using namespace pmt; + +namespace gr { + namespace blocks { + + annotator_raw::sptr + annotator_raw::make(size_t sizeof_stream_item) + { + return gnuradio::get_initial_sptr + (new annotator_raw_impl(sizeof_stream_item)); + } + + annotator_raw_impl::annotator_raw_impl(size_t sizeof_stream_item) + : gr_sync_block("annotator_raw", + gr_make_io_signature(1, 1, sizeof_stream_item), + gr_make_io_signature(1, 1, sizeof_stream_item)), + d_itemsize(sizeof_stream_item) + { + set_tag_propagation_policy(TPP_ONE_TO_ONE); + set_relative_rate(1.0); + } + + annotator_raw_impl::~annotator_raw_impl() + { + } + + void + annotator_raw_impl::add_tag(uint64_t offset, pmt_t key, pmt_t val) + { + gruel::scoped_lock l(d_mutex); + + gr_tag_t tag; + tag.srcid = pmt::intern(name()); + tag.key = key; + tag.value = val; + tag.offset = offset; + + // add our new tag + d_queued_tags.push_back(tag); + // make sure our tags are in offset order + std::sort(d_queued_tags.begin(), d_queued_tags.end(), + gr_tag_t::offset_compare); + // make sure we are not adding an item in the past! + if(tag.offset > nitems_read(0)) { + throw std::runtime_error("annotator_raw::add_tag: item added too far in the past\n."); + } + } + + int + annotator_raw_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + gruel::scoped_lock l(d_mutex); + + const char *in = (const char*)input_items[0]; + char *out = (char*)output_items[0]; + + uint64_t start_N = nitems_read(0); + uint64_t end_N = start_N + (uint64_t)(noutput_items); + + // locate queued tags that fall in this range and insert them when appropriate + std::vector<gr_tag_t>::iterator i = d_queued_tags.begin(); + while( i != d_queued_tags.end() ) { + if( (*i).offset >= start_N && (*i).offset < end_N) { + add_item_tag(0, (*i).offset,(*i).key, (*i).value, (*i).srcid); + i = d_queued_tags.erase(i); + } + else { + break; + } + } + + // copy data across + memcpy(out, in, noutput_items*d_itemsize); + return noutput_items; + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/annotator_raw_impl.h b/gr-blocks/lib/annotator_raw_impl.h new file mode 100644 index 0000000000..2e349bfe33 --- /dev/null +++ b/gr-blocks/lib/annotator_raw_impl.h @@ -0,0 +1,54 @@ +/* -*- c++ -*- */ +/* + * Copyright 2010,2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_GR_ANNOTATOR_RAW_IMPL_H +#define INCLUDED_GR_ANNOTATOR_RAW_IMPL_H + +#include <blocks/annotator_raw.h> +#include <gruel/thread.h> + +namespace gr { + namespace blocks { + + class annotator_raw_impl : public annotator_raw + { + private: + size_t d_itemsize; + std::vector<gr_tag_t> d_queued_tags; + gruel::mutex d_mutex; + + public: + annotator_raw_impl(size_t sizeof_stream_item); + ~annotator_raw_impl(); + + // insert a tag to be added + void add_tag(uint64_t offset, pmt::pmt_t key, pmt::pmt_t val); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_ANNOTATOR_RAW_IMPL_H */ diff --git a/gr-blocks/lib/check_lfsr_32k_s_impl.cc b/gr-blocks/lib/check_lfsr_32k_s_impl.cc new file mode 100644 index 0000000000..5664067591 --- /dev/null +++ b/gr-blocks/lib/check_lfsr_32k_s_impl.cc @@ -0,0 +1,179 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2010,2013 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 "check_lfsr_32k_s_impl.h" +#include <gr_io_signature.h> +#include <stdlib.h> +#include <stdio.h> + +namespace gr { + namespace blocks { + + check_lfsr_32k_s::sptr + check_lfsr_32k_s::make() + { + return gnuradio::get_initial_sptr + (new check_lfsr_32k_s_impl()); + } + + check_lfsr_32k_s_impl::check_lfsr_32k_s_impl() + : gr_sync_block("check_lfsr_32k", + gr_make_io_signature(1, 1, sizeof(short)), + gr_make_io_signature(0, 0, 0)), + d_state(SEARCHING), d_history(0), d_ntotal(0), d_nright(0), + d_runlength(0), d_index(0) + { + lfsr_32k lfsr; + + for(int i = 0; i < BUFSIZE; i++) + d_buffer[i] = lfsr.next_short(); + + enter_SEARCHING(); + } + + check_lfsr_32k_s_impl::~check_lfsr_32k_s_impl() + { + } + + int + check_lfsr_32k_s_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + unsigned short *in = (unsigned short*)input_items[0]; + + for(int i = 0; i < noutput_items; i++) { + unsigned short x = in[i]; + unsigned short expected; + + switch(d_state) { + case MATCH0: + if(x == d_buffer[0]) + enter_MATCH1(); + break; + + case MATCH1: + if(x == d_buffer[1]) + enter_MATCH2(); + else + enter_MATCH0(); + break; + + case MATCH2: + if(x == d_buffer[2]) + enter_LOCKED(); + else + enter_MATCH0(); + break; + + case LOCKED: + expected = d_buffer[d_index]; + d_index = d_index + 1; + if(d_index >= BUFSIZE) + d_index = 0; + + if(x == expected) + right(); + else { + wrong(); + log_error(expected, x); + if(wrong_three_times()) + enter_SEARCHING(); + } + break; + + default: + abort(); + } + + d_ntotal++; + } + + return noutput_items; + } + + void + check_lfsr_32k_s_impl::enter_SEARCHING() + { + d_state = SEARCHING; + wrong(); // reset history + wrong(); + wrong(); + + d_runlength = 0; + d_index = 0; // reset LFSR to beginning + + if(0) + fprintf(stdout, "check_lfsr_32k: enter_SEARCHING at offset %8ld (0x%08lx)\n", + d_ntotal, d_ntotal); + + enter_MATCH0(); + } + + void + check_lfsr_32k_s_impl::enter_MATCH0() + { + d_state = MATCH0; + } + + void + check_lfsr_32k_s_impl::enter_MATCH1() + { + d_state = MATCH1; + } + + void + check_lfsr_32k_s_impl::enter_MATCH2() + { + d_state = MATCH2; + } + + void + check_lfsr_32k_s_impl::enter_LOCKED() + { + d_state = LOCKED; + right(); // setup history + right(); + right(); + + d_index = 3; // already matched first 3 items + + if(0) + fprintf(stdout, "check_lfsr_32k: enter_LOCKED at offset %8ld (0x%08lx)\n", + d_ntotal, d_ntotal); + } + + void + check_lfsr_32k_s_impl::log_error(unsigned short expected, unsigned short actual) + { + if(0) + fprintf(stdout, + "check_lfsr_32k: expected %5d (0x%04x) got %5d (0x%04x) offset %8ld (0x%08lx)\n", + expected, expected, actual, actual, d_ntotal, d_ntotal); + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/check_lfsr_32k_s_impl.h b/gr-blocks/lib/check_lfsr_32k_s_impl.h new file mode 100644 index 0000000000..f6d3c8daa2 --- /dev/null +++ b/gr-blocks/lib/check_lfsr_32k_s_impl.h @@ -0,0 +1,94 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2013 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_CHECK_LFSR_32K_S_IMPL_H +#define INCLUDED_GR_CHECK_LFSR_32K_S_IMPL_H + +#include <blocks/check_lfsr_32k_s.h> +#include <blocks/lfsr_32k.h> + +namespace gr { + namespace blocks { + + class check_lfsr_32k_s_impl : public check_lfsr_32k_s + { + private: + enum state { + SEARCHING, // searching for synchronization + MATCH0, + MATCH1, + MATCH2, + LOCKED // is locked + }; + + state d_state; + unsigned int d_history; // bitmask of decisions + + long d_ntotal; // total number of shorts + long d_nright; // # of correct shorts + long d_runlength; // # of correct shorts in a row + + static const int BUFSIZE = 2048 - 1; // ensure pattern isn't packet aligned + int d_index; + unsigned short d_buffer[BUFSIZE]; + + void enter_SEARCHING(); + void enter_MATCH0(); + void enter_MATCH1(); + void enter_MATCH2(); + void enter_LOCKED(); + + void right() + { + d_history = (d_history << 1) | 0x1; + d_nright++; + d_runlength++; + } + + void wrong() + { + d_history = (d_history << 1) | 0x0; + d_runlength = 0; + } + + bool right_three_times() { return (d_history & 0x7) == 0x7; } + bool wrong_three_times() { return (d_history & 0x7) == 0x0; } + + void log_error(unsigned short expected, unsigned short actual); + + public: + check_lfsr_32k_s_impl(); + ~check_lfsr_32k_s_impl(); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + + long ntotal() const { return d_ntotal; } + long nright() const { return d_nright; } + long runlength() const { return d_runlength; } + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_CHECK_LFSR_32K_S_IMPL_H */ diff --git a/gr-blocks/lib/copy_impl.cc b/gr-blocks/lib/copy_impl.cc new file mode 100644 index 0000000000..929f22b7d3 --- /dev/null +++ b/gr-blocks/lib/copy_impl.cc @@ -0,0 +1,91 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006,2009,2013 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 "copy_impl.h" +#include <gr_io_signature.h> +#include <string.h> + +namespace gr { + namespace blocks { + + copy::sptr + copy::make(size_t itemsize) + { + return gnuradio::get_initial_sptr + (new copy_impl(itemsize)); + } + + copy_impl::copy_impl(size_t itemsize) + : gr_block("copy", + gr_make_io_signature(1, -1, itemsize), + gr_make_io_signature(1, -1, itemsize)), + d_itemsize(itemsize), + d_enabled(true) + { + } + + copy_impl::~copy_impl() + { + } + + void + copy_impl::forecast(int noutput_items, gr_vector_int &ninput_items_required) + { + unsigned ninputs = ninput_items_required.size(); + for (unsigned i = 0; i < ninputs; i++) + ninput_items_required[i] = noutput_items; + } + + bool + copy_impl::check_topology(int ninputs, int noutputs) + { + return ninputs == noutputs; + } + + int + copy_impl::general_work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + const uint8_t **in = (const uint8_t**)&input_items[0]; + uint8_t **out = (uint8_t**)&output_items[0]; + + int n = 0; + if(d_enabled) { + int ninputs = input_items.size(); + for(int i = 0; i < ninputs; i++) { + memcpy(out[i], in[i], noutput_items*d_itemsize); + } + n = noutput_items; + } + + consume_each(noutput_items); + return n; + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/copy_impl.h b/gr-blocks/lib/copy_impl.h new file mode 100644 index 0000000000..1f0f1a655e --- /dev/null +++ b/gr-blocks/lib/copy_impl.h @@ -0,0 +1,56 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006,2009,2013 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_COPY_IMPL_H +#define INCLUDED_GR_COPY_IMPL_H + +#include <blocks/copy.h> + +namespace gr { + namespace blocks { + + class copy_impl : public copy + { + private: + size_t d_itemsize; + bool d_enabled; + + public: + copy_impl(size_t itemsize); + ~copy_impl(); + + void forecast(int noutput_items, gr_vector_int &ninput_items_required); + bool check_topology(int ninputs, int noutputs); + + void set_enabled(bool enable) { d_enabled = enable; } + bool enabled() const { return d_enabled;} + + int general_work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_COPY_IMPL_H */ diff --git a/gr-blocks/lib/ctrlport_probe2_c_impl.cc b/gr-blocks/lib/ctrlport_probe2_c_impl.cc new file mode 100644 index 0000000000..f52e605a0d --- /dev/null +++ b/gr-blocks/lib/ctrlport_probe2_c_impl.cc @@ -0,0 +1,163 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012-2013 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 "ctrlport_probe2_c_impl.h" +#include <gr_io_signature.h> + +namespace gr { + namespace blocks { + + ctrlport_probe2_c::sptr + ctrlport_probe2_c::make(const std::string &id, + const std::string &desc, int len) + { + return gnuradio::get_initial_sptr + (new ctrlport_probe2_c_impl(id, desc, len)); + } + + ctrlport_probe2_c_impl::ctrlport_probe2_c_impl(const std::string &id, + const std::string &desc, int len) + : gr_sync_block("probe2_c", + gr_make_io_signature(1, 1, sizeof(gr_complex)), + gr_make_io_signature(0, 0, 0)), + d_id(id), d_desc(desc), d_len(len) + { + set_length(len); + } + + ctrlport_probe2_c_impl::~ctrlport_probe2_c_impl() + { + } + + void + ctrlport_probe2_c_impl::forecast(int noutput_items, + gr_vector_int &ninput_items_required) + { + // make sure all inputs have noutput_items available + unsigned ninputs = ninput_items_required.size(); + for(unsigned i = 0; i < ninputs; i++) + ninput_items_required[i] = d_len; + } + + // boost::shared_mutex mutex_buffer; + // mutable boost::mutex mutex_notify; + // boost::condition_variable condition_buffer_ready; + std::vector<gr_complex> + ctrlport_probe2_c_impl::get() + { + mutex_buffer.lock(); + d_buffer.clear(); + mutex_buffer.unlock(); + + // wait for condition + boost::mutex::scoped_lock lock(mutex_notify); + condition_buffer_ready.wait(lock); + + mutex_buffer.lock(); + std::vector<gr_complex> buf_copy = d_buffer; + assert(buf_copy.size() == d_len); + mutex_buffer.unlock(); + + return buf_copy; + } + + void + ctrlport_probe2_c_impl::set_length(int len) + { + if(len > 8191) { + std::cerr << "probe2_c: length " << len + << " exceeds maximum buffer size of 8191" << std::endl; + len = 8191; + } + + d_len = len; + d_buffer.reserve(d_len); + } + + int + ctrlport_probe2_c_impl::length() const + { + return (int)d_len; + } + + int + ctrlport_probe2_c_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + const gr_complex *in = (const gr_complex*)input_items[0]; + + // copy samples to get buffer if we need samples + mutex_buffer.lock(); + if(d_buffer.size() < d_len) { + // copy smaller of remaining buffer space and num inputs to work() + int num_copy = std::min( (int)(d_len - d_buffer.size()), noutput_items ); + + // TODO: convert this to a copy operator for speed... + for(int i = 0; i < num_copy; i++) { + d_buffer.push_back(in[i]); + } + + // notify the waiting get() if we fill up the buffer + if(d_buffer.size() == d_len) { + condition_buffer_ready.notify_one(); + } + } + mutex_buffer.unlock(); + + return noutput_items; + } + + void + ctrlport_probe2_c_impl::setup_rpc() + { +#ifdef GR_CTRLPORT + int len = static_cast<int>(d_len); + d_rpc_vars.push_back( + rpcbasic_sptr(new rpcbasic_register_get<ctrlport_probe2_c, std::vector<std::complex<float> > >( + alias(), d_id.c_str(), &ctrlport_probe2_c::get, + pmt::make_c32vector(0,-2), + pmt::make_c32vector(0,2), + pmt::make_c32vector(0,0), + "volts", d_desc.c_str(), RPC_PRIVLVL_MIN, + DISPXY | DISPOPTSCATTER))); + + d_rpc_vars.push_back( + rpcbasic_sptr(new rpcbasic_register_get<ctrlport_probe2_c, int>( + alias(), "length", &ctrlport_probe2_c::length, + pmt::mp(1), pmt::mp(10*len), pmt::mp(len), + "samples", "get vector length", RPC_PRIVLVL_MIN, DISPNULL))); + + d_rpc_vars.push_back( + rpcbasic_sptr(new rpcbasic_register_set<ctrlport_probe2_c, int>( + alias(), "length", &ctrlport_probe2_c::set_length, + pmt::mp(1), pmt::mp(10*len), pmt::mp(len), + "samples", "set vector length", RPC_PRIVLVL_MIN, DISPNULL))); +#endif /* GR_CTRLPORT */ + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/ctrlport_probe2_c_impl.h b/gr-blocks/lib/ctrlport_probe2_c_impl.h new file mode 100644 index 0000000000..4d290a4e8f --- /dev/null +++ b/gr-blocks/lib/ctrlport_probe2_c_impl.h @@ -0,0 +1,67 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012-2013 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_CTRLPORT_PROBE2_C_IMPL_H +#define INCLUDED_CTRLPORT_PROBE2_C_IMPL_H + +#include <blocks/ctrlport_probe2_c.h> +#include <rpcregisterhelpers.h> +#include <boost/thread/shared_mutex.hpp> + +namespace gr { + namespace blocks { + + class ctrlport_probe2_c_impl : public ctrlport_probe2_c + { + private: + std::string d_id; + std::string d_desc; + size_t d_len; + boost::shared_mutex mutex_buffer; + mutable boost::mutex mutex_notify; + boost::condition_variable condition_buffer_ready; + + std::vector<gr_complex> d_buffer; + + public: + ctrlport_probe2_c_impl(const std::string &id, const std::string &desc, int len); + ~ctrlport_probe2_c_impl(); + + void setup_rpc(); + + void forecast(int noutput_items, gr_vector_int &ninput_items_required); + + std::vector<gr_complex> get(); + + void set_length(int len); + int length() const; + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_CTRLPORT_PROBE2_C_IMPL_H */ + diff --git a/gr-blocks/lib/ctrlport_probe_c_impl.cc b/gr-blocks/lib/ctrlport_probe_c_impl.cc new file mode 100644 index 0000000000..e11bd0496e --- /dev/null +++ b/gr-blocks/lib/ctrlport_probe_c_impl.cc @@ -0,0 +1,101 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012-2013 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 "ctrlport_probe_c_impl.h" +#include <gr_io_signature.h> + +namespace gr { + namespace blocks { + + ctrlport_probe_c::sptr + ctrlport_probe_c::make(const std::string &id, + const std::string &desc) + { + return gnuradio::get_initial_sptr + (new ctrlport_probe_c_impl(id, desc)); + } + + ctrlport_probe_c_impl::ctrlport_probe_c_impl(const std::string &id, + const std::string &desc) + : gr_sync_block("probe_c", + gr_make_io_signature(1, 1, sizeof(gr_complex)), + gr_make_io_signature(0, 0, 0)), + d_id(id), d_desc(desc), d_ptr(NULL), d_ptrLen(0) + { + } + + ctrlport_probe_c_impl::~ctrlport_probe_c_impl() + { + } + + std::vector<gr_complex> + ctrlport_probe_c_impl::get() + { + if(d_ptr != NULL && d_ptrLen > 0) { + ptrlock.lock(); + std::vector<gr_complex> vec(d_ptr, d_ptr+d_ptrLen); + ptrlock.unlock(); + return vec; + } + else { + std::vector<gr_complex> vec; + return vec; + } + } + + int + ctrlport_probe_c_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + const gr_complex *in = (const gr_complex*)input_items[0]; + + // keep reference to symbols + ptrlock.lock(); + d_ptr = in; + d_ptrLen = noutput_items; + ptrlock.unlock(); + + return noutput_items; + } + + void + ctrlport_probe_c_impl::setup_rpc() + { +#ifdef GR_CTRLPORT + d_rpc_vars.push_back( + rpcbasic_sptr(new rpcbasic_register_get<ctrlport_probe_c, std::vector<std::complex<float> > >( + alias(), d_id.c_str(), &ctrlport_probe_c::get, + pmt::make_c32vector(0,-2), + pmt::make_c32vector(0,2), + pmt::make_c32vector(0,0), + "volts", d_desc.c_str(), RPC_PRIVLVL_MIN, + DISPXY | DISPOPTSCATTER))); +#endif /* GR_CTRLPORT */ + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/ctrlport_probe_c_impl.h b/gr-blocks/lib/ctrlport_probe_c_impl.h new file mode 100644 index 0000000000..5d9073ac10 --- /dev/null +++ b/gr-blocks/lib/ctrlport_probe_c_impl.h @@ -0,0 +1,60 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012-2013 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_CTRLPORT_PROBE_C_IMPL_H +#define INCLUDED_CTRLPORT_PROBE_C_IMPL_H + +#include <blocks/ctrlport_probe_c.h> +#include <rpcregisterhelpers.h> +#include <boost/thread/shared_mutex.hpp> + +namespace gr { + namespace blocks { + + class ctrlport_probe_c_impl : public ctrlport_probe_c + { + private: + boost::shared_mutex ptrlock; + + std::string d_id; + std::string d_desc; + const gr_complex* d_ptr; + size_t d_ptrLen; + + public: + ctrlport_probe_c_impl(const std::string &id, const std::string &desc); + ~ctrlport_probe_c_impl(); + + void setup_rpc(); + + std::vector<gr_complex> get(); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_CTRLPORT_GR_CTRLPORT_PROBE_C_IMPL_H */ + diff --git a/gr-blocks/lib/endian_swap_impl.cc b/gr-blocks/lib/endian_swap_impl.cc new file mode 100644 index 0000000000..7e67c30147 --- /dev/null +++ b/gr-blocks/lib/endian_swap_impl.cc @@ -0,0 +1,110 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2010,2012,2013 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 "endian_swap_impl.h" +#include <gr_io_signature.h> +#include <volk/volk.h> + +namespace gr { + namespace blocks { + + endian_swap::sptr + endian_swap::make(size_t item_size_bytes) + { + return gnuradio::get_initial_sptr + (new endian_swap_impl(item_size_bytes)); + } + + endian_swap_impl::endian_swap_impl (size_t item_size_bytes) + : gr_sync_block("endian_swap_impl", + gr_make_io_signature(1, 1, item_size_bytes), + gr_make_io_signature(1, 1, item_size_bytes)) + { + const int alignment_multiple = volk_get_alignment(); + set_alignment(std::max(1, alignment_multiple)); + } + + endian_swap_impl::~endian_swap_impl() + { + } + + int + endian_swap_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + const char *in = (const char*)input_items[0]; + char *out = (char*)output_items[0]; + + int nbytes(output_signature()->sizeof_stream_item(0)); + if(is_unaligned()) { + switch(nbytes){ + case 1: + memcpy(out,in,noutput_items); + break; + case 2: + memcpy(out,in,2*noutput_items); + volk_16u_byteswap_u((uint16_t*)out,noutput_items); + break; + case 4: + memcpy(out,in,4*noutput_items); + volk_32u_byteswap_u((uint32_t*)out,noutput_items); + break; + case 8: + memcpy(out,in,8*noutput_items); + volk_64u_byteswap_u((uint64_t*)out,noutput_items); + break; + default: + throw std::runtime_error("itemsize is not valid for endian_swap!"); + } + } + else { + switch(nbytes) { + case 1: + memcpy(out,in,noutput_items); + break; + case 2: + memcpy(out,in,2*noutput_items); + volk_16u_byteswap_a((uint16_t*)out,noutput_items); + break; + case 4: + memcpy(out,in,4*noutput_items); + volk_32u_byteswap_a((uint32_t*)out,noutput_items); + break; + case 8: + memcpy(out,in,8*noutput_items); + volk_64u_byteswap_a((uint64_t*)out,noutput_items); + break; + default: + throw std::runtime_error("itemsize is not valid for endian_swap!"); + } + } + + return noutput_items; + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gnuradio-core/src/lib/io/i2c.h b/gr-blocks/lib/endian_swap_impl.h index 6b7f25a293..517df44f17 100644 --- a/gnuradio-core/src/lib/io/i2c.h +++ b/gr-blocks/lib/endian_swap_impl.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2001,2004 Free Software Foundation, Inc. + * Copyright 2004,2012,2013 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,30 +20,29 @@ * Boston, MA 02110-1301, USA. */ -#ifndef INCLUDED_I2C_H -#define INCLUDED_I2C_H +#ifndef INCLUDED_GR_ENDIAN_SWAP_IMPL_H +#define INCLUDED_GR_ENDIAN_SWAP_IMPL_H -#include <gr_core_api.h> -#include <boost/shared_ptr.hpp> +#include <blocks/endian_swap.h> -class i2c; -typedef boost::shared_ptr<i2c> i2c_sptr; +namespace gr { + namespace blocks { -/*! - * \brief abstract class for controlling i2c bus - */ -class GR_CORE_API i2c { - public: - - i2c () {} - virtual ~i2c (); + class endian_swap_impl : public endian_swap + { + private: + size_t item_size_bytes; - //! \returns true iff successful - virtual bool write (int addr, const unsigned char *buf, int nbytes) = 0; + public: + endian_swap_impl(size_t item_size_bytes); + ~endian_swap_impl(); - //! \returns number of bytes read or -1 if error - virtual int read (int addr, unsigned char *buf, int max_bytes) = 0; -}; + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; -#endif /* INCLUDED_I2C_H */ + } /* namespace blocks */ +} /* namespace gr */ +#endif /* INCLUDED_GR_ENDIAN_SWAP_IMPL_H */ diff --git a/gr-blocks/lib/gen_sine_table.py b/gr-blocks/lib/gen_sine_table.py deleted file mode 100755 index d7d11eff11..0000000000 --- a/gr-blocks/lib/gen_sine_table.py +++ /dev/null @@ -1,77 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2004 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -import math -import sys - -def wrap (x): - if x >= 2**31: - return x - 2**32 - return x - -def gen_approx_table (f, nentries, min_x, max_x): - """return a list of nentries containing tuples of the form: - (m, c, abs_error). min_x and max_x specify the domain - of the table. - """ - r = [] - incx = float (max_x - min_x) / nentries - for i in range (nentries): - a = (i * incx) + min_x - b = ((i + 1) * incx) + min_x - m = (f(b)-f(a))/(b-a) - c = (3*a+b)*(f(a)-f(b))/(4*(b-a)) + (f((a+b)/2) + f(a))/2 - abs_error = c+m*a-f(a) - r.append ((m, c, abs_error)) - return r - -def scaled_sine (x): - return math.sin (x * math.pi / 2**31) - -def gen_sine_table (): - nbits = 10 - nentries = 2**nbits - - # min_x = -2**31 - # max_x = 2**31-1 - min_x = 0 - max_x = 2**32-1 - t = gen_approx_table (scaled_sine, nentries, min_x, max_x) - - max_error = 0 - for e in t: - max_error = max (max_error, abs (e[2])) - - # sys.stdout.write ('static const int WORDBITS = 32;\n') - # sys.stdout.write ('static const int NBITS = %d;\n' % (nbits,)) - - sys.stdout.write (' // max_error = %22.15e\n' % (max_error,)) - - # sys.stdout.write ('static const double sine_table[%d][2] = {\n'% (nentries,)) - - for e in t: - sys.stdout.write (' { %22.15e, %22.15e },\n' % (2 * e[0], e[1])) - - # sys.stdout.write ('};\n') - -if __name__ == '__main__': - gen_sine_table () diff --git a/gr-blocks/lib/head_impl.cc b/gr-blocks/lib/head_impl.cc new file mode 100644 index 0000000000..7dfa36607c --- /dev/null +++ b/gr-blocks/lib/head_impl.cc @@ -0,0 +1,75 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2009,2013 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 "head_impl.h" +#include <gr_io_signature.h> +#include <string.h> + +namespace gr { + namespace blocks { + + head::sptr + head::make(size_t sizeof_stream_item, uint64_t nitems) + { + return gnuradio::get_initial_sptr + (new head_impl(sizeof_stream_item, nitems)); + } + + head_impl::head_impl(size_t sizeof_stream_item, uint64_t nitems) + : gr_sync_block("head", + gr_make_io_signature(1, 1, sizeof_stream_item), + gr_make_io_signature(1, 1, sizeof_stream_item)), + d_nitems(nitems), d_ncopied_items(0) + { + } + + head_impl::~head_impl() + { + } + + int + head_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + if(d_ncopied_items >= d_nitems) + return -1; // Done! + + unsigned n = std::min(d_nitems - d_ncopied_items, + (uint64_t)noutput_items); + + if(n == 0) + return 0; + + memcpy(output_items[0], input_items[0], + n * input_signature()->sizeof_stream_item (0)); + d_ncopied_items += n; + + return n; + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/head_impl.h b/gr-blocks/lib/head_impl.h new file mode 100644 index 0000000000..a56acfbb27 --- /dev/null +++ b/gr-blocks/lib/head_impl.h @@ -0,0 +1,52 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2009,2012,2013 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_HEAD_IMPL_H +#define INCLUDED_GR_HEAD_IMPL_H + +#include <blocks/head.h> + +namespace gr { + namespace blocks { + + class head_impl : public head + { + private: + uint64_t d_nitems; + uint64_t d_ncopied_items; + + public: + head_impl(size_t sizeof_stream_item, uint64_t nitems); + ~head_impl(); + + void reset() { d_ncopied_items = 0; } + void set_length(int nitems) { d_nitems = nitems; } + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_HEAD_IMPL_H */ diff --git a/gr-blocks/lib/lfsr_32k_source_s_impl.cc b/gr-blocks/lib/lfsr_32k_source_s_impl.cc new file mode 100644 index 0000000000..738e732b49 --- /dev/null +++ b/gr-blocks/lib/lfsr_32k_source_s_impl.cc @@ -0,0 +1,79 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2010,2013 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 "lfsr_32k_source_s_impl.h" +#include <gr_io_signature.h> +#include <stdexcept> + +namespace gr { + namespace blocks { + + lfsr_32k_source_s::sptr + lfsr_32k_source_s::make() + { + return gnuradio::get_initial_sptr + (new lfsr_32k_source_s_impl()); + } + + lfsr_32k_source_s_impl::lfsr_32k_source_s_impl() + : gr_sync_block("lfsr_32k_source_s", + gr_make_io_signature(0, 0, 0), + gr_make_io_signature(1, 1, sizeof(short))), + d_index(0) + { + lfsr_32k lfsr; + + for(int i = 0; i < BUFSIZE; i++) + d_buffer[i] = lfsr.next_short(); + } + + lfsr_32k_source_s_impl::~lfsr_32k_source_s_impl() + { + } + + int + lfsr_32k_source_s_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + short *out = (short*)output_items[0]; + short *buf = d_buffer; + int index = d_index; + + for(int i = 0; i < noutput_items; i++) { + out[i] = buf[index]; + // index = (index + 1) & (BUFSIZE - 1); + index = index + 1; + if(index >= BUFSIZE) + index = 0; + } + + d_index = index; + return noutput_items; + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/lfsr_32k_source_s_impl.h b/gr-blocks/lib/lfsr_32k_source_s_impl.h new file mode 100644 index 0000000000..b8c684e8d6 --- /dev/null +++ b/gr-blocks/lib/lfsr_32k_source_s_impl.h @@ -0,0 +1,52 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2013 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_LFSR_32K_SOURCE_S_IMPL_H +#define INCLUDED_GR_LFSR_32K_SOURCE_S_IMPL_H + +#include <blocks/lfsr_32k_source_s.h> +#include <blocks/lfsr_32k.h> +#include <gr_sync_block.h> + +namespace gr { + namespace blocks { + + class lfsr_32k_source_s_impl : public lfsr_32k_source_s + { + private: + static const int BUFSIZE = 2048 - 1; // ensure pattern isn't packet aligned + int d_index; + short d_buffer[BUFSIZE]; + + public: + lfsr_32k_source_s_impl(); + ~lfsr_32k_source_s_impl(); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_LFSR_32K_SOURCE_S_IMPL_H */ diff --git a/gr-blocks/lib/nop_impl.cc b/gr-blocks/lib/nop_impl.cc new file mode 100644 index 0000000000..387eda0baf --- /dev/null +++ b/gr-blocks/lib/nop_impl.cc @@ -0,0 +1,100 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2010,2013 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 "nop_impl.h" +#include <gr_io_signature.h> +#include <boost/bind.hpp> + +namespace gr { + namespace blocks { + + nop::sptr + nop::make(size_t sizeof_stream_item) + { + return gnuradio::get_initial_sptr + (new nop_impl(sizeof_stream_item)); + } + + nop_impl::nop_impl (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)), + d_nmsgs_recvd(0) + { + // Arrange to have count_received_msgs called when messages are received. + message_port_register_in(pmt::mp("port")); + set_msg_handler(pmt::mp("port"), boost::bind(&nop_impl::count_received_msgs, this, _1)); + } + + nop_impl::~nop_impl() + { + } + + // Trivial message handler that just counts them. + // (N.B., This feature is used in qa_set_msg_handler) + void + nop_impl::count_received_msgs(pmt::pmt_t msg) + { + d_nmsgs_recvd++; + } + + int + nop_impl::general_work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + // eat any input that's available + for(unsigned i = 0; i < ninput_items.size (); i++) + consume(i, ninput_items[i]); + + return noutput_items; + } + + void + nop_impl::setup_rpc() + { +#ifdef GR_CTRLPORT + d_rpc_vars.push_back( + rpcbasic_sptr(new rpcbasic_register_get<nop, int>( + alias(), "test", + &nop::ctrlport_test, + pmt::mp(-256), pmt::mp(255), pmt::mp(0), + "", "Simple testing variable", + RPC_PRIVLVL_MIN, DISPNULL))); + + d_rpc_vars.push_back( + rpcbasic_sptr(new rpcbasic_register_set<nop, int>( + alias(), "test", + &nop::set_ctrlport_test, + pmt::mp(-256), pmt::mp(255), pmt::mp(0), + "", "Simple testing variable", + RPC_PRIVLVL_MIN, DISPNULL))); +#endif /* GR_CTRLPORT */ + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/nop_impl.h b/gr-blocks/lib/nop_impl.h new file mode 100644 index 0000000000..e01e8fc9d9 --- /dev/null +++ b/gr-blocks/lib/nop_impl.h @@ -0,0 +1,60 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2010,2013 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_NOP_IMPL_H +#define INCLUDED_GR_NOP_IMPL_H + +#include <blocks/nop.h> + +namespace gr { + namespace blocks { + + class nop_impl : public nop + { + protected: + int d_nmsgs_recvd; + int d_ctrlport_test; + + // Method that just counts any received messages. + void count_received_msgs(pmt::pmt_t msg); + + public: + nop_impl(size_t sizeof_stream_item); + ~nop_impl(); + + void setup_rpc(); + + int nmsgs_received() const { return d_nmsgs_recvd; } + + int ctrlport_test() const { return d_ctrlport_test; } + void set_ctrlport_test(int x) { d_ctrlport_test = x; } + + int general_work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_NOP_IMPL_H */ diff --git a/gnuradio-core/src/lib/general/gr_null_source.cc b/gr-blocks/lib/null_sink_impl.cc index 1ad5c351d6..b780a2405a 100644 --- a/gnuradio-core/src/lib/general/gr_null_source.cc +++ b/gr-blocks/lib/null_sink_impl.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2010 Free Software Foundation, Inc. + * Copyright 2004,2010,2013 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -24,29 +24,37 @@ #include "config.h" #endif -#include <gr_null_source.h> +#include "null_sink_impl.h" #include <gr_io_signature.h> -#include <string.h> - -gr_null_source::gr_null_source (size_t sizeof_stream_item) - : gr_sync_block ("null_source", - gr_make_io_signature (0, 0, 0), - gr_make_io_signature (1, 1, sizeof_stream_item)) -{ -} - -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)); -} - -int -gr_null_source::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - void *optr = (void *) output_items[0]; - memset (optr, 0, noutput_items * output_signature()->sizeof_stream_item (0)); - return noutput_items; -} + +namespace gr { + namespace blocks { + + null_sink::sptr + null_sink::make(size_t sizeof_stream_item) + { + return gnuradio::get_initial_sptr + (new null_sink_impl(sizeof_stream_item)); + } + + null_sink_impl::null_sink_impl(size_t sizeof_stream_item) + : gr_sync_block("null_sink", + gr_make_io_signature(1, 1, sizeof_stream_item), + gr_make_io_signature(0, 0, 0)) + { + } + + null_sink_impl::~null_sink_impl() + { + } + + int + null_sink_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + return noutput_items; + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/fxpt.cc b/gr-blocks/lib/null_sink_impl.h index 4566f7c595..bb4c695c23 100644 --- a/gr-blocks/lib/fxpt.cc +++ b/gr-blocks/lib/null_sink_impl.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2013 Free Software Foundation, Inc. + * Copyright 2004,2010,2013 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,21 +20,26 @@ * Boston, MA 02110-1301, USA. */ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif +#ifndef INCLUDED_GR_NULL_SINK_IMPL_H +#define INCLUDED_GR_NULL_SINK_IMPL_H -#include <blocks/fxpt.h> +#include <blocks/null_sink.h> namespace gr { namespace blocks { - const float fxpt::s_sine_table[1 << NBITS][2] = { - #include "sine_table.h" - }; + class null_sink_impl : public null_sink + { + public: + null_sink_impl(size_t sizeof_stream_item); + ~null_sink_impl(); - const float fxpt::PI = 3.14159265358979323846; - const float fxpt::TWO_TO_THE_31 = 2147483648.0; + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; } /* namespace blocks */ } /* namespace gr */ + +#endif /* INCLUDED_GR_NULL_SINK_IMPL_H */ diff --git a/gr-blocks/lib/null_source_impl.cc b/gr-blocks/lib/null_source_impl.cc new file mode 100644 index 0000000000..81999d0501 --- /dev/null +++ b/gr-blocks/lib/null_source_impl.cc @@ -0,0 +1,63 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2010,2013 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 "null_source_impl.h" +#include <gr_io_signature.h> +#include <string.h> + +namespace gr { + namespace blocks { + + null_source::sptr + null_source::make(size_t sizeof_stream_item) + { + return gnuradio::get_initial_sptr + (new null_source_impl(sizeof_stream_item)); + } + + null_source_impl::null_source_impl (size_t sizeof_stream_item) + : gr_sync_block("null_source", + gr_make_io_signature(0, 0, 0), + gr_make_io_signature(1, 1, sizeof_stream_item)) + { + } + + null_source_impl::~null_source_impl() + { + } + + int + null_source_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + void *optr = (void*)output_items[0]; + memset(optr, 0, noutput_items * output_signature()->sizeof_stream_item(0)); + return noutput_items; + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-analog/include/analog/sincos.h b/gr-blocks/lib/null_source_impl.h index a71164c885..36201d54b6 100644 --- a/gr-analog/include/analog/sincos.h +++ b/gr-blocks/lib/null_source_impl.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2002,2004,2012 Free Software Foundation, Inc. + * Copyright 2004,2010,2013 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,21 +20,26 @@ * Boston, MA 02110-1301, USA. */ -#ifndef INCLUDED_ANALOG_SINCOS_H -#define INCLUDED_ANALOG_SINCOS_H +#ifndef INCLUDED_GR_NULL_SOURCE_IMPL_H +#define INCLUDED_GR_NULL_SOURCE_IMPL_H -#include <analog/api.h> +#include <blocks/null_source.h> namespace gr { - namespace analog { + namespace blocks { - //! compute double sine and cosine at the same time - ANALOG_API void sincos(double x, double *sin, double *cos); + class null_source_impl : public null_source + { + public: + null_source_impl(size_t sizeof_stream_item); + ~null_source_impl(); - //! compute floating point sine and cosine at the same time - ANALOG_API void sincosf(float x, float *sin, float *cos); + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; - } /* namespace analog */ + } /* namespace blocks */ } /* namespace gr */ -#endif /* INCLUDED_ANALOG_SINCOS_H */ +#endif /* INCLUDED_GR_NULL_SOURCE_IMPL_H */ diff --git a/gnuradio-core/src/lib/runtime/qa_block_tags.cc b/gr-blocks/lib/qa_block_tags.cc index c3c18cac01..f3139245d8 100644 --- a/gnuradio-core/src/lib/runtime/qa_block_tags.cc +++ b/gr-blocks/lib/qa_block_tags.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2010 Free Software Foundation, Inc. + * Copyright 2010,2013 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -27,16 +27,19 @@ #include <qa_block_tags.h> #include <gr_block.h> #include <gr_top_block.h> -#include <gr_null_source.h> -#include <gr_null_sink.h> -#include <gr_head.h> -#include <gr_annotator_alltoall.h> -#include <gr_annotator_1to1.h> +#include <blocks/null_source.h> +#include <blocks/null_sink.h> +#include <blocks/head.h> +#include <blocks/annotator_alltoall.h> +#include <blocks/annotator_1to1.h> +#include <blocks/keep_one_in_n.h> #include <gr_tags.h> // ---------------------------------------------------------------- +using namespace pmt; + // set to 1 to turn on debug output // The debug output fully checks that the tags seen are what are expected. While // this behavior currently works with our implementation, there is no guarentee @@ -47,13 +50,13 @@ #define QA_TAGS_DEBUG 0 void -qa_block_tags::t0 () +qa_block_tags::t0() { unsigned int N = 1000; gr_top_block_sptr tb = gr_make_top_block("top"); - gr_block_sptr src (gr_make_null_source(sizeof(int))); - gr_block_sptr head (gr_make_head(sizeof(int), N)); - gr_block_sptr snk (gr_make_null_sink(sizeof(int))); + gr_block_sptr src (gr::blocks::null_source::make(sizeof(int))); + gr_block_sptr head (gr::blocks::head::make(sizeof(int), N)); + gr_block_sptr snk (gr::blocks::null_sink::make(sizeof(int))); tb->connect(src, 0, head, 0); tb->connect(head, 0, snk, 0); @@ -73,19 +76,19 @@ qa_block_tags::t0 () void -qa_block_tags::t1 () +qa_block_tags::t1() { int N = 40000; gr_top_block_sptr tb = gr_make_top_block("top"); - gr_block_sptr src (gr_make_null_source(sizeof(int))); - gr_block_sptr head (gr_make_head(sizeof(int), N)); - gr_annotator_alltoall_sptr ann0 (gr_make_annotator_alltoall(10000, sizeof(int))); - gr_annotator_alltoall_sptr ann1 (gr_make_annotator_alltoall(10000, sizeof(int))); - gr_annotator_alltoall_sptr ann2 (gr_make_annotator_alltoall(10000, sizeof(int))); - gr_annotator_alltoall_sptr ann3 (gr_make_annotator_alltoall(10000, sizeof(int))); - gr_annotator_alltoall_sptr ann4 (gr_make_annotator_alltoall(10000, sizeof(int))); - gr_block_sptr snk0 (gr_make_null_sink(sizeof(int))); - gr_block_sptr snk1 (gr_make_null_sink(sizeof(int))); + gr_block_sptr src (gr::blocks::null_source::make(sizeof(int))); + gr_block_sptr head (gr::blocks::head::make(sizeof(int), N)); + gr::blocks::annotator_alltoall::sptr ann0(gr::blocks::annotator_alltoall::make(10000, sizeof(int))); + gr::blocks::annotator_alltoall::sptr ann1(gr::blocks::annotator_alltoall::make(10000, sizeof(int))); + gr::blocks::annotator_alltoall::sptr ann2(gr::blocks::annotator_alltoall::make(10000, sizeof(int))); + gr::blocks::annotator_alltoall::sptr ann3(gr::blocks::annotator_alltoall::make(10000, sizeof(int))); + gr::blocks::annotator_alltoall::sptr ann4(gr::blocks::annotator_alltoall::make(10000, sizeof(int))); + gr_block_sptr snk0 (gr::blocks::null_sink::make(sizeof(int))); + gr_block_sptr snk1 (gr::blocks::null_sink::make(sizeof(int))); tb->connect(src, 0, head, 0); tb->connect(head, 0, ann0, 0); @@ -116,7 +119,7 @@ qa_block_tags::t1 () str1 << ann1->name() << ann1->unique_id(); str2 << ann2->name() << ann2->unique_id(); - pmt::pmt_t expected_tags3[8]; + pmt_t expected_tags3[8]; expected_tags3[0] = mp(pmt::from_uint64(0), mp(str1.str()), mp("seq"), mp(0)); expected_tags3[1] = mp(pmt::from_uint64(0), mp(str0.str()), mp("seq"), mp(0)); expected_tags3[2] = mp(pmt::from_uint64(10000), mp(str1.str()), mp("seq"), mp(1)); @@ -126,7 +129,7 @@ qa_block_tags::t1 () expected_tags3[6] = mp(pmt::from_uint64(30000), mp(str1.str()), mp("seq"), mp(3)); expected_tags3[7] = mp(pmt::from_uint64(30000), mp(str0.str()), mp("seq"), mp(6)); - pmt::pmt_t expected_tags4[8]; + pmt_t expected_tags4[8]; expected_tags4[0] = mp(pmt::from_uint64(0), mp(str2.str()), mp("seq"), mp(0)); expected_tags4[1] = mp(pmt::from_uint64(0), mp(str0.str()), mp("seq"), mp(1)); expected_tags4[2] = mp(pmt::from_uint64(10000), mp(str2.str()), mp("seq"), mp(1)); @@ -158,16 +161,16 @@ qa_block_tags::t2 () { int N = 40000; gr_top_block_sptr tb = gr_make_top_block("top"); - gr_block_sptr src (gr_make_null_source(sizeof(int))); - gr_block_sptr head (gr_make_head(sizeof(int), N)); - gr_annotator_alltoall_sptr ann0 (gr_make_annotator_alltoall(10000, sizeof(int))); - gr_annotator_alltoall_sptr ann1 (gr_make_annotator_alltoall(10000, sizeof(int))); - gr_annotator_alltoall_sptr ann2 (gr_make_annotator_alltoall(10000, sizeof(int))); - gr_annotator_alltoall_sptr ann3 (gr_make_annotator_alltoall(10000, sizeof(int))); - gr_annotator_alltoall_sptr ann4 (gr_make_annotator_alltoall(10000, sizeof(int))); - gr_block_sptr snk0 (gr_make_null_sink(sizeof(int))); - gr_block_sptr snk1 (gr_make_null_sink(sizeof(int))); - gr_block_sptr snk2 (gr_make_null_sink(sizeof(int))); + gr_block_sptr src (gr::blocks::null_source::make(sizeof(int))); + gr_block_sptr head (gr::blocks::head::make(sizeof(int), N)); + gr::blocks::annotator_alltoall::sptr ann0(gr::blocks::annotator_alltoall::make(10000, sizeof(int))); + gr::blocks::annotator_alltoall::sptr ann1(gr::blocks::annotator_alltoall::make(10000, sizeof(int))); + gr::blocks::annotator_alltoall::sptr ann2(gr::blocks::annotator_alltoall::make(10000, sizeof(int))); + gr::blocks::annotator_alltoall::sptr ann3(gr::blocks::annotator_alltoall::make(10000, sizeof(int))); + gr::blocks::annotator_alltoall::sptr ann4(gr::blocks::annotator_alltoall::make(10000, sizeof(int))); + gr_block_sptr snk0 (gr::blocks::null_sink::make(sizeof(int))); + gr_block_sptr snk1 (gr::blocks::null_sink::make(sizeof(int))); + gr_block_sptr snk2 (gr::blocks::null_sink::make(sizeof(int))); tb->connect(src, 0, head, 0); tb->connect(head, 0, ann0, 0); @@ -206,7 +209,7 @@ qa_block_tags::t2 () str0 << ann0->name() << ann0->unique_id(); str1 << ann1->name() << ann1->unique_id(); - pmt::pmt_t expected_tags2[12]; + pmt_t expected_tags2[12]; expected_tags2[0] = mp(pmt::from_uint64(0), mp(str1.str()), mp("seq"), mp(0)); expected_tags2[1] = mp(pmt::from_uint64(0), mp(str0.str()), mp("seq"), mp(0)); expected_tags2[2] = mp(pmt::from_uint64(0), mp(str0.str()), mp("seq"), mp(1)); @@ -220,7 +223,7 @@ qa_block_tags::t2 () expected_tags2[10] = mp(pmt::from_uint64(30000), mp(str0.str()), mp("seq"), mp(6)); expected_tags2[11] = mp(pmt::from_uint64(30000), mp(str0.str()), mp("seq"), mp(7)); - pmt::pmt_t expected_tags4[12]; + pmt_t expected_tags4[12]; expected_tags4[0] = mp(pmt::from_uint64(0), mp(str1.str()), mp("seq"), mp(2)); expected_tags4[1] = mp(pmt::from_uint64(0), mp(str0.str()), mp("seq"), mp(0)); expected_tags4[2] = mp(pmt::from_uint64(0), mp(str0.str()), mp("seq"), mp(1)); @@ -255,19 +258,19 @@ qa_block_tags::t2 () void -qa_block_tags::t3 () +qa_block_tags::t3() { int N = 40000; gr_top_block_sptr tb = gr_make_top_block("top"); - gr_block_sptr src (gr_make_null_source(sizeof(int))); - gr_block_sptr head (gr_make_head(sizeof(int), N)); - gr_annotator_1to1_sptr ann0 (gr_make_annotator_1to1(10000, sizeof(int))); - gr_annotator_alltoall_sptr ann1 (gr_make_annotator_alltoall(10000, sizeof(int))); - gr_annotator_alltoall_sptr ann2 (gr_make_annotator_alltoall(10000, sizeof(int))); - gr_annotator_1to1_sptr ann3 (gr_make_annotator_1to1(10000, sizeof(int))); - gr_annotator_1to1_sptr ann4 (gr_make_annotator_1to1(10000, sizeof(int))); - gr_block_sptr snk0 (gr_make_null_sink(sizeof(int))); - gr_block_sptr snk1 (gr_make_null_sink(sizeof(int))); + gr_block_sptr src (gr::blocks::null_source::make(sizeof(int))); + gr_block_sptr head (gr::blocks::head::make(sizeof(int), N)); + gr::blocks::annotator_1to1::sptr ann0 (gr::blocks::annotator_1to1::make(10000, sizeof(int))); + gr::blocks::annotator_alltoall::sptr ann1 (gr::blocks::annotator_alltoall::make(10000, sizeof(int))); + gr::blocks::annotator_alltoall::sptr ann2 (gr::blocks::annotator_alltoall::make(10000, sizeof(int))); + gr::blocks::annotator_1to1::sptr ann3 (gr::blocks::annotator_1to1::make(10000, sizeof(int))); + gr::blocks::annotator_1to1::sptr ann4 (gr::blocks::annotator_1to1::make(10000, sizeof(int))); + gr_block_sptr snk0 (gr::blocks::null_sink::make(sizeof(int))); + gr_block_sptr snk1 (gr::blocks::null_sink::make(sizeof(int))); tb->connect(src, 0, head, 0); tb->connect(head, 0, ann0, 0); @@ -300,7 +303,7 @@ qa_block_tags::t3 () str1 << ann1->name() << ann1->unique_id(); str2 << ann2->name() << ann2->unique_id(); - pmt::pmt_t expected_tags3[8]; + pmt_t expected_tags3[8]; expected_tags3[0] = mp(pmt::from_uint64(0), mp(str1.str()), mp("seq"), mp(0)); expected_tags3[1] = mp(pmt::from_uint64(0), mp(str0.str()), mp("seq"), mp(0)); expected_tags3[2] = mp(pmt::from_uint64(10000), mp(str1.str()), mp("seq"), mp(1)); @@ -310,7 +313,7 @@ qa_block_tags::t3 () expected_tags3[6] = mp(pmt::from_uint64(30000), mp(str1.str()), mp("seq"), mp(3)); expected_tags3[7] = mp(pmt::from_uint64(30000), mp(str0.str()), mp("seq"), mp(6)); - pmt::pmt_t expected_tags4[8]; + pmt_t expected_tags4[8]; expected_tags4[0] = mp(pmt::from_uint64(0), mp(str2.str()), mp("seq"), mp(0)); expected_tags4[1] = mp(pmt::from_uint64(0), mp(str0.str()), mp("seq"), mp(1)); expected_tags4[2] = mp(pmt::from_uint64(10000), mp(str2.str()), mp("seq"), mp(1)); @@ -339,17 +342,17 @@ qa_block_tags::t3 () void -qa_block_tags::t4 () +qa_block_tags::t4() { int N = 40000; gr_top_block_sptr tb = gr_make_top_block("top"); - gr_block_sptr src (gr_make_null_source(sizeof(int))); - gr_block_sptr head (gr_make_head(sizeof(int), N)); - gr_annotator_1to1_sptr ann0 (gr_make_annotator_1to1(10000, sizeof(int))); - gr_annotator_1to1_sptr ann1 (gr_make_annotator_1to1(10000, sizeof(int))); - gr_annotator_1to1_sptr ann2 (gr_make_annotator_1to1(10000, sizeof(int))); - gr_block_sptr snk0 (gr_make_null_sink(sizeof(int))); - gr_block_sptr snk1 (gr_make_null_sink(sizeof(int))); + gr_block_sptr src (gr::blocks::null_source::make(sizeof(int))); + gr_block_sptr head (gr::blocks::head::make(sizeof(int), N)); + gr::blocks::annotator_1to1::sptr ann0(gr::blocks::annotator_1to1::make(10000, sizeof(int))); + gr::blocks::annotator_1to1::sptr ann1(gr::blocks::annotator_1to1::make(10000, sizeof(int))); + gr::blocks::annotator_1to1::sptr ann2(gr::blocks::annotator_1to1::make(10000, sizeof(int))); + gr_block_sptr snk0 (gr::blocks::null_sink::make(sizeof(int))); + gr_block_sptr snk1 (gr::blocks::null_sink::make(sizeof(int))); // using 1-to-1 tag propagation without having equal number of // ins and outs. Make sure this works; will just exit run early. @@ -367,21 +370,20 @@ qa_block_tags::t4 () } -/* void -qa_block_tags::t5 () +qa_block_tags::t5() { int N = 40000; gr_top_block_sptr tb = gr_make_top_block("top"); - gr_block_sptr src (gr_make_null_source(sizeof(float))); - gr_block_sptr head (gr_make_head(sizeof(float), N)); - gr_annotator_alltoall_sptr ann0 (gr_make_annotator_alltoall(10000, sizeof(float))); - gr_annotator_alltoall_sptr ann1 (gr_make_annotator_alltoall(10000, sizeof(float))); - gr_annotator_alltoall_sptr ann2 (gr_make_annotator_alltoall(1000, sizeof(float))); - gr_block_sptr snk0 (gr_make_null_sink(sizeof(float))); + gr_block_sptr src (gr::blocks::null_source::make(sizeof(float))); + gr_block_sptr head (gr::blocks::head::make(sizeof(float), N)); + gr::blocks::annotator_alltoall::sptr ann0(gr::blocks::annotator_alltoall::make(10000, sizeof(float))); + gr::blocks::annotator_alltoall::sptr ann1(gr::blocks::annotator_alltoall::make(10000, sizeof(float))); + gr::blocks::annotator_alltoall::sptr ann2(gr::blocks::annotator_alltoall::make(1000, sizeof(float))); + gr_block_sptr snk0 (gr::blocks::null_sink::make(sizeof(float))); // Rate change blocks - gr_keep_one_in_n_sptr dec10 (gr_make_keep_one_in_n(sizeof(float), 10)); + gr::blocks::keep_one_in_n::sptr dec10(gr::blocks::keep_one_in_n::make(sizeof(float), 10)); tb->connect(src, 0, head, 0); tb->connect(head, 0, ann0, 0); @@ -409,13 +411,13 @@ qa_block_tags::t5 () str1 << ann1->name() << ann1->unique_id(); str2 << ann2->name() << ann2->unique_id(); - pmt::pmt_t expected_tags1[5]; + pmt_t expected_tags1[5]; expected_tags1[0] = mp(pmt::from_uint64(0), mp(str0.str()), mp("seq"), mp(0)); expected_tags1[1] = mp(pmt::from_uint64(10000), mp(str0.str()), mp("seq"), mp(1)); expected_tags1[2] = mp(pmt::from_uint64(20000), mp(str0.str()), mp("seq"), mp(2)); expected_tags1[3] = mp(pmt::from_uint64(30000), mp(str0.str()), mp("seq"), mp(3)); - pmt::pmt_t expected_tags2[10]; + pmt_t expected_tags2[10]; expected_tags2[0] = mp(pmt::from_uint64(0), mp(str1.str()), mp("seq"), mp(0)); expected_tags2[1] = mp(pmt::from_uint64(0), mp(str0.str()), mp("seq"), mp(0)); expected_tags2[2] = mp(pmt::from_uint64(1000), mp(str1.str()), mp("seq"), mp(1)); @@ -445,4 +447,4 @@ qa_block_tags::t5 () } #endif } -*/ + diff --git a/gr-blocks/lib/qa_fxpt_vco.h b/gr-blocks/lib/qa_block_tags.h index 72693f32e2..83bebe23f6 100644 --- a/gr-blocks/lib/qa_fxpt_vco.h +++ b/gr-blocks/lib/qa_block_tags.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2005,2013 Free Software Foundation, Inc. + * Copyright 2010,2013 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,28 +20,31 @@ * Boston, MA 02110-1301, USA. */ -#ifndef INCLUDED_QA_GR_FXPT_VCO_H -#define INCLUDED_QA_GR_FXPT_VCO_H +#ifndef INCLUDED_QA_BLOCK_TAGS_H +#define INCLUDED_QA_BLOCK_TAGS_H #include <cppunit/extensions/HelperMacros.h> #include <cppunit/TestCase.h> +#include <stdexcept> -class qa_fxpt_vco : public CppUnit::TestCase +class qa_block_tags : public CppUnit::TestCase { - CPPUNIT_TEST_SUITE(qa_fxpt_vco); + CPPUNIT_TEST_SUITE(qa_block_tags); CPPUNIT_TEST(t0); CPPUNIT_TEST(t1); CPPUNIT_TEST(t2); CPPUNIT_TEST(t3); + CPPUNIT_TEST(t4); + CPPUNIT_TEST(t5); CPPUNIT_TEST_SUITE_END(); -private: + private: void t0(); void t1(); void t2(); void t3(); + void t4(); + void t5(); }; -#endif /* INCLUDED_QA_GR_FXPT_VCO_H */ - - +#endif /* INCLUDED_QA_BLOCK_TAGS_H */ diff --git a/gr-blocks/lib/qa_blocks.cc b/gr-blocks/lib/qa_blocks.cc index fbae11d264..409b5d5762 100644 --- a/gr-blocks/lib/qa_blocks.cc +++ b/gr-blocks/lib/qa_blocks.cc @@ -26,18 +26,16 @@ */ #include <qa_blocks.h> -#include <qa_fxpt.h> -#include <qa_fxpt_nco.h> -#include <qa_fxpt_vco.h> +#include <qa_block_tags.h> +#include <qa_rotator.h> CppUnit::TestSuite * qa_gr_blocks::suite() { CppUnit::TestSuite *s = new CppUnit::TestSuite("gr-blocks"); - s->addTest(qa_fxpt::suite()); - s->addTest(qa_fxpt_nco::suite()); - s->addTest(qa_fxpt_vco::suite()); + s->addTest(qa_block_tags::suite()); + s->addTest(qa_rotator::suite()); return s; } diff --git a/gr-blocks/lib/qa_fxpt.cc b/gr-blocks/lib/qa_fxpt.cc deleted file mode 100644 index 9ce26b240b..0000000000 --- a/gr-blocks/lib/qa_fxpt.cc +++ /dev/null @@ -1,104 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2013 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 <qa_fxpt.h> -#include <blocks/fxpt.h> -#include <cppunit/TestAssert.h> -#include <iostream> -#include <stdio.h> -#include <unistd.h> -#include <math.h> - -static const float SIN_COS_TOLERANCE = 1e-5; - -using namespace gr::blocks; - -void -qa_fxpt::t0() -{ - CPPUNIT_ASSERT_DOUBLES_EQUAL(M_PI/2, fxpt::fixed_to_float(0x40000000), SIN_COS_TOLERANCE); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, fxpt::fixed_to_float(0x00000000), SIN_COS_TOLERANCE); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-M_PI, fxpt::fixed_to_float(0x80000000), SIN_COS_TOLERANCE); - - if(0) { - /* - * These are disabled because of some precision issues. - * - * Different compilers seem to have different opinions on whether - * the calulations are done single or double (or extended) - * precision. Any of the answers are fine for our real purpose, but - * sometimes the answer is off by a few bits at the bottom. - * Hence, the disabled check. - */ - CPPUNIT_ASSERT_EQUAL((int32_t) 0x40000000, fxpt::float_to_fixed(M_PI/2)); - CPPUNIT_ASSERT_EQUAL((int32_t) 0, fxpt::float_to_fixed(0)); - CPPUNIT_ASSERT_EQUAL((int32_t) 0x80000000, fxpt::float_to_fixed(-M_PI)); - } -} - -void -qa_fxpt::t1() -{ - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0, fxpt::sin (0x00000000), SIN_COS_TOLERANCE); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.707106781, fxpt::sin (0x20000000), SIN_COS_TOLERANCE); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 1, fxpt::sin (0x40000000), SIN_COS_TOLERANCE); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.707106781, fxpt::sin (0x60000000), SIN_COS_TOLERANCE); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0, fxpt::sin (0x7fffffff), SIN_COS_TOLERANCE); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0, fxpt::sin (0x80000000), SIN_COS_TOLERANCE); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0, fxpt::sin (0x80000001), SIN_COS_TOLERANCE); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-1, fxpt::sin (-0x40000000), SIN_COS_TOLERANCE); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-0.707106781, fxpt::sin (-0x20000000), SIN_COS_TOLERANCE); - - for(float p = -M_PI; p < M_PI; p += 2 * M_PI / 3600) { - float expected = sin(p); - float actual = fxpt::sin(fxpt::float_to_fixed(p)); - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected, actual, SIN_COS_TOLERANCE); - } -} - -void -qa_fxpt::t2() -{ - for(float p = -M_PI; p < M_PI; p += 2 * M_PI / 3600) { - float expected = cos(p); - float actual = fxpt::cos(fxpt::float_to_fixed(p)); - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected, actual, SIN_COS_TOLERANCE); - } -} - -void -qa_fxpt::t3() -{ - for(float p = -M_PI; p < M_PI; p += 2 * M_PI / 3600) { - float expected_sin = sin(p); - float expected_cos = cos(p); - float actual_sin; - float actual_cos; - fxpt::sincos(fxpt::float_to_fixed(p), &actual_sin, &actual_cos); - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected_sin, actual_sin, SIN_COS_TOLERANCE); - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected_cos, actual_cos, SIN_COS_TOLERANCE); - } -} diff --git a/gr-blocks/lib/qa_fxpt_nco.cc b/gr-blocks/lib/qa_fxpt_nco.cc deleted file mode 100644 index 63c0a92902..0000000000 --- a/gr-blocks/lib/qa_fxpt_nco.cc +++ /dev/null @@ -1,122 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2013 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 <qa_fxpt_nco.h> -#include <blocks/fxpt_nco.h> -#include <blocks/nco.h> -#include <cppunit/TestAssert.h> -#include <iostream> -#include <stdio.h> -#include <unistd.h> -#include <math.h> - -using namespace gr::blocks; - -static const float SIN_COS_TOLERANCE = 1e-5; - -//static const float SIN_COS_FREQ = 5003; -static const float SIN_COS_FREQ = 4096; - -static const int SIN_COS_BLOCK_SIZE = 100000; - -static double max_d(double a, double b) -{ - return fabs(a) > fabs(b) ? a : b; -} - -void -qa_fxpt_nco::t0() -{ - nco<float,float> ref_nco; - fxpt_nco new_nco; - double max_error = 0, max_phase_error = 0; - - ref_nco.set_freq((float)(2 * M_PI / SIN_COS_FREQ)); - new_nco.set_freq((float)(2 * M_PI / SIN_COS_FREQ)); - - CPPUNIT_ASSERT_DOUBLES_EQUAL(ref_nco.get_freq(), new_nco.get_freq(), SIN_COS_TOLERANCE); - - for(int i = 0; i < SIN_COS_BLOCK_SIZE; i++) { - float ref_sin = ref_nco.sin(); - float new_sin = new_nco.sin(); - //printf ("i = %6d\n", i); - CPPUNIT_ASSERT_DOUBLES_EQUAL(ref_sin, new_sin, SIN_COS_TOLERANCE); - - max_error = max_d(max_error, ref_sin-new_sin); - - float ref_cos = ref_nco.cos(); - float new_cos = new_nco.cos(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(ref_cos, new_cos, SIN_COS_TOLERANCE); - - max_error = max_d(max_error, ref_cos-new_cos); - - ref_nco.step(); - new_nco.step(); - - CPPUNIT_ASSERT_DOUBLES_EQUAL(ref_nco.get_phase(), new_nco.get_phase(), SIN_COS_TOLERANCE); - - max_phase_error = max_d(max_phase_error, ref_nco.get_phase()-new_nco.get_phase()); - } - // printf("Fxpt max error %.9f, max phase error %.9f\n", max_error, max_phase_error); -} - -void -qa_fxpt_nco::t1() -{ - nco<float,float> ref_nco; - fxpt_nco new_nco; - gr_complex ref_block[SIN_COS_BLOCK_SIZE]; - gr_complex new_block[SIN_COS_BLOCK_SIZE]; - double max_error = 0; - - ref_nco.set_freq((float)(2 * M_PI / SIN_COS_FREQ)); - new_nco.set_freq((float)(2 * M_PI / SIN_COS_FREQ)); - - CPPUNIT_ASSERT_DOUBLES_EQUAL(ref_nco.get_freq(), new_nco.get_freq(), SIN_COS_TOLERANCE); - - ref_nco.sincos((gr_complex*)ref_block, SIN_COS_BLOCK_SIZE); - new_nco.sincos((gr_complex*)new_block, SIN_COS_BLOCK_SIZE); - - for(int i = 0; i < SIN_COS_BLOCK_SIZE; i++) { - CPPUNIT_ASSERT_DOUBLES_EQUAL(ref_block[i].real(), new_block[i].real(), SIN_COS_TOLERANCE); - max_error = max_d(max_error, ref_block[i].real()-new_block[i].real()); - - CPPUNIT_ASSERT_DOUBLES_EQUAL(ref_block[i].imag(), new_block[i].imag(), SIN_COS_TOLERANCE); - max_error = max_d(max_error, ref_block[i].imag()-new_block[i].imag()); - } - CPPUNIT_ASSERT_DOUBLES_EQUAL(ref_nco.get_phase(), new_nco.get_phase(), SIN_COS_TOLERANCE); - // printf("Fxpt max error %.9f, max phase error %.9f\n", max_error, max_phase_error); -} - -void -qa_fxpt_nco::t2() -{ -} - -void -qa_fxpt_nco::t3() -{ -} diff --git a/gr-blocks/lib/qa_fxpt_vco.cc b/gr-blocks/lib/qa_fxpt_vco.cc deleted file mode 100644 index 2efce0506b..0000000000 --- a/gr-blocks/lib/qa_fxpt_vco.cc +++ /dev/null @@ -1,112 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2005,2013 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 <qa_fxpt_vco.h> -#include <blocks/fxpt_vco.h> -#include <blocks/vco.h> -#include <cppunit/TestAssert.h> -#include <iostream> -#include <stdio.h> -#include <unistd.h> -#include <math.h> - -using namespace gr::blocks; - -static const float SIN_COS_TOLERANCE = 1e-5; - -static const float SIN_COS_K = 0.42; -static const float SIN_COS_AMPL = 0.8; - -static const int SIN_COS_BLOCK_SIZE = 100000; - -static double max_d(double a, double b) -{ - return fabs(a) > fabs(b) ? a : b; -} - -void -qa_fxpt_vco::t0() -{ - vco<float,float> ref_vco; - fxpt_vco new_vco; - double max_error = 0, max_phase_error = 0; - float input[SIN_COS_BLOCK_SIZE]; - - for(int i = 0; i < SIN_COS_BLOCK_SIZE; i++) { - input[i] = sin(double(i)); - } - - for(int i = 0; i < SIN_COS_BLOCK_SIZE; i++) { - float ref_cos = ref_vco.cos(); - float new_cos = new_vco.cos(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(ref_cos, new_cos, SIN_COS_TOLERANCE); - - max_error = max_d(max_error, ref_cos-new_cos); - - ref_vco.adjust_phase(input[i]); - new_vco.adjust_phase(input[i]); - - CPPUNIT_ASSERT_DOUBLES_EQUAL(ref_vco.get_phase(), new_vco.get_phase(), SIN_COS_TOLERANCE); - - max_phase_error = max_d(max_phase_error, ref_vco.get_phase()-new_vco.get_phase()); - } - // printf("Fxpt max error %.9f, max phase error %.9f\n", max_error, max_phase_error); -} - -void -qa_fxpt_vco::t1() -{ - vco<float,float> ref_vco; - fxpt_vco new_vco; - float ref_block[SIN_COS_BLOCK_SIZE]; - float new_block[SIN_COS_BLOCK_SIZE]; - float input[SIN_COS_BLOCK_SIZE]; - double max_error = 0; - - for(int i = 0; i < SIN_COS_BLOCK_SIZE; i++) { - input[i] = sin(double(i)); - } - - ref_vco.cos(ref_block, input, SIN_COS_BLOCK_SIZE, SIN_COS_K, SIN_COS_AMPL); - new_vco.cos(new_block, input, SIN_COS_BLOCK_SIZE, SIN_COS_K, SIN_COS_AMPL); - - for(int i = 0; i < SIN_COS_BLOCK_SIZE; i++) { - CPPUNIT_ASSERT_DOUBLES_EQUAL(ref_block[i], new_block[i], SIN_COS_TOLERANCE); - max_error = max_d(max_error, ref_block[i]-new_block[i]); - } - CPPUNIT_ASSERT_DOUBLES_EQUAL(ref_vco.get_phase(), new_vco.get_phase(), SIN_COS_TOLERANCE); - // printf("Fxpt max error %.9f, max phase error %.9f\n", max_error, ref_vco.get_phase()-new_vco.get_phase()); -} - -void -qa_fxpt_vco::t2() -{ -} - -void -qa_fxpt_vco::t3() -{ -} diff --git a/gnuradio-core/src/lib/runtime/qa_gr_block.cc b/gr-blocks/lib/qa_gr_block.cc index aeab5b74a8..7f4a01bbd0 100644 --- a/gnuradio-core/src/lib/runtime/qa_gr_block.cc +++ b/gr-blocks/lib/qa_gr_block.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004 Free Software Foundation, Inc. + * Copyright 2004.2013 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -23,11 +23,12 @@ #ifdef HAVE_CONFIG_H #include <config.h> #endif + #include <qa_gr_block.h> #include <gr_block.h> #include <gr_io_signature.h> -#include <gr_null_sink.h> -#include <gr_null_source.h> +#include <blocks/null_sink.h> +#include <blocks/null_source.h> // ---------------------------------------------------------------- @@ -37,21 +38,21 @@ void qa_gr_block::t0 () { // test creation of sources - gr_block_sptr src1 (gr_make_null_source (sizeof (int))); - CPPUNIT_ASSERT_EQUAL (std::string ("null_source"), src1->name ()); - CPPUNIT_ASSERT_EQUAL (0, src1->input_signature()->max_streams ()); - CPPUNIT_ASSERT_EQUAL (1, src1->output_signature()->min_streams ()); - CPPUNIT_ASSERT_EQUAL (1, src1->output_signature()->max_streams ()); - CPPUNIT_ASSERT_EQUAL ((int) sizeof(int), - src1->output_signature()->sizeof_stream_item (0)); + gr_block_sptr src1(gr::blocks::null_source::make(sizeof (int))); + CPPUNIT_ASSERT_EQUAL(std::string("null_source"), src1->name ()); + CPPUNIT_ASSERT_EQUAL(0, src1->input_signature()->max_streams ()); + CPPUNIT_ASSERT_EQUAL(1, src1->output_signature()->min_streams ()); + CPPUNIT_ASSERT_EQUAL(1, src1->output_signature()->max_streams ()); + CPPUNIT_ASSERT_EQUAL((int) sizeof(int), + src1->output_signature()->sizeof_stream_item (0)); - gr_block_sptr src2 (gr_make_null_source (sizeof (short))); - CPPUNIT_ASSERT_EQUAL (std::string ("null_source"), src2->name ()); - CPPUNIT_ASSERT_EQUAL (0, src2->input_signature()->max_streams ()); - CPPUNIT_ASSERT_EQUAL (1, src2->output_signature()->min_streams ()); - CPPUNIT_ASSERT_EQUAL (1, src2->output_signature()->max_streams ()); - CPPUNIT_ASSERT_EQUAL ((int) sizeof (short), - src2->output_signature()->sizeof_stream_item (0)); + gr_block_sptr src2(gr::blocks::null_source::make(sizeof(short))); + CPPUNIT_ASSERT_EQUAL(std::string ("null_source"), src2->name ()); + CPPUNIT_ASSERT_EQUAL(0, src2->input_signature()->max_streams ()); + CPPUNIT_ASSERT_EQUAL(1, src2->output_signature()->min_streams ()); + CPPUNIT_ASSERT_EQUAL(1, src2->output_signature()->max_streams ()); + CPPUNIT_ASSERT_EQUAL((int)sizeof (short), + src2->output_signature()->sizeof_stream_item (0)); } @@ -59,7 +60,7 @@ void qa_gr_block::t1 () { // test creation of sinks - gr_block_sptr dst1 (gr_make_null_sink (sizeof (int))); + gr_block_sptr dst1 (gr::blocks::null_sink::make (sizeof (int))); CPPUNIT_ASSERT_EQUAL (std::string ("null_sink"), dst1->name ()); CPPUNIT_ASSERT_EQUAL (1, dst1->input_signature()->min_streams ()); CPPUNIT_ASSERT_EQUAL (1, dst1->input_signature()->max_streams ()); @@ -68,7 +69,7 @@ qa_gr_block::t1 () CPPUNIT_ASSERT_EQUAL (0, dst1->output_signature()->max_streams ()); - gr_block_sptr dst2 (gr_make_null_sink (sizeof (short))); + gr_block_sptr dst2 (gr::blocks::null_sink::make (sizeof (short))); CPPUNIT_ASSERT_EQUAL (std::string ("null_sink"), dst2->name ()); CPPUNIT_ASSERT_EQUAL (1, dst2->input_signature()->min_streams ()); CPPUNIT_ASSERT_EQUAL (1, dst2->input_signature()->max_streams ()); diff --git a/gnuradio-core/src/lib/runtime/qa_gr_block.h b/gr-blocks/lib/qa_gr_block.h index 14c7c40d1f..14c7c40d1f 100644 --- a/gnuradio-core/src/lib/runtime/qa_gr_block.h +++ b/gr-blocks/lib/qa_gr_block.h diff --git a/gnuradio-core/src/lib/runtime/qa_gr_flowgraph.cc b/gr-blocks/lib/qa_gr_flowgraph.cc index cce83cb0a0..1a3006039b 100644 --- a/gnuradio-core/src/lib/runtime/qa_gr_flowgraph.cc +++ b/gr-blocks/lib/qa_gr_flowgraph.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2007 Free Software Foundation, Inc. + * Copyright 2007,2013 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -26,9 +26,9 @@ #include <qa_gr_flowgraph.h> #include <gr_flowgraph.h> -#include <gr_nop.h> -#include <gr_null_source.h> -#include <gr_null_sink.h> +#include <blocks/nop.h> +#include <blocks/null_source.h> +#include <blocks/null_sink.h> void qa_gr_flowgraph::t0() { @@ -41,8 +41,8 @@ void qa_gr_flowgraph::t1_connect() { gr_flowgraph_sptr fg = gr_make_flowgraph(); - gr_block_sptr nop1 = gr_make_nop(sizeof(int)); - gr_block_sptr nop2 = gr_make_nop(sizeof(int)); + gr_block_sptr nop1 = gr::blocks::nop::make(sizeof(int)); + gr_block_sptr nop2 = gr::blocks::nop::make(sizeof(int)); fg->connect(nop1, 0, nop2, 0); } @@ -51,8 +51,8 @@ void qa_gr_flowgraph::t2_connect_invalid_src_port_neg() { gr_flowgraph_sptr fg = gr_make_flowgraph(); - gr_block_sptr nop1 = gr_make_nop(sizeof(int)); - gr_block_sptr nop2 = gr_make_nop(sizeof(int)); + gr_block_sptr nop1 = gr::blocks::nop::make(sizeof(int)); + gr_block_sptr nop2 = gr::blocks::nop::make(sizeof(int)); CPPUNIT_ASSERT_THROW(fg->connect(nop1, -1, nop2, 0), std::invalid_argument); } @@ -61,8 +61,8 @@ void qa_gr_flowgraph::t3_connect_src_port_exceeds() { gr_flowgraph_sptr fg = gr_make_flowgraph(); - gr_block_sptr src = gr_make_null_source(sizeof(int)); - gr_block_sptr dst = gr_make_null_sink(sizeof(int)); + gr_block_sptr src = gr::blocks::null_source::make(sizeof(int)); + gr_block_sptr dst = gr::blocks::null_sink::make(sizeof(int)); CPPUNIT_ASSERT_THROW(fg->connect(src, 1, dst, 0), std::invalid_argument); } @@ -71,8 +71,8 @@ void qa_gr_flowgraph::t4_connect_invalid_dst_port_neg() { gr_flowgraph_sptr fg = gr_make_flowgraph(); - gr_block_sptr nop1 = gr_make_nop(sizeof(int)); - gr_block_sptr nop2 = gr_make_nop(sizeof(int)); + gr_block_sptr nop1 = gr::blocks::nop::make(sizeof(int)); + gr_block_sptr nop2 = gr::blocks::nop::make(sizeof(int)); CPPUNIT_ASSERT_THROW(fg->connect(nop1, 0, nop2, -1), std::invalid_argument); } @@ -81,8 +81,8 @@ void qa_gr_flowgraph::t5_connect_dst_port_exceeds() { gr_flowgraph_sptr fg = gr_make_flowgraph(); - gr_block_sptr src = gr_make_null_source(sizeof(int)); - gr_block_sptr dst = gr_make_null_sink(sizeof(int)); + gr_block_sptr src = gr::blocks::null_source::make(sizeof(int)); + gr_block_sptr dst = gr::blocks::null_sink::make(sizeof(int)); CPPUNIT_ASSERT_THROW(fg->connect(src, 0, dst, 1), std::invalid_argument); } @@ -91,9 +91,9 @@ void qa_gr_flowgraph::t6_connect_dst_in_use() { gr_flowgraph_sptr fg = gr_make_flowgraph(); - gr_block_sptr src1 = gr_make_null_source(sizeof(int)); - gr_block_sptr src2 = gr_make_null_source(sizeof(int)); - gr_block_sptr dst = gr_make_null_sink(sizeof(int)); + gr_block_sptr src1 = gr::blocks::null_source::make(sizeof(int)); + gr_block_sptr src2 = gr::blocks::null_source::make(sizeof(int)); + gr_block_sptr dst = gr::blocks::null_sink::make(sizeof(int)); fg->connect(src1, 0, dst, 0); CPPUNIT_ASSERT_THROW(fg->connect(src2, 0, dst, 0), std::invalid_argument); @@ -103,9 +103,9 @@ void qa_gr_flowgraph::t7_connect_one_src_two_dst() { gr_flowgraph_sptr fg = gr_make_flowgraph(); - gr_block_sptr src = gr_make_null_source(sizeof(int)); - gr_block_sptr dst1 = gr_make_null_sink(sizeof(int)); - gr_block_sptr dst2 = gr_make_null_sink(sizeof(int)); + gr_block_sptr src = gr::blocks::null_source::make(sizeof(int)); + gr_block_sptr dst1 = gr::blocks::null_sink::make(sizeof(int)); + gr_block_sptr dst2 = gr::blocks::null_sink::make(sizeof(int)); fg->connect(src, 0, dst1, 0); fg->connect(src, 0, dst2, 0); @@ -115,8 +115,8 @@ void qa_gr_flowgraph::t8_connect_type_mismatch() { gr_flowgraph_sptr fg = gr_make_flowgraph(); - gr_block_sptr nop1 = gr_make_nop(sizeof(char)); - gr_block_sptr nop2 = gr_make_nop(sizeof(int)); + gr_block_sptr nop1 = gr::blocks::nop::make(sizeof(char)); + gr_block_sptr nop2 = gr::blocks::nop::make(sizeof(int)); CPPUNIT_ASSERT_THROW(fg->connect(nop1, 0, nop2, 0), std::invalid_argument); } @@ -125,8 +125,8 @@ void qa_gr_flowgraph::t9_disconnect() { gr_flowgraph_sptr fg = gr_make_flowgraph(); - gr_block_sptr nop1 = gr_make_nop(sizeof(int)); - gr_block_sptr nop2 = gr_make_nop(sizeof(int)); + gr_block_sptr nop1 = gr::blocks::nop::make(sizeof(int)); + gr_block_sptr nop2 = gr::blocks::nop::make(sizeof(int)); fg->connect(nop1, 0, nop2, 0); fg->disconnect(nop1, 0, nop2, 0); @@ -136,9 +136,9 @@ void qa_gr_flowgraph::t10_disconnect_unconnected_block() { gr_flowgraph_sptr fg = gr_make_flowgraph(); - gr_block_sptr nop1 = gr_make_nop(sizeof(int)); - gr_block_sptr nop2 = gr_make_nop(sizeof(int)); - gr_block_sptr nop3 = gr_make_nop(sizeof(int)); + gr_block_sptr nop1 = gr::blocks::nop::make(sizeof(int)); + gr_block_sptr nop2 = gr::blocks::nop::make(sizeof(int)); + gr_block_sptr nop3 = gr::blocks::nop::make(sizeof(int)); fg->connect(nop1, 0, nop2, 0); CPPUNIT_ASSERT_THROW(fg->disconnect(nop1, 0, nop3, 0), std::invalid_argument); @@ -148,8 +148,8 @@ void qa_gr_flowgraph::t11_disconnect_unconnected_port() { gr_flowgraph_sptr fg = gr_make_flowgraph(); - gr_block_sptr nop1 = gr_make_nop(sizeof(int)); - gr_block_sptr nop2 = gr_make_nop(sizeof(int)); + gr_block_sptr nop1 = gr::blocks::nop::make(sizeof(int)); + gr_block_sptr nop2 = gr::blocks::nop::make(sizeof(int)); fg->connect(nop1, 0, nop2, 0); CPPUNIT_ASSERT_THROW(fg->disconnect(nop1, 0, nop2, 1), std::invalid_argument); @@ -159,8 +159,8 @@ void qa_gr_flowgraph::t12_validate() { gr_flowgraph_sptr fg = gr_make_flowgraph(); - gr_block_sptr nop1 = gr_make_nop(sizeof(int)); - gr_block_sptr nop2 = gr_make_nop(sizeof(int)); + gr_block_sptr nop1 = gr::blocks::nop::make(sizeof(int)); + gr_block_sptr nop2 = gr::blocks::nop::make(sizeof(int)); fg->connect(nop1, 0, nop2, 0); fg->validate(); @@ -170,8 +170,8 @@ void qa_gr_flowgraph::t13_validate_missing_input_assignment() { gr_flowgraph_sptr fg = gr_make_flowgraph(); - gr_block_sptr nop1 = gr_make_nop(sizeof(int)); - gr_block_sptr nop2 = gr_make_nop(sizeof(int)); + gr_block_sptr nop1 = gr::blocks::nop::make(sizeof(int)); + gr_block_sptr nop2 = gr::blocks::nop::make(sizeof(int)); fg->connect(nop1, 0, nop2, 0); fg->connect(nop1, 0, nop2, 2); @@ -182,8 +182,8 @@ void qa_gr_flowgraph::t14_validate_missing_output_assignment() { gr_flowgraph_sptr fg = gr_make_flowgraph(); - gr_block_sptr nop1 = gr_make_nop(sizeof(int)); - gr_block_sptr nop2 = gr_make_nop(sizeof(int)); + gr_block_sptr nop1 = gr::blocks::nop::make(sizeof(int)); + gr_block_sptr nop2 = gr::blocks::nop::make(sizeof(int)); fg->connect(nop1, 0, nop2, 0); fg->connect(nop1, 2, nop2, 1); @@ -194,8 +194,8 @@ void qa_gr_flowgraph::t15_clear() { gr_flowgraph_sptr fg = gr_make_flowgraph(); - gr_block_sptr nop1 = gr_make_nop(sizeof(int)); - gr_block_sptr nop2 = gr_make_nop(sizeof(int)); + gr_block_sptr nop1 = gr::blocks::nop::make(sizeof(int)); + gr_block_sptr nop2 = gr::blocks::nop::make(sizeof(int)); fg->connect(nop1, 0, nop2, 0); @@ -212,17 +212,17 @@ void qa_gr_flowgraph::t16_partition() { gr_flowgraph_sptr fg = gr_make_flowgraph(); - gr_block_sptr nop11 = gr_make_nop(sizeof(int)); - gr_block_sptr nop12 = gr_make_nop(sizeof(int)); - gr_block_sptr nop13 = gr_make_nop(sizeof(int)); - gr_block_sptr nop14 = gr_make_nop(sizeof(int)); + gr_block_sptr nop11 = gr::blocks::nop::make(sizeof(int)); + gr_block_sptr nop12 = gr::blocks::nop::make(sizeof(int)); + gr_block_sptr nop13 = gr::blocks::nop::make(sizeof(int)); + gr_block_sptr nop14 = gr::blocks::nop::make(sizeof(int)); - gr_block_sptr nop21 = gr_make_nop(sizeof(int)); - gr_block_sptr nop22 = gr_make_nop(sizeof(int)); - gr_block_sptr nop23 = gr_make_nop(sizeof(int)); + gr_block_sptr nop21 = gr::blocks::nop::make(sizeof(int)); + gr_block_sptr nop22 = gr::blocks::nop::make(sizeof(int)); + gr_block_sptr nop23 = gr::blocks::nop::make(sizeof(int)); - gr_block_sptr nop31 = gr_make_nop(sizeof(int)); - gr_block_sptr nop32 = gr_make_nop(sizeof(int)); + gr_block_sptr nop31 = gr::blocks::nop::make(sizeof(int)); + gr_block_sptr nop32 = gr::blocks::nop::make(sizeof(int)); // Build disjoint graph #1 fg->connect(nop11, 0, nop12, 0); diff --git a/gnuradio-core/src/lib/runtime/qa_gr_flowgraph.h b/gr-blocks/lib/qa_gr_flowgraph.h index 2c2686f71b..2c2686f71b 100644 --- a/gnuradio-core/src/lib/runtime/qa_gr_flowgraph.h +++ b/gr-blocks/lib/qa_gr_flowgraph.h diff --git a/gnuradio-core/src/lib/runtime/qa_gr_hier_block2.cc b/gr-blocks/lib/qa_gr_hier_block2.cc index 9844d33814..a3d599039c 100644 --- a/gnuradio-core/src/lib/runtime/qa_gr_hier_block2.cc +++ b/gr-blocks/lib/qa_gr_hier_block2.cc @@ -27,8 +27,6 @@ #include <qa_gr_hier_block2.h> #include <gr_hier_block2.h> #include <gr_io_signature.h> -#include <gr_null_source.h> -#include <gr_null_sink.h> void qa_gr_hier_block2::test_make() { diff --git a/gnuradio-core/src/lib/runtime/qa_gr_hier_block2.h b/gr-blocks/lib/qa_gr_hier_block2.h index 653cd27251..653cd27251 100644 --- a/gnuradio-core/src/lib/runtime/qa_gr_hier_block2.h +++ b/gr-blocks/lib/qa_gr_hier_block2.h diff --git a/gnuradio-core/src/lib/runtime/qa_gr_hier_block2_derived.cc b/gr-blocks/lib/qa_gr_hier_block2_derived.cc index 060c4e2447..eb747d32cc 100644 --- a/gnuradio-core/src/lib/runtime/qa_gr_hier_block2_derived.cc +++ b/gr-blocks/lib/qa_gr_hier_block2_derived.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2006,2008 Free Software Foundation, Inc. + * Copyright 2006,2008,2013 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -27,10 +27,10 @@ #include <qa_gr_hier_block2_derived.h> #include <gr_top_block.h> #include <gr_io_signature.h> -#include <gr_null_source.h> -#include <gr_null_sink.h> -#include <gr_head.h> -#include <gr_kludge_copy.h> +#include <blocks/null_source.h> +#include <blocks/null_sink.h> +#include <blocks/head.h> +#include <blocks/copy.h> // Declare a test C++ hierarchical block @@ -60,7 +60,7 @@ gr_derived_block::gr_derived_block() gr_make_io_signature(1, 1, sizeof(int)), // Input signature gr_make_io_signature(1, 1, sizeof(int))) // Output signature { - gr_block_sptr copy(gr_make_kludge_copy(sizeof(int))); + gr_block_sptr copy(gr::blocks::copy::make(sizeof(int))); connect(self(), 0, copy, 0); connect(copy, 0, self(), 0); @@ -74,10 +74,10 @@ void qa_gr_hier_block2_derived::test_1() { gr_top_block_sptr tb(gr_make_top_block("test")); - gr_block_sptr src(gr_make_null_source(sizeof(int))); - gr_block_sptr head(gr_make_head(sizeof(int), 1000)); + gr_block_sptr src(gr::blocks::null_source::make(sizeof(int))); + gr_block_sptr head(gr::blocks::head::make(sizeof(int), 1000)); gr_derived_block_sptr blk(gr_make_derived_block()); - gr_block_sptr dst(gr_make_null_sink(sizeof(int))); + gr_block_sptr dst(gr::blocks::null_sink::make(sizeof(int))); tb->connect(src, 0, head, 0); tb->connect(head, 0, blk, 0); diff --git a/gnuradio-core/src/lib/runtime/qa_gr_hier_block2_derived.h b/gr-blocks/lib/qa_gr_hier_block2_derived.h index 8e0a1880ce..8e0a1880ce 100644 --- a/gnuradio-core/src/lib/runtime/qa_gr_hier_block2_derived.h +++ b/gr-blocks/lib/qa_gr_hier_block2_derived.h diff --git a/gnuradio-core/src/lib/runtime/qa_gr_top_block.cc b/gr-blocks/lib/qa_gr_top_block.cc index 1d3dafadf8..9833ed7f8b 100644 --- a/gnuradio-core/src/lib/runtime/qa_gr_top_block.cc +++ b/gr-blocks/lib/qa_gr_top_block.cc @@ -26,10 +26,10 @@ #include <qa_gr_top_block.h> #include <gr_top_block.h> -#include <gr_head.h> -#include <gr_nop.h> -#include <gr_null_source.h> -#include <gr_null_sink.h> +#include <blocks/head.h> +#include <blocks/nop.h> +#include <blocks/null_source.h> +#include <blocks/null_sink.h> #include <iostream> #define VERBOSE 0 @@ -49,9 +49,9 @@ void qa_gr_top_block::t1_run() gr_top_block_sptr tb = gr_make_top_block("top"); - gr_block_sptr src = gr_make_null_source(sizeof(int)); - gr_block_sptr head = gr_make_head(sizeof(int), 100000); - gr_block_sptr dst = gr_make_null_sink(sizeof(int)); + gr_block_sptr src = gr::blocks::null_source::make(sizeof(int)); + gr_block_sptr head = gr::blocks::head::make(sizeof(int), 100000); + gr_block_sptr dst = gr::blocks::null_sink::make(sizeof(int)); tb->connect(src, 0, head, 0); tb->connect(head, 0, dst, 0); @@ -64,9 +64,9 @@ void qa_gr_top_block::t2_start_stop_wait() gr_top_block_sptr tb = gr_make_top_block("top"); - gr_block_sptr src = gr_make_null_source(sizeof(int)); - gr_block_sptr head = gr_make_head(sizeof(int), 100000); - gr_block_sptr dst = gr_make_null_sink(sizeof(int)); + gr_block_sptr src = gr::blocks::null_source::make(sizeof(int)); + gr_block_sptr head = gr::blocks::head::make(sizeof(int), 100000); + gr_block_sptr dst = gr::blocks::null_sink::make(sizeof(int)); tb->connect(src, 0, head, 0); tb->connect(head, 0, dst, 0); @@ -82,8 +82,8 @@ void qa_gr_top_block::t3_lock_unlock() gr_top_block_sptr tb = gr_make_top_block("top"); - gr_block_sptr src = gr_make_null_source(sizeof(int)); - gr_block_sptr dst = gr_make_null_sink(sizeof(int)); + gr_block_sptr src = gr::blocks::null_source::make(sizeof(int)); + gr_block_sptr dst = gr::blocks::null_sink::make(sizeof(int)); tb->connect(src, 0, dst, 0); @@ -102,9 +102,9 @@ void qa_gr_top_block::t4_reconfigure() gr_top_block_sptr tb = gr_make_top_block("top"); - gr_block_sptr src = gr_make_null_source(sizeof(int)); - gr_block_sptr head = gr_make_head(sizeof(int), 100000); - gr_block_sptr dst = gr_make_null_sink(sizeof(int)); + gr_block_sptr src = gr::blocks::null_source::make(sizeof(int)); + gr_block_sptr head = gr::blocks::head::make(sizeof(int), 100000); + gr_block_sptr dst = gr::blocks::null_sink::make(sizeof(int)); // Start infinite flowgraph tb->connect(src, 0, dst, 0); @@ -128,9 +128,9 @@ void qa_gr_top_block::t5_max_noutputs() gr_top_block_sptr tb = gr_make_top_block("top"); - gr_block_sptr src = gr_make_null_source(sizeof(int)); - gr_block_sptr head = gr_make_head(sizeof(int), 100000); - gr_block_sptr dst = gr_make_null_sink(sizeof(int)); + gr_block_sptr src = gr::blocks::null_source::make(sizeof(int)); + gr_block_sptr head = gr::blocks::head::make(sizeof(int), 100000); + gr_block_sptr dst = gr::blocks::null_sink::make(sizeof(int)); // Start infinite flowgraph tb->connect(src, 0, head, 0); @@ -145,9 +145,9 @@ void qa_gr_top_block::t6_reconfig_max_noutputs() gr_top_block_sptr tb = gr_make_top_block("top"); - gr_block_sptr src = gr_make_null_source(sizeof(int)); - gr_block_sptr head = gr_make_head(sizeof(int), 100000); - gr_block_sptr dst = gr_make_null_sink(sizeof(int)); + gr_block_sptr src = gr::blocks::null_source::make(sizeof(int)); + gr_block_sptr head = gr::blocks::head::make(sizeof(int), 100000); + gr_block_sptr dst = gr::blocks::null_sink::make(sizeof(int)); // Start infinite flowgraph tb->connect(src, 0, dst, 0); @@ -172,9 +172,9 @@ void qa_gr_top_block::t7_max_noutputs_per_block() gr_top_block_sptr tb = gr_make_top_block("top"); - gr_block_sptr src = gr_make_null_source(sizeof(int)); - gr_block_sptr head = gr_make_head(sizeof(int), 100000); - gr_block_sptr dst = gr_make_null_sink(sizeof(int)); + gr_block_sptr src = gr::blocks::null_source::make(sizeof(int)); + gr_block_sptr head = gr::blocks::head::make(sizeof(int), 100000); + gr_block_sptr dst = gr::blocks::null_sink::make(sizeof(int)); head->set_max_noutput_items(100); @@ -191,9 +191,9 @@ void qa_gr_top_block::t8_reconfig_max_noutputs_per_block() gr_top_block_sptr tb = gr_make_top_block("top"); - gr_block_sptr src = gr_make_null_source(sizeof(int)); - gr_block_sptr head = gr_make_head(sizeof(int), 100000); - gr_block_sptr dst = gr_make_null_sink(sizeof(int)); + gr_block_sptr src = gr::blocks::null_source::make(sizeof(int)); + gr_block_sptr head = gr::blocks::head::make(sizeof(int), 100000); + gr_block_sptr dst = gr::blocks::null_sink::make(sizeof(int)); head->set_max_noutput_items(99); @@ -220,9 +220,9 @@ void qa_gr_top_block::t9_max_output_buffer() gr_top_block_sptr tb = gr_make_top_block("top"); - gr_block_sptr src = gr_make_null_source(sizeof(int)); - gr_block_sptr head = gr_make_head(sizeof(int), 100000); - gr_block_sptr dst = gr_make_null_sink(sizeof(int)); + gr_block_sptr src = gr::blocks::null_source::make(sizeof(int)); + gr_block_sptr head = gr::blocks::head::make(sizeof(int), 100000); + gr_block_sptr dst = gr::blocks::null_sink::make(sizeof(int)); head->set_max_output_buffer(1024); @@ -239,9 +239,9 @@ void qa_gr_top_block::t10_reconfig_max_output_buffer() gr_top_block_sptr tb = gr_make_top_block("top"); - gr_block_sptr src = gr_make_null_source(sizeof(int)); - gr_block_sptr head = gr_make_head(sizeof(int), 100000); - gr_block_sptr dst = gr_make_null_sink(sizeof(int)); + gr_block_sptr src = gr::blocks::null_source::make(sizeof(int)); + gr_block_sptr head = gr::blocks::head::make(sizeof(int), 100000); + gr_block_sptr dst = gr::blocks::null_sink::make(sizeof(int)); head->set_max_output_buffer(1000); @@ -251,7 +251,7 @@ void qa_gr_top_block::t10_reconfig_max_output_buffer() // Reconfigure with gr_head in the middle tb->lock(); - gr_block_sptr nop = gr_make_nop(sizeof(int)); + gr_block_sptr nop = gr::blocks::nop::make(sizeof(int)); nop->set_max_output_buffer(4000); tb->disconnect(src, 0, dst, 0); tb->connect(src, 0, head, 0); @@ -266,8 +266,8 @@ void qa_gr_top_block::t10_reconfig_max_output_buffer() void qa_gr_top_block::t11_set_block_affinity() { gr_top_block_sptr tb = gr_make_top_block("top"); - gr_block_sptr src (gr_make_null_source(sizeof(float))); - gr_block_sptr snk (gr_make_null_sink(sizeof(float))); + gr_block_sptr src (gr::blocks::null_source::make(sizeof(float))); + gr_block_sptr snk (gr::blocks::null_sink::make(sizeof(float))); std::vector<unsigned int> set(1, 0), ret; src->set_processor_affinity(set); diff --git a/gnuradio-core/src/lib/runtime/qa_gr_top_block.h b/gr-blocks/lib/qa_gr_top_block.h index 634eeab1f8..634eeab1f8 100644 --- a/gnuradio-core/src/lib/runtime/qa_gr_top_block.h +++ b/gr-blocks/lib/qa_gr_top_block.h diff --git a/gr-blocks/lib/qa_rotator.cc b/gr-blocks/lib/qa_rotator.cc new file mode 100644 index 0000000000..86bbdd5282 --- /dev/null +++ b/gr-blocks/lib/qa_rotator.cc @@ -0,0 +1,75 @@ +/* -*- c++ -*- */ +/* + * Copyright 2002,2013 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 <gruel/attributes.h> +#include <cppunit/TestAssert.h> +#include <qa_rotator.h> +#include <blocks/rotator.h> +#include <stdio.h> +#include <cmath> +#include <gr_expj.h> + +// error vector magnitude +__GR_ATTR_UNUSED static float +error_vector_mag(gr_complex a, gr_complex b) +{ + return abs(a-b); +} + +void +qa_rotator::t1() +{ + static const unsigned int N = 100000; + + gr::blocks::rotator r; + + double phase_incr = 2*M_PI / 1003; + double phase = 0; + + // Old code: We increment then return the rotated value, thus we + // need to start one tick back r.set_phase(gr_complex(1,0) * + // conj(gr_expj(phase_incr))); + + r.set_phase(gr_complex(1,0)); + r.set_phase_incr(gr_expj(phase_incr)); + + for(unsigned i = 0; i < N; i++) { + gr_complex expected = gr_expj(phase); + gr_complex actual = r.rotate(gr_complex(1, 0)); + +#if 0 + float evm = error_vector_mag(expected, actual); + printf("[%6d] expected: (%8.6f, %8.6f) actual: (%8.6f, %8.6f) evm: %8.6f\n", + i, expected.real(), expected.imag(), actual.real(), actual.imag(), evm); +#endif + + CPPUNIT_ASSERT_COMPLEXES_EQUAL(expected, actual, 0.0001); + + phase += phase_incr; + if(phase >= 2*M_PI) + phase -= 2*M_PI; + } +} diff --git a/gnuradio-core/src/lib/general/gr_iqcomp_cc.i b/gr-blocks/lib/qa_rotator.h index 5cca59dd5d..575ea506c7 100644 --- a/gnuradio-core/src/lib/general/gr_iqcomp_cc.i +++ b/gr-blocks/lib/qa_rotator.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2008 Free Software Foundation, Inc. + * Copyright 2008,2013 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,17 +20,20 @@ * Boston, MA 02110-1301, USA. */ +#ifndef _QA_GR_ROTATOR_H_ +#define _QA_GR_ROTATOR_H_ -GR_SWIG_BLOCK_MAGIC(gr,iqcomp_cc) +#include <cppunit/extensions/HelperMacros.h> +#include <cppunit/TestCase.h> -gr_iqcomp_cc_sptr gr_make_iqcomp_cc (float mu); - -class gr_iqcomp_cc : public gr_sync_block +class qa_rotator : public CppUnit::TestCase { - private: - gr_iqcomp_cc (float mu); + CPPUNIT_TEST_SUITE(qa_rotator); + CPPUNIT_TEST(t1); + CPPUNIT_TEST_SUITE_END(); - public: - float mu () const { return d_mu; } - void set_mu (float mu) { d_mu = mu; } + private: + void t1(); }; + +#endif /* _QA_GR_ROTATOR_H_ */ diff --git a/gnuradio-core/src/lib/runtime/qa_set_msg_handler.cc b/gr-blocks/lib/qa_set_msg_handler.cc index ac06a3f8bc..cfb990f0c4 100644 --- a/gnuradio-core/src/lib/runtime/qa_set_msg_handler.cc +++ b/gr-blocks/lib/qa_set_msg_handler.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2007,2011 Free Software Foundation, Inc. + * Copyright 2007,2011,2013 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -26,10 +26,10 @@ #include <qa_set_msg_handler.h> #include <gr_top_block.h> -#include <gr_head.h> -#include <gr_null_source.h> -#include <gr_null_sink.h> -#include <gr_nop.h> +#include <blocks/head.h> +#include <blocks/null_source.h> +#include <blocks/null_sink.h> +#include <blocks/nop.h> #include <gruel/msg_passing.h> #include <iostream> #include <boost/thread/thread.hpp> @@ -38,10 +38,9 @@ #define VERBOSE 0 /* - * The gr_nop block has been instrumented so that it counts - * the number of messages sent to it. We use this feature - * to confirm that gr_nop's call to set_msg_handler is working - * correctly. + * The gr::block::nop block has been instrumented so that it counts + * the number of messages sent to it. We use this feature to confirm + * that gr::blocks::nop's call to set_msg_handler is working correctly. */ void qa_set_msg_handler::t0() @@ -52,9 +51,9 @@ void qa_set_msg_handler::t0() gr_top_block_sptr tb = gr_make_top_block("top"); - gr_block_sptr src = gr_make_null_source(sizeof(int)); - gr_nop_sptr nop = gr_make_nop(sizeof(int)); - gr_block_sptr dst = gr_make_null_sink(sizeof(int)); + gr_block_sptr src = gr::blocks::null_source::make(sizeof(int)); + gr::blocks::nop::sptr nop = gr::blocks::nop::make(sizeof(int)); + gr_block_sptr dst = gr::blocks::null_sink::make(sizeof(int)); tb->connect(src, 0, nop, 0); tb->connect(nop, 0, dst, 0); diff --git a/gnuradio-core/src/lib/runtime/qa_set_msg_handler.h b/gr-blocks/lib/qa_set_msg_handler.h index 60277a12cc..60277a12cc 100644 --- a/gnuradio-core/src/lib/runtime/qa_set_msg_handler.h +++ b/gr-blocks/lib/qa_set_msg_handler.h diff --git a/gr-blocks/lib/skiphead_impl.cc b/gr-blocks/lib/skiphead_impl.cc new file mode 100644 index 0000000000..feb39eb8f4 --- /dev/null +++ b/gr-blocks/lib/skiphead_impl.cc @@ -0,0 +1,93 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,2007,2010,2013 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 "skiphead_impl.h" +#include <gr_io_signature.h> +#include <string.h> + +namespace gr { + namespace blocks { + + skiphead::sptr + skiphead::make(size_t itemsize, uint64_t nitems_to_skip) + { + return gnuradio::get_initial_sptr + (new skiphead_impl(itemsize, nitems_to_skip)); + } + + skiphead_impl::skiphead_impl(size_t itemsize, uint64_t nitems_to_skip) + : gr_block("skiphead", + gr_make_io_signature(1, 1, itemsize), + gr_make_io_signature(1, 1, itemsize)), + d_nitems_to_skip(nitems_to_skip), d_nitems(0) + { + } + + skiphead_impl::~skiphead_impl() + { + } + + int + skiphead_impl::general_work(int noutput_items, + gr_vector_int &ninput_items_, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + const char *in = (const char*)input_items[0]; + char *out = (char*)output_items[0]; + + int ninput_items = std::min(ninput_items_[0], noutput_items); + int ii = 0; // input index + + while (ii < ninput_items) { + uint64_t ni_total = ii + d_nitems; // total items processed so far + if(ni_total < d_nitems_to_skip) { // need to skip some more + + int n_to_skip = (int)std::min(d_nitems_to_skip - ni_total, + (uint64_t)(ninput_items - ii)); + ii += n_to_skip; + } + + else { // nothing left to skip. copy away + int n_to_copy = ninput_items - ii; + if(n_to_copy > 0) { + size_t itemsize = output_signature()->sizeof_stream_item(0); + memcpy(out, in + (ii*itemsize), n_to_copy*itemsize); + } + + d_nitems += ninput_items; + consume_each(ninput_items); + return n_to_copy; + } + } + + d_nitems += ninput_items; + consume_each(ninput_items); + return 0; + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/skiphead_impl.h b/gr-blocks/lib/skiphead_impl.h new file mode 100644 index 0000000000..d8e0870cb1 --- /dev/null +++ b/gr-blocks/lib/skiphead_impl.h @@ -0,0 +1,50 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,2013 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_SKIPHEAD_IMPL_H +#define INCLUDED_GR_SKIPHEAD_IMPL_H + +#include <blocks/skiphead.h> + +namespace gr { + namespace blocks { + + class skiphead_impl : public skiphead + { + private: + uint64_t d_nitems_to_skip; + uint64_t d_nitems; // total items seen + + public: + skiphead_impl(size_t itemsize, uint64_t nitems_to_skip); + ~skiphead_impl(); + + int general_work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_SKIPHEAD_IMPL_H */ diff --git a/gr-blocks/lib/vco_f_impl.h b/gr-blocks/lib/vco_f_impl.h index cecf72441f..37435b7736 100644 --- a/gr-blocks/lib/vco_f_impl.h +++ b/gr-blocks/lib/vco_f_impl.h @@ -24,7 +24,7 @@ #define INCLUDED_GR_VCO_F_IMPL_H #include <blocks/vco_f.h> -#include <blocks/fxpt_vco.h> +#include <gr_fxpt_vco.h> namespace gr { namespace blocks { @@ -36,7 +36,7 @@ namespace gr { double d_sensitivity; double d_amplitude; double d_k; - fxpt_vco d_vco; + gr_fxpt_vco d_vco; public: vco_f_impl(double sampling_rate, double sensitivity, double amplitude); diff --git a/gr-blocks/lib/vector_insert_X_impl.cc.t b/gr-blocks/lib/vector_insert_X_impl.cc.t new file mode 100644 index 0000000000..adf31fe05a --- /dev/null +++ b/gr-blocks/lib/vector_insert_X_impl.cc.t @@ -0,0 +1,109 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +// @WARNING@ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <@NAME_IMPL@.h> +#include <algorithm> +#include <gr_io_signature.h> +#include <stdexcept> +#include <stdio.h> + +namespace gr { + namespace blocks { + + @NAME@::sptr + @NAME@::make(const std::vector<@TYPE@> &data, int periodicity, int offset) + { + return gnuradio::get_initial_sptr + (new @NAME_IMPL@(data, periodicity, offset)); + } + + @NAME_IMPL@::@NAME_IMPL@(const std::vector<@TYPE@> &data, + int periodicity, int offset) + : gr_block("@BASE_NAME@", + gr_make_io_signature(1, 1, sizeof(@TYPE@)), + gr_make_io_signature(1, 1, sizeof(@TYPE@))), + d_data(data), + d_offset(offset), + d_periodicity(periodicity) + { + //printf("INITIAL: periodicity = %d, offset = %d\n", periodicity, offset); + // some sanity checks + assert(offset < periodicity); + assert(offset >= 0); + assert((size_t)periodicity > data.size()); + } + + @NAME_IMPL@::~@NAME_IMPL@() + {} + + int + @NAME_IMPL@::general_work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + @TYPE@ *out = (@TYPE@ *)output_items[0]; + const @TYPE@ *in = (const @TYPE@ *)input_items[0]; + + int ii(0), oo(0); + + while((oo < noutput_items) && (ii < ninput_items[0])) { + //printf("oo = %d, ii = %d, d_offset = %d, noutput_items = %d, ninput_items[0] = %d", oo, ii, d_offset, noutput_items, ninput_items[0]); + //printf(", d_periodicity = %d\n", d_periodicity); + + if(d_offset >= ((int)d_data.size())) { // if we are in the copy region + int max_copy = std::min(std::min(noutput_items - oo, ninput_items[0] - ii), + d_periodicity - d_offset); + //printf("copy %d from input\n", max_copy); + memcpy( &out[oo], &in[ii], sizeof(@TYPE@)*max_copy ); + //printf(" * memcpy returned.\n"); + ii += max_copy; + oo += max_copy; + d_offset = (d_offset + max_copy)%d_periodicity; + } + else { // if we are in the insertion region + int max_copy = std::min(noutput_items - oo, ((int)d_data.size()) - d_offset); + //printf("copy %d from d_data[%d] to out[%d]\n", max_copy, d_offset, oo); + memcpy(&out[oo], &d_data[d_offset], sizeof(@TYPE@)*max_copy); + //printf(" * memcpy returned.\n"); + oo += max_copy; + d_offset = (d_offset + max_copy)%d_periodicity; + //printf(" ## (inelse) oo = %d, d_offset = %d\n", oo, d_offset); + } + + //printf(" # exit else, on to next loop.\n"); + } + //printf(" # got out of loop\n"); + + //printf("consume = %d, produce = %d\n", ii, oo); + consume_each(ii); + return oo; + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/vector_insert_X_impl.h.t b/gr-blocks/lib/vector_insert_X_impl.h.t new file mode 100644 index 0000000000..f447ef1e80 --- /dev/null +++ b/gr-blocks/lib/vector_insert_X_impl.h.t @@ -0,0 +1,58 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012,2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +// @WARNING@ + +#ifndef @GUARD_NAME_IMPL@ +#define @GUARD_NAME_IMPL@ + +#include <blocks/@NAME@.h> + +namespace gr { + namespace blocks { + + class @NAME_IMPL@ : public @NAME@ + { + private: + std::vector<@TYPE@> d_data; + int d_offset; + int d_periodicity; + + public: + @NAME_IMPL@(const std::vector<@TYPE@> &data, + int periodicity, int offset); + ~@NAME_IMPL@(); + + void rewind() { d_offset=0; } + void set_data(const std::vector<@TYPE@> &data) { + d_data = data; rewind(); } + + int general_work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* @GUARD_NAME_IMPL@ */ diff --git a/gr-blocks/lib/vector_map_impl.cc b/gr-blocks/lib/vector_map_impl.cc new file mode 100644 index 0000000000..cefaaeea35 --- /dev/null +++ b/gr-blocks/lib/vector_map_impl.cc @@ -0,0 +1,127 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012,2013 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 "vector_map_impl.h" +#include <gr_io_signature.h> +#include <string.h> + +namespace gr { + namespace blocks { + + std::vector<int> + get_in_sizeofs(size_t item_size, std::vector<size_t> in_vlens) + { + std::vector<int> in_sizeofs; + for(unsigned int i = 0; i < in_vlens.size(); i++) { + in_sizeofs.push_back(in_vlens[i]*item_size); + } + return in_sizeofs; + } + + std::vector<int> + get_out_sizeofs(size_t item_size, + std::vector< std::vector< std::vector<size_t> > > mapping) + { + std::vector<int> out_sizeofs; + for(unsigned int i = 0; i < mapping.size(); i++) { + out_sizeofs.push_back(mapping[i].size()*item_size); + } + return out_sizeofs; + } + + vector_map::sptr + vector_map::make(size_t item_size, std::vector<size_t> in_vlens, + std::vector< std::vector< std::vector<size_t> > > mapping) + { + return gnuradio::get_initial_sptr + (new vector_map_impl(item_size, in_vlens, mapping)); + } + + vector_map_impl::vector_map_impl(size_t item_size, std::vector<size_t> in_vlens, + std::vector< std::vector< std::vector<size_t> > > mapping) + : gr_sync_block("vector_map", + gr_make_io_signaturev(in_vlens.size(), in_vlens.size(), + get_in_sizeofs(item_size, in_vlens)), + gr_make_io_signaturev(mapping.size(), mapping.size(), + get_out_sizeofs(item_size, mapping))), + d_item_size(item_size), d_in_vlens(in_vlens) + { + set_mapping(mapping); + } + + vector_map_impl::~vector_map_impl() + { + } + + void + vector_map_impl::set_mapping(std::vector< std::vector< std::vector<size_t> > > mapping) + { + // Make sure the contents of the mapping vectors are possible. + for(unsigned int i=0; i<mapping.size(); i++) { + for(unsigned int j=0; j<mapping[i].size(); j++) { + if(mapping[i][j].size() != 2) { + throw std::runtime_error("Mapping must be of the form (out_mapping_stream1, out_mapping_stream2, ...), where out_mapping_stream1 is of the form (mapping_element1, mapping_element2, ...), where mapping_element1 is of the form (input_stream, input_element). This error is raised because a mapping_element vector does not contain exactly 2 items."); + } + unsigned int s = mapping[i][j][0]; + unsigned int index = mapping[i][j][1]; + if(s >= d_in_vlens.size()) { + throw std::runtime_error("Stream numbers in mapping must be less than the number of input streams."); + } + if((index < 0) || (index >= d_in_vlens[s])) { + throw std::runtime_error ("Indices in mapping must be greater than 0 and less than the input vector lengths."); + } + } + } + gruel::scoped_lock guard(d_mutex); + d_mapping = mapping; + } + + int + vector_map_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + const char **inv = (const char**)&input_items[0]; + char **outv = (char**)&output_items[0]; + + for(unsigned int n = 0; n < (unsigned int)(noutput_items); n++) { + for(unsigned int i = 0; i < d_mapping.size(); i++) { + unsigned int out_vlen = d_mapping[i].size(); + for(unsigned int j = 0; j < out_vlen; j++) { + unsigned int s = d_mapping[i][j][0]; + unsigned int k = d_mapping[i][j][1]; + memcpy(outv[i] + out_vlen*d_item_size*n + + d_item_size*j, inv[s] + d_in_vlens[s]*d_item_size*n + + k*d_item_size, d_item_size); + } + } + } + + return noutput_items; + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/vector_map_impl.h b/gr-blocks/lib/vector_map_impl.h new file mode 100644 index 0000000000..e27b3b9cec --- /dev/null +++ b/gr-blocks/lib/vector_map_impl.h @@ -0,0 +1,55 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012,2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_GR_VECTOR_MAP_IMPL_H +#define INCLUDED_GR_VECTOR_MAP_IMPL_H + +#include <blocks/vector_map.h> +#include <gruel/thread.h> + +namespace gr { + namespace blocks { + + class vector_map_impl : public vector_map + { + private: + size_t d_item_size; + std::vector<size_t> d_in_vlens; + std::vector< std::vector< std::vector<size_t> > > d_mapping; + gruel::mutex d_mutex; // mutex to protect set/work access + + public: + vector_map_impl(size_t item_size, std::vector<size_t> in_vlens, + std::vector< std::vector< std::vector<size_t> > > mapping); + ~vector_map_impl(); + + void set_mapping(std::vector< std::vector< std::vector<size_t> > > mapping); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_VECTOR_MAP_IMPL_H */ diff --git a/gr-blocks/lib/vector_sink_X_impl.cc.t b/gr-blocks/lib/vector_sink_X_impl.cc.t new file mode 100644 index 0000000000..3be2861025 --- /dev/null +++ b/gr-blocks/lib/vector_sink_X_impl.cc.t @@ -0,0 +1,83 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2008,2010,2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +// @WARNING@ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <@NAME_IMPL@.h> +#include <gr_io_signature.h> +#include <algorithm> +#include <iostream> + +namespace gr { + namespace blocks { + + @NAME@::sptr + @BASE_NAME@::make(int vlen) + { + return gnuradio::get_initial_sptr + (new @NAME_IMPL@(vlen)); + } + + @NAME_IMPL@::@NAME_IMPL@(int vlen) + : gr_sync_block("@NAME@", + gr_make_io_signature(1, 1, sizeof(@TYPE@) * vlen), + gr_make_io_signature(0, 0, 0)), + d_vlen(vlen) + { + } + + @NAME_IMPL@::~@NAME_IMPL@() + {} + + std::vector<@TYPE@> + @NAME_IMPL@::data() const + { + return d_data; + } + + std::vector<gr_tag_t> + @NAME_IMPL@::tags() const + { + return d_tags; + } + + int + @NAME_IMPL@::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + @TYPE@ *iptr = (@TYPE@*)input_items[0]; + + for(int i = 0; i < noutput_items * d_vlen; i++) + d_data.push_back (iptr[i]); + std::vector<gr_tag_t> tags; + get_tags_in_range(tags, 0, nitems_read(0), nitems_read(0) + noutput_items); + d_tags.insert(d_tags.end(), tags.begin(), tags.end()); + return noutput_items; + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gnuradio-core/src/lib/gengen/gr_vector_sink_X.i.t b/gr-blocks/lib/vector_sink_X_impl.h.t index ee0ebf378b..60d21e0c8c 100644 --- a/gnuradio-core/src/lib/gengen/gr_vector_sink_X.i.t +++ b/gr-blocks/lib/vector_sink_X_impl.h.t @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2008,2009 Free Software Foundation, Inc. + * Copyright 2004,2008,2009,2013 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -22,19 +22,35 @@ // @WARNING@ +#ifndef @GUARD_NAME_IMPL@ +#define @GUARD_NAME_IMPL@ -GR_SWIG_BLOCK_MAGIC(gr,@BASE_NAME@); +#include <blocks/@NAME@.h> -@SPTR_NAME@ gr_make_@BASE_NAME@ (int vlen = 1); +namespace gr { + namespace blocks { -class @NAME@ : public gr_sync_block { - private: - @NAME@ (int vlen); + class @NAME_IMPL@ : public @NAME@ + { + private: + std::vector<@TYPE@> d_data; + std::vector<gr_tag_t> d_tags; + int d_vlen; - public: - void clear(); // deprecated - void reset(); - std::vector<@TYPE@> data () const; - std::vector<gr_tag_t> tags () const; -}; + public: + @NAME_IMPL@(int vlen); + ~@NAME_IMPL@(); + void reset() { d_data.clear(); } + std::vector<@TYPE@> data() const; + std::vector<gr_tag_t> tags() const; + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* @GUARD_NAME_IMPL@ */ diff --git a/gr-blocks/lib/vector_source_X_impl.cc.t b/gr-blocks/lib/vector_source_X_impl.cc.t new file mode 100644 index 0000000000..9c1c63a213 --- /dev/null +++ b/gr-blocks/lib/vector_source_X_impl.cc.t @@ -0,0 +1,144 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2008,2010,2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +// @WARNING@ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <@NAME_IMPL@.h> +#include <algorithm> +#include <gr_io_signature.h> +#include <stdexcept> + +namespace gr { + namespace blocks { + + @NAME@::sptr + @NAME@::make(const std::vector<@TYPE@> &data, + bool repeat, int vlen, + const std::vector<gr_tag_t> &tags) + { + return gnuradio::get_initial_sptr + (new @NAME_IMPL@(data, repeat, vlen, tags)); + } + + @NAME_IMPL@::@NAME_IMPL@(const std::vector<@TYPE@> &data, + bool repeat, int vlen, + const std::vector<gr_tag_t> &tags) + : gr_sync_block("@BASE_NAME@", + gr_make_io_signature(0, 0, 0), + gr_make_io_signature(1, 1, sizeof(@TYPE@) * vlen)), + d_data(data), + d_repeat(repeat), + d_offset(0), + d_vlen(vlen), + d_tags(tags), + d_tagpos(0) + { + if(tags.size() == 0) { + d_settags = 0; + } + else { + d_settags = 1; + set_output_multiple(data.size() / vlen); + } + if((data.size() % vlen) != 0) + throw std::invalid_argument("data length must be a multiple of vlen"); + } + + @NAME_IMPL@::~@NAME_IMPL@() + {} + + void + @NAME_IMPL@::set_data (const std::vector<@TYPE@> &data, + const std::vector<gr_tag_t> &tags) + { + d_data = data; + d_tags = tags; + rewind(); + if(tags.size() == 0) { + d_settags = false; + } + else { + d_settags = true; + } + } + + int + @NAME_IMPL@::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + @TYPE@ *optr = (@TYPE@ *) output_items[0]; + + if(d_repeat) { + unsigned int size = d_data.size (); + unsigned int offset = d_offset; + if(size == 0) + return -1; + + if(d_settags) { + int n_outputitems_per_vector = d_data.size() / d_vlen; + for(int i = 0; i < noutput_items; i += n_outputitems_per_vector) { + // FIXME do proper vector copy + memcpy((void *) optr, (const void*)&d_data[0], size*sizeof (@TYPE@)); + optr += size; + for(unsigned t = 0; t < d_tags.size(); t++) { + add_item_tag(0, nitems_written(0)+i+d_tags[t].offset, + d_tags[t].key, d_tags[t].value); + } + } + } + else { + for(int i = 0; i < noutput_items*d_vlen; i++) { + optr[i] = d_data[offset++]; + if(offset >= size) { + offset = 0; + } + } + } + + d_offset = offset; + return noutput_items; + } + else { + if(d_offset >= d_data.size ()) + return -1; // Done! + + unsigned n = std::min((unsigned)d_data.size() - d_offset, + (unsigned)noutput_items*d_vlen); + for(unsigned i = 0; i < n; i++) { + optr[i] = d_data[d_offset + i]; + } + for(unsigned t = 0; t < d_tags.size(); t++) { + if((d_tags[t].offset >= d_offset) && (d_tags[t].offset < d_offset+n)) + add_item_tag(0, d_tags[t].offset, d_tags[t].key, d_tags[t].value); + } + d_offset += n; + return n/d_vlen; + } + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/vector_source_X_impl.h.t b/gr-blocks/lib/vector_source_X_impl.h.t new file mode 100644 index 0000000000..78ec52bacf --- /dev/null +++ b/gr-blocks/lib/vector_source_X_impl.h.t @@ -0,0 +1,62 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2008,2012-2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +// @WARNING@ + +#ifndef @GUARD_NAME_IMPL@ +#define @GUARD_NAME_IMPL@ + +#include <blocks/@NAME@.h> + +namespace gr { + namespace blocks { + + class @NAME_IMPL@ : public @NAME@ + { + private: + std::vector<@TYPE@> d_data; + bool d_repeat; + unsigned int d_offset; + int d_vlen; + bool d_settags; + std::vector<gr_tag_t> d_tags; + unsigned int d_tagpos; + + public: + @NAME_IMPL@(const std::vector<@TYPE@> &data, + bool repeat, int vlen, + const std::vector<gr_tag_t> &tags); + ~@NAME_IMPL@(); + + void rewind() { d_offset=0; } + void set_data(const std::vector<@TYPE@> &data, + const std::vector<gr_tag_t> &tags); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* @GUARD_NAME_IMPL@ */ diff --git a/gr-blocks/python/qa_add_mult_div_sub.py b/gr-blocks/python/qa_add_mult_div_sub.py index 0aca03d3fd..6d48a6c389 100755 --- a/gr-blocks/python/qa_add_mult_div_sub.py +++ b/gr-blocks/python/qa_add_mult_div_sub.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2004,2007,2010,2012 Free Software Foundation, Inc. +# Copyright 2004,2007,2010,2012,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -21,7 +21,7 @@ # from gnuradio import gr, gr_unittest -import blocks_swig +import blocks_swig as blocks class test_add_mult_div_sub(gr_unittest.TestCase): @@ -33,9 +33,9 @@ class test_add_mult_div_sub(gr_unittest.TestCase): def help_ii(self, src_data, exp_data, op): for s in zip(range(len(src_data)), src_data): - src = gr.vector_source_i(s[1]) + src = blocks.vector_source_i(s[1]) self.tb.connect(src, (op, s[0])) - dst = gr.vector_sink_i() + dst = blocks.vector_sink_i() self.tb.connect(op, dst) self.tb.run() result_data = dst.data() @@ -43,9 +43,9 @@ class test_add_mult_div_sub(gr_unittest.TestCase): def help_ss(self, src_data, exp_data, op): for s in zip(range(len(src_data)), src_data): - src = gr.vector_source_s(s[1]) + src = blocks.vector_source_s(s[1]) self.tb.connect(src, (op, s[0])) - dst = gr.vector_sink_s() + dst = blocks.vector_sink_s() self.tb.connect(op, dst) self.tb.run() result_data = dst.data() @@ -53,9 +53,9 @@ class test_add_mult_div_sub(gr_unittest.TestCase): def help_ff(self, src_data, exp_data, op): for s in zip(range(len(src_data)), src_data): - src = gr.vector_source_f(s[1]) + src = blocks.vector_source_f(s[1]) self.tb.connect(src, (op, s[0])) - dst = gr.vector_sink_f() + dst = blocks.vector_sink_f() self.tb.connect(op, dst) self.tb.run() result_data = dst.data() @@ -63,9 +63,9 @@ class test_add_mult_div_sub(gr_unittest.TestCase): def help_cc(self, src_data, exp_data, op): for s in zip(range(len(src_data)), src_data): - src = gr.vector_source_c(s[1]) + src = blocks.vector_source_c(s[1]) self.tb.connect(src, (op, s[0])) - dst = gr.vector_sink_c() + dst = blocks.vector_sink_c() self.tb.connect(op, dst) self.tb.run() result_data = dst.data() @@ -77,28 +77,28 @@ class test_add_mult_div_sub(gr_unittest.TestCase): src1_data = (1, 2, 3, 4, 5) src2_data = (8, -3, 4, 8, 2) expected_result = (9, -1, 7, 12, 7) - op = blocks_swig.add_ss() + op = blocks.add_ss() self.help_ss((src1_data, src2_data), expected_result, op) def test_add_ii(self): src1_data = (1, 2, 3, 4, 5) src2_data = (8, -3, 4, 8, 2) expected_result = (9, -1, 7, 12, 7) - op = blocks_swig.add_ii() + op = blocks.add_ii() self.help_ii((src1_data, src2_data), expected_result, op) def test_add_ff(self): src1_data = (1.0, 2.0, 3.0, 4.0, 5.0) src2_data = (8.0, -3.0, 4.0, 8.0, 2.0) expected_result = (9.0, -1.0, 7.0, 12.0, 7.0) - op = blocks_swig.add_ff() + op = blocks.add_ff() self.help_ff((src1_data, src2_data), expected_result, op) def test_add_cc(self): src1_data = (1+1j, 2+2j, 3+3j, 4+4j, 5+5j) src2_data = (8+8j, -3-3j, 4+4j, 8+8j, 2+2j) expected_result = (9+9j, -1-1j, 7+7j, 12+12j, 7+7j) - op = blocks_swig.add_cc() + op = blocks.add_cc() self.help_cc((src1_data, src2_data), expected_result, op) # add_const_XX @@ -106,25 +106,25 @@ class test_add_mult_div_sub(gr_unittest.TestCase): def test_add_const_ss(self): src_data = (1, 2, 3, 4, 5) expected_result = (6, 7, 8, 9, 10) - op = blocks_swig.add_const_ss(5) + op = blocks.add_const_ss(5) self.help_ss((src_data,), expected_result, op) def test_add_const_ii(self): src_data = (1, 2, 3, 4, 5) expected_result = (6, 7, 8, 9, 10) - op = blocks_swig.add_const_ii(5) + op = blocks.add_const_ii(5) self.help_ii((src_data,), expected_result, op) def test_add_const_ff(self): src_data = (1, 2, 3, 4, 5) expected_result = (6, 7, 8, 9, 10) - op = blocks_swig.add_const_ff(5) + op = blocks.add_const_ff(5) self.help_ff((src_data,), expected_result, op) def test_add_const_cc(self): src_data = (1, 2, 3, 4, 5) expected_result = (1+5j, 2+5j, 3+5j, 4+5j, 5+5j) - op = blocks_swig.add_const_cc(5j) + op = blocks.add_const_cc(5j) self.help_cc((src_data,), expected_result, op) # multiply_XX @@ -133,7 +133,7 @@ class test_add_mult_div_sub(gr_unittest.TestCase): src1_data = (1, 2, 3, 4, 5) src2_data = (8, -3, 4, 8, 2) expected_result = (8, -6, 12, 32, 10) - op = blocks_swig.multiply_ss() + op = blocks.multiply_ss() self.help_ss((src1_data, src2_data), expected_result, op) @@ -141,7 +141,7 @@ class test_add_mult_div_sub(gr_unittest.TestCase): src1_data = (1, 2, 3, 4, 5) src2_data = (8, -3, 4, 8, 2) expected_result = (8, -6, 12, 32, 10) - op = blocks_swig.multiply_ii() + op = blocks.multiply_ii() self.help_ii((src1_data, src2_data), expected_result, op) @@ -149,7 +149,7 @@ class test_add_mult_div_sub(gr_unittest.TestCase): src1_data = (1, 2, 3, 4, 5) src2_data = (8, -3, 4, 8, 2) expected_result = (8, -6, 12, 32, 10) - op = blocks_swig.multiply_ff() + op = blocks.multiply_ff() self.help_ff((src1_data, src2_data), expected_result, op) @@ -157,7 +157,7 @@ class test_add_mult_div_sub(gr_unittest.TestCase): src1_data = (1+1j, 2+2j, 3+3j, 4+4j, 5+5j) src2_data = (8, -3, 4, 8, 2) expected_result = (8+8j, -6-6j, 12+12j, 32+32j, 10+10j) - op = blocks_swig.multiply_cc() + op = blocks.multiply_cc() self.help_cc((src1_data, src2_data), expected_result, op) @@ -166,38 +166,38 @@ class test_add_mult_div_sub(gr_unittest.TestCase): def test_multiply_const_ss(self): src_data = (-1, 0, 1, 2, 3) expected_result = (-5, 0, 5, 10, 15) - op = blocks_swig.multiply_const_ss(5) + op = blocks.multiply_const_ss(5) self.help_ss((src_data,), expected_result, op) def test_multiply_const_ii(self): src_data = (-1, 0, 1, 2, 3) expected_result = (-5, 0, 5, 10, 15) - op = blocks_swig.multiply_const_ii(5) + op = blocks.multiply_const_ii(5) self.help_ii((src_data,), expected_result, op) def test_multiply_const_ff(self): src_data = (-1, 0, 1, 2, 3) expected_result = (-5, 0, 5, 10, 15) - op = blocks_swig.multiply_const_ff(5) + op = blocks.multiply_const_ff(5) self.help_ff((src_data,), expected_result, op) def test_multiply_const_cc(self): src_data = (-1-1j, 0+0j, 1+1j, 2+2j, 3+3j) expected_result = (-5-5j, 0+0j, 5+5j, 10+10j, 15+15j) - op = blocks_swig.multiply_const_cc(5) + op = blocks.multiply_const_cc(5) self.help_cc((src_data,), expected_result, op) def test_multiply_const_cc2(self): src_data = (-1-1j, 0+0j, 1+1j, 2+2j, 3+3j) expected_result = (-3-7j, 0+0j, 3+7j, 6+14j, 9+21j) - op = blocks_swig.multiply_const_cc(5+2j) + op = blocks.multiply_const_cc(5+2j) self.help_cc((src_data,), expected_result, op) def test_sub_ii(self): src1_data = (1, 2, 3, 4, 5) src2_data = (8, -3, 4, 8, 2) expected_result = (-7, 5, -1, -4, 3) - op = blocks_swig.sub_ii() + op = blocks.sub_ii() self.help_ii((src1_data, src2_data), expected_result, op) @@ -205,7 +205,7 @@ class test_add_mult_div_sub(gr_unittest.TestCase): src1_data = ( 5, 9, -15, 1024) src2_data = (10, 3, -5, 64) expected_result = (0.5, 3, 3, 16) - op = blocks_swig.divide_ff() + op = blocks.divide_ff() self.help_ff((src1_data, src2_data), expected_result, op) if __name__ == '__main__': diff --git a/gr-blocks/python/qa_add_mult_v.py b/gr-blocks/python/qa_add_mult_v.py index 13cb71df2c..39040b159a 100755 --- a/gr-blocks/python/qa_add_mult_v.py +++ b/gr-blocks/python/qa_add_mult_v.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2004,2007,2010,2012 Free Software Foundation, Inc. +# Copyright 2004,2007,2010,2012,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -33,12 +33,12 @@ class test_add_mult_v(gr_unittest.TestCase): def help_ss(self, size, src_data, exp_data, op): for s in zip(range (len (src_data)), src_data): - src = gr.vector_source_s(s[1]) + src = blocks.vector_source_s(s[1]) srcv = blocks.stream_to_vector(gr.sizeof_short, size) self.tb.connect(src, srcv) self.tb.connect(srcv, (op, s[0])) rhs = blocks.vector_to_stream(gr.sizeof_short, size) - dst = gr.vector_sink_s() + dst = blocks.vector_sink_s() self.tb.connect(op, rhs, dst) self.tb.run() result_data = dst.data() @@ -46,12 +46,12 @@ class test_add_mult_v(gr_unittest.TestCase): def help_ii(self, size, src_data, exp_data, op): for s in zip(range (len (src_data)), src_data): - src = gr.vector_source_i(s[1]) + src = blocks.vector_source_i(s[1]) srcv = blocks.stream_to_vector(gr.sizeof_int, size) self.tb.connect(src, srcv) self.tb.connect(srcv, (op, s[0])) rhs = blocks.vector_to_stream(gr.sizeof_int, size) - dst = gr.vector_sink_i() + dst = blocks.vector_sink_i() self.tb.connect(op, rhs, dst) self.tb.run() result_data = dst.data() @@ -59,12 +59,12 @@ class test_add_mult_v(gr_unittest.TestCase): def help_ff(self, size, src_data, exp_data, op): for s in zip(range (len (src_data)), src_data): - src = gr.vector_source_f(s[1]) + src = blocks.vector_source_f(s[1]) srcv = blocks.stream_to_vector(gr.sizeof_float, size) self.tb.connect(src, srcv) self.tb.connect(srcv, (op, s[0])) rhs = blocks.vector_to_stream(gr.sizeof_float, size) - dst = gr.vector_sink_f() + dst = blocks.vector_sink_f() self.tb.connect(op, rhs, dst) self.tb.run() result_data = dst.data() @@ -72,52 +72,52 @@ class test_add_mult_v(gr_unittest.TestCase): def help_cc(self, size, src_data, exp_data, op): for s in zip(range (len (src_data)), src_data): - src = gr.vector_source_c(s[1]) + src = blocks.vector_source_c(s[1]) srcv = blocks.stream_to_vector(gr.sizeof_gr_complex, size) self.tb.connect(src, srcv) self.tb.connect(srcv, (op, s[0])) rhs = blocks.vector_to_stream(gr.sizeof_gr_complex, size) - dst = gr.vector_sink_c() + dst = blocks.vector_sink_c() self.tb.connect(op, rhs, dst) self.tb.run() result_data = dst.data() self.assertEqual(exp_data, result_data) def help_const_ss(self, src_data, exp_data, op): - src = gr.vector_source_s(src_data) + src = blocks.vector_source_s(src_data) srcv = blocks.stream_to_vector(gr.sizeof_short, len(src_data)) rhs = blocks.vector_to_stream(gr.sizeof_short, len(src_data)) - dst = gr.vector_sink_s() + dst = blocks.vector_sink_s() self.tb.connect(src, srcv, op, rhs, dst) self.tb.run() result_data = dst.data() self.assertEqual(exp_data, result_data) def help_const_ii(self, src_data, exp_data, op): - src = gr.vector_source_i(src_data) + src = blocks.vector_source_i(src_data) srcv = blocks.stream_to_vector(gr.sizeof_int, len(src_data)) rhs = blocks.vector_to_stream(gr.sizeof_int, len(src_data)) - dst = gr.vector_sink_i() + dst = blocks.vector_sink_i() self.tb.connect(src, srcv, op, rhs, dst) self.tb.run() result_data = dst.data() self.assertEqual(exp_data, result_data) def help_const_ff(self, src_data, exp_data, op): - src = gr.vector_source_f(src_data) + src = blocks.vector_source_f(src_data) srcv = blocks.stream_to_vector(gr.sizeof_float, len(src_data)) rhs = blocks.vector_to_stream(gr.sizeof_float, len(src_data)) - dst = gr.vector_sink_f() + dst = blocks.vector_sink_f() self.tb.connect(src, srcv, op, rhs, dst) self.tb.run() result_data = dst.data() self.assertEqual(exp_data, result_data) def help_const_cc(self, src_data, exp_data, op): - src = gr.vector_source_c(src_data) + src = blocks.vector_source_c(src_data) srcv = blocks.stream_to_vector(gr.sizeof_gr_complex, len(src_data)) rhs = blocks.vector_to_stream(gr.sizeof_gr_complex, len(src_data)) - dst = gr.vector_sink_c() + dst = blocks.vector_sink_c() self.tb.connect(src, srcv, op, rhs, dst) self.tb.run() result_data = dst.data() diff --git a/gr-blocks/python/qa_argmax.py b/gr-blocks/python/qa_argmax.py index ec82b71cd4..2fc8641d16 100644 --- a/gr-blocks/python/qa_argmax.py +++ b/gr-blocks/python/qa_argmax.py @@ -39,20 +39,20 @@ class test_arg_max(gr_unittest.TestCase): src2_data = (0,0.0,3.0,0,10,0) src3_data = (0,0.0,3.0,0,1,0) - src1 = gr.vector_source_f(src1_data) + src1 = blocks.vector_source_f(src1_data) s2v1 = blocks.stream_to_vector(gr.sizeof_float, len(src1_data)) tb.connect(src1, s2v1) - src2 = gr.vector_source_f(src2_data) + src2 = blocks.vector_source_f(src2_data) s2v2 = blocks.stream_to_vector(gr.sizeof_float, len(src1_data)) tb.connect(src2, s2v2) - src3 = gr.vector_source_f(src3_data) + src3 = blocks.vector_source_f(src3_data) s2v3 = blocks.stream_to_vector(gr.sizeof_float, len(src1_data)) tb.connect(src3, s2v3) - dst1 = gr.vector_sink_s() - dst2 = gr.vector_sink_s() + dst1 = blocks.vector_sink_s() + dst2 = blocks.vector_sink_s() argmax = blocks.argmax_fs(len(src1_data)) tb.connect(s2v1, (argmax, 0)) diff --git a/gr-blocks/python/qa_bin_statistics.py b/gr-blocks/python/qa_bin_statistics.py index 666f7c0d68..45d5105eb2 100755 --- a/gr-blocks/python/qa_bin_statistics.py +++ b/gr-blocks/python/qa_bin_statistics.py @@ -120,7 +120,7 @@ class test_bin_statistics(gr_unittest.TestCase): 13, 14, 15, 16 )]) - src = gr.vector_source_f(src_data, False) + src = blocks.vector_source_f(src_data, False) s2v = blocks.stream_to_vector(gr.sizeof_float, vlen) stats = blocks.bin_statistics_f(vlen, msgq, tune, tune_delay, dwell_delay) self.tb.connect(src, s2v, stats) @@ -148,7 +148,7 @@ class test_bin_statistics(gr_unittest.TestCase): expected_results = tuple([float(x) for x in ( 9, 10, 11, 12)]) - src = gr.vector_source_f(src_data, False) + src = blocks.vector_source_f(src_data, False) s2v = blocks.stream_to_vector(gr.sizeof_float, vlen) stats = blocks.bin_statistics_f(vlen, msgq, tune, tune_delay, dwell_delay) self.tb.connect(src, s2v, stats) @@ -178,7 +178,7 @@ class test_bin_statistics(gr_unittest.TestCase): expected_results = tuple([float(x) for x in ( 9, 10, 11, 12)]) - src = gr.vector_source_f(src_data, False) + src = blocks.vector_source_f(src_data, False) s2v = blocks.stream_to_vector(gr.sizeof_float, vlen) stats = blocks.bin_statistics_f(vlen, msgq, tune, tune_delay, dwell_delay) self.tb.connect(src, s2v, stats) @@ -210,7 +210,7 @@ class test_bin_statistics(gr_unittest.TestCase): expected_results = tuple([float(x) for x in ( 9, 10, 11, 12)]) - src = gr.vector_source_f(src_data, False) + src = blocks.vector_source_f(src_data, False) s2v = blocks.stream_to_vector(gr.sizeof_float, vlen) stats = blocks.bin_statistics_f(vlen, msgq, tune, tune_delay, dwell_delay) self.tb.connect(src, s2v, stats) diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_block_gateway.py b/gr-blocks/python/qa_block_gateway.py index 2c8cba5439..20a2660cba 100644 --- a/gnuradio-core/src/python/gnuradio/gr/qa_block_gateway.py +++ b/gr-blocks/python/qa_block_gateway.py @@ -1,5 +1,5 @@ # -# Copyright 2011-2012 Free Software Foundation, Inc. +# Copyright 2011-2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -22,6 +22,7 @@ from gnuradio import gr, gr_unittest import pmt import numpy +import blocks_swig as blocks class add_2_f32_1_f32(gr.sync_block): def __init__(self): @@ -182,10 +183,10 @@ class test_block_gateway(gr_unittest.TestCase): def test_add_f32(self): tb = gr.top_block() - src0 = gr.vector_source_f([1, 3, 5, 7, 9], False) - src1 = gr.vector_source_f([0, 2, 4, 6, 8], False) + src0 = blocks.vector_source_f([1, 3, 5, 7, 9], False) + src1 = blocks.vector_source_f([0, 2, 4, 6, 8], False) adder = add_2_f32_1_f32() - sink = gr.vector_sink_f() + sink = blocks.vector_sink_f() tb.connect((src0, 0), (adder, 0)) tb.connect((src1, 0), (adder, 1)) tb.connect(adder, sink) @@ -194,10 +195,10 @@ class test_block_gateway(gr_unittest.TestCase): def test_add_fc32(self): tb = gr.top_block() - src0 = gr.vector_source_c([1, 3j, 5, 7j, 9], False) - src1 = gr.vector_source_c([0, 2j, 4, 6j, 8], False) + src0 = blocks.vector_source_c([1, 3j, 5, 7j, 9], False) + src1 = blocks.vector_source_c([0, 2j, 4, 6j, 8], False) adder = add_2_fc32_1_fc32() - sink = gr.vector_sink_c() + sink = blocks.vector_sink_c() tb.connect((src0, 0), (adder, 0)) tb.connect((src1, 0), (adder, 1)) tb.connect(adder, sink) @@ -206,27 +207,27 @@ class test_block_gateway(gr_unittest.TestCase): def test_convolve(self): tb = gr.top_block() - src = gr.vector_source_f([1, 2, 3, 4, 5, 6, 7, 8], False) + src = blocks.vector_source_f([1, 2, 3, 4, 5, 6, 7, 8], False) cv = convolve() - sink = gr.vector_sink_f() + sink = blocks.vector_sink_f() tb.connect(src, cv, sink) tb.run() self.assertEqual(sink.data(), (1, 2, 3, 4, 5, 6, 7, 8)) def test_decim2x(self): tb = gr.top_block() - src = gr.vector_source_f([1, 2, 3, 4, 5, 6, 7, 8], False) + src = blocks.vector_source_f([1, 2, 3, 4, 5, 6, 7, 8], False) d2x = decim2x() - sink = gr.vector_sink_f() + sink = blocks.vector_sink_f() tb.connect(src, d2x, sink) tb.run() self.assertEqual(sink.data(), (1, 3, 5, 7)) def test_interp2x(self): tb = gr.top_block() - src = gr.vector_source_f([1, 3, 5, 7, 9], False) + src = blocks.vector_source_f([1, 3, 5, 7, 9], False) i2x = interp2x() - sink = gr.vector_sink_f() + sink = blocks.vector_sink_f() tb.connect(src, i2x, sink) tb.run() self.assertEqual(sink.data(), (1, 1, 3, 3, 5, 5, 7, 7, 9, 9)) @@ -234,7 +235,7 @@ class test_block_gateway(gr_unittest.TestCase): def test_tags(self): src = tag_source() sink = tag_sink() - head = gr.head(gr.sizeof_float, 50000) #should be enough items to get a tag through + head = blocks.head(gr.sizeof_float, 50000) #should be enough items to get a tag through tb = gr.top_block() tb.connect(src, head, sink) tb.run() @@ -242,10 +243,10 @@ class test_block_gateway(gr_unittest.TestCase): def test_fc32_to_f32_2(self): tb = gr.top_block() - src = gr.vector_source_c([1+2j, 3+4j, 5+6j, 7+8j, 9+10j], False) + src = blocks.vector_source_c([1+2j, 3+4j, 5+6j, 7+8j, 9+10j], False) convert = fc32_to_f32_2() v2s = vector_to_stream(numpy.float32, 2) - sink = gr.vector_sink_f() + sink = blocks.vector_sink_f() tb.connect(src, convert, v2s, sink) tb.run() self.assertEqual(sink.data(), (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)) diff --git a/gr-blocks/python/qa_boolean_operators.py b/gr-blocks/python/qa_boolean_operators.py index 5572f60acb..8755dad2fc 100755 --- a/gr-blocks/python/qa_boolean_operators.py +++ b/gr-blocks/python/qa_boolean_operators.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2004,2007,2008,2010 Free Software Foundation, Inc. +# Copyright 2004,2007,2008,2010,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -21,7 +21,7 @@ # from gnuradio import gr, gr_unittest -import blocks_swig +import blocks_swig as blocks class test_boolean_operators (gr_unittest.TestCase): @@ -33,9 +33,9 @@ class test_boolean_operators (gr_unittest.TestCase): def help_ss (self, src_data, exp_data, op): for s in zip (range (len (src_data)), src_data): - src = gr.vector_source_s (s[1]) + src = blocks.vector_source_s (s[1]) self.tb.connect (src, (op, s[0])) - dst = gr.vector_sink_s () + dst = blocks.vector_sink_s () self.tb.connect (op, dst) self.tb.run () result_data = dst.data () @@ -43,9 +43,9 @@ class test_boolean_operators (gr_unittest.TestCase): def help_bb (self, src_data, exp_data, op): for s in zip (range (len (src_data)), src_data): - src = gr.vector_source_b (s[1]) + src = blocks.vector_source_b (s[1]) self.tb.connect (src, (op, s[0])) - dst = gr.vector_sink_b () + dst = blocks.vector_sink_b () self.tb.connect (op, dst) self.tb.run () result_data = dst.data () @@ -53,9 +53,9 @@ class test_boolean_operators (gr_unittest.TestCase): def help_ii (self, src_data, exp_data, op): for s in zip (range (len (src_data)), src_data): - src = gr.vector_source_i (s[1]) + src = blocks.vector_source_i (s[1]) self.tb.connect (src, (op, s[0])) - dst = gr.vector_sink_i () + dst = blocks.vector_sink_i () self.tb.connect (op, dst) self.tb.run () result_data = dst.data () @@ -65,7 +65,7 @@ class test_boolean_operators (gr_unittest.TestCase): src1_data = (1, 2, 3, 0x5004, 0x1150) src2_data = (8, 2, 1 , 0x0508, 0x1105) expected_result = (9, 0, 2, 0x550C, 0x0055) - op = blocks_swig.xor_ss () + op = blocks.xor_ss () self.help_ss ((src1_data, src2_data), expected_result, op) @@ -73,7 +73,7 @@ class test_boolean_operators (gr_unittest.TestCase): src1_data = (1, 2, 3, 4, 0x50) src2_data = (8, 2, 1 , 8, 0x05) expected_result = (9, 0, 2, 0xC, 0x55) - op = blocks_swig.xor_bb () + op = blocks.xor_bb () self.help_bb ((src1_data, src2_data), expected_result, op) @@ -82,7 +82,7 @@ class test_boolean_operators (gr_unittest.TestCase): src1_data = (1, 2, 3, 0x5000004, 0x11000050) src2_data = (8, 2, 1 , 0x0500008, 0x11000005) expected_result = (9, 0, 2, 0x550000C, 0x00000055) - op = blocks_swig.xor_ii () + op = blocks.xor_ii () self.help_ii ((src1_data, src2_data), expected_result, op) @@ -91,7 +91,7 @@ class test_boolean_operators (gr_unittest.TestCase): src1_data = (1, 2, 3, 0x5004, 0x1150) src2_data = (8, 2, 1 , 0x0508, 0x1105) expected_result = (0, 2, 1, 0x0000, 0x1100) - op = blocks_swig.and_ss () + op = blocks.and_ss () self.help_ss ((src1_data, src2_data), expected_result, op) @@ -100,7 +100,7 @@ class test_boolean_operators (gr_unittest.TestCase): src2_data = (8, 2, 2, 1, 0x08, 0x05) src3_data = (8, 2, 1, 1, 0x08, 0x05) expected_result = (0, 2, 0, 1, 0x00, 0x00) - op = blocks_swig.and_bb () + op = blocks.and_bb () self.help_bb ((src1_data, src2_data, src3_data), expected_result, op) @@ -108,16 +108,16 @@ class test_boolean_operators (gr_unittest.TestCase): src1_data = (1, 2, 3, 0x50005004, 0x11001150) src2_data = (8, 2, 1 , 0x05000508, 0x11001105) expected_result = (0, 2, 1, 0x00000000, 0x11001100) - op = blocks_swig.and_ii () + op = blocks.and_ii () self.help_ii ((src1_data, src2_data), expected_result, op) def test_and_const_ss (self): src_data = (1, 2, 3, 0x5004, 0x1150) expected_result = (0, 2, 2, 0x5000, 0x1100) - src = gr.vector_source_s(src_data) - op = blocks_swig.and_const_ss (0x55AA) - dst = gr.vector_sink_s() + src = blocks.vector_source_s(src_data) + op = blocks.and_const_ss (0x55AA) + dst = blocks.vector_sink_s() self.tb.connect(src, op, dst) self.tb.run() self.assertEqual(dst.data(), expected_result) @@ -125,9 +125,9 @@ class test_boolean_operators (gr_unittest.TestCase): def test_and_const_bb (self): src_data = (1, 2, 3, 0x50, 0x11) expected_result = (0, 2, 2, 0x00, 0x00) - src = gr.vector_source_b(src_data) - op = blocks_swig.and_const_bb (0xAA) - dst = gr.vector_sink_b() + src = blocks.vector_source_b(src_data) + op = blocks.and_const_bb (0xAA) + dst = blocks.vector_sink_b() self.tb.connect(src, op, dst) self.tb.run() self.assertEqual(dst.data(), expected_result) @@ -136,9 +136,9 @@ class test_boolean_operators (gr_unittest.TestCase): def test_and_const_ii (self): src_data = (1, 2, 3, 0x5004, 0x1150) expected_result = (0, 2, 2, 0x5000, 0x1100) - src = gr.vector_source_i(src_data) - op = blocks_swig.and_const_ii (0x55AA) - dst = gr.vector_sink_i() + src = blocks.vector_source_i(src_data) + op = blocks.and_const_ii (0x55AA) + dst = blocks.vector_sink_i() self.tb.connect(src, op, dst) self.tb.run() self.assertEqual(dst.data(), expected_result) @@ -148,7 +148,7 @@ class test_boolean_operators (gr_unittest.TestCase): src1_data = (1, 2, 3, 0x5004, 0x1150) src2_data = (8, 2, 1 , 0x0508, 0x1105) expected_result = (9, 2, 3, 0x550C, 0x1155) - op = blocks_swig.or_ss () + op = blocks.or_ss () self.help_ss ((src1_data, src2_data), expected_result, op) @@ -157,7 +157,7 @@ class test_boolean_operators (gr_unittest.TestCase): src2_data = (8, 2, 2, 1 , 0x08, 0x05) src3_data = (8, 2, 1, 1 , 0x08, 0x05) expected_result = (9, 2, 3, 3, 0x0C, 0x55) - op = blocks_swig.or_bb () + op = blocks.or_bb () self.help_bb ((src1_data, src2_data, src3_data), expected_result, op) @@ -165,28 +165,28 @@ class test_boolean_operators (gr_unittest.TestCase): src1_data = (1, 2, 3, 0x50005004, 0x11001150) src2_data = (8, 2, 1 , 0x05000508, 0x11001105) expected_result = (9, 2, 3, 0x5500550C, 0x11001155) - op = blocks_swig.or_ii () + op = blocks.or_ii () self.help_ii ((src1_data, src2_data), expected_result, op) def test_not_ss (self): src1_data = (1, 2, 3, 0x5004, 0x1150) expected_result = (~1, ~2, ~3, ~0x5004, ~0x1150) - op = blocks_swig.not_ss () + op = blocks.not_ss () self.help_ss ((((src1_data),)), expected_result, op) def test_not_bb (self): src1_data = (1, 2, 2, 3, 0x04, 0x50) expected_result = (0xFE, 0xFD, 0xFD, 0xFC, 0xFB, 0xAF) - op = blocks_swig.not_bb () + op = blocks.not_bb () self.help_bb (((src1_data), ), expected_result, op) def test_not_ii (self): src1_data = (1, 2, 3, 0x50005004, 0x11001150) expected_result = (~1 , ~2, ~3, ~0x50005004, ~0x11001150) - op = blocks_swig.not_ii () + op = blocks.not_ii () self.help_ii (((src1_data),), expected_result, op) diff --git a/gr-blocks/python/qa_burst_tagger.py b/gr-blocks/python/qa_burst_tagger.py index 52d688d103..9923d2a368 100644 --- a/gr-blocks/python/qa_burst_tagger.py +++ b/gr-blocks/python/qa_burst_tagger.py @@ -35,8 +35,8 @@ class test_burst_tagger(gr_unittest.TestCase): def test_001(self): src_data = ( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10) trg_data = (-1, -1, 1, 1, -1, -1, 1, 1, -1, -1) - src = gr.vector_source_i(src_data) - trg = gr.vector_source_s(trg_data) + src = blocks.vector_source_i(src_data) + trg = blocks.vector_source_s(trg_data) op = blocks.burst_tagger(gr.sizeof_int) snk = blocks.tag_debug(gr.sizeof_int, "burst tagger QA") self.tb.connect(src, (op,0)) diff --git a/gr-blocks/python/qa_conjugate.py b/gr-blocks/python/qa_conjugate.py index 1808aa9c0b..7aab2e70a7 100644 --- a/gr-blocks/python/qa_conjugate.py +++ b/gr-blocks/python/qa_conjugate.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2012 Free Software Foundation, Inc. +# Copyright 2012,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -21,7 +21,7 @@ # from gnuradio import gr, gr_unittest -import blocks_swig +import blocks_swig as blocks class test_conjugate (gr_unittest.TestCase): @@ -40,9 +40,9 @@ class test_conjugate (gr_unittest.TestCase): 2+2j, 1+1j, 2-2j, 1-1j, 0-0j) - src = gr.vector_source_c(src_data) - op = blocks_swig.conjugate_cc () - dst = gr.vector_sink_c () + src = blocks.vector_source_c(src_data) + op = blocks.conjugate_cc () + dst = blocks.vector_sink_c () self.tb.connect(src, op) self.tb.connect(op, dst) diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_copy.py b/gr-blocks/python/qa_copy.py index 68c8e451f3..04f6454231 100755 --- a/gnuradio-core/src/python/gnuradio/gr/qa_copy.py +++ b/gr-blocks/python/qa_copy.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2009,2010 Free Software Foundation, Inc. +# Copyright 2009,2010,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -21,21 +21,22 @@ # from gnuradio import gr, gr_unittest +import blocks_swig as blocks class test_copy(gr_unittest.TestCase): - def setUp (self): - self.tb = gr.top_block () + def setUp(self): + self.tb = gr.top_block() - def tearDown (self): + def tearDown(self): self.tb = None - def test_copy (self): + def test_copy(self): src_data = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) expected_result = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) - src = gr.vector_source_b(src_data) - op = gr.copy(gr.sizeof_char) - dst = gr.vector_sink_b() + src = blocks.vector_source_b(src_data) + op = blocks.copy(gr.sizeof_char) + dst = blocks.vector_sink_b() self.tb.connect(src, op, dst) self.tb.run() dst_data = dst.data() @@ -44,15 +45,14 @@ class test_copy(gr_unittest.TestCase): def test_copy_drop (self): src_data = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) expected_result = () - src = gr.vector_source_b(src_data) - op = gr.copy(gr.sizeof_char) + src = blocks.vector_source_b(src_data) + op = blocks.copy(gr.sizeof_char) op.set_enabled(False) - dst = gr.vector_sink_b() + dst = blocks.vector_sink_b() self.tb.connect(src, op, dst) self.tb.run() dst_data = dst.data() self.assertEqual(expected_result, dst_data) - if __name__ == '__main__': gr_unittest.run(test_copy, "test_copy.xml") diff --git a/gnuradio-core/src/python/gnuradio/ctrlport/qa_cpp_py_binding.py b/gr-blocks/python/qa_cpp_py_binding.py index 6de5d5fc9f..c3d6a3f3bc 100755 --- a/gnuradio-core/src/python/gnuradio/ctrlport/qa_cpp_py_binding.py +++ b/gr-blocks/python/qa_cpp_py_binding.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2012 Free Software Foundation, Inc. +# Copyright 2012,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -32,6 +32,8 @@ from gnuradio.ctrlport import GNURadio from gnuradio import ctrlport import os +import blocks_swig as blocks + def get1(): return "success" @@ -134,9 +136,9 @@ class test_cpp_py_binding(gr_unittest.TestCase): def test_002(self): data = range(1,9) - self.src = gr.vector_source_c(data) - self.p1 = gr.ctrlport_probe_c("aaa","C++ exported variable") - self.p2 = gr.ctrlport_probe_c("bbb","C++ exported variable") + self.src = blocks.vector_source_c(data) + self.p1 = blocks.ctrlport_probe_c("aaa","C++ exported variable") + self.p2 = blocks.ctrlport_probe_c("bbb","C++ exported variable") probe_name = self.p2.alias() self.tb.connect(self.src, self.p1) diff --git a/gnuradio-core/src/python/gnuradio/ctrlport/qa_cpp_py_binding_set.py b/gr-blocks/python/qa_cpp_py_binding_set.py index 4ca120099c..28ddc48b2f 100755 --- a/gnuradio-core/src/python/gnuradio/ctrlport/qa_cpp_py_binding_set.py +++ b/gr-blocks/python/qa_cpp_py_binding_set.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2012 Free Software Foundation, Inc. +# Copyright 2012,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -32,6 +32,8 @@ from gnuradio.ctrlport import GNURadio from gnuradio import ctrlport import os +import blocks_swig as blocks + class inc_class: def __init__(self,val): self.val = val; @@ -111,8 +113,8 @@ class test_cpp_py_binding_set(gr_unittest.TestCase): def test_002(self): data = range(1, 10) - self.src = gr.vector_source_c(data, True) - self.p = gr.nop(gr.sizeof_gr_complex) + self.src = blocks.vector_source_c(data, True) + self.p = blocks.nop(gr.sizeof_gr_complex) self.p.set_ctrlport_test(0); probe_info = self.p.alias() diff --git a/gr-blocks/python/qa_delay.py b/gr-blocks/python/qa_delay.py index 031cadb2d7..44b87c14ae 100755 --- a/gr-blocks/python/qa_delay.py +++ b/gr-blocks/python/qa_delay.py @@ -37,9 +37,9 @@ class test_delay(gr_unittest.TestCase): src_data = [float(x) for x in range(0, 100)] expected_result = tuple(delta_t*[0.0] + src_data) - src = gr.vector_source_f(src_data) + src = blocks.vector_source_f(src_data) op = blocks.delay(gr.sizeof_float, delta_t) - dst = gr.vector_sink_f() + dst = blocks.vector_sink_f() tb.connect(src, op, dst) tb.run() @@ -52,9 +52,9 @@ class test_delay(gr_unittest.TestCase): src_data = [float(x) for x in range(0, 100)] expected_result = tuple(delta_t*[0.0] + src_data) - src = gr.vector_source_f(src_data) + src = blocks.vector_source_f(src_data) op = blocks.delay(gr.sizeof_float, delta_t) - dst = gr.vector_sink_f() + dst = blocks.vector_sink_f() tb.connect(src, op, dst) tb.run() diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_endian_swap.py b/gr-blocks/python/qa_endian_swap.py index 4d2555cc4d..5180293052 100644 --- a/gnuradio-core/src/python/gnuradio/gr/qa_endian_swap.py +++ b/gr-blocks/python/qa_endian_swap.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2011,2012 Free Software Foundation, Inc. +# Copyright 2011-2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -21,24 +21,24 @@ # from gnuradio import gr, gr_unittest +import blocks_swig as blocks import ctypes -class test_endian_swap (gr_unittest.TestCase): +class test_endian_swap(gr_unittest.TestCase): - def setUp (self): - self.tb = gr.top_block () + def setUp(self): + self.tb = gr.top_block() - def tearDown (self): + def tearDown(self): self.tb = None def test_001(self): - src_data = [1,2,3,4] expected_result = [256, 512, 768, 1024]; - src = gr.vector_source_s(src_data) - op = gr.endian_swap(2) - dst = gr.vector_sink_s() + src = blocks.vector_source_s(src_data) + op = blocks.endian_swap(2) + dst = blocks.vector_sink_s() self.tb.connect(src, op, dst) self.tb.run() @@ -51,9 +51,9 @@ class test_endian_swap (gr_unittest.TestCase): src_data = [1,2,3,4] expected_result = [16777216, 33554432, 50331648, 67108864]; - src = gr.vector_source_i(src_data) - op = gr.endian_swap(4) - dst = gr.vector_sink_i() + src = blocks.vector_source_i(src_data) + op = blocks.endian_swap(4) + dst = blocks.vector_sink_i() self.tb.connect(src, op, dst) self.tb.run() diff --git a/gr-blocks/python/qa_file_metadata.py b/gr-blocks/python/qa_file_metadata.py index cf7a075f42..3112ea69b0 100644 --- a/gr-blocks/python/qa_file_metadata.py +++ b/gr-blocks/python/qa_file_metadata.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2012 Free Software Foundation, Inc. +# Copyright 2012,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -54,7 +54,7 @@ class test_file_metadata(gr_unittest.TestCase): extras_str = pmt.serialize_str(extras) data = sig_source_c(samp_rate, 1000, 1, N) - src = gr.vector_source_c(data) + src = blocks.vector_source_c(data) fsnk = blocks.file_meta_sink(gr.sizeof_gr_complex, outfile, samp_rate, 1, blocks.GR_FILE_FLOAT, True, @@ -96,9 +96,9 @@ class test_file_metadata(gr_unittest.TestCase): # Test file metadata source src.rewind() fsrc = blocks.file_meta_source(outfile, False) - vsnk = gr.vector_sink_c() + vsnk = blocks.vector_sink_c() tsnk = blocks.tag_debug(gr.sizeof_gr_complex, "QA") - ssnk = gr.vector_sink_c() + ssnk = blocks.vector_sink_c() self.tb.disconnect(src, fsnk) self.tb.connect(fsrc, vsnk) self.tb.connect(fsrc, tsnk) @@ -133,7 +133,7 @@ class test_file_metadata(gr_unittest.TestCase): extras_str = pmt.serialize_str(extras) data = sig_source_c(samp_rate, 1000, 1, N) - src = gr.vector_source_c(data) + src = blocks.vector_source_c(data) fsnk = blocks.file_meta_sink(gr.sizeof_gr_complex, outfile, samp_rate, 1, blocks.GR_FILE_FLOAT, True, @@ -175,9 +175,9 @@ class test_file_metadata(gr_unittest.TestCase): # Test file metadata source src.rewind() fsrc = blocks.file_meta_source(outfile, False, detached, outfile_hdr) - vsnk = gr.vector_sink_c() + vsnk = blocks.vector_sink_c() tsnk = blocks.tag_debug(gr.sizeof_gr_complex, "QA") - ssnk = gr.vector_sink_c() + ssnk = blocks.vector_sink_c() self.tb.disconnect(src, fsnk) self.tb.connect(fsrc, vsnk) self.tb.connect(fsrc, tsnk) diff --git a/gr-blocks/python/qa_file_source_sink.py b/gr-blocks/python/qa_file_source_sink.py index 2898f760ec..cf3b512db0 100644 --- a/gr-blocks/python/qa_file_source_sink.py +++ b/gr-blocks/python/qa_file_source_sink.py @@ -38,12 +38,12 @@ class test_file_source_sink(gr_unittest.TestCase): expected_result = range(1000) filename = "tmp.32f" - src = gr.vector_source_f(src_data) + src = blocks.vector_source_f(src_data) snk = blocks.file_sink(gr.sizeof_float, filename) snk.set_unbuffered(True) src2 = blocks.file_source(gr.sizeof_float, filename) - snk2 = gr.vector_sink_f() + snk2 = blocks.vector_sink_f() self.tb.connect(src, snk) self.tb.run() @@ -65,7 +65,7 @@ class test_file_source_sink(gr_unittest.TestCase): fhandle0 = open(filename, "wb") fd0 = fhandle0.fileno() - src = gr.vector_source_f(src_data) + src = blocks.vector_source_f(src_data) snk = blocks.file_descriptor_sink(gr.sizeof_float, fd0) self.tb.connect(src, snk) @@ -76,7 +76,7 @@ class test_file_source_sink(gr_unittest.TestCase): fhandle1 = open(filename, "rb") fd1 = fhandle1.fileno() src2 = blocks.file_descriptor_source(gr.sizeof_float, fd1, False) - snk2 = gr.vector_sink_f() + snk2 = blocks.vector_sink_f() self.tb.disconnect(src, snk) self.tb.connect(src2, snk2) diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_head.py b/gr-blocks/python/qa_head.py index d7cb354dcb..39b1255978 100755 --- a/gnuradio-core/src/python/gnuradio/gr/qa_head.py +++ b/gr-blocks/python/qa_head.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2004,2007,2010 Free Software Foundation, Inc. +# Copyright 2004,2007,2010,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -21,27 +21,27 @@ # from gnuradio import gr, gr_unittest +import blocks_swig as blocks -class test_head (gr_unittest.TestCase): +class test_head(gr_unittest.TestCase): - def setUp (self): - self.tb = gr.top_block () + def setUp(self): + self.tb = gr.top_block() - def tearDown (self): + def tearDown(self): self.tb = None - def test_head (self): + def test_head(self): src_data = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) expected_result = (1, 2, 3, 4) - src1 = gr.vector_source_i (src_data) - op = gr.head (gr.sizeof_int, 4) - dst1 = gr.vector_sink_i () - self.tb.connect (src1, op) - self.tb.connect (op, dst1) - self.tb.run () - dst_data = dst1.data () - self.assertEqual (expected_result, dst_data) - + src1 = blocks.vector_source_i(src_data) + op = blocks.head(gr.sizeof_int, 4) + dst1 = blocks.vector_sink_i() + self.tb.connect(src1, op) + self.tb.connect(op, dst1) + self.tb.run() + dst_data = dst1.data() + self.assertEqual(expected_result, dst_data) if __name__ == '__main__': gr_unittest.run(test_head, "test_head.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_hier_block2.py b/gr-blocks/python/qa_hier_block2.py index 9ba48599af..f482fda8cf 100755 --- a/gnuradio-core/src/python/gnuradio/gr/qa_hier_block2.py +++ b/gr-blocks/python/qa_hier_block2.py @@ -1,6 +1,7 @@ #!/usr/bin/env python from gnuradio import gr, gr_unittest +import blocks_swig as blocks import numpy class add_ff(gr.sync_block): @@ -52,22 +53,22 @@ class test_hier_block2(gr_unittest.TestCase): hblock = gr.hier_block2("test_block", gr.io_signature(1,1,gr.sizeof_int), gr.io_signature(1,1,gr.sizeof_int)) - nop1 = gr.nop(gr.sizeof_int) + nop1 = blocks.nop(gr.sizeof_int) hblock.connect(hblock, nop1) def test_004_connect_output(self): hblock = gr.hier_block2("test_block", gr.io_signature(1,1,gr.sizeof_int), gr.io_signature(1,1,gr.sizeof_int)) - nop1 = gr.nop(gr.sizeof_int) + nop1 = blocks.nop(gr.sizeof_int) hblock.connect(nop1, hblock) def test_005_connect_output_in_use(self): hblock = gr.hier_block2("test_block", gr.io_signature(1,1,gr.sizeof_int), gr.io_signature(1,1,gr.sizeof_int)) - nop1 = gr.nop(gr.sizeof_int) - nop2 = gr.nop(gr.sizeof_int) + nop1 = blocks.nop(gr.sizeof_int) + nop2 = blocks.nop(gr.sizeof_int) hblock.connect(nop1, hblock) self.assertRaises(ValueError, lambda: hblock.connect(nop2, hblock)) @@ -76,7 +77,7 @@ class test_hier_block2(gr_unittest.TestCase): hblock = gr.hier_block2("test_block", gr.io_signature(1,1,gr.sizeof_int), gr.io_signature(1,1,gr.sizeof_int)) - nop1 = gr.nop(gr.sizeof_int) + nop1 = blocks.nop(gr.sizeof_int) self.assertRaises(ValueError, lambda: hblock.connect((hblock, -1), nop1)) @@ -84,7 +85,7 @@ class test_hier_block2(gr_unittest.TestCase): hblock = gr.hier_block2("test_block", gr.io_signature(1,1,gr.sizeof_int), gr.io_signature(1,1,gr.sizeof_int)) - nop1 = gr.nop(gr.sizeof_int) + nop1 = blocks.nop(gr.sizeof_int) self.assertRaises(ValueError, lambda: hblock.connect((hblock, 1), nop1)) @@ -92,8 +93,8 @@ class test_hier_block2(gr_unittest.TestCase): hblock = gr.hier_block2("test_block", gr.io_signature(1,1,gr.sizeof_int), gr.io_signature(1,1,gr.sizeof_int)) - nop1 = gr.nop(gr.sizeof_int) - nop2 = gr.nop(gr.sizeof_int) + nop1 = blocks.nop(gr.sizeof_int) + nop2 = blocks.nop(gr.sizeof_int) self.assertRaises(ValueError, lambda: hblock.connect(nop1, (nop2, -1))) @@ -101,8 +102,8 @@ class test_hier_block2(gr_unittest.TestCase): hblock = gr.hier_block2("test_block", gr.io_signature(1,1,gr.sizeof_int), gr.io_signature(1,1,gr.sizeof_int)) - nop1 = gr.null_sink(gr.sizeof_int) - nop2 = gr.null_sink(gr.sizeof_int) + nop1 = blocks.null_sink(gr.sizeof_int) + nop2 = blocks.null_sink(gr.sizeof_int) self.assertRaises(ValueError, lambda: hblock.connect(nop1, (nop2, 1))) @@ -113,9 +114,9 @@ class test_hier_block2(gr_unittest.TestCase): def test_010_run(self): expected = (1.0, 2.0, 3.0, 4.0) hblock = gr.top_block("test_block") - src = gr.vector_source_f(expected, False) - sink1 = gr.vector_sink_f() - sink2 = gr.vector_sink_f() + src = blocks.vector_source_f(expected, False) + sink1 = blocks.vector_sink_f() + sink2 = blocks.vector_sink_f() hblock.connect(src, sink1) hblock.connect(src, sink2) hblock.run() @@ -128,7 +129,7 @@ class test_hier_block2(gr_unittest.TestCase): hblock = gr.hier_block2("test_block", gr.io_signature(1,1,gr.sizeof_int), gr.io_signature(1,1,gr.sizeof_int)) - nop1 = gr.nop(gr.sizeof_int) + nop1 = blocks.nop(gr.sizeof_int) hblock.connect(hblock, nop1) hblock.disconnect(hblock, nop1) @@ -136,8 +137,8 @@ class test_hier_block2(gr_unittest.TestCase): hblock = gr.hier_block2("test_block", gr.io_signature(1,1,gr.sizeof_int), gr.io_signature(1,1,gr.sizeof_int)) - nop1 = gr.nop(gr.sizeof_int) - nop2 = gr.nop(gr.sizeof_int) + nop1 = blocks.nop(gr.sizeof_int) + nop2 = blocks.nop(gr.sizeof_int) hblock.connect(hblock, nop1) self.assertRaises(ValueError, lambda: hblock.disconnect(hblock, nop2)) @@ -146,7 +147,7 @@ class test_hier_block2(gr_unittest.TestCase): hblock = gr.hier_block2("test_block", gr.io_signature(1,1,gr.sizeof_int), gr.io_signature(1,1,gr.sizeof_int)) - nop1 = gr.nop(gr.sizeof_int) + nop1 = blocks.nop(gr.sizeof_int) hblock.connect(hblock, nop1) self.assertRaises(ValueError, lambda: hblock.disconnect((hblock, -1), nop1)) @@ -155,7 +156,7 @@ class test_hier_block2(gr_unittest.TestCase): hblock = gr.hier_block2("test_block", gr.io_signature(1,1,gr.sizeof_int), gr.io_signature(1,1,gr.sizeof_int)) - nop1 = gr.nop(gr.sizeof_int) + nop1 = blocks.nop(gr.sizeof_int) hblock.connect(hblock, nop1) self.assertRaises(ValueError, lambda: hblock.disconnect((hblock, 1), nop1)) @@ -164,7 +165,7 @@ class test_hier_block2(gr_unittest.TestCase): hblock = gr.hier_block2("test_block", gr.io_signature(1,1,gr.sizeof_int), gr.io_signature(1,1,gr.sizeof_int)) - nop1 = gr.nop(gr.sizeof_int) + nop1 = blocks.nop(gr.sizeof_int) hblock.connect(nop1, hblock) hblock.disconnect(nop1, hblock) @@ -172,8 +173,8 @@ class test_hier_block2(gr_unittest.TestCase): hblock = gr.hier_block2("test_block", gr.io_signature(1,1,gr.sizeof_int), gr.io_signature(1,1,gr.sizeof_int)) - nop1 = gr.nop(gr.sizeof_int) - nop2 = gr.nop(gr.sizeof_int) + nop1 = blocks.nop(gr.sizeof_int) + nop2 = blocks.nop(gr.sizeof_int) hblock.connect(nop1, hblock) self.assertRaises(ValueError, lambda: hblock.disconnect(nop2, hblock)) @@ -182,7 +183,7 @@ class test_hier_block2(gr_unittest.TestCase): hblock = gr.hier_block2("test_block", gr.io_signature(1,1,gr.sizeof_int), gr.io_signature(1,1,gr.sizeof_int)) - nop1 = gr.nop(gr.sizeof_int) + nop1 = blocks.nop(gr.sizeof_int) hblock.connect(hblock, nop1) self.assertRaises(ValueError, lambda: hblock.disconnect(nop1, (hblock, -1))) @@ -191,7 +192,7 @@ class test_hier_block2(gr_unittest.TestCase): hblock = gr.hier_block2("test_block", gr.io_signature(1,1,gr.sizeof_int), gr.io_signature(1,1,gr.sizeof_int)) - nop1 = gr.nop(gr.sizeof_int) + nop1 = blocks.nop(gr.sizeof_int) hblock.connect(nop1, hblock) self.assertRaises(ValueError, lambda: hblock.disconnect(nop1, (hblock, 1))) @@ -199,8 +200,8 @@ class test_hier_block2(gr_unittest.TestCase): def test_020_run(self): hblock = gr.top_block("test_block") data = (1.0, 2.0, 3.0, 4.0) - src = gr.vector_source_f(data, False) - dst = gr.vector_sink_f() + src = blocks.vector_source_f(data, False) + dst = blocks.vector_sink_f() hblock.connect(src, dst) hblock.run() self.assertEquals(data, dst.data()) @@ -251,8 +252,8 @@ class test_hier_block2(gr_unittest.TestCase): hb = gr.hier_block2("block", gr.io_signature(0, 0, 0), gr.io_signature(0, 0, 0)) - src = gr.vector_source_f(expected_data) - dst = gr.vector_sink_f() + src = blocks.vector_source_f(expected_data) + dst = blocks.vector_sink_f() hb.connect(src, dst) tb.connect(hb) tb.run() @@ -263,10 +264,10 @@ class test_hier_block2(gr_unittest.TestCase): hb = gr.hier_block2("block", gr.io_signature(1, 1, 1), gr.io_signature(1, 1, 1)) - hsrc = gr.vector_source_b([1,]) + hsrc = blocks.vector_source_b([1,]) hb.connect(hsrc, hb) # wire output internally - src = gr.vector_source_b([1, ]) - dst = gr.vector_sink_b() + src = blocks.vector_source_b([1, ]) + dst = blocks.vector_sink_b() tb.connect(src, hb, dst) # hb's input is not connected internally self.assertRaises(RuntimeError, lambda: tb.run()) @@ -277,10 +278,10 @@ class test_hier_block2(gr_unittest.TestCase): hb = gr.hier_block2("block", gr.io_signature(1, 1, 1), gr.io_signature(1, 1, 1)) - hdst = gr.vector_sink_b() + hdst = blocks.vector_sink_b() hb.connect(hb, hdst) # wire input internally - src = gr.vector_source_b([1, ]) - dst = gr.vector_sink_b() + src = blocks.vector_source_b([1, ]) + dst = blocks.vector_sink_b() tb.connect(src, hb, dst) # hb's output is not connected internally self.assertRaises(RuntimeError, lambda: tb.run()) @@ -290,10 +291,10 @@ class test_hier_block2(gr_unittest.TestCase): hb = gr.hier_block2("block", gr.io_signature(1, 1, 1), gr.io_signature(1, 1, 1)) - hsrc = gr.vector_sink_b() + hsrc = blocks.vector_sink_b() hb.connect(hb, hsrc) # wire input internally - src = gr.vector_source_b([1, ]) - dst = gr.vector_sink_b() + src = blocks.vector_source_b([1, ]) + dst = blocks.vector_sink_b() tb.connect(src, hb) # hb's output is not connected internally or externally self.assertRaises(RuntimeError, lambda: tb.run()) @@ -303,9 +304,9 @@ class test_hier_block2(gr_unittest.TestCase): hb = gr.hier_block2("block", gr.io_signature(1, 1, 1), gr.io_signature(1, 1, 1)) - hdst = gr.vector_source_b([1,]) + hdst = blocks.vector_source_b([1,]) hb.connect(hdst, hb) # wire output internally - dst = gr.vector_sink_b() + dst = blocks.vector_sink_b() tb.connect(hb, dst) # hb's input is not connected internally or externally self.assertRaises(RuntimeError, lambda: tb.run()) @@ -314,8 +315,8 @@ class test_hier_block2(gr_unittest.TestCase): tb = gr.top_block() hb = gr.hier_block2("block", gr.io_signature(0, 0, 0), gr.io_signature(0, 0, 0)) - src = gr.vector_source_b([1, ]) - dst = gr.vector_sink_b() + src = blocks.vector_source_b([1, ]) + dst = blocks.vector_sink_b() hb.connect(src, dst) tb.connect(hb) # Singleton connect tb.lock() @@ -325,8 +326,8 @@ class test_hier_block2(gr_unittest.TestCase): def test_029_singleton_disconnect(self): tb = gr.top_block() - src = gr.vector_source_b([1, ]) - dst = gr.vector_sink_b() + src = blocks.vector_source_b([1, ]) + dst = blocks.vector_sink_b() tb.connect(src, dst) tb.disconnect(src) # Singleton disconnect tb.connect(src, dst) @@ -335,23 +336,23 @@ class test_hier_block2(gr_unittest.TestCase): def test_030_nested_input(self): tb = gr.top_block() - src = gr.vector_source_b([1,]) + src = blocks.vector_source_b([1,]) hb1 = gr.hier_block2("hb1", gr.io_signature(1, 1, gr.sizeof_char), gr.io_signature(0, 0, 0)) hb2 = gr.hier_block2("hb2", gr.io_signature(1, 1, gr.sizeof_char), gr.io_signature(0, 0, 0)) - dst = gr.vector_sink_b() + dst = blocks.vector_sink_b() tb.connect(src, hb1) hb1.connect(hb1, hb2) - hb2.connect(hb2, gr.kludge_copy(gr.sizeof_char), dst) + hb2.connect(hb2, blocks.copy(gr.sizeof_char), dst) tb.run() self.assertEquals(dst.data(), (1,)) def test_031_multiple_internal_inputs(self): tb = gr.top_block() - src = gr.vector_source_f([1.0,]) + src = blocks.vector_source_f([1.0,]) hb = gr.hier_block2("hb", gr.io_signature(1, 1, gr.sizeof_float), gr.io_signature(1, 1, gr.sizeof_float)) @@ -363,14 +364,14 @@ class test_hier_block2(gr_unittest.TestCase): hb.connect(m1, (add, 0)) hb.connect(m2, (add, 1)) hb.connect(add, hb) # add is connected to hb external output #0 - dst = gr.vector_sink_f() + dst = blocks.vector_sink_f() tb.connect(src, hb, dst) tb.run() self.assertEquals(dst.data(), (3.0,)) def test_032_nested_multiple_internal_inputs(self): tb = gr.top_block() - src = gr.vector_source_f([1.0,]) + src = blocks.vector_source_f([1.0,]) hb = gr.hier_block2("hb", gr.io_signature(1, 1, gr.sizeof_float), gr.io_signature(1, 1, gr.sizeof_float)) @@ -387,7 +388,7 @@ class test_hier_block2(gr_unittest.TestCase): hb2.connect(m2, (add, 1)) hb2.connect(add, hb2) # add is connected to hb2 external output #0 hb.connect(hb, hb2, hb) # hb as hb2 as nested internal block - dst = gr.vector_sink_f() + dst = blocks.vector_sink_f() tb.connect(src, hb, dst) tb.run() self.assertEquals(dst.data(), (3.0,)) diff --git a/gr-blocks/python/qa_integrate.py b/gr-blocks/python/qa_integrate.py index c404f1b309..9d9d9345f4 100755 --- a/gr-blocks/python/qa_integrate.py +++ b/gr-blocks/python/qa_integrate.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2008,2010 Free Software Foundation, Inc. +# Copyright 2008,2010,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -21,7 +21,7 @@ # from gnuradio import gr, gr_unittest -import blocks_swig +import blocks_swig as blocks import math class test_integrate (gr_unittest.TestCase): @@ -35,9 +35,9 @@ class test_integrate (gr_unittest.TestCase): def test_000_ss(self): src_data = (1, 2, 3, 4, 5, 6) dst_data = (6, 15) - src = gr.vector_source_s(src_data) - itg = blocks_swig.integrate_ss(3) - dst = gr.vector_sink_s() + src = blocks.vector_source_s(src_data) + itg = blocks.integrate_ss(3) + dst = blocks.vector_sink_s() self.tb.connect(src, itg, dst) self.tb.run() self.assertEqual(dst_data, dst.data()) @@ -45,9 +45,9 @@ class test_integrate (gr_unittest.TestCase): def test_001_ii(self): src_data = (1, 2, 3, 4, 5, 6) dst_data = (6, 15) - src = gr.vector_source_i(src_data) - itg = blocks_swig.integrate_ii(3) - dst = gr.vector_sink_i() + src = blocks.vector_source_i(src_data) + itg = blocks.integrate_ii(3) + dst = blocks.vector_sink_i() self.tb.connect(src, itg, dst) self.tb.run() self.assertEqual(dst_data, dst.data()) @@ -55,9 +55,9 @@ class test_integrate (gr_unittest.TestCase): def test_002_ff(self): src_data = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0] dst_data = [6.0, 15.0] - src = gr.vector_source_f(src_data) - itg = blocks_swig.integrate_ff(3) - dst = gr.vector_sink_f() + src = blocks.vector_source_f(src_data) + itg = blocks.integrate_ff(3) + dst = blocks.vector_sink_f() self.tb.connect(src, itg, dst) self.tb.run() self.assertFloatTuplesAlmostEqual(dst_data, dst.data(), 6) @@ -65,9 +65,9 @@ class test_integrate (gr_unittest.TestCase): def test_003_cc(self): src_data = [1.0+1.0j, 2.0+2.0j, 3.0+3.0j, 4.0+4.0j, 5.0+5.0j, 6.0+6.0j] dst_data = [6.0+6.0j, 15.0+15.0j] - src = gr.vector_source_c(src_data) - itg = blocks_swig.integrate_cc(3) - dst = gr.vector_sink_c() + src = blocks.vector_source_c(src_data) + itg = blocks.integrate_cc(3) + dst = blocks.vector_sink_c() self.tb.connect(src, itg, dst) self.tb.run() self.assertComplexTuplesAlmostEqual(dst_data, dst.data(), 6) diff --git a/gr-blocks/python/qa_interleave.py b/gr-blocks/python/qa_interleave.py index 376d487b10..a65824ec33 100755 --- a/gr-blocks/python/qa_interleave.py +++ b/gr-blocks/python/qa_interleave.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2004,2007,2010,2012 Free Software Foundation, Inc. +# Copyright 2004,2007,2010,2012,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -21,7 +21,7 @@ # from gnuradio import gr, gr_unittest -import blocks_swig +import blocks_swig as blocks import math class test_interleave (gr_unittest.TestCase): @@ -34,12 +34,12 @@ class test_interleave (gr_unittest.TestCase): def test_int_001 (self): lenx = 64 - src0 = gr.vector_source_f (range (0, lenx, 4)) - src1 = gr.vector_source_f (range (1, lenx, 4)) - src2 = gr.vector_source_f (range (2, lenx, 4)) - src3 = gr.vector_source_f (range (3, lenx, 4)) - op = blocks_swig.interleave (gr.sizeof_float) - dst = gr.vector_sink_f () + src0 = blocks.vector_source_f (range (0, lenx, 4)) + src1 = blocks.vector_source_f (range (1, lenx, 4)) + src2 = blocks.vector_source_f (range (2, lenx, 4)) + src3 = blocks.vector_source_f (range (3, lenx, 4)) + op = blocks.interleave (gr.sizeof_float) + dst = blocks.vector_sink_f () self.tb.connect (src0, (op, 0)) self.tb.connect (src1, (op, 1)) @@ -53,12 +53,12 @@ class test_interleave (gr_unittest.TestCase): def test_deint_001 (self): lenx = 64 - src = gr.vector_source_f (range (lenx)) - op = blocks_swig.deinterleave (gr.sizeof_float) - dst0 = gr.vector_sink_f () - dst1 = gr.vector_sink_f () - dst2 = gr.vector_sink_f () - dst3 = gr.vector_sink_f () + src = blocks.vector_source_f (range (lenx)) + op = blocks.deinterleave (gr.sizeof_float) + dst0 = blocks.vector_sink_f () + dst1 = blocks.vector_sink_f () + dst2 = blocks.vector_sink_f () + dst3 = blocks.vector_sink_f () self.tb.connect (src, op) self.tb.connect ((op, 0), dst0) diff --git a/gr-blocks/python/qa_keep_m_in_n.py b/gr-blocks/python/qa_keep_m_in_n.py index 0898217ba9..22e8c45138 100755 --- a/gr-blocks/python/qa_keep_m_in_n.py +++ b/gr-blocks/python/qa_keep_m_in_n.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2008,2010,2012 Free Software Foundation, Inc. +# Copyright 2008,2010,2012,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -20,7 +20,7 @@ # from gnuradio import gr, gr_unittest -import blocks_swig +import blocks_swig as blocks import sys import random @@ -35,15 +35,15 @@ class test_keep_m_in_n(gr_unittest.TestCase): def test_001(self): self.maxDiff = None; tb = gr.top_block() - src = gr.vector_source_b( range(0,100) ) + src = blocks.vector_source_b( range(0,100) ) # itemsize, M, N, offset - km2 = blocks_swig.keep_m_in_n( 1, 1, 2, 0 ); - km3 = blocks_swig.keep_m_in_n( 1, 1, 3, 1 ); - km7 = blocks_swig.keep_m_in_n( 1, 1, 7, 2 ); - snk2 = gr.vector_sink_b(); - snk3 = gr.vector_sink_b(); - snk7 = gr.vector_sink_b(); + km2 = blocks.keep_m_in_n( 1, 1, 2, 0 ); + km3 = blocks.keep_m_in_n( 1, 1, 3, 1 ); + km7 = blocks.keep_m_in_n( 1, 1, 7, 2 ); + snk2 = blocks.vector_sink_b(); + snk3 = blocks.vector_sink_b(); + snk7 = blocks.vector_sink_b(); tb.connect(src,km2,snk2); tb.connect(src,km3,snk3); tb.connect(src,km7,snk7); diff --git a/gr-blocks/python/qa_keep_one_in_n.py b/gr-blocks/python/qa_keep_one_in_n.py index 8c5f44b84b..f06ed33d6b 100755 --- a/gr-blocks/python/qa_keep_one_in_n.py +++ b/gr-blocks/python/qa_keep_one_in_n.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2012 Free Software Foundation, Inc. +# Copyright 2012,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -21,7 +21,7 @@ # from gnuradio import gr, gr_unittest -import blocks_swig +import blocks_swig as blocks class test_keep_one_in_n(gr_unittest.TestCase): @@ -34,9 +34,9 @@ class test_keep_one_in_n(gr_unittest.TestCase): def test_001(self): src_data = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) expected_data = (5, 10) - src = gr.vector_source_b(src_data); - op = blocks_swig.keep_one_in_n(gr.sizeof_char, 5) - dst = gr.vector_sink_b() + src = blocks.vector_source_b(src_data); + op = blocks.keep_one_in_n(gr.sizeof_char, 5) + dst = blocks.vector_sink_b() self.tb.connect(src, op, dst) self.tb.run() self.assertEqual(dst.data(), expected_data) diff --git a/gr-blocks/python/qa_max.py b/gr-blocks/python/qa_max.py index 4af70bd4be..982f4b5590 100755 --- a/gr-blocks/python/qa_max.py +++ b/gr-blocks/python/qa_max.py @@ -36,10 +36,10 @@ class test_max(gr_unittest.TestCase): src_data = (0,0.2,-0.3,0,12,0) expected_result = (float(max(src_data)),) - src = gr.vector_source_f(src_data) + src = blocks.vector_source_f(src_data) s2v = blocks.stream_to_vector(gr.sizeof_float, len(src_data)) op = blocks.max_ff(len(src_data)) - dst = gr.vector_sink_f() + dst = blocks.vector_sink_f() self.tb.connect(src, s2v, op, dst) self.tb.run() @@ -50,10 +50,10 @@ class test_max(gr_unittest.TestCase): src_data=(-100,-99,-98,-97,-96,-1) expected_result = (float(max(src_data)),) - src = gr.vector_source_f(src_data) + src = blocks.vector_source_f(src_data) s2v = blocks.stream_to_vector(gr.sizeof_float, len(src_data)) op = blocks.max_ff(len(src_data)) - dst = gr.vector_sink_f() + dst = blocks.vector_sink_f() self.tb.connect(src, s2v, op, dst) self.tb.run() diff --git a/gr-blocks/python/qa_message.py b/gr-blocks/python/qa_message.py index a556f65cee..27cf186ed3 100755 --- a/gr-blocks/python/qa_message.py +++ b/gr-blocks/python/qa_message.py @@ -93,8 +93,8 @@ class test_message(gr_unittest.TestCase): def test_300(self): input_data = (0,1,2,3,4,5,6,7,8,9) - src = gr.vector_source_b(input_data) - dst = gr.vector_sink_b() + src = blocks.vector_source_b(input_data) + dst = blocks.vector_sink_b() tb = gr.top_block() tb.connect(src, dst) tb.run() @@ -103,7 +103,7 @@ class test_message(gr_unittest.TestCase): def test_301(self): # Use itemsize, limit constructor src = blocks.message_source(gr.sizeof_char) - dst = gr.vector_sink_b() + dst = blocks.vector_sink_b() tb = gr.top_block() tb.connect(src, dst) src.msgq().insert_tail(gr.message_from_string('01234')) @@ -118,7 +118,7 @@ class test_message(gr_unittest.TestCase): # Use itemsize, msgq constructor msgq = gr.msg_queue() src = blocks.message_source(gr.sizeof_char, msgq) - dst = gr.vector_sink_b() + dst = blocks.vector_sink_b() tb = gr.top_block() tb.connect(src, dst) src.msgq().insert_tail(gr.message_from_string('01234')) diff --git a/gr-blocks/python/qa_moving_average.py b/gr-blocks/python/qa_moving_average.py index 169b4746c2..d3fbdbbfdf 100644 --- a/gr-blocks/python/qa_moving_average.py +++ b/gr-blocks/python/qa_moving_average.py @@ -53,9 +53,9 @@ class test_moving_average(gr_unittest.TestCase): data = make_random_float_tuple(N, 1) expected_result = N*[0,] - src = gr.vector_source_f(data, False) + src = blocks.vector_source_f(data, False) op = blocks.moving_average_ff(100, 0.001) - dst = gr.vector_sink_f() + dst = blocks.vector_sink_f() tb.connect(src, op) tb.connect(op, dst) @@ -74,9 +74,9 @@ class test_moving_average(gr_unittest.TestCase): data = make_random_complex_tuple(N, 1) expected_result = N*[0,] - src = gr.vector_source_c(data, False) + src = blocks.vector_source_c(data, False) op = blocks.moving_average_cc(100, 0.001) - dst = gr.vector_sink_c() + dst = blocks.vector_sink_c() tb.connect(src, op) tb.connect(op, dst) diff --git a/gr-blocks/python/qa_multiply_conjugate.py b/gr-blocks/python/qa_multiply_conjugate.py index f51563f854..a18d80324c 100644 --- a/gr-blocks/python/qa_multiply_conjugate.py +++ b/gr-blocks/python/qa_multiply_conjugate.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2012 Free Software Foundation, Inc. +# Copyright 2012,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -21,7 +21,7 @@ # from gnuradio import gr, gr_unittest -import blocks_swig +import blocks_swig as blocks class test_multiply_conjugate (gr_unittest.TestCase): @@ -42,10 +42,10 @@ class test_multiply_conjugate (gr_unittest.TestCase): exp_data = (12+0j, 8+0j, 12+0j, 8+0j, 12+0j, 8+0j, 12+0j, 8+0j, 0+0j) - src0 = gr.vector_source_c(src_data0) - src1 = gr.vector_source_c(src_data1) - op = blocks_swig.multiply_conjugate_cc () - dst = gr.vector_sink_c () + src0 = blocks.vector_source_c(src_data0) + src1 = blocks.vector_source_c(src_data1) + op = blocks.multiply_conjugate_cc () + dst = blocks.vector_sink_c () self.tb.connect(src0, (op,0)) self.tb.connect(src1, (op,1)) diff --git a/gr-blocks/python/qa_mute.py b/gr-blocks/python/qa_mute.py index 96c57b2ed1..0c10846333 100755 --- a/gr-blocks/python/qa_mute.py +++ b/gr-blocks/python/qa_mute.py @@ -33,9 +33,9 @@ class test_mute(gr_unittest.TestCase): def help_ii(self, src_data, exp_data, op): for s in zip(range(len(src_data)), src_data): - src = gr.vector_source_i(s[1]) + src = blocks.vector_source_i(s[1]) self.tb.connect(src, (op, s[0])) - dst = gr.vector_sink_i() + dst = blocks.vector_sink_i() self.tb.connect(op, dst) self.tb.run() result_data = dst.data() @@ -43,9 +43,9 @@ class test_mute(gr_unittest.TestCase): def help_ff(self, src_data, exp_data, op): for s in zip(range(len(src_data)), src_data): - src = gr.vector_source_f(s[1]) + src = blocks.vector_source_f(s[1]) self.tb.connect(src, (op, s[0])) - dst = gr.vector_sink_f() + dst = blocks.vector_sink_f() self.tb.connect(op, dst) self.tb.run() result_data = dst.data() @@ -53,9 +53,9 @@ class test_mute(gr_unittest.TestCase): def help_cc(self, src_data, exp_data, op): for s in zip(range(len(src_data)), src_data): - src = gr.vector_source_c(s[1]) + src = blocks.vector_source_c(s[1]) self.tb.connect(src, (op, s[0])) - dst = gr.vector_sink_c() + dst = blocks.vector_sink_c() self.tb.connect(op, dst) self.tb.run() result_data = dst.data() diff --git a/gr-blocks/python/qa_nlog10.py b/gr-blocks/python/qa_nlog10.py index cc2a3e8cc5..a61313cacc 100755 --- a/gr-blocks/python/qa_nlog10.py +++ b/gr-blocks/python/qa_nlog10.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2005,2007,2010,2012 Free Software Foundation, Inc. +# Copyright 2005,2007,2010,2012,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -21,7 +21,7 @@ # from gnuradio import gr, gr_unittest -import blocks_swig +import blocks_swig as blocks class test_nlog10(gr_unittest.TestCase): @@ -34,9 +34,9 @@ class test_nlog10(gr_unittest.TestCase): def test_001(self): src_data = (-10, 0, 10, 100, 1000, 10000, 100000) expected_result = (-180, -180, 10, 20, 30, 40, 50) - src = gr.vector_source_f(src_data) - op = blocks_swig.nlog10_ff(10) - dst = gr.vector_sink_f() + src = blocks.vector_source_f(src_data) + op = blocks.nlog10_ff(10) + dst = blocks.vector_sink_f() self.tb.connect (src, op, dst) self.tb.run() result_data = dst.data() diff --git a/gnuradio-core/src/lib/gengen/generate_all.py b/gr-blocks/python/qa_null_sink_source.py index 6b0f20f058..60552cb207 100755..100644 --- a/gnuradio-core/src/lib/gengen/generate_all.py +++ b/gr-blocks/python/qa_null_sink_source.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2004 Free Software Foundation, Inc. +# Copyright 2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -20,14 +20,27 @@ # Boston, MA 02110-1301, USA. # -from build_utils import output_glue +from gnuradio import gr, gr_unittest +import blocks_swig as blocks +import math -import generate_common +class test_null_sink_source(gr_unittest.TestCase): -def generate_all (): - generate_common.generate () - output_glue ('gengen') + def setUp(self): + self.tb = gr.top_block() + def tearDown(self): + self.tb = None + + def test_001(self): + # Just running some data through null source/sink + src = blocks.null_source(gr.sizeof_float) + hed = blocks.head(gr.sizeof_float, 100) + dst = blocks.null_sink(gr.sizeof_float) + + self.tb.connect(src, hed, dst) + self.tb.run() if __name__ == '__main__': - generate_all () + gr_unittest.run(test_null_sink_source, "test_null_sink_source.xml") + diff --git a/gr-blocks/python/qa_pack_k_bits.py b/gr-blocks/python/qa_pack_k_bits.py index cd55d2f200..51152889f6 100755 --- a/gr-blocks/python/qa_pack_k_bits.py +++ b/gr-blocks/python/qa_pack_k_bits.py @@ -35,9 +35,9 @@ class test_pack(gr_unittest.TestCase): def test_001(self): src_data = (1,0,1,1,0,1,1,0) expected_results = (1,0,1,1,0,1,1,0) - src = gr.vector_source_b(src_data,False) + src = blocks.vector_source_b(src_data,False) op = blocks.pack_k_bits_bb(1) - dst = gr.vector_sink_b() + dst = blocks.vector_sink_b() self.tb.connect(src, op, dst) self.tb.run() self.assertEqual(expected_results, dst.data()) @@ -45,9 +45,9 @@ class test_pack(gr_unittest.TestCase): def test_002(self): src_data = (1,0,1,1,0,0,0,1) expected_results = ( 2, 3, 0, 1) - src = gr.vector_source_b(src_data,False) + src = blocks.vector_source_b(src_data,False) op = blocks.pack_k_bits_bb(2) - dst = gr.vector_sink_b() + dst = blocks.vector_sink_b() self.tb.connect(src, op, dst) self.tb.run() #self.assertEqual(expected_results, dst.data()) @@ -55,10 +55,10 @@ class test_pack(gr_unittest.TestCase): def test_003(self): src_data = expected_results = map(lambda x: random.randint(0,3), range(10)); - src = gr.vector_source_b( src_data ); + src = blocks.vector_source_b( src_data ); pack = blocks.pack_k_bits_bb(2); unpack = blocks.unpack_k_bits_bb(2); - snk = gr.vector_sink_b(); + snk = blocks.vector_sink_b(); self.tb.connect(src,unpack,pack,snk); self.tb.run() self.assertEqual(list(expected_results), list(snk.data())); diff --git a/gr-blocks/python/qa_packed_to_unpacked.py b/gr-blocks/python/qa_packed_to_unpacked.py index d84f5dbd37..23745d3859 100755 --- a/gr-blocks/python/qa_packed_to_unpacked.py +++ b/gr-blocks/python/qa_packed_to_unpacked.py @@ -35,9 +35,9 @@ class test_packing(gr_unittest.TestCase): def test_001(self): src_data = (0x80,) expected_results = (1,0,0,0,0,0,0,0) - src = gr.vector_source_b(src_data, False) + src = blocks.vector_source_b(src_data, False) op = blocks.packed_to_unpacked_bb(1, gr.GR_MSB_FIRST) - dst = gr.vector_sink_b() + dst = blocks.vector_sink_b() self.tb.connect(src, op) self.tb.connect(op, dst) @@ -48,9 +48,9 @@ class test_packing(gr_unittest.TestCase): def test_002(self): src_data = (0x80,) expected_results = (0,0,0,0,0,0,0,1) - src = gr.vector_source_b(src_data, False) + src = blocks.vector_source_b(src_data, False) op = blocks.packed_to_unpacked_bb(1, gr.GR_LSB_FIRST) - dst = gr.vector_sink_b() + dst = blocks.vector_sink_b() self.tb.connect(src, op) self.tb.connect(op, dst) @@ -61,9 +61,9 @@ class test_packing(gr_unittest.TestCase): def test_003(self): src_data = (0x11,) expected_results = (4, 2) - src = gr.vector_source_b(src_data, False) + src = blocks.vector_source_b(src_data, False) op = blocks.packed_to_unpacked_bb(3, gr.GR_LSB_FIRST) - dst = gr.vector_sink_b() + dst = blocks.vector_sink_b() self.tb.connect(src, op) self.tb.connect(op, dst) @@ -74,9 +74,9 @@ class test_packing(gr_unittest.TestCase): def test_004(self): src_data = (0x11,) expected_results = (0, 4) - src = gr.vector_source_b(src_data, False) + src = blocks.vector_source_b(src_data, False) op = blocks.packed_to_unpacked_bb(3, gr.GR_MSB_FIRST) - dst = gr.vector_sink_b() + dst = blocks.vector_sink_b() self.tb.connect(src, op) self.tb.connect(op, dst) @@ -87,9 +87,9 @@ class test_packing(gr_unittest.TestCase): def test_005(self): src_data = (1,0,0,0,0,0,1,0,0,1,0,1,1,0,1,0) expected_results = (0x82, 0x5a) - src = gr.vector_source_b(src_data, False) + src = blocks.vector_source_b(src_data, False) op = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST) - dst = gr.vector_sink_b() + dst = blocks.vector_sink_b() self.tb.connect(src, op) self.tb.connect(op, dst) @@ -100,9 +100,9 @@ class test_packing(gr_unittest.TestCase): def test_006(self): src_data = (0,1,0,0,0,0,0,1,0,1,0,1,1,0,1,0) expected_results = (0x82, 0x5a) - src = gr.vector_source_b(src_data, False) + src = blocks.vector_source_b(src_data, False) op = blocks.unpacked_to_packed_bb(1, gr.GR_LSB_FIRST) - dst = gr.vector_sink_b() + dst = blocks.vector_sink_b() self.tb.connect(src, op) self.tb.connect(op, dst) @@ -113,9 +113,9 @@ class test_packing(gr_unittest.TestCase): def test_007(self): src_data = (4, 2, 0,0,0) expected_results = (0x11,) - src = gr.vector_source_b(src_data, False) + src = blocks.vector_source_b(src_data, False) op = blocks.unpacked_to_packed_bb(3, gr.GR_LSB_FIRST) - dst = gr.vector_sink_b() + dst = blocks.vector_sink_b() self.tb.connect(src, op) self.tb.connect(op, dst) @@ -126,9 +126,9 @@ class test_packing(gr_unittest.TestCase): def test_008(self): src_data = (0, 4, 2,0,0) expected_results = (0x11,) - src = gr.vector_source_b(src_data,False) + src = blocks.vector_source_b(src_data,False) op = blocks.unpacked_to_packed_bb(3, gr.GR_MSB_FIRST) - dst = gr.vector_sink_b() + dst = blocks.vector_sink_b() self.tb.connect(src, op) self.tb.connect(op, dst) @@ -144,10 +144,10 @@ class test_packing(gr_unittest.TestCase): src_data = tuple(src_data) expected_results = src_data - src = gr.vector_source_b(tuple(src_data), False) + src = blocks.vector_source_b(tuple(src_data), False) op1 = blocks.packed_to_unpacked_bb(3, gr.GR_MSB_FIRST) op2 = blocks.unpacked_to_packed_bb(3, gr.GR_MSB_FIRST) - dst = gr.vector_sink_b() + dst = blocks.vector_sink_b() self.tb.connect(src, op1, op2) self.tb.connect(op2, dst) @@ -162,10 +162,10 @@ class test_packing(gr_unittest.TestCase): src_data.append((random.randint(0,255))) src_data = tuple(src_data) expected_results = src_data - src = gr.vector_source_b(tuple(src_data), False) + src = blocks.vector_source_b(tuple(src_data), False) op1 = blocks.packed_to_unpacked_bb(7, gr.GR_MSB_FIRST) op2 = blocks.unpacked_to_packed_bb(7, gr.GR_MSB_FIRST) - dst = gr.vector_sink_b() + dst = blocks.vector_sink_b() self.tb.connect(src, op1, op2) self.tb.connect(op2, dst) @@ -180,10 +180,10 @@ class test_packing(gr_unittest.TestCase): src_data.append((random.randint(0,255))) src_data = tuple(src_data) expected_results = src_data - src = gr.vector_source_b(tuple(src_data),False) + src = blocks.vector_source_b(tuple(src_data),False) op1 = blocks.packed_to_unpacked_bb(7, gr.GR_LSB_FIRST) op2 = blocks.unpacked_to_packed_bb(7, gr.GR_LSB_FIRST) - dst = gr.vector_sink_b() + dst = blocks.vector_sink_b() self.tb.connect(src, op1, op2) self.tb.connect(op2, dst) @@ -200,10 +200,10 @@ class test_packing(gr_unittest.TestCase): src_data.append((random.randint(-2**15,2**15-1))) src_data = tuple(src_data) expected_results = src_data - src = gr.vector_source_s(tuple(src_data), False) + src = blocks.vector_source_s(tuple(src_data), False) op1 = blocks.packed_to_unpacked_ss(1, gr.GR_MSB_FIRST) op2 = blocks.unpacked_to_packed_ss(1, gr.GR_MSB_FIRST) - dst = gr.vector_sink_s() + dst = blocks.vector_sink_s() self.tb.connect(src, op1, op2) self.tb.connect(op2, dst) @@ -218,10 +218,10 @@ class test_packing(gr_unittest.TestCase): src_data.append((random.randint(-2**15,2**15-1))) src_data = tuple(src_data) expected_results = src_data - src = gr.vector_source_s(tuple(src_data), False) + src = blocks.vector_source_s(tuple(src_data), False) op1 = blocks.packed_to_unpacked_ss(1, gr.GR_LSB_FIRST) op2 = blocks.unpacked_to_packed_ss(1, gr.GR_LSB_FIRST) - dst = gr.vector_sink_s() + dst = blocks.vector_sink_s() self.tb.connect(src, op1, op2) self.tb.connect(op2, dst) @@ -236,10 +236,10 @@ class test_packing(gr_unittest.TestCase): src_data.append((random.randint(-2**15,2**15-1))) src_data = tuple(src_data) expected_results = src_data - src = gr.vector_source_s(tuple(src_data), False) + src = blocks.vector_source_s(tuple(src_data), False) op1 = blocks.packed_to_unpacked_ss(8, gr.GR_MSB_FIRST) op2 = blocks.unpacked_to_packed_ss(8, gr.GR_MSB_FIRST) - dst = gr.vector_sink_s() + dst = blocks.vector_sink_s() self.tb.connect(src, op1, op2) self.tb.connect(op2, dst) @@ -254,10 +254,10 @@ class test_packing(gr_unittest.TestCase): src_data.append((random.randint(-2**15,2**15-1))) src_data = tuple(src_data) expected_results = src_data - src = gr.vector_source_s(tuple(src_data), False) + src = blocks.vector_source_s(tuple(src_data), False) op1 = blocks.packed_to_unpacked_ss(8, gr.GR_LSB_FIRST) op2 = blocks.unpacked_to_packed_ss(8, gr.GR_LSB_FIRST) - dst = gr.vector_sink_s() + dst = blocks.vector_sink_s() self.tb.connect(src, op1, op2) self.tb.connect(op2, dst) @@ -274,10 +274,10 @@ class test_packing(gr_unittest.TestCase): src_data.append((random.randint(-2**31,2**31-1))) src_data = tuple(src_data) expected_results = src_data - src = gr.vector_source_i(tuple(src_data), False) + src = blocks.vector_source_i(tuple(src_data), False) op1 = blocks.packed_to_unpacked_ii(1, gr.GR_MSB_FIRST) op2 = blocks.unpacked_to_packed_ii(1, gr.GR_MSB_FIRST) - dst = gr.vector_sink_i() + dst = blocks.vector_sink_i() self.tb.connect(src, op1, op2) self.tb.connect(op2, dst) @@ -292,10 +292,10 @@ class test_packing(gr_unittest.TestCase): src_data.append((random.randint(-2**31,2**31-1))) src_data = tuple(src_data) expected_results = src_data - src = gr.vector_source_i(tuple(src_data), False) + src = blocks.vector_source_i(tuple(src_data), False) op1 = blocks.packed_to_unpacked_ii(1, gr.GR_LSB_FIRST) op2 = blocks.unpacked_to_packed_ii(1, gr.GR_LSB_FIRST) - dst = gr.vector_sink_i() + dst = blocks.vector_sink_i() self.tb.connect(src, op1, op2) self.tb.connect(op2, dst) @@ -310,10 +310,10 @@ class test_packing(gr_unittest.TestCase): src_data.append((random.randint(-2**31,2**31-1))) src_data = tuple(src_data) expected_results = src_data - src = gr.vector_source_i(tuple(src_data), False) + src = blocks.vector_source_i(tuple(src_data), False) op1 = blocks.packed_to_unpacked_ii(8, gr.GR_MSB_FIRST) op2 = blocks.unpacked_to_packed_ii(8, gr.GR_MSB_FIRST) - dst = gr.vector_sink_i() + dst = blocks.vector_sink_i() self.tb.connect(src, op1, op2) self.tb.connect(op2, dst) @@ -328,10 +328,10 @@ class test_packing(gr_unittest.TestCase): src_data.append((random.randint(-2**31,2**31-1))) src_data = tuple(src_data) expected_results = src_data - src = gr.vector_source_i(tuple(src_data), False) + src = blocks.vector_source_i(tuple(src_data), False) op1 = blocks.packed_to_unpacked_ii(8, gr.GR_LSB_FIRST) op2 = blocks.unpacked_to_packed_ii(8, gr.GR_LSB_FIRST) - dst = gr.vector_sink_i() + dst = blocks.vector_sink_i() self.tb.connect(src, op1, op2) self.tb.connect(op2, dst) diff --git a/gr-blocks/python/qa_patterned_interleaver.py b/gr-blocks/python/qa_patterned_interleaver.py index 3cf29c9178..c960ac2e66 100755 --- a/gr-blocks/python/qa_patterned_interleaver.py +++ b/gr-blocks/python/qa_patterned_interleaver.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2008,2010 Free Software Foundation, Inc. +# Copyright 2008,2010,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -37,12 +37,12 @@ class test_patterned_interleaver (gr_unittest.TestCase): def test_000(self): dst_data = [0,0,1,2,0,2,1,0]; - src0 = gr.vector_source_f(200*[0]) - src1 = gr.vector_source_f(200*[1]) - src2 = gr.vector_source_f(200*[2]) + src0 = blocks.vector_source_f(200*[0]) + src1 = blocks.vector_source_f(200*[1]) + src2 = blocks.vector_source_f(200*[2]) itg = blocks.patterned_interleaver(gr.sizeof_float, dst_data) - dst = gr.vector_sink_f() - head = gr.head(gr.sizeof_float, 8); + dst = blocks.vector_sink_f() + head = blocks.head(gr.sizeof_float, 8); self.tb.connect( src0, (itg,0) ); self.tb.connect( src1, (itg,1) ); diff --git a/gr-blocks/python/qa_pdu.py b/gr-blocks/python/qa_pdu.py index c8fc0e5a91..a9d8ea86f3 100755 --- a/gr-blocks/python/qa_pdu.py +++ b/gr-blocks/python/qa_pdu.py @@ -39,7 +39,7 @@ class test_pdu(gr_unittest.TestCase): src = blocks.pdu_to_tagged_stream(blocks.byte_t) snk3 = blocks.tagged_stream_to_pdu(blocks.byte_t) - snk2 = gr.vector_sink_b() + snk2 = blocks.vector_sink_b() snk = blocks.tag_debug(1, "test") snk.set_display(False) diff --git a/gr-blocks/python/qa_peak_detector.py b/gr-blocks/python/qa_peak_detector.py index c3ff2548c4..4b28518410 100644 --- a/gr-blocks/python/qa_peak_detector.py +++ b/gr-blocks/python/qa_peak_detector.py @@ -40,9 +40,9 @@ class test_peak_detector(gr_unittest.TestCase): expected_result = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) - src = gr.vector_source_f(data, False) + src = blocks.vector_source_f(data, False) regen = blocks.peak_detector_fb() - dst = gr.vector_sink_b() + dst = blocks.vector_sink_b() tb.connect(src, regen) tb.connect(regen, dst) @@ -61,9 +61,9 @@ class test_peak_detector(gr_unittest.TestCase): expected_result = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) - src = gr.vector_source_i(data, False) + src = blocks.vector_source_i(data, False) regen = blocks.peak_detector_ib() - dst = gr.vector_sink_b() + dst = blocks.vector_sink_b() tb.connect(src, regen) tb.connect(regen, dst) @@ -82,9 +82,9 @@ class test_peak_detector(gr_unittest.TestCase): expected_result = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) - src = gr.vector_source_s(data, False) + src = blocks.vector_source_s(data, False) regen = blocks.peak_detector_sb() - dst = gr.vector_sink_b() + dst = blocks.vector_sink_b() tb.connect(src, regen) tb.connect(regen, dst) diff --git a/gr-blocks/python/qa_peak_detector2.py b/gr-blocks/python/qa_peak_detector2.py index b2d8e318dd..5fcda9be08 100644 --- a/gr-blocks/python/qa_peak_detector2.py +++ b/gr-blocks/python/qa_peak_detector2.py @@ -41,9 +41,9 @@ class test_peak_detector2(gr_unittest.TestCase): 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) - src = gr.vector_source_f(data, False) + src = blocks.vector_source_f(data, False) regen = blocks.peak_detector2_fb() - dst = gr.vector_sink_b() + dst = blocks.vector_sink_b() tb.connect(src, regen) tb.connect(regen, dst) diff --git a/gr-blocks/python/qa_pipe_fittings.py b/gr-blocks/python/qa_pipe_fittings.py index 9894a5c211..634638dcdd 100755 --- a/gr-blocks/python/qa_pipe_fittings.py +++ b/gr-blocks/python/qa_pipe_fittings.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2005,2007,2010,2012 Free Software Foundation, Inc. +# Copyright 2005,2007,2010,2012,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -50,13 +50,13 @@ class test_pipe_fittings(gr_unittest.TestCase): expected_results = calc_expected_result(src_data, n) #print "expected results: ", expected_results - src = gr.vector_source_i(src_data) + src = blocks.vector_source_i(src_data) op = blocks.stream_to_streams(gr.sizeof_int, n) self.tb.connect(src, op) dsts = [] for i in range(n): - dst = gr.vector_sink_i() + dst = blocks.vector_sink_i() self.tb.connect((op, i), (dst, 0)) dsts.append(dst) @@ -74,10 +74,10 @@ class test_pipe_fittings(gr_unittest.TestCase): src_data = tuple(range(src_len)) expected_results = src_data - src = gr.vector_source_i(src_data) + src = blocks.vector_source_i(src_data) op1 = blocks.stream_to_streams(gr.sizeof_int, n) op2 = blocks.streams_to_stream(gr.sizeof_int, n) - dst = gr.vector_sink_i() + dst = blocks.vector_sink_i() self.tb.connect(src, op1) for i in range(n): @@ -96,11 +96,11 @@ class test_pipe_fittings(gr_unittest.TestCase): src_data = tuple(range(src_len)) expected_results = src_data - src = gr.vector_source_i(src_data) + src = blocks.vector_source_i(src_data) op1 = blocks.stream_to_streams(gr.sizeof_int, n) op2 = blocks.streams_to_vector(gr.sizeof_int, n) op3 = blocks.vector_to_stream(gr.sizeof_int, n) - dst = gr.vector_sink_i() + dst = blocks.vector_sink_i() self.tb.connect(src, op1) for i in range(n): @@ -119,11 +119,11 @@ class test_pipe_fittings(gr_unittest.TestCase): src_data = tuple(range(src_len)) expected_results = src_data - src = gr.vector_source_i(src_data) + src = blocks.vector_source_i(src_data) op1 = blocks.stream_to_vector(gr.sizeof_int, n) op2 = blocks.vector_to_streams(gr.sizeof_int, n) op3 = blocks.streams_to_stream(gr.sizeof_int, n) - dst = gr.vector_sink_i() + dst = blocks.vector_sink_i() self.tb.connect(src, op1, op2) for i in range(n): diff --git a/gr-blocks/python/qa_probe_signal.py b/gr-blocks/python/qa_probe_signal.py index 6d25a25087..1cb151bfc0 100644 --- a/gr-blocks/python/qa_probe_signal.py +++ b/gr-blocks/python/qa_probe_signal.py @@ -36,7 +36,7 @@ class test_probe_signal(gr_unittest.TestCase): repeats = 100 src_data = [value] * repeats - src = gr.vector_source_f(src_data) + src = blocks.vector_source_f(src_data) dst = blocks.probe_signal_f() self.tb.connect(src, dst) @@ -50,7 +50,7 @@ class test_probe_signal(gr_unittest.TestCase): value = [0.5+i for i in range(0, vector_length)] src_data = value * repeats - src = gr.vector_source_f(src_data) + src = blocks.vector_source_f(src_data) s2v = blocks.stream_to_vector(gr.sizeof_float, vector_length) dst = blocks.probe_signal_vf(vector_length) diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_python_message_passing.py b/gr-blocks/python/qa_python_message_passing.py index 51f8ede4db..f199d5470f 100644 --- a/gnuradio-core/src/python/gnuradio/gr/qa_python_message_passing.py +++ b/gr-blocks/python/qa_python_message_passing.py @@ -25,6 +25,7 @@ try: import pmt except: from gruel import pmt import numpy import time +import blocks_swig as blocks # Simple block to generate messages class message_generator(gr.sync_block): @@ -88,7 +89,7 @@ class test_python_message_passing(gr_unittest.TestCase): src_data = [] for i in range(num_msgs*msg_interval): src_data.append(float(i)) - src = gr.vector_source_f(src_data, False) + src = blocks.vector_source_f(src_data, False) msg_gen = message_generator(msg_list, msg_interval) msg_cons = message_consumer() diff --git a/gr-blocks/python/qa_regenerate.py b/gr-blocks/python/qa_regenerate.py index a57eeba2bb..0be68d001c 100755 --- a/gr-blocks/python/qa_regenerate.py +++ b/gr-blocks/python/qa_regenerate.py @@ -43,9 +43,9 @@ class test_regenerate(gr_unittest.TestCase): 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) - src = gr.vector_source_b(data, False) + src = blocks.vector_source_b(data, False) regen = blocks.regenerate_bb(5, 2) - dst = gr.vector_sink_b() + dst = blocks.vector_sink_b() tb.connect(src, regen) tb.connect(regen, dst) @@ -73,9 +73,9 @@ class test_regenerate(gr_unittest.TestCase): expected_result[119] = 1 expected_result[129] = 1 - src = gr.vector_source_b(data, False) + src = blocks.vector_source_b(data, False) regen = blocks.regenerate_bb(10, 3) - dst = gr.vector_sink_b() + dst = blocks.vector_sink_b() tb.connect(src, regen) tb.connect(regen, dst) diff --git a/gr-blocks/python/qa_repack_bits_bb.py b/gr-blocks/python/qa_repack_bits_bb.py index 3f88df4a68..9da6cf26c6 100755 --- a/gr-blocks/python/qa_repack_bits_bb.py +++ b/gr-blocks/python/qa_repack_bits_bb.py @@ -39,9 +39,9 @@ class qa_repack_bits_bb (gr_unittest.TestCase): expected_data = (0b1, 0b1, 0b1, 0b0, 0b0, 0b1) k = 2 l = 1 - src = gr.vector_source_b(src_data, False, 1) + src = blocks.vector_source_b(src_data, False, 1) repack = blocks.repack_bits_bb(k, l) - sink = gr.vector_sink_b() + sink = blocks.vector_sink_b() self.tb.connect(src, repack, sink) self.tb.run () self.assertEqual(sink.data(), expected_data) @@ -52,9 +52,9 @@ class qa_repack_bits_bb (gr_unittest.TestCase): expected_data = (0b101,) + (0b111,) * 7 k = 8 l = 3 - src = gr.vector_source_b(src_data, False, 1) + src = blocks.vector_source_b(src_data, False, 1) repack = blocks.repack_bits_bb(k, l) - sink = gr.vector_sink_b() + sink = blocks.vector_sink_b() self.tb.connect(src, repack, sink) self.tb.run () self.assertEqual(sink.data(), expected_data) @@ -62,12 +62,12 @@ class qa_repack_bits_bb (gr_unittest.TestCase): def test_003_lots_of_bytes (self): """ Lots and lots of bytes, multiple packer stages """ src_data = tuple([random.randint(0, 255) for x in range(3*5*7*8 * 10)]) - src = gr.vector_source_b(src_data, False, 1) + src = blocks.vector_source_b(src_data, False, 1) repack1 = blocks.repack_bits_bb(8, 3) repack2 = blocks.repack_bits_bb(3, 5) repack3 = blocks.repack_bits_bb(5, 7) repack4 = blocks.repack_bits_bb(7, 8) - sink = gr.vector_sink_b() + sink = blocks.vector_sink_b() self.tb.connect(src, repack1, repack2, repack3, repack4, sink) self.tb.run () self.assertEqual(sink.data(), src_data) @@ -83,9 +83,9 @@ class qa_repack_bits_bb (gr_unittest.TestCase): tag.offset = 0 tag.key = pmt.string_to_symbol(tag_name) tag.value = pmt.from_long(len(src_data)) - src = gr.vector_source_b(src_data, False, 1, (tag,)) + src = blocks.vector_source_b(src_data, False, 1, (tag,)) repack = blocks.repack_bits_bb(k, l, tag_name) - sink = gr.vector_sink_b() + sink = blocks.vector_sink_b() self.tb.connect(src, repack, sink) self.tb.run () self.assertEqual(sink.data(), expected_data) @@ -108,9 +108,9 @@ class qa_repack_bits_bb (gr_unittest.TestCase): tag.offset = 0 tag.key = pmt.string_to_symbol(tag_name) tag.value = pmt.from_long(len(src_data)) - src = gr.vector_source_b(src_data, False, 1, (tag,)) + src = blocks.vector_source_b(src_data, False, 1, (tag,)) repack = blocks.repack_bits_bb(k, l, tag_name, True) - sink = gr.vector_sink_b() + sink = blocks.vector_sink_b() self.tb.connect(src, repack, sink) self.tb.run () self.assertEqual(sink.data(), expected_data) diff --git a/gr-blocks/python/qa_repeat.py b/gr-blocks/python/qa_repeat.py index 69fb3ef72d..aa1b1f45f1 100755 --- a/gr-blocks/python/qa_repeat.py +++ b/gr-blocks/python/qa_repeat.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2008,2010,2012 Free Software Foundation, Inc. +# Copyright 2008,2010,2012,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -21,7 +21,7 @@ # from gnuradio import gr, gr_unittest -import blocks_swig +import blocks_swig as blocks import math class test_repeat (gr_unittest.TestCase): @@ -38,9 +38,9 @@ class test_repeat (gr_unittest.TestCase): for n in range(100): dst_data += [1.0*n, 1.0*n, 1.0*n] - src = gr.vector_source_f(src_data) - rpt = blocks_swig.repeat(gr.sizeof_float, 3) - dst = gr.vector_sink_f() + src = blocks.vector_source_f(src_data) + rpt = blocks.repeat(gr.sizeof_float, 3) + dst = blocks.vector_sink_f() self.tb.connect(src, rpt, dst) self.tb.run() self.assertFloatTuplesAlmostEqual(dst_data, dst.data(), 6) diff --git a/gr-blocks/python/qa_rms.py b/gr-blocks/python/qa_rms.py index f3386668af..3dac70c1ec 100644 --- a/gr-blocks/python/qa_rms.py +++ b/gr-blocks/python/qa_rms.py @@ -50,10 +50,10 @@ class test_rms(gr_unittest.TestCase): expected_data = amp/math.sqrt(2.0) - src = gr.vector_source_f(src_data, True) - head = gr.head(gr.sizeof_float, N) + src = blocks.vector_source_f(src_data, True) + head = blocks.head(gr.sizeof_float, N) op = blocks.rms_ff(0.0001) - dst = gr.vector_sink_f() + dst = blocks.vector_sink_f() self.tb.connect(src, head, op, dst) self.tb.run() @@ -68,10 +68,10 @@ class test_rms(gr_unittest.TestCase): expected_data = amp - src = gr.vector_source_c(src_data, True) - head = gr.head(gr.sizeof_gr_complex, N) + src = blocks.vector_source_c(src_data, True) + head = blocks.head(gr.sizeof_gr_complex, N) op = blocks.rms_cf(0.0001) - dst = gr.vector_sink_f() + dst = blocks.vector_sink_f() self.tb.connect(src, head, op, dst) self.tb.run() diff --git a/gr-blocks/python/qa_sample_and_hold.py b/gr-blocks/python/qa_sample_and_hold.py index 59628090d1..87d472a038 100644 --- a/gr-blocks/python/qa_sample_and_hold.py +++ b/gr-blocks/python/qa_sample_and_hold.py @@ -37,10 +37,10 @@ class test_sample_and_hold(gr_unittest.TestCase): ctrl_data = 10*[1,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0,0,0] expected_result = 10*(0,0,0,0,4,5,6,7,8,9,9,9,9,9,9,9,9,9) - src = gr.vector_source_f(src_data) - ctrl = gr.vector_source_b(ctrl_data) + src = blocks.vector_source_f(src_data) + ctrl = blocks.vector_source_b(ctrl_data) op = blocks.sample_and_hold_ff() - dst = gr.vector_sink_f() + dst = blocks.vector_sink_f() self.tb.connect(src, (op,0)) self.tb.connect(ctrl, (op,1)) diff --git a/gr-blocks/python/qa_skiphead.py b/gr-blocks/python/qa_skiphead.py new file mode 100755 index 0000000000..50a9bbc639 --- /dev/null +++ b/gr-blocks/python/qa_skiphead.py @@ -0,0 +1,103 @@ +#!/usr/bin/env python +# +# Copyright 2007,2010,2013 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +from gnuradio import gr, gr_unittest +import blocks_swig as blocks + +class test_skiphead(gr_unittest.TestCase): + + def setUp(self): + self.tb = gr.top_block() + self.src_data = [int(x) for x in range(65536)] + + def tearDown(self): + self.tb = None + + def test_skip_0(self): + skip_cnt = 0 + expected_result = tuple(self.src_data[skip_cnt:]) + src1 = blocks.vector_source_i(self.src_data) + op = blocks.skiphead(gr.sizeof_int, skip_cnt) + dst1 = blocks.vector_sink_i() + self.tb.connect(src1, op, dst1) + self.tb.run() + dst_data = dst1.data() + self.assertEqual(expected_result, dst_data) + + def test_skip_1(self): + skip_cnt = 1 + expected_result = tuple(self.src_data[skip_cnt:]) + src1 = blocks.vector_source_i(self.src_data) + op = blocks.skiphead(gr.sizeof_int, skip_cnt) + dst1 = blocks.vector_sink_i() + self.tb.connect(src1, op, dst1) + self.tb.run() + dst_data = dst1.data() + self.assertEqual(expected_result, dst_data) + + def test_skip_1023(self): + skip_cnt = 1023 + expected_result = tuple(self.src_data[skip_cnt:]) + src1 = blocks.vector_source_i(self.src_data) + op = blocks.skiphead(gr.sizeof_int, skip_cnt) + dst1 = blocks.vector_sink_i() + self.tb.connect(src1, op, dst1) + self.tb.run() + dst_data = dst1.data() + self.assertEqual(expected_result, dst_data) + + def test_skip_6339(self): + skip_cnt = 6339 + expected_result = tuple(self.src_data[skip_cnt:]) + src1 = blocks.vector_source_i(self.src_data) + op = blocks.skiphead(gr.sizeof_int, skip_cnt) + dst1 = blocks.vector_sink_i() + self.tb.connect(src1, op, dst1) + self.tb.run() + dst_data = dst1.data() + self.assertEqual(expected_result, dst_data) + + def test_skip_12678(self): + skip_cnt = 12678 + expected_result = tuple(self.src_data[skip_cnt:]) + src1 = blocks.vector_source_i(self.src_data) + op = blocks.skiphead(gr.sizeof_int, skip_cnt) + dst1 = blocks.vector_sink_i() + self.tb.connect(src1, op, dst1) + self.tb.run() + dst_data = dst1.data() + self.assertEqual(expected_result, dst_data) + + def test_skip_all(self): + skip_cnt = len(self.src_data) + expected_result = tuple(self.src_data[skip_cnt:]) + src1 = blocks.vector_source_i(self.src_data) + op = blocks.skiphead(gr.sizeof_int, skip_cnt) + dst1 = blocks.vector_sink_i() + self.tb.connect(src1, op, dst1) + self.tb.run() + dst_data = dst1.data() + self.assertEqual(expected_result, dst_data) + + +if __name__ == '__main__': + gr_unittest.run(test_skiphead, "test_skiphead.xml") diff --git a/gr-blocks/python/qa_stream_mux.py b/gr-blocks/python/qa_stream_mux.py index 657bd3d63f..a5004dd8da 100755 --- a/gr-blocks/python/qa_stream_mux.py +++ b/gr-blocks/python/qa_stream_mux.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2004,2005,2007,2010,2012 Free Software Foundation, Inc. +# Copyright 2004,2005,2007,2010,2012,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -21,7 +21,7 @@ # from gnuradio import gr, gr_unittest -import blocks_swig +import blocks_swig as blocks import os class test_stream_mux (gr_unittest.TestCase): @@ -34,12 +34,12 @@ class test_stream_mux (gr_unittest.TestCase): self.tb = None def help_stream_2ff(self, N, stream_sizes): - v0 = gr.vector_source_f(N*[1,], False) - v1 = gr.vector_source_f(N*[2,], False) + v0 = blocks.vector_source_f(N*[1,], False) + v1 = blocks.vector_source_f(N*[2,], False) - mux = blocks_swig.stream_mux(gr.sizeof_float, stream_sizes) + mux = blocks.stream_mux(gr.sizeof_float, stream_sizes) - dst = gr.vector_sink_f () + dst = blocks.vector_sink_f () self.tb.connect (v0, (mux,0)) self.tb.connect (v1, (mux,1)) @@ -53,12 +53,12 @@ class test_stream_mux (gr_unittest.TestCase): r2 = range(N) r2.reverse() - v0 = gr.vector_source_f(r1, False) - v1 = gr.vector_source_f(r2, False) + v0 = blocks.vector_source_f(r1, False) + v1 = blocks.vector_source_f(r2, False) - mux = blocks_swig.stream_mux(gr.sizeof_float, stream_sizes) + mux = blocks.stream_mux(gr.sizeof_float, stream_sizes) - dst = gr.vector_sink_f () + dst = blocks.vector_sink_f () self.tb.connect (v0, (mux,0)) self.tb.connect (v1, (mux,1)) diff --git a/gr-blocks/python/qa_stretch.py b/gr-blocks/python/qa_stretch.py index 078b404dbf..94bb6e0353 100755 --- a/gr-blocks/python/qa_stretch.py +++ b/gr-blocks/python/qa_stretch.py @@ -41,13 +41,13 @@ class test_stretch(gr_unittest.TestCase): expected_result0 = 10*[0.05,] expected_result1 = 10*[0.1,] - src0 = gr.vector_source_f(data0, False) - src1 = gr.vector_source_f(data1, False) + src0 = blocks.vector_source_f(data0, False) + src1 = blocks.vector_source_f(data1, False) inter = blocks.streams_to_vector(gr.sizeof_float, 2) op = blocks.stretch_ff(0.1, 2) deinter = blocks.vector_to_streams(gr.sizeof_float, 2) - dst0 = gr.vector_sink_f() - dst1 = gr.vector_sink_f() + dst0 = blocks.vector_sink_f() + dst1 = blocks.vector_sink_f() tb.connect(src0, (inter,0)) tb.connect(src1, (inter,1)) diff --git a/gr-blocks/python/qa_tag_debug.py b/gr-blocks/python/qa_tag_debug.py index ad85daebcc..52864d34fb 100755 --- a/gr-blocks/python/qa_tag_debug.py +++ b/gr-blocks/python/qa_tag_debug.py @@ -34,7 +34,7 @@ class test_tag_debug(gr_unittest.TestCase): def test_001(self): # Just run some data through and make sure it doesn't puke. src_data = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) - src = gr.vector_source_i(src_data) + src = blocks.vector_source_i(src_data) op = blocks.tag_debug(gr.sizeof_int, "tag QA") self.tb.connect(src, op) self.tb.run() diff --git a/gr-blocks/python/qa_tag_file_sink.py b/gr-blocks/python/qa_tag_file_sink.py index 80e41a7dd0..e41e6544fd 100644 --- a/gr-blocks/python/qa_tag_file_sink.py +++ b/gr-blocks/python/qa_tag_file_sink.py @@ -35,8 +35,8 @@ class test_tag_file_sink(gr_unittest.TestCase): def test_001(self): src_data = ( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10) trg_data = (-1, -1, 1, 1, -1, -1, 1, 1, -1, -1) - src = gr.vector_source_i(src_data) - trg = gr.vector_source_s(trg_data) + src = blocks.vector_source_i(src_data) + trg = blocks.vector_source_s(trg_data) op = blocks.burst_tagger(gr.sizeof_int) snk = blocks.tagged_file_sink(gr.sizeof_int, 1) self.tb.connect(src, (op,0)) diff --git a/gr-blocks/python/qa_tagged_stream_mux.py b/gr-blocks/python/qa_tagged_stream_mux.py index e39f8cac29..1759c44623 100755 --- a/gr-blocks/python/qa_tagged_stream_mux.py +++ b/gr-blocks/python/qa_tagged_stream_mux.py @@ -82,10 +82,10 @@ class qa_tagged_stream_mux (gr_unittest.TestCase): test_tag_1.offset = 3 # On the first '3' of the 2nd stream test_tag_1.value = pmt.to_pmt(23) - src0 = gr.vector_source_b(datas[0:9], False, 1, len_tags_0 + (test_tag_0,)) - src1 = gr.vector_source_b(datas[9:], False, 1, len_tags_1 + (test_tag_1,)) + src0 = blocks.vector_source_b(datas[0:9], False, 1, len_tags_0 + (test_tag_0,)) + src1 = blocks.vector_source_b(datas[9:], False, 1, len_tags_1 + (test_tag_1,)) tagged_stream_mux = blocks.tagged_stream_mux(gr.sizeof_char, tagname) - snk = gr.vector_sink_b() + snk = blocks.vector_sink_b() self.tb.connect(src0, (tagged_stream_mux, 0)) self.tb.connect(src1, (tagged_stream_mux, 1)) self.tb.connect(tagged_stream_mux, snk) diff --git a/gr-blocks/python/qa_threshold.py b/gr-blocks/python/qa_threshold.py index f91af739ad..352a14da9e 100644 --- a/gr-blocks/python/qa_threshold.py +++ b/gr-blocks/python/qa_threshold.py @@ -38,9 +38,9 @@ class test_threshold(gr_unittest.TestCase): expected_result = (0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1) - src = gr.vector_source_f(data, False) + src = blocks.vector_source_f(data, False) op = blocks.threshold_ff(1, 1) - dst = gr.vector_sink_f() + dst = blocks.vector_sink_f() tb.connect(src, op) tb.connect(op, dst) diff --git a/gr-blocks/python/qa_transcendental.py b/gr-blocks/python/qa_transcendental.py index 8174f79630..b57b0b4430 100644 --- a/gr-blocks/python/qa_transcendental.py +++ b/gr-blocks/python/qa_transcendental.py @@ -38,9 +38,9 @@ class test_transcendental(gr_unittest.TestCase): data = 100*[0,] expected_result = 100*[1,] - src = gr.vector_source_f(data, False) + src = blocks.vector_source_f(data, False) op = blocks.transcendental("cos", "float") - dst = gr.vector_sink_f() + dst = blocks.vector_sink_f() tb.connect(src, op) tb.connect(op, dst) @@ -56,9 +56,9 @@ class test_transcendental(gr_unittest.TestCase): data = 100*[3,] expected_result = 100*[math.log10(3),] - src = gr.vector_source_f(data, False) + src = blocks.vector_source_f(data, False) op = blocks.transcendental("log10", "float") - dst = gr.vector_sink_f() + dst = blocks.vector_sink_f() tb.connect(src, op) tb.connect(op, dst) @@ -74,9 +74,9 @@ class test_transcendental(gr_unittest.TestCase): data = 100*[3,] expected_result = 100*[math.tanh(3),] - src = gr.vector_source_f(data, False) + src = blocks.vector_source_f(data, False) op = blocks.transcendental("tanh", "float") - dst = gr.vector_sink_f() + dst = blocks.vector_sink_f() tb.connect(src, op) tb.connect(op, dst) diff --git a/gr-blocks/python/qa_type_conversions.py b/gr-blocks/python/qa_type_conversions.py index eb1b42b636..548ab33926 100755 --- a/gr-blocks/python/qa_type_conversions.py +++ b/gr-blocks/python/qa_type_conversions.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2012 Free Software Foundation, Inc. +# Copyright 2012,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -21,7 +21,7 @@ # from gnuradio import gr, gr_unittest -import blocks_swig +import blocks_swig as blocks from math import sqrt, atan2 class test_type_conversions(gr_unittest.TestCase): @@ -35,9 +35,9 @@ class test_type_conversions(gr_unittest.TestCase): def test_char_to_float_identity(self): src_data = (1, 2, 3, 4, 5) expected_data = (1.0, 2.0, 3.0, 4.0, 5.0) - src = gr.vector_source_b(src_data) - op = blocks_swig.char_to_float() - dst = gr.vector_sink_f() + src = blocks.vector_source_b(src_data) + op = blocks.char_to_float() + dst = blocks.vector_sink_f() self.tb.connect(src, op, dst) self.tb.run() self.assertFloatTuplesAlmostEqual(expected_data, dst.data()) @@ -45,9 +45,9 @@ class test_type_conversions(gr_unittest.TestCase): def test_char_to_float_scale(self): src_data = (1, 2, 3, 4, 5) expected_data = (0.5, 1.0, 1.5, 2.0, 2.5) - src = gr.vector_source_b(src_data) - op = blocks_swig.char_to_float(scale=2.0) - dst = gr.vector_sink_f() + src = blocks.vector_source_b(src_data) + op = blocks.char_to_float(scale=2.0) + dst = blocks.vector_sink_f() self.tb.connect(src, op, dst) self.tb.run() self.assertFloatTuplesAlmostEqual(expected_data, dst.data()) @@ -55,9 +55,9 @@ class test_type_conversions(gr_unittest.TestCase): def test_char_to_short(self): src_data = (1, 2, 3, 4, 5) expected_data = (256, 512, 768, 1024, 1280) - src = gr.vector_source_b(src_data) - op = blocks_swig.char_to_short() - dst = gr.vector_sink_s() + src = blocks.vector_source_b(src_data) + op = blocks.char_to_short() + dst = blocks.vector_sink_s() self.tb.connect(src, op, dst) self.tb.run() self.assertEqual(expected_data, dst.data()) @@ -65,9 +65,9 @@ class test_type_conversions(gr_unittest.TestCase): def test_complex_to_interleaved_short(self): src_data = (1+2j, 3+4j, 5+6j, 7+8j, 9+10j) expected_data = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) - src = gr.vector_source_c(src_data) - op = blocks_swig.complex_to_interleaved_short() - dst = gr.vector_sink_s() + src = blocks.vector_source_c(src_data) + op = blocks.complex_to_interleaved_short() + dst = blocks.vector_sink_s() self.tb.connect(src, op, dst) self.tb.run() self.assertEqual(expected_data, dst.data()) @@ -75,9 +75,9 @@ class test_type_conversions(gr_unittest.TestCase): def test_complex_to_float_1(self): src_data = (1+2j, 3+4j, 5+6j, 7+8j, 9+10j) expected_data = (1.0, 3.0, 5.0, 7.0, 9.0) - src = gr.vector_source_c(src_data) - op = blocks_swig.complex_to_float() - dst = gr.vector_sink_f() + src = blocks.vector_source_c(src_data) + op = blocks.complex_to_float() + dst = blocks.vector_sink_f() self.tb.connect(src, op, dst) self.tb.run() self.assertFloatTuplesAlmostEqual(expected_data, dst.data()) @@ -86,10 +86,10 @@ class test_type_conversions(gr_unittest.TestCase): src_data = (1+2j, 3+4j, 5+6j, 7+8j, 9+10j) expected_data1 = (1.0, 3.0, 5.0, 7.0, 9.0) expected_data2 = (2.0, 4.0, 6.0, 8.0, 10.0) - src = gr.vector_source_c(src_data) - op = blocks_swig.complex_to_float() - dst1 = gr.vector_sink_f() - dst2 = gr.vector_sink_f() + src = blocks.vector_source_c(src_data) + op = blocks.complex_to_float() + dst1 = blocks.vector_sink_f() + dst2 = blocks.vector_sink_f() self.tb.connect(src, op) self.tb.connect((op, 0), dst1) self.tb.connect((op, 1), dst2) @@ -100,9 +100,9 @@ class test_type_conversions(gr_unittest.TestCase): def test_complex_to_real(self): src_data = (1+2j, 3+4j, 5+6j, 7+8j, 9+10j) expected_data = (1.0, 3.0, 5.0, 7.0, 9.0) - src = gr.vector_source_c(src_data) - op = blocks_swig.complex_to_real() - dst = gr.vector_sink_f() + src = blocks.vector_source_c(src_data) + op = blocks.complex_to_real() + dst = blocks.vector_sink_f() self.tb.connect(src, op, dst) self.tb.run() self.assertFloatTuplesAlmostEqual(expected_data, dst.data()) @@ -110,9 +110,9 @@ class test_type_conversions(gr_unittest.TestCase): def test_complex_to_imag(self): src_data = (1+2j, 3+4j, 5+6j, 7+8j, 9+10j) expected_data = (2.0, 4.0, 6.0, 8.0, 10.0) - src = gr.vector_source_c(src_data) - op = blocks_swig.complex_to_imag() - dst = gr.vector_sink_f() + src = blocks.vector_source_c(src_data) + op = blocks.complex_to_imag() + dst = blocks.vector_sink_f() self.tb.connect(src, op, dst) self.tb.run() self.assertFloatTuplesAlmostEqual(expected_data, dst.data()) @@ -120,9 +120,9 @@ class test_type_conversions(gr_unittest.TestCase): def test_complex_to_mag(self): src_data = (1+2j, 3-4j, 5+6j, 7-8j, -9+10j) expected_data = (sqrt(5), sqrt(25), sqrt(61), sqrt(113), sqrt(181)) - src = gr.vector_source_c(src_data) - op = blocks_swig.complex_to_mag() - dst = gr.vector_sink_f() + src = blocks.vector_source_c(src_data) + op = blocks.complex_to_mag() + dst = blocks.vector_sink_f() self.tb.connect(src, op, dst) self.tb.run() self.assertFloatTuplesAlmostEqual(expected_data, dst.data(), 5) @@ -130,9 +130,9 @@ class test_type_conversions(gr_unittest.TestCase): def test_complex_to_mag_squared(self): src_data = (1+2j, 3-4j, 5+6j, 7-8j, -9+10j) expected_data = (5.0, 25.0, 61.0, 113.0, 181.0) - src = gr.vector_source_c(src_data) - op = blocks_swig.complex_to_mag_squared() - dst = gr.vector_sink_f() + src = blocks.vector_source_c(src_data) + op = blocks.complex_to_mag_squared() + dst = blocks.vector_sink_f() self.tb.connect(src, op, dst) self.tb.run() self.assertFloatTuplesAlmostEqual(expected_data, dst.data()) @@ -140,9 +140,9 @@ class test_type_conversions(gr_unittest.TestCase): def test_complex_to_arg(self): src_data = (1+2j, 3-4j, 5+6j, 7-8j, -9+10j) expected_data = (atan2(2, 1), atan2(-4,3), atan2(6, 5), atan2(-8, 7), atan2(10,-9)) - src = gr.vector_source_c(src_data) - op = blocks_swig.complex_to_arg() - dst = gr.vector_sink_f() + src = blocks.vector_source_c(src_data) + op = blocks.complex_to_arg() + dst = blocks.vector_sink_f() self.tb.connect(src, op, dst) self.tb.run() self.assertFloatTuplesAlmostEqual(expected_data, dst.data(), 2) @@ -150,9 +150,9 @@ class test_type_conversions(gr_unittest.TestCase): def test_float_to_char_identity(self): src_data = (1.0, 2.0, 3.0, 4.0, 5.0) expected_data = (1, 2, 3, 4, 5) - src = gr.vector_source_f(src_data) - op = blocks_swig.float_to_char() - dst = gr.vector_sink_b() + src = blocks.vector_source_f(src_data) + op = blocks.float_to_char() + dst = blocks.vector_sink_b() self.tb.connect(src, op, dst) self.tb.run() self.assertEqual(expected_data, dst.data()) @@ -160,9 +160,9 @@ class test_type_conversions(gr_unittest.TestCase): def test_float_to_char_scale(self): src_data = (1.0, 2.0, 3.0, 4.0, 5.0) expected_data = (5, 10, 15, 20, 25) - src = gr.vector_source_f(src_data) - op = blocks_swig.float_to_char(1, 5) - dst = gr.vector_sink_b() + src = blocks.vector_source_f(src_data) + op = blocks.float_to_char(1, 5) + dst = blocks.vector_sink_b() self.tb.connect(src, op, dst) self.tb.run() self.assertEqual(expected_data, dst.data()) @@ -170,9 +170,9 @@ class test_type_conversions(gr_unittest.TestCase): def test_float_to_complex_1(self): src_data = (1.0, 3.0, 5.0, 7.0, 9.0) expected_data = (1+0j, 3+0j, 5+0j, 7+0j, 9+0j) - src = gr.vector_source_f(src_data) - op = blocks_swig.float_to_complex() - dst = gr.vector_sink_c() + src = blocks.vector_source_f(src_data) + op = blocks.float_to_complex() + dst = blocks.vector_sink_c() self.tb.connect(src, op, dst) self.tb.run() self.assertFloatTuplesAlmostEqual(expected_data, dst.data()) @@ -181,10 +181,10 @@ class test_type_conversions(gr_unittest.TestCase): src1_data = (1.0, 3.0, 5.0, 7.0, 9.0) src2_data = (2.0, 4.0, 6.0, 8.0, 10.0) expected_data = (1+2j, 3+4j, 5+6j, 7+8j, 9+10j) - src1 = gr.vector_source_f(src1_data) - src2 = gr.vector_source_f(src2_data) - op = blocks_swig.float_to_complex() - dst = gr.vector_sink_c() + src1 = blocks.vector_source_f(src1_data) + src2 = blocks.vector_source_f(src2_data) + op = blocks.float_to_complex() + dst = blocks.vector_sink_c() self.tb.connect(src1, (op, 0)) self.tb.connect(src2, (op, 1)) self.tb.connect(op, dst) @@ -194,9 +194,9 @@ class test_type_conversions(gr_unittest.TestCase): def test_float_to_int_identity(self): src_data = (1.0, 2.0, 3.0, 4.0, 5.0) expected_data = (1, 2, 3, 4, 5) - src = gr.vector_source_f(src_data) - op = blocks_swig.float_to_int() - dst = gr.vector_sink_i() + src = blocks.vector_source_f(src_data) + op = blocks.float_to_int() + dst = blocks.vector_sink_i() self.tb.connect(src, op, dst) self.tb.run() self.assertEqual(expected_data, dst.data()) @@ -204,9 +204,9 @@ class test_type_conversions(gr_unittest.TestCase): def test_float_to_int_scale(self): src_data = (1.0, 2.0, 3.0, 4.0, 5.0) expected_data = (5, 10, 15, 20, 25) - src = gr.vector_source_f(src_data) - op = blocks_swig.float_to_int(1, 5) - dst = gr.vector_sink_i() + src = blocks.vector_source_f(src_data) + op = blocks.float_to_int(1, 5) + dst = blocks.vector_sink_i() self.tb.connect(src, op, dst) self.tb.run() self.assertEqual(expected_data, dst.data()) @@ -214,9 +214,9 @@ class test_type_conversions(gr_unittest.TestCase): def test_float_to_short_identity(self): src_data = (1.0, 2.0, 3.0, 4.0, 5.0) expected_data = (1, 2, 3, 4, 5) - src = gr.vector_source_f(src_data) - op = blocks_swig.float_to_short() - dst = gr.vector_sink_s() + src = blocks.vector_source_f(src_data) + op = blocks.float_to_short() + dst = blocks.vector_sink_s() self.tb.connect(src, op, dst) self.tb.run() self.assertEqual(expected_data, dst.data()) @@ -224,9 +224,9 @@ class test_type_conversions(gr_unittest.TestCase): def test_float_to_short_scale(self): src_data = (1.0, 2.0, 3.0, 4.0, 5.0) expected_data = (5, 10, 15, 20, 25) - src = gr.vector_source_f(src_data) - op = blocks_swig.float_to_short(1, 5) - dst = gr.vector_sink_s() + src = blocks.vector_source_f(src_data) + op = blocks.float_to_short(1, 5) + dst = blocks.vector_sink_s() self.tb.connect(src, op, dst) self.tb.run() self.assertEqual(expected_data, dst.data()) @@ -234,9 +234,9 @@ class test_type_conversions(gr_unittest.TestCase): def test_float_to_uchar(self): src_data = (1.0, -2.0, 3.0, -4.0, 256.0) expected_data = (1, 0, 3, 0, 255) - src = gr.vector_source_f(src_data) - op = blocks_swig.float_to_uchar() - dst = gr.vector_sink_b() + src = blocks.vector_source_f(src_data) + op = blocks.float_to_uchar() + dst = blocks.vector_sink_b() self.tb.connect(src, op, dst) self.tb.run() self.assertEqual(expected_data, dst.data()) @@ -244,9 +244,9 @@ class test_type_conversions(gr_unittest.TestCase): def test_int_to_float_identity(self): src_data = (1, 2, 3, 4, 5) expected_data = (1.0, 2.0, 3.0, 4.0, 5.0) - src = gr.vector_source_i(src_data) - op = blocks_swig.int_to_float() - dst = gr.vector_sink_f() + src = blocks.vector_source_i(src_data) + op = blocks.int_to_float() + dst = blocks.vector_sink_f() self.tb.connect(src, op, dst) self.tb.run() self.assertFloatTuplesAlmostEqual(expected_data, dst.data()) @@ -254,9 +254,9 @@ class test_type_conversions(gr_unittest.TestCase): def test_int_to_float_scale(self): src_data = (1, 2, 3, 4, 5) expected_data = (0.2, 0.4, 0.6, 0.8, 1.0) - src = gr.vector_source_i(src_data) - op = blocks_swig.int_to_float(1, 5) - dst = gr.vector_sink_f() + src = blocks.vector_source_i(src_data) + op = blocks.int_to_float(1, 5) + dst = blocks.vector_sink_f() self.tb.connect(src, op, dst) self.tb.run() self.assertFloatTuplesAlmostEqual(expected_data, dst.data()) @@ -264,9 +264,9 @@ class test_type_conversions(gr_unittest.TestCase): def test_interleaved_short_to_complex(self): src_data = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) expected_data = (1+2j, 3+4j, 5+6j, 7+8j, 9+10j) - src = gr.vector_source_s(src_data) - op = blocks_swig.interleaved_short_to_complex() - dst = gr.vector_sink_c() + src = blocks.vector_source_s(src_data) + op = blocks.interleaved_short_to_complex() + dst = blocks.vector_sink_c() self.tb.connect(src, op, dst) self.tb.run() self.assertEqual(expected_data, dst.data()) @@ -274,9 +274,9 @@ class test_type_conversions(gr_unittest.TestCase): def test_short_to_char(self): src_data = (256, 512, 768, 1024, 1280) expected_data = (1, 2, 3, 4, 5) - src = gr.vector_source_s(src_data) - op = blocks_swig.short_to_char() - dst = gr.vector_sink_b() + src = blocks.vector_source_s(src_data) + op = blocks.short_to_char() + dst = blocks.vector_sink_b() self.tb.connect(src, op, dst) self.tb.run() self.assertEqual(expected_data, dst.data()) @@ -284,9 +284,9 @@ class test_type_conversions(gr_unittest.TestCase): def test_short_to_float_identity(self): src_data = (1, 2, 3, 4, 5) expected_data = (1.0, 2.0, 3.0, 4.0, 5.0) - src = gr.vector_source_s(src_data) - op = blocks_swig.short_to_float() - dst = gr.vector_sink_f() + src = blocks.vector_source_s(src_data) + op = blocks.short_to_float() + dst = blocks.vector_sink_f() self.tb.connect(src, op, dst) self.tb.run() self.assertEqual(expected_data, dst.data()) @@ -294,9 +294,9 @@ class test_type_conversions(gr_unittest.TestCase): def test_short_to_float_scale(self): src_data = (5, 10, 15, 20, 25) expected_data = (1.0, 2.0, 3.0, 4.0, 5.0) - src = gr.vector_source_s(src_data) - op = blocks_swig.short_to_float(1, 5) - dst = gr.vector_sink_f() + src = blocks.vector_source_s(src_data) + op = blocks.short_to_float(1, 5) + dst = blocks.vector_sink_f() self.tb.connect(src, op, dst) self.tb.run() self.assertEqual(expected_data, dst.data()) @@ -304,9 +304,9 @@ class test_type_conversions(gr_unittest.TestCase): def test_uchar_to_float(self): src_data = (1, 2, 3, 4, 5) expected_data = (1.0, 2.0, 3.0, 4.0, 5.0) - src = gr.vector_source_b(src_data) - op = blocks_swig.uchar_to_float() - dst = gr.vector_sink_f() + src = blocks.vector_source_b(src_data) + op = blocks.uchar_to_float() + dst = blocks.vector_sink_f() self.tb.connect(src, op, dst) self.tb.run() self.assertEqual(expected_data, dst.data()) diff --git a/gr-blocks/python/qa_udp_source_sink.py b/gr-blocks/python/qa_udp_source_sink.py index 8c5fa28217..ac8a9d0eb1 100644 --- a/gr-blocks/python/qa_udp_source_sink.py +++ b/gr-blocks/python/qa_udp_source_sink.py @@ -45,7 +45,7 @@ class test_udp_sink_source(gr_unittest.TestCase): n_data = 16 src_data = [x for x in range(n_data)] expected_result = tuple(src_data) - src = gr.vector_source_s(src_data, False) + src = blocks.vector_source_s(src_data, False) udp_snd = blocks.udp_sink(gr.sizeof_short, 'localhost', port) self.tb_snd.connect(src, udp_snd) @@ -62,12 +62,12 @@ class test_udp_sink_source(gr_unittest.TestCase): n_data = 100 src_data = [float(x) for x in range(n_data)] expected_result = tuple(src_data) - src = gr.vector_source_f(src_data, False) + src = blocks.vector_source_f(src_data, False) udp_snd = blocks.udp_sink(gr.sizeof_float, 'localhost', port) self.tb_snd.connect(src, udp_snd) udp_rcv = blocks.udp_source(gr.sizeof_float, 'localhost', port) - dst = gr.vector_sink_f() + dst = blocks.vector_sink_f() self.tb_rcv.connect(udp_rcv, dst) self.tb_rcv.start() @@ -93,8 +93,8 @@ class test_udp_sink_source(gr_unittest.TestCase): n_data = 16 src_data = [float(x) for x in range(n_data)] expected_result = tuple(src_data) - src = gr.vector_source_f(src_data) - dst = gr.vector_sink_f() + src = blocks.vector_source_f(src_data) + dst = blocks.vector_sink_f() self.tb_snd.connect(src, udp_snd) self.tb_rcv.connect(udp_rcv, dst) diff --git a/gr-blocks/python/qa_unpack_k_bits.py b/gr-blocks/python/qa_unpack_k_bits.py index e038d5a03a..dd7024f74c 100755 --- a/gr-blocks/python/qa_unpack_k_bits.py +++ b/gr-blocks/python/qa_unpack_k_bits.py @@ -35,9 +35,9 @@ class test_unpack(gr_unittest.TestCase): def test_001(self): src_data = (1,0,1,1,0,1,1,0) expected_results = (1,0,1,1,0,1,1,0) - src = gr.vector_source_b(src_data,False) + src = blocks.vector_source_b(src_data,False) op = blocks.unpack_k_bits_bb(1) - dst = gr.vector_sink_b() + dst = blocks.vector_sink_b() self.tb.connect(src, op, dst) self.tb.run() self.assertEqual(expected_results, dst.data()) @@ -45,9 +45,9 @@ class test_unpack(gr_unittest.TestCase): def test_002(self): src_data = ( 2, 3, 0, 1) expected_results = (1,0,1,1,0,0,0,1) - src = gr.vector_source_b(src_data,False) + src = blocks.vector_source_b(src_data,False) op = blocks.unpack_k_bits_bb(2) - dst = gr.vector_sink_b() + dst = blocks.vector_sink_b() self.tb.connect(src, op, dst) self.tb.run() self.assertEqual(expected_results, dst.data()) diff --git a/gr-blocks/python/qa_vco.py b/gr-blocks/python/qa_vco.py index 721eb9471b..23ff636d86 100644 --- a/gr-blocks/python/qa_vco.py +++ b/gr-blocks/python/qa_vco.py @@ -21,7 +21,7 @@ # from gnuradio import gr, gr_unittest -import blocks_swig +import blocks_swig as blocks import math def sig_source_f(samp_rate, freq, amp, N): @@ -43,9 +43,9 @@ class test_vco(gr_unittest.TestCase): sig_source_f(1, 0.125, 1, 200) + \ sig_source_f(1, 0.25, 1, 200) - src = gr.vector_source_f(src_data) - op = blocks_swig.vco_f(1, math.pi/2.0, 1) - dst = gr.vector_sink_f() + src = blocks.vector_source_f(src_data) + op = blocks.vco_f(1, math.pi/2.0, 1) + dst = blocks.vector_sink_f() self.tb.connect(src, op, dst) self.tb.run() diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_vector_insert.py b/gr-blocks/python/qa_vector_insert.py index acc06dfded..e3c0d3102f 100755 --- a/gnuradio-core/src/python/gnuradio/gr/qa_vector_insert.py +++ b/gr-blocks/python/qa_vector_insert.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2012 Free Software Foundation, Inc. +# Copyright 2012-2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -21,14 +21,15 @@ # from gnuradio import gr, gr_unittest +import blocks_swig as blocks import math class test_vector_insert(gr_unittest.TestCase): - def setUp (self): - self.tb = gr.top_block () + def setUp(self): + self.tb = gr.top_block() - def tearDown (self): + def tearDown(self): self.tb = None def test_001(self): @@ -38,10 +39,10 @@ class test_vector_insert(gr_unittest.TestCase): period = 9177; offset = 0; - src = gr.null_source(1) - head = gr.head(1, 10000000); - ins = gr.vector_insert_b([1], period, offset); - dst = gr.vector_sink_b() + src = blocks.null_source(1) + head = blocks.head(1, 10000000); + ins = blocks.vector_insert_b([1], period, offset); + dst = blocks.vector_sink_b() self.tb.connect(src, head, ins, dst) self.tb.run() diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_vector_map.py b/gr-blocks/python/qa_vector_map.py index 12f4be5898..54565fe443 100644 --- a/gnuradio-core/src/python/gnuradio/gr/qa_vector_map.py +++ b/gr-blocks/python/qa_vector_map.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2012 Free Software Foundation, Inc. +# Copyright 2012,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -21,14 +21,15 @@ # from gnuradio import gr, gr_unittest +import blocks_swig as blocks import math class test_vector_map(gr_unittest.TestCase): - def setUp (self): + def setUp(self): self.tb = gr.top_block() - def tearDown (self): + def tearDown(self): self.tb = None def test_reversing(self): @@ -40,9 +41,9 @@ class test_vector_map(gr_unittest.TestCase): for j in range(0, N): expected_result.append(1.0*(i-j)) mapping = [list(reversed([(0, i) for i in range(0, N)]))] - src = gr.vector_source_f(src_data, False, N) - vmap = gr.vector_map(gr.sizeof_float, (N, ), mapping) - dst = gr.vector_sink_f(N) + src = blocks.vector_source_f(src_data, False, N) + vmap = blocks.vector_map(gr.sizeof_float, (N, ), mapping) + dst = blocks.vector_sink_f(N) self.tb.connect(src, vmap, dst) self.tb.run() result_data = list(dst.data()) @@ -57,9 +58,9 @@ class test_vector_map(gr_unittest.TestCase): for n in range(0, N): expected_results.append(range(n, M, N)) mapping = [[(0, n)] for n in range(0, N)] - src = gr.vector_source_f(src_data, False, N) - vmap = gr.vector_map(gr.sizeof_float, (N, ), mapping) - dsts = [gr.vector_sink_f(1) for n in range(0, N)] + src = blocks.vector_source_f(src_data, False, N) + vmap = blocks.vector_map(gr.sizeof_float, (N, ), mapping) + dsts = [blocks.vector_sink_f(1) for n in range(0, N)] self.tb.connect(src, vmap) for n in range(0, N): self.tb.connect((vmap, n), dsts[n]) @@ -83,12 +84,12 @@ class test_vector_map(gr_unittest.TestCase): mapping = [[(0, 0), (1, 0)], # mapping to produce D [(0, 0), (1, 0), (2, 1), (2, 0)], # mapping to produce E ] - srcA = gr.vector_source_f(A, False, 1) - srcB = gr.vector_source_f(B, False, 1) - srcC = gr.vector_source_f(C, False, 2) - vmap = gr.vector_map(gr.sizeof_int, (1, 1, 2), mapping) - dstD = gr.vector_sink_f(2) - dstE = gr.vector_sink_f(4) + srcA = blocks.vector_source_f(A, False, 1) + srcB = blocks.vector_source_f(B, False, 1) + srcC = blocks.vector_source_f(C, False, 2) + vmap = blocks.vector_map(gr.sizeof_int, (1, 1, 2), mapping) + dstD = blocks.vector_sink_f(2) + dstE = blocks.vector_sink_f(4) self.tb.connect(srcA, (vmap, 0)) self.tb.connect(srcB, (vmap, 1)) self.tb.connect(srcC, (vmap, 2)) @@ -97,8 +98,6 @@ class test_vector_map(gr_unittest.TestCase): self.tb.run() self.assertEqual(expected_D, dstD.data()) self.assertEqual(expected_E, dstE.data()) - - if __name__ == '__main__': gr_unittest.run(test_vector_map, "test_vector_map.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_vector_sink_source.py b/gr-blocks/python/qa_vector_sink_source.py index 64cbbe72a3..169e6a4450 100755 --- a/gnuradio-core/src/python/gnuradio/gr/qa_vector_sink_source.py +++ b/gr-blocks/python/qa_vector_sink_source.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2008,2010 Free Software Foundation, Inc. +# Copyright 2008,2010,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -21,22 +21,23 @@ # from gnuradio import gr, gr_unittest +import blocks_swig as blocks import math class test_vector_sink_source(gr_unittest.TestCase): - def setUp (self): - self.tb = gr.top_block () + def setUp(self): + self.tb = gr.top_block() - def tearDown (self): + def tearDown(self): self.tb = None def test_001(self): src_data = [float(x) for x in range(16)] expected_result = tuple(src_data) - src = gr.vector_source_f(src_data) - dst = gr.vector_sink_f() + src = blocks.vector_source_f(src_data) + dst = blocks.vector_sink_f() self.tb.connect(src, dst) self.tb.run() @@ -47,8 +48,8 @@ class test_vector_sink_source(gr_unittest.TestCase): src_data = [float(x) for x in range(16)] expected_result = tuple(src_data) - src = gr.vector_source_f(src_data, False, 2) - dst = gr.vector_sink_f(2) + src = blocks.vector_source_f(src_data, False, 2) + dst = blocks.vector_sink_f(2) self.tb.connect(src, dst) self.tb.run() @@ -58,7 +59,7 @@ class test_vector_sink_source(gr_unittest.TestCase): def test_003(self): src_data = [float(x) for x in range(16)] expected_result = tuple(src_data) - self.assertRaises(ValueError, lambda : gr.vector_source_f(src_data, False, 3)) + self.assertRaises(RuntimeError, lambda : blocks.vector_source_f(src_data, False, 3)) if __name__ == '__main__': gr_unittest.run(test_vector_sink_source, "test_vector_sink_source.xml") diff --git a/gr-blocks/swig/CMakeLists.txt b/gr-blocks/swig/CMakeLists.txt index 84ab5b660f..1e4213fdc2 100644 --- a/gr-blocks/swig/CMakeLists.txt +++ b/gr-blocks/swig/CMakeLists.txt @@ -31,6 +31,10 @@ set(GR_SWIG_INCLUDE_DIRS ${Boost_INCLUDE_DIRS} ) +if(ENABLE_GR_CTRLPORT) + SET(GR_SWIG_FLAGS "-DGR_CTRLPORT") +endif(ENABLE_GR_CTRLPORT) + set(GR_SWIG_DOC_FILE ${CMAKE_CURRENT_BINARY_DIR}/blocks_swig_doc.i) set(GR_SWIG_DOC_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../lib) set(GR_SWIG_TARGET_DEPS blocks_generated_includes) diff --git a/gr-blocks/swig/blocks_swig.i b/gr-blocks/swig/blocks_swig.i index 5245721b68..9be2281b11 100644 --- a/gr-blocks/swig/blocks_swig.i +++ b/gr-blocks/swig/blocks_swig.i @@ -30,6 +30,9 @@ %include <gr_endianness.h> +%template() std::vector<size_t>; +%template() std::vector< std::vector< std::vector<size_t> > >; + %{ #include "blocks/add_ff.h" #include "blocks/add_ss.h" @@ -51,6 +54,9 @@ #include "blocks/and_const_bb.h" #include "blocks/and_const_ss.h" #include "blocks/and_const_ii.h" +#include "blocks/annotator_1to1.h" +#include "blocks/annotator_alltoall.h" +#include "blocks/annotator_raw.h" #include "blocks/argmax_fs.h" #include "blocks/argmax_is.h" #include "blocks/argmax_ss.h" @@ -58,6 +64,7 @@ #include "blocks/burst_tagger.h" #include "blocks/char_to_float.h" #include "blocks/char_to_short.h" +#include "blocks/check_lfsr_32k_s.h" #include "blocks/complex_to_interleaved_short.h" #include "blocks/complex_to_float.h" #include "blocks/complex_to_real.h" @@ -67,12 +74,14 @@ #include "blocks/complex_to_arg.h" #include "blocks/conjugate_cc.h" #include "blocks/control_loop.h" +#include "blocks/copy.h" #include "blocks/deinterleave.h" #include "blocks/delay.h" #include "blocks/divide_ff.h" #include "blocks/divide_ss.h" #include "blocks/divide_ii.h" #include "blocks/divide_cc.h" +#include "blocks/endian_swap.h" #include "blocks/file_descriptor_sink.h" #include "blocks/file_descriptor_source.h" #include "blocks/file_sink_base.h" @@ -85,6 +94,7 @@ #include "blocks/float_to_int.h" #include "blocks/float_to_short.h" #include "blocks/float_to_uchar.h" +#include "blocks/head.h" #include "blocks/int_to_float.h" #include "blocks/integrate_ss.h" #include "blocks/integrate_ii.h" @@ -94,6 +104,7 @@ #include "blocks/interleaved_short_to_complex.h" #include "blocks/keep_m_in_n.h" #include "blocks/keep_one_in_n.h" +#include "blocks/lfsr_32k_source_s.h" #include "blocks/max_ff.h" #include "blocks/max_ii.h" #include "blocks/max_ss.h" @@ -124,9 +135,12 @@ #include "blocks/mute_ff.h" #include "blocks/mute_cc.h" #include "blocks/nlog10_ff.h" +#include "blocks/nop.h" #include "blocks/not_bb.h" #include "blocks/not_ss.h" #include "blocks/not_ii.h" +#include "blocks/null_sink.h" +#include "blocks/null_source.h" #include "blocks/patterned_interleaver.h" #include "blocks/pack_k_bits_bb.h" #include "blocks/packed_to_unpacked_bb.h" @@ -163,6 +177,7 @@ #include "blocks/sample_and_hold_ff.h" #include "blocks/short_to_char.h" #include "blocks/short_to_float.h" +#include "blocks/skiphead.h" #include "blocks/socket_pdu.h" #include "blocks/stream_mux.h" #include "blocks/stream_to_streams.h" @@ -190,8 +205,24 @@ #include "blocks/unpacked_to_packed_ss.h" #include "blocks/unpacked_to_packed_ii.h" #include "blocks/vco_f.h" +#include "blocks/vector_map.h" #include "blocks/vector_to_stream.h" #include "blocks/vector_to_streams.h" +#include "blocks/vector_insert_b.h" +#include "blocks/vector_insert_s.h" +#include "blocks/vector_insert_i.h" +#include "blocks/vector_insert_f.h" +#include "blocks/vector_insert_c.h" +#include "blocks/vector_sink_b.h" +#include "blocks/vector_sink_s.h" +#include "blocks/vector_sink_i.h" +#include "blocks/vector_sink_f.h" +#include "blocks/vector_sink_c.h" +#include "blocks/vector_source_b.h" +#include "blocks/vector_source_s.h" +#include "blocks/vector_source_i.h" +#include "blocks/vector_source_f.h" +#include "blocks/vector_source_c.h" #include "blocks/wavfile_sink.h" #include "blocks/wavfile_source.h" #include "blocks/xor_bb.h" @@ -219,6 +250,9 @@ %include "blocks/and_const_bb.h" %include "blocks/and_const_ss.h" %include "blocks/and_const_ii.h" +%include "blocks/annotator_1to1.h" +%include "blocks/annotator_alltoall.h" +%include "blocks/annotator_raw.h" %include "blocks/argmax_fs.h" %include "blocks/argmax_is.h" %include "blocks/argmax_ss.h" @@ -226,6 +260,7 @@ %include "blocks/bin_statistics_f.h" %include "blocks/burst_tagger.h" %include "blocks/char_to_short.h" +%include "blocks/check_lfsr_32k_s.h" %include "blocks/complex_to_interleaved_short.h" %include "blocks/complex_to_float.h" %include "blocks/complex_to_real.h" @@ -235,6 +270,7 @@ %include "blocks/complex_to_arg.h" %include "blocks/conjugate_cc.h" %include "blocks/control_loop.h" +%include "blocks/copy.h" %include "blocks/deinterleave.h" %include "blocks/delay.h" %include "blocks/file_descriptor_sink.h" @@ -248,11 +284,13 @@ %include "blocks/divide_ss.h" %include "blocks/divide_ii.h" %include "blocks/divide_cc.h" +%include "blocks/endian_swap.h" %include "blocks/float_to_char.h" %include "blocks/float_to_complex.h" %include "blocks/float_to_int.h" %include "blocks/float_to_short.h" %include "blocks/float_to_uchar.h" +%include "blocks/head.h" %include "blocks/int_to_float.h" %include "blocks/integrate_ss.h" %include "blocks/integrate_ii.h" @@ -262,6 +300,7 @@ %include "blocks/interleaved_short_to_complex.h" %include "blocks/keep_m_in_n.h" %include "blocks/keep_one_in_n.h" +%include "blocks/lfsr_32k_source_s.h" %include "blocks/max_ff.h" %include "blocks/max_ii.h" %include "blocks/max_ss.h" @@ -292,9 +331,12 @@ %include "blocks/mute_ff.h" %include "blocks/mute_cc.h" %include "blocks/nlog10_ff.h" +%include "blocks/nop.h" %include "blocks/not_bb.h" %include "blocks/not_ss.h" %include "blocks/not_ii.h" +%include "blocks/null_sink.h" +%include "blocks/null_source.h" %include "blocks/probe_signal_b.h" %include "blocks/probe_signal_s.h" %include "blocks/probe_signal_i.h" @@ -332,6 +374,7 @@ %include "blocks/sample_and_hold_ff.h" %include "blocks/short_to_char.h" %include "blocks/short_to_float.h" +%include "blocks/skiphead.h" %include "blocks/socket_pdu.h" %include "blocks/stream_mux.h" %include "blocks/stream_to_streams.h" @@ -358,8 +401,24 @@ %include "blocks/unpacked_to_packed_ss.h" %include "blocks/unpacked_to_packed_ii.h" %include "blocks/vco_f.h" +%include "blocks/vector_map.h" %include "blocks/vector_to_stream.h" %include "blocks/vector_to_streams.h" +%include "blocks/vector_insert_b.h" +%include "blocks/vector_insert_s.h" +%include "blocks/vector_insert_i.h" +%include "blocks/vector_insert_f.h" +%include "blocks/vector_insert_c.h" +%include "blocks/vector_sink_b.h" +%include "blocks/vector_sink_s.h" +%include "blocks/vector_sink_i.h" +%include "blocks/vector_sink_f.h" +%include "blocks/vector_sink_c.h" +%include "blocks/vector_source_b.h" +%include "blocks/vector_source_s.h" +%include "blocks/vector_source_i.h" +%include "blocks/vector_source_f.h" +%include "blocks/vector_source_c.h" %include "blocks/wavfile_sink.h" %include "blocks/wavfile_source.h" %include "blocks/xor_bb.h" @@ -386,6 +445,9 @@ GR_SWIG_BLOCK_MAGIC2(blocks, and_ii); GR_SWIG_BLOCK_MAGIC2(blocks, and_const_bb); GR_SWIG_BLOCK_MAGIC2(blocks, and_const_ss); GR_SWIG_BLOCK_MAGIC2(blocks, and_const_ii); +GR_SWIG_BLOCK_MAGIC2(blocks, annotator_1to1); +GR_SWIG_BLOCK_MAGIC2(blocks, annotator_alltoall); +GR_SWIG_BLOCK_MAGIC2(blocks, annotator_raw); GR_SWIG_BLOCK_MAGIC2(blocks, argmax_fs); GR_SWIG_BLOCK_MAGIC2(blocks, argmax_is); GR_SWIG_BLOCK_MAGIC2(blocks, argmax_ss); @@ -393,6 +455,7 @@ GR_SWIG_BLOCK_MAGIC2(blocks, bin_statistics_f); GR_SWIG_BLOCK_MAGIC2(blocks, burst_tagger); GR_SWIG_BLOCK_MAGIC2(blocks, char_to_float); GR_SWIG_BLOCK_MAGIC2(blocks, char_to_short); +GR_SWIG_BLOCK_MAGIC2(blocks, check_lfsr_32k_s); GR_SWIG_BLOCK_MAGIC2(blocks, complex_to_interleaved_short); GR_SWIG_BLOCK_MAGIC2(blocks, complex_to_float); GR_SWIG_BLOCK_MAGIC2(blocks, complex_to_real); @@ -401,8 +464,10 @@ GR_SWIG_BLOCK_MAGIC2(blocks, complex_to_mag); GR_SWIG_BLOCK_MAGIC2(blocks, complex_to_mag_squared); GR_SWIG_BLOCK_MAGIC2(blocks, complex_to_arg); GR_SWIG_BLOCK_MAGIC2(blocks, conjugate_cc); +GR_SWIG_BLOCK_MAGIC2(blocks, copy); GR_SWIG_BLOCK_MAGIC2(blocks, deinterleave); GR_SWIG_BLOCK_MAGIC2(blocks, delay); +GR_SWIG_BLOCK_MAGIC2(blocks, endian_swap); GR_SWIG_BLOCK_MAGIC2(blocks, divide_ff); GR_SWIG_BLOCK_MAGIC2(blocks, divide_ss); GR_SWIG_BLOCK_MAGIC2(blocks, divide_ii); @@ -418,6 +483,7 @@ GR_SWIG_BLOCK_MAGIC2(blocks, float_to_complex); GR_SWIG_BLOCK_MAGIC2(blocks, float_to_int); GR_SWIG_BLOCK_MAGIC2(blocks, float_to_short); GR_SWIG_BLOCK_MAGIC2(blocks, float_to_uchar); +GR_SWIG_BLOCK_MAGIC2(blocks, head); GR_SWIG_BLOCK_MAGIC2(blocks, int_to_float); GR_SWIG_BLOCK_MAGIC2(blocks, integrate_ss); GR_SWIG_BLOCK_MAGIC2(blocks, integrate_ii); @@ -427,6 +493,7 @@ GR_SWIG_BLOCK_MAGIC2(blocks, interleave); GR_SWIG_BLOCK_MAGIC2(blocks, interleaved_short_to_complex); GR_SWIG_BLOCK_MAGIC2(blocks, keep_m_in_n); GR_SWIG_BLOCK_MAGIC2(blocks, keep_one_in_n); +GR_SWIG_BLOCK_MAGIC2(blocks, lfsr_32k_source_s); GR_SWIG_BLOCK_MAGIC2(blocks, max_ff); GR_SWIG_BLOCK_MAGIC2(blocks, max_ii); GR_SWIG_BLOCK_MAGIC2(blocks, max_ss); @@ -457,9 +524,12 @@ GR_SWIG_BLOCK_MAGIC2(blocks, mute_ii); GR_SWIG_BLOCK_MAGIC2(blocks, mute_ff); GR_SWIG_BLOCK_MAGIC2(blocks, mute_cc); GR_SWIG_BLOCK_MAGIC2(blocks, nlog10_ff); +GR_SWIG_BLOCK_MAGIC2(blocks, nop); GR_SWIG_BLOCK_MAGIC2(blocks, not_bb); GR_SWIG_BLOCK_MAGIC2(blocks, not_ss); GR_SWIG_BLOCK_MAGIC2(blocks, not_ii); +GR_SWIG_BLOCK_MAGIC2(blocks, null_sink); +GR_SWIG_BLOCK_MAGIC2(blocks, null_source); GR_SWIG_BLOCK_MAGIC2(blocks, patterned_interleaver); GR_SWIG_BLOCK_MAGIC2(blocks, pack_k_bits_bb); GR_SWIG_BLOCK_MAGIC2(blocks, packed_to_unpacked_bb); @@ -496,6 +566,7 @@ GR_SWIG_BLOCK_MAGIC2(blocks, sample_and_hold_ii); GR_SWIG_BLOCK_MAGIC2(blocks, sample_and_hold_ff); GR_SWIG_BLOCK_MAGIC2(blocks, short_to_char); GR_SWIG_BLOCK_MAGIC2(blocks, short_to_float); +GR_SWIG_BLOCK_MAGIC2(blocks, skiphead); GR_SWIG_BLOCK_MAGIC2(blocks, socket_pdu); GR_SWIG_BLOCK_MAGIC2(blocks, stream_mux); GR_SWIG_BLOCK_MAGIC2(blocks, stream_to_streams); @@ -523,10 +594,42 @@ GR_SWIG_BLOCK_MAGIC2(blocks, unpacked_to_packed_bb); GR_SWIG_BLOCK_MAGIC2(blocks, unpacked_to_packed_ss); GR_SWIG_BLOCK_MAGIC2(blocks, unpacked_to_packed_ii); GR_SWIG_BLOCK_MAGIC2(blocks, vco_f); +GR_SWIG_BLOCK_MAGIC2(blocks, vector_map); GR_SWIG_BLOCK_MAGIC2(blocks, vector_to_stream); GR_SWIG_BLOCK_MAGIC2(blocks, vector_to_streams); +GR_SWIG_BLOCK_MAGIC2(blocks, vector_insert_b); +GR_SWIG_BLOCK_MAGIC2(blocks, vector_insert_s); +GR_SWIG_BLOCK_MAGIC2(blocks, vector_insert_i); +GR_SWIG_BLOCK_MAGIC2(blocks, vector_insert_f); +GR_SWIG_BLOCK_MAGIC2(blocks, vector_insert_c); +GR_SWIG_BLOCK_MAGIC2(blocks, vector_sink_b); +GR_SWIG_BLOCK_MAGIC2(blocks, vector_sink_s); +GR_SWIG_BLOCK_MAGIC2(blocks, vector_sink_i); +GR_SWIG_BLOCK_MAGIC2(blocks, vector_sink_f); +GR_SWIG_BLOCK_MAGIC2(blocks, vector_sink_c); +GR_SWIG_BLOCK_MAGIC2(blocks, vector_source_b); +GR_SWIG_BLOCK_MAGIC2(blocks, vector_source_s); +GR_SWIG_BLOCK_MAGIC2(blocks, vector_source_i); +GR_SWIG_BLOCK_MAGIC2(blocks, vector_source_f); +GR_SWIG_BLOCK_MAGIC2(blocks, vector_source_c); GR_SWIG_BLOCK_MAGIC2(blocks, wavfile_sink); GR_SWIG_BLOCK_MAGIC2(blocks, wavfile_source); GR_SWIG_BLOCK_MAGIC2(blocks, xor_bb); GR_SWIG_BLOCK_MAGIC2(blocks, xor_ss); GR_SWIG_BLOCK_MAGIC2(blocks, xor_ii); + + +#ifdef GR_CTRLPORT + +%{ +#include "blocks/ctrlport_probe_c.h" +#include "blocks/ctrlport_probe2_c.h" +%} + +%include "blocks/ctrlport_probe_c.h" +%include "blocks/ctrlport_probe2_c.h" + +GR_SWIG_BLOCK_MAGIC2(blocks, ctrlport_probe_c); +GR_SWIG_BLOCK_MAGIC2(blocks, ctrlport_probe2_c); + +#endif /* GR_CTRLPORT */ diff --git a/gr-channels/lib/fading_model_impl.cc b/gr-channels/lib/fading_model_impl.cc index 106cc19c53..ecebe4a069 100644 --- a/gr-channels/lib/fading_model_impl.cc +++ b/gr-channels/lib/fading_model_impl.cc @@ -27,11 +27,11 @@ #include <boost/format.hpp> #include <boost/random.hpp> -#include <blocks/fxpt.h> +#include <gr_fxpt.h> #include <sincostable.h> -// FASTSINCOS: 0 = slow native, 1 = gr::blocks::fxpt impl, 2 = sincostable.h +// FASTSINCOS: 0 = slow native, 1 = gr_fxpt impl, 2 = sincostable.h #define FASTSINCOS 2 @@ -163,8 +163,8 @@ namespace gr { for(int n=1; n<d_N; n++){ float alpha_n = (2*M_PI*n - M_PI + d_theta)/4*d_N; #if FASTSINCOS == 1 - float s_i = scale_sin*gr::blocks::fxpt::cos(gr::blocks::fxpt::float_to_fixed(2*M_PI*d_fDTs*d_m*gr::blocks::fxpt::cos(gr::blocks::fxpt::float_to_fixed(alpha_n))+d_psi[n+1])); - float s_q = scale_sin*gr::blocks::fxpt::cos(gr::blocks::fxpt::float_to_fixed(2*M_PI*d_fDTs*d_m*gr::blocks::fxpt::sin(gr::blocks::fxpt::float_to_fixed(alpha_n))+d_phi[n+1])); + float s_i = scale_sin*gr_fxpt::cos(gr_fxpt::float_to_fixed(2*M_PI*d_fDTs*d_m*gr_fxpt::cos(gr_fxpt::float_to_fixed(alpha_n))+d_psi[n+1])); + float s_q = scale_sin*gr_fxpt::cos(gr_fxpt::float_to_fixed(2*M_PI*d_fDTs*d_m*gr_fxpt::sin(gr_fxpt::float_to_fixed(alpha_n))+d_phi[n+1])); #elif FASTSINCOS == 2 float s_i = scale_sin*d_table.cos(2*M_PI*d_fDTs*d_m*d_table.cos(alpha_n)+d_psi[n+1]); float s_q = scale_sin*d_table.cos(2*M_PI*d_fDTs*d_m*d_table.sin(alpha_n)+d_phi[n+1]); @@ -179,8 +179,8 @@ namespace gr { if(d_LOS){ #if FASTSINCOS == 1 - float los_i = gr::blocks::fxpt::cos(gr::blocks::fxpt::float_to_fixed(2*M_PI*d_fDTs*d_m*gr::blocks::fxpt::cos(gr::blocks::fxpt::float_to_fixed(d_theta_los)) + d_psi[0])); - float los_q = gr::blocks::fxpt::sin(gr::blocks::fxpt::float_to_fixed(2*M_PI*d_fDTs*d_m*gr::blocks::fxpt::cos(gr::blocks::fxpt::float_to_fixed(d_theta_los)) + d_psi[0])); + float los_i = gr_fxpt::cos(gr_fxpt::float_to_fixed(2*M_PI*d_fDTs*d_m*gr_fxpt::cos(gr_fxpt::float_to_fixed(d_theta_los)) + d_psi[0])); + float los_q = gr_fxpt::sin(gr_fxpt::float_to_fixed(2*M_PI*d_fDTs*d_m*gr_fxpt::cos(gr_fxpt::float_to_fixed(d_theta_los)) + d_psi[0])); #elif FASTSINCOS == 2 float los_i = d_table.cos(2*M_PI*d_fDTs*d_m*d_table.cos(d_theta_los) + d_psi[0]); float los_q = d_table.sin(2*M_PI*d_fDTs*d_m*d_table.cos(d_theta_los) + d_psi[0]); diff --git a/gr-channels/lib/fading_model_impl.h b/gr-channels/lib/fading_model_impl.h index f59504fc14..5c2d7f3877 100644 --- a/gr-channels/lib/fading_model_impl.h +++ b/gr-channels/lib/fading_model_impl.h @@ -30,7 +30,7 @@ #include <boost/format.hpp> #include <boost/random.hpp> -#include <blocks/fxpt.h> +#include <gr_fxpt.h> #include <sincostable.h> namespace gr { diff --git a/gr-channels/python/CMakeLists.txt b/gr-channels/python/CMakeLists.txt index ee58d5b164..92fe0ef220 100644 --- a/gr-channels/python/CMakeLists.txt +++ b/gr-channels/python/CMakeLists.txt @@ -37,6 +37,8 @@ list(APPEND GR_TEST_PYTHON_DIRS ${CMAKE_BINARY_DIR}/gr-channels/swig ${CMAKE_BINARY_DIR}/gr-analog/python ${CMAKE_BINARY_DIR}/gr-analog/swig + ${CMAKE_BINARY_DIR}/gr-blocks/python + ${CMAKE_BINARY_DIR}/gr-blocks/swig ) list(APPEND GR_TEST_TARGET_DEPS gnuradio-channels gnuradio-analog gnuradio-blocks) diff --git a/gr-channels/python/qa_channel_model.py b/gr-channels/python/qa_channel_model.py index 0a99477097..473650f1d7 100755 --- a/gr-channels/python/qa_channel_model.py +++ b/gr-channels/python/qa_channel_model.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2012 Free Software Foundation, Inc. +# Copyright 2012,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -22,6 +22,7 @@ from gnuradio import gr, gr_unittest import analog_swig as analog +import blocks_swig as blocks import channels_swig as channels import math @@ -39,10 +40,10 @@ class test_channel_model(gr_unittest.TestCase): freq = 100 signal = analog.sig_source_c(fs, analog.GR_SIN_WAVE, freq, 1) - head = gr.head(gr.sizeof_gr_complex, N) + head = blocks.head(gr.sizeof_gr_complex, N) op = channels.channel_model(0.0, 0.0, 1.0, [1,], 0) - snk = gr.vector_sink_c() - snk1 = gr.vector_sink_c() + snk = blocks.vector_sink_c() + snk1 = blocks.vector_sink_c() op.set_noise_voltage(0.0) op.set_frequency_offset(0.0) diff --git a/gr-channels/python/qa_fading_model.py b/gr-channels/python/qa_fading_model.py index e8a066ccb5..5ad378075a 100644 --- a/gr-channels/python/qa_fading_model.py +++ b/gr-channels/python/qa_fading_model.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2012 Free Software Foundation, Inc. +# Copyright 2012,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -22,6 +22,7 @@ from gnuradio import gr, gr_unittest import analog_swig as analog +import blocks_swig as blocks import channels_swig as channels import math @@ -41,11 +42,11 @@ class test_fading_model(gr_unittest.TestCase): fDTs = 0.01 K = 4 signal = analog.sig_source_c(fs, analog.GR_SIN_WAVE, freq, 1) - head = gr.head(gr.sizeof_gr_complex, N) + head = blocks.head(gr.sizeof_gr_complex, N) op = channels.fading_model(8, fDTs=fDTs, LOS=True, K=K, seed=0) - snk = gr.vector_sink_c() - snk1 = gr.vector_sink_c() + snk = blocks.vector_sink_c() + snk1 = blocks.vector_sink_c() self.assertAlmostEqual(K, op.K(), 4) self.assertAlmostEqual(fDTs, op.fDTs(), 4) diff --git a/gr-digital/CMakeLists.txt b/gr-digital/CMakeLists.txt index 7d3046dc50..1ef84d5654 100644 --- a/gr-digital/CMakeLists.txt +++ b/gr-digital/CMakeLists.txt @@ -91,7 +91,6 @@ CPACK_COMPONENT("digital_swig" ######################################################################## # Add subdirectories ######################################################################## -add_subdirectory(include) add_subdirectory(include/digital) add_subdirectory(lib) add_subdirectory(doc) diff --git a/gr-digital/examples/berawgn.py b/gr-digital/examples/berawgn.py index 6f9679d555..7fd1a2337d 100755 --- a/gr-digital/examples/berawgn.py +++ b/gr-digital/examples/berawgn.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2012 Free Software Foundation, Inc. +# Copyright 2012,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -91,7 +91,7 @@ class BERAWGNSimu(gr.top_block): self.const = digital.qpsk_constellation() # Source is N_BITS bits, non-repeated data = map(int, numpy.random.randint(0, self.const.arity(), N_BITS/self.const.bits_per_symbol())) - src = gr.vector_source_b(data, False) + src = blocks.vector_source_b(data, False) mod = digital.chunks_to_symbols_bc((self.const.points()), 1) add = blocks.add_vcc() noise = analog.noise_source_c(analog.GR_GAUSSIAN, @@ -99,7 +99,7 @@ class BERAWGNSimu(gr.top_block): RAND_SEED) demod = digital.constellation_decoder_cb(self.const.base()) ber = BitErrors(self.const.bits_per_symbol()) - self.sink = gr.vector_sink_f() + self.sink = blocks.vector_sink_f() self.connect(src, mod, add, demod, ber, self.sink) self.connect(noise, (add, 1)) self.connect(src, (ber, 1)) diff --git a/gr-digital/examples/demod/ber_simulation.grc b/gr-digital/examples/demod/ber_simulation.grc index b216912a6f..d0bec741c3 100644 --- a/gr-digital/examples/demod/ber_simulation.grc +++ b/gr-digital/examples/demod/ber_simulation.grc @@ -537,7 +537,7 @@ </param> <param> <key>trig_mode</key> - <value>gr.gr_TRIG_MODE_AUTO</value> + <value>wxgui.TRIG_MODE_AUTO</value> </param> <param> <key>y_axis_label</key> diff --git a/gr-digital/examples/demod/digital_freq_lock.grc b/gr-digital/examples/demod/digital_freq_lock.grc index 965768ece3..399d52488d 100644 --- a/gr-digital/examples/demod/digital_freq_lock.grc +++ b/gr-digital/examples/demod/digital_freq_lock.grc @@ -244,7 +244,7 @@ </param> <param> <key>trig_mode</key> - <value>gr.gr_TRIG_MODE_AUTO</value> + <value>wxgui.TRIG_MODE_AUTO</value> </param> <param> <key>y_axis_label</key> @@ -630,7 +630,7 @@ </param> <param> <key>trig_mode</key> - <value>gr.gr_TRIG_MODE_AUTO</value> + <value>wxgui.TRIG_MODE_AUTO</value> </param> <param> <key>y_axis_label</key> diff --git a/gr-digital/examples/demod/dpsk_loopback.grc b/gr-digital/examples/demod/dpsk_loopback.grc index 9befa69b6c..daa076c47b 100644 --- a/gr-digital/examples/demod/dpsk_loopback.grc +++ b/gr-digital/examples/demod/dpsk_loopback.grc @@ -374,7 +374,7 @@ </param> <param> <key>trig_mode</key> - <value>gr.gr_TRIG_MODE_AUTO</value> + <value>wxgui.TRIG_MODE_AUTO</value> </param> <param> <key>y_axis_label</key> diff --git a/gr-digital/examples/demod/mpsk_demod.grc b/gr-digital/examples/demod/mpsk_demod.grc index 1045ef5797..c252bb6e4f 100644 --- a/gr-digital/examples/demod/mpsk_demod.grc +++ b/gr-digital/examples/demod/mpsk_demod.grc @@ -1,6 +1,6 @@ <?xml version='1.0' encoding='ASCII'?> <flow_graph> - <timestamp>Mon Aug 20 19:51:38 2012</timestamp> + <timestamp>Sun Mar 17 21:08:14 2013</timestamp> <block> <key>options</key> <param> @@ -123,49 +123,6 @@ </param> </block> <block> - <key>digital_dxpsk_mod</key> - <param> - <key>id</key> - <value>digital_dxpsk_mod_0</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>type</key> - <value>dqpsk</value> - </param> - <param> - <key>samples_per_symbol</key> - <value>samps_per_sym</value> - </param> - <param> - <key>excess_bw</key> - <value>0.35</value> - </param> - <param> - <key>mod_code</key> - <value>"gray"</value> - </param> - <param> - <key>verbose</key> - <value>False</value> - </param> - <param> - <key>log</key> - <value>False</value> - </param> - <param> - <key>_coordinate</key> - <value>(361, 119)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> <key>variable</key> <param> <key>id</key> @@ -346,38 +303,58 @@ </param> </block> <block> - <key>channel_model</key> + <key>qtgui_const_sink_x</key> <param> <key>id</key> - <value>channel_model_0</value> + <value>qtgui_const_sink_x_0</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>noise_voltage</key> - <value>noise</value> + <key>type</key> + <value>complex</value> </param> <param> - <key>freq_offset</key> - <value>freq_off</value> + <key>name</key> + <value>QT GUI Plot</value> </param> <param> - <key>epsilon</key> - <value>1.0</value> + <key>size</key> + <value>1024</value> </param> <param> - <key>taps</key> - <value>1.0</value> + <key>ymin</key> + <value>-2</value> </param> <param> - <key>seed</key> - <value>0</value> + <key>ymax</key> + <value>2</value> + </param> + <param> + <key>xmin</key> + <value>-2</value> + </param> + <param> + <key>xmax</key> + <value>2</value> + </param> + <param> + <key>nconnections</key> + <value>1</value> + </param> + <param> + <key>update_time</key> + <value>0.10</value> + </param> + <param> + <key>gui_hint</key> + <value>notebook@0</value> </param> <param> <key>_coordinate</key> - <value>(369, 264)</value> + <value>(810, 184)</value> </param> <param> <key>_rotation</key> @@ -385,10 +362,10 @@ </param> </block> <block> - <key>blocks_throttle</key> + <key>qtgui_freq_sink_x</key> <param> <key>id</key> - <value>blocks_throttle_0</value> + <value>qtgui_freq_sink_x_0</value> </param> <param> <key>_enabled</key> @@ -399,16 +376,48 @@ <value>complex</value> </param> <param> - <key>samples_per_second</key> + <key>name</key> + <value>QT GUI Plot</value> + </param> + <param> + <key>fftsize</key> + <value>1024</value> + </param> + <param> + <key>wintype</key> + <value>firdes.WIN_BLACKMAN_hARRIS</value> + </param> + <param> + <key>fc</key> + <value>0</value> + </param> + <param> + <key>bw</key> <value>samp_rate</value> </param> <param> - <key>vlen</key> + <key>ymin</key> + <value>-140</value> + </param> + <param> + <key>ymax</key> + <value>10</value> + </param> + <param> + <key>nconnections</key> <value>1</value> </param> <param> + <key>update_time</key> + <value>0.10</value> + </param> + <param> + <key>gui_hint</key> + <value>notebook@1</value> + </param> + <param> <key>_coordinate</key> - <value>(597, 142)</value> + <value>(810, 65)</value> </param> <param> <key>_rotation</key> @@ -416,10 +425,10 @@ </param> </block> <block> - <key>qtgui_const_sink_x</key> + <key>digital_dxpsk_mod</key> <param> <key>id</key> - <value>qtgui_const_sink_x_0</value> + <value>digital_dxpsk_mod_0</value> </param> <param> <key>_enabled</key> @@ -427,27 +436,31 @@ </param> <param> <key>type</key> - <value>complex</value> + <value>dqpsk</value> </param> <param> - <key>name</key> - <value>QT GUI Plot</value> + <key>samples_per_symbol</key> + <value>samps_per_sym</value> </param> <param> - <key>size</key> - <value>1024</value> + <key>excess_bw</key> + <value>0.35</value> </param> <param> - <key>nconnections</key> - <value>1</value> + <key>mod_code</key> + <value>"gray"</value> </param> <param> - <key>gui_hint</key> - <value>notebook@0</value> + <key>verbose</key> + <value>False</value> + </param> + <param> + <key>log</key> + <value>False</value> </param> <param> <key>_coordinate</key> - <value>(810, 184)</value> + <value>(361, 119)</value> </param> <param> <key>_rotation</key> @@ -455,10 +468,10 @@ </param> </block> <block> - <key>qtgui_freq_sink_x</key> + <key>blocks_throttle</key> <param> <key>id</key> - <value>qtgui_freq_sink_x_0</value> + <value>blocks_throttle_0</value> </param> <param> <key>_enabled</key> @@ -469,40 +482,55 @@ <value>complex</value> </param> <param> - <key>name</key> - <value>QT GUI Plot</value> + <key>samples_per_second</key> + <value>samp_rate</value> </param> <param> - <key>fftsize</key> - <value>1024</value> + <key>vlen</key> + <value>1</value> </param> <param> - <key>wintype</key> - <value>firdes.WIN_BLACKMAN_hARRIS</value> + <key>_coordinate</key> + <value>(597, 142)</value> </param> <param> - <key>fc</key> + <key>_rotation</key> <value>0</value> </param> + </block> + <block> + <key>channels_channel_model</key> <param> - <key>bw</key> - <value>samp_rate</value> + <key>id</key> + <value>channels_channel_model_0</value> </param> <param> - <key>rate</key> - <value>10</value> + <key>_enabled</key> + <value>True</value> </param> <param> - <key>nconnections</key> - <value>1</value> + <key>noise_voltage</key> + <value>noise</value> </param> <param> - <key>gui_hint</key> - <value>notebook@1</value> + <key>freq_offset</key> + <value>freq_off</value> + </param> + <param> + <key>epsilon</key> + <value>1.0</value> + </param> + <param> + <key>taps</key> + <value>1.0 + 1.0j</value> + </param> + <param> + <key>seed</key> + <value>0</value> </param> <param> <key>_coordinate</key> - <value>(810, 65)</value> + <value>(494, 263)</value> </param> <param> <key>_rotation</key> @@ -516,26 +544,26 @@ <sink_key>0</sink_key> </connection> <connection> - <source_block_id>digital_dxpsk_mod_0</source_block_id> - <sink_block_id>channel_model_0</sink_block_id> + <source_block_id>blocks_throttle_0</source_block_id> + <sink_block_id>qtgui_freq_sink_x_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>channel_model_0</source_block_id> - <sink_block_id>blocks_throttle_0</sink_block_id> + <source_block_id>blocks_throttle_0</source_block_id> + <sink_block_id>qtgui_const_sink_x_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>blocks_throttle_0</source_block_id> - <sink_block_id>qtgui_freq_sink_x_0</sink_block_id> + <source_block_id>digital_dxpsk_mod_0</source_block_id> + <sink_block_id>channels_channel_model_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>blocks_throttle_0</source_block_id> - <sink_block_id>qtgui_const_sink_x_0</sink_block_id> + <source_block_id>channels_channel_model_0</source_block_id> + <sink_block_id>blocks_throttle_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> diff --git a/gr-digital/examples/demod/pam_sync.grc b/gr-digital/examples/demod/pam_sync.grc index 4785482e3f..d8497e423d 100644 --- a/gr-digital/examples/demod/pam_sync.grc +++ b/gr-digital/examples/demod/pam_sync.grc @@ -1,6 +1,6 @@ <?xml version='1.0' encoding='ASCII'?> <flow_graph> - <timestamp>Tue Jan 15 15:21:49 2013</timestamp> + <timestamp>Sun Mar 17 21:08:58 2013</timestamp> <block> <key>options</key> <param> @@ -228,7 +228,7 @@ </param> <param> <key>trig_mode</key> - <value>gr.gr_TRIG_MODE_AUTO</value> + <value>wxgui.TRIG_MODE_AUTO</value> </param> <param> <key>y_axis_label</key> @@ -1054,7 +1054,7 @@ </param> <param> <key>trig_mode</key> - <value>gr.gr_TRIG_MODE_AUTO</value> + <value>wxgui.TRIG_MODE_AUTO</value> </param> <param> <key>y_axis_label</key> diff --git a/gr-digital/examples/demod/pam_timing.grc b/gr-digital/examples/demod/pam_timing.grc index 632477821a..50dd8a1c86 100644 --- a/gr-digital/examples/demod/pam_timing.grc +++ b/gr-digital/examples/demod/pam_timing.grc @@ -519,7 +519,7 @@ </param> <param> <key>trig_mode</key> - <value>gr.gr_TRIG_MODE_AUTO</value> + <value>wxgui.TRIG_MODE_AUTO</value> </param> <param> <key>y_axis_label</key> @@ -594,7 +594,7 @@ </param> <param> <key>trig_mode</key> - <value>gr.gr_TRIG_MODE_AUTO</value> + <value>wxgui.TRIG_MODE_AUTO</value> </param> <param> <key>y_axis_label</key> @@ -669,7 +669,7 @@ </param> <param> <key>trig_mode</key> - <value>gr.gr_TRIG_MODE_AUTO</value> + <value>wxgui.TRIG_MODE_AUTO</value> </param> <param> <key>y_axis_label</key> @@ -744,7 +744,7 @@ </param> <param> <key>trig_mode</key> - <value>gr.gr_TRIG_MODE_AUTO</value> + <value>wxgui.TRIG_MODE_AUTO</value> </param> <param> <key>y_axis_label</key> @@ -819,7 +819,7 @@ </param> <param> <key>trig_mode</key> - <value>gr.gr_TRIG_MODE_AUTO</value> + <value>wxgui.TRIG_MODE_AUTO</value> </param> <param> <key>y_axis_label</key> diff --git a/gr-digital/examples/example_costas.py b/gr-digital/examples/example_costas.py index 726e0756d8..dbb5e42cdf 100755 --- a/gr-digital/examples/example_costas.py +++ b/gr-digital/examples/example_costas.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2011,2012 Free Software Foundation, Inc. +# Copyright 2011-2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -21,6 +21,8 @@ # from gnuradio import gr, digital, filter +from gnuradio import blocks +from gnuradio import channels from gnuradio import eng_notation from gnuradio.eng_option import eng_option from optparse import OptionParser @@ -47,14 +49,14 @@ class example_costas(gr.top_block): data = 2.0*scipy.random.randint(0, 2, N) - 1.0 data = scipy.exp(1j*poffset) * data - self.src = gr.vector_source_c(data.tolist(), False) + self.src = blocks.vector_source_c(data.tolist(), False) self.rrc = filter.interp_fir_filter_ccf(sps, rrc_taps) - self.chn = filter.channel_model(noise, foffset, toffset) + self.chn = channels.channel_model(noise, foffset, toffset) self.cst = digital.costas_loop_cc(bw, 2) - self.vsnk_src = gr.vector_sink_c() - self.vsnk_cst = gr.vector_sink_c() - self.vsnk_frq = gr.vector_sink_f() + self.vsnk_src = blocks.vector_sink_c() + self.vsnk_cst = blocks.vector_sink_c() + self.vsnk_frq = blocks.vector_sink_f() self.connect(self.src, self.rrc, self.chn, self.cst, self.vsnk_cst) self.connect(self.rrc, self.vsnk_src) diff --git a/gr-digital/examples/example_fll.py b/gr-digital/examples/example_fll.py index ef6e1b1658..4fb12f5aae 100755 --- a/gr-digital/examples/example_fll.py +++ b/gr-digital/examples/example_fll.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2011,2012 Free Software Foundation, Inc. +# Copyright 2011-2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -21,6 +21,8 @@ # from gnuradio import gr, digital, filter +from gnuradio import blocks +from gnuradio import channels from gnuradio import eng_notation from gnuradio.eng_option import eng_option from optparse import OptionParser @@ -47,16 +49,16 @@ class example_fll(gr.top_block): data = 2.0*scipy.random.randint(0, 2, N) - 1.0 data = scipy.exp(1j*poffset) * data - self.src = gr.vector_source_c(data.tolist(), False) + self.src = blocks.vector_source_c(data.tolist(), False) self.rrc = filter.interp_fir_filter_ccf(sps, rrc_taps) - self.chn = filter.channel_model(noise, foffset, toffset) + self.chn = channels.channel_model(noise, foffset, toffset) self.fll = digital.fll_band_edge_cc(sps, rolloff, ntaps, bw) - self.vsnk_src = gr.vector_sink_c() - self.vsnk_fll = gr.vector_sink_c() - self.vsnk_frq = gr.vector_sink_f() - self.vsnk_phs = gr.vector_sink_f() - self.vsnk_err = gr.vector_sink_f() + self.vsnk_src = blocks.vector_sink_c() + self.vsnk_fll = blocks.vector_sink_c() + self.vsnk_frq = blocks.vector_sink_f() + self.vsnk_phs = blocks.vector_sink_f() + self.vsnk_err = blocks.vector_sink_f() self.connect(self.src, self.rrc, self.chn, self.fll, self.vsnk_fll) self.connect(self.rrc, self.vsnk_src) diff --git a/gr-digital/examples/example_timing.py b/gr-digital/examples/example_timing.py index d51aebb31d..73a05b05dc 100755 --- a/gr-digital/examples/example_timing.py +++ b/gr-digital/examples/example_timing.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2011,2012 Free Software Foundation, Inc. +# Copyright 2011-2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -21,6 +21,8 @@ # from gnuradio import gr, digital, filter +from gnuradio import blocks +from gnuradio import channels from gnuradio import eng_notation from gnuradio.eng_option import eng_option from optparse import OptionParser @@ -55,9 +57,9 @@ class example_timing(gr.top_block): data = 2.0*scipy.random.randint(0, 2, N) - 1.0 data = scipy.exp(1j*poffset) * data - self.src = gr.vector_source_c(data.tolist(), False) + self.src = blocks.vector_source_c(data.tolist(), False) self.rrc = filter.interp_fir_filter_ccf(sps, rrc_taps) - self.chn = filter.channel_model(noise, foffset, toffset) + self.chn = channels.channel_model(noise, foffset, toffset) self.off = filter.fractional_interpolator_cc(0.20, 1.0) if mode == 0: @@ -66,9 +68,9 @@ class example_timing(gr.top_block): self.taps = self.clk.taps() self.dtaps = self.clk.diff_taps() - self.vsnk_err = gr.vector_sink_f() - self.vsnk_rat = gr.vector_sink_f() - self.vsnk_phs = gr.vector_sink_f() + self.vsnk_err = blocks.vector_sink_f() + self.vsnk_rat = blocks.vector_sink_f() + self.vsnk_phs = blocks.vector_sink_f() self.connect((self.clk,1), self.vsnk_err) self.connect((self.clk,2), self.vsnk_rat) @@ -83,12 +85,12 @@ class example_timing(gr.top_block): mu, gain_mu, omega_rel_lim) - self.vsnk_err = gr.vector_sink_f() + self.vsnk_err = blocks.vector_sink_f() self.connect((self.clk,1), self.vsnk_err) - self.vsnk_src = gr.vector_sink_c() - self.vsnk_clk = gr.vector_sink_c() + self.vsnk_src = blocks.vector_sink_c() + self.vsnk_clk = blocks.vector_sink_c() self.connect(self.src, self.rrc, self.chn, self.off, self.clk, self.vsnk_clk) self.connect(self.off, self.vsnk_src) diff --git a/gr-digital/examples/gen_whitener.py b/gr-digital/examples/gen_whitener.py index 0b1591c3ab..63616605ba 100755 --- a/gr-digital/examples/gen_whitener.py +++ b/gr-digital/examples/gen_whitener.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2011 Free Software Foundation, Inc. +# Copyright 2011,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -21,6 +21,7 @@ # from gnuradio import gr, gru +from gnuradio import blocks from gnuradio.eng_option import eng_option from optparse import OptionParser import sys @@ -36,9 +37,9 @@ class my_graph(gr.top_block): parser.print_help() raise SystemExit, 1 - src = gr.lfsr_32k_source_s() - head = gr.head(gr.sizeof_short, 2048) - self.dst = gr.vector_sink_s() + src = blocks.lfsr_32k_source_s() + head = blocks.head(gr.sizeof_short, 2048) + self.dst = blocks.vector_sink_s() self.connect(src, head, self.dst) if __name__ == '__main__': diff --git a/gr-digital/examples/narrowband/benchmark_rx.py b/gr-digital/examples/narrowband/benchmark_rx.py index ce47bf87b8..622773aac5 100755 --- a/gr-digital/examples/narrowband/benchmark_rx.py +++ b/gr-digital/examples/narrowband/benchmark_rx.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2010,2011 Free Software Foundation, Inc. +# Copyright 2010,2011,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -61,7 +61,7 @@ class my_top_block(gr.top_block): self.source = blocks.file_source(gr.sizeof_gr_complex, options.from_file) else: sys.stderr.write("No source defined, pulling samples from null source.\n\n") - self.source = gr.null_source(gr.sizeof_gr_complex) + self.source = blocks.null_source(gr.sizeof_gr_complex) # Set up receive path # do this after for any adjustments to the options that may diff --git a/gr-digital/examples/narrowband/benchmark_tx.py b/gr-digital/examples/narrowband/benchmark_tx.py index 593abb3cae..11ad7ea26e 100755 --- a/gr-digital/examples/narrowband/benchmark_tx.py +++ b/gr-digital/examples/narrowband/benchmark_tx.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2010,2011 Free Software Foundation, Inc. +# Copyright 2010,2011,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -60,7 +60,7 @@ class my_top_block(gr.top_block): self.sink = blocks.file_sink(gr.sizeof_gr_complex, options.to_file) else: sys.stderr.write("No sink defined, dumping samples to null sink.\n\n") - self.sink = gr.null_sink(gr.sizeof_gr_complex) + self.sink = blocks.null_sink(gr.sizeof_gr_complex) # do this after for any adjustments to the options that may # occur in the sinks (specifically the UHD sink) diff --git a/gr-digital/examples/narrowband/digital_bert_rx.py b/gr-digital/examples/narrowband/digital_bert_rx.py index cf42742736..c04c76762f 100755 --- a/gr-digital/examples/narrowband/digital_bert_rx.py +++ b/gr-digital/examples/narrowband/digital_bert_rx.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2008,2011 Free Software Foundation, Inc. +# Copyright 2008,2011,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -127,7 +127,7 @@ class rx_psk_block(gr.top_block): elif(options.from_file is not None): self._source = blocks.file_source(gr.sizeof_gr_complex, options.from_file) else: - self._source = gr.null_source(gr.sizeof_gr_complex) + self._source = blocks.null_source(gr.sizeof_gr_complex) # Create the BERT receiver self._receiver = bert_receiver(options.bitrate, diff --git a/gr-digital/examples/narrowband/digital_bert_tx.py b/gr-digital/examples/narrowband/digital_bert_tx.py index 2a99137704..6859d2e7af 100755 --- a/gr-digital/examples/narrowband/digital_bert_tx.py +++ b/gr-digital/examples/narrowband/digital_bert_tx.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2008,2011 Free Software Foundation, Inc. +# Copyright 2008,2011,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -43,7 +43,7 @@ class bert_transmit(gr.hier_block2): gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Input signature # Create BERT data bit stream - self._bits = gr.vector_source_b([1,], True) # Infinite stream of ones + self._bits = blocks.vector_source_b([1,], True) # Infinite stream of ones self._scrambler = digital.scrambler_bb(0x8A, 0x7F, 7) # CCSDS 7-bit scrambler self._mod = digital.generic_mod(constellation, differential, @@ -80,7 +80,7 @@ class tx_psk_block(gr.top_block): elif(options.to_file is not None): self._sink = blocks.file_sink(gr.sizeof_gr_complex, options.to_file) else: - self._sink = gr.null_sink(gr.sizeof_gr_complex) + self._sink = blocks.null_sink(gr.sizeof_gr_complex) self._transmitter = bert_transmit(self._modulator._constellation, diff --git a/gr-digital/examples/narrowband/rx_voice.py b/gr-digital/examples/narrowband/rx_voice.py index b2b4174cc4..8a0e9844be 100755 --- a/gr-digital/examples/narrowband/rx_voice.py +++ b/gr-digital/examples/narrowband/rx_voice.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2005,2006,2009,2011 Free Software Foundation, Inc. +# Copyright 2005,2006,2009,2011,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -89,7 +89,7 @@ class my_top_block(gr.top_block): else: self.thr = blocks.throttle(gr.sizeof_gr_complex, 1e6) - self.source = gr.null_source(gr.sizeof_gr_complex) + self.source = blocks.null_source(gr.sizeof_gr_complex) self.connect(self.source, self.thr, self.rxpath) self.connect(self.audio_tx) diff --git a/gr-digital/examples/narrowband/tx_voice.py b/gr-digital/examples/narrowband/tx_voice.py index d3df9d788f..afdb4406e6 100755 --- a/gr-digital/examples/narrowband/tx_voice.py +++ b/gr-digital/examples/narrowband/tx_voice.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2005-2007,2009,2011 Free Software Foundation, Inc. +# Copyright 2005-2007,2009,2011,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -83,7 +83,7 @@ class my_top_block(gr.top_block): self.sink = blocks.file_sink(gr.sizeof_gr_complex, options.to_file) rrate = 1 else: - self.sink = gr.null_sink(gr.sizeof_gr_complex) + self.sink = blocks.null_sink(gr.sizeof_gr_complex) rrate = 1 self.resampler = filter.pfb.arb_resampler_ccf(rrate) diff --git a/gr-digital/examples/ofdm/benchmark_rx.py b/gr-digital/examples/ofdm/benchmark_rx.py index 740e0aed0e..dbcd866ad2 100755 --- a/gr-digital/examples/ofdm/benchmark_rx.py +++ b/gr-digital/examples/ofdm/benchmark_rx.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2006,2007,2011 Free Software Foundation, Inc. +# Copyright 2006,2007,2011,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -47,7 +47,7 @@ class my_top_block(gr.top_block): elif(options.from_file is not None): self.source = blocks.file_source(gr.sizeof_gr_complex, options.from_file) else: - self.source = gr.null_source(gr.sizeof_gr_complex) + self.source = blocks.null_source(gr.sizeof_gr_complex) # Set up receive path # do this after for any adjustments to the options that may diff --git a/gr-digital/examples/ofdm/benchmark_tx.py b/gr-digital/examples/ofdm/benchmark_tx.py index 44b127e0cc..2942178ccf 100755 --- a/gr-digital/examples/ofdm/benchmark_tx.py +++ b/gr-digital/examples/ofdm/benchmark_tx.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2005,2006,2011 Free Software Foundation, Inc. +# Copyright 2005,2006,2011,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -46,7 +46,7 @@ class my_top_block(gr.top_block): elif(options.to_file is not None): self.sink = blocks.file_sink(gr.sizeof_gr_complex, options.to_file) else: - self.sink = gr.null_sink(gr.sizeof_gr_complex) + self.sink = blocks.null_sink(gr.sizeof_gr_complex) # do this after for any adjustments to the options that may # occur in the sinks (specifically the UHD sink) diff --git a/gr-digital/examples/ofdm/rx_ofdm.grc b/gr-digital/examples/ofdm/rx_ofdm.grc index 1541e8dedf..47e165508c 100644 --- a/gr-digital/examples/ofdm/rx_ofdm.grc +++ b/gr-digital/examples/ofdm/rx_ofdm.grc @@ -689,10 +689,10 @@ </param> </block> <block> - <key>gr_null_sink</key> + <key>blocks_null_sink</key> <param> <key>id</key> - <value>gr_null_sink_0</value> + <value>blocks_null_sink_0</value> </param> <param> <key>_enabled</key> @@ -1067,7 +1067,7 @@ </connection> <connection> <source_block_id>digital_constellation_decoder_cb_0</source_block_id> - <sink_block_id>gr_null_sink_0</sink_block_id> + <sink_block_id>blocks_null_sink_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> diff --git a/gr-digital/examples/ofdm/tx_ofdm.grc b/gr-digital/examples/ofdm/tx_ofdm.grc index 6c4f9797d1..a2deb05f9f 100644 --- a/gr-digital/examples/ofdm/tx_ofdm.grc +++ b/gr-digital/examples/ofdm/tx_ofdm.grc @@ -414,10 +414,10 @@ </param> </block> <block> - <key>gr_vector_source_x</key> + <key>blocks_vector_source_x</key> <param> <key>id</key> - <value>gr_vector_source_x_1</value> + <value>blocks_vector_source_x_1</value> </param> <param> <key>_enabled</key> @@ -709,7 +709,7 @@ </param> </block> <block> - <key>gr_vector_source_x</key> + <key>blocks_vector_source_x</key> <param> <key>id</key> <value>sync_word_source</value> @@ -952,10 +952,10 @@ </param> </block> <block> - <key>gr_null_sink</key> + <key>blocks_null_sink</key> <param> <key>id</key> - <value>gr_null_sink_0</value> + <value>blocks_null_sink_0</value> </param> <param> <key>_enabled</key> @@ -1045,7 +1045,7 @@ </param> </block> <connection> - <source_block_id>gr_vector_source_x_1</source_block_id> + <source_block_id>blocks_vector_source_x_1</source_block_id> <sink_block_id>blocks_throttle_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> @@ -1130,7 +1130,7 @@ </connection> <connection> <source_block_id>digital_ofdm_cyclic_prefixer_0</source_block_id> - <sink_block_id>gr_null_sink_0</sink_block_id> + <sink_block_id>blocks_null_sink_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> diff --git a/gr-digital/examples/snr_estimators.py b/gr-digital/examples/snr_estimators.py index e310ec2937..9eae7865e5 100755 --- a/gr-digital/examples/snr_estimators.py +++ b/gr-digital/examples/snr_estimators.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2011,2012 Free Software Foundation, Inc. +# Copyright 2011-2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -36,6 +36,8 @@ except ImportError: sys.exit(1) from gnuradio import gr, digital, filter +from gnuradio import blocks +from gnuradio import channels from optparse import OptionParser from gnuradio.eng_option import eng_option @@ -165,10 +167,10 @@ def main(): snrdB, snr = py_est(yy) snr_python.append(snrdB) - gr_src = gr.vector_source_c(bits.tolist(), False) + gr_src = blocks.vector_source_c(bits.tolist(), False) gr_snr = digital.mpsk_snr_est_cc(gr_est, ntag, 0.001) - gr_chn = filter.channel_model(1.0/scale) - gr_snk = gr.null_sink(gr.sizeof_gr_complex) + gr_chn = channels.channel_model(1.0/scale) + gr_snk = blocks.null_sink(gr.sizeof_gr_complex) tb = gr.top_block() tb.connect(gr_src, gr_chn, gr_snr, gr_snk) tb.run() diff --git a/gr-digital/include/digital/CMakeLists.txt b/gr-digital/include/digital/CMakeLists.txt index 0531e837d5..3babcbad44 100644 --- a/gr-digital/include/digital/CMakeLists.txt +++ b/gr-digital/include/digital/CMakeLists.txt @@ -89,6 +89,7 @@ install(FILES costas_loop_cc.h cpmmod_bc.h crc32.h + crc32_bb.h descrambler_bb.h diff_decoder_bb.h diff_encoder_bb.h @@ -107,7 +108,12 @@ install(FILES mpsk_receiver_cc.h mpsk_snr_est.h mpsk_snr_est_cc.h + ofdm_carrier_allocator_cvc.h + ofdm_chanest_vcvc.h ofdm_cyclic_prefixer.h + ofdm_equalizer_base.h + ofdm_equalizer_simpledfe.h + ofdm_equalizer_static.h ofdm_frame_acquisition.h ofdm_frame_equalizer_vcvc.h ofdm_frame_sink.h @@ -115,6 +121,7 @@ install(FILES ofdm_mapper_bcv.h ofdm_sampler.h ofdm_serializer_vcc.h + ofdm_sync_sc_cfb.h packet_header_default.h packet_header_ofdm.h packet_headergenerator_bb.h @@ -133,3 +140,4 @@ install(FILES DESTINATION ${GR_INCLUDE_DIR}/gnuradio/digital COMPONENT "digital_devel" ) + diff --git a/gr-digital/include/digital/costas_loop_cc.h b/gr-digital/include/digital/costas_loop_cc.h index bad6de9363..252f39914a 100644 --- a/gr-digital/include/digital/costas_loop_cc.h +++ b/gr-digital/include/digital/costas_loop_cc.h @@ -24,6 +24,7 @@ #define INCLUDED_DIGITAL_COSTAS_LOOP_CC_H #include <digital/api.h> +#include <blocks/control_loop.h> #include <gr_sync_block.h> namespace gr { @@ -54,7 +55,9 @@ namespace gr { * stream 1 is the baseband I and Q; * stream 2 is the normalized frequency of the loop */ - class DIGITAL_API costas_loop_cc : virtual public gr_sync_block + class DIGITAL_API costas_loop_cc + : virtual public gr_sync_block, + virtual public blocks::control_loop { public: // gr::digital::costas_loop_cc::sptr diff --git a/gr-digital/include/digital/crc32_bb.h b/gr-digital/include/digital/crc32_bb.h new file mode 100644 index 0000000000..4bfac76070 --- /dev/null +++ b/gr-digital/include/digital/crc32_bb.h @@ -0,0 +1,60 @@ +/* -*- c++ -*- */ +/* + * Copyright 2013 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_DIGITAL_CRC32_BB_H +#define INCLUDED_DIGITAL_CRC32_BB_H + +#include <digital/api.h> +#include <gr_tagged_stream_block.h> + +namespace gr { + namespace digital { + + /*! + * \brief Byte-stream CRC block + * \ingroup digital + * + * Input: stream of bytes, which form a packet. The first byte of the packet + * has a tag with key "length" and the value being the number of bytes in the + * packet. + * + * Output: The same bytes as incoming, but trailing a CRC32 of the packet. + * The tag is re-set to the new length. + */ + class DIGITAL_API crc32_bb : virtual public gr_tagged_stream_block + { + public: + typedef boost::shared_ptr<crc32_bb> sptr; + + /*! + * \param check Set to true if you want to check CRC, false to create CRC. + * \param lengthtagname Length tag key + */ + static sptr make(bool check=false, const std::string& lengthtagname="packet_len"); + }; + + } // namespace digital +} // namespace gr + +#endif /* INCLUDED_DIGITAL_CRC32_BB_H */ + diff --git a/gr-digital/include/digital/ofdm_carrier_allocator_cvc.h b/gr-digital/include/digital/ofdm_carrier_allocator_cvc.h new file mode 100644 index 0000000000..8915c23c45 --- /dev/null +++ b/gr-digital/include/digital/ofdm_carrier_allocator_cvc.h @@ -0,0 +1,95 @@ +/* -*- c++ -*- */ +/* + * Copyright 2013 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_DIGITAL_OFDM_CARRIER_ALLOCATOR_CVC_H +#define INCLUDED_DIGITAL_OFDM_CARRIER_ALLOCATOR_CVC_H + +#include <digital/api.h> +#include <gr_tagged_stream_block.h> + +namespace gr { + namespace digital { + + /*! + * \brief Create frequency domain OFDM symbols from complex values, add pilots. + * \ingroup ofdm_blk + * + * This block turns a stream of complex, scalar modulation symbols into vectors + * which are the input for an IFFT in an OFDM transmitter. It also supports the + * possibility of placing pilot symbols onto the carriers. + * + * The carriers can be allocated freely, if a carrier is not allocated, it is set + * to zero. This allows doing OFDMA-style carrier allocations. + * + * Input: A tagged stream of complex scalars. The first item must have a tag + * containing the number of complex symbols in this frame. + * Output: A tagged stream of complex vectors of length fft_len. This can directly + * be connected to an FFT block. Make sure to set this block to 'reverse' + * for the IFFT and to deactivate FFT shifting. + * + * Carrier indexes are always such that index 0 is the DC carrier (note: you should + * not allocate this carrier). The carriers below the DC carrier are either indexed + * with negative numbers, or with indexes larger than fft_len/2. Index -1 and index + * fft_len-1 both identify the carrier below the DC carrier. + * + */ + class DIGITAL_API ofdm_carrier_allocator_cvc : virtual public gr_tagged_stream_block + { + public: + typedef boost::shared_ptr<ofdm_carrier_allocator_cvc> sptr; + + virtual std::string len_tag_key() = 0; + virtual const int fft_len() = 0; + virtual std::vector<std::vector<int> > occupied_carriers() = 0; + + /* + * \param occupied_carriers A vector of vectors of indexes. Example: if + * occupied_carriers = ((1, 2, 3), (1, 2, 4)), the first + * three input symbols will be mapped to carriers 1, 2 + * and 3. After that, a new OFDM symbol is started. The next + * three input symbols will be placed onto carriers 1, 2 + * and 4 of the second OFDM symbol. The allocation then + * starts from the beginning. + * Order matters! The first input symbol is always mapped + * onto occupied_carriers[0][0]. + * \param pilot_carriers The position of the pilot symbols. Same as occupied_carriers, + * but the actual symbols are taken from pilot_symbols instead + * of the input stream. + * \param pilot_symbols The pilot symbols which are placed onto the pilot carriers. + * pilot_symbols[0][0] is placed onto the first OFDM symbol, on + * carrier index pilot_carriers[0][0] etc. + * \param len_tag_key The key of the tag identifying the length of the input packet. + */ + static sptr make( + int fft_len, + const std::vector<std::vector<int> > &occupied_carriers, + const std::vector<std::vector<int> > &pilot_carriers, + const std::vector<std::vector<gr_complex> > &pilot_symbols, + const std::string &len_tag_key = "packet_len"); + }; + + } // namespace digital +} // namespace gr + +#endif /* INCLUDED_DIGITAL_OFDM_CARRIER_ALLOCATOR_CVC_H */ + diff --git a/gr-digital/include/digital/ofdm_chanest_vcvc.h b/gr-digital/include/digital/ofdm_chanest_vcvc.h new file mode 100644 index 0000000000..0c29d630da --- /dev/null +++ b/gr-digital/include/digital/ofdm_chanest_vcvc.h @@ -0,0 +1,95 @@ +/* -*- c++ -*- */ +/* + * Copyright 2013 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_DIGITAL_OFDM_CHANEST_VCVC_H +#define INCLUDED_DIGITAL_OFDM_CHANEST_VCVC_H + +#include <digital/api.h> +#include <gr_block.h> + +namespace gr { + namespace digital { + + /*! + * \brief Estimate channel and coarse frequency offset for OFDM from preambles + * \ingroup ofdm_blk + * \ingroup sync_blk + * + * Input: OFDM symbols (in frequency domain). The first one (or two) symbols are expected + * to be synchronisation symbols, which are used to estimate the coarse freq offset + * and the initial equalizer taps (these symbols are removed from the stream). + * The following \p n_data_symbols are passed through unmodified (the actual equalisation + * must be done elsewhere). + * Output: The data symbols, without the synchronisation symbols. + * The first data symbol passed through has two tags: + * 'ofdm_sync_carr_offset' (integer), the coarse frequency offset as number of carriers, + * and 'ofdm_sync_eq_taps' (complex vector). + * Any tags attached to the synchronisation symbols are attached to the first data + * symbol. All other tags are propagated normally. + * + * This block assumes the frequency offset is even (i.e. an integer multiple of 2). + * + * [1] Schmidl, T.M. and Cox, D.C., "Robust frequency and timing synchronization for OFDM", + * Communications, IEEE Transactions on, 1997. + * [2] K.D. Kammeyer, "Nachrichtenuebertragung," Chapter. 16.3.2. + */ + class DIGITAL_API ofdm_chanest_vcvc : virtual public gr_block + { + public: + typedef boost::shared_ptr<ofdm_chanest_vcvc> sptr; + + /* + * \param sync_symbol1 First synchronisation symbol in the frequency domain. Its length must be + * the FFT length. For Schmidl & Cox synchronisation, every second sub-carrier + * has to be zero. + * \param sync_symbol2 Second synchronisation symbol in the frequency domain. Must be equal to + * the FFT length, or zero length if only one synchronisation symbol is used. + * Using this symbol is how synchronisation is described in [1]. Leaving this + * empty forces us to interpolate the equalizer taps. + * If you are using an unusual sub-carrier configuration (e.g. because of OFDMA), + * this sync symbol is used to identify the active sub-carriers. If you only + * have one synchronisation symbol, set the active sub-carriers to a non-zero + * value in here, and also set \p force_one_sync_symbol parameter to true. + * \param n_data_symbols The number of data symbols following each set of synchronisation symbols. + * Must be at least 1. + * \param eq_noise_red_len If non-zero, noise reduction for the equalizer taps is done according + * to [2]. In this case, it is the channel influence time in number of + * samples. A good value is usually the length of the cyclic prefix. + * \param max_carr_offset Limit the number of sub-carriers the frequency offset can maximally be. + * Leave this zero to try all possibilities. + * \param force_one_sync_symbol See \p sync_symbol2. + */ + static sptr make( + const std::vector<gr_complex> &sync_symbol1, + const std::vector<gr_complex> &sync_symbol2, + int n_data_symbols, + int eq_noise_red_len=0, + int max_carr_offset=-1, + bool force_one_sync_symbol=false + ); + }; + + } // namespace digital +} // namespace gr + +#endif /* INCLUDED_DIGITAL_OFDM_CHANEST_VCVC_H */ + diff --git a/gr-digital/include/digital/ofdm_cyclic_prefixer.h b/gr-digital/include/digital/ofdm_cyclic_prefixer.h index 551d1ee834..6292d62697 100644 --- a/gr-digital/include/digital/ofdm_cyclic_prefixer.h +++ b/gr-digital/include/digital/ofdm_cyclic_prefixer.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ -/* - * Copyright 2004-2006,2011,2012 Free Software Foundation, Inc. +/* + * Copyright 2013 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -24,34 +24,48 @@ #define INCLUDED_DIGITAL_OFDM_CYCLIC_PREFIXER_H #include <digital/api.h> -#include <gr_sync_interpolator.h> +#include <gr_tagged_stream_block.h> namespace gr { namespace digital { - + /*! - * \brief adds a cyclic prefix vector to an input size long ofdm - * symbol(vector) and converts vector to a stream output_size - * long. + * \brief Adds a cyclic prefix and performs pulse shaping on OFDM symbols. * \ingroup ofdm_blk + * + * Input: OFDM symbols (in the time domain, i.e. after the IFFT). Optionally, + * entire frames can be processed. In this case, \p len_tag_key must be + * specified which holds the key of the tag that denotes how + * many OFDM symbols are in a frame. + * Output: A stream of (scalar) complex symbols, which include the cyclic prefix + * and the pulse shaping. + * Note: If complete frames are processed, and \p rolloff_len is greater + * than zero, the final OFDM symbol is followed by the delay line of + * the pulse shaping. + * + * The pulse shape is a raised cosine in the time domain. */ - class DIGITAL_API ofdm_cyclic_prefixer : virtual public gr_sync_interpolator + class DIGITAL_API ofdm_cyclic_prefixer : virtual public gr_tagged_stream_block { - public: - // gr::digital::ofdm_cyclic_prefixer::sptr + public: typedef boost::shared_ptr<ofdm_cyclic_prefixer> sptr; /*! - * Make an OFDM cyclic prefix adder block. - * - * \param input_size size of the input symbol - * \param output_size output of the symbol - * (CP len = output_size - input_size) + * \param input_size FFT length (i.e. length of the OFDM symbols) + * \param output_size FFT length + cyclic prefix length (in samples) + * \param rolloff_len Length of the rolloff flank in samples + * \param len_tag_key For framed processing the key of the length tag */ - static sptr make(size_t input_size, size_t output_size); + static sptr make( + size_t input_size, + size_t output_size, + int rolloff_len=0, + const std::string &len_tag_key="" + ); }; - } /* namespace digital */ -} /* namespace gr */ + } // namespace digital +} // namespace gr #endif /* INCLUDED_DIGITAL_OFDM_CYCLIC_PREFIXER_H */ + diff --git a/gr-digital/include/digital/ofdm_equalizer_base.h b/gr-digital/include/digital/ofdm_equalizer_base.h new file mode 100644 index 0000000000..0e23eb381f --- /dev/null +++ b/gr-digital/include/digital/ofdm_equalizer_base.h @@ -0,0 +1,109 @@ +/* -*- c++ -*- */ +/* Copyright 2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_DIGITAL_OFDM_EQUALIZER_BASE_H +#define INCLUDED_DIGITAL_OFDM_EQUALIZER_BASE_H + +#include <digital/api.h> +#include <gr_tags.h> +#include <gr_complex.h> +#include <boost/enable_shared_from_this.hpp> + +namespace gr { + namespace digital { + + /* \brief Base class for implementation details of frequency-domain OFDM equalizers. + * \ingroup ofdm_blk + * \ingroup eq_blk + */ + class DIGITAL_API ofdm_equalizer_base + : public boost::enable_shared_from_this<ofdm_equalizer_base> + { + protected: + int d_fft_len; + int d_carr_offset; + + public: + typedef boost::shared_ptr<ofdm_equalizer_base> sptr; + + ofdm_equalizer_base(int fft_len); + ~ofdm_equalizer_base(); + + //! Reset the channel information state knowledge + virtual void reset() = 0; + //! Set the carrier offset in integer multiples + void set_carrier_offset(int offset) { d_carr_offset = offset; }; + virtual void equalize( + gr_complex *frame, + int n_sym, + const std::vector<gr_complex> &initial_taps = std::vector<gr_complex>(), + const std::vector<gr_tag_t> &tags = std::vector<gr_tag_t>()) = 0; + //! Return the current channel state + virtual void get_channel_state(std::vector<gr_complex> &taps) = 0; + int fft_len() { return d_fft_len; }; + sptr base() { return shared_from_this(); }; + }; + + + /* \brief Base class for implementation details of 1-dimensional OFDM FDEs which use pilot tones. + * \ingroup digital + * + */ + class DIGITAL_API ofdm_equalizer_1d_pilots : public ofdm_equalizer_base + { + protected: + //! If \p d_occupied_carriers[k][l] is true, symbol k, carrier l is carrying data. + // (this is a different format than occupied_carriers!) + std::vector<bool> d_occupied_carriers; + //! If \p d_pilot_carriers[k][l] is true, symbol k, carrier l is carrying data. + // (this is a different format than pilot_carriers!) + std::vector<std::vector<bool> > d_pilot_carriers; + //! If \p d_pilot_carriers[k][l] is true, d_pilot_symbols[k][l] is its tx'd value. + // (this is a different format than pilot_symbols!) + std::vector<std::vector<gr_complex> > d_pilot_symbols; + //! In case the frame doesn't begin with OFDM symbol 0, this is the index of the first symbol + int d_symbols_skipped; + //! The current position in the set of pilot symbols + int d_pilot_carr_set; + //! Vector of length d_fft_len saving the current channel state (on the occupied carriers) + std::vector<gr_complex> d_channel_state; + + public: + typedef boost::shared_ptr<ofdm_equalizer_1d_pilots> sptr; + + ofdm_equalizer_1d_pilots( + int fft_len, + const std::vector<std::vector<int> > &occupied_carriers, + const std::vector<std::vector<int> > &pilot_carriers, + const std::vector<std::vector<gr_complex> > &pilot_symbols, + int symbols_skipped, + bool input_is_shifted); + ~ofdm_equalizer_1d_pilots(); + + void reset(); + void get_channel_state(std::vector<gr_complex> &taps); + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_DIGITAL_OFDM_EQUALIZER_BASE_H */ + diff --git a/gr-digital/include/digital/ofdm_equalizer_simpledfe.h b/gr-digital/include/digital/ofdm_equalizer_simpledfe.h new file mode 100644 index 0000000000..9d286576bc --- /dev/null +++ b/gr-digital/include/digital/ofdm_equalizer_simpledfe.h @@ -0,0 +1,130 @@ +/* -*- c++ -*- */ +/* Copyright 2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_DIGITAL_OFDM_EQUALIZER_SIMPLEDFE_H +#define INCLUDED_DIGITAL_OFDM_EQUALIZER_SIMPLEDFE_H + +#include <digital/api.h> +#include <digital/constellation.h> +#include <digital/ofdm_equalizer_base.h> + +namespace gr { + namespace digital { + + /* \brief Simple decision feedback equalizer for OFDM. + * \ingroup ofdm_blk + * \ingroup eq_blk + * + * Equalizes an OFDM signal symbol by symbol using knowledge of the + * complex modulations symbols. + * For every symbol, the following steps are performed: + * - On every sub-carrier, decode the modulation symbol + * - Use the difference between the decoded symbol and the received symbol + * to update the channel state on this carrier + * - Whenever a pilot symbol is found, it uses the known pilot symbol to + * update the channel state. + * + * This equalizer makes a lot of assumptions: + * - The initial channel state is good enough to decode the first + * symbol without error (unless the first symbol only consists of pilot + * tones) + * - The channel changes only very slowly, such that the channel state + * from one symbol is enough to decode the next + * - SNR low enough that equalization will always suffice to correctly + * decode a symbol + * If these assumptions are not met, the most common error is that the + * channel state is estimated incorrectly during equalization; after that, + * all subsequent symbols will be completely wrong. + * + * Note that the equalized symbols are *exact points* on the constellation. + * This means soft information of the modulation symbols is lost after the + * equalization, which is suboptimal for channel codes that use soft decision. + * + */ + class DIGITAL_API ofdm_equalizer_simpledfe : public ofdm_equalizer_1d_pilots + { + public: + typedef boost::shared_ptr<ofdm_equalizer_simpledfe> sptr; + + ofdm_equalizer_simpledfe( + int fft_len, + const gr::digital::constellation_sptr &constellation, + const std::vector<std::vector<int> > &occupied_carriers = std::vector<std::vector<int> >(), + const std::vector<std::vector<int> > &pilot_carriers = std::vector<std::vector<int> >(), + const std::vector<std::vector<gr_complex> > &pilot_symbols = std::vector<std::vector<gr_complex> >(), + int symbols_skipped = 0, + float alpha = 0.1, + bool input_is_shifted = true); + + ~ofdm_equalizer_simpledfe(); + + void equalize(gr_complex *frame, + int n_sym, + const std::vector<gr_complex> &initial_taps = std::vector<gr_complex>(), + const std::vector<gr_tag_t> &tags = std::vector<gr_tag_t>()); + + /* + * \param fft_len FFT length + * \param constellation The constellation object describing the modulation used + * on the subcarriers (e.g. QPSK). This is used to decode + * the individual symbols. + * \param occupied_carriers List of occupied carriers, see ofdm_carrier_allocator + * for a description. + * \param pilot_carriers Position of pilot symbols, see ofdm_carrier_allocator + * for a description. + * \param pilot_symbols Value of pilot symbols, see ofdm_carrier_allocator + * for a description. + * \param alpha Averaging coefficient (in a nutshell, if \f$H_{i,k}\f$ is the channel + * state for carrier i and symbol k, + * \f$H_{i,k+1} = \alpha H_{i,k} + (1 - \alpha) H_{i,k+1}\f$. Make this + * larger if there's more noise, but keep in mind that larger values + * of alpha mean slower response to channel changes). + * \param symbols_skipped Starting position within occupied_carriers and pilot_carriers. + * If the first symbol of the frame was removed (e.g. to decode the + * header), set this make sure the pilot symbols are correctly + * identified. + * \param input_is_shifted Set this to false if the input signal is not shifted, i.e. + * the first input items is on the DC carrier. + * Note that a lot of the OFDM receiver blocks operate on shifted + * signals! + */ + static sptr make( + int fft_len, + const gr::digital::constellation_sptr &constellation, + const std::vector<std::vector<int> > &occupied_carriers = std::vector<std::vector<int> >(), + const std::vector<std::vector<int> > &pilot_carriers = std::vector<std::vector<int> >(), + const std::vector<std::vector<gr_complex> > &pilot_symbols = std::vector<std::vector<gr_complex> >(), + int symbols_skipped=0, + float alpha=0.1, + bool input_is_shifted=true + ); + + private: + gr::digital::constellation_sptr d_constellation; + //! Averaging coefficient + float d_alpha; + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_DIGITAL_OFDM_EQUALIZER_SIMPLEDFE_H */ + diff --git a/gr-digital/include/digital/ofdm_equalizer_static.h b/gr-digital/include/digital/ofdm_equalizer_static.h new file mode 100644 index 0000000000..67586be6fb --- /dev/null +++ b/gr-digital/include/digital/ofdm_equalizer_static.h @@ -0,0 +1,100 @@ +/* -*- c++ -*- */ +/* Copyright 2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_DIGITAL_OFDM_EQUALIZER_STATIC_H +#define INCLUDED_DIGITAL_OFDM_EQUALIZER_STATIC_H + +#include <digital/api.h> +#include <digital/constellation.h> +#include <digital/ofdm_equalizer_base.h> + +namespace gr { + namespace digital { + + /* \brief Very simple static equalizer for OFDM. + * \ingroup ofdm_blk + * \ingroup eq_blk + * + * This is an extremely simple equalizer. It will only work for high-SNR, very, very + * slowly changing channels. + * It simply divides the signal with the currently known channel state. Whenever + * a pilot symbol comes around, it updates the channel state on that particular + * carrier by dividing the received symbol with the known pilot symbol. + */ + class DIGITAL_API ofdm_equalizer_static : public ofdm_equalizer_1d_pilots + { + public: + typedef boost::shared_ptr<ofdm_equalizer_static> sptr; + + ofdm_equalizer_static( + int fft_len, + const std::vector<std::vector<int> > &occupied_carriers = std::vector<std::vector<int> >(), + const std::vector<std::vector<int> > &pilot_carriers = std::vector<std::vector<int> >(), + const std::vector<std::vector<gr_complex> > &pilot_symbols = std::vector<std::vector<gr_complex> >(), + int symbols_skipped = 0, + bool input_is_shifted = true + ); + ~ofdm_equalizer_static(); + + /*! \brief Divide the input signal with the current channel state. + * + * Does the following (and nothing else): + * - Divide every OFDM symbol with the current channel state + * - If a pilot symbol is found, re-set the channel state by dividing the received + * symbol with the known pilot symbol + */ + void equalize(gr_complex *frame, + int n_sym, + const std::vector<gr_complex> &initial_taps = std::vector<gr_complex>(), + const std::vector<gr_tag_t> &tags = std::vector<gr_tag_t>()); + + /* + * \param fft_len FFT length + * \param occupied_carriers List of occupied carriers, see ofdm_carrier_allocator + * for a description. + * \param pilot_carriers Position of pilot symbols, see ofdm_carrier_allocator + * for a description. + * \param pilot_symbols Value of pilot symbols, see ofdm_carrier_allocator + * for a description. + * \param symbols_skipped Starting position within occupied_carriers and pilot_carriers. + * If the first symbol of the frame was removed (e.g. to decode the + * header), set this make sure the pilot symbols are correctly + * identified. + * \param input_is_shifted Set this to false if the input signal is not shifted, i.e. + * the first input items is on the DC carrier. + * Note that a lot of the OFDM receiver blocks operate on shifted + * signals! + */ + static sptr make( + int fft_len, + const std::vector<std::vector<int> > &occupied_carriers = std::vector<std::vector<int> >(), + const std::vector<std::vector<int> > &pilot_carriers = std::vector<std::vector<int> >(), + const std::vector<std::vector<gr_complex> > &pilot_symbols = std::vector<std::vector<gr_complex> >(), + int symbols_skipped = 0, + bool input_is_shifted = true + ); + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_DIGITAL_OFDM_EQUALIZER_STATIC_H */ + diff --git a/gr-digital/include/digital/ofdm_frame_equalizer_vcvc.h b/gr-digital/include/digital/ofdm_frame_equalizer_vcvc.h index d5d526ddc3..68e8b7ad9f 100644 --- a/gr-digital/include/digital/ofdm_frame_equalizer_vcvc.h +++ b/gr-digital/include/digital/ofdm_frame_equalizer_vcvc.h @@ -19,12 +19,11 @@ * Boston, MA 02110-1301, USA. */ - #ifndef INCLUDED_OFDM_FRAME_EQUALIZER_VCVC_H #define INCLUDED_OFDM_FRAME_EQUALIZER_VCVC_H -#include <digital_ofdm_equalizer_base.h> #include <digital/api.h> +#include <digital/ofdm_equalizer_base.h> #include <gr_tagged_stream_block.h> namespace gr { @@ -50,7 +49,7 @@ namespace gr { * will be added to the first symbol as a tag */ static sptr make( - digital_ofdm_equalizer_base_sptr equalizer, + ofdm_equalizer_base::sptr equalizer, const std::string &len_tag_key = "frame_len", bool propagate_channel_state=false ); diff --git a/gr-digital/include/digital/ofdm_serializer_vcc.h b/gr-digital/include/digital/ofdm_serializer_vcc.h index 3893d6674e..c4dc36ec06 100644 --- a/gr-digital/include/digital/ofdm_serializer_vcc.h +++ b/gr-digital/include/digital/ofdm_serializer_vcc.h @@ -24,7 +24,7 @@ #include <digital/api.h> #include <gr_tagged_stream_block.h> -#include <digital_ofdm_carrier_allocator_cvc.h> +#include <digital/ofdm_carrier_allocator_cvc.h> namespace gr { namespace digital { @@ -77,7 +77,7 @@ namespace gr { * \param input_is_shifted If the input has the DC carrier on index 0 (i.e. it is not FFT shifted), set this to false */ static sptr make( - const digital_ofdm_carrier_allocator_cvc_sptr &allocator, + const gr::digital::ofdm_carrier_allocator_cvc::sptr &allocator, const std::string &packet_len_tag_key="", int symbols_skipped=0, bool input_is_shifted=true diff --git a/gr-digital/include/digital/ofdm_sync_sc_cfb.h b/gr-digital/include/digital/ofdm_sync_sc_cfb.h new file mode 100644 index 0000000000..0c5c46f38d --- /dev/null +++ b/gr-digital/include/digital/ofdm_sync_sc_cfb.h @@ -0,0 +1,78 @@ +/* -*- c++ -*- */ +/* + * Copyright 2013 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_DIGITAL_OFDM_SYNC_SC_CFB_H +#define INCLUDED_DIGITAL_OFDM_SYNC_SC_CFB_H + +#include <digital/api.h> +#include <gr_hier_block2.h> + +namespace gr { + namespace digital { + + /*! + * \brief Schmidl & Cox synchronisation for OFDM + * \ingroup ofdm_blk + * \ingroup sync_blk + * + * Input: complex samples. + * Output 0: Fine frequency offset, scaled by the OFDM symbol duration. + * This is \f$\hat{\varphi}\f$ in [1]. The normalized frequency + * offset is then 2.0*output0/fft_len. + * Output 1: Beginning of the first OFDM symbol after the first (doubled) OFDM + * symbol. The beginning is marked with a 1 (it's 0 everywhere else). + * + * The evaluation of the coarse frequency offset is *not* done in this block. + * Also, the initial equalizer taps are not calculated here. + * + * Note that we use a different normalization factor in the timing metric than + * the authors do in their original work[1]. If the timing metric (8) is + * \f[ + * M(d) = \frac{|P(d)|^2}{(R(d))^2}, + * \f] + * we calculate the normalization as + * \f[ + * R(d) = \frac{1}{2} \sum_{k=0}^{N-1} |r_{k+d}|^2, + * \f] + * i.e., we estimate the energy from *both* half-symbols. This avoids spurious detects + * at the end of a burst, when the energy level suddenly drops. + * + * [1] Schmidl, T.M. and Cox, D.C., "Robust frequency and timing synchronization for OFDM", + * Communications, IEEE Transactions on, 1997. + */ + class DIGITAL_API ofdm_sync_sc_cfb : virtual public gr_hier_block2 + { + public: + typedef boost::shared_ptr<ofdm_sync_sc_cfb> sptr; + + /*! \param fft_len FFT length + * \param cp_len Length of the guard interval (cyclic prefix) in samples + */ + static sptr make(int fft_len, int cp_len); + }; + + } // namespace digital +} // namespace gr + +#endif /* INCLUDED_DIGITAL_OFDM_SYNC_SC_CFB_H */ + diff --git a/gr-digital/include/digital_crc32_bb.h b/gr-digital/include/digital_crc32_bb.h deleted file mode 100644 index efbf2d545a..0000000000 --- a/gr-digital/include/digital_crc32_bb.h +++ /dev/null @@ -1,67 +0,0 @@ -/* -*- c++ -*- */ -/* Copyright 2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - - -#ifndef INCLUDED_DIGITAL_CRC32_BB_H -#define INCLUDED_DIGITAL_CRC32_BB_H - -#include <digital/api.h> -#include <gr_tagged_stream_block.h> - -class digital_crc32_bb; - -typedef boost::shared_ptr<digital_crc32_bb> digital_crc32_bb_sptr; - -DIGITAL_API digital_crc32_bb_sptr digital_make_crc32_bb (bool check=false, const std::string& lengthtagname="packet_len"); - -/*! - * \brief Byte-stream CRC block - * \ingroup digital - * - * Input: stream of bytes, which form a packet. The first byte of the packet - * has a tag with key "length" and the value being the number of bytes in the - * packet. - * - * Output: The same bytes as incoming, but trailing a CRC32 of the packet. - * The tag is re-set to the new length. - */ -class DIGITAL_API digital_crc32_bb : public gr_tagged_stream_block -{ - private: - friend DIGITAL_API digital_crc32_bb_sptr digital_make_crc32_bb (bool check, const std::string& lengthtagname); - - bool d_check; - - digital_crc32_bb(bool check, const std::string& lengthtagname); - - public: - ~digital_crc32_bb(); - - int calculate_output_stream_length(const std::vector<int> &ninput_items); - - int work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_DIGITAL_CRC32_BB_H */ - diff --git a/gr-digital/include/digital_ofdm_carrier_allocator_cvc.h b/gr-digital/include/digital_ofdm_carrier_allocator_cvc.h deleted file mode 100644 index 9052299aa9..0000000000 --- a/gr-digital/include/digital_ofdm_carrier_allocator_cvc.h +++ /dev/null @@ -1,116 +0,0 @@ -/* -*- c++ -*- */ -/* Copyright 2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - - -#ifndef INCLUDED_DIGITAL_OFDM_CARRIER_ALLOCATOR_CVC_H -#define INCLUDED_DIGITAL_OFDM_CARRIER_ALLOCATOR_CVC_H - -#include <digital/api.h> -#include <gr_tagged_stream_block.h> - -class digital_ofdm_carrier_allocator_cvc; -typedef boost::shared_ptr<digital_ofdm_carrier_allocator_cvc> digital_ofdm_carrier_allocator_cvc_sptr; - -/* - * \param occupied_carriers A vector of vectors of indexes. Example: if - * occupied_carriers = ((1, 2, 3), (1, 2, 4)), the first - * three input symbols will be mapped to carriers 1, 2 - * and 3. After that, a new OFDM symbol is started. The next - * three input symbols will be placed onto carriers 1, 2 - * and 4 of the second OFDM symbol. The allocation then - * starts from the beginning. - * Order matters! The first input symbol is always mapped - * onto occupied_carriers[0][0]. - * \param pilot_carriers The position of the pilot symbols. Same as occupied_carriers, - * but the actual symbols are taken from pilot_symbols instead - * of the input stream. - * \param pilot_symbols The pilot symbols which are placed onto the pilot carriers. - * pilot_symbols[0][0] is placed onto the first OFDM symbol, on - * carrier index pilot_carriers[0][0] etc. - * \param len_tag_key The key of the tag identifying the length of the input packet. - */ -DIGITAL_API digital_ofdm_carrier_allocator_cvc_sptr -digital_make_ofdm_carrier_allocator_cvc ( - int fft_len, - const std::vector<std::vector<int> > &occupied_carriers, - const std::vector<std::vector<int> > &pilot_carriers, - const std::vector<std::vector<gr_complex> > &pilot_symbols, - const std::string &len_tag_key = "packet_len"); - -/*! - * \brief Create frequency domain OFDM symbols from complex values, add pilots. - * \ingroup ofdm_blk - * - * This block turns a stream of complex, scalar modulation symbols into vectors - * which are the input for an IFFT in an OFDM transmitter. It also supports the - * possibility of placing pilot symbols onto the carriers. - * - * The carriers can be allocated freely, if a carrier is not allocated, it is set - * to zero. This allows doing OFDMA-style carrier allocations. - * - * Input: A tagged stream of complex scalars. The first item must have a tag - * containing the number of complex symbols in this frame. - * Output: A tagged stream of complex vectors of length fft_len. This can directly - * be connected to an FFT block. Make sure to set this block to 'reverse' - * for the IFFT and to deactivate FFT shifting. - * - * Carrier indexes are always such that index 0 is the DC carrier (note: you should - * not allocate this carrier). The carriers below the DC carrier are either indexed - * with negative numbers, or with indexes larger than fft_len/2. Index -1 and index - * fft_len-1 both identify the carrier below the DC carrier. - * - */ -class DIGITAL_API digital_ofdm_carrier_allocator_cvc : public gr_tagged_stream_block -{ - private: - friend DIGITAL_API digital_ofdm_carrier_allocator_cvc_sptr digital_make_ofdm_carrier_allocator_cvc (int fft_len, const std::vector<std::vector<int> > &occupied_carriers, const std::vector<std::vector<int> > &pilot_carriers, const std::vector<std::vector<gr_complex> > &pilot_symbols, const std::string &len_tag_key); - - digital_ofdm_carrier_allocator_cvc(int fft_len, const std::vector<std::vector<int> > &occupied_carriers, const std::vector<std::vector<int> > &pilot_carriers, const std::vector<std::vector<gr_complex> > &pilot_symbols, const std::string &len_tag_key); - - //! FFT length - const int d_fft_len; - //! Which carriers/symbols carry data - std::vector<std::vector<int> > d_occupied_carriers; - //! Which carriers/symbols carry pilots symbols - std::vector<std::vector<int> > d_pilot_carriers; - //! Value of said pilot symbols - const std::vector<std::vector<gr_complex> > d_pilot_symbols; - int d_symbols_per_set; - - protected: - int calculate_output_stream_length(const gr_vector_int &ninput_items); - - public: - ~digital_ofdm_carrier_allocator_cvc(); - - std::string len_tag_key() { return d_length_tag_key_str; }; - - const int fft_len() { return d_fft_len; }; - std::vector<std::vector<int> > occupied_carriers() { return d_occupied_carriers; }; - - int work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_DIGITAL_OFDM_CARRIER_ALLOCATOR_CVC_H */ - diff --git a/gr-digital/include/digital_ofdm_chanest_vcvc.h b/gr-digital/include/digital_ofdm_chanest_vcvc.h deleted file mode 100644 index da03f96720..0000000000 --- a/gr-digital/include/digital_ofdm_chanest_vcvc.h +++ /dev/null @@ -1,133 +0,0 @@ -/* -*- c++ -*- */ -/* Copyright 2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_DIGITAL_OFDM_CHANEST_VCVC_H -#define INCLUDED_DIGITAL_OFDM_CHANEST_VCVC_H - -#include <digital/api.h> -#include <gr_block.h> - -class digital_ofdm_chanest_vcvc; - -typedef boost::shared_ptr<digital_ofdm_chanest_vcvc> digital_ofdm_chanest_vcvc_sptr; - -/* - * \param sync_symbol1 First synchronisation symbol in the frequency domain. Its length must be - * the FFT length. For Schmidl & Cox synchronisation, every second sub-carrier - * has to be zero. - * \param sync_symbol2 Second synchronisation symbol in the frequency domain. Must be equal to - * the FFT length, or zero length if only one synchronisation symbol is used. - * Using this symbol is how synchronisation is described in [1]. Leaving this - * empty forces us to interpolate the equalizer taps. - * If you are using an unusual sub-carrier configuration (e.g. because of OFDMA), - * this sync symbol is used to identify the active sub-carriers. If you only - * have one synchronisation symbol, set the active sub-carriers to a non-zero - * value in here, and also set \p force_one_sync_symbol parameter to true. - * \param n_data_symbols The number of data symbols following each set of synchronisation symbols. - * Must be at least 1. - * \param eq_noise_red_len If non-zero, noise reduction for the equalizer taps is done according - * to [2]. In this case, it is the channel influence time in number of - * samples. A good value is usually the length of the cyclic prefix. - * \param max_carr_offset Limit the number of sub-carriers the frequency offset can maximally be. - * Leave this zero to try all possibilities. - * \param force_one_sync_symbol See \p sync_symbol2. - */ -DIGITAL_API digital_ofdm_chanest_vcvc_sptr -digital_make_ofdm_chanest_vcvc ( - const std::vector<gr_complex> &sync_symbol1, - const std::vector<gr_complex> &sync_symbol2, - int n_data_symbols, - int eq_noise_red_len=0, - int max_carr_offset=-1, - bool force_one_sync_symbol=false); - -/*! - * \brief Estimate channel and coarse frequency offset for OFDM from preambles - * \ingroup ofdm_blk - * \ingroup sync_blk - * - * Input: OFDM symbols (in frequency domain). The first one (or two) symbols are expected - * to be synchronisation symbols, which are used to estimate the coarse freq offset - * and the initial equalizer taps (these symbols are removed from the stream). - * The following \p n_data_symbols are passed through unmodified (the actual equalisation - * must be done elsewhere). - * Output: The data symbols, without the synchronisation symbols. - * The first data symbol passed through has two tags: - * 'ofdm_sync_carr_offset' (integer), the coarse frequency offset as number of carriers, - * and 'ofdm_sync_eq_taps' (complex vector). - * Any tags attached to the synchronisation symbols are attached to the first data - * symbol. All other tags are propagated normally. - * - * This block assumes the frequency offset is even (i.e. an integer multiple of 2). - * - * [1] Schmidl, T.M. and Cox, D.C., "Robust frequency and timing synchronization for OFDM", - * Communications, IEEE Transactions on, 1997. - * [2] K.D. Kammeyer, "Nachrichtenuebertragung," Chapter. 16.3.2. - */ -class DIGITAL_API digital_ofdm_chanest_vcvc : public gr_block -{ - private: - friend DIGITAL_API digital_ofdm_chanest_vcvc_sptr digital_make_ofdm_chanest_vcvc (const std::vector<gr_complex> &sync_symbol1, const std::vector<gr_complex> &sync_symbol2, int n_data_symbols, int eq_noise_red_len, int max_carr_offset, bool force_one_sync_symbol); - - int d_fft_len; //! FFT length - int d_n_data_syms; //! Number of data symbols following the sync symbol(s) - int d_n_sync_syms; //! Number of sync symbols (1 or 2) - //! 0 if no noise reduction is done for the initial channel state estimation. Otherwise, the maximum length of the channel delay in samples. - int d_eq_noise_red_len; - //! Is sync_symbol1 if d_n_sync_syms == 1, otherwise sync_symbol2. Used as a reference symbol to estimate the channel. - std::vector<gr_complex> d_ref_sym; - //! If d_n_sync_syms == 2 this is used as a differential correlation vector (called 'v' in [1]). - std::vector<gr_complex> d_corr_v; - //! If d_n_sync_syms == 1 we use this instead of d_corr_v to estimate the coarse freq. offset - std::vector<float> d_known_symbol_diffs; - //! If d_n_sync_syms == 1 we use this instead of d_corr_v to estimate the coarse freq. offset (temp. variable) - std::vector<float> d_new_symbol_diffs; - //! The index of the first carrier with data (index 0 is not DC here, but the lowest frequency) - int d_first_active_carrier; - //! The index of the last carrier with data - int d_last_active_carrier; - //! If true, the channel estimation must be interpolated - bool d_interpolate; - //! Maximum carrier offset (negative value!) - int d_max_neg_carr_offset; - //! Maximum carrier offset (positive value!) - int d_max_pos_carr_offset; - - - digital_ofdm_chanest_vcvc(const std::vector<gr_complex> &sync_symbol1, const std::vector<gr_complex> &sync_symbol2, int n_data_symbols, int eq_noise_red_len, int max_carr_offset, bool force_one_sync_symbol); - - //! Calculate the coarse frequency offset in number of carriers - int get_carr_offset(const gr_complex *sync_sym1, const gr_complex *sync_sym2); - //! Estimate the channel (phase and amplitude offset per carrier) - void get_chan_taps(const gr_complex *sync_sym1, const gr_complex *sync_sym2, int carr_offset, std::vector<gr_complex> &taps); - - public: - ~digital_ofdm_chanest_vcvc(); - - void forecast (int noutput_items, gr_vector_int &ninput_items_required); - int general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_DIGITAL_OFDM_CHANEST_VCVC_H */ - diff --git a/gr-digital/include/digital_ofdm_cyclic_prefixer.h b/gr-digital/include/digital_ofdm_cyclic_prefixer.h deleted file mode 100644 index 563a311fa3..0000000000 --- a/gr-digital/include/digital_ofdm_cyclic_prefixer.h +++ /dev/null @@ -1,95 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004-2006,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_DIGITAL_OFDM_CYCLIC_PREFIXER_H -#define INCLUDED_DIGITAL_OFDM_CYCLIC_PREFIXER_H - -#include <digital/api.h> -#include <gr_tagged_stream_block.h> - -class digital_ofdm_cyclic_prefixer; -typedef boost::shared_ptr<digital_ofdm_cyclic_prefixer> digital_ofdm_cyclic_prefixer_sptr; - -/*! - * \param input_size FFT length (i.e. length of the OFDM symbols) - * \param output_size FFT length + cyclic prefix length (in samples) - * \param rolloff_len Length of the rolloff flank in samples - * \param len_tag_key For framed processing the key of the length tag - */ -DIGITAL_API digital_ofdm_cyclic_prefixer_sptr -digital_make_ofdm_cyclic_prefixer (size_t input_size, - size_t output_size, - int rolloff_len=0, - const std::string &len_tag_key=""); - - -/*! - * \brief Adds a cyclic prefix and performs pulse shaping on OFDM symbols. - * \ingroup ofdm_blk - * - * Input: OFDM symbols (in the time domain, i.e. after the IFFT). Optionally, - * entire frames can be processed. In this case, \p len_tag_key must be - * specified which holds the key of the tag that denotes how - * many OFDM symbols are in a frame. - * Output: A stream of (scalar) complex symbols, which include the cyclic prefix - * and the pulse shaping. - * Note: If complete frames are processed, and \p rolloff_len is greater - * than zero, the final OFDM symbol is followed by the delay line of - * the pulse shaping. - * - * The pulse shape is a raised cosine in the time domain. - */ -class DIGITAL_API digital_ofdm_cyclic_prefixer : public gr_tagged_stream_block -{ - friend DIGITAL_API digital_ofdm_cyclic_prefixer_sptr - digital_make_ofdm_cyclic_prefixer (size_t input_size, size_t output_size, int rolloff_len, const std::string &len_tag_key); - - - protected: - digital_ofdm_cyclic_prefixer (size_t input_size, size_t output_size, int rolloff_len, const std::string &len_tag_key); - - //! Return the number of complex samples from the number of OFDM symbols (includes rolloff) - int calculate_output_stream_length(const gr_vector_int &ninput_items); - - public: - int work(int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - private: - size_t d_fft_len; - //! FFT length + CP length in samples - size_t d_output_size; - //! Length of the cyclic prefix in samples - int d_cp_size; - //! Length of pulse rolloff in samples - int d_rolloff_len; - //! Buffers the up-flank (at the beginning of the cyclic prefix) - std::vector<float> d_up_flank; - //! Buffers the down-flank (which trails the symbol) - std::vector<float> d_down_flank; - std::vector<gr_complex> d_delay_line; // We do this explicitly to avoid outputting zeroes (i.e. no history!) -}; - -#endif /* INCLUDED_DIGITAL_OFDM_CYCLIC_PREFIXER_H */ - diff --git a/gr-digital/include/digital_ofdm_equalizer_base.h b/gr-digital/include/digital_ofdm_equalizer_base.h deleted file mode 100644 index 8665395540..0000000000 --- a/gr-digital/include/digital_ofdm_equalizer_base.h +++ /dev/null @@ -1,102 +0,0 @@ -/* -*- c++ -*- */ -/* Copyright 2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_DIGITAL_OFDM_EQUALIZER_BASE_H -#define INCLUDED_DIGITAL_OFDM_EQUALIZER_BASE_H - -#include <digital/api.h> -#include <gr_tags.h> -#include <gr_complex.h> -#include <boost/enable_shared_from_this.hpp> - -class digital_ofdm_equalizer_base; -typedef boost::shared_ptr<digital_ofdm_equalizer_base> digital_ofdm_equalizer_base_sptr; - -class digital_ofdm_equalizer_1d_pilots; -typedef boost::shared_ptr<digital_ofdm_equalizer_1d_pilots> digital_ofdm_equalizer_1d_pilots_sptr; - -/* \brief Base class for implementation details of frequency-domain OFDM equalizers. - * \ingroup ofdm_blk - * \ingroup eq_blk - * - */ -class DIGITAL_API digital_ofdm_equalizer_base : public boost::enable_shared_from_this<digital_ofdm_equalizer_base> -{ - protected: - int d_fft_len; - int d_carr_offset; - - public: - digital_ofdm_equalizer_base(int fft_len); - ~digital_ofdm_equalizer_base(); - - virtual void reset() = 0; - void set_carrier_offset(int offset) { d_carr_offset = offset; }; - virtual void equalize( - gr_complex *frame, - int n_sym, - const std::vector<gr_complex> &initial_taps = std::vector<gr_complex>(), - const std::vector<gr_tag_t> &tags = std::vector<gr_tag_t>()) = 0; - virtual void get_channel_state(std::vector<gr_complex> &taps) = 0; - int fft_len() { return d_fft_len; }; - digital_ofdm_equalizer_base_sptr base() { return shared_from_this(); }; -}; - - -/* \brief Base class for implementation details of 1-dimensional OFDM FDEs which use pilot tones. - * \ingroup digital - * - */ -class DIGITAL_API digital_ofdm_equalizer_1d_pilots : public digital_ofdm_equalizer_base -{ - protected: - //! If \p d_occupied_carriers[k][l] is true, symbol k, carrier l is carrying data. - // (this is a different format than occupied_carriers!) - std::vector<bool> d_occupied_carriers; - //! If \p d_pilot_carriers[k][l] is true, symbol k, carrier l is carrying data. - // (this is a different format than pilot_carriers!) - std::vector<std::vector<bool> > d_pilot_carriers; - //! If \p d_pilot_carriers[k][l] is true, d_pilot_symbols[k][l] is its tx'd value. - // (this is a different format than pilot_symbols!) - std::vector<std::vector<gr_complex> > d_pilot_symbols; - //! In case the frame doesn't begin with OFDM symbol 0, this is the index of the first symbol - int d_symbols_skipped; - //! The current position in the set of pilot symbols - int d_pilot_carr_set; - //! Vector of length d_fft_len saving the current channel state (on the occupied carriers) - std::vector<gr_complex> d_channel_state; - - public: - digital_ofdm_equalizer_1d_pilots( - int fft_len, - const std::vector<std::vector<int> > &occupied_carriers, - const std::vector<std::vector<int> > &pilot_carriers, - const std::vector<std::vector<gr_complex> > &pilot_symbols, - int symbols_skipped, - bool input_is_shifted); - ~digital_ofdm_equalizer_1d_pilots(); - - void reset(); - void get_channel_state(std::vector<gr_complex> &taps); -}; - -#endif /* INCLUDED_DIGITAL_OFDM_EQUALIZER_BASE_H */ - diff --git a/gr-digital/include/digital_ofdm_equalizer_simpledfe.h b/gr-digital/include/digital_ofdm_equalizer_simpledfe.h deleted file mode 100644 index 89b0b5cd6d..0000000000 --- a/gr-digital/include/digital_ofdm_equalizer_simpledfe.h +++ /dev/null @@ -1,126 +0,0 @@ -/* -*- c++ -*- */ -/* Copyright 2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_DIGITAL_OFDM_EQUALIZER_SIMPLEDFE_H -#define INCLUDED_DIGITAL_OFDM_EQUALIZER_SIMPLEDFE_H - -#include <digital/api.h> -#include <digital/constellation.h> -#include <digital_ofdm_equalizer_base.h> - -class digital_ofdm_equalizer_simpledfe; -typedef boost::shared_ptr<digital_ofdm_equalizer_simpledfe> digital_ofdm_equalizer_simpledfe_sptr; - -/* - * \param fft_len FFT length - * \param constellation The constellation object describing the modulation used - * on the subcarriers (e.g. QPSK). This is used to decode - * the individual symbols. - * \param occupied_carriers List of occupied carriers, see ofdm_carrier_allocator - * for a description. - * \param pilot_carriers Position of pilot symbols, see ofdm_carrier_allocator - * for a description. - * \param pilot_symbols Value of pilot symbols, see ofdm_carrier_allocator - * for a description. - * \param alpha Averaging coefficient (in a nutshell, if \f$H_{i,k}\f$ is the channel - * state for carrier i and symbol k, - * \f$H_{i,k+1} = \alpha H_{i,k} + (1 - \alpha) H_{i,k+1}\f$. Make this - * larger if there's more noise, but keep in mind that larger values - * of alpha mean slower response to channel changes). - * \param symbols_skipped Starting position within occupied_carriers and pilot_carriers. - * If the first symbol of the frame was removed (e.g. to decode the - * header), set this make sure the pilot symbols are correctly - * identified. - * \param input_is_shifted Set this to false if the input signal is not shifted, i.e. - * the first input items is on the DC carrier. - * Note that a lot of the OFDM receiver blocks operate on shifted - * signals! - */ -DIGITAL_API digital_ofdm_equalizer_simpledfe_sptr -digital_make_ofdm_equalizer_simpledfe( - int fft_len, - const gr::digital::constellation_sptr &constellation, - const std::vector<std::vector<int> > &occupied_carriers = std::vector<std::vector<int> >(), - const std::vector<std::vector<int> > &pilot_carriers = std::vector<std::vector<int> >(), - const std::vector<std::vector<gr_complex> > &pilot_symbols = std::vector<std::vector<gr_complex> >(), - int symbols_skipped = 0, - float alpha = 0.1, - bool input_is_shifted = true); - -/* \brief Simple decision feedback equalizer for OFDM. - * \ingroup ofdm_blk - * \ingroup eq_blk - * - * Equalizes an OFDM signal symbol by symbol using knowledge of the - * complex modulations symbols. - * For every symbol, the following steps are performed: - * - On every sub-carrier, decode the modulation symbol - * - Use the difference between the decoded symbol and the received symbol - * to update the channel state on this carrier - * - Whenever a pilot symbol is found, it uses the known pilot symbol to - * update the channel state. - * - * This equalizer makes a lot of assumptions: - * - The initial channel state is good enough to decode the first - * symbol without error (unless the first symbol only consists of pilot - * tones) - * - The channel changes only very slowly, such that the channel state - * from one symbol is enough to decode the next - * - SNR low enough that equalization will always suffice to correctly - * decode a symbol - * If these assumptions are not met, the most common error is that the - * channel state is estimated incorrectly during equalization; after that, - * all subsequent symbols will be completely wrong. - * - * Note that the equalized symbols are *exact points* on the constellation. - * This means soft information of the modulation symbols is lost after the - * equalization, which is suboptimal for channel codes that use soft decision. - * - */ -class DIGITAL_API digital_ofdm_equalizer_simpledfe : public digital_ofdm_equalizer_1d_pilots -{ - public: - digital_ofdm_equalizer_simpledfe( - int fft_len, - const gr::digital::constellation_sptr &constellation, - const std::vector<std::vector<int> > &occupied_carriers = std::vector<std::vector<int> >(), - const std::vector<std::vector<int> > &pilot_carriers = std::vector<std::vector<int> >(), - const std::vector<std::vector<gr_complex> > &pilot_symbols = std::vector<std::vector<gr_complex> >(), - int symbols_skipped = 0, - float alpha = 0.1, - bool input_is_shifted = true); - - ~digital_ofdm_equalizer_simpledfe(); - - void equalize(gr_complex *frame, - int n_sym, - const std::vector<gr_complex> &initial_taps = std::vector<gr_complex>(), - const std::vector<gr_tag_t> &tags = std::vector<gr_tag_t>()); - - private: - gr::digital::constellation_sptr d_constellation; - //! Averaging coefficient - float d_alpha; - -}; - -#endif /* INCLUDED_DIGITAL_OFDM_EQUALIZER_SIMPLEDFE_H */ - diff --git a/gr-digital/include/digital_ofdm_equalizer_static.h b/gr-digital/include/digital_ofdm_equalizer_static.h deleted file mode 100644 index 4537d329f4..0000000000 --- a/gr-digital/include/digital_ofdm_equalizer_static.h +++ /dev/null @@ -1,97 +0,0 @@ -/* -*- c++ -*- */ -/* Copyright 2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_DIGITAL_OFDM_EQUALIZER_STATIC_H -#define INCLUDED_DIGITAL_OFDM_EQUALIZER_STATIC_H - -#include <digital/api.h> -#include <digital/constellation.h> -#include <digital_ofdm_equalizer_base.h> - -class digital_ofdm_equalizer_static; -typedef boost::shared_ptr<digital_ofdm_equalizer_static> digital_ofdm_equalizer_static_sptr; - -/* - * \param fft_len FFT length - * \param occupied_carriers List of occupied carriers, see ofdm_carrier_allocator - * for a description. - * \param pilot_carriers Position of pilot symbols, see ofdm_carrier_allocator - * for a description. - * \param pilot_symbols Value of pilot symbols, see ofdm_carrier_allocator - * for a description. - * \param symbols_skipped Starting position within occupied_carriers and pilot_carriers. - * If the first symbol of the frame was removed (e.g. to decode the - * header), set this make sure the pilot symbols are correctly - * identified. - * \param input_is_shifted Set this to false if the input signal is not shifted, i.e. - * the first input items is on the DC carrier. - * Note that a lot of the OFDM receiver blocks operate on shifted - * signals! - */ -DIGITAL_API digital_ofdm_equalizer_static_sptr -digital_make_ofdm_equalizer_static( - int fft_len, - const std::vector<std::vector<int> > &occupied_carriers = std::vector<std::vector<int> >(), - const std::vector<std::vector<int> > &pilot_carriers = std::vector<std::vector<int> >(), - const std::vector<std::vector<gr_complex> > &pilot_symbols = std::vector<std::vector<gr_complex> >(), - int symbols_skipped = 0, - bool input_is_shifted = true); - -/* \brief Very simple static equalizer for OFDM. - * \ingroup ofdm_blk - * \ingroup eq_blk - * - * This is an extremely simple equalizer. It will only work for high-SNR, very, very - * slowly changing channels. - * It simply divides the signal with the currently known channel state. Whenever - * a pilot symbol comes around, it updates the channel state on that particular - * carrier by dividing the received symbol with the known pilot symbol. - */ -class DIGITAL_API digital_ofdm_equalizer_static : public digital_ofdm_equalizer_1d_pilots -{ - public: - digital_ofdm_equalizer_static( - int fft_len, - const std::vector<std::vector<int> > &occupied_carriers = std::vector<std::vector<int> >(), - const std::vector<std::vector<int> > &pilot_carriers = std::vector<std::vector<int> >(), - const std::vector<std::vector<gr_complex> > &pilot_symbols = std::vector<std::vector<gr_complex> >(), - int symbols_skipped = 0, - bool input_is_shifted = true); - ~digital_ofdm_equalizer_static(); - - /*! \brief Divide the input signal with the current channel state. - * - * Does the following (and nothing else): - * - Divide every OFDM symbol with the current channel state - * - If a pilot symbol is found, re-set the channel state by dividing the received - * symbol with the known pilot symbol - */ - void equalize(gr_complex *frame, - int n_sym, - const std::vector<gr_complex> &initial_taps = std::vector<gr_complex>(), - const std::vector<gr_tag_t> &tags = std::vector<gr_tag_t>()); - - private: - -}; - -#endif /* INCLUDED_DIGITAL_OFDM_EQUALIZER_STATIC_H */ - diff --git a/gr-digital/include/digital_ofdm_sync_sc_cfb.h b/gr-digital/include/digital_ofdm_sync_sc_cfb.h deleted file mode 100644 index cc728814ed..0000000000 --- a/gr-digital/include/digital_ofdm_sync_sc_cfb.h +++ /dev/null @@ -1,79 +0,0 @@ -/* -*- c++ -*- */ -/* Copyright 2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_DIGITAL_OFDM_SYNC_SC_CFB_H -#define INCLUDED_DIGITAL_OFDM_SYNC_SC_CFB_H - -#include <digital/api.h> -#include <gr_hier_block2.h> - -class digital_ofdm_sync_sc_cfb; -typedef boost::shared_ptr<digital_ofdm_sync_sc_cfb> digital_ofdm_sync_sc_cfb_sptr; - -/*! \param fft_len FFT length - * \param cp_len Length of the guard interval (cyclic prefix) in samples - */ -DIGITAL_API digital_ofdm_sync_sc_cfb_sptr -digital_make_ofdm_sync_sc_cfb (int fft_len, int cp_len); - -/*! - * \brief Schmidl & Cox synchronisation for OFDM - * \ingroup ofdm_blk - * \ingroup sync_blk - * - * Input: complex samples. - * Output 0: Fine frequency offset, scaled by the OFDM symbol duration. - * This is \f$\hat{\varphi}\f$ in [1]. The normalized frequency - * offset is then 2.0*output0/fft_len. - * Output 1: Beginning of the first OFDM symbol after the first (doubled) OFDM - * symbol. The beginning is marked with a 1 (it's 0 everywhere else). - * - * The evaluation of the coarse frequency offset is *not* done in this block. - * Also, the initial equalizer taps are not calculated here. - * - * Note that we use a different normalization factor in the timing metric than - * the authors do in their original work[1]. If the timing metric (8) is - * \f[ - * M(d) = \frac{|P(d)|^2}{(R(d))^2}, - * \f] - * we calculate the normalization as - * \f[ - * R(d) = \frac{1}{2} \sum_{k=0}^{N-1} |r_{k+d}|^2, - * \f] - * i.e., we estimate the energy from *both* half-symbols. This avoids spurious detects - * at the end of a burst, when the energy level suddenly drops. - * - * [1] Schmidl, T.M. and Cox, D.C., "Robust frequency and timing synchronization for OFDM", - * Communications, IEEE Transactions on, 1997. - */ -class DIGITAL_API digital_ofdm_sync_sc_cfb : public gr_hier_block2 -{ - private: - friend DIGITAL_API digital_ofdm_sync_sc_cfb_sptr digital_make_ofdm_sync_sc_cfb (int fft_len, int cp_len); - digital_ofdm_sync_sc_cfb(int fft_len, int cp_len); - - public: - ~digital_ofdm_sync_sc_cfb(); - -}; - -#endif /* INCLUDED_DIGITAL_OFDM_SYNC_SC_CFB_H */ - diff --git a/gr-digital/lib/CMakeLists.txt b/gr-digital/lib/CMakeLists.txt index 20a773a566..d0a9132250 100644 --- a/gr-digital/lib/CMakeLists.txt +++ b/gr-digital/lib/CMakeLists.txt @@ -126,18 +126,11 @@ list(APPEND digital_sources costas_loop_cc_impl.cc cpmmod_bc_impl.cc crc32.cc + crc32_bb_impl.cc descrambler_bb_impl.cc diff_decoder_bb_impl.cc diff_encoder_bb_impl.cc diff_phasor_cc_impl.cc - digital_crc32_bb.cc - digital_ofdm_carrier_allocator_cvc.cc - digital_ofdm_chanest_vcvc.cc - digital_ofdm_cyclic_prefixer.cc - digital_ofdm_equalizer_base.cc - digital_ofdm_equalizer_simpledfe.cc - digital_ofdm_equalizer_static.cc - digital_ofdm_sync_sc_cfb.cc fll_band_edge_cc_impl.cc framer_sink_1_impl.cc glfsr.cc @@ -150,7 +143,12 @@ list(APPEND digital_sources mpsk_receiver_cc_impl.cc mpsk_snr_est.cc mpsk_snr_est_cc_impl.cc + ofdm_carrier_allocator_cvc_impl.cc + ofdm_chanest_vcvc_impl.cc ofdm_cyclic_prefixer_impl.cc + ofdm_equalizer_base.cc + ofdm_equalizer_simpledfe.cc + ofdm_equalizer_static.cc ofdm_frame_acquisition_impl.cc ofdm_frame_equalizer_vcvc_impl.cc ofdm_frame_sink_impl.cc @@ -158,6 +156,7 @@ list(APPEND digital_sources ofdm_mapper_bcv_impl.cc ofdm_sampler_impl.cc ofdm_serializer_vcc_impl.cc + ofdm_sync_sc_cfb_impl.cc packet_header_default.cc packet_header_ofdm.cc packet_headergenerator_bb_impl.cc diff --git a/gr-digital/lib/costas_loop_cc_impl.h b/gr-digital/lib/costas_loop_cc_impl.h index d9756ea2f1..ecba2cdd4f 100644 --- a/gr-digital/lib/costas_loop_cc_impl.h +++ b/gr-digital/lib/costas_loop_cc_impl.h @@ -25,12 +25,11 @@ #define INCLUDED_DIGITAL_COSTAS_LOOP_CC_IMPL_H #include <digital/costas_loop_cc.h> -#include <blocks/control_loop.h> namespace gr { namespace digital { - class costas_loop_cc_impl : public costas_loop_cc, blocks::control_loop + class costas_loop_cc_impl : public costas_loop_cc { private: int d_order; diff --git a/gr-digital/lib/crc32_bb_impl.cc b/gr-digital/lib/crc32_bb_impl.cc new file mode 100644 index 0000000000..608c5758ac --- /dev/null +++ b/gr-digital/lib/crc32_bb_impl.cc @@ -0,0 +1,105 @@ +/* -*- c++ -*- */ +/* + * Copyright 2013 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_io_signature.h> +#include "crc32_bb_impl.h" +#include <digital/crc32.h> + +namespace gr { + namespace digital { + + crc32_bb::sptr + crc32_bb::make(bool check, const std::string& lengthtagname) + { + return gnuradio::get_initial_sptr (new crc32_bb_impl(check, lengthtagname)); + } + + crc32_bb_impl::crc32_bb_impl(bool check, const std::string& lengthtagname) + : gr_tagged_stream_block("crc32_bb", + gr_make_io_signature(1, 1, sizeof (char)), + gr_make_io_signature(1, 1, sizeof (char)), + lengthtagname), + d_check(check) + { + set_tag_propagation_policy(TPP_DONT); + } + + crc32_bb_impl::~crc32_bb_impl() + { + } + + int + crc32_bb_impl::calculate_output_stream_length(const gr_vector_int &ninput_items) + { + if (d_check) { + return ninput_items[0] - 4; + } else { + return ninput_items[0] + 4; + } + } + + int + crc32_bb_impl::work (int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + const unsigned char *in = (const unsigned char *) input_items[0]; + unsigned char *out = (unsigned char *) output_items[0]; + long packet_length = ninput_items[0]; + int packet_size_diff = d_check ? -4 : 4; + unsigned int crc; + + if (d_check) { + crc = gr::digital::crc32(in, packet_length-4); + if (crc != *(unsigned int *)(in+packet_length-4)) { // Drop package + return 0; + } + memcpy((void *) out, (const void *) in, packet_length-4); + } else { + crc = gr::digital::crc32(in, packet_length); + memcpy((void *) out, (const void *) in, packet_length); + memcpy((void *) (out + packet_length), &crc, 4); // FIXME big-endian/little-endian, this might be wrong + } + + std::vector<gr_tag_t> tags; + get_tags_in_range(tags, 0, nitems_read(0), nitems_read(0)+packet_length); + for (unsigned i = 0; i < tags.size(); i++) { + tags[i].offset -= nitems_read(0); + if (d_check && tags[i].offset > packet_length+packet_size_diff) { + tags[i].offset = packet_length-5; + } + add_item_tag(0, nitems_written(0) + tags[i].offset, + tags[i].key, + tags[i].value); + } + + return packet_length + packet_size_diff; + } + + } /* namespace digital */ +} /* namespace gr */ + diff --git a/gr-digital/swig/digital_ofdm_chanest_vcvc.i b/gr-digital/lib/crc32_bb_impl.h index aa6e79b5c2..7b9dbb6351 100644 --- a/gr-digital/swig/digital_ofdm_chanest_vcvc.i +++ b/gr-digital/lib/crc32_bb_impl.h @@ -1,5 +1,6 @@ /* -*- c++ -*- */ -/* Copyright 2012 Free Software Foundation, Inc. +/* + * Copyright 2013 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -19,22 +20,32 @@ * Boston, MA 02110-1301, USA. */ -GR_SWIG_BLOCK_MAGIC(digital, ofdm_chanest_vcvc); +#ifndef INCLUDED_DIGITAL_CRC32_BB_IMPL_H +#define INCLUDED_DIGITAL_CRC32_BB_IMPL_H -digital_ofdm_chanest_vcvc_sptr -digital_make_ofdm_chanest_vcvc ( - const std::vector<gr_complex> &sync_symbol1, - const std::vector<gr_complex> &sync_symbol2, - int n_data_symbols, - int eq_noise_red_len=0, - int max_carr_offset=-1, - bool force_one_sync_symbol=false); +#include <digital/crc32_bb.h> -class digital_ofdm_chanest_vcvc : public gr_block -{ - private: - digital_ofdm_chanest_vcvc(const std::vector<gr_complex> &sync_symbol1, const std::vector<gr_complex> &sync_symbol2, int n_data_symbols, int eq_noise_red_len, int max_carr_offset, bool force_one_sync_symbol); +namespace gr { + namespace digital { - public: -}; + class crc32_bb_impl : public crc32_bb + { + private: + bool d_check; + + public: + crc32_bb_impl(bool check, const std::string& lengthtagname); + ~crc32_bb_impl(); + + int calculate_output_stream_length(const gr_vector_int &ninput_items); + int work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } // namespace digital +} // namespace gr + +#endif /* INCLUDED_DIGITAL_CRC32_BB_IMPL_H */ diff --git a/gr-digital/lib/digital_crc32_bb.cc b/gr-digital/lib/digital_crc32_bb.cc deleted file mode 100644 index 40d313ba89..0000000000 --- a/gr-digital/lib/digital_crc32_bb.cc +++ /dev/null @@ -1,102 +0,0 @@ -/* -*- c++ -*- */ -/* Copyright 2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_io_signature.h> -#include <digital/crc32.h> -#include <digital_crc32_bb.h> - -digital_crc32_bb_sptr -digital_make_crc32_bb (bool check, const std::string& lengthtagname) -{ - return gnuradio::get_initial_sptr (new digital_crc32_bb(check, lengthtagname)); -} - - -digital_crc32_bb::digital_crc32_bb (bool check, const std::string& lengthtagname) - : gr_tagged_stream_block ("crc32_bb", - gr_make_io_signature(1, 1, sizeof (char)), - gr_make_io_signature(1, 1, sizeof (char)), - lengthtagname), - d_check(check) -{ - set_tag_propagation_policy(TPP_DONT); -} - - -digital_crc32_bb::~digital_crc32_bb() -{ -} - - -int -digital_crc32_bb::calculate_output_stream_length(const std::vector<int> &ninput_items) -{ - if (d_check) { - return ninput_items[0] - 4; - } else { - return ninput_items[0] + 4; - } -} - - -int -digital_crc32_bb::work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const unsigned char *in = (const unsigned char *) input_items[0]; - unsigned char *out = (unsigned char *) output_items[0]; - long packet_length = ninput_items[0]; - int packet_size_diff = d_check ? -4 : 4; - unsigned int crc; - - if (d_check) { - crc = gr::digital::crc32(in, packet_length-4); - if (crc != *(unsigned int *)(in+packet_length-4)) { // Drop package - return 0; - } - memcpy((void *) out, (const void *) in, packet_length-4); - } else { - crc = gr::digital::crc32(in, packet_length); - memcpy((void *) out, (const void *) in, packet_length); - memcpy((void *) (out + packet_length), &crc, 4); // FIXME big-endian/little-endian, this might be wrong - } - - std::vector<gr_tag_t> tags; - get_tags_in_range(tags, 0, nitems_read(0), nitems_read(0)+packet_length); - for (unsigned i = 0; i < tags.size(); i++) { - tags[i].offset -= nitems_read(0); - if (d_check && tags[i].offset > packet_length+packet_size_diff) { - tags[i].offset = packet_length-5; - } - add_item_tag(0, nitems_written(0) + tags[i].offset, - tags[i].key, - tags[i].value); - } - - return packet_length + packet_size_diff; -} - diff --git a/gr-digital/lib/digital_ofdm_carrier_allocator_cvc.cc b/gr-digital/lib/digital_ofdm_carrier_allocator_cvc.cc deleted file mode 100644 index e5b3013302..0000000000 --- a/gr-digital/lib/digital_ofdm_carrier_allocator_cvc.cc +++ /dev/null @@ -1,156 +0,0 @@ -/* -*- c++ -*- */ -/* Copyright 2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_io_signature.h> -#include "digital_ofdm_carrier_allocator_cvc.h" - -digital_ofdm_carrier_allocator_cvc_sptr -digital_make_ofdm_carrier_allocator_cvc ( - int fft_len, - const std::vector<std::vector<int> > &occupied_carriers, - const std::vector<std::vector<int> > &pilot_carriers, - const std::vector<std::vector<gr_complex> > &pilot_symbols, - const std::string &len_tag_key) -{ - return gnuradio::get_initial_sptr (new digital_ofdm_carrier_allocator_cvc(fft_len, occupied_carriers, pilot_carriers, pilot_symbols, len_tag_key)); -} - - -digital_ofdm_carrier_allocator_cvc::digital_ofdm_carrier_allocator_cvc ( - int fft_len, - const std::vector<std::vector<int> > &occupied_carriers, - const std::vector<std::vector<int> > &pilot_carriers, - const std::vector<std::vector<gr_complex> > &pilot_symbols, - const std::string &len_tag_key) - : gr_tagged_stream_block ("ofdm_carrier_allocator_cvc", - gr_make_io_signature(1, 1, sizeof (gr_complex)), - gr_make_io_signature(1, 1, sizeof (gr_complex) * fft_len), len_tag_key), - d_fft_len(fft_len), - d_occupied_carriers(occupied_carriers), - d_pilot_carriers(pilot_carriers), - d_pilot_symbols(pilot_symbols), - d_symbols_per_set(0) -{ - for (unsigned i = 0; i < d_occupied_carriers.size(); i++) { - for (unsigned j = 0; j < d_occupied_carriers[i].size(); j++) { - if (occupied_carriers[i][j] < 0) { - d_occupied_carriers[i][j] += d_fft_len; - } - if (d_occupied_carriers[i][j] > d_fft_len || d_occupied_carriers[i][j] < 0) { - throw std::invalid_argument("data carrier index out of bounds"); - } - } - } - for (unsigned i = 0; i < d_pilot_carriers.size(); i++) { - if (d_pilot_carriers[i].size() != pilot_symbols[i].size()) { - throw std::invalid_argument("pilot_carriers do not match pilot_symbols"); - } - for (unsigned j = 0; j < d_pilot_carriers[i].size(); j++) { - if (d_pilot_carriers[i][j] < 0) { - d_pilot_carriers[i][j] += d_fft_len; - } - if (d_pilot_carriers[i][j] > d_fft_len || d_pilot_carriers[i][j] < 0) { - throw std::invalid_argument("pilot carrier index out of bounds"); - } - } - } - - for (unsigned i = 0; i < d_occupied_carriers.size(); i++) { - d_symbols_per_set += d_occupied_carriers[i].size(); - } - set_tag_propagation_policy(TPP_DONT); - set_relative_rate((double) d_symbols_per_set / d_occupied_carriers.size()); -} - - -digital_ofdm_carrier_allocator_cvc::~digital_ofdm_carrier_allocator_cvc() -{ -} - - -int -digital_ofdm_carrier_allocator_cvc::calculate_output_stream_length(const gr_vector_int &ninput_items) -{ - int nin = ninput_items[0]; - int nout = (nin / d_symbols_per_set) * d_occupied_carriers.size(); - int k = 0; - for (int i = 0; i < nin % d_symbols_per_set; k++) { - nout++; - i += d_occupied_carriers[k % d_occupied_carriers.size()].size(); - } - return nout; -} - - -int -digital_ofdm_carrier_allocator_cvc::work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const gr_complex *in = (const gr_complex *) input_items[0]; - gr_complex *out = (gr_complex *) output_items[0]; - - std::vector<gr_tag_t> tags; - - memset((void *) out, 0x00, sizeof(gr_complex) * d_fft_len * noutput_items); - long n_ofdm_symbols = 0; - int curr_set = 0; - int symbols_to_allocate = d_occupied_carriers[0].size(); - int symbols_allocated = 0; - for (int i = 0; i < ninput_items[0]; i++) { - if (symbols_allocated == 0) { - // Copy all tags associated with these input symbols onto this OFDM symbol - get_tags_in_range(tags, 0, - nitems_read(0)+i, - nitems_read(0)+std::min(i+symbols_to_allocate, (int) ninput_items[0]) - ); - for (unsigned t = 0; t < tags.size(); t++) { - add_item_tag(0, nitems_written(0)+n_ofdm_symbols, - tags[t].key, - tags[t].value); - } - n_ofdm_symbols++; - } - out[(n_ofdm_symbols-1) * d_fft_len + d_occupied_carriers[curr_set][symbols_allocated]] = in[i]; - symbols_allocated++; - if (symbols_allocated == symbols_to_allocate) { - curr_set = (curr_set + 1) % d_occupied_carriers.size(); - symbols_to_allocate = d_occupied_carriers[curr_set].size(); - symbols_allocated = 0; - } - } - // 2) Copy pilot symbols - curr_set = 0; - for (int i = 0; i < n_ofdm_symbols; i++) { - for (unsigned k = 0; k < d_pilot_carriers[curr_set].size(); k++) { - out[i * d_fft_len + d_pilot_carriers[curr_set][k]] = d_pilot_symbols[curr_set][k]; - } - curr_set = (curr_set + 1) % d_pilot_carriers.size(); - } - - return n_ofdm_symbols; -} - diff --git a/gr-digital/lib/digital_ofdm_chanest_vcvc.cc b/gr-digital/lib/digital_ofdm_chanest_vcvc.cc deleted file mode 100644 index a484594577..0000000000 --- a/gr-digital/lib/digital_ofdm_chanest_vcvc.cc +++ /dev/null @@ -1,281 +0,0 @@ -/* -*- c++ -*- */ -// vim: set sw=2: -/* Copyright 2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_io_signature.h> -#include "digital_ofdm_chanest_vcvc.h" - -digital_ofdm_chanest_vcvc_sptr -digital_make_ofdm_chanest_vcvc ( - const std::vector<gr_complex> &sync_symbol1, - const std::vector<gr_complex> &sync_symbol2, - int n_data_symbols, - int eq_noise_red_len, - int max_carr_offset, - bool force_one_sync_symbol) -{ - return gnuradio::get_initial_sptr (new digital_ofdm_chanest_vcvc( - sync_symbol1, sync_symbol2, n_data_symbols, eq_noise_red_len, max_carr_offset, force_one_sync_symbol)); -} - - -digital_ofdm_chanest_vcvc::digital_ofdm_chanest_vcvc ( - const std::vector<gr_complex> &sync_symbol1, - const std::vector<gr_complex> &sync_symbol2, - int n_data_symbols, - int eq_noise_red_len, - int max_carr_offset, - bool force_one_sync_symbol) - : gr_block ("ofdm_chanest_vcvc", - gr_make_io_signature(1, 1, sizeof (gr_complex) * sync_symbol1.size()), - gr_make_io_signature(1, 1, sizeof (gr_complex) * sync_symbol1.size())), - d_fft_len(sync_symbol1.size()), - d_n_data_syms(n_data_symbols), - d_n_sync_syms(1), - d_eq_noise_red_len(eq_noise_red_len), - d_ref_sym((sync_symbol2.size() && !force_one_sync_symbol) ? sync_symbol2 : sync_symbol1), - d_corr_v(sync_symbol2), - d_known_symbol_diffs(0, 0), - d_new_symbol_diffs(0, 0), - d_interpolate(false) -{ - // Set index of first and last active carrier - for (int i = 0; i < d_fft_len; i++) { - if (d_ref_sym[i] != gr_complex(0, 0)) { - d_first_active_carrier = i; - break; - } - } - for (int i = d_fft_len-1; i >= 0; i--) { - if (d_ref_sym[i] != gr_complex(0, 0)) { - d_last_active_carrier = i; - break; - } - } - - // Sanity checks - if (sync_symbol2.size()) { - if (sync_symbol1.size() != sync_symbol2.size()) { - throw std::invalid_argument("sync symbols must have equal length."); - } - if (!force_one_sync_symbol) { - d_n_sync_syms = 2; - } - } else { - if (sync_symbol1[d_first_active_carrier+1] == gr_complex(0, 0)) { - d_last_active_carrier++; - d_interpolate = true; - } - } - - // Set up coarse freq estimation info - // Allow all possible values: - d_max_neg_carr_offset = -d_first_active_carrier; - d_max_pos_carr_offset = d_fft_len - d_last_active_carrier - 1; - if (max_carr_offset != -1) { - d_max_neg_carr_offset = std::max(-max_carr_offset, d_max_neg_carr_offset); - d_max_pos_carr_offset = std::min(max_carr_offset, d_max_pos_carr_offset); - } - // Carrier offsets must be even - if (d_max_neg_carr_offset % 2) - d_max_neg_carr_offset++; - if (d_max_pos_carr_offset % 2) - d_max_pos_carr_offset--; - - if (d_n_sync_syms == 2) { - for (int i = 0; i < d_fft_len; i++) { - if (sync_symbol1[i] == gr_complex(0, 0)) { - d_corr_v[i] = gr_complex(0, 0); - } else { - d_corr_v[i] /= sync_symbol1[i]; - } - } - } else { - d_corr_v.resize(0, 0); - d_known_symbol_diffs.resize(d_fft_len, 0); - d_new_symbol_diffs.resize(d_fft_len, 0); - for (int i = d_first_active_carrier; i < d_last_active_carrier-2 && i < d_fft_len-2; i += 2) { - d_known_symbol_diffs[i] = std::norm(sync_symbol1[i] - sync_symbol1[i+2]); - } - } - - set_relative_rate((double) n_data_symbols / (n_data_symbols + d_n_sync_syms)); - set_tag_propagation_policy(TPP_DONT); -} - - -digital_ofdm_chanest_vcvc::~digital_ofdm_chanest_vcvc() -{ -} - -void -digital_ofdm_chanest_vcvc::forecast (int noutput_items, gr_vector_int &ninput_items_required) -{ - ninput_items_required[0] = (noutput_items/d_n_data_syms) * (d_n_data_syms + d_n_sync_syms); -} - - -int -digital_ofdm_chanest_vcvc::get_carr_offset(const gr_complex *sync_sym1, const gr_complex *sync_sym2) -{ - int carr_offset = 0; - if (d_corr_v.size()) { - // Use Schmidl & Cox method - float Bg_max = 0; - // g here is 2g in the paper - for (int g = d_max_neg_carr_offset; g <= d_max_pos_carr_offset; g += 2) { - gr_complex tmp = gr_complex(0, 0); - for (int k = 0; k < d_fft_len; k++) { - if (d_corr_v[k] != gr_complex(0, 0)) { - tmp += std::conj(sync_sym1[k+g]) * std::conj(d_corr_v[k]) * sync_sym2[k+g]; - } - } - if (std::abs(tmp) > Bg_max) { - Bg_max = std::abs(tmp); - carr_offset = g; - } - } - } else { - // Correlate - std::fill(d_new_symbol_diffs.begin(), d_new_symbol_diffs.end(), 0); - for(int i = 0; i < d_fft_len-2; i++) { - d_new_symbol_diffs[i] = std::norm(sync_sym1[i] - sync_sym1[i+2]); - } - - float sum; - float max = 0; - for (int g = d_max_neg_carr_offset; g <= d_max_pos_carr_offset; g += 2) { - sum = 0; - for (int j = 0; j < d_fft_len; j++) { - if (d_known_symbol_diffs[j]) { - sum += (d_known_symbol_diffs[j] * d_new_symbol_diffs[j + g]); - } - if(sum > max) { - max = sum; - carr_offset = g; - } - } - } - } - return carr_offset; -} - - -void -digital_ofdm_chanest_vcvc::get_chan_taps( - const gr_complex *sync_sym1, - const gr_complex *sync_sym2, - int carr_offset, - std::vector<gr_complex> &taps) -{ - const gr_complex *sym = ((d_n_sync_syms == 2) ? sync_sym2 : sync_sym1); - std::fill(taps.begin(), taps.end(), gr_complex(0, 0)); - int loop_start = 0; - int loop_end = d_fft_len; - if (carr_offset > 0) { - loop_start = carr_offset; - } else if (carr_offset < 0) { - loop_end = d_fft_len + carr_offset; - } - for (int i = loop_start; i < loop_end; i++) { - if ((d_ref_sym[i-carr_offset] != gr_complex(0, 0))) { - taps[i] = sym[i] / d_ref_sym[i-carr_offset]; - } - } - - if (d_interpolate) { - for (int i = d_first_active_carrier + 1; i < d_last_active_carrier; i += 2) { - taps[i] = (taps[i-1] + taps[i+1]) / gr_complex(2.0, 0); - } - taps[d_last_active_carrier] = taps[d_last_active_carrier-1]; - } - - if (d_eq_noise_red_len) { - // TODO - // 1) IFFT - // 2) Set all elements > d_eq_noise_red_len to zero - // 3) FFT - } -} - - -// 1) Go through all the frames available on the input buffer -// 2) Estimate the coarse freq. offset and the eq. taps from the -// input symbol(s) -// 3) Copy the data symbols to the output -// 4) Copy all other tags onto the output. A tag that was on -// a sync symbol is copied onto the first data symbol. -// 5) Add the new tags for carrier offset and eq. taps -int -digital_ofdm_chanest_vcvc::general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const gr_complex *in = (const gr_complex *) input_items[0]; - gr_complex *out = (gr_complex *) output_items[0]; - int n_frames = noutput_items/d_n_data_syms; - const int framesize = d_n_sync_syms + d_n_data_syms; - - for (int i = 0; i < n_frames; i++) { - int carr_offset = 0; - if (d_max_neg_carr_offset || d_max_pos_carr_offset) - carr_offset = get_carr_offset(in, in+d_fft_len); - std::vector<gr_complex> chan_taps(d_fft_len, 0); - get_chan_taps(in, in+d_fft_len, carr_offset, chan_taps); - - memcpy((void *) out, - (void *) &in[d_n_sync_syms * d_fft_len], - sizeof(gr_complex) * d_fft_len * d_n_data_syms); - in += framesize * d_fft_len; - out += d_n_data_syms * d_fft_len; - - std::vector<gr_tag_t> tags; - this->get_tags_in_range(tags, 0, - this->nitems_read(0)+i*framesize, - this->nitems_read(0)+(i+1)*framesize); - for (unsigned t = 0; t < tags.size(); t++) { - int offset = tags[t].offset - (this->nitems_read(0) + i*framesize); - if (offset < d_n_sync_syms) { - offset = 0; - } else { - offset -= d_n_sync_syms; - } - tags[t].offset = offset + this->nitems_written(0) + i*d_n_data_syms; - this->add_item_tag(0, tags[t]); - } - - this->add_item_tag(0, this->nitems_written(0) + i*d_n_data_syms, - pmt::string_to_symbol("ofdm_sync_carr_offset"), - pmt::from_long(carr_offset)); - this->add_item_tag(0, this->nitems_written(0) + i*d_n_data_syms, - pmt::string_to_symbol("ofdm_sync_chan_taps"), - pmt::init_c32vector(d_fft_len, chan_taps)); - } - - consume_each(n_frames * framesize); - return n_frames * d_n_data_syms; -} - diff --git a/gr-digital/lib/digital_ofdm_cyclic_prefixer.cc b/gr-digital/lib/digital_ofdm_cyclic_prefixer.cc deleted file mode 100644 index ada5742a51..0000000000 --- a/gr-digital/lib/digital_ofdm_cyclic_prefixer.cc +++ /dev/null @@ -1,162 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2006,2010,2011 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <cmath> -#include <digital_ofdm_cyclic_prefixer.h> -#include <gr_io_signature.h> - -digital_ofdm_cyclic_prefixer_sptr -digital_make_ofdm_cyclic_prefixer (size_t input_size, - size_t output_size, - int rolloff_len, - const std::string &len_tag_key) -{ - return gnuradio::get_initial_sptr(new digital_ofdm_cyclic_prefixer (input_size, - output_size, - rolloff_len, - len_tag_key)); -} - -digital_ofdm_cyclic_prefixer::digital_ofdm_cyclic_prefixer (size_t input_size, - size_t output_size, - int rolloff_len, - const std::string &len_tag_key) - : gr_tagged_stream_block ("ofdm_cyclic_prefixer", - gr_make_io_signature (1, 1, input_size*sizeof(gr_complex)), - gr_make_io_signature (1, 1, sizeof(gr_complex)), - len_tag_key), - d_fft_len(input_size), - d_output_size(output_size), - d_cp_size(output_size - input_size), - d_rolloff_len(rolloff_len), - d_up_flank((rolloff_len ? rolloff_len-1 : 0), 0), - d_down_flank((rolloff_len ? rolloff_len-1 : 0), 0), - d_delay_line(0, 0) -{ - set_relative_rate(d_output_size); - - // Flank of length 1 would just be rectangular - if (d_rolloff_len == 1) { - d_rolloff_len = 0; - } - if (d_rolloff_len) { - d_delay_line.resize(d_rolloff_len-1, 0); - if (rolloff_len > d_cp_size) { - throw std::invalid_argument("cyclic prefixer: rolloff len must smaller than the cyclic prefix."); - } - // The actual flanks are one sample shorter than d_rolloff_len, because the - // first sample of the up- and down flank is always zero and one, respectively - for (int i = 1; i < d_rolloff_len; i++) { - d_up_flank[i-1] = 0.5 * (1 + cos(M_PI * i/rolloff_len - M_PI)); - d_down_flank[i-1] = 0.5 * (1 + cos(M_PI * (rolloff_len-i)/rolloff_len - M_PI)); - } - } - - if (len_tag_key.empty()) { - set_output_multiple(d_output_size); - } else { - set_tag_propagation_policy(TPP_DONT); - } -} - -int -digital_ofdm_cyclic_prefixer::calculate_output_stream_length(const gr_vector_int &ninput_items) -{ - int nout = ninput_items[0] * d_output_size + d_delay_line.size(); - return nout; -} - -// Operates in two ways: -// - When there's a length tag name specified, operates in packet mode. -// Here, an entire OFDM frame is processed at once. The final OFDM symbol -// is postfixed with the delay line of the pulse shape. -// We manually propagate tags. -// - Otherwise, we're in freewheeling mode. Process as many OFDM symbols as -// are space for in the output buffer. The delay line is never flushed. -// Tags are propagated by the scheduler. -int -digital_ofdm_cyclic_prefixer::work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - gr_complex *in = (gr_complex *) input_items[0]; - gr_complex *out = (gr_complex *) output_items[0]; - int symbols_to_read = 0; - - // 1) Figure out if we're in freewheeling or packet mode - if (!d_length_tag_key_str.empty()) { - symbols_to_read = ninput_items[0]; - noutput_items = symbols_to_read * d_output_size + d_delay_line.size(); - } else { - symbols_to_read = std::min(noutput_items / (int) d_output_size, ninput_items[0]); - noutput_items = symbols_to_read * d_output_size; - } - - // 2) Do the cyclic prefixing and, optionally, the pulse shaping - for (int sym_idx = 0; sym_idx < symbols_to_read; sym_idx++) { - memcpy((void *)(out + d_cp_size), (void *) in, d_fft_len * sizeof(gr_complex)); - memcpy((void *) out, (void *) (in + d_fft_len - d_cp_size), d_cp_size * sizeof(gr_complex)); - if (d_rolloff_len) { - for (int i = 0; i < d_rolloff_len-1; i++) { - out[i] = out[i] * d_up_flank[i] + d_delay_line[i]; - d_delay_line[i] = in[i] * d_down_flank[i]; - } - } - in += d_fft_len; - out += d_output_size; - } - - // 3) If we're in packet mode: - // - flush the delay line, if applicable - // - Propagate tags - if (!d_length_tag_key_str.empty()) { - if (d_rolloff_len) { - for (unsigned i = 0; i < d_delay_line.size(); i++) { - *out++ = d_delay_line[i]; - } - d_delay_line.assign(d_delay_line.size(), 0); - } - std::vector<gr_tag_t> tags; - get_tags_in_range( - tags, 0, - nitems_read(0), nitems_read(0)+symbols_to_read - ); - for (unsigned i = 0; i < tags.size(); i++) { - tags[i].offset = ((tags[i].offset - nitems_read(0)) * d_output_size) + nitems_written(0); - add_item_tag(0, - tags[i].offset, - tags[i].key, - tags[i].value - ); - } - } else { - consume_each(symbols_to_read); - } - - return noutput_items; -} - diff --git a/gr-digital/lib/digital_ofdm_equalizer_base.cc b/gr-digital/lib/digital_ofdm_equalizer_base.cc deleted file mode 100644 index b4fa5df87e..0000000000 --- a/gr-digital/lib/digital_ofdm_equalizer_base.cc +++ /dev/null @@ -1,116 +0,0 @@ -/* -*- c++ -*- */ -/* Copyright 2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "digital_ofdm_equalizer_base.h" - -// *** Base class **************************************************** -digital_ofdm_equalizer_base::digital_ofdm_equalizer_base(int fft_len) : - d_fft_len(fft_len), - d_carr_offset(0) -{ -} - - -digital_ofdm_equalizer_base::~digital_ofdm_equalizer_base() -{ -} - - -// *** Sub-Base class for 1D equalizers using pilot tones ************* -digital_ofdm_equalizer_1d_pilots::digital_ofdm_equalizer_1d_pilots( - int fft_len, - const std::vector<std::vector<int> > &occupied_carriers, - const std::vector<std::vector<int> > &pilot_carriers, - const std::vector<std::vector<gr_complex> > &pilot_symbols, - int symbols_skipped, - bool input_is_shifted) - : digital_ofdm_equalizer_base(fft_len), - d_occupied_carriers(fft_len, false), - d_pilot_carriers(pilot_carriers.size(), std::vector<bool>(fft_len, false)), - d_pilot_symbols(pilot_symbols.size(), std::vector<gr_complex>(fft_len, gr_complex(0, 0))), - d_symbols_skipped(symbols_skipped), - d_pilot_carr_set(symbols_skipped), - d_channel_state(fft_len, gr_complex(1, 0)) -{ - int fft_shift_width = 0; - if (input_is_shifted) { - fft_shift_width = fft_len/2; - } - if (!occupied_carriers.size()) { - std::fill(d_occupied_carriers.begin(), d_occupied_carriers.end(), true); - } else { - for (unsigned i = 0; i < occupied_carriers.size(); i++) { - for (unsigned k = 0; k < occupied_carriers[i].size(); k++) { - int carr_index = occupied_carriers[i][k]; - if (occupied_carriers[i][k] < 0) { - carr_index += fft_len; - } - if (carr_index >= fft_len || carr_index < 0) { - throw std::invalid_argument("data carrier index out of bounds."); - } - d_occupied_carriers[(carr_index + fft_shift_width) % fft_len] = true; - } - } - } - if (pilot_carriers.size()) { - for (unsigned i = 0; i < pilot_carriers.size(); i++) { - if (pilot_carriers[i].size() != pilot_symbols[i].size()) { - throw std::invalid_argument("pilot carriers and -symbols do not match."); - } - for (unsigned k = 0; k < pilot_carriers[i].size(); k++) { - int carr_index = pilot_carriers[i][k]; - if (pilot_carriers[i][k] < 0) { - carr_index += fft_len; - } - if (carr_index >= fft_len || carr_index < 0) { - throw std::invalid_argument("pilot carrier index out of bounds."); - } - d_pilot_carriers[i][(carr_index + fft_shift_width) % fft_len] = true; - d_pilot_symbols[i][(carr_index + fft_shift_width) % fft_len] = pilot_symbols[i][k]; - } - } - } -} - - -digital_ofdm_equalizer_1d_pilots::~digital_ofdm_equalizer_1d_pilots() -{ -} - - -void -digital_ofdm_equalizer_1d_pilots::reset() -{ - std::fill(d_channel_state.begin(), d_channel_state.end(), gr_complex(1, 0)); - d_pilot_carr_set = d_symbols_skipped; -} - - -void digital_ofdm_equalizer_1d_pilots::get_channel_state(std::vector<gr_complex> &taps) -{ - taps = d_channel_state; -} - - diff --git a/gr-digital/lib/digital_ofdm_equalizer_simpledfe.cc b/gr-digital/lib/digital_ofdm_equalizer_simpledfe.cc deleted file mode 100644 index c6a05b9da8..0000000000 --- a/gr-digital/lib/digital_ofdm_equalizer_simpledfe.cc +++ /dev/null @@ -1,101 +0,0 @@ -/* -*- c++ -*- */ -/* Copyright 2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "digital_ofdm_equalizer_simpledfe.h" - -digital_ofdm_equalizer_simpledfe_sptr -digital_make_ofdm_equalizer_simpledfe( - int fft_len, - const gr::digital::constellation_sptr &constellation, - const std::vector<std::vector<int> > &occupied_carriers, - const std::vector<std::vector<int> > &pilot_carriers, - const std::vector<std::vector<gr_complex> > &pilot_symbols, - int symbols_skipped, - float alpha, - bool input_is_shifted) -{ - return digital_ofdm_equalizer_simpledfe_sptr(new digital_ofdm_equalizer_simpledfe( - fft_len, - constellation, - occupied_carriers, - pilot_carriers, - pilot_symbols, - symbols_skipped, - alpha, - input_is_shifted)); -} - -digital_ofdm_equalizer_simpledfe::digital_ofdm_equalizer_simpledfe( - int fft_len, - const gr::digital::constellation_sptr &constellation, - const std::vector<std::vector<int> > &occupied_carriers, - const std::vector<std::vector<int> > &pilot_carriers, - const std::vector<std::vector<gr_complex> > &pilot_symbols, - int symbols_skipped, - float alpha, - bool input_is_shifted) - : digital_ofdm_equalizer_1d_pilots(fft_len, occupied_carriers, pilot_carriers, pilot_symbols, symbols_skipped, input_is_shifted), - d_constellation(constellation), - d_alpha(alpha) -{ -} - - -digital_ofdm_equalizer_simpledfe::~digital_ofdm_equalizer_simpledfe() -{ -} - - -void -digital_ofdm_equalizer_simpledfe::equalize(gr_complex *frame, - int n_sym, - const std::vector<gr_complex> &initial_taps, - const std::vector<gr_tag_t> &tags) -{ - if (!initial_taps.empty()) { - d_channel_state = initial_taps; - } - gr_complex sym_eq, sym_est; - - for (int i = 0; i < n_sym; i++) { - for (int k = 0; k < d_fft_len; k++) { - if (!d_occupied_carriers[k]) { - continue; - } - if (d_pilot_carriers.size() && d_pilot_carriers[d_pilot_carr_set][k-d_carr_offset]) { - d_channel_state[k] = d_alpha * d_channel_state[k] - + (1-d_alpha) * frame[i*d_fft_len + k] / d_pilot_symbols[d_pilot_carr_set][k-d_carr_offset]; - frame[i*d_fft_len+k] = d_pilot_symbols[d_pilot_carr_set][k-d_carr_offset]; - } else { - sym_eq = frame[i*d_fft_len+k] / d_channel_state[k]; - d_constellation->map_to_points(d_constellation->decision_maker(&sym_eq), &sym_est); - d_channel_state[k] = d_alpha * d_channel_state[k] + frame[i*d_fft_len+k] / sym_est; - frame[i*d_fft_len+k] = sym_est; - } - } - d_pilot_carr_set = (d_pilot_carr_set + 1) % d_pilot_carriers.size(); - } -} - diff --git a/gr-digital/lib/digital_ofdm_equalizer_static.cc b/gr-digital/lib/digital_ofdm_equalizer_static.cc deleted file mode 100644 index 66903fa90a..0000000000 --- a/gr-digital/lib/digital_ofdm_equalizer_static.cc +++ /dev/null @@ -1,90 +0,0 @@ -/* -*- c++ -*- */ -/* Copyright 2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "digital_ofdm_equalizer_static.h" - -#include <iostream> - -digital_ofdm_equalizer_static_sptr -digital_make_ofdm_equalizer_static( - int fft_len, - const std::vector<std::vector<int> > &occupied_carriers, - const std::vector<std::vector<int> > &pilot_carriers, - const std::vector<std::vector<gr_complex> > &pilot_symbols, - int symbols_skipped, - bool input_is_shifted) -{ - return digital_ofdm_equalizer_static_sptr(new digital_ofdm_equalizer_static( - fft_len, - occupied_carriers, - pilot_carriers, - pilot_symbols, - symbols_skipped, - input_is_shifted)); -} - -digital_ofdm_equalizer_static::digital_ofdm_equalizer_static( - int fft_len, - const std::vector<std::vector<int> > &occupied_carriers, - const std::vector<std::vector<int> > &pilot_carriers, - const std::vector<std::vector<gr_complex> > &pilot_symbols, - int symbols_skipped, - bool input_is_shifted) - : digital_ofdm_equalizer_1d_pilots(fft_len, occupied_carriers, pilot_carriers, pilot_symbols, symbols_skipped, input_is_shifted) -{ -} - - -digital_ofdm_equalizer_static::~digital_ofdm_equalizer_static() -{ -} - - -void -digital_ofdm_equalizer_static::equalize(gr_complex *frame, - int n_sym, - const std::vector<gr_complex> &initial_taps, - const std::vector<gr_tag_t> &tags) -{ - d_channel_state = initial_taps; - - for (int i = 0; i < n_sym; i++) { - for (int k = 0; k < d_fft_len; k++) { - if (!d_occupied_carriers[k]) { - continue; - } - if (d_pilot_carriers.size() && d_pilot_carriers[d_pilot_carr_set][k-d_carr_offset]) { - d_channel_state[k] = frame[i*d_fft_len + k] / d_pilot_symbols[d_pilot_carr_set][k-d_carr_offset]; - frame[i*d_fft_len+k] = d_pilot_symbols[d_pilot_carr_set][k-d_carr_offset]; - } else { - frame[i*d_fft_len+k] /= d_channel_state[k]; - } - } - if (!d_pilot_carriers.empty()) { - d_pilot_carr_set = (d_pilot_carr_set + 1) % d_pilot_carriers.size(); - } - } -} - diff --git a/gr-digital/lib/digital_ofdm_sync_sc_cfb.cc b/gr-digital/lib/digital_ofdm_sync_sc_cfb.cc deleted file mode 100644 index dbb8571c28..0000000000 --- a/gr-digital/lib/digital_ofdm_sync_sc_cfb.cc +++ /dev/null @@ -1,109 +0,0 @@ -/* -*- c++ -*- */ -/* Copyright 2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_io_signature.h> -#include "digital_ofdm_sync_sc_cfb.h" - -#include <analog/plateau_detector_fb.h> -#include <blocks/complex_to_arg.h> -#include <blocks/complex_to_mag_squared.h> -#include <blocks/conjugate_cc.h> -#include <blocks/delay.h> -#include <blocks/divide_ff.h> -#include <blocks/multiply_cc.h> -#include <blocks/multiply_ff.h> -#include <blocks/sample_and_hold_ff.h> -#include <filter/fir_filter_ccf.h> -#include <filter/fir_filter_fff.h> - -// Define this to add a third output for debugging -//#define SYNC_ADD_DEBUG_OUTPUT - -digital_ofdm_sync_sc_cfb_sptr -digital_make_ofdm_sync_sc_cfb (int fft_len, int cp_len) -{ - return gnuradio::get_initial_sptr (new digital_ofdm_sync_sc_cfb(fft_len, cp_len)); -} - - -digital_ofdm_sync_sc_cfb::digital_ofdm_sync_sc_cfb (int fft_len, int cp_len) - : gr_hier_block2 ("ofdm_sync_sc_cfb", - gr_make_io_signature(1, 1, sizeof (gr_complex)), -#ifndef SYNC_ADD_DEBUG_OUTPUT - gr_make_io_signature2(2, 2, sizeof (float), sizeof (unsigned char))) -#else - gr_make_io_signature3(3, 3, sizeof (float), sizeof (unsigned char), sizeof (float))) -#endif -{ - std::vector<float> ma_taps(fft_len/2, 1.0); - gr::blocks::delay::sptr delay(gr::blocks::delay::make(sizeof(gr_complex), fft_len/2)); - gr::blocks::conjugate_cc::sptr delay_conjugate(gr::blocks::conjugate_cc::make()); - gr::blocks::multiply_cc::sptr delay_corr(gr::blocks::multiply_cc::make()); - gr::filter::fir_filter_ccf::sptr delay_ma(gr::filter::fir_filter_ccf::make(1, std::vector<float>(fft_len/2, 1.0))); - gr::blocks::complex_to_mag_squared::sptr delay_magsquare(gr::blocks::complex_to_mag_squared::make()); - gr::blocks::divide_ff::sptr delay_normalize(gr::blocks::divide_ff::make()); - - gr::blocks::complex_to_mag_squared::sptr normalizer_magsquare(gr::blocks::complex_to_mag_squared::make()); - gr::filter::fir_filter_fff::sptr normalizer_ma(gr::filter::fir_filter_fff::make(1, std::vector<float>(fft_len, 0.5))); - gr::blocks::multiply_ff::sptr normalizer_square(gr::blocks::multiply_ff::make()); - - gr::blocks::complex_to_arg::sptr peak_to_angle(gr::blocks::complex_to_arg::make()); - gr::blocks::sample_and_hold_ff::sptr sample_and_hold(gr::blocks::sample_and_hold_ff::make()); - - gr::analog::plateau_detector_fb::sptr plateau_detector(gr::analog::plateau_detector_fb::make(cp_len)); - - // Delay Path - connect(self(), 0, delay, 0); - connect(delay, 0, delay_conjugate, 0); - connect(delay_conjugate, 0, delay_corr, 1); - connect(self(), 0, delay_corr, 0); - connect(delay_corr, 0, delay_ma, 0); - connect(delay_ma, 0, delay_magsquare, 0); - connect(delay_magsquare, 0, delay_normalize, 0); - // Energy Path - connect(self(), 0, normalizer_magsquare, 0); - connect(normalizer_magsquare, 0, normalizer_ma, 0); - connect(normalizer_ma, 0, normalizer_square, 0); - connect(normalizer_ma, 0, normalizer_square, 1); - connect(normalizer_square, 0, delay_normalize, 1); - // Fine frequency estimate (output 0) - connect(delay_ma, 0, peak_to_angle, 0); - connect(peak_to_angle, 0, sample_and_hold, 0); - connect(sample_and_hold, 0, self(), 0); - // Peak detect (output 1) - connect(delay_normalize, 0, plateau_detector, 0); - connect(plateau_detector, 0, sample_and_hold, 1); - connect(plateau_detector, 0, self(), 1); -#ifdef SYNC_ADD_DEBUG_OUTPUT - // Debugging: timing metric (output 2) - connect(delay_normalize, 0, self(), 2); -#endif -} - - -digital_ofdm_sync_sc_cfb::~digital_ofdm_sync_sc_cfb() -{ -} - diff --git a/gr-digital/lib/ofdm_carrier_allocator_cvc_impl.cc b/gr-digital/lib/ofdm_carrier_allocator_cvc_impl.cc new file mode 100644 index 0000000000..d7159547b4 --- /dev/null +++ b/gr-digital/lib/ofdm_carrier_allocator_cvc_impl.cc @@ -0,0 +1,162 @@ +/* -*- c++ -*- */ +/* + * Copyright 2013 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_io_signature.h> +#include "ofdm_carrier_allocator_cvc_impl.h" + +namespace gr { + namespace digital { + + ofdm_carrier_allocator_cvc::sptr + ofdm_carrier_allocator_cvc::make( + int fft_len, + const std::vector<std::vector<int> > &occupied_carriers, + const std::vector<std::vector<int> > &pilot_carriers, + const std::vector<std::vector<gr_complex> > &pilot_symbols, + const std::string &len_tag_key) + { + return gnuradio::get_initial_sptr( + new ofdm_carrier_allocator_cvc_impl( + fft_len, + occupied_carriers, + pilot_carriers, + pilot_symbols, + len_tag_key + ) + ); + } + + ofdm_carrier_allocator_cvc_impl::ofdm_carrier_allocator_cvc_impl(int fft_len, const std::vector<std::vector<int> > &occupied_carriers, const std::vector<std::vector<int> > &pilot_carriers, const std::vector<std::vector<gr_complex> > &pilot_symbols, const std::string &len_tag_key) + : gr_tagged_stream_block("ofdm_carrier_allocator_cvc", + gr_make_io_signature(1, 1, sizeof (gr_complex)), + gr_make_io_signature(1, 1, sizeof (gr_complex) * fft_len), len_tag_key), + d_fft_len(fft_len), + d_occupied_carriers(occupied_carriers), + d_pilot_carriers(pilot_carriers), + d_pilot_symbols(pilot_symbols), + d_symbols_per_set(0) + { + for (unsigned i = 0; i < d_occupied_carriers.size(); i++) { + for (unsigned j = 0; j < d_occupied_carriers[i].size(); j++) { + if (occupied_carriers[i][j] < 0) { + d_occupied_carriers[i][j] += d_fft_len; + } + if (d_occupied_carriers[i][j] > d_fft_len || d_occupied_carriers[i][j] < 0) { + throw std::invalid_argument("data carrier index out of bounds"); + } + } + } + for (unsigned i = 0; i < d_pilot_carriers.size(); i++) { + if (d_pilot_carriers[i].size() != pilot_symbols[i].size()) { + throw std::invalid_argument("pilot_carriers do not match pilot_symbols"); + } + for (unsigned j = 0; j < d_pilot_carriers[i].size(); j++) { + if (d_pilot_carriers[i][j] < 0) { + d_pilot_carriers[i][j] += d_fft_len; + } + if (d_pilot_carriers[i][j] > d_fft_len || d_pilot_carriers[i][j] < 0) { + throw std::invalid_argument("pilot carrier index out of bounds"); + } + } + } + + for (unsigned i = 0; i < d_occupied_carriers.size(); i++) { + d_symbols_per_set += d_occupied_carriers[i].size(); + } + set_tag_propagation_policy(TPP_DONT); + set_relative_rate((double) d_symbols_per_set / d_occupied_carriers.size()); + } + + ofdm_carrier_allocator_cvc_impl::~ofdm_carrier_allocator_cvc_impl() + { + } + + int + ofdm_carrier_allocator_cvc_impl::calculate_output_stream_length(const gr_vector_int &ninput_items) + { + int nin = ninput_items[0]; + int nout = (nin / d_symbols_per_set) * d_occupied_carriers.size(); + int k = 0; + for (int i = 0; i < nin % d_symbols_per_set; k++) { + nout++; + i += d_occupied_carriers[k % d_occupied_carriers.size()].size(); + } + return nout; + } + + int + ofdm_carrier_allocator_cvc_impl::work (int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + const gr_complex *in = (const gr_complex *) input_items[0]; + gr_complex *out = (gr_complex *) output_items[0]; + + std::vector<gr_tag_t> tags; + + memset((void *) out, 0x00, sizeof(gr_complex) * d_fft_len * noutput_items); + long n_ofdm_symbols = 0; + int curr_set = 0; + int symbols_to_allocate = d_occupied_carriers[0].size(); + int symbols_allocated = 0; + for (int i = 0; i < ninput_items[0]; i++) { + if (symbols_allocated == 0) { + // Copy all tags associated with these input symbols onto this OFDM symbol + get_tags_in_range(tags, 0, + nitems_read(0)+i, + nitems_read(0)+std::min(i+symbols_to_allocate, (int) ninput_items[0]) + ); + for (unsigned t = 0; t < tags.size(); t++) { + add_item_tag(0, nitems_written(0)+n_ofdm_symbols, + tags[t].key, + tags[t].value); + } + n_ofdm_symbols++; + } + out[(n_ofdm_symbols-1) * d_fft_len + d_occupied_carriers[curr_set][symbols_allocated]] = in[i]; + symbols_allocated++; + if (symbols_allocated == symbols_to_allocate) { + curr_set = (curr_set + 1) % d_occupied_carriers.size(); + symbols_to_allocate = d_occupied_carriers[curr_set].size(); + symbols_allocated = 0; + } + } + // 2) Copy pilot symbols + curr_set = 0; + for (int i = 0; i < n_ofdm_symbols; i++) { + for (unsigned k = 0; k < d_pilot_carriers[curr_set].size(); k++) { + out[i * d_fft_len + d_pilot_carriers[curr_set][k]] = d_pilot_symbols[curr_set][k]; + } + curr_set = (curr_set + 1) % d_pilot_carriers.size(); + } + + return n_ofdm_symbols; + } + + } /* namespace digital */ +} /* namespace gr */ + diff --git a/gr-digital/lib/ofdm_carrier_allocator_cvc_impl.h b/gr-digital/lib/ofdm_carrier_allocator_cvc_impl.h new file mode 100644 index 0000000000..5da14332a5 --- /dev/null +++ b/gr-digital/lib/ofdm_carrier_allocator_cvc_impl.h @@ -0,0 +1,66 @@ +/* -*- c++ -*- */ +/* + * Copyright 2013 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_DIGITAL_OFDM_CARRIER_ALLOCATOR_CVC_IMPL_H +#define INCLUDED_DIGITAL_OFDM_CARRIER_ALLOCATOR_CVC_IMPL_H + +#include <digital/ofdm_carrier_allocator_cvc.h> + +namespace gr { + namespace digital { + + class ofdm_carrier_allocator_cvc_impl : public ofdm_carrier_allocator_cvc + { + private: + //! FFT length + const int d_fft_len; + //! Which carriers/symbols carry data + std::vector<std::vector<int> > d_occupied_carriers; + //! Which carriers/symbols carry pilots symbols + std::vector<std::vector<int> > d_pilot_carriers; + //! Value of said pilot symbols + const std::vector<std::vector<gr_complex> > d_pilot_symbols; + int d_symbols_per_set; + + protected: + int calculate_output_stream_length(const gr_vector_int &ninput_items); + + public: + ofdm_carrier_allocator_cvc_impl(int fft_len, const std::vector<std::vector<int> > &occupied_carriers, const std::vector<std::vector<int> > &pilot_carriers, const std::vector<std::vector<gr_complex> > &pilot_symbols, const std::string &len_tag_key); + ~ofdm_carrier_allocator_cvc_impl(); + + std::string len_tag_key() { return d_length_tag_key_str; }; + + const int fft_len() { return d_fft_len; }; + std::vector<std::vector<int> > occupied_carriers() { return d_occupied_carriers; }; + + int work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } // namespace digital +} // namespace gr + +#endif /* INCLUDED_DIGITAL_OFDM_CARRIER_ALLOCATOR_CVC_IMPL_H */ + diff --git a/gr-digital/lib/ofdm_chanest_vcvc_impl.cc b/gr-digital/lib/ofdm_chanest_vcvc_impl.cc new file mode 100644 index 0000000000..d0d8faba59 --- /dev/null +++ b/gr-digital/lib/ofdm_chanest_vcvc_impl.cc @@ -0,0 +1,273 @@ +/* -*- c++ -*- */ +/* + * Copyright 2013 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_io_signature.h> +#include "ofdm_chanest_vcvc_impl.h" + +namespace gr { + namespace digital { + + ofdm_chanest_vcvc::sptr + ofdm_chanest_vcvc::make(const std::vector<gr_complex> &sync_symbol1, const std::vector<gr_complex> &sync_symbol2, int n_data_symbols, int eq_noise_red_len, int max_carr_offset, bool force_one_sync_symbol) + { + return gnuradio::get_initial_sptr ( + new ofdm_chanest_vcvc_impl( + sync_symbol1, + sync_symbol2, + n_data_symbols, + eq_noise_red_len, + max_carr_offset, + force_one_sync_symbol + ) + ); + } + + ofdm_chanest_vcvc_impl::ofdm_chanest_vcvc_impl(const std::vector<gr_complex> &sync_symbol1, const std::vector<gr_complex> &sync_symbol2, int n_data_symbols, int eq_noise_red_len, int max_carr_offset, bool force_one_sync_symbol) + : gr_block("ofdm_chanest_vcvc", + gr_make_io_signature(1, 1, sizeof (gr_complex) * sync_symbol1.size()), + gr_make_io_signature(1, 1, sizeof (gr_complex) * sync_symbol1.size())), + d_fft_len(sync_symbol1.size()), + d_n_data_syms(n_data_symbols), + d_n_sync_syms(1), + d_eq_noise_red_len(eq_noise_red_len), + d_ref_sym((sync_symbol2.size() && !force_one_sync_symbol) ? sync_symbol2 : sync_symbol1), + d_corr_v(sync_symbol2), + d_known_symbol_diffs(0, 0), + d_new_symbol_diffs(0, 0), + d_interpolate(false) + { + // Set index of first and last active carrier + for (int i = 0; i < d_fft_len; i++) { + if (d_ref_sym[i] != gr_complex(0, 0)) { + d_first_active_carrier = i; + break; + } + } + for (int i = d_fft_len-1; i >= 0; i--) { + if (d_ref_sym[i] != gr_complex(0, 0)) { + d_last_active_carrier = i; + break; + } + } + + // Sanity checks + if (sync_symbol2.size()) { + if (sync_symbol1.size() != sync_symbol2.size()) { + throw std::invalid_argument("sync symbols must have equal length."); + } + if (!force_one_sync_symbol) { + d_n_sync_syms = 2; + } + } else { + if (sync_symbol1[d_first_active_carrier+1] == gr_complex(0, 0)) { + d_last_active_carrier++; + d_interpolate = true; + } + } + + // Set up coarse freq estimation info + // Allow all possible values: + d_max_neg_carr_offset = -d_first_active_carrier; + d_max_pos_carr_offset = d_fft_len - d_last_active_carrier - 1; + if (max_carr_offset != -1) { + d_max_neg_carr_offset = std::max(-max_carr_offset, d_max_neg_carr_offset); + d_max_pos_carr_offset = std::min(max_carr_offset, d_max_pos_carr_offset); + } + // Carrier offsets must be even + if (d_max_neg_carr_offset % 2) + d_max_neg_carr_offset++; + if (d_max_pos_carr_offset % 2) + d_max_pos_carr_offset--; + + if (d_n_sync_syms == 2) { + for (int i = 0; i < d_fft_len; i++) { + if (sync_symbol1[i] == gr_complex(0, 0)) { + d_corr_v[i] = gr_complex(0, 0); + } else { + d_corr_v[i] /= sync_symbol1[i]; + } + } + } else { + d_corr_v.resize(0, 0); + d_known_symbol_diffs.resize(d_fft_len, 0); + d_new_symbol_diffs.resize(d_fft_len, 0); + for (int i = d_first_active_carrier; i < d_last_active_carrier-2 && i < d_fft_len-2; i += 2) { + d_known_symbol_diffs[i] = std::norm(sync_symbol1[i] - sync_symbol1[i+2]); + } + } + + set_relative_rate((double) n_data_symbols / (n_data_symbols + d_n_sync_syms)); + set_tag_propagation_policy(TPP_DONT); + } + + ofdm_chanest_vcvc_impl::~ofdm_chanest_vcvc_impl() + { + } + + void + ofdm_chanest_vcvc_impl::forecast (int noutput_items, gr_vector_int &ninput_items_required) + { + ninput_items_required[0] = (noutput_items/d_n_data_syms) * (d_n_data_syms + d_n_sync_syms); + } + + int + ofdm_chanest_vcvc_impl::get_carr_offset(const gr_complex *sync_sym1, const gr_complex *sync_sym2) + { + int carr_offset = 0; + if (d_corr_v.size()) { + // Use Schmidl & Cox method + float Bg_max = 0; + // g here is 2g in the paper + for (int g = d_max_neg_carr_offset; g <= d_max_pos_carr_offset; g += 2) { + gr_complex tmp = gr_complex(0, 0); + for (int k = 0; k < d_fft_len; k++) { + if (d_corr_v[k] != gr_complex(0, 0)) { + tmp += std::conj(sync_sym1[k+g]) * std::conj(d_corr_v[k]) * sync_sym2[k+g]; + } + } + if (std::abs(tmp) > Bg_max) { + Bg_max = std::abs(tmp); + carr_offset = g; + } + } + } else { + // Correlate + std::fill(d_new_symbol_diffs.begin(), d_new_symbol_diffs.end(), 0); + for(int i = 0; i < d_fft_len-2; i++) { + d_new_symbol_diffs[i] = std::norm(sync_sym1[i] - sync_sym1[i+2]); + } + + float sum; + float max = 0; + for (int g = d_max_neg_carr_offset; g <= d_max_pos_carr_offset; g += 2) { + sum = 0; + for (int j = 0; j < d_fft_len; j++) { + if (d_known_symbol_diffs[j]) { + sum += (d_known_symbol_diffs[j] * d_new_symbol_diffs[j + g]); + } + if(sum > max) { + max = sum; + carr_offset = g; + } + } + } + } + return carr_offset; + } + + + void + ofdm_chanest_vcvc_impl::get_chan_taps( + const gr_complex *sync_sym1, + const gr_complex *sync_sym2, + int carr_offset, + std::vector<gr_complex> &taps) + { + const gr_complex *sym = ((d_n_sync_syms == 2) ? sync_sym2 : sync_sym1); + std::fill(taps.begin(), taps.end(), gr_complex(0, 0)); + int loop_start = 0; + int loop_end = d_fft_len; + if (carr_offset > 0) { + loop_start = carr_offset; + } else if (carr_offset < 0) { + loop_end = d_fft_len + carr_offset; + } + for (int i = loop_start; i < loop_end; i++) { + if ((d_ref_sym[i-carr_offset] != gr_complex(0, 0))) { + taps[i] = sym[i] / d_ref_sym[i-carr_offset]; + } + } + + if (d_interpolate) { + for (int i = d_first_active_carrier + 1; i < d_last_active_carrier; i += 2) { + taps[i] = (taps[i-1] + taps[i+1]) / gr_complex(2.0, 0); + } + taps[d_last_active_carrier] = taps[d_last_active_carrier-1]; + } + + if (d_eq_noise_red_len) { + // TODO + // 1) IFFT + // 2) Set all elements > d_eq_noise_red_len to zero + // 3) FFT + } + } + + + int + ofdm_chanest_vcvc_impl::general_work (int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + const gr_complex *in = (const gr_complex *) input_items[0]; + gr_complex *out = (gr_complex *) output_items[0]; + int n_frames = noutput_items/d_n_data_syms; + const int framesize = d_n_sync_syms + d_n_data_syms; + + for (int i = 0; i < n_frames; i++) { + int carr_offset = 0; + if (d_max_neg_carr_offset || d_max_pos_carr_offset) + carr_offset = get_carr_offset(in, in+d_fft_len); + std::vector<gr_complex> chan_taps(d_fft_len, 0); + get_chan_taps(in, in+d_fft_len, carr_offset, chan_taps); + + memcpy((void *) out, + (void *) &in[d_n_sync_syms * d_fft_len], + sizeof(gr_complex) * d_fft_len * d_n_data_syms); + in += framesize * d_fft_len; + out += d_n_data_syms * d_fft_len; + + std::vector<gr_tag_t> tags; + this->get_tags_in_range(tags, 0, + this->nitems_read(0)+i*framesize, + this->nitems_read(0)+(i+1)*framesize); + for (unsigned t = 0; t < tags.size(); t++) { + int offset = tags[t].offset - (this->nitems_read(0) + i*framesize); + if (offset < d_n_sync_syms) { + offset = 0; + } else { + offset -= d_n_sync_syms; + } + tags[t].offset = offset + this->nitems_written(0) + i*d_n_data_syms; + this->add_item_tag(0, tags[t]); + } + + this->add_item_tag(0, this->nitems_written(0) + i*d_n_data_syms, + pmt::string_to_symbol("ofdm_sync_carr_offset"), + pmt::from_long(carr_offset)); + this->add_item_tag(0, this->nitems_written(0) + i*d_n_data_syms, + pmt::string_to_symbol("ofdm_sync_chan_taps"), + pmt::init_c32vector(d_fft_len, chan_taps)); + } + + consume_each(n_frames * framesize); + return n_frames * d_n_data_syms; + } + + } /* namespace digital */ +} /* namespace gr */ + diff --git a/gr-digital/lib/ofdm_chanest_vcvc_impl.h b/gr-digital/lib/ofdm_chanest_vcvc_impl.h new file mode 100644 index 0000000000..def8734e64 --- /dev/null +++ b/gr-digital/lib/ofdm_chanest_vcvc_impl.h @@ -0,0 +1,78 @@ +/* -*- c++ -*- */ +/* + * Copyright 2013 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_DIGITAL_OFDM_CHANEST_VCVC_IMPL_H +#define INCLUDED_DIGITAL_OFDM_CHANEST_VCVC_IMPL_H + +#include <digital/ofdm_chanest_vcvc.h> + +namespace gr { + namespace digital { + + class ofdm_chanest_vcvc_impl : public ofdm_chanest_vcvc + { + private: + int d_fft_len; //! FFT length + int d_n_data_syms; //! Number of data symbols following the sync symbol(s) + int d_n_sync_syms; //! Number of sync symbols (1 or 2) + //! 0 if no noise reduction is done for the initial channel state estimation. Otherwise, the maximum length of the channel delay in samples. + int d_eq_noise_red_len; + //! Is sync_symbol1 if d_n_sync_syms == 1, otherwise sync_symbol2. Used as a reference symbol to estimate the channel. + std::vector<gr_complex> d_ref_sym; + //! If d_n_sync_syms == 2 this is used as a differential correlation vector (called 'v' in [1]). + std::vector<gr_complex> d_corr_v; + //! If d_n_sync_syms == 1 we use this instead of d_corr_v to estimate the coarse freq. offset + std::vector<float> d_known_symbol_diffs; + //! If d_n_sync_syms == 1 we use this instead of d_corr_v to estimate the coarse freq. offset (temp. variable) + std::vector<float> d_new_symbol_diffs; + //! The index of the first carrier with data (index 0 is not DC here, but the lowest frequency) + int d_first_active_carrier; + //! The index of the last carrier with data + int d_last_active_carrier; + //! If true, the channel estimation must be interpolated + bool d_interpolate; + //! Maximum carrier offset (negative value!) + int d_max_neg_carr_offset; + //! Maximum carrier offset (positive value!) + int d_max_pos_carr_offset; + + //! Calculate the coarse frequency offset in number of carriers + int get_carr_offset(const gr_complex *sync_sym1, const gr_complex *sync_sym2); + //! Estimate the channel (phase and amplitude offset per carrier) + void get_chan_taps(const gr_complex *sync_sym1, const gr_complex *sync_sym2, int carr_offset, std::vector<gr_complex> &taps); + + public: + ofdm_chanest_vcvc_impl(const std::vector<gr_complex> &sync_symbol1, const std::vector<gr_complex> &sync_symbol2, int n_data_symbols, int eq_noise_red_len, int max_carr_offset, bool force_one_sync_symbol); + ~ofdm_chanest_vcvc_impl(); + + void forecast (int noutput_items, gr_vector_int &ninput_items_required); + int general_work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } // namespace digital +} // namespace gr + +#endif /* INCLUDED_DIGITAL_OFDM_CHANEST_VCVC_IMPL_H */ + diff --git a/gr-digital/lib/ofdm_cyclic_prefixer_impl.cc b/gr-digital/lib/ofdm_cyclic_prefixer_impl.cc index 67cfba615f..d48c5f7e45 100644 --- a/gr-digital/lib/ofdm_cyclic_prefixer_impl.cc +++ b/gr-digital/lib/ofdm_cyclic_prefixer_impl.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ -/* - * Copyright 2004,2006,2010-2012 Free Software Foundation, Inc. +/* + * Copyright 2013 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -24,56 +24,142 @@ #include "config.h" #endif -#include "ofdm_cyclic_prefixer_impl.h" #include <gr_io_signature.h> +#include "ofdm_cyclic_prefixer_impl.h" namespace gr { namespace digital { - + ofdm_cyclic_prefixer::sptr - ofdm_cyclic_prefixer::make(size_t input_size, size_t output_size) + ofdm_cyclic_prefixer::make(size_t input_size, size_t output_size, int rolloff_len, const std::string &len_tag_key) { - return gnuradio::get_initial_sptr - (new ofdm_cyclic_prefixer_impl(input_size, output_size)); + return gnuradio::get_initial_sptr (new ofdm_cyclic_prefixer_impl(input_size, output_size, rolloff_len, len_tag_key)); } - ofdm_cyclic_prefixer_impl::ofdm_cyclic_prefixer_impl(size_t input_size, - size_t output_size) - : gr_sync_interpolator("ofdm_cyclic_prefixer", - gr_make_io_signature(1, 1, input_size*sizeof(gr_complex)), - gr_make_io_signature(1, 1, sizeof(gr_complex)), - output_size), - d_input_size(input_size), - d_output_size(output_size) + + ofdm_cyclic_prefixer_impl::ofdm_cyclic_prefixer_impl(size_t input_size, size_t output_size, int rolloff_len, const std::string &len_tag_key) + : gr_tagged_stream_block ("ofdm_cyclic_prefixer", + gr_make_io_signature (1, 1, input_size*sizeof(gr_complex)), + gr_make_io_signature (1, 1, sizeof(gr_complex)), + len_tag_key), + d_fft_len(input_size), + d_output_size(output_size), + d_cp_size(output_size - input_size), + d_rolloff_len(rolloff_len), + d_up_flank((rolloff_len ? rolloff_len-1 : 0), 0), + d_down_flank((rolloff_len ? rolloff_len-1 : 0), 0), + d_delay_line(0, 0) { + set_relative_rate(d_output_size); + + // Flank of length 1 would just be rectangular + if (d_rolloff_len == 1) { + d_rolloff_len = 0; + } + if (d_rolloff_len) { + d_delay_line.resize(d_rolloff_len-1, 0); + if (rolloff_len > d_cp_size) { + throw std::invalid_argument("cyclic prefixer: rolloff len must smaller than the cyclic prefix."); + } + // The actual flanks are one sample shorter than d_rolloff_len, because the + // first sample of the up- and down flank is always zero and one, respectively + for (int i = 1; i < d_rolloff_len; i++) { + d_up_flank[i-1] = 0.5 * (1 + cos(M_PI * i/rolloff_len - M_PI)); + d_down_flank[i-1] = 0.5 * (1 + cos(M_PI * (rolloff_len-i)/rolloff_len - M_PI)); + } + } + + if (len_tag_key.empty()) { + set_output_multiple(d_output_size); + } else { + set_tag_propagation_policy(TPP_DONT); + } } ofdm_cyclic_prefixer_impl::~ofdm_cyclic_prefixer_impl() { } + int - ofdm_cyclic_prefixer_impl::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) + ofdm_cyclic_prefixer_impl::calculate_output_stream_length(const gr_vector_int &ninput_items) { - gr_complex *in = (gr_complex*)input_items[0]; - gr_complex *out = (gr_complex*)output_items[0]; - size_t cp_size = d_output_size - d_input_size; - unsigned int i=0, j=0; - - j = cp_size; - for(i=0; i < d_input_size; i++,j++) { - out[j] = in[i]; + int nout = ninput_items[0] * d_output_size + d_delay_line.size(); + return nout; + } + + + // Operates in two ways: + // - When there's a length tag name specified, operates in packet mode. + // Here, an entire OFDM frame is processed at once. The final OFDM symbol + // is postfixed with the delay line of the pulse shape. + // We manually propagate tags. + // - Otherwise, we're in freewheeling mode. Process as many OFDM symbols as + // are space for in the output buffer. The delay line is never flushed. + // Tags are propagated by the scheduler. + int + ofdm_cyclic_prefixer_impl::work (int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + gr_complex *in = (gr_complex *) input_items[0]; + gr_complex *out = (gr_complex *) output_items[0]; + int symbols_to_read = 0; + + // 1) Figure out if we're in freewheeling or packet mode + if (!d_length_tag_key_str.empty()) { + symbols_to_read = ninput_items[0]; + noutput_items = symbols_to_read * d_output_size + d_delay_line.size(); + } else { + symbols_to_read = std::min(noutput_items / (int) d_output_size, ninput_items[0]); + noutput_items = symbols_to_read * d_output_size; + } + + // 2) Do the cyclic prefixing and, optionally, the pulse shaping + for (int sym_idx = 0; sym_idx < symbols_to_read; sym_idx++) { + memcpy((void *)(out + d_cp_size), (void *) in, d_fft_len * sizeof(gr_complex)); + memcpy((void *) out, (void *) (in + d_fft_len - d_cp_size), d_cp_size * sizeof(gr_complex)); + if (d_rolloff_len) { + for (int i = 0; i < d_rolloff_len-1; i++) { + out[i] = out[i] * d_up_flank[i] + d_delay_line[i]; + d_delay_line[i] = in[i] * d_down_flank[i]; + } + } + in += d_fft_len; + out += d_output_size; } - j = d_input_size - cp_size; - for(i=0; i < cp_size; i++, j++) { - out[i] = in[j]; + // 3) If we're in packet mode: + // - flush the delay line, if applicable + // - Propagate tags + if (!d_length_tag_key_str.empty()) { + if (d_rolloff_len) { + for (unsigned i = 0; i < d_delay_line.size(); i++) { + *out++ = d_delay_line[i]; + } + d_delay_line.assign(d_delay_line.size(), 0); + } + std::vector<gr_tag_t> tags; + get_tags_in_range( + tags, 0, + nitems_read(0), nitems_read(0)+symbols_to_read + ); + for (unsigned i = 0; i < tags.size(); i++) { + tags[i].offset = ((tags[i].offset - nitems_read(0)) * d_output_size) + nitems_written(0); + add_item_tag(0, + tags[i].offset, + tags[i].key, + tags[i].value + ); + } + } else { + consume_each(symbols_to_read); } - return d_output_size; + return noutput_items; } } /* namespace digital */ } /* namespace gr */ + diff --git a/gr-digital/lib/ofdm_cyclic_prefixer_impl.h b/gr-digital/lib/ofdm_cyclic_prefixer_impl.h index 20f0489d7c..5a5766f131 100644 --- a/gr-digital/lib/ofdm_cyclic_prefixer_impl.h +++ b/gr-digital/lib/ofdm_cyclic_prefixer_impl.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ -/* - * Copyright 2004-2006,2011,2012 Free Software Foundation, Inc. +/* + * Copyright 2013 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -27,23 +27,38 @@ namespace gr { namespace digital { - + class ofdm_cyclic_prefixer_impl : public ofdm_cyclic_prefixer { - private: - size_t d_input_size; + private: + size_t d_fft_len; + //! FFT length + CP length in samples size_t d_output_size; + //! Length of the cyclic prefix in samples + int d_cp_size; + //! Length of pulse rolloff in samples + int d_rolloff_len; + //! Buffers the up-flank (at the beginning of the cyclic prefix) + std::vector<float> d_up_flank; + //! Buffers the down-flank (which trails the symbol) + std::vector<float> d_down_flank; + std::vector<gr_complex> d_delay_line; // We do this explicitly to avoid outputting zeroes (i.e. no history!) + + protected: + int calculate_output_stream_length(const gr_vector_int &ninput_items); - public: - ofdm_cyclic_prefixer_impl(size_t input_size, size_t output_size); + public: + ofdm_cyclic_prefixer_impl(size_t input_size, size_t output_size, int rolloff_len, const std::string &len_tag_key); ~ofdm_cyclic_prefixer_impl(); int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); }; - } /* namespace digital */ -} /* namespace gr */ + } // namespace digital +} // namespace gr #endif /* INCLUDED_DIGITAL_OFDM_CYCLIC_PREFIXER_IMPL_H */ + diff --git a/gr-digital/lib/ofdm_equalizer_base.cc b/gr-digital/lib/ofdm_equalizer_base.cc new file mode 100644 index 0000000000..5209b09c29 --- /dev/null +++ b/gr-digital/lib/ofdm_equalizer_base.cc @@ -0,0 +1,121 @@ +/* -*- c++ -*- */ +/* Copyright 2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <digital/ofdm_equalizer_base.h> + +namespace gr { + namespace digital { + + // *** Base class **************************************************** + ofdm_equalizer_base::ofdm_equalizer_base(int fft_len) : + d_fft_len(fft_len), + d_carr_offset(0) + { + } + + + ofdm_equalizer_base::~ofdm_equalizer_base() + { + } + + + // *** Sub-Base class for 1D equalizers using pilot tones ************* + ofdm_equalizer_1d_pilots::ofdm_equalizer_1d_pilots( + int fft_len, + const std::vector<std::vector<int> > &occupied_carriers, + const std::vector<std::vector<int> > &pilot_carriers, + const std::vector<std::vector<gr_complex> > &pilot_symbols, + int symbols_skipped, + bool input_is_shifted) + : ofdm_equalizer_base(fft_len), + d_occupied_carriers(fft_len, false), + d_pilot_carriers(pilot_carriers.size(), std::vector<bool>(fft_len, false)), + d_pilot_symbols(pilot_symbols.size(), std::vector<gr_complex>(fft_len, gr_complex(0, 0))), + d_symbols_skipped(symbols_skipped), + d_pilot_carr_set(symbols_skipped), + d_channel_state(fft_len, gr_complex(1, 0)) + { + int fft_shift_width = 0; + if (input_is_shifted) { + fft_shift_width = fft_len/2; + } + if (!occupied_carriers.size()) { + std::fill(d_occupied_carriers.begin(), d_occupied_carriers.end(), true); + } else { + for (unsigned i = 0; i < occupied_carriers.size(); i++) { + for (unsigned k = 0; k < occupied_carriers[i].size(); k++) { + int carr_index = occupied_carriers[i][k]; + if (occupied_carriers[i][k] < 0) { + carr_index += fft_len; + } + if (carr_index >= fft_len || carr_index < 0) { + throw std::invalid_argument("data carrier index out of bounds."); + } + d_occupied_carriers[(carr_index + fft_shift_width) % fft_len] = true; + } + } + } + if (pilot_carriers.size()) { + for (unsigned i = 0; i < pilot_carriers.size(); i++) { + if (pilot_carriers[i].size() != pilot_symbols[i].size()) { + throw std::invalid_argument("pilot carriers and -symbols do not match."); + } + for (unsigned k = 0; k < pilot_carriers[i].size(); k++) { + int carr_index = pilot_carriers[i][k]; + if (pilot_carriers[i][k] < 0) { + carr_index += fft_len; + } + if (carr_index >= fft_len || carr_index < 0) { + throw std::invalid_argument("pilot carrier index out of bounds."); + } + d_pilot_carriers[i][(carr_index + fft_shift_width) % fft_len] = true; + d_pilot_symbols[i][(carr_index + fft_shift_width) % fft_len] = pilot_symbols[i][k]; + } + } + } + } + + + ofdm_equalizer_1d_pilots::~ofdm_equalizer_1d_pilots() + { + } + + + void + ofdm_equalizer_1d_pilots::reset() + { + std::fill(d_channel_state.begin(), d_channel_state.end(), gr_complex(1, 0)); + d_pilot_carr_set = d_symbols_skipped; + } + + + void ofdm_equalizer_1d_pilots::get_channel_state(std::vector<gr_complex> &taps) + { + taps = d_channel_state; + } + + } /* namespace digital */ +} /* namespace gr */ + diff --git a/gr-digital/lib/ofdm_equalizer_simpledfe.cc b/gr-digital/lib/ofdm_equalizer_simpledfe.cc new file mode 100644 index 0000000000..fcb0e18cbf --- /dev/null +++ b/gr-digital/lib/ofdm_equalizer_simpledfe.cc @@ -0,0 +1,110 @@ +/* -*- c++ -*- */ +/* Copyright 2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <digital/ofdm_equalizer_simpledfe.h> + +namespace gr { + namespace digital { + + ofdm_equalizer_simpledfe::sptr + ofdm_equalizer_simpledfe::make( + int fft_len, + const gr::digital::constellation_sptr &constellation, + const std::vector<std::vector<int> > &occupied_carriers, + const std::vector<std::vector<int> > &pilot_carriers, + const std::vector<std::vector<gr_complex> > &pilot_symbols, + int symbols_skipped, + float alpha, + bool input_is_shifted) + { + return ofdm_equalizer_simpledfe::sptr( + new ofdm_equalizer_simpledfe( + fft_len, + constellation, + occupied_carriers, + pilot_carriers, + pilot_symbols, + symbols_skipped, + alpha, + input_is_shifted + ) + ); + } + + ofdm_equalizer_simpledfe::ofdm_equalizer_simpledfe( + int fft_len, + const gr::digital::constellation_sptr &constellation, + const std::vector<std::vector<int> > &occupied_carriers, + const std::vector<std::vector<int> > &pilot_carriers, + const std::vector<std::vector<gr_complex> > &pilot_symbols, + int symbols_skipped, + float alpha, + bool input_is_shifted) + : ofdm_equalizer_1d_pilots(fft_len, occupied_carriers, pilot_carriers, pilot_symbols, symbols_skipped, input_is_shifted), + d_constellation(constellation), + d_alpha(alpha) + { + } + + + ofdm_equalizer_simpledfe::~ofdm_equalizer_simpledfe() + { + } + + + void + ofdm_equalizer_simpledfe::equalize(gr_complex *frame, + int n_sym, + const std::vector<gr_complex> &initial_taps, + const std::vector<gr_tag_t> &tags) + { + if (!initial_taps.empty()) { + d_channel_state = initial_taps; + } + gr_complex sym_eq, sym_est; + + for (int i = 0; i < n_sym; i++) { + for (int k = 0; k < d_fft_len; k++) { + if (!d_occupied_carriers[k]) { + continue; + } + if (d_pilot_carriers.size() && d_pilot_carriers[d_pilot_carr_set][k-d_carr_offset]) { + d_channel_state[k] = d_alpha * d_channel_state[k] + + (1-d_alpha) * frame[i*d_fft_len + k] / d_pilot_symbols[d_pilot_carr_set][k-d_carr_offset]; + frame[i*d_fft_len+k] = d_pilot_symbols[d_pilot_carr_set][k-d_carr_offset]; + } else { + sym_eq = frame[i*d_fft_len+k] / d_channel_state[k]; + d_constellation->map_to_points(d_constellation->decision_maker(&sym_eq), &sym_est); + d_channel_state[k] = d_alpha * d_channel_state[k] + frame[i*d_fft_len+k] / sym_est; + frame[i*d_fft_len+k] = sym_est; + } + } + d_pilot_carr_set = (d_pilot_carr_set + 1) % d_pilot_carriers.size(); + } + } + + } /* namespace digital */ +} /* namespace gr */ + diff --git a/gr-digital/lib/ofdm_equalizer_static.cc b/gr-digital/lib/ofdm_equalizer_static.cc new file mode 100644 index 0000000000..8601eff430 --- /dev/null +++ b/gr-digital/lib/ofdm_equalizer_static.cc @@ -0,0 +1,97 @@ +/* -*- c++ -*- */ +/* Copyright 2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <digital/ofdm_equalizer_static.h> + +namespace gr { + namespace digital { + + ofdm_equalizer_static::sptr + ofdm_equalizer_static::make( + int fft_len, + const std::vector<std::vector<int> > &occupied_carriers, + const std::vector<std::vector<int> > &pilot_carriers, + const std::vector<std::vector<gr_complex> > &pilot_symbols, + int symbols_skipped, + bool input_is_shifted) + { + return ofdm_equalizer_static::sptr( + new ofdm_equalizer_static( + fft_len, + occupied_carriers, + pilot_carriers, + pilot_symbols, + symbols_skipped, + input_is_shifted + ) + ); + } + + ofdm_equalizer_static::ofdm_equalizer_static( + int fft_len, + const std::vector<std::vector<int> > &occupied_carriers, + const std::vector<std::vector<int> > &pilot_carriers, + const std::vector<std::vector<gr_complex> > &pilot_symbols, + int symbols_skipped, + bool input_is_shifted) + : ofdm_equalizer_1d_pilots(fft_len, occupied_carriers, pilot_carriers, pilot_symbols, symbols_skipped, input_is_shifted) + { + } + + + ofdm_equalizer_static::~ofdm_equalizer_static() + { + } + + + void + ofdm_equalizer_static::equalize(gr_complex *frame, + int n_sym, + const std::vector<gr_complex> &initial_taps, + const std::vector<gr_tag_t> &tags) + { + d_channel_state = initial_taps; + + for (int i = 0; i < n_sym; i++) { + for (int k = 0; k < d_fft_len; k++) { + if (!d_occupied_carriers[k]) { + continue; + } + if (d_pilot_carriers.size() && d_pilot_carriers[d_pilot_carr_set][k-d_carr_offset]) { + d_channel_state[k] = frame[i*d_fft_len + k] / d_pilot_symbols[d_pilot_carr_set][k-d_carr_offset]; + frame[i*d_fft_len+k] = d_pilot_symbols[d_pilot_carr_set][k-d_carr_offset]; + } else { + frame[i*d_fft_len+k] /= d_channel_state[k]; + } + } + if (!d_pilot_carriers.empty()) { + d_pilot_carr_set = (d_pilot_carr_set + 1) % d_pilot_carriers.size(); + } + } + } + + } /* namespace digital */ +} /* namespace gr */ + diff --git a/gr-digital/lib/ofdm_frame_equalizer_vcvc_impl.cc b/gr-digital/lib/ofdm_frame_equalizer_vcvc_impl.cc index 49235db5bb..594b2df838 100644 --- a/gr-digital/lib/ofdm_frame_equalizer_vcvc_impl.cc +++ b/gr-digital/lib/ofdm_frame_equalizer_vcvc_impl.cc @@ -30,12 +30,16 @@ namespace gr { namespace digital { ofdm_frame_equalizer_vcvc::sptr - ofdm_frame_equalizer_vcvc::make(digital_ofdm_equalizer_base_sptr equalizer, const std::string &len_tag_key, bool propagate_channel_state) + ofdm_frame_equalizer_vcvc::make(ofdm_equalizer_base::sptr equalizer, const std::string &len_tag_key, bool propagate_channel_state) { - return gnuradio::get_initial_sptr (new ofdm_frame_equalizer_vcvc_impl(equalizer, len_tag_key, propagate_channel_state)); + return gnuradio::get_initial_sptr ( + new ofdm_frame_equalizer_vcvc_impl( + equalizer, len_tag_key, propagate_channel_state + ) + ); } - ofdm_frame_equalizer_vcvc_impl::ofdm_frame_equalizer_vcvc_impl(digital_ofdm_equalizer_base_sptr equalizer, const std::string &len_tag_key, bool propagate_channel_state) + ofdm_frame_equalizer_vcvc_impl::ofdm_frame_equalizer_vcvc_impl(ofdm_equalizer_base::sptr equalizer, const std::string &len_tag_key, bool propagate_channel_state) : gr_tagged_stream_block("ofdm_frame_equalizer_vcvc", gr_make_io_signature(1, 1, sizeof (gr_complex) * equalizer->fft_len()), gr_make_io_signature(1, 1, sizeof (gr_complex) * equalizer->fft_len()), diff --git a/gr-digital/lib/ofdm_frame_equalizer_vcvc_impl.h b/gr-digital/lib/ofdm_frame_equalizer_vcvc_impl.h index cba2d513ea..803874713f 100644 --- a/gr-digital/lib/ofdm_frame_equalizer_vcvc_impl.h +++ b/gr-digital/lib/ofdm_frame_equalizer_vcvc_impl.h @@ -31,7 +31,7 @@ namespace gr { { private: const int d_fft_len; - digital_ofdm_equalizer_base_sptr d_eq; + ofdm_equalizer_base::sptr d_eq; bool d_propagate_channel_state; std::vector<gr_complex> d_channel_state; @@ -41,7 +41,7 @@ namespace gr { void update_length_tags(int n_produced, int n_ports) {}; public: - ofdm_frame_equalizer_vcvc_impl(digital_ofdm_equalizer_base_sptr equalizer, const std::string &len_tag_key, bool propagate_channel_state); + ofdm_frame_equalizer_vcvc_impl(ofdm_equalizer_base::sptr equalizer, const std::string &len_tag_key, bool propagate_channel_state); ~ofdm_frame_equalizer_vcvc_impl(); int work(int noutput_items, diff --git a/gr-digital/lib/ofdm_serializer_vcc_impl.cc b/gr-digital/lib/ofdm_serializer_vcc_impl.cc index 9c41daae77..09c0039a1c 100644 --- a/gr-digital/lib/ofdm_serializer_vcc_impl.cc +++ b/gr-digital/lib/ofdm_serializer_vcc_impl.cc @@ -50,7 +50,7 @@ namespace gr { ofdm_serializer_vcc::sptr ofdm_serializer_vcc::make( - const digital_ofdm_carrier_allocator_cvc_sptr &allocator, + const gr::digital::ofdm_carrier_allocator_cvc::sptr &allocator, const std::string &packet_len_tag_key, int symbols_skipped, bool input_is_shifted diff --git a/gr-digital/lib/ofdm_sync_sc_cfb_impl.cc b/gr-digital/lib/ofdm_sync_sc_cfb_impl.cc new file mode 100644 index 0000000000..26e791210f --- /dev/null +++ b/gr-digital/lib/ofdm_sync_sc_cfb_impl.cc @@ -0,0 +1,111 @@ +/* -*- c++ -*- */ +/* + * Copyright 2013 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_io_signature.h> +#include "ofdm_sync_sc_cfb_impl.h" + +#include <analog/plateau_detector_fb.h> +#include <blocks/complex_to_arg.h> +#include <blocks/complex_to_mag_squared.h> +#include <blocks/conjugate_cc.h> +#include <blocks/delay.h> +#include <blocks/divide_ff.h> +#include <blocks/multiply_cc.h> +#include <blocks/multiply_ff.h> +#include <blocks/sample_and_hold_ff.h> +#include <filter/fir_filter_ccf.h> +#include <filter/fir_filter_fff.h> + +namespace gr { + namespace digital { + + ofdm_sync_sc_cfb::sptr + ofdm_sync_sc_cfb::make(int fft_len, int cp_len) + { + return gnuradio::get_initial_sptr (new ofdm_sync_sc_cfb_impl(fft_len, cp_len)); + } + + ofdm_sync_sc_cfb_impl::ofdm_sync_sc_cfb_impl(int fft_len, int cp_len) + : gr_hier_block2 ("ofdm_sync_sc_cfb", + gr_make_io_signature(1, 1, sizeof (gr_complex)), +#ifndef SYNC_ADD_DEBUG_OUTPUT + gr_make_io_signature2(2, 2, sizeof (float), sizeof (unsigned char))) +#else + gr_make_io_signature3(3, 3, sizeof (float), sizeof (unsigned char), sizeof (float))) +#endif + { + std::vector<float> ma_taps(fft_len/2, 1.0); + gr::blocks::delay::sptr delay(gr::blocks::delay::make(sizeof(gr_complex), fft_len/2)); + gr::blocks::conjugate_cc::sptr delay_conjugate(gr::blocks::conjugate_cc::make()); + gr::blocks::multiply_cc::sptr delay_corr(gr::blocks::multiply_cc::make()); + gr::filter::fir_filter_ccf::sptr delay_ma(gr::filter::fir_filter_ccf::make(1, std::vector<float>(fft_len/2, 1.0))); + gr::blocks::complex_to_mag_squared::sptr delay_magsquare(gr::blocks::complex_to_mag_squared::make()); + gr::blocks::divide_ff::sptr delay_normalize(gr::blocks::divide_ff::make()); + + gr::blocks::complex_to_mag_squared::sptr normalizer_magsquare(gr::blocks::complex_to_mag_squared::make()); + gr::filter::fir_filter_fff::sptr normalizer_ma(gr::filter::fir_filter_fff::make(1, std::vector<float>(fft_len, 0.5))); + gr::blocks::multiply_ff::sptr normalizer_square(gr::blocks::multiply_ff::make()); + + gr::blocks::complex_to_arg::sptr peak_to_angle(gr::blocks::complex_to_arg::make()); + gr::blocks::sample_and_hold_ff::sptr sample_and_hold(gr::blocks::sample_and_hold_ff::make()); + + gr::analog::plateau_detector_fb::sptr plateau_detector(gr::analog::plateau_detector_fb::make(cp_len)); + + // Delay Path + connect(self(), 0, delay, 0); + connect(delay, 0, delay_conjugate, 0); + connect(delay_conjugate, 0, delay_corr, 1); + connect(self(), 0, delay_corr, 0); + connect(delay_corr, 0, delay_ma, 0); + connect(delay_ma, 0, delay_magsquare, 0); + connect(delay_magsquare, 0, delay_normalize, 0); + // Energy Path + connect(self(), 0, normalizer_magsquare, 0); + connect(normalizer_magsquare, 0, normalizer_ma, 0); + connect(normalizer_ma, 0, normalizer_square, 0); + connect(normalizer_ma, 0, normalizer_square, 1); + connect(normalizer_square, 0, delay_normalize, 1); + // Fine frequency estimate (output 0) + connect(delay_ma, 0, peak_to_angle, 0); + connect(peak_to_angle, 0, sample_and_hold, 0); + connect(sample_and_hold, 0, self(), 0); + // Peak detect (output 1) + connect(delay_normalize, 0, plateau_detector, 0); + connect(plateau_detector, 0, sample_and_hold, 1); + connect(plateau_detector, 0, self(), 1); +#ifdef SYNC_ADD_DEBUG_OUTPUT + // Debugging: timing metric (output 2) + connect(delay_normalize, 0, self(), 2); +#endif + } + + ofdm_sync_sc_cfb_impl::~ofdm_sync_sc_cfb_impl() + { + } + + } /* namespace digital */ +} /* namespace gr */ + diff --git a/gnuradio-core/src/lib/filter/qa_rotator.h b/gr-digital/lib/ofdm_sync_sc_cfb_impl.h index a22e41ec26..207ea41ae1 100644 --- a/gnuradio-core/src/lib/filter/qa_rotator.h +++ b/gr-digital/lib/ofdm_sync_sc_cfb_impl.h @@ -1,45 +1,42 @@ /* -*- c++ -*- */ -/* - * Copyright 2008,2012 Free Software Foundation, Inc. - * +/* + * Copyright 2013 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 _QA_ANALOG_ROTATOR_H_ -#define _QA_ANALOG_ROTATOR_H_ +#ifndef INCLUDED_DIGITAL_OFDM_SYNC_SC_CFB_IMPL_H +#define INCLUDED_DIGITAL_OFDM_SYNC_SC_CFB_IMPL_H -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> +#include <digital/ofdm_sync_sc_cfb.h> namespace gr { - namespace analog { + namespace digital { - class qa_rotator : public CppUnit::TestCase + class ofdm_sync_sc_cfb_impl : public ofdm_sync_sc_cfb { - CPPUNIT_TEST_SUITE(qa_rotator); - CPPUNIT_TEST(t1); - CPPUNIT_TEST_SUITE_END(); - - private: - void t1(); + public: + ofdm_sync_sc_cfb_impl(int fft_len, int cp_len); + ~ofdm_sync_sc_cfb_impl(); }; - } /* namespace analog */ -} /* namespace gr */ + } // namespace digital +} // namespace gr + +#endif /* INCLUDED_DIGITAL_OFDM_SYNC_SC_CFB_IMPL_H */ -#endif /* _QA_ANALOG_ROTATOR_H_ */ diff --git a/gr-digital/python/digital_voice.py.real b/gr-digital/python/digital_voice.py.real index 4a2ef7721f..241a4a3dc2 100644 --- a/gr-digital/python/digital_voice.py.real +++ b/gr-digital/python/digital_voice.py.real @@ -23,8 +23,7 @@ """ Digital voice Tx and Rx using GSM 13kbit vocoder and GMSK. -Runs channel at 32kbit/sec. Currently uses fake channel coding, -but there's room for a rate 1/2 coder. +Runs channel at 32kbit/sec. """ from gnuradio import gr, gru @@ -66,7 +65,7 @@ class digital_voice_tx(gr.hier_block): f2s = blocks.float_to_short() voice_coder = gsm_full_rate.encode_sp() - channel_coder = gr.fake_channel_encoder_pp(GSM_FRAME_SIZE, AIR_FRAME_SIZE) + channel_coder = gr.multiply_const_b(1) p2s = gr.parallel_to_serial(gr.sizeof_char, AIR_FRAME_SIZE) mod = gmsk_mod(fg, sps=samples_per_symbol, @@ -93,7 +92,7 @@ class digital_voice_rx(gr.hier_block): p_size=AIR_FRAME_SIZE) s2p = gr.serial_to_parallel(gr.sizeof_char, AIR_FRAME_SIZE) - channel_decoder = gr.fake_channel_decoder_pp(AIR_FRAME_SIZE, GSM_FRAME_SIZE) + channel_decoder = gr.multiply_const_b(1) voice_decoder = gsm_full_rate.decode_ps() s2f = blocks.short_to_float () diff --git a/gr-digital/python/gfsk.py b/gr-digital/python/gfsk.py index 54c94b88fd..6ba007ca0f 100644 --- a/gr-digital/python/gfsk.py +++ b/gr-digital/python/gfsk.py @@ -116,7 +116,7 @@ class gfsk_mod(gr.hier_block2): self.gaussian_filter = filter.interp_fir_filter_fff(samples_per_symbol, self.taps) # FM modulation - self.fmmod = frequency.frequency_modulator_fc(sensitivity) + self.fmmod = analog.frequency_modulator_fc(sensitivity) # small amount of output attenuation to prevent clipping USRP sink self.amp = blocks.multiply_const_cc(0.999) diff --git a/gr-digital/python/ofdm.py b/gr-digital/python/ofdm.py index bf129675ab..fdb23703f9 100644 --- a/gr-digital/python/ofdm.py +++ b/gr-digital/python/ofdm.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2006,2007,2008 Free Software Foundation, Inc. +# Copyright 2006-2008,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -260,7 +260,7 @@ class ofdm_demod(gr.hier_block2): "ofdm_frame_sink_c.dat")) else: self.connect(self.ofdm_demod, - gr.null_sink(gr.sizeof_gr_complex*self._occupied_tones)) + blocks.null_sink(gr.sizeof_gr_complex*self._occupied_tones)) if options.verbose: self._print_verbage() diff --git a/gr-digital/python/ofdm_sync_fixed.py b/gr-digital/python/ofdm_sync_fixed.py index bd64964651..9cbd59b943 100644 --- a/gr-digital/python/ofdm_sync_fixed.py +++ b/gr-digital/python/ofdm_sync_fixed.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2007 Free Software Foundation, Inc. +# Copyright 2007,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -36,13 +36,13 @@ class ofdm_sync_fixed(gr.hier_block2): pkt_length = nsymbols*symbol_length data = (pkt_length)*[0,] data[(symbol_length)-1] = 1 - self.peak_trigger = gr.vector_source_b(data, True) + self.peak_trigger = blocks.vector_source_b(data, True) # Use a pre-defined frequency offset foffset = (pkt_length)*[math.pi*freq_offset,] - self.frequency_offset = gr.vector_source_f(foffset, True) + self.frequency_offset = blocks.vector_source_f(foffset, True) - self.connect(self, gr.null_sink(gr.sizeof_gr_complex)) + self.connect(self, blocks.null_sink(gr.sizeof_gr_complex)) self.connect(self.frequency_offset, (self,0)) self.connect(self.peak_trigger, (self,1)) diff --git a/gr-digital/python/ofdm_txrx.py b/gr-digital/python/ofdm_txrx.py index 2734e9cc1c..c403ef6cbf 100644 --- a/gr-digital/python/ofdm_txrx.py +++ b/gr-digital/python/ofdm_txrx.py @@ -1,5 +1,5 @@ # -# Copyright 2005,2006,2007 Free Software Foundation, Inc. +# Copyright 2005-2007,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -143,7 +143,7 @@ class ofdm_tx(gr.hier_block2): (header_payload_mux, 1) ) self.connect(payload_mod, gr.tag_debug(gr.sizeof_gr_complex, "pmod")) - sync_word_gen = gr.vector_source_c( + sync_word_gen = blocks.vector_source_c( total_sync_word, True, self.fft_len, tagged_streams.make_lengthtags((n_sync_words,), (0,), self.frame_length_tag_key) ) diff --git a/gr-digital/python/qa_binary_slicer_fb.py b/gr-digital/python/qa_binary_slicer_fb.py index 22f7da73ff..40213d7e33 100755 --- a/gr-digital/python/qa_binary_slicer_fb.py +++ b/gr-digital/python/qa_binary_slicer_fb.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2011,2012 Free Software Foundation, Inc. +# Copyright 2011-2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -22,6 +22,7 @@ from gnuradio import gr, gr_unittest import digital_swig as digital +import blocks_swig as blocks import math, random class test_binary_slicer_fb(gr_unittest.TestCase): @@ -36,9 +37,9 @@ class test_binary_slicer_fb(gr_unittest.TestCase): expected_result = ( 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1) src_data = (-1, 1, -1, -1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1) src_data = [s + (1 - random.random()) for s in src_data] # add some noise - src = gr.vector_source_f(src_data) + src = blocks.vector_source_f(src_data) op = digital.binary_slicer_fb() - dst = gr.vector_sink_b() + dst = blocks.vector_sink_b() self.tb.connect(src, op) self.tb.connect(op, dst) diff --git a/gr-digital/python/qa_chunks_to_symbols.py b/gr-digital/python/qa_chunks_to_symbols.py index 5ffe425132..cbc29b83a9 100755 --- a/gr-digital/python/qa_chunks_to_symbols.py +++ b/gr-digital/python/qa_chunks_to_symbols.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2012 Free Software Foundation, Inc. +# Copyright 2012,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -22,6 +22,7 @@ from gnuradio import gr, gr_unittest import digital_swig as digital +import blocks_swig as blocks class test_chunks_to_symbols(gr_unittest.TestCase): @@ -38,10 +39,10 @@ class test_chunks_to_symbols(gr_unittest.TestCase): expected_result = (1+0j, 0+1j, -1+0j, 0-1j, 0-1j, -1+0j, 0+1j, 1+0j) - src = gr.vector_source_b(src_data) + src = blocks.vector_source_b(src_data) op = digital.chunks_to_symbols_bc(const) - dst = gr.vector_sink_c() + dst = blocks.vector_sink_c() self.tb.connect(src, op) self.tb.connect(op, dst) self.tb.run() @@ -55,10 +56,10 @@ class test_chunks_to_symbols(gr_unittest.TestCase): expected_result = (-3, -1, 1, 3, 3, 1, -1, -3) - src = gr.vector_source_b(src_data) + src = blocks.vector_source_b(src_data) op = digital.chunks_to_symbols_bf(const) - dst = gr.vector_sink_f() + dst = blocks.vector_sink_f() self.tb.connect(src, op) self.tb.connect(op, dst) self.tb.run() @@ -73,10 +74,10 @@ class test_chunks_to_symbols(gr_unittest.TestCase): expected_result = (1+0j, 0+1j, -1+0j, 0-1j, 0-1j, -1+0j, 0+1j, 1+0j) - src = gr.vector_source_i(src_data) + src = blocks.vector_source_i(src_data) op = digital.chunks_to_symbols_ic(const) - dst = gr.vector_sink_c() + dst = blocks.vector_sink_c() self.tb.connect(src, op) self.tb.connect(op, dst) self.tb.run() @@ -90,10 +91,10 @@ class test_chunks_to_symbols(gr_unittest.TestCase): expected_result = (-3, -1, 1, 3, 3, 1, -1, -3) - src = gr.vector_source_i(src_data) + src = blocks.vector_source_i(src_data) op = digital.chunks_to_symbols_if(const) - dst = gr.vector_sink_f() + dst = blocks.vector_sink_f() self.tb.connect(src, op) self.tb.connect(op, dst) self.tb.run() @@ -108,10 +109,10 @@ class test_chunks_to_symbols(gr_unittest.TestCase): expected_result = (1+0j, 0+1j, -1+0j, 0-1j, 0-1j, -1+0j, 0+1j, 1+0j) - src = gr.vector_source_s(src_data) + src = blocks.vector_source_s(src_data) op = digital.chunks_to_symbols_sc(const) - dst = gr.vector_sink_c() + dst = blocks.vector_sink_c() self.tb.connect(src, op) self.tb.connect(op, dst) self.tb.run() @@ -125,10 +126,10 @@ class test_chunks_to_symbols(gr_unittest.TestCase): expected_result = (-3, -1, 1, 3, 3, 1, -1, -3) - src = gr.vector_source_s(src_data) + src = blocks.vector_source_s(src_data) op = digital.chunks_to_symbols_sf(const) - dst = gr.vector_sink_f() + dst = blocks.vector_sink_f() self.tb.connect(src, op) self.tb.connect(op, dst) self.tb.run() diff --git a/gr-digital/python/qa_clock_recovery_mm.py b/gr-digital/python/qa_clock_recovery_mm.py index e904cf4c21..f696c9f124 100755 --- a/gr-digital/python/qa_clock_recovery_mm.py +++ b/gr-digital/python/qa_clock_recovery_mm.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2011,2012 Free Software Foundation, Inc. +# Copyright 2011-2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -22,6 +22,7 @@ from gnuradio import gr, gr_unittest import digital_swig as digital +import blocks_swig as blocks import random, cmath class test_clock_recovery_mm(gr_unittest.TestCase): @@ -45,8 +46,8 @@ class test_clock_recovery_mm(gr_unittest.TestCase): omega_rel_lim) data = 100*[complex(1, 1),] - self.src = gr.vector_source_c(data, False) - self.snk = gr.vector_sink_c() + self.src = blocks.vector_source_c(data, False) + self.snk = blocks.vector_sink_c() self.tb.connect(self.src, self.test, self.snk) self.tb.run() @@ -80,8 +81,8 @@ class test_clock_recovery_mm(gr_unittest.TestCase): omega_rel_lim) data = 100*[1,] - self.src = gr.vector_source_f(data, False) - self.snk = gr.vector_sink_f() + self.src = blocks.vector_source_f(data, False) + self.snk = blocks.vector_sink_f() self.tb.connect(self.src, self.test, self.snk) self.tb.run() @@ -115,8 +116,8 @@ class test_clock_recovery_mm(gr_unittest.TestCase): omega_rel_lim) data = 1000*[complex(1, 1), complex(1, 1), complex(-1, -1), complex(-1, -1)] - self.src = gr.vector_source_c(data, False) - self.snk = gr.vector_sink_c() + self.src = blocks.vector_source_c(data, False) + self.snk = blocks.vector_sink_c() self.tb.connect(self.src, self.test, self.snk) self.tb.run() @@ -150,8 +151,8 @@ class test_clock_recovery_mm(gr_unittest.TestCase): omega_rel_lim) data = 1000*[1, 1, -1, -1] - self.src = gr.vector_source_f(data, False) - self.snk = gr.vector_sink_f() + self.src = blocks.vector_source_f(data, False) + self.snk = blocks.vector_sink_f() self.tb.connect(self.src, self.test, self.snk) self.tb.run() diff --git a/gr-digital/python/qa_cma_equalizer.py b/gr-digital/python/qa_cma_equalizer.py index f71e199189..183ba4f4e7 100755 --- a/gr-digital/python/qa_cma_equalizer.py +++ b/gr-digital/python/qa_cma_equalizer.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2006,2007,2010,2011 Free Software Foundation, Inc. +# Copyright 2006,2007,2010,2011,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -22,6 +22,7 @@ from gnuradio import gr, gr_unittest import digital_swig as digital +import blocks_swig as blocks class test_cma_equalizer_fir(gr_unittest.TestCase): @@ -32,9 +33,9 @@ class test_cma_equalizer_fir(gr_unittest.TestCase): self.tb = None def transform(self, src_data): - SRC = gr.vector_source_c(src_data, False) + SRC = blocks.vector_source_c(src_data, False) EQU = digital.cma_equalizer_cc(4, 1.0, .001, 1) - DST = gr.vector_sink_c() + DST = blocks.vector_sink_c() self.tb.connect(SRC, EQU, DST) self.tb.run() return DST.data() diff --git a/gr-digital/python/qa_constellation.py b/gr-digital/python/qa_constellation.py index a593c3ea3e..77fb88031c 100755 --- a/gr-digital/python/qa_constellation.py +++ b/gr-digital/python/qa_constellation.py @@ -180,9 +180,9 @@ class test_constellation(gr_unittest.TestCase): else: rotations = [None] for rotation in rotations: - src = gr.vector_source_b(self.src_data) + src = blocks.vector_source_b(self.src_data) content = mod_demod(constellation, differential, rotation) - dst = gr.vector_sink_b() + dst = blocks.vector_sink_b() self.tb = gr.top_block() self.tb.connect(src, content, dst) self.tb.run() diff --git a/gr-digital/python/qa_constellation_decoder_cb.py b/gr-digital/python/qa_constellation_decoder_cb.py index 6a93b6e743..12fef4345f 100755 --- a/gr-digital/python/qa_constellation_decoder_cb.py +++ b/gr-digital/python/qa_constellation_decoder_cb.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2004,2007,2010-2012 Free Software Foundation, Inc. +# Copyright 2004,2007,2010-2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -22,6 +22,7 @@ from gnuradio import gr, gr_unittest import digital_swig as digital +import blocks_swig as blocks import math class test_constellation_decoder(gr_unittest.TestCase): @@ -38,9 +39,9 @@ class test_constellation_decoder(gr_unittest.TestCase): 0.8 + 1.0j, -0.5 + 0.1j, 0.1 - 1.2j) expected_result = ( 1, 1, 0, 0, 1, 0, 1) - src = gr.vector_source_c(src_data) + src = blocks.vector_source_c(src_data) op = digital.constellation_decoder_cb(cnst.base()) - dst = gr.vector_sink_b() + dst = blocks.vector_sink_b() self.tb.connect(src, op) self.tb.connect(op, dst) @@ -57,9 +58,9 @@ class test_constellation_decoder(gr_unittest.TestCase): 0.8 + 1.0j, -0.5 + 0.1j, 0.1 - 1.2j) expected_result = ( 3, 1, 0, 2, 3, 2, 1) - src = gr.vector_source_c(src_data) + src = blocks.vector_source_c(src_data) op = digital_swig.constellation_decoder_cb(cnst.base()) - dst = gr.vector_sink_b() + dst = blocks.vector_sink_b() self.tb.connect(src, op) self.tb.connect(op, dst) diff --git a/gr-digital/python/qa_constellation_receiver.py b/gr-digital/python/qa_constellation_receiver.py index bc44220ea9..73a78d0f8e 100755 --- a/gr-digital/python/qa_constellation_receiver.py +++ b/gr-digital/python/qa_constellation_receiver.py @@ -156,7 +156,7 @@ class rec_test_tb(gr.top_block): else: self.src_data = src_data packer = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST) - src = gr.vector_source_b(self.src_data) + src = blocks.vector_source_b(self.src_data) mod = generic_mod(constellation, differential=differential) # Channel if freq_offset: @@ -171,7 +171,7 @@ class rec_test_tb(gr.top_block): else: demod = generic_demod(constellation, differential=differential, freq_bw=0, phase_bw=0) - self.dst = gr.vector_sink_b() + self.dst = blocks.vector_sink_b() self.connect(src, packer, mod, channel, demod, self.dst) if __name__ == '__main__': diff --git a/gr-digital/python/qa_correlate_access_code.py b/gr-digital/python/qa_correlate_access_code.py index 5a5f2209f7..ccddc0f113 100755 --- a/gr-digital/python/qa_correlate_access_code.py +++ b/gr-digital/python/qa_correlate_access_code.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2006,2007,2010,2011 Free Software Foundation, Inc. +# Copyright 2006,2007,2010,2011,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -22,6 +22,7 @@ from gnuradio import gr, gr_unittest import digital_swig as digital +import blocks_swig as blocks import math default_access_code = '\xAC\xDD\xA4\xE2\xF2\x8C\x20\xFC' @@ -52,9 +53,9 @@ class test_correlate_access_code(gr_unittest.TestCase): # 0 0 0 1 0 0 0 1 src_data = (1, 0, 1, 1, 1, 1, 0, 1, 1) + pad + (0,) * 7 expected_result = pad + (1, 0, 1, 1, 3, 1, 0, 1, 1, 2) + (0,) * 6 - src = gr.vector_source_b(src_data) + src = blocks.vector_source_b(src_data) op = digital.correlate_access_code_bb("1011", 0) - dst = gr.vector_sink_b() + dst = blocks.vector_sink_b() self.tb.connect(src, op, dst) self.tb.run() result_data = dst.data() @@ -69,9 +70,9 @@ class test_correlate_access_code(gr_unittest.TestCase): #print access_code src_data = code + (1, 0, 1, 1) + pad expected_result = pad + code + (3, 0, 1, 1) - src = gr.vector_source_b(src_data) + src = blocks.vector_source_b(src_data) op = digital.correlate_access_code_bb(access_code, 0) - dst = gr.vector_sink_b() + dst = blocks.vector_sink_b() self.tb.connect(src, op, dst) self.tb.run() result_data = dst.data() @@ -85,9 +86,9 @@ class test_correlate_access_code(gr_unittest.TestCase): #print access_code src_data = code + (1, 0, 1, 1) + pad expected_result = code + (1, 0, 1, 1) + pad - src = gr.vector_source_b(src_data) + src = blocks.vector_source_b(src_data) op = digital.correlate_access_code_tag_bb(access_code, 0, "test") - dst = gr.vector_sink_b() + dst = blocks.vector_sink_b() self.tb.connect(src, op, dst) self.tb.run() result_data = dst.data() diff --git a/gr-digital/python/qa_costas_loop_cc.py b/gr-digital/python/qa_costas_loop_cc.py index 365eda736a..9be96101e3 100755 --- a/gr-digital/python/qa_costas_loop_cc.py +++ b/gr-digital/python/qa_costas_loop_cc.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2011 Free Software Foundation, Inc. +# Copyright 2011,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -22,6 +22,7 @@ from gnuradio import gr, gr_unittest import digital_swig as digital +import blocks_swig as blocks import psk import random, cmath @@ -40,8 +41,8 @@ class test_costas_loop_cc(gr_unittest.TestCase): self.test = digital.costas_loop_cc(natfreq, order) data = 100*[complex(1,0),] - self.src = gr.vector_source_c(data, False) - self.snk = gr.vector_sink_c() + self.src = blocks.vector_source_c(data, False) + self.snk = blocks.vector_sink_c() self.tb.connect(self.src, self.test, self.snk) self.tb.run() @@ -57,8 +58,8 @@ class test_costas_loop_cc(gr_unittest.TestCase): self.test = digital.costas_loop_cc(natfreq, order) data = [complex(2*random.randint(0,1)-1, 0) for i in xrange(100)] - self.src = gr.vector_source_c(data, False) - self.snk = gr.vector_sink_c() + self.src = blocks.vector_source_c(data, False) + self.snk = blocks.vector_sink_c() self.tb.connect(self.src, self.test, self.snk) self.tb.run() @@ -81,8 +82,8 @@ class test_costas_loop_cc(gr_unittest.TestCase): expected_result = data[N:] data = [rot*d for d in data] - self.src = gr.vector_source_c(data, False) - self.snk = gr.vector_sink_c() + self.src = blocks.vector_source_c(data, False) + self.snk = blocks.vector_sink_c() self.tb.connect(self.src, self.test, self.snk) self.tb.run() @@ -107,8 +108,8 @@ class test_costas_loop_cc(gr_unittest.TestCase): expected_result = data[N:] data = [rot*d for d in data] - self.src = gr.vector_source_c(data, False) - self.snk = gr.vector_sink_c() + self.src = blocks.vector_source_c(data, False) + self.snk = blocks.vector_sink_c() self.tb.connect(self.src, self.test, self.snk) self.tb.run() @@ -136,8 +137,8 @@ class test_costas_loop_cc(gr_unittest.TestCase): rot = cmath.exp(0.1j) # some small rotation data = [rot*d for d in data] - self.src = gr.vector_source_c(data, False) - self.snk = gr.vector_sink_c() + self.src = blocks.vector_source_c(data, False) + self.snk = blocks.vector_sink_c() self.tb.connect(self.src, self.test, self.snk) self.tb.run() diff --git a/gr-digital/python/qa_cpm.py b/gr-digital/python/qa_cpm.py index 070e69a982..c87f7c34d6 100755 --- a/gr-digital/python/qa_cpm.py +++ b/gr-digital/python/qa_cpm.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2010 Free Software Foundation, Inc. +# Copyright 2010,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -38,10 +38,10 @@ class test_cpm(gr_unittest.TestCase): sps = 2 L = 1 in_bits = (1,) * 20 - src = gr.vector_source_b(in_bits, False) + src = blocks.vector_source_b(in_bits, False) cpm = digital.cpmmod_bc(type, 0.5, sps, L) arg = blocks.complex_to_arg() - sink = gr.vector_sink_f() + sink = blocks.vector_sink_f() self.tb.connect(src, cpm, arg, sink) self.tb.run() @@ -69,10 +69,10 @@ class test_cpm(gr_unittest.TestCase): L = 5 bt = 0.3 in_bits = (1,) * 20 - src = gr.vector_source_b(in_bits, False) + src = blocks.vector_source_b(in_bits, False) gmsk = digital.gmskmod_bc(sps, L, bt) arg = blocks.complex_to_arg() - sink = gr.vector_sink_f() + sink = blocks.vector_sink_f() self.tb.connect(src, gmsk, arg, sink) self.tb.run() diff --git a/gr-digital/python/qa_crc32_bb.py b/gr-digital/python/qa_crc32_bb.py index 4574b9dca7..6ee7ca1bcf 100755 --- a/gr-digital/python/qa_crc32_bb.py +++ b/gr-digital/python/qa_crc32_bb.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# Copyright 2012 Free Software Foundation, Inc. +# Copyright 2012,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -41,9 +41,9 @@ class qa_crc32_bb (gr_unittest.TestCase): tag.offset = 0 tag.key = pmt.string_to_symbol(tag_name) tag.value = pmt.from_long(len(data)) - src = gr.vector_source_b(data, False, 1, (tag,)) + src = blocks.vector_source_b(data, False, 1, (tag,)) crc = digital.crc32_bb(False, tag_name) - sink = gr.vector_sink_b() + sink = blocks.vector_sink_b() self.tb.connect(src, crc, sink) self.tb.run() # Check that the packets before crc_check are 4 bytes longer that the input. @@ -58,10 +58,10 @@ class qa_crc32_bb (gr_unittest.TestCase): tag.offset = 0 tag.key = pmt.string_to_symbol(tag_name) tag.value = pmt.from_long(len(data)) - src = gr.vector_source_b(data, False, 1, (tag,)) + src = blocks.vector_source_b(data, False, 1, (tag,)) crc = digital.crc32_bb(False, tag_name) crc_check = digital.crc32_bb(True, tag_name) - sink = gr.vector_sink_b() + sink = blocks.vector_sink_b() self.tb.connect(src, crc, crc_check, sink) self.tb.run() # Check that the packets after crc_check are the same as input. @@ -91,9 +91,9 @@ class qa_crc32_bb (gr_unittest.TestCase): testtag3.offset = len(packets)-1 testtag3.key = pmt.string_to_symbol("tag3") testtag3.value = pmt.from_long(0) - src = gr.vector_source_b(packets, False, 1, (tag1, tag2, testtag1, testtag2, testtag3)) + src = blocks.vector_source_b(packets, False, 1, (tag1, tag2, testtag1, testtag2, testtag3)) crc = digital.crc32_bb(False, tag_name) - sink = gr.vector_sink_b() + sink = blocks.vector_sink_b() self.tb.connect(src, crc, sink) self.tb.run() self.assertEqual(len(sink.data()), 2*(pack_len+4)) @@ -117,11 +117,11 @@ class qa_crc32_bb (gr_unittest.TestCase): tag.offset = 0 tag.key = pmt.string_to_symbol(tag_name) tag.value = pmt.from_long(len(data)) - src = gr.vector_source_b(data, False, 1, (tag,)) + src = blocks.vector_source_b(data, False, 1, (tag,)) crc = digital.crc32_bb(False, tag_name) crc_check = digital.crc32_bb(True, tag_name) corruptor = blocks.add_const_bb(1) - sink = gr.vector_sink_b() + sink = blocks.vector_sink_b() self.tb.connect(src, crc, corruptor, crc_check, sink) self.tb.run() # crc_check will drop invalid packets @@ -139,9 +139,9 @@ class qa_crc32_bb (gr_unittest.TestCase): testtag.offset = len(data)-1 testtag.key = pmt.string_to_symbol('tag1') testtag.value = pmt.from_long(0) - src = gr.vector_source_b(data, False, 1, (tag, testtag)) + src = blocks.vector_source_b(data, False, 1, (tag, testtag)) crc_check = digital.crc32_bb(True, tag_name) - sink = gr.vector_sink_b() + sink = blocks.vector_sink_b() self.tb.connect(src, crc_check, sink) self.tb.run() self.assertEqual([len(data)-5,], [tag.offset for tag in sink.tags() if pmt.symbol_to_string(tag.key) == 'tag1']) diff --git a/gr-digital/python/qa_diff_encoder.py b/gr-digital/python/qa_diff_encoder.py index c28f4dbdf8..06efdf7189 100755 --- a/gr-digital/python/qa_diff_encoder.py +++ b/gr-digital/python/qa_diff_encoder.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2006,2007,2010,2012 Free Software Foundation, Inc. +# Copyright 2006,2007,2010,2012,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -22,6 +22,7 @@ from gnuradio import gr, gr_unittest import digital_swig as digital +import blocks_swig as blocks import math import random @@ -45,10 +46,10 @@ class test_diff_encoder(gr_unittest.TestCase): modulus = 2 src_data = make_random_int_tuple(1000, 0, modulus-1) expected_result = src_data - src = gr.vector_source_b(src_data) + src = blocks.vector_source_b(src_data) enc = digital.diff_encoder_bb(modulus) dec = digital.diff_decoder_bb(modulus) - dst = gr.vector_sink_b() + dst = blocks.vector_sink_b() self.tb.connect(src, enc, dec, dst) self.tb.run() # run the graph and wait for it to finish actual_result = dst.data() # fetch the contents of the sink @@ -59,10 +60,10 @@ class test_diff_encoder(gr_unittest.TestCase): modulus = 4 src_data = make_random_int_tuple(1000, 0, modulus-1) expected_result = src_data - src = gr.vector_source_b(src_data) + src = blocks.vector_source_b(src_data) enc = digital.diff_encoder_bb(modulus) dec = digital.diff_decoder_bb(modulus) - dst = gr.vector_sink_b() + dst = blocks.vector_sink_b() self.tb.connect(src, enc, dec, dst) self.tb.run() # run the graph and wait for it to finish actual_result = dst.data() # fetch the contents of the sink @@ -73,10 +74,10 @@ class test_diff_encoder(gr_unittest.TestCase): modulus = 8 src_data = make_random_int_tuple(40000, 0, modulus-1) expected_result = src_data - src = gr.vector_source_b(src_data) + src = blocks.vector_source_b(src_data) enc = digital.diff_encoder_bb(modulus) dec = digital.diff_decoder_bb(modulus) - dst = gr.vector_sink_b() + dst = blocks.vector_sink_b() self.tb.connect(src, enc, dec, dst) self.tb.run() # run the graph and wait for it to finish actual_result = dst.data() # fetch the contents of the sink diff --git a/gr-digital/python/qa_diff_phasor_cc.py b/gr-digital/python/qa_diff_phasor_cc.py index 833158d0a8..87ff59a2c4 100755 --- a/gr-digital/python/qa_diff_phasor_cc.py +++ b/gr-digital/python/qa_diff_phasor_cc.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2004,2007,2010 Free Software Foundation, Inc. +# Copyright 2004,2007,2010,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -22,6 +22,7 @@ from gnuradio import gr, gr_unittest import digital_swig as digital +import blocks_swig as blocks import math class test_diff_phasor(gr_unittest.TestCase): @@ -35,9 +36,9 @@ class test_diff_phasor(gr_unittest.TestCase): def test_diff_phasor_cc(self): src_data = (0+0j, 1+0j, -1+0j, 3+4j, -3-4j, -3+4j) expected_result = (0+0j, 0+0j, -1+0j, -3-4j, -25+0j, -7-24j) - src = gr.vector_source_c(src_data) + src = blocks.vector_source_c(src_data) op = digital.diff_phasor_cc() - dst = gr.vector_sink_c() + dst = blocks.vector_sink_c() self.tb.connect(src, op) self.tb.connect(op, dst) self.tb.run() # run the graph and wait for it to finish diff --git a/gr-digital/python/qa_fll_band_edge.py b/gr-digital/python/qa_fll_band_edge.py index 0f6bad984e..050bf888d5 100755 --- a/gr-digital/python/qa_fll_band_edge.py +++ b/gr-digital/python/qa_fll_band_edge.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2011,2012 Free Software Foundation, Inc. +# Copyright 2011-2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -51,7 +51,7 @@ class test_fll_band_edge_cc(gr_unittest.TestCase): # Create a set of 1's and -1's, pulse shape and interpolate to sps random.seed(0) data = [2.0*random.randint(0, 2) - 1.0 for i in xrange(200)] - self.src = gr.vector_source_c(data, False) + self.src = blocks.vector_source_c(data, False) self.rrc = filter.interp_fir_filter_ccf(sps, rrc_taps) # Mix symbols with a complex sinusoid to spin them @@ -63,10 +63,10 @@ class test_fll_band_edge_cc(gr_unittest.TestCase): # Create sinks for all outputs of the FLL # we will only care about the freq and error outputs - self.vsnk_frq = gr.vector_sink_f() - self.nsnk_fll = gr.null_sink(gr.sizeof_gr_complex) - self.nsnk_phs = gr.null_sink(gr.sizeof_float) - self.nsnk_err = gr.null_sink(gr.sizeof_float) + self.vsnk_frq = blocks.vector_sink_f() + self.nsnk_fll = blocks.null_sink(gr.sizeof_gr_complex) + self.nsnk_phs = blocks.null_sink(gr.sizeof_float) + self.nsnk_err = blocks.null_sink(gr.sizeof_float) # Connect the blocks self.tb.connect(self.nco, (self.mix,1)) diff --git a/gr-digital/python/qa_framer_sink.py b/gr-digital/python/qa_framer_sink.py index e717e6ae05..bf6c5cc96d 100755 --- a/gr-digital/python/qa_framer_sink.py +++ b/gr-digital/python/qa_framer_sink.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2012 Free Software Foundation, Inc. +# Copyright 2012,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -22,6 +22,7 @@ from gnuradio import gr, gr_unittest import digital_swig as digital +import blocks_swig as blocks default_access_code = '\xAC\xDD\xA4\xE2\xF2\x8C\x20\xFC' @@ -56,10 +57,10 @@ class test_framker_sink(gr_unittest.TestCase): rcvd_pktq = gr.msg_queue() - src = gr.vector_source_b(src_data) + src = blocks.vector_source_b(src_data) correlator = digital.correlate_access_code_bb(access_code, 0) framer_sink = digital.framer_sink_1(rcvd_pktq) - vsnk = gr.vector_sink_b() + vsnk = blocks.vector_sink_b() self.tb.connect(src, correlator, framer_sink) self.tb.connect(correlator, vsnk) @@ -80,10 +81,10 @@ class test_framker_sink(gr_unittest.TestCase): rcvd_pktq = gr.msg_queue() - src = gr.vector_source_b(src_data) + src = blocks.vector_source_b(src_data) correlator = digital.correlate_access_code_bb(access_code, 0) framer_sink = digital.framer_sink_1(rcvd_pktq) - vsnk = gr.vector_sink_b() + vsnk = blocks.vector_sink_b() self.tb.connect(src, correlator, framer_sink) self.tb.connect(correlator, vsnk) diff --git a/gr-digital/python/qa_glfsr_source.py b/gr-digital/python/qa_glfsr_source.py index c5adab3023..227801c07e 100755 --- a/gr-digital/python/qa_glfsr_source.py +++ b/gr-digital/python/qa_glfsr_source.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2007,2010,2012 Free Software Foundation, Inc. +# Copyright 2007,2010,2012,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -22,6 +22,7 @@ from gnuradio import gr, gr_unittest import digital_swig as digital +import blocks_swig as blocks class test_glfsr_source(gr_unittest.TestCase): @@ -46,7 +47,7 @@ class test_glfsr_source(gr_unittest.TestCase): for degree in range(1,11): # Higher degrees take too long to correlate src = digital.glfsr_source_b(degree, False) b2f = digital.chunks_to_symbols_bf((-1.0,1.0), 1) - dst = gr.vector_sink_f() + dst = blocks.vector_sink_f() del self.tb # Discard existing top block self.tb = gr.top_block() self.tb.connect(src, b2f, dst) @@ -71,7 +72,7 @@ class test_glfsr_source(gr_unittest.TestCase): def test_005_correlation_f(self): for degree in range(1,11): # Higher degrees take too long to correlate src = digital.glfsr_source_f(degree, False) - dst = gr.vector_sink_f() + dst = blocks.vector_sink_f() del self.tb # Discard existing top block self.tb = gr.top_block() self.tb.connect(src, dst) diff --git a/gr-digital/python/qa_header_payload_demux.py b/gr-digital/python/qa_header_payload_demux.py index 4073f24ace..7595409ef8 100755 --- a/gr-digital/python/qa_header_payload_demux.py +++ b/gr-digital/python/qa_header_payload_demux.py @@ -23,6 +23,7 @@ from gnuradio import gr, gr_unittest try: import pmt except: from gruel import pmt import digital_swig as digital +import blocks_swig as blocks import time class qa_header_payload_demux (gr_unittest.TestCase): @@ -45,14 +46,14 @@ class qa_header_payload_demux (gr_unittest.TestCase): trigger_signal = [0,] * len(data_signal) trigger_signal[n_zeros] = 1 - data_src = gr.vector_source_f(data_signal, False) - trigger_src = gr.vector_source_b(trigger_signal, False) + data_src = blocks.vector_source_f(data_signal, False) + trigger_src = blocks.vector_source_b(trigger_signal, False) hpd = digital.header_payload_demux( len(header), 1, 0, "frame_len", "detect", False, gr.sizeof_float ) self.assertEqual(pmt.length(hpd.message_ports_in()), 1) - header_sink = gr.vector_sink_f() - payload_sink = gr.vector_sink_f() + header_sink = blocks.vector_sink_f() + payload_sink = blocks.vector_sink_f() self.tb.connect(data_src, (hpd, 0)) self.tb.connect(trigger_src, (hpd, 1)) diff --git a/gr-digital/python/qa_lms_equalizer.py b/gr-digital/python/qa_lms_equalizer.py index 9ba90a89ab..749cce2075 100755 --- a/gr-digital/python/qa_lms_equalizer.py +++ b/gr-digital/python/qa_lms_equalizer.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2006,2007,2010,2011 Free Software Foundation, Inc. +# Copyright 2006,2007,2010,2011,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -22,6 +22,7 @@ from gnuradio import gr, gr_unittest import digital_swig as digital +import blocks_swig as blocks class test_lms_dd_equalizer(gr_unittest.TestCase): @@ -32,9 +33,9 @@ class test_lms_dd_equalizer(gr_unittest.TestCase): self.tb = None def transform(self, src_data, gain, const): - SRC = gr.vector_source_c(src_data, False) + SRC = blocks.vector_source_c(src_data, False) EQU = digital.lms_dd_equalizer_cc(4, gain, 1, const.base()) - DST = gr.vector_sink_c() + DST = blocks.vector_sink_c() self.tb.connect(SRC, EQU, DST) self.tb.run() return DST.data() diff --git a/gr-digital/python/qa_map.py b/gr-digital/python/qa_map.py index 0fd7c479a1..2083d4a849 100755 --- a/gr-digital/python/qa_map.py +++ b/gr-digital/python/qa_map.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2012 Free Software Foundation, Inc. +# Copyright 2012,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -22,6 +22,7 @@ from gnuradio import gr, gr_unittest import digital_swig as digital +import blocks_swig as blocks class test_map(gr_unittest.TestCase): @@ -34,9 +35,9 @@ class test_map(gr_unittest.TestCase): def helper(self, symbols): src_data = [0, 1, 2, 3, 0, 1, 2, 3] expected_data = map(lambda x: symbols[x], src_data) - src = gr.vector_source_b(src_data) + src = blocks.vector_source_b(src_data) op = digital.map_bb(symbols) - dst = gr.vector_sink_b() + dst = blocks.vector_sink_b() self.tb.connect(src, op, dst) self.tb.run() diff --git a/gr-digital/python/qa_mpsk_receiver.py b/gr-digital/python/qa_mpsk_receiver.py index bde8895e76..9590df1f72 100755 --- a/gr-digital/python/qa_mpsk_receiver.py +++ b/gr-digital/python/qa_mpsk_receiver.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2011,2012 Free Software Foundation, Inc. +# Copyright 2011-2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -23,6 +23,7 @@ from gnuradio import gr, gr_unittest import digital_swig as digital import filter_swig as filter +import blocks_swig as blocks import random, cmath, time class test_mpsk_receiver(gr_unittest.TestCase): @@ -53,8 +54,8 @@ class test_mpsk_receiver(gr_unittest.TestCase): data = 10000*[complex(1,0), complex(-1,0)] #data = [2*random.randint(0,1)-1 for x in xrange(10000)] - self.src = gr.vector_source_c(data, False) - self.snk = gr.vector_sink_c() + self.src = blocks.vector_source_c(data, False) + self.snk = blocks.vector_sink_c() # pulse shaping interpolation filter nfilts = 32 @@ -109,8 +110,8 @@ class test_mpsk_receiver(gr_unittest.TestCase): complex(-0.707, -0.707), complex( 0.707, -0.707)] data = [0.5*d for d in data] - self.src = gr.vector_source_c(data, False) - self.snk = gr.vector_sink_c() + self.src = blocks.vector_source_c(data, False) + self.snk = blocks.vector_sink_c() # pulse shaping interpolation filter nfilts = 32 diff --git a/gr-digital/python/qa_mpsk_snr_est.py b/gr-digital/python/qa_mpsk_snr_est.py index c976bf21a8..f500f0eb16 100755 --- a/gr-digital/python/qa_mpsk_snr_est.py +++ b/gr-digital/python/qa_mpsk_snr_est.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2011,2012 Free Software Foundation, Inc. +# Copyright 2011-2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -22,6 +22,7 @@ from gnuradio import gr, gr_unittest import digital_swig as digital +import blocks_swig as blocks import math, random def get_cplx(): @@ -46,8 +47,8 @@ class test_mpsk_snr_est(gr_unittest.TestCase): for i in xrange(1,6): src_data = [b+(i*n) for b,n in zip(self._bits, self._noise)] - src = gr.vector_source_c(src_data) - dst = gr.null_sink(gr.sizeof_gr_complex) + src = blocks.vector_source_c(src_data) + dst = blocks.null_sink(gr.sizeof_gr_complex) tb = gr.top_block() tb.connect(src, op) @@ -104,7 +105,7 @@ class test_mpsk_snr_est(gr_unittest.TestCase): for i in xrange(1,6): src_data = [b+(i*n) for b,n in zip(self._bits, self._noise)] - src = gr.vector_source_c(src_data) + src = blocks.vector_source_c(src_data) N = 10000 alpha = 0.001 diff --git a/gr-digital/python/qa_ofdm_carrier_allocator_cvc.py b/gr-digital/python/qa_ofdm_carrier_allocator_cvc.py index 2105727e04..0f5803a270 100755 --- a/gr-digital/python/qa_ofdm_carrier_allocator_cvc.py +++ b/gr-digital/python/qa_ofdm_carrier_allocator_cvc.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# Copyright 2012 Free Software Foundation, Inc. +# Copyright 2012,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -23,6 +23,7 @@ from gnuradio import gr, gr_unittest try: import pmt except: from gruel import pmt import digital_swig as digital +import blocks_swig as blocks class qa_digital_carrier_allocator_cvc (gr_unittest.TestCase): @@ -47,13 +48,13 @@ class qa_digital_carrier_allocator_cvc (gr_unittest.TestCase): tag.offset = 0 tag.key = pmt.string_to_symbol(tag_name) tag.value = pmt.from_long(len(tx_symbols)) - src = gr.vector_source_c(tx_symbols, False, 1, (tag,)) + src = blocks.vector_source_c(tx_symbols, False, 1, (tag,)) alloc = digital.ofdm_carrier_allocator_cvc(fft_len, occupied_carriers, pilot_carriers, pilot_symbols, tag_name) - sink = gr.vector_sink_c(fft_len) + sink = blocks.vector_sink_c(fft_len) self.tb.connect(src, alloc, sink) self.tb.run () self.assertEqual(sink.data(), expected_result) @@ -73,13 +74,13 @@ class qa_digital_carrier_allocator_cvc (gr_unittest.TestCase): tag.offset = 0 tag.key = pmt.string_to_symbol(tag_name) tag.value = pmt.from_long(len(tx_symbols)) - src = gr.vector_source_c(tx_symbols, False, 1, (tag,)) + src = blocks.vector_source_c(tx_symbols, False, 1, (tag,)) alloc = digital.ofdm_carrier_allocator_cvc(fft_len, occupied_carriers, pilot_carriers, pilot_symbols, tag_name) - sink = gr.vector_sink_c(fft_len) + sink = blocks.vector_sink_c(fft_len) self.tb.connect(src, alloc, sink) self.tb.run () self.assertEqual(sink.data(), expected_result) @@ -126,13 +127,14 @@ class qa_digital_carrier_allocator_cvc (gr_unittest.TestCase): testtag4.offset = 2*len(tx_symbols)-1 # Last OFDM symbol of packet 2 testtag4.key = pmt.string_to_symbol('tag4') testtag4.value = pmt.from_long(0) - src = gr.vector_source_c(tx_symbols * 2, False, 1, (tag1, tag2, testtag1, testtag2, testtag3, testtag4)) + src = blocks.vector_source_c(tx_symbols * 2, False, 1, + (tag1, tag2, testtag1, testtag2, testtag3, testtag4)) alloc = digital.ofdm_carrier_allocator_cvc(fft_len, occupied_carriers, pilot_carriers, pilot_symbols, tag_name) - sink = gr.vector_sink_c(fft_len) + sink = blocks.vector_sink_c(fft_len) self.tb.connect(src, alloc, sink) self.tb.run () self.assertEqual(sink.data(), expected_result * 2) diff --git a/gr-digital/python/qa_ofdm_chanest_vcvc.py b/gr-digital/python/qa_ofdm_chanest_vcvc.py index c7c0d83a84..c45e39988b 100755 --- a/gr-digital/python/qa_ofdm_chanest_vcvc.py +++ b/gr-digital/python/qa_ofdm_chanest_vcvc.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# Copyright 2012 Free Software Foundation, Inc. +# Copyright 2012,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -70,9 +70,9 @@ class qa_ofdm_sync_eqinit_vcvc (gr_unittest.TestCase): tag2.offset = 2 tag2.key = pmt.string_to_symbol("test_tag_2") tag2.value = pmt.from_long(42) - src = gr.vector_source_c(tx_data, False, fft_len, (tag1, tag2)) + src = blocks.vector_source_c(tx_data, False, fft_len, (tag1, tag2)) chanest = digital.ofdm_chanest_vcvc(sync_symbol1, sync_symbol2, 1) - sink = gr.vector_sink_c(fft_len) + sink = blocks.vector_sink_c(fft_len) self.tb.connect(src, chanest, sink) self.tb.run() self.assertEqual(shift_tuple(sink.data(), -carr_offset), data_symbol) @@ -104,10 +104,10 @@ class qa_ofdm_sync_eqinit_vcvc (gr_unittest.TestCase): data_symbol = (0, 0, 0, 1, -1, 1, -1, 1, 0, 1, -1, -1, -1, 1, 0, 0) tx_data = shift_tuple(sync_symbol, carr_offset) + \ shift_tuple(data_symbol, carr_offset) - src = gr.vector_source_c(tx_data, False, fft_len) + src = blocks.vector_source_c(tx_data, False, fft_len) # 17 is out of bounds! chanest = digital.ofdm_chanest_vcvc(sync_symbol, (), 1, 0, 17) - sink = gr.vector_sink_c(fft_len) + sink = blocks.vector_sink_c(fft_len) self.tb.connect(src, chanest, sink) self.tb.run() self.assertEqual(shift_tuple(sink.data(), -carr_offset), data_symbol) @@ -126,10 +126,10 @@ class qa_ofdm_sync_eqinit_vcvc (gr_unittest.TestCase): data_symbol = (0, 0, 0, 1, -1, 1, -1, 1, 0, 1, -1, -1, -1, 1, 0, 0) tx_data = sync_symbol1 + sync_symbol2 + data_symbol channel = (0, 0, 0, 2, -2, 2, 3j, 2, 0, 2, 2, 2, 2, 3, 0, 0) - src = gr.vector_source_c(tx_data, False, fft_len) + src = blocks.vector_source_c(tx_data, False, fft_len) chan = blocks.multiply_const_vcc(channel) chanest = digital.ofdm_chanest_vcvc(sync_symbol1, sync_symbol2, 1) - sink = gr.vector_sink_c(fft_len) + sink = blocks.vector_sink_c(fft_len) self.tb.connect(src, chan, chanest, sink) self.tb.run() tags = sink.tags() @@ -149,10 +149,10 @@ class qa_ofdm_sync_eqinit_vcvc (gr_unittest.TestCase): data_symbol = (0, 0, 0, 1, -1, 1, -1, 1, 0, 1, -1, -1, -1, 1, 0, 0) tx_data = sync_symbol + data_symbol channel = (0, 0, 0, 2, 2, 2, 2.5, 3, 2.5, 2, 2.5, 3, 2, 1, 1, 0) - src = gr.vector_source_c(tx_data, False, fft_len) + src = blocks.vector_source_c(tx_data, False, fft_len) chan = blocks.multiply_const_vcc(channel) chanest = digital.ofdm_chanest_vcvc(sync_symbol, (), 1) - sink = gr.vector_sink_c(fft_len) + sink = blocks.vector_sink_c(fft_len) self.tb.connect(src, chan, chanest, sink) self.tb.run() tags = sink.tags() @@ -172,10 +172,10 @@ class qa_ofdm_sync_eqinit_vcvc (gr_unittest.TestCase): data_symbol = (0, 0, 0, 1, -1, 1, -1, 1, 0, 1, -1, -1, -1, 1, 0, 0) tx_data = sync_symbol + data_symbol channel = (0, 0, 0, 2, 2, 2, 2.5, 3, 2.5, 2, 2.5, 3, 2, 1, 1, 0) - src = gr.vector_source_c(tx_data, False, fft_len) + src = blocks.vector_source_c(tx_data, False, fft_len) chan = blocks.multiply_const_vcc(channel) chanest = digital.ofdm_chanest_vcvc(sync_symbol, ref_symbol, 1) - sink = gr.vector_sink_c(fft_len) + sink = blocks.vector_sink_c(fft_len) self.tb.connect(src, chan, chanest, sink) self.tb.run() tags = sink.tags() @@ -199,10 +199,10 @@ class qa_ofdm_sync_eqinit_vcvc (gr_unittest.TestCase): shift_tuple(sync_symbol2, carr_offset) + \ shift_tuple(data_symbol, carr_offset) channel = range(fft_len) - src = gr.vector_source_c(tx_data, False, fft_len) + src = blocks.vector_source_c(tx_data, False, fft_len) chan = blocks.multiply_const_vcc(channel) chanest = digital.ofdm_chanest_vcvc(sync_symbol1, sync_symbol2, 1) - sink = gr.vector_sink_c(fft_len) + sink = blocks.vector_sink_c(fft_len) self.tb.connect(src, chan, chanest, sink) self.tb.run() tags = sink.tags() @@ -236,12 +236,12 @@ class qa_ofdm_sync_eqinit_vcvc (gr_unittest.TestCase): shift_tuple(sync_sym2, carr_offset) + \ shift_tuple(data_sym, carr_offset) channel = [rand_range(min_chan_ampl, max_chan_ampl) * numpy.exp(1j * rand_range(0, 2 * numpy.pi)) for x in range(fft_len)] - src = gr.vector_source_c(tx_data, False, fft_len) + src = blocks.vector_source_c(tx_data, False, fft_len) chan = blocks.multiply_const_vcc(channel) noise = analog.noise_source_c(analog.GR_GAUSSIAN, wgn_amplitude) add = blocks.add_cc(fft_len) chanest = digital.ofdm_chanest_vcvc(sync_sym1, sync_sym2, 1) - sink = gr.vector_sink_c(fft_len) + sink = blocks.vector_sink_c(fft_len) top_block.connect(src, chan, (add, 0), chanest, sink) top_block.connect(noise, blocks.stream_to_vector(gr.sizeof_gr_complex, fft_len), (add, 1)) top_block.run() diff --git a/gr-digital/python/qa_ofdm_cyclic_prefixer.py b/gr-digital/python/qa_ofdm_cyclic_prefixer.py index 003e987e95..355742ab07 100755 --- a/gr-digital/python/qa_ofdm_cyclic_prefixer.py +++ b/gr-digital/python/qa_ofdm_cyclic_prefixer.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2007,2010,2011 Free Software Foundation, Inc. +# Copyright 2007,2010,2011,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -24,6 +24,7 @@ from gnuradio import gr, gr_unittest try: import pmt except: from gruel import pmt import digital_swig as digital +import blocks_swig as blocks class test_ofdm_cyclic_prefixer (gr_unittest.TestCase): @@ -39,9 +40,9 @@ class test_ofdm_cyclic_prefixer (gr_unittest.TestCase): cp_len = 2 expected_result = (6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7) - src = gr.vector_source_c(range(fft_len) * 2, False, fft_len) + src = blocks.vector_source_c(range(fft_len) * 2, False, fft_len) cp = digital.ofdm_cyclic_prefixer(fft_len, fft_len + cp_len) - sink = gr.vector_sink_c() + sink = blocks.vector_sink_c() self.tb.connect(src, cp, sink) self.tb.run() self.assertEqual(sink.data(), expected_result) @@ -53,9 +54,9 @@ class test_ofdm_cyclic_prefixer (gr_unittest.TestCase): rolloff = 2 expected_result = (7.0/2, 8, 1, 2, 3, 4, 5, 6, 7, 8, # 1.0/2 7.0/2+1.0/2, 8, 1, 2, 3, 4, 5, 6, 7, 8) - src = gr.vector_source_c(range(1, fft_len+1) * 2, False, fft_len) + src = blocks.vector_source_c(range(1, fft_len+1) * 2, False, fft_len) cp = digital.ofdm_cyclic_prefixer(fft_len, fft_len + cp_len, rolloff) - sink = gr.vector_sink_c() + sink = blocks.vector_sink_c() self.tb.connect(src, cp, sink) self.tb.run() self.assertEqual(sink.data(), expected_result) @@ -75,9 +76,9 @@ class test_ofdm_cyclic_prefixer (gr_unittest.TestCase): tag2.offset = 1 tag2.key = pmt.string_to_symbol("random_tag") tag2.value = pmt.from_long(42) - src = gr.vector_source_c(range(1, fft_len+1) * 2, False, fft_len, (tag, tag2)) + src = blocks.vector_source_c(range(1, fft_len+1) * 2, False, fft_len, (tag, tag2)) cp = digital.ofdm_cyclic_prefixer(fft_len, fft_len + cp_len, 2, tag_name) - sink = gr.vector_sink_c() + sink = blocks.vector_sink_c() self.tb.connect(src, cp, sink) self.tb.run() self.assertEqual(sink.data(), expected_result) diff --git a/gr-digital/python/qa_ofdm_frame_equalizer_vcvc.py b/gr-digital/python/qa_ofdm_frame_equalizer_vcvc.py index 9faface03f..6df9ecbecf 100755 --- a/gr-digital/python/qa_ofdm_frame_equalizer_vcvc.py +++ b/gr-digital/python/qa_ofdm_frame_equalizer_vcvc.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# Copyright 2012 Free Software Foundation, Inc. +# Copyright 2012,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -24,6 +24,7 @@ from gnuradio import gr, gr_unittest try: import pmt except: from gruel import pmt import digital_swig as digital +import blocks_swig as blocks class qa_ofdm_frame_equalizer_vcvc (gr_unittest.TestCase): @@ -48,9 +49,9 @@ class qa_ofdm_frame_equalizer_vcvc (gr_unittest.TestCase): chan_tag.offset = 0 chan_tag.key = pmt.string_to_symbol("ofdm_sync_chan_taps") chan_tag.value = pmt.init_c32vector(fft_len, (1,) * fft_len) - src = gr.vector_source_c(tx_data, False, fft_len, (len_tag, chan_tag)) + src = blocks.vector_source_c(tx_data, False, fft_len, (len_tag, chan_tag)) eq = digital.ofdm_frame_equalizer_vcvc(equalizer.base(), len_tag_key) - sink = gr.vector_sink_c(fft_len) + sink = blocks.vector_sink_c(fft_len) self.tb.connect(src, eq, sink) self.tb.run () # Check data @@ -93,9 +94,9 @@ class qa_ofdm_frame_equalizer_vcvc (gr_unittest.TestCase): chan_tag.offset = 0 chan_tag.key = pmt.string_to_symbol("ofdm_sync_chan_taps") chan_tag.value = pmt.init_c32vector(fft_len, channel[:fft_len]) - src = gr.vector_source_c(numpy.multiply(tx_signal, channel), False, fft_len, (len_tag, chan_tag)) + src = blocks.vector_source_c(numpy.multiply(tx_signal, channel), False, fft_len, (len_tag, chan_tag)) eq = digital.ofdm_frame_equalizer_vcvc(equalizer.base(), len_tag_key, True) - sink = gr.vector_sink_c(fft_len) + sink = blocks.vector_sink_c(fft_len) self.tb.connect(src, eq, sink) self.tb.run () rx_data = [cnst.decision_maker_v((x,)) if x != 0 else -1 for x in sink.data()] @@ -142,9 +143,9 @@ class qa_ofdm_frame_equalizer_vcvc (gr_unittest.TestCase): chan_tag.offset = 0 chan_tag.key = pmt.string_to_symbol("ofdm_sync_chan_taps") chan_tag.value = pmt.init_c32vector(fft_len, channel[:fft_len]) - src = gr.vector_source_c(numpy.multiply(tx_signal, channel), False, fft_len, (len_tag, chan_tag)) + src = blocks.vector_source_c(numpy.multiply(tx_signal, channel), False, fft_len, (len_tag, chan_tag)) eq = digital.ofdm_frame_equalizer_vcvc(equalizer.base(), len_tag_key, True) - sink = gr.vector_sink_c(fft_len) + sink = blocks.vector_sink_c(fft_len) self.tb.connect(src, eq, sink) self.tb.run () rx_data = [cnst.decision_maker_v((x,)) if x != 0 else -1 for x in sink.data()] diff --git a/gr-digital/python/qa_ofdm_insert_preamble.py b/gr-digital/python/qa_ofdm_insert_preamble.py index 60902edc14..ec7ace8905 100755 --- a/gr-digital/python/qa_ofdm_insert_preamble.py +++ b/gr-digital/python/qa_ofdm_insert_preamble.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2007,2010-2012 Free Software Foundation, Inc. +# Copyright 2007,2010-2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -35,8 +35,8 @@ class test_ofdm_insert_preamble(gr_unittest.TestCase): def helper(self, v0, v1, fft_length, preamble): tb = self.tb - src0 = gr.vector_source_c(v0) - src1 = gr.vector_source_b(v1) + src0 = blocks.vector_source_c(v0) + src1 = blocks.vector_source_b(v1) s2v = blocks.stream_to_vector(gr.sizeof_gr_complex, fft_length) @@ -45,8 +45,8 @@ class test_ofdm_insert_preamble(gr_unittest.TestCase): op = digital.ofdm_insert_preamble(fft_length, preamble) v2s = blocks.vector_to_stream(gr.sizeof_gr_complex, fft_length) - dst0 = gr.vector_sink_c() - dst1 = gr.vector_sink_b() + dst0 = blocks.vector_sink_c() + dst1 = blocks.vector_sink_b() tb.connect(src0, s2v, (op, 0)) tb.connect(src1, (op, 1)) diff --git a/gr-digital/python/qa_ofdm_serializer_vcc.py b/gr-digital/python/qa_ofdm_serializer_vcc.py index 107d6076c5..684cfe341f 100755 --- a/gr-digital/python/qa_ofdm_serializer_vcc.py +++ b/gr-digital/python/qa_ofdm_serializer_vcc.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2012 Free Software Foundation, Inc. +# Copyright 2012,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -52,9 +52,9 @@ class qa_ofdm_serializer_vcc (gr_unittest.TestCase): tag.offset = 0 tag.key = pmt.string_to_symbol(tag_name) tag.value = pmt.from_long(n_syms) - src = gr.vector_source_c(tx_symbols, False, fft_len, (tag,)) + src = blocks.vector_source_c(tx_symbols, False, fft_len, (tag,)) serializer = digital.ofdm_serializer_vcc(fft_len, occupied_carriers, tag_name, "", 0, False) - sink = gr.vector_sink_c() + sink = blocks.vector_sink_c() self.tb.connect(src, serializer, sink) self.tb.run () self.assertEqual(sink.data(), expected_result) @@ -83,9 +83,9 @@ class qa_ofdm_serializer_vcc (gr_unittest.TestCase): offsettag.offset = 0 offsettag.key = pmt.string_to_symbol("ofdm_sync_carr_offset") offsettag.value = pmt.from_long(carr_offset) - src = gr.vector_source_c(tx_symbols, False, fft_len, (tag, offsettag)) + src = blocks.vector_source_c(tx_symbols, False, fft_len, (tag, offsettag)) serializer = digital.ofdm_serializer_vcc(fft_len, occupied_carriers, tag_name, "", 0, False) - sink = gr.vector_sink_c() + sink = blocks.vector_sink_c() self.tb.connect(src, serializer, sink) self.tb.run () self.assertEqual(sink.data(), expected_result) @@ -108,14 +108,14 @@ class qa_ofdm_serializer_vcc (gr_unittest.TestCase): tag.offset = 0 tag.key = pmt.string_to_symbol(tag_name) tag.value = pmt.from_long(len(tx_data)) - src = gr.vector_source_c(tx_data, False, 1, (tag,)) + src = blocks.vector_source_c(tx_data, False, 1, (tag,)) alloc = digital.ofdm_carrier_allocator_cvc(fft_len, occupied_carriers, pilot_carriers, pilot_symbols, tag_name) serializer = digital.ofdm_serializer_vcc(alloc) - sink = gr.vector_sink_c() + sink = blocks.vector_sink_c() self.tb.connect(src, alloc, serializer, sink) self.tb.run () self.assertEqual(sink.data(), tx_data) @@ -146,7 +146,7 @@ class qa_ofdm_serializer_vcc (gr_unittest.TestCase): offsettag.offset = 0 offsettag.key = pmt.string_to_symbol("ofdm_sync_carr_offset") offsettag.value = pmt.from_long(carr_offset) - src = gr.vector_source_c(tx_data, False, 1, (tag, offsettag)) + src = blocks.vector_source_c(tx_data, False, 1, (tag, offsettag)) alloc = digital.ofdm_carrier_allocator_cvc(fft_len, occupied_carriers, pilot_carriers, @@ -157,7 +157,7 @@ class qa_ofdm_serializer_vcc (gr_unittest.TestCase): mixer = blocks.multiply_cc() rx_fft = fft.fft_vcc(fft_len, True, (), True) serializer = digital.ofdm_serializer_vcc(alloc) - sink = gr.vector_sink_c() + sink = blocks.vector_sink_c() self.tb.connect( src, alloc, tx_ifft, blocks.vector_to_stream(gr.sizeof_gr_complex, fft_len), @@ -189,9 +189,9 @@ class qa_ofdm_serializer_vcc (gr_unittest.TestCase): tag2.offset = 0 tag2.key = pmt.string_to_symbol("packet_len") tag2.value = pmt.from_long(len(expected_result)) - src = gr.vector_source_c(tx_symbols, False, fft_len, (tag, tag2)) + src = blocks.vector_source_c(tx_symbols, False, fft_len, (tag, tag2)) serializer = digital.ofdm_serializer_vcc(fft_len, occupied_carriers, tag_name, "packet_len", 0, False) - sink = gr.vector_sink_c() + sink = blocks.vector_sink_c() self.tb.connect(src, serializer, sink) self.tb.run () self.assertEqual(sink.data(), expected_result) diff --git a/gr-digital/python/qa_ofdm_sync_sc_cfb.py b/gr-digital/python/qa_ofdm_sync_sc_cfb.py index e71cd5cce3..8374595d62 100755 --- a/gr-digital/python/qa_ofdm_sync_sc_cfb.py +++ b/gr-digital/python/qa_ofdm_sync_sc_cfb.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2012 Free Software Foundation, Inc. +# Copyright 2012,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -63,9 +63,9 @@ class qa_ofdm_sync_sc_cfb (gr_unittest.TestCase): tx_signal = tx_signal * 2 add = blocks.add_cc() sync = digital.ofdm_sync_sc_cfb(fft_len, cp_len) - sink_freq = gr.vector_sink_f() - sink_detect = gr.vector_sink_b() - self.tb.connect(gr.vector_source_c(tx_signal), (add, 0)) + sink_freq = blocks.vector_sink_f() + sink_detect = blocks.vector_sink_b() + self.tb.connect(blocks.vector_source_c(tx_signal), (add, 0)) self.tb.connect(analog.noise_source_c(analog.GR_GAUSSIAN, .01), (add, 1)) self.tb.connect(add, sync) self.tb.connect((sync, 0), sink_freq) @@ -92,9 +92,9 @@ class qa_ofdm_sync_sc_cfb (gr_unittest.TestCase): mult = blocks.multiply_cc() add = blocks.add_cc() sync = digital.ofdm_sync_sc_cfb(fft_len, cp_len) - sink_freq = gr.vector_sink_f() - sink_detect = gr.vector_sink_b() - self.tb.connect(gr.vector_source_c(tx_signal), (mult, 0), (add, 0)) + sink_freq = blocks.vector_sink_f() + sink_detect = blocks.vector_sink_b() + self.tb.connect(blocks.vector_source_c(tx_signal), (mult, 0), (add, 0)) self.tb.connect(analog.sig_source_c(2 * numpy.pi, analog.GR_SIN_WAVE, freq_offset, 1.0), (mult, 1)) self.tb.connect(analog.noise_source_c(analog.GR_GAUSSIAN, .01), (add, 1)) self.tb.connect(add, sync) @@ -122,9 +122,9 @@ class qa_ofdm_sync_sc_cfb (gr_unittest.TestCase): [(random.randint(0, 1)*2)-1 for x in range(fft_len * random.randint(5,23))] add = blocks.add_cc() sync = digital.ofdm_sync_sc_cfb(fft_len, cp_len) - sink_freq = gr.vector_sink_f() - sink_detect = gr.vector_sink_b() - self.tb.connect(gr.vector_source_c(tx_signal), (add, 0)) + sink_freq = blocks.vector_sink_f() + sink_detect = blocks.vector_sink_b() + self.tb.connect(blocks.vector_source_c(tx_signal), (add, 0)) self.tb.connect(analog.noise_source_c(analog.GR_GAUSSIAN, .005), (add, 1)) self.tb.connect(add, sync) self.tb.connect((sync, 0), sink_freq) @@ -161,7 +161,7 @@ Detection error was: %d """ % (numpy.sum(sink_detect.data()) - n_bursts) #packets, tagname, vlen=1) #total_length = len(data) - #src = gr.vector_source_b(data, False, 1, tags) + #src = blocks.vector_source_b(data, False, 1, tags) #mod = ofdm_tx( #fft_len=fft_len, #cp_len=cp_len, @@ -178,11 +178,11 @@ Detection error was: %d """ % (numpy.sum(sink_detect.data()) - n_bursts) #head = gr.head(gr.sizeof_gr_complex, int(total_length * ratio*2)) #add = gr.add_cc() #sync = digital.ofdm_sync_sc_cfb(fft_len, cp_len) - #sink_freq = gr.vector_sink_f() - #sink_detect = gr.vector_sink_b() + #sink_freq = blocks.vector_sink_f() + #sink_detect = blocks.vector_sink_b() #noise_level = 0.01 #noise = gr.noise_source_c(gr.GR_GAUSSIAN, noise_level) - #self.tb.connect(src, mod, gr.null_sink(gr.sizeof_gr_complex)) + #self.tb.connect(src, mod, blocks.null_sink(gr.sizeof_gr_complex)) #self.tb.connect(insert_zeros, sink_countbursts) #self.tb.connect(noise, (add, 1)) #self.tb.connect(add, sync) diff --git a/gr-digital/python/qa_ofdm_txrx.py b/gr-digital/python/qa_ofdm_txrx.py index 778f03f515..963fca850c 100755 --- a/gr-digital/python/qa_ofdm_txrx.py +++ b/gr-digital/python/qa_ofdm_txrx.py @@ -22,7 +22,8 @@ import numpy from gnuradio import gr, gr_unittest -import digital_swig +import digital_swig as digital +import blocks_swig as blocks class test_ofdm_txrx (gr_unittest.TestCase): @@ -38,18 +39,18 @@ class test_ofdm_txrx (gr_unittest.TestCase): #n_bytes = 100 #test_data = [random.randint(0, 255) for x in range(n_bytes)] #tx_data, tags = tagged_streams.packets_to_vectors((test_data,), len_tag_key) - #src = gr.vector_source_b(test_data, False, 1, tags) + #src = blocks.vector_source_b(test_data, False, 1, tags) #tx = ofdm_tx(frame_length_tag_key=len_tag_key) #rx = ofdm_rx(frame_length_tag_key=len_tag_key) #self.assertEqual(tx.sync_word1, rx.sync_word1) #self.assertEqual(tx.sync_word2, rx.sync_word2) - #delay = gr.delay(gr.sizeof_gr_complex, 100) - #noise = gr.noise_source_c(gr.GR_GAUSSIAN, 0.05) - #add = gr.add_cc() - #sink = gr.vector_sink_b() + #delay = blocks.delay(gr.sizeof_gr_complex, 100) + #noise = analog.noise_source_c(analog.GR_GAUSSIAN, 0.05) + #add = blocks.add_cc() + #sink = blocks.vector_sink_b() ##self.tb.connect(src, tx, add, rx, sink) ##self.tb.connect(noise, (add, 1)) - #self.tb.connect(src, tx, gr.null_sink(gr.sizeof_gr_complex)) + #self.tb.connect(src, tx, blocks.null_sink(gr.sizeof_gr_complex)) #self.tb.run() diff --git a/gr-digital/python/qa_packet_headergenerator_bb.py b/gr-digital/python/qa_packet_headergenerator_bb.py index 2e6e401566..43659c604d 100755 --- a/gr-digital/python/qa_packet_headergenerator_bb.py +++ b/gr-digital/python/qa_packet_headergenerator_bb.py @@ -21,6 +21,7 @@ from gnuradio import gr, gr_unittest import digital_swig as digital +import blocks_swig as blocks try: import pmt except: from gruel import pmt @@ -48,9 +49,9 @@ class qa_packet_headergenerator_bb (gr_unittest.TestCase): tag3.offset = 6 tag3.key = pmt.string_to_symbol(tagname) tag3.value = pmt.from_long(4) - src = gr.vector_source_b(data, False, 1, (tag1, tag2, tag3)) + src = blocks.vector_source_b(data, False, 1, (tag1, tag2, tag3)) header = digital.packet_headergenerator_bb(12, tagname) - sink = gr.vector_sink_b() + sink = blocks.vector_sink_b() self.tb.connect(src, header, sink) self.tb.run() expected_data = ( @@ -77,9 +78,9 @@ class qa_packet_headergenerator_bb (gr_unittest.TestCase): tag3.offset = 6 tag3.key = pmt.string_to_symbol(tagname) tag3.value = pmt.from_long(4) - src = gr.vector_source_b(data, False, 1, (tag1, tag2, tag3)) + src = blocks.vector_source_b(data, False, 1, (tag1, tag2, tag3)) header = digital.packet_headergenerator_bb(32, tagname) - sink = gr.vector_sink_b() + sink = blocks.vector_sink_b() self.tb.connect(src, header, sink) self.tb.run() expected_data = ( @@ -107,10 +108,10 @@ class qa_packet_headergenerator_bb (gr_unittest.TestCase): tag3.offset = 6 tag3.key = pmt.string_to_symbol(tagname) tag3.value = pmt.from_long(4) - src = gr.vector_source_b(data, False, 1, (tag1, tag2, tag3)) + src = blocks.vector_source_b(data, False, 1, (tag1, tag2, tag3)) formatter_object = digital.packet_header_default(12, tagname) header = digital.packet_headergenerator_bb(formatter_object.formatter()) - sink = gr.vector_sink_b() + sink = blocks.vector_sink_b() self.tb.connect(src, header, sink) self.tb.run() expected_data = ( @@ -137,12 +138,12 @@ class qa_packet_headergenerator_bb (gr_unittest.TestCase): tag3.offset = 6 tag3.key = pmt.string_to_symbol(tagname) tag3.value = pmt.from_long(4) - src = gr.vector_source_b(data, False, 1, (tag1, tag2, tag3)) + src = blocks.vector_source_b(data, False, 1, (tag1, tag2, tag3)) formatter_object = digital.packet_header_ofdm(occupied_carriers, 1, tagname) self.assertEqual(formatter_object.header_len(), 6) self.assertEqual(pmt.symbol_to_string(formatter_object.len_tag_key()), tagname) header = digital.packet_headergenerator_bb(formatter_object.formatter()) - sink = gr.vector_sink_b() + sink = blocks.vector_sink_b() self.tb.connect(src, header, sink) self.tb.run() expected_data = ( diff --git a/gr-digital/python/qa_packet_headerparser_b.py b/gr-digital/python/qa_packet_headerparser_b.py index aec2f96b57..da7aef69d3 100755 --- a/gr-digital/python/qa_packet_headerparser_b.py +++ b/gr-digital/python/qa_packet_headerparser_b.py @@ -43,7 +43,7 @@ class qa_packet_headerparser_b (gr_unittest.TestCase): ) tagname = "packet_len" - src = gr.vector_source_b(expected_data) + src = blocks.vector_source_b(expected_data) parser = digital.packet_headerparser_b(32, tagname) sink = blocks.message_debug() diff --git a/gr-digital/python/qa_pfb_clock_sync.py b/gr-digital/python/qa_pfb_clock_sync.py index 4d0276bcd6..3db1fd5581 100755 --- a/gr-digital/python/qa_pfb_clock_sync.py +++ b/gr-digital/python/qa_pfb_clock_sync.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2011 Free Software Foundation, Inc. +# Copyright 2011,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -23,6 +23,7 @@ from gnuradio import gr, gr_unittest import filter_swig as filter import digital_swig as digital +import blocks_swig as blocks import random, cmath class test_pfb_clock_sync(gr_unittest.TestCase): @@ -54,7 +55,7 @@ class test_pfb_clock_sync(gr_unittest.TestCase): osps) data = 10000*[complex(1,0), complex(-1,0)] - self.src = gr.vector_source_c(data, False) + self.src = blocks.vector_source_c(data, False) # pulse shaping interpolation filter rrc_taps = filter.firdes.root_raised_cosine( @@ -65,7 +66,7 @@ class test_pfb_clock_sync(gr_unittest.TestCase): ntaps) self.rrc_filter = filter.pfb_arb_resampler_ccf(sps, rrc_taps) - self.snk = gr.vector_sink_c() + self.snk = blocks.vector_sink_c() self.tb.connect(self.src, self.rrc_filter, self.test, self.snk) self.tb.run() @@ -107,7 +108,7 @@ class test_pfb_clock_sync(gr_unittest.TestCase): osps) data = 10000*[1, -1] - self.src = gr.vector_source_f(data, False) + self.src = blocks.vector_source_f(data, False) # pulse shaping interpolation filter rrc_taps = filter.firdes.root_raised_cosine( @@ -118,7 +119,7 @@ class test_pfb_clock_sync(gr_unittest.TestCase): ntaps) self.rrc_filter = filter.pfb_arb_resampler_fff(sps, rrc_taps) - self.snk = gr.vector_sink_f() + self.snk = blocks.vector_sink_f() self.tb.connect(self.src, self.rrc_filter, self.test, self.snk) self.tb.run() diff --git a/gr-digital/python/qa_pn_correlator_cc.py b/gr-digital/python/qa_pn_correlator_cc.py index 53633d04fa..14d6bcfbe1 100755 --- a/gr-digital/python/qa_pn_correlator_cc.py +++ b/gr-digital/python/qa_pn_correlator_cc.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2007,2010,2012 Free Software Foundation, Inc. +# Copyright 2007,2010,2012,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -39,10 +39,10 @@ class test_pn_correlator_cc(gr_unittest.TestCase): degree = 10 length = 2**degree-1 src = digital.glfsr_source_f(degree) - head = gr.head(gr.sizeof_float, length*length) + head = blocks.head(gr.sizeof_float, length*length) f2c = blocks.float_to_complex() corr = digital.pn_correlator_cc(degree) - dst = gr.vector_sink_c() + dst = blocks.vector_sink_c() self.tb.connect(src, head, f2c, corr, dst) self.tb.run() data = dst.data() diff --git a/gr-digital/python/qa_probe_density.py b/gr-digital/python/qa_probe_density.py index f42f00a7f7..45d651ec1c 100755 --- a/gr-digital/python/qa_probe_density.py +++ b/gr-digital/python/qa_probe_density.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2012 Free Software Foundation, Inc. +# Copyright 2012,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -22,6 +22,7 @@ from gnuradio import gr, gr_unittest import digital_swig as digital +import blocks_swig as blocks class test_probe_density(gr_unittest.TestCase): @@ -34,7 +35,7 @@ class test_probe_density(gr_unittest.TestCase): def test_001(self): src_data = [0, 1, 0, 1] expected_data = 1 - src = gr.vector_source_b(src_data) + src = blocks.vector_source_b(src_data) op = digital.probe_density_b(1) self.tb.connect(src, op) self.tb.run() @@ -46,7 +47,7 @@ class test_probe_density(gr_unittest.TestCase): def test_002(self): src_data = [1, 1, 1, 1] expected_data = 1 - src = gr.vector_source_b(src_data) + src = blocks.vector_source_b(src_data) op = digital.probe_density_b(0.01) self.tb.connect(src, op) self.tb.run() @@ -57,7 +58,7 @@ class test_probe_density(gr_unittest.TestCase): def test_003(self): src_data = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1] expected_data = 0.95243 - src = gr.vector_source_b(src_data) + src = blocks.vector_source_b(src_data) op = digital.probe_density_b(0.01) self.tb.connect(src, op) self.tb.run() diff --git a/gr-digital/python/qa_scrambler.py b/gr-digital/python/qa_scrambler.py index 3127a7c1e6..b4980e7816 100755 --- a/gr-digital/python/qa_scrambler.py +++ b/gr-digital/python/qa_scrambler.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2008,2010,2012 Free Software Foundation, Inc. +# Copyright 2008,2010,2012,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -22,6 +22,7 @@ from gnuradio import gr, gr_unittest import digital_swig as digital +import blocks_swig as blocks class test_scrambler(gr_unittest.TestCase): @@ -33,30 +34,30 @@ class test_scrambler(gr_unittest.TestCase): def test_scrambler_descrambler(self): src_data = (1,)*1000 - src = gr.vector_source_b(src_data, False) + src = blocks.vector_source_b(src_data, False) scrambler = digital.scrambler_bb(0x8a, 0x7F, 7) # CCSDS 7-bit scrambler descrambler = digital.descrambler_bb(0x8a, 0x7F, 7) - dst = gr.vector_sink_b() + dst = blocks.vector_sink_b() self.tb.connect(src, scrambler, descrambler, dst) self.tb.run() self.assertEqual(tuple(src_data[:-8]), dst.data()[8:]) # skip garbage during synchronization def test_additive_scrambler(self): src_data = (1,)*1000 - src = gr.vector_source_b(src_data, False) + src = blocks.vector_source_b(src_data, False) scrambler = digital.additive_scrambler_bb(0x8a, 0x7f, 7) descrambler = digital.additive_scrambler_bb(0x8a, 0x7f, 7) - dst = gr.vector_sink_b() + dst = blocks.vector_sink_b() self.tb.connect(src, scrambler, descrambler, dst) self.tb.run() self.assertEqual(src_data, dst.data()) def test_additive_scrambler_reset(self): src_data = (1,)*1000 - src = gr.vector_source_b(src_data, False) + src = blocks.vector_source_b(src_data, False) scrambler = digital.additive_scrambler_bb(0x8a, 0x7f, 7, 100) descrambler = digital.additive_scrambler_bb(0x8a, 0x7f, 7, 100) - dst = gr.vector_sink_b() + dst = blocks.vector_sink_b() self.tb.connect(src, scrambler, descrambler, dst) self.tb.run() self.assertEqual(src_data, dst.data()) diff --git a/gr-digital/python/qa_simple_correlator.py b/gr-digital/python/qa_simple_correlator.py index ff0faeb415..57312ff0dd 100755 --- a/gr-digital/python/qa_simple_correlator.py +++ b/gr-digital/python/qa_simple_correlator.py @@ -44,7 +44,7 @@ class test_simple_correlator(gr_unittest.TestCase): # Just using a RRC for some basic filter shape taps = filter.firdes.root_raised_cosine(8, 8, 1.0, 0.5, 21) - src = gr.vector_source_b(expected_result) + src = blocks.vector_source_b(expected_result) frame = digital.simple_framer(4) unpack = blocks.packed_to_unpacked_bb(1, gr.GR_MSB_FIRST) expand = filter.interp_fir_filter_fff(8, taps) @@ -52,7 +52,7 @@ class test_simple_correlator(gr_unittest.TestCase): mult2 = blocks.multiply_const_ff(2) sub1 = blocks.add_const_ff(-1) op = digital.simple_correlator(4) - dst = gr.vector_sink_b() + dst = blocks.vector_sink_b() self.tb.connect(src, frame, unpack, b2f, mult2, sub1, expand) self.tb.connect(expand, op, dst) self.tb.run() diff --git a/gr-digital/python/qa_simple_framer.py b/gr-digital/python/qa_simple_framer.py index f8c894da28..f598b393f2 100755 --- a/gr-digital/python/qa_simple_framer.py +++ b/gr-digital/python/qa_simple_framer.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2004,2007,2010,2012 Free Software Foundation, Inc. +# Copyright 2004,2007,2010,2012,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -22,6 +22,7 @@ from gnuradio import gr, gr_unittest import digital_swig as digital +import blocks_swig as blocks import math class test_simple_framer(gr_unittest.TestCase): @@ -44,9 +45,9 @@ class test_simple_framer(gr_unittest.TestCase): 0xac, 0xdd, 0xa4, 0xe2, 0xf2, 0x8c, 0x20, 0xfc, 0x02, 0x88, 0x99, 0xaa, 0xbb, 0x55, 0xac, 0xdd, 0xa4, 0xe2, 0xf2, 0x8c, 0x20, 0xfc, 0x03, 0xcc, 0xdd, 0xee, 0xff, 0x55) - src = gr.vector_source_b(src_data) + src = blocks.vector_source_b(src_data) op = digital.simple_framer(4) - dst = gr.vector_sink_b() + dst = blocks.vector_sink_b() self.tb.connect(src, op) self.tb.connect(op, dst) self.tb.run() diff --git a/gr-digital/swig/CMakeLists.txt b/gr-digital/swig/CMakeLists.txt index 0db5140429..cbef8da888 100644 --- a/gr-digital/swig/CMakeLists.txt +++ b/gr-digital/swig/CMakeLists.txt @@ -59,13 +59,7 @@ install( FILES digital_swig.i constellation.i - digital_crc32_bb.i - digital_ofdm_carrier_allocator_cvc.i - digital_ofdm_chanest_vcvc.i - digital_ofdm_equalizer_base.i - digital_ofdm_equalizer_simpledfe.i - digital_ofdm_equalizer_static.i - digital_ofdm_sync_sc_cfb.i + ofdm_equalizer.i packet_header.i ${CMAKE_CURRENT_BINARY_DIR}/digital_swig_doc.i DESTINATION ${GR_INCLUDE_DIR}/gnuradio/swig diff --git a/gr-digital/swig/digital_crc32_bb.i b/gr-digital/swig/digital_crc32_bb.i deleted file mode 100644 index 45b240793d..0000000000 --- a/gr-digital/swig/digital_crc32_bb.i +++ /dev/null @@ -1,32 +0,0 @@ -/* -*- c++ -*- */ -/* Copyright 2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(digital, crc32_bb) - -digital_crc32_bb_sptr -digital_make_crc32_bb (bool check=false, const std::string& lengthtagname="packet_len"); - -class digital_crc32_bb : public gr_block -{ - private: - digital_crc32_bb(bool check, const std::string& lengthtagname); -}; - diff --git a/gr-digital/swig/digital_ofdm_carrier_allocator_cvc.i b/gr-digital/swig/digital_ofdm_carrier_allocator_cvc.i deleted file mode 100644 index 1663a4de3d..0000000000 --- a/gr-digital/swig/digital_ofdm_carrier_allocator_cvc.i +++ /dev/null @@ -1,37 +0,0 @@ -/* -*- c++ -*- */ -/* Copyright 2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(digital, ofdm_carrier_allocator_cvc); - -digital_ofdm_carrier_allocator_cvc_sptr -digital_make_ofdm_carrier_allocator_cvc ( - int fft_len, - const std::vector<std::vector<int> > &occupied_carriers, - const std::vector<std::vector<int> > &pilot_carriers, - const std::vector<std::vector<gr_complex> > &pilot_symbols, - const std::string &len_tag_key = "packet_len"); - -class digital_ofdm_carrier_allocator_cvc : public gr_tagged_stream_block -{ - private: - digital_ofdm_carrier_allocator_cvc(int fft_len, const std::vector<std::vector<int> > &occupied_carriers, const std::vector<std::vector<int> > &pilot_carriers, const std::vector<std::vector<gr_complex> > &pilot_symbols, const std::string &len_tag_key); -}; - diff --git a/gr-digital/swig/digital_ofdm_cyclic_prefixer.i b/gr-digital/swig/digital_ofdm_cyclic_prefixer.i deleted file mode 100644 index 19ffd6a12b..0000000000 --- a/gr-digital/swig/digital_ofdm_cyclic_prefixer.i +++ /dev/null @@ -1,35 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004-2006,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(digital,ofdm_cyclic_prefixer); - -digital_ofdm_cyclic_prefixer_sptr -digital_make_ofdm_cyclic_prefixer (size_t input_size, - size_t output_size, - int rolloff_len=0, - const std::string &len_tag_key=""); - - -class digital_ofdm_cyclic_prefixer : public gr_tagged_stream_block -{ -}; - diff --git a/gr-digital/swig/digital_ofdm_equalizer_base.i b/gr-digital/swig/digital_ofdm_equalizer_base.i deleted file mode 100644 index c862fed09d..0000000000 --- a/gr-digital/swig/digital_ofdm_equalizer_base.i +++ /dev/null @@ -1,64 +0,0 @@ -/* -*- c++ -*- */ -/* Copyright 2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - - - -class digital_ofdm_equalizer_base; -typedef boost::shared_ptr<digital_ofdm_equalizer_base> digital_ofdm_equalizer_base_sptr; -%template(digital_ofdm_equalizer_base_sptr) boost::shared_ptr<digital_ofdm_equalizer_base>; -%ignore digital_ofdm_equalizer_base; - -class digital_ofdm_equalizer_1d_pilots; -typedef boost::shared_ptr<digital_ofdm_equalizer_1d_pilots> digital_ofdm_equalizer_1d_pilots_sptr; -%template(digital_ofdm_equalizer_1d_pilots_sptr) boost::shared_ptr<digital_ofdm_equalizer_1d_pilots>; -%ignore digital_ofdm_equalizer_1d_pilots; - -class digital_ofdm_equalizer_base -{ - public: - digital_ofdm_equalizer_base(int fft_len); - - virtual void reset() = 0; - void set_carrier_offset(int offset) { d_carr_offset = offset; }; - virtual void equalize( - gr_complex *frame, - int n_sym, - const std::vector<gr_complex> &initial_taps = std::vector<gr_complex>(), - const std::vector<gr_tag_t> &tags = std::vector<gr_tag_t>()) = 0; - virtual void get_channel_state(std::vector<gr_complex> &taps) = 0; - digital_ofdm_equalizer_base_sptr base(); -}; - - -class digital_ofdm_equalizer_1d_pilots : public digital_ofdm_equalizer_base -{ - public: - digital_ofdm_equalizer_1d_pilots( - int fft_len, - const std::vector<std::vector<int> > &occupied_carriers, - const std::vector<std::vector<int> > &pilot_carriers, - const std::vector<std::vector<gr_complex> > &pilot_symbols, - int symbols_skipped, - bool input_is_shifted); - - void reset(); -}; - diff --git a/gr-digital/swig/digital_ofdm_equalizer_simpledfe.i b/gr-digital/swig/digital_ofdm_equalizer_simpledfe.i deleted file mode 100644 index 1ca31c1edd..0000000000 --- a/gr-digital/swig/digital_ofdm_equalizer_simpledfe.i +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- c++ -*- */ -/* Copyright 2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - - -class digital_ofdm_equalizer_simpledfe; -typedef boost::shared_ptr<digital_ofdm_equalizer_simpledfe> digital_ofdm_equalizer_simpledfe_sptr; -%template(digital_ofdm_equalizer_simpledfe_sptr) boost::shared_ptr<digital_ofdm_equalizer_simpledfe>; -%rename(ofdm_equalizer_simpledfe) digital_make_ofdm_equalizer_simpledfe; -digital_ofdm_equalizer_simpledfe_sptr -digital_make_ofdm_equalizer_simpledfe( - int fft_len, - const gr::digital::constellation_sptr &constellation, - const std::vector<std::vector<int> > &occupied_carriers = std::vector<std::vector<int> >(), - const std::vector<std::vector<int> > &pilot_carriers = std::vector<std::vector<int> >(), - const std::vector<std::vector<gr_complex> > &pilot_symbols = std::vector<std::vector<gr_complex> >(), - int symbols_skipped = 0, - float alpha = 0.1, - bool input_is_shifted = true); -%ignore digital_ofdm_equalizer_simpledfe; - -class digital_ofdm_equalizer_simpledfe : public digital_ofdm_equalizer_1d_pilots -{ - public: - digital_ofdm_equalizer_simpledfe( - int fft_len, - const digital_constellation_sptr &constellation, - const std::vector<std::vector<int> > &occupied_carriers = std::vector<std::vector<int> >(), - const std::vector<std::vector<int> > &pilot_carriers = std::vector<std::vector<int> >(), - const std::vector<std::vector<gr_complex> > &pilot_symbols = std::vector<std::vector<gr_complex> >(), - int symbols_skipped = 0, - float alpha = 0.1, - bool input_is_shifted = true); - - void equalize(gr_complex *frame, - int n_sym, - const std::vector<gr_complex> &initial_taps = std::vector<gr_complex>(), - const std::vector<gr_tag_t> &tags = std::vector<gr_tag_t>()); - void get_channel_state(std::vector<gr_complex> &taps); -}; - diff --git a/gr-digital/swig/digital_ofdm_equalizer_static.i b/gr-digital/swig/digital_ofdm_equalizer_static.i deleted file mode 100644 index 3e99403ff7..0000000000 --- a/gr-digital/swig/digital_ofdm_equalizer_static.i +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- c++ -*- */ -/* Copyright 2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - - -class digital_ofdm_equalizer_static; -typedef boost::shared_ptr<digital_ofdm_equalizer_static> digital_ofdm_equalizer_static_sptr; -%template(digital_ofdm_equalizer_static_sptr) boost::shared_ptr<digital_ofdm_equalizer_static>; -%rename(ofdm_equalizer_static) digital_make_ofdm_equalizer_static; -digital_ofdm_equalizer_static_sptr -digital_make_ofdm_equalizer_static( - int fft_len, - const std::vector<std::vector<int> > &occupied_carriers = std::vector<std::vector<int> >(), - const std::vector<std::vector<int> > &pilot_carriers = std::vector<std::vector<int> >(), - const std::vector<std::vector<gr_complex> > &pilot_symbols = std::vector<std::vector<gr_complex> >(), - int symbols_skipped = 0, - bool input_is_shifted = true); -%ignore digital_ofdm_equalizer_static; - -class digital_ofdm_equalizer_static : public digital_ofdm_equalizer_1d_pilots -{ - public: - digital_ofdm_equalizer_static( - int fft_len, - const std::vector<std::vector<int> > &occupied_carriers = std::vector<std::vector<int> >(), - const std::vector<std::vector<int> > &pilot_carriers = std::vector<std::vector<int> >(), - const std::vector<std::vector<gr_complex> > &pilot_symbols = std::vector<std::vector<gr_complex> >(), - int symbols_skipped = 0, - bool input_is_shifted = true); - ~digital_ofdm_equalizer_static(); - - void equalize(gr_complex *frame, - int n_sym, - const std::vector<gr_complex> &initial_taps = std::vector<gr_complex>(), - const std::vector<gr_tag_t> &tags = std::vector<gr_tag_t>()); - void get_channel_state(std::vector<gr_complex> &taps); -}; - diff --git a/gr-digital/swig/digital_ofdm_sync_sc_cfb.i b/gr-digital/swig/digital_ofdm_sync_sc_cfb.i deleted file mode 100644 index 6a863ca3f9..0000000000 --- a/gr-digital/swig/digital_ofdm_sync_sc_cfb.i +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(digital, ofdm_sync_sc_cfb) - -digital_ofdm_sync_sc_cfb_sptr -digital_make_ofdm_sync_sc_cfb (int fft_len, int cp_len); - -class digital_ofdm_sync_sc_cfb : public gr_hier_block2 -{ - private: - digital_ofdm_sync_sc_cfb(int fft_len, int cp_len); -}; - diff --git a/gr-digital/swig/digital_swig.i b/gr-digital/swig/digital_swig.i index 10f34c9c81..b9a9dd617a 100644 --- a/gr-digital/swig/digital_swig.i +++ b/gr-digital/swig/digital_swig.i @@ -21,6 +21,7 @@ #define DIGITAL_API #define ANALOG_API +#define BLOCKS_API %include "gnuradio.i" %include "stdint.i" @@ -33,6 +34,7 @@ %{ #include <blocks/control_loop.h> %} +%include <blocks/control_loop.h> // Used in the constellation objects %template(unsigned_int_vector) std::vector<unsigned int>; @@ -57,6 +59,7 @@ #include "digital/costas_loop_cc.h" #include "digital/cpmmod_bc.h" #include "digital/crc32.h" +#include "digital/crc32_bb.h" #include "digital/descrambler_bb.h" #include "digital/diff_decoder_bb.h" #include "digital/diff_encoder_bb.h" @@ -74,6 +77,12 @@ #include "digital/mpsk_receiver_cc.h" #include "digital/mpsk_snr_est.h" #include "digital/mpsk_snr_est_cc.h" +#include "digital/ofdm_carrier_allocator_cvc.h" +#include "digital/ofdm_chanest_vcvc.h" +#include "digital/ofdm_cyclic_prefixer.h" +#include "digital/ofdm_equalizer_base.h" +#include "digital/ofdm_equalizer_simpledfe.h" +#include "digital/ofdm_equalizer_static.h" #include "digital/ofdm_frame_acquisition.h" #include "digital/ofdm_frame_equalizer_vcvc.h" #include "digital/ofdm_frame_sink.h" @@ -81,6 +90,7 @@ #include "digital/ofdm_mapper_bcv.h" #include "digital/ofdm_sampler.h" #include "digital/ofdm_serializer_vcc.h" +#include "digital/ofdm_sync_sc_cfb.h" #include "digital/packet_header_default.h" #include "digital/packet_header_ofdm.h" #include "digital/packet_headergenerator_bb.h" @@ -118,6 +128,7 @@ %include "digital/costas_loop_cc.h" %include "digital/cpmmod_bc.h" %include "digital/crc32.h" +%include "digital/crc32_bb.h" %include "digital/descrambler_bb.h" %include "digital/diff_decoder_bb.h" %include "digital/diff_encoder_bb.h" @@ -135,6 +146,12 @@ %include "digital/mpsk_receiver_cc.h" %include "digital/mpsk_snr_est.h" %include "digital/mpsk_snr_est_cc.h" +%include "digital/ofdm_carrier_allocator_cvc.h" +%include "digital/ofdm_chanest_vcvc.h" +%include "digital/ofdm_cyclic_prefixer.h" +%include "digital/ofdm_equalizer_base.h" +%include "digital/ofdm_equalizer_simpledfe.h" +%include "digital/ofdm_equalizer_static.h" %include "digital/ofdm_frame_acquisition.h" %include "digital/ofdm_frame_equalizer_vcvc.h" %include "digital/ofdm_frame_sink.h" @@ -142,6 +159,7 @@ %include "digital/ofdm_mapper_bcv.h" %include "digital/ofdm_sampler.h" %include "digital/ofdm_serializer_vcc.h" +%include "digital/ofdm_sync_sc_cfb.h" %include "digital/packet_header_default.h" %include "digital/packet_header_ofdm.h" %include "digital/packet_headergenerator_bb.h" @@ -172,6 +190,7 @@ GR_SWIG_BLOCK_MAGIC2(digital, constellation_receiver_cb); GR_SWIG_BLOCK_MAGIC2(digital, correlate_access_code_bb); GR_SWIG_BLOCK_MAGIC2(digital, correlate_access_code_tag_bb); GR_SWIG_BLOCK_MAGIC2(digital, costas_loop_cc); +GR_SWIG_BLOCK_MAGIC2(digital, crc32_bb); GR_SWIG_BLOCK_MAGIC2(digital, cpmmod_bc); GR_SWIG_BLOCK_MAGIC2(digital, descrambler_bb); GR_SWIG_BLOCK_MAGIC2(digital, diff_decoder_bb); @@ -187,6 +206,9 @@ GR_SWIG_BLOCK_MAGIC2(digital, lms_dd_equalizer_cc); GR_SWIG_BLOCK_MAGIC2(digital, map_bb); GR_SWIG_BLOCK_MAGIC2(digital, mpsk_receiver_cc); GR_SWIG_BLOCK_MAGIC2(digital, mpsk_snr_est_cc); +GR_SWIG_BLOCK_MAGIC2(digital, ofdm_carrier_allocator_cvc); +GR_SWIG_BLOCK_MAGIC2(digital, ofdm_chanest_vcvc); +GR_SWIG_BLOCK_MAGIC2(digital, ofdm_cyclic_prefixer); GR_SWIG_BLOCK_MAGIC2(digital, ofdm_frame_acquisition); GR_SWIG_BLOCK_MAGIC2(digital, ofdm_frame_equalizer_vcvc); GR_SWIG_BLOCK_MAGIC2(digital, ofdm_frame_sink); @@ -194,6 +216,7 @@ GR_SWIG_BLOCK_MAGIC2(digital, ofdm_insert_preamble); GR_SWIG_BLOCK_MAGIC2(digital, ofdm_mapper_bcv); GR_SWIG_BLOCK_MAGIC2(digital, ofdm_sampler); GR_SWIG_BLOCK_MAGIC2(digital, ofdm_serializer_vcc); +GR_SWIG_BLOCK_MAGIC2(digital, ofdm_sync_sc_cfb); GR_SWIG_BLOCK_MAGIC2(digital, packet_headergenerator_bb); GR_SWIG_BLOCK_MAGIC2(digital, packet_headerparser_b); GR_SWIG_BLOCK_MAGIC2(digital, packet_sink); @@ -208,29 +231,8 @@ GR_SWIG_BLOCK_MAGIC2(digital, simple_framer); GR_SWIG_BLOCK_MAGIC_FACTORY(digital, cpmmod_bc, gmskmod_bc); -// Properly package up constellation objects +// Properly package up non-block objects %include "constellation.i" - %include "packet_header.i" +%include "ofdm_equalizer.i" -// Old-style blocks to be converted to 3.7 -%{ -#include <digital_crc32_bb.h> -#include <digital_ofdm_carrier_allocator_cvc.h> -#include <digital_ofdm_cyclic_prefixer.h> -#include <digital_ofdm_chanest_vcvc.h> -#include <digital_ofdm_cyclic_prefixer.h> -#include <digital_ofdm_equalizer_base.h> -#include <digital_ofdm_equalizer_simpledfe.h> -#include <digital_ofdm_equalizer_static.h> -#include <digital_ofdm_sync_sc_cfb.h> -%} - -%include "digital_crc32_bb.i" -%include "digital_ofdm_carrier_allocator_cvc.i" -%include "digital_ofdm_chanest_vcvc.i" -%include "digital_ofdm_cyclic_prefixer.i" -%include "digital_ofdm_equalizer_base.i" -%include "digital_ofdm_equalizer_simpledfe.i" -%include "digital_ofdm_equalizer_static.i" -%include "digital_ofdm_sync_sc_cfb.i" diff --git a/gr-digital/swig/ofdm_equalizer.i b/gr-digital/swig/ofdm_equalizer.i new file mode 100644 index 0000000000..bd97b5bc06 --- /dev/null +++ b/gr-digital/swig/ofdm_equalizer.i @@ -0,0 +1,43 @@ +/* -*- c++ -*- */ +/* Copyright 2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +%template(ofdm_equalizer_base_sptr) boost::shared_ptr<gr::digital::ofdm_equalizer_base>; +%template(ofdm_equalizer_1d_pilots_sptr) boost::shared_ptr<gr::digital::ofdm_equalizer_1d_pilots>; +%pythoncode %{ +ofdm_equalizer_1d_pilots_sptr.__repr__ = lambda self: "<OFDM equalizer 1D base class>" +%} + +%template(ofdm_equalizer_simpledfe_sptr) boost::shared_ptr<gr::digital::ofdm_equalizer_simpledfe>; +%pythoncode %{ +ofdm_equalizer_simpledfe_sptr.__repr__ = lambda self: "<OFDM equalizer simpledfe>" +ofdm_equalizer_simpledfe = ofdm_equalizer_simpledfe.make; +%} +//%rename(ofdm_equalizer_simpledfe) make_ofdm_equalizer_simpledfe; +//%ignore ofdm_equalizer_simpledfe; + +%template(ofdm_equalizer_static_sptr) boost::shared_ptr<gr::digital::ofdm_equalizer_static>; +%pythoncode %{ +ofdm_equalizer_static_sptr.__repr__ = lambda self: "<OFDM equalizer static>" +ofdm_equalizer_static = ofdm_equalizer_static.make; +%} +//%rename(ofdm_equalizer_static) make_ofdm_equalizer_static; +//%ignore ofdm_equalizer_static; + diff --git a/gr-fcd/examples/grc/fcd_apt_rx.grc b/gr-fcd/examples/grc/fcd_apt_rx.grc index 41a806a102..3c88db7edd 100644 --- a/gr-fcd/examples/grc/fcd_apt_rx.grc +++ b/gr-fcd/examples/grc/fcd_apt_rx.grc @@ -1,6 +1,6 @@ <?xml version='1.0' encoding='ASCII'?> <flow_graph> - <timestamp>Sun May 8 18:01:53 2011</timestamp> + <timestamp>Mon Mar 18 10:04:36 2013</timestamp> <block> <key>options</key> <param> @@ -44,6 +44,10 @@ <value>True</value> </param> <param> + <key>max_nouts</key> + <value>0</value> + </param> + <param> <key>realtime_scheduling</key> <value></value> </param> @@ -57,57 +61,42 @@ </param> </block> <block> - <key>variable</key> + <key>variable_static_text</key> <param> <key>id</key> - <value>samp_rate</value> + <value>rec_info</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>value</key> - <value>96000</value> - </param> - <param> - <key>_coordinate</key> - <value>(200, 9)</value> + <key>label</key> + <value>Recording to</value> </param> <param> - <key>_rotation</key> - <value>0</value> + <key>value</key> + <value>wav_file</value> </param> - </block> - <block> - <key>audio_sink</key> <param> - <key>id</key> - <value>audio_sink</value> + <key>converver</key> + <value>str_converter</value> </param> <param> - <key>_enabled</key> - <value>True</value> + <key>formatter</key> + <value>None</value> </param> <param> - <key>samp_rate</key> - <value>48000</value> + <key>grid_pos</key> + <value>1,1,1,1</value> </param> <param> - <key>device_name</key> + <key>notebook</key> <value></value> </param> <param> - <key>ok_to_block</key> - <value>True</value> - </param> - <param> - <key>num_inputs</key> - <value>1</value> - </param> - <param> <key>_coordinate</key> - <value>(794, 355)</value> + <value>(641, 14)</value> </param> <param> <key>_rotation</key> @@ -115,46 +104,54 @@ </param> </block> <block> - <key>blks2_fm_demod_cf</key> + <key>fcd_source_c</key> <param> <key>id</key> - <value>blks2_fm_demod_cf</value> + <value>fcd_source_c_0</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>chan_rate</key> - <value>samp_rate</value> + <key>device_name</key> + <value>hw:1</value> </param> <param> - <key>audio_decim</key> - <value>2</value> + <key>freq</key> + <value>sat_freq</value> </param> <param> - <key>deviation</key> - <value>max_dev</value> + <key>lna</key> + <value>fcd_lna_gain</value> </param> <param> - <key>audio_pass</key> - <value>5000</value> + <key>mixer</key> + <value>+12</value> </param> <param> - <key>audio_stop</key> - <value>7000</value> + <key>ppm</key> + <value>-120</value> </param> <param> - <key>gain</key> - <value>1.0</value> + <key>dci</key> + <value>0.0</value> </param> <param> - <key>tau</key> - <value>75e-6</value> + <key>dcq</key> + <value>0.0</value> + </param> + <param> + <key>iq_phase</key> + <value>0.0</value> + </param> + <param> + <key>iq_gain</key> + <value>1.0</value> </param> <param> <key>_coordinate</key> - <value>(568, 307)</value> + <value>(68, 215)</value> </param> <param> <key>_rotation</key> @@ -162,38 +159,50 @@ </param> </block> <block> - <key>blks2_rational_resampler_xxx</key> + <key>variable_chooser</key> <param> <key>id</key> - <value>blks2_rational_resampler_xxx_0</value> + <value>fcd_lna_gain</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>type</key> - <value>fff</value> + <key>label</key> + <value>LNA gain [dB]</value> </param> <param> - <key>decim</key> - <value>48000</value> + <key>value</key> + <value>20.0</value> </param> <param> - <key>interp</key> - <value>11025</value> + <key>choices</key> + <value>[30.0, 25.0, 20.0, 17.5, 15.0, 12.5, 10.0, 7.5, 5.0, 2.5, 0.0, -2.5, -5.0]</value> </param> <param> - <key>taps</key> + <key>labels</key> <value>[]</value> </param> <param> - <key>fractional_bw</key> - <value>0</value> + <key>type</key> + <value>drop_down</value> + </param> + <param> + <key>style</key> + <value>wx.RA_HORIZONTAL</value> + </param> + <param> + <key>grid_pos</key> + <value>2,0,1,1</value> + </param> + <param> + <key>notebook</key> + <value></value> </param> <param> <key>_coordinate</key> - <value>(516, 522)</value> + <value>(247, 405)</value> </param> <param> <key>_rotation</key> @@ -201,45 +210,50 @@ </param> </block> <block> - <key>variable</key> + <key>variable_chooser</key> <param> <key>id</key> - <value>wav_file</value> + <value>sat_freq</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> + <key>label</key> + <value>Satellite</value> + </param> + <param> <key>value</key> - <value>prefix + datetime.now().strftime("%Y.%m.%d.%H.%M.%S") + ".wav"</value> + <value>137500000</value> </param> <param> - <key>_coordinate</key> - <value>(762, 652)</value> + <key>choices</key> + <value>[137500000,137620000,137912500,137100000]</value> </param> <param> - <key>_rotation</key> - <value>0</value> + <key>labels</key> + <value>["NOAA-15","NOAA-17","NOAA-18","NOAA-19"]</value> </param> - </block> - <block> - <key>variable</key> <param> - <key>id</key> - <value>prefix</value> + <key>type</key> + <value>drop_down</value> </param> <param> - <key>_enabled</key> - <value>True</value> + <key>style</key> + <value>wx.RA_HORIZONTAL</value> </param> <param> - <key>value</key> - <value>"FCD_APT_REC-"</value> + <key>grid_pos</key> + <value>1,0,1,1</value> + </param> + <param> + <key>notebook</key> + <value></value> </param> <param> <key>_coordinate</key> - <value>(625, 653)</value> + <value>(58, 403)</value> </param> <param> <key>_rotation</key> @@ -247,108 +261,113 @@ </param> </block> <block> - <key>import</key> + <key>wxgui_fftsink2</key> <param> <key>id</key> - <value>import_0</value> + <value>fftsink</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>import</key> - <value>from datetime import datetime</value> + <key>type</key> + <value>complex</value> </param> <param> - <key>_coordinate</key> - <value>(508, 653)</value> + <key>title</key> + <value>FCD Spectrum</value> </param> <param> - <key>_rotation</key> - <value>0</value> + <key>samp_rate</key> + <value>samp_rate</value> </param> - </block> - <block> - <key>blocks_wavfile_sink</key> <param> - <key>id</key> - <value>wavfile_sink</value> + <key>baseband_freq</key> + <value>sat_freq</value> </param> <param> - <key>_enabled</key> - <value>True</value> + <key>y_per_div</key> + <value>10</value> </param> <param> - <key>file</key> - <value>wav_file</value> + <key>y_divs</key> + <value>10</value> </param> <param> - <key>nchan</key> - <value>1</value> + <key>ref_level</key> + <value>0.0</value> </param> <param> - <key>samp_rate</key> - <value>11025</value> + <key>ref_scale</key> + <value>1.0</value> </param> <param> - <key>bits_per_sample</key> - <value>16</value> + <key>fft_size</key> + <value>512</value> </param> <param> - <key>_coordinate</key> - <value>(805, 530)</value> + <key>fft_rate</key> + <value>15</value> </param> <param> - <key>_rotation</key> + <key>peak_hold</key> + <value>False</value> + </param> + <param> + <key>average</key> + <value>False</value> + </param> + <param> + <key>avg_alpha</key> <value>0</value> </param> - </block> - <block> - <key>variable_chooser</key> <param> - <key>id</key> - <value>sat_freq</value> + <key>win</key> + <value>None</value> </param> <param> - <key>_enabled</key> - <value>True</value> + <key>win_size</key> + <value></value> </param> <param> - <key>label</key> - <value>Satellite</value> + <key>grid_pos</key> + <value>0,0,1,2</value> </param> <param> - <key>value</key> - <value>137500000</value> + <key>notebook</key> + <value></value> </param> <param> - <key>choices</key> - <value>[137500000,137620000,137912500,137100000]</value> + <key>freqvar</key> + <value>None</value> </param> <param> - <key>labels</key> - <value>["NOAA-15","NOAA-17","NOAA-18","NOAA-19"]</value> + <key>_coordinate</key> + <value>(375, 11)</value> </param> <param> - <key>type</key> - <value>drop_down</value> + <key>_rotation</key> + <value>0</value> </param> + </block> + <block> + <key>variable</key> <param> - <key>style</key> - <value>wx.RA_HORIZONTAL</value> + <key>id</key> + <value>samp_rate</value> </param> <param> - <key>grid_pos</key> - <value>1,0,1,1</value> + <key>_enabled</key> + <value>True</value> </param> <param> - <key>notebook</key> - <value></value> + <key>value</key> + <value>96000</value> </param> <param> <key>_coordinate</key> - <value>(18, 479)</value> + <value>(190, 11)</value> </param> <param> <key>_rotation</key> @@ -371,7 +390,7 @@ </param> <param> <key>_coordinate</key> - <value>(299, 10)</value> + <value>(282, 11)</value> </param> <param> <key>_rotation</key> @@ -379,50 +398,57 @@ </param> </block> <block> - <key>variable_chooser</key> + <key>blocks_wavfile_sink</key> <param> <key>id</key> - <value>fcd_lna_gain</value> + <value>wavfile_sink</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>label</key> - <value>LNA gain [dB]</value> + <key>file</key> + <value>wav_file</value> </param> <param> - <key>value</key> - <value>20.0</value> + <key>nchan</key> + <value>1</value> </param> <param> - <key>choices</key> - <value>[30.0, 25.0, 20.0, 17.5, 15.0, 12.5, 10.0, 7.5, 5.0, 2.5, 0.0, -2.5, -5.0]</value> + <key>samp_rate</key> + <value>11025</value> </param> <param> - <key>labels</key> - <value>[]</value> + <key>bits_per_sample</key> + <value>16</value> </param> <param> - <key>type</key> - <value>drop_down</value> + <key>_coordinate</key> + <value>(845, 431)</value> </param> <param> - <key>style</key> - <value>wx.RA_HORIZONTAL</value> + <key>_rotation</key> + <value>0</value> </param> + </block> + <block> + <key>import</key> <param> - <key>grid_pos</key> - <value>2,0,1,1</value> + <key>id</key> + <value>import_0</value> </param> <param> - <key>notebook</key> - <value></value> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>import</key> + <value>from datetime import datetime</value> </param> <param> <key>_coordinate</key> - <value>(207, 481)</value> + <value>(552, 523)</value> </param> <param> <key>_rotation</key> @@ -430,42 +456,45 @@ </param> </block> <block> - <key>variable_static_text</key> + <key>variable</key> <param> <key>id</key> - <value>rec_info</value> + <value>prefix</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>label</key> - <value>Recording to</value> + <key>value</key> + <value>"FCD_APT_REC-"</value> </param> <param> - <key>value</key> - <value>wav_file</value> + <key>_coordinate</key> + <value>(669, 523)</value> </param> <param> - <key>converver</key> - <value>str_converter</value> + <key>_rotation</key> + <value>0</value> </param> + </block> + <block> + <key>variable</key> <param> - <key>formatter</key> - <value>None</value> + <key>id</key> + <value>wav_file</value> </param> <param> - <key>grid_pos</key> - <value>1,1,1,1</value> + <key>_enabled</key> + <value>True</value> </param> <param> - <key>notebook</key> - <value></value> + <key>value</key> + <value>prefix + datetime.now().strftime("%Y.%m.%d.%H.%M.%S") + ".wav"</value> </param> <param> <key>_coordinate</key> - <value>(641, 14)</value> + <value>(806, 522)</value> </param> <param> <key>_rotation</key> @@ -520,7 +549,7 @@ </param> <param> <key>_coordinate</key> - <value>(334, 307)</value> + <value>(374, 231)</value> </param> <param> <key>_rotation</key> @@ -528,50 +557,34 @@ </param> </block> <block> - <key>fcd_source_c</key> + <key>audio_sink</key> <param> <key>id</key> - <value>fcd_source_c_0</value> + <value>audio_sink</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>device_name</key> - <value>hw:1</value> - </param> - <param> - <key>freq</key> - <value>sat_freq</value> - </param> - <param> - <key>lna</key> - <value>fcd_lna_gain</value> - </param> - <param> - <key>ppm</key> - <value>-120</value> - </param> - <param> - <key>dci</key> - <value>0.0</value> + <key>samp_rate</key> + <value>48000</value> </param> <param> - <key>dcq</key> - <value>0.0</value> + <key>device_name</key> + <value></value> </param> <param> - <key>iq_phase</key> - <value>0.0</value> + <key>ok_to_block</key> + <value>True</value> </param> <param> - <key>iq_gain</key> - <value>1.0</value> + <key>num_inputs</key> + <value>1</value> </param> <param> <key>_coordinate</key> - <value>(25, 299)</value> + <value>(834, 279)</value> </param> <param> <key>_rotation</key> @@ -579,10 +592,10 @@ </param> </block> <block> - <key>wxgui_fftsink2</key> + <key>rational_resampler_xxx</key> <param> <key>id</key> - <value>fftsink</value> + <value>rational_resampler_xxx_0</value> </param> <param> <key>_enabled</key> @@ -590,75 +603,74 @@ </param> <param> <key>type</key> - <value>complex</value> - </param> - <param> - <key>title</key> - <value>FCD Spectrum</value> + <value>fff</value> </param> <param> - <key>samp_rate</key> - <value>samp_rate</value> + <key>interp</key> + <value>11025</value> </param> <param> - <key>baseband_freq</key> - <value>sat_freq</value> + <key>decim</key> + <value>48000</value> </param> <param> - <key>y_per_div</key> - <value>10</value> + <key>taps</key> + <value>[]</value> </param> <param> - <key>y_divs</key> - <value>10</value> + <key>fbw</key> + <value>0</value> </param> <param> - <key>ref_level</key> - <value>0.0</value> + <key>_coordinate</key> + <value>(591, 423)</value> </param> <param> - <key>ref_scale</key> - <value>1.0</value> + <key>_rotation</key> + <value>0</value> </param> + </block> + <block> + <key>analog_fm_demod_cf</key> <param> - <key>fft_size</key> - <value>512</value> + <key>id</key> + <value>analog_fm_demod_cf_0</value> </param> <param> - <key>fft_rate</key> - <value>15</value> + <key>_enabled</key> + <value>True</value> </param> <param> - <key>peak_hold</key> - <value>False</value> + <key>chan_rate</key> + <value>samp_rate</value> </param> <param> - <key>average</key> - <value>False</value> + <key>audio_decim</key> + <value>2</value> </param> <param> - <key>avg_alpha</key> - <value>0</value> + <key>deviation</key> + <value>max_dev</value> </param> <param> - <key>win</key> - <value>None</value> + <key>audio_pass</key> + <value>5000</value> </param> <param> - <key>win_size</key> - <value></value> + <key>audio_stop</key> + <value>7000</value> </param> <param> - <key>grid_pos</key> - <value>0,0,1,2</value> + <key>gain</key> + <value>1.0</value> </param> <param> - <key>notebook</key> - <value></value> + <key>tau</key> + <value>75e-6</value> </param> <param> <key>_coordinate</key> - <value>(335, 103)</value> + <value>(605, 231)</value> </param> <param> <key>_rotation</key> @@ -666,38 +678,38 @@ </param> </block> <connection> - <source_block_id>low_pass_filter</source_block_id> - <sink_block_id>blks2_fm_demod_cf</sink_block_id> + <source_block_id>rational_resampler_xxx_0</source_block_id> + <sink_block_id>wavfile_sink</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>blks2_fm_demod_cf</source_block_id> - <sink_block_id>audio_sink</sink_block_id> + <source_block_id>fcd_source_c_0</source_block_id> + <sink_block_id>fftsink</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>blks2_rational_resampler_xxx_0</source_block_id> - <sink_block_id>wavfile_sink</sink_block_id> + <source_block_id>fcd_source_c_0</source_block_id> + <sink_block_id>low_pass_filter</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>blks2_fm_demod_cf</source_block_id> - <sink_block_id>blks2_rational_resampler_xxx_0</sink_block_id> + <source_block_id>low_pass_filter</source_block_id> + <sink_block_id>analog_fm_demod_cf_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>fcd_source_c_0</source_block_id> - <sink_block_id>low_pass_filter</sink_block_id> + <source_block_id>analog_fm_demod_cf_0</source_block_id> + <sink_block_id>audio_sink</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>fcd_source_c_0</source_block_id> - <sink_block_id>fftsink</sink_block_id> + <source_block_id>analog_fm_demod_cf_0</source_block_id> + <sink_block_id>rational_resampler_xxx_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> diff --git a/gr-fcd/examples/grc/fcd_nfm_rx.grc b/gr-fcd/examples/grc/fcd_nfm_rx.grc index 96d6f55e2e..afe343a834 100644 --- a/gr-fcd/examples/grc/fcd_nfm_rx.grc +++ b/gr-fcd/examples/grc/fcd_nfm_rx.grc @@ -1,6 +1,6 @@ <?xml version='1.0' encoding='ASCII'?> <flow_graph> - <timestamp>Tue Nov 6 12:24:50 2012</timestamp> + <timestamp>Mon Mar 18 10:11:39 2013</timestamp> <block> <key>options</key> <param> @@ -379,37 +379,6 @@ </param> </block> <block> - <key>blocks_multiply_const_vxx</key> - <param> - <key>id</key> - <value>blocks_multiply_const_vxx_1</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>type</key> - <value>float</value> - </param> - <param> - <key>const</key> - <value>af_gain</value> - </param> - <param> - <key>vlen</key> - <value>1</value> - </param> - <param> - <key>_coordinate</key> - <value>(674, 507)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> <key>audio_sink</key> <param> <key>id</key> @@ -880,41 +849,6 @@ </param> </block> <block> - <key>blks2_nbfm_rx</key> - <param> - <key>id</key> - <value>nbfm_normal</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>audio_rate</key> - <value>48000</value> - </param> - <param> - <key>quad_rate</key> - <value>96000</value> - </param> - <param> - <key>tau</key> - <value>75e-6</value> - </param> - <param> - <key>max_dev</key> - <value>5e3</value> - </param> - <param> - <key>_coordinate</key> - <value>(441, 483)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> <key>low_pass_filter</key> <param> <key>id</key> @@ -962,7 +896,7 @@ </param> <param> <key>_coordinate</key> - <value>(742, 258)</value> + <value>(742, 266)</value> </param> <param> <key>_rotation</key> @@ -996,6 +930,72 @@ <value>0</value> </param> </block> + <block> + <key>blocks_multiply_const_vxx</key> + <param> + <key>id</key> + <value>blocks_multiply_const_vxx_1</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>type</key> + <value>float</value> + </param> + <param> + <key>const</key> + <value>af_gain</value> + </param> + <param> + <key>vlen</key> + <value>1</value> + </param> + <param> + <key>_coordinate</key> + <value>(674, 507)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>analog_nbfm_rx</key> + <param> + <key>id</key> + <value>analog_nbfm_rx_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>audio_rate</key> + <value>48000</value> + </param> + <param> + <key>quad_rate</key> + <value>96000</value> + </param> + <param> + <key>tau</key> + <value>75e-6</value> + </param> + <param> + <key>max_dev</key> + <value>5e3</value> + </param> + <param> + <key>_coordinate</key> + <value>(440, 483)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> <connection> <source_block_id>blocks_multiply_const_vxx_1</source_block_id> <sink_block_id>audio_sink</sink_block_id> @@ -1009,12 +1009,6 @@ <sink_key>0</sink_key> </connection> <connection> - <source_block_id>nbfm_normal</source_block_id> - <sink_block_id>blocks_multiply_const_vxx_1</sink_block_id> - <source_key>0</source_key> - <sink_key>0</sink_key> - </connection> - <connection> <source_block_id>fcd_source_c_1</source_block_id> <sink_block_id>freq_xlating_fir_filter_xxx_0</sink_block_id> <source_key>0</source_key> @@ -1033,14 +1027,20 @@ <sink_key>0</sink_key> </connection> <connection> + <source_block_id>low_pass_filter</source_block_id> + <sink_block_id>analog_simple_squelch_cc_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> <source_block_id>analog_simple_squelch_cc_0</source_block_id> - <sink_block_id>nbfm_normal</sink_block_id> + <sink_block_id>analog_nbfm_rx_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>low_pass_filter</source_block_id> - <sink_block_id>analog_simple_squelch_cc_0</sink_block_id> + <source_block_id>analog_nbfm_rx_0</source_block_id> + <sink_block_id>blocks_multiply_const_vxx_1</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> diff --git a/gr-fec/python/qa_ecc_ccsds_27.py b/gr-fec/python/qa_ecc_ccsds_27.py index 52615abe23..895e683345 100755 --- a/gr-fec/python/qa_ecc_ccsds_27.py +++ b/gr-fec/python/qa_ecc_ccsds_27.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2004,2007,2010 Free Software Foundation, Inc. +# Copyright 2004,2007,2010,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -35,13 +35,13 @@ class test_ccsds_27 (gr_unittest.TestCase): def xtest_ccsds_27 (self): src_data = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) expected = (0, 0, 0, 0, 1, 2, 3, 4, 5, 6) - src = gr.vector_source_b(src_data) + src = blocks.vector_source_b(src_data) enc = fec.encode_ccsds_27_bb() b2f = blocks.char_to_float() add = blocks.add_const_ff(-0.5) mul = blocks.multiply_const_ff(2.0) dec = fec.decode_ccsds_27_fb() - dst = gr.vector_sink_b() + dst = blocks.vector_sink_b() self.tb.connect(src, enc, b2f, add, mul, dec, dst) self.tb.run() dst_data = dst.data() diff --git a/gr-fft/python/qa_fft.py b/gr-fft/python/qa_fft.py index 0a66a2c1fc..c90eea69c5 100755 --- a/gr-fft/python/qa_fft.py +++ b/gr-fft/python/qa_fft.py @@ -87,11 +87,11 @@ class test_fft(gr_unittest.TestCase): (689.48553466796875-918.2142333984375j), (1646.539306640625-1694.1956787109375j)) - src = gr.vector_source_c(src_data) + src = blocks.vector_source_c(src_data) s2v = blocks.stream_to_vector(gr.sizeof_gr_complex, fft_size) op = fft.fft_vcc(fft_size, True, [], False) v2s = blocks.vector_to_stream(gr.sizeof_gr_complex, fft_size) - dst = gr.vector_sink_c() + dst = blocks.vector_sink_c() tb.connect(src, s2v, op, v2s, dst) tb.run() result_data = dst.data() @@ -141,11 +141,11 @@ class test_fft(gr_unittest.TestCase): expected_result = tuple([complex(primes[2*i], primes[2*i+1]) for i in range(fft_size)]) - src = gr.vector_source_c(src_data) + src = blocks.vector_source_c(src_data) s2v = blocks.stream_to_vector(gr.sizeof_gr_complex, fft_size) op = fft.fft_vcc(fft_size, False, [], False) v2s = blocks.vector_to_stream(gr.sizeof_gr_complex, fft_size) - dst = gr.vector_sink_c() + dst = blocks.vector_sink_c() tb.connect(src, s2v, op, v2s, dst) tb.run() result_data = dst.data() @@ -199,11 +199,11 @@ class test_fft(gr_unittest.TestCase): nthreads = 2 - src = gr.vector_source_c(src_data) + src = blocks.vector_source_c(src_data) s2v = blocks.stream_to_vector(gr.sizeof_gr_complex, fft_size) op = fft.fft_vcc(fft_size, False, [], False, nthreads) v2s = blocks.vector_to_stream(gr.sizeof_gr_complex, fft_size) - dst = gr.vector_sink_c() + dst = blocks.vector_sink_c() tb.connect(src, s2v, op, v2s, dst) tb.run() result_data = dst.data() diff --git a/gr-fft/python/qa_goertzel.py b/gr-fft/python/qa_goertzel.py index 27f9d370e1..33f1413b6d 100755 --- a/gr-fft/python/qa_goertzel.py +++ b/gr-fft/python/qa_goertzel.py @@ -23,6 +23,7 @@ from gnuradio import gr, gr_unittest from math import pi, cos import fft_swig as fft +import blocks_swig as blocks class test_goertzel(gr_unittest.TestCase): @@ -36,9 +37,9 @@ class test_goertzel(gr_unittest.TestCase): return [cos(2*pi*x*freq/rate) for x in range(rate)] def transform(self, src_data, rate, freq): - src = gr.vector_source_f(src_data, False) + src = blocks.vector_source_f(src_data, False) dft = fft.goertzel_fc(rate, rate, freq) - dst = gr.vector_sink_c() + dst = blocks.vector_sink_c() self.tb.connect(src, dft, dst) self.tb.run() return dst.data() diff --git a/gr-filter/examples/benchmark_filters.py b/gr-filter/examples/benchmark_filters.py index 5fd012bcc4..ffc869db73 100755 --- a/gr-filter/examples/benchmark_filters.py +++ b/gr-filter/examples/benchmark_filters.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2005,2006,2007 Free Software Foundation, Inc. +# Copyright 2005-2007,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -24,6 +24,7 @@ import time import random from optparse import OptionParser from gnuradio import gr +from gnuradio import blocks from gnuradio.eng_option import eng_option def make_random_complex_tuple(L): @@ -38,10 +39,10 @@ def benchmark(name, creator, dec, ntaps, total_test_size, block_size): tb = gr.top_block() taps = make_random_complex_tuple(ntaps) - src = gr.vector_source_c(make_random_complex_tuple(block_size), True) - head = gr.head(gr.sizeof_gr_complex, int(total_test_size)) + src = blocks.vector_source_c(make_random_complex_tuple(block_size), True) + head = blocks.head(gr.sizeof_gr_complex, int(total_test_size)) op = creator(dec, taps) - dst = gr.null_sink(gr.sizeof_gr_complex) + dst = blocks.null_sink(gr.sizeof_gr_complex) tb.connect(src, head, op, dst) start = time.time() tb.run() @@ -66,9 +67,9 @@ def main(): block_size = options.block_size dec = options.decimation - benchmark("filter.fir_filter_ccc", gr.fir_filter_ccc, + benchmark("filter.fir_filter_ccc", filter.fir_filter_ccc, dec, ntaps, total_input_size, block_size) - benchmark("filter.fft_filter_ccc", gr.fft_filter_ccc, + benchmark("filter.fft_filter_ccc", filter.fft_filter_ccc, dec, ntaps, total_input_size, block_size) if __name__ == '__main__': diff --git a/gr-filter/examples/channelize.py b/gr-filter/examples/channelize.py index 77d3c21968..e70817e873 100755 --- a/gr-filter/examples/channelize.py +++ b/gr-filter/examples/channelize.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2009,2012 Free Software Foundation, Inc. +# Copyright 2009,2012,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -76,13 +76,13 @@ class pfb_top_block(gr.top_block): self.signals.append(analog.sig_source_c(self._ifs, analog.GR_SIN_WAVE, f, 1)) self.connect(self.signals[i], (self.add,i)) - self.head = gr.head(gr.sizeof_gr_complex, self._N) + self.head = blocks.head(gr.sizeof_gr_complex, self._N) # Construct the channelizer filter self.pfb = filter.pfb.channelizer_ccf(self._M, self._taps, 1) # Construct a vector sink for the input signal to the channelizer - self.snk_i = gr.vector_sink_c() + self.snk_i = blocks.vector_sink_c() # Connect the blocks self.connect(self.add, self.head, self.pfb) @@ -94,7 +94,7 @@ class pfb_top_block(gr.top_block): # Create a vector sink for each of M output channels of the filter and connect it self.snks = list() for i in xrange(self._M): - self.snks.append(gr.vector_sink_c()) + self.snks.append(blocks.vector_sink_c()) self.connect((self.pfb, i), self.snks[i]) diff --git a/gr-filter/examples/chirp_channelize.py b/gr-filter/examples/chirp_channelize.py index d4d2f8e238..aedd5c4892 100755 --- a/gr-filter/examples/chirp_channelize.py +++ b/gr-filter/examples/chirp_channelize.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2009,2012 Free Software Foundation, Inc. +# Copyright 2009,2012,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -70,20 +70,20 @@ class pfb_top_block(gr.top_block): else: amp = 100 data = scipy.arange(0, amp, amp/float(self._N)) - self.vco_input = gr.vector_source_f(data, False) + self.vco_input = blocks.vector_source_f(data, False) # Build a VCO controlled by either the sinusoid or single chirp tone # Then convert this to a complex signal self.vco = blocks.vco_f(self._fs, 225, 1) self.f2c = blocks.float_to_complex() - self.head = gr.head(gr.sizeof_gr_complex, self._N) + self.head = blocks.head(gr.sizeof_gr_complex, self._N) # Construct the channelizer filter self.pfb = filter.pfb.channelizer_ccf(self._M, self._taps) # Construct a vector sink for the input signal to the channelizer - self.snk_i = gr.vector_sink_c() + self.snk_i = blocks.vector_sink_c() # Connect the blocks self.connect(self.vco_input, self.vco, self.f2c) @@ -93,7 +93,7 @@ class pfb_top_block(gr.top_block): # Create a vector sink for each of M output channels of the filter and connect it self.snks = list() for i in xrange(self._M): - self.snks.append(gr.vector_sink_c()) + self.snks.append(blocks.vector_sink_c()) self.connect((self.pfb, i), self.snks[i]) diff --git a/gr-filter/examples/decimate.py b/gr-filter/examples/decimate.py index 56ed7edff1..675073a431 100755 --- a/gr-filter/examples/decimate.py +++ b/gr-filter/examples/decimate.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2009,2012 Free Software Foundation, Inc. +# Copyright 2009,2012,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -75,7 +75,7 @@ class pfb_top_block(gr.top_block): self.signals.append(analog.sig_source_c(self._fs, analog.GR_SIN_WAVE, freqs[i], 1)) self.connect(self.signals[i], (self.add,i)) - self.head = gr.head(gr.sizeof_gr_complex, self._N) + self.head = blocks.head(gr.sizeof_gr_complex, self._N) # Construct a PFB decimator filter self.pfb = filter.pfb.decimator_ccf(self._decim, self._taps, 0) @@ -83,14 +83,14 @@ class pfb_top_block(gr.top_block): # Construct a standard FIR decimating filter self.dec = filter.fir_filter_ccf(self._decim, self._taps) - self.snk_i = gr.vector_sink_c() + self.snk_i = blocks.vector_sink_c() # Connect the blocks self.connect(self.add, self.head, self.pfb) self.connect(self.add, self.snk_i) # Create the sink for the decimated siganl - self.snk = gr.vector_sink_c() + self.snk = blocks.vector_sink_c() self.connect(self.pfb, self.snk) diff --git a/gr-filter/examples/fft_filter_ccc.py b/gr-filter/examples/fft_filter_ccc.py index 676e7d9f16..aaa3c6e6eb 100755 --- a/gr-filter/examples/fft_filter_ccc.py +++ b/gr-filter/examples/fft_filter_ccc.py @@ -2,6 +2,7 @@ from gnuradio import gr, filter from gnuradio import analog +from gnuradio import blocks from gnuradio import eng_notation from gnuradio.eng_option import eng_option from optparse import OptionParser @@ -35,12 +36,12 @@ class example_fft_filter_ccc(gr.top_block): print "Num. Taps: ", len(taps) self.src = analog.noise_source_c(analog.GR_GAUSSIAN, 1) - self.head = gr.head(gr.sizeof_gr_complex, self._nsamps) + self.head = blocks.head(gr.sizeof_gr_complex, self._nsamps) self.filt0 = filter.fft_filter_ccc(self._decim, taps) - self.vsnk_src = gr.vector_sink_c() - self.vsnk_out = gr.vector_sink_c() + self.vsnk_src = blocks.vector_sink_c() + self.vsnk_out = blocks.vector_sink_c() self.connect(self.src, self.head, self.vsnk_src) self.connect(self.head, self.filt0, self.vsnk_out) diff --git a/gr-filter/examples/fir_filter_ccc.py b/gr-filter/examples/fir_filter_ccc.py index 6e68fc0af7..0991124b8d 100755 --- a/gr-filter/examples/fir_filter_ccc.py +++ b/gr-filter/examples/fir_filter_ccc.py @@ -2,6 +2,7 @@ from gnuradio import gr, filter from gnuradio import analog +from gnuradio import blocks from gnuradio import eng_notation from gnuradio.eng_option import eng_option from optparse import OptionParser @@ -32,12 +33,12 @@ class example_fir_filter_ccc(gr.top_block): print "Num. Taps: ", len(taps) self.src = analog.noise_source_c(analog.GR_GAUSSIAN, 1) - self.head = gr.head(gr.sizeof_gr_complex, self._nsamps) + self.head = blocks.head(gr.sizeof_gr_complex, self._nsamps) self.filt0 = filter.fir_filter_ccc(self._decim, taps) - self.vsnk_src = gr.vector_sink_c() - self.vsnk_out = gr.vector_sink_c() + self.vsnk_src = blocks.vector_sink_c() + self.vsnk_out = blocks.vector_sink_c() self.connect(self.src, self.head, self.vsnk_src) self.connect(self.head, self.filt0, self.vsnk_out) diff --git a/gr-filter/examples/fir_filter_fff.py b/gr-filter/examples/fir_filter_fff.py index a1a8ab9573..549b543498 100755 --- a/gr-filter/examples/fir_filter_fff.py +++ b/gr-filter/examples/fir_filter_fff.py @@ -2,6 +2,7 @@ from gnuradio import gr, filter from gnuradio import analog +from gnuradio import blocks from gnuradio import eng_notation from gnuradio.eng_option import eng_option from optparse import OptionParser @@ -32,12 +33,12 @@ class example_fir_filter_fff(gr.top_block): print "Num. Taps: ", len(taps) self.src = analog.noise_source_f(analog.GR_GAUSSIAN, 1) - self.head = gr.head(gr.sizeof_float, self._nsamps) + self.head = blocks.head(gr.sizeof_float, self._nsamps) self.filt0 = filter.fir_filter_fff(self._decim, taps) - self.vsnk_src = gr.vector_sink_f() - self.vsnk_out = gr.vector_sink_f() + self.vsnk_src = blocks.vector_sink_f() + self.vsnk_out = blocks.vector_sink_f() self.connect(self.src, self.head, self.vsnk_src) self.connect(self.head, self.filt0, self.vsnk_out) diff --git a/gr-filter/examples/interpolate.py b/gr-filter/examples/interpolate.py index e0d4cc14b1..40bab7b1f1 100755 --- a/gr-filter/examples/interpolate.py +++ b/gr-filter/examples/interpolate.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2009,2012 Free Software Foundation, Inc. +# Copyright 2009,2012,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -89,14 +89,14 @@ class pfb_top_block(gr.top_block): self.signal2 = analog.sig_source_c(self._fs, analog.GR_SIN_WAVE, freq2, 0.5) self.signal = blocks.add_cc() - self.head = gr.head(gr.sizeof_gr_complex, self._N) + self.head = blocks.head(gr.sizeof_gr_complex, self._N) # Construct the PFB interpolator filter self.pfb = filter.pfb.interpolator_ccf(self._interp, self._taps) # Construct the PFB arbitrary resampler filter self.pfb_ar = filter.pfb.arb_resampler_ccf(self._ainterp, self._taps2, flt_size) - self.snk_i = gr.vector_sink_c() + self.snk_i = blocks.vector_sink_c() #self.pfb_ar.pfb.print_taps() #self.pfb.pfb.print_taps() @@ -109,8 +109,8 @@ class pfb_top_block(gr.top_block): self.connect(self.signal, self.snk_i) # Create the sink for the interpolated signals - self.snk1 = gr.vector_sink_c() - self.snk2 = gr.vector_sink_c() + self.snk1 = blocks.vector_sink_c() + self.snk2 = blocks.vector_sink_c() self.connect(self.pfb, self.snk1) self.connect(self.pfb_ar, self.snk2) diff --git a/gr-filter/examples/reconstruction.py b/gr-filter/examples/reconstruction.py index 75c224e79c..85704bda2b 100755 --- a/gr-filter/examples/reconstruction.py +++ b/gr-filter/examples/reconstruction.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2010,2012 Free Software Foundation, Inc. +# Copyright 2010,2012,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -22,6 +22,7 @@ from gnuradio import gr, digital from gnuradio import filter +from gnuradio import blocks try: from gnuradio import channels @@ -68,7 +69,7 @@ def main(): data = scipy.random.randint(0, 256, N) rrc_taps = filter.firdes.root_raised_cosine(1, 2, 1, 0.35, 41) - src = gr.vector_source_b(data.astype(scipy.uint8).tolist(), False) + src = blocks.vector_source_b(data.astype(scipy.uint8).tolist(), False) mod = digital.bpsk_mod(samples_per_symbol=2) chan = filter.channel_model(npwr) rrc = filter.fft_filter_ccc(1, rrc_taps) @@ -79,8 +80,8 @@ def main(): # Put the pieces back together again syn_taps = [nchans*t for t in proto_taps] synthesizer = filter.pfb_synthesizer_ccf(nchans, syn_taps, True) - src_snk = gr.vector_sink_c() - snk = gr.vector_sink_c() + src_snk = blocks.vector_sink_c() + snk = blocks.vector_sink_c() # Remap the location of the channels # Can be done in synth or channelizer (watch out for rotattions in @@ -96,7 +97,7 @@ def main(): for i in xrange(nchans): tb.connect((channelizer,i), (synthesizer, i)) - vsnk.append(gr.vector_sink_c()) + vsnk.append(blocks.vector_sink_c()) tb.connect((channelizer,i), vsnk[i]) tb.connect(synthesizer, snk) diff --git a/gr-filter/examples/resampler.py b/gr-filter/examples/resampler.py index c2a24116fc..e329f062d0 100755 --- a/gr-filter/examples/resampler.py +++ b/gr-filter/examples/resampler.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2009,2012 Free Software Foundation, Inc. +# Copyright 2009,2012,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -22,6 +22,7 @@ from gnuradio import gr from gnuradio import filter +from gnuradio import blocks import sys try: @@ -54,7 +55,7 @@ class mytb(gr.top_block): self.src = analog.sig_source_c(fs_in, analog.GR_SIN_WAVE, fc, 1) #self.src = analog.noise_source_c(analog.GR_GAUSSIAN, 1) - self.head = gr.head(gr.sizeof_gr_complex, N) + self.head = blocks.head(gr.sizeof_gr_complex, N) # A resampler with our taps self.resamp_0 = filter.pfb.arb_resampler_ccf(rerate, taps, @@ -67,9 +68,9 @@ class mytb(gr.top_block): # specify the out-of-band rejection (default=80). self.resamp_1 = filter.pfb.arb_resampler_ccf(rerate) - self.snk_in = gr.vector_sink_c() - self.snk_0 = gr.vector_sink_c() - self.snk_1 = gr.vector_sink_c() + self.snk_in = blocks.vector_sink_c() + self.snk_0 = blocks.vector_sink_c() + self.snk_1 = blocks.vector_sink_c() self.connect(self.src, self.head, self.snk_in) self.connect(self.head, self.resamp_0, self.snk_0) diff --git a/gr-filter/examples/synth_filter.py b/gr-filter/examples/synth_filter.py index 505141614a..5382127b35 100755 --- a/gr-filter/examples/synth_filter.py +++ b/gr-filter/examples/synth_filter.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2010,2012 Free Software Foundation, Inc. +# Copyright 2010,2012,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -22,6 +22,7 @@ from gnuradio import gr from gnuradio import filter +from gnuradio import blocks import sys try: @@ -60,8 +61,8 @@ def main(): len(taps)/nchans) filtbank = filter.pfb_synthesizer_ccf(nchans, taps) - head = gr.head(gr.sizeof_gr_complex, N) - snk = gr.vector_sink_c() + head = blocks.head(gr.sizeof_gr_complex, N) + snk = blocks.vector_sink_c() tb = gr.top_block() tb.connect(filtbank, head, snk) diff --git a/gr-filter/examples/synth_to_chan.py b/gr-filter/examples/synth_to_chan.py index 5ea4d8ee47..9e682021b7 100755 --- a/gr-filter/examples/synth_to_chan.py +++ b/gr-filter/examples/synth_to_chan.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2010,2012 Free Software Foundation, Inc. +# Copyright 2010,2012,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -68,10 +68,10 @@ def main(): channelizer = filter.pfb.channelizer_ccf(nchans, chtaps) noise_level = 0.01 - head = gr.head(gr.sizeof_gr_complex, N) + head = blocks.head(gr.sizeof_gr_complex, N) noise = analog.noise_source_c(analog.GR_GAUSSIAN, noise_level) addnoise = blocks.add_cc() - snk_synth = gr.vector_sink_c() + snk_synth = blocks.vector_sink_c() tb = gr.top_block() @@ -85,7 +85,7 @@ def main(): tb.connect(si, fmtx[i], (filtbank, i)) for i in xrange(nchans): - snk.append(gr.vector_sink_c()) + snk.append(blocks.vector_sink_c()) tb.connect((channelizer, i), snk[i]) tb.run() diff --git a/gr-filter/grc/CMakeLists.txt b/gr-filter/grc/CMakeLists.txt index 1ca23d560e..3a2af83da9 100644 --- a/gr-filter/grc/CMakeLists.txt +++ b/gr-filter/grc/CMakeLists.txt @@ -33,6 +33,7 @@ install(FILES filter_pfb_decimator.xml filter_pfb_interpolator.xml filter_pfb_synthesizer.xml + filter_rational_resampler_xxx.xml filter_rational_resampler_base_xxx.xml filter_single_pole_iir_filter_xx.xml filter_low_pass_filter.xml diff --git a/gr-filter/grc/filter_block_tree.xml b/gr-filter/grc/filter_block_tree.xml index 9b72dcf605..a9dfd56549 100644 --- a/gr-filter/grc/filter_block_tree.xml +++ b/gr-filter/grc/filter_block_tree.xml @@ -51,6 +51,7 @@ <block>pfb_decimator_ccf</block> <block>pfb_interpolator_ccf</block> <block>pfb_synthesizer_ccf</block> + <block>rational_resampler_xxx</block> <block>rational_resampler_base_xxx</block> <block>single_pole_iir_filter_xx</block> </cat> diff --git a/gr-filter/grc/filter_rational_resampler_xxx.xml b/gr-filter/grc/filter_rational_resampler_xxx.xml new file mode 100644 index 0000000000..6287c5a437 --- /dev/null +++ b/gr-filter/grc/filter_rational_resampler_xxx.xml @@ -0,0 +1,92 @@ +<?xml version="1.0"?> +<!-- +################################################### +##Rational Resampler Base +################################################### + --> +<block> + <name>Rational Resampler</name> + <key>rational_resampler_xxx</key> + <import>from gnuradio import filter</import> + <import>from gnuradio.filter import firdes</import> + <make>filter.rational_resampler_$(type)( + interpolation=$interp, + decimation=$decim, +#if $taps() + taps=$taps, +#else + taps=None, +#end if +#if $fbw() != 0 + fractional_bw=$fbw, +#else + fractional_bw=None, +#end if +)</make> + <callback>set_taps($taps)</callback> + <param> + <name>Type</name> + <key>type</key> + <type>enum</type> + <option> + <name>Complex->Complex (Complex Taps)</name> + <key>ccc</key> + <opt>input:complex</opt> + <opt>output:complex</opt> + <opt>taps:complex_vector</opt> + </option> + <option> + <name>Complex->Complex (Real Taps)</name> + <key>ccf</key> + <opt>input:complex</opt> + <opt>output:complex</opt> + <opt>taps:real_vector</opt> + </option> + <option> + <name>Float->Complex (Complex Taps)</name> + <key>fcc</key> + <opt>input:float</opt> + <opt>output:complex</opt> + <opt>taps:complex_vector</opt> + </option> + <option> + <name>Float->Float (Real Taps)</name> + <key>fff</key> + <opt>input:float</opt> + <opt>output:float</opt> + <opt>taps:real_vector</opt> + </option> + </param> + <param> + <name>Interpolation</name> + <key>interp</key> + <value>1</value> + <type>int</type> + </param> + <param> + <name>Decimation</name> + <key>decim</key> + <value>1</value> + <type>int</type> + </param> + <param> + <name>Taps</name> + <key>taps</key> + <value>None</value> + <type>$type.taps</type> + </param> + <param> + <name>Fractional BW</name> + <key>fbw</key> + <value>0</value> + <type>real</type> + </param> + <sink> + <name>in</name> + <type>$type.input</type> + </sink> + <source> + <name>out</name> + <type>$type.output</type> + </source> +</block> diff --git a/gr-filter/include/filter/freq_xlating_fir_filter_XXX.h.t b/gr-filter/include/filter/freq_xlating_fir_filter_XXX.h.t index 88e15f823d..7aa4a55cc8 100644 --- a/gr-filter/include/filter/freq_xlating_fir_filter_XXX.h.t +++ b/gr-filter/include/filter/freq_xlating_fir_filter_XXX.h.t @@ -30,7 +30,6 @@ #include <filter/api.h> #include <gr_sync_decimator.h> -#include <gr_rotator.h> namespace gr { namespace filter { diff --git a/gr-filter/include/filter/pfb_channelizer_ccf.h b/gr-filter/include/filter/pfb_channelizer_ccf.h index 07e0c96387..825532a699 100644 --- a/gr-filter/include/filter/pfb_channelizer_ccf.h +++ b/gr-filter/include/filter/pfb_channelizer_ccf.h @@ -52,14 +52,15 @@ namespace gr { * filters in the filterbank are filled out with 0's to make sure each * filter has the same number of taps. * - * Each filter operates using the gr_fir filter classs of GNU Radio, - * which takes the input stream at <EM>i</EM> and performs the inner - * product calculation to <EM>i+(n-1)</EM> where <EM>n</EM> is the - * number of filter taps. To efficiently handle this in the GNU Radio - * structure, each filter input must come from its own input - * stream. So the channelizer must be provided with <EM>M</EM> streams - * where the input stream has been deinterleaved. This is most easily - * done using the gr::blocks::stream_to_streams block. + * Each filter operates using the gr::blocks::fir_filter_XXX + * classs of GNU Radio, which takes the input stream at <EM>i</EM> + * and performs the inner product calculation to <EM>i+(n-1)</EM> + * where <EM>n</EM> is the number of filter taps. To efficiently + * handle this in the GNU Radio structure, each filter input must + * come from its own input stream. So the channelizer must be + * provided with <EM>M</EM> streams where the input stream has + * been deinterleaved. This is most easily done using the + * gr::blocks::stream_to_streams block. * * The output is then produced as a vector, where index <EM>i</EM> * in the vector is the next sample from the <EM>i</EM>th diff --git a/gr-filter/include/filter/polyphase_filterbank.h b/gr-filter/include/filter/polyphase_filterbank.h index cd4ee4db99..500d1c9b8f 100644 --- a/gr-filter/include/filter/polyphase_filterbank.h +++ b/gr-filter/include/filter/polyphase_filterbank.h @@ -55,15 +55,15 @@ namespace gr { * are filled out with 0's to make sure each filter has the same * number of taps. * - * Each filter operates using the gr_fir filter classs of GNU - * Radio, which takes the input stream at <EM>i</EM> and - * performs the inner product calculation to <EM>i+(n-1)</EM> - * where <EM>n</EM> is the number of filter taps. To efficiently - * handle this in the GNU Radio structure, each filter input - * must come from its own input stream. So the channelizer must - * be provided with <EM>M</EM> streams where the input stream - * has been deinterleaved. This is most easily done using the - * gr::blocks::stream_to_streams block. + * Each filter operates using the gr::filter::fir_filter_XXX + * classs of GNU Radio, which takes the input stream at + * <EM>i</EM> and performs the inner product calculation to + * <EM>i+(n-1)</EM> where <EM>n</EM> is the number of filter + * taps. To efficiently handle this in the GNU Radio structure, + * each filter input must come from its own input stream. So the + * channelizer must be provided with <EM>M</EM> streams where + * the input stream has been deinterleaved. This is most easily + * done using the gr::blocks::stream_to_streams block. * * The output is then produced as a vector, where index * <EM>i</EM> in the vector is the next sample from the diff --git a/gr-filter/lib/CMakeLists.txt b/gr-filter/lib/CMakeLists.txt index 5fa06701d7..3164e7ad54 100644 --- a/gr-filter/lib/CMakeLists.txt +++ b/gr-filter/lib/CMakeLists.txt @@ -94,6 +94,7 @@ include_directories( ${CMAKE_CURRENT_BINARY_DIR} ${GR_FILTER_INCLUDE_DIRS} ${GR_FFT_INCLUDE_DIRS} + ${GR_BLOCKS_INCLUDE_DIRS} ${GNURADIO_CORE_INCLUDE_DIRS} ${VOLK_INCLUDE_DIRS} ${GRUEL_INCLUDE_DIRS} @@ -163,6 +164,7 @@ endif(MSVC) list(APPEND filter_libs gnuradio-core gnuradio-fft + gnuradio-blocks volk ${Boost_LIBRARIES} ) diff --git a/gr-filter/lib/freq_xlating_fir_filter_XXX_impl.h.t b/gr-filter/lib/freq_xlating_fir_filter_XXX_impl.h.t index 0cf976d582..00222cac00 100644 --- a/gr-filter/lib/freq_xlating_fir_filter_XXX_impl.h.t +++ b/gr-filter/lib/freq_xlating_fir_filter_XXX_impl.h.t @@ -31,6 +31,7 @@ #include <filter/api.h> #include <filter/fir_filter.h> #include <filter/@BASE_NAME@.h> +#include <blocks/rotator.h> namespace gr { namespace filter { @@ -40,7 +41,7 @@ namespace gr { protected: std::vector<@TAP_TYPE@> d_proto_taps; kernel::@CFIR_TYPE@ *d_composite_fir; - gr_rotator d_r; + blocks::rotator d_r; double d_center_freq; double d_sampling_freq; bool d_updated; diff --git a/gr-filter/python/qa_adaptive_fir_filter.py b/gr-filter/python/qa_adaptive_fir_filter.py index cadce52044..e8233f76ae 100755 --- a/gr-filter/python/qa_adaptive_fir_filter.py +++ b/gr-filter/python/qa_adaptive_fir_filter.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2008,2010,2012 Free Software Foundation, Inc. +# Copyright 2008,2010,2012,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -21,6 +21,7 @@ from gnuradio import gr, gr_unittest import filter_swig as filter +import blocks_swig as blocks class test_adaptive_filter(gr_unittest.TestCase): @@ -61,9 +62,9 @@ class test_adaptive_filter(gr_unittest.TestCase): (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j)) - src = gr.vector_source_c(src_data) + src = blocks.vector_source_c(src_data) op = filter.adaptive_fir_ccf("test", 1, 20*[0.5, 0.5]) - dst = gr.vector_sink_c() + dst = blocks.vector_sink_c() self.tb.connect(src, op, dst) self.tb.run() result_data = dst.data() @@ -80,9 +81,9 @@ class test_adaptive_filter(gr_unittest.TestCase): (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j)) - src = gr.vector_source_c(src_data) + src = blocks.vector_source_c(src_data) op = filter.adaptive_fir_ccf("test", 4, 20*[0.5, 0.5]) - dst = gr.vector_sink_c() + dst = blocks.vector_sink_c() self.tb.connect(src, op, dst) self.tb.run() result_data = dst.data() @@ -124,9 +125,9 @@ class test_adaptive_filter(gr_unittest.TestCase): (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j)) - src = gr.vector_source_c(src_data) + src = blocks.vector_source_c(src_data) op = filter.adaptive_fir_ccc("test", 1, 20*[0.5+1j, 0.5+1j]) - dst = gr.vector_sink_c() + dst = blocks.vector_sink_c() self.tb.connect(src, op, dst) self.tb.run() result_data = dst.data() @@ -146,9 +147,9 @@ class test_adaptive_filter(gr_unittest.TestCase): (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j)) - src = gr.vector_source_c(src_data) + src = blocks.vector_source_c(src_data) op = filter.adaptive_fir_ccc("test", 4, 20*[0.5+1j, 0.5+1j]) - dst = gr.vector_sink_c() + dst = blocks.vector_sink_c() self.tb.connect(src, op, dst) self.tb.run() result_data = dst.data() diff --git a/gr-filter/python/qa_dc_blocker.py b/gr-filter/python/qa_dc_blocker.py index b9df06b453..29a05fb550 100755 --- a/gr-filter/python/qa_dc_blocker.py +++ b/gr-filter/python/qa_dc_blocker.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2011,2012 Free Software Foundation, Inc. +# Copyright 2011-2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -22,6 +22,7 @@ from gnuradio import gr, gr_unittest import filter_swig as filter +import blocks_swig as blocks class test_dc_blocker(gr_unittest.TestCase): @@ -38,9 +39,9 @@ class test_dc_blocker(gr_unittest.TestCase): (0.979156494140625+0j), (-0.02081298828125+0j), (-0.02072429656982422+0j)) - src = gr.vector_source_c(src_data) + src = blocks.vector_source_c(src_data) op = filter.dc_blocker_cc(32, True) - dst = gr.vector_sink_c() + dst = blocks.vector_sink_c() self.tb.connect (src, op, dst) self.tb.run() @@ -56,9 +57,9 @@ class test_dc_blocker(gr_unittest.TestCase): (0.96875+0j), (-0.0302734375+0j), (-0.029296875+0j)) - src = gr.vector_source_c(src_data) + src = blocks.vector_source_c(src_data) op = filter.dc_blocker_cc(32, False) - dst = gr.vector_sink_c() + dst = blocks.vector_sink_c() self.tb.connect (src, op, dst) self.tb.run() @@ -75,9 +76,9 @@ class test_dc_blocker(gr_unittest.TestCase): (0.979156494140625), (-0.02081298828125), (-0.02072429656982422)) - src = gr.vector_source_f(src_data) + src = blocks.vector_source_f(src_data) op = filter.dc_blocker_ff(32, True) - dst = gr.vector_sink_f() + dst = blocks.vector_sink_f() self.tb.connect (src, op, dst) self.tb.run() @@ -93,9 +94,9 @@ class test_dc_blocker(gr_unittest.TestCase): (0.96875), (-0.0302734375), (-0.029296875)) - src = gr.vector_source_f(src_data) + src = blocks.vector_source_f(src_data) op = filter.dc_blocker_ff(32, False) - dst = gr.vector_sink_f() + dst = blocks.vector_sink_f() self.tb.connect (src, op, dst) self.tb.run() diff --git a/gr-filter/python/qa_fft_filter.py b/gr-filter/python/qa_fft_filter.py index cb5416373f..9e0008d7c6 100755 --- a/gr-filter/python/qa_fft_filter.py +++ b/gr-filter/python/qa_fft_filter.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2004,2005,2007,2010,2012 Free Software Foundation, Inc. +# Copyright 2004,2005,2007,2010,2012,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -22,6 +22,7 @@ from gnuradio import gr, gr_unittest import filter_swig as filter +import blocks_swig as blocks import sys import random @@ -44,10 +45,10 @@ def reference_filter_ccc(dec, taps, input): compute result using conventional fir filter """ tb = gr.top_block() - #src = gr.vector_source_c(((0,) * (len(taps) - 1)) + input) - src = gr.vector_source_c(input) + #src = blocks.vector_source_c(((0,) * (len(taps) - 1)) + input) + src = blocks.vector_source_c(input) op = filter.fir_filter_ccc(dec, taps) - dst = gr.vector_sink_c() + dst = blocks.vector_sink_c() tb.connect(src, op, dst) tb.run() return dst.data() @@ -57,10 +58,10 @@ def reference_filter_fff(dec, taps, input): compute result using conventional fir filter """ tb = gr.top_block() - #src = gr.vector_source_f(((0,) * (len(taps) - 1)) + input) - src = gr.vector_source_f(input) + #src = blocks.vector_source_f(((0,) * (len(taps) - 1)) + input) + src = blocks.vector_source_f(input) op = filter.fir_filter_fff(dec, taps) - dst = gr.vector_sink_f() + dst = blocks.vector_sink_f() tb.connect(src, op, dst) tb.run() return dst.data() @@ -96,9 +97,9 @@ class test_fft_filter(gr_unittest.TestCase): src_data = (0,1,2,3,4,5,6,7) taps = (1,) expected_result = tuple([complex(x) for x in (0,1,2,3,4,5,6,7)]) - src = gr.vector_source_c(src_data) + src = blocks.vector_source_c(src_data) op = filter.fft_filter_ccc(1, taps) - dst = gr.vector_sink_c() + dst = blocks.vector_sink_c() tb.connect(src, op, dst) tb.run() result_data = dst.data() @@ -114,9 +115,9 @@ class test_fft_filter(gr_unittest.TestCase): taps = (2,) nthreads = 2 expected_result = tuple([2 * complex(x) for x in (0,1,2,3,4,5,6,7)]) - src = gr.vector_source_c(src_data) + src = blocks.vector_source_c(src_data) op = filter.fft_filter_ccc(1, taps, nthreads) - dst = gr.vector_sink_c() + dst = blocks.vector_sink_c() tb.connect(src, op, dst) tb.run() result_data = dst.data() @@ -129,9 +130,9 @@ class test_fft_filter(gr_unittest.TestCase): src_data = (0,1,2,3,4,5,6,7) taps = (2,) expected_result = tuple([2 * complex(x) for x in (0,1,2,3,4,5,6,7)]) - src = gr.vector_source_c(src_data) + src = blocks.vector_source_c(src_data) op = filter.fft_filter_ccc(1, taps) - dst = gr.vector_sink_c() + dst = blocks.vector_sink_c() tb.connect(src, op, dst) tb.run() result_data = dst.data() @@ -150,9 +151,9 @@ class test_fft_filter(gr_unittest.TestCase): taps = make_random_complex_tuple(ntaps) expected_result = reference_filter_ccc(1, taps, src_data) - src = gr.vector_source_c(src_data) + src = blocks.vector_source_c(src_data) op = filter.fft_filter_ccc(1, taps) - dst = gr.vector_sink_c() + dst = blocks.vector_sink_c() tb = gr.top_block() tb.connect(src, op, dst) tb.run() @@ -171,9 +172,9 @@ class test_fft_filter(gr_unittest.TestCase): taps = make_random_complex_tuple(ntaps) expected_result = reference_filter_ccc(dec, taps, src_data) - src = gr.vector_source_c(src_data) + src = blocks.vector_source_c(src_data) op = filter.fft_filter_ccc(dec, taps) - dst = gr.vector_sink_c() + dst = blocks.vector_sink_c() tb = gr.top_block() tb.connect(src, op, dst) tb.run() @@ -195,9 +196,9 @@ class test_fft_filter(gr_unittest.TestCase): taps = make_random_complex_tuple(ntaps) expected_result = reference_filter_ccc(dec, taps, src_data) - src = gr.vector_source_c(src_data) + src = blocks.vector_source_c(src_data) op = filter.fft_filter_ccc(dec, taps, nthreads) - dst = gr.vector_sink_c() + dst = blocks.vector_sink_c() tb = gr.top_block() tb.connect(src, op, dst) tb.run() @@ -215,9 +216,9 @@ class test_fft_filter(gr_unittest.TestCase): src_data = (0,1,2,3,4,5,6,7) taps = (1,) expected_result = tuple([float(x) for x in (0,1,2,3,4,5,6,7)]) - src = gr.vector_source_f(src_data) + src = blocks.vector_source_f(src_data) op = filter.fft_filter_fff(1, taps) - dst = gr.vector_sink_f() + dst = blocks.vector_sink_f() tb.connect(src, op, dst) tb.run() result_data = dst.data() @@ -231,9 +232,9 @@ class test_fft_filter(gr_unittest.TestCase): src_data = (0,1,2,3,4,5,6,7) taps = (2,) expected_result = tuple([2 * float(x) for x in (0,1,2,3,4,5,6,7)]) - src = gr.vector_source_f(src_data) + src = blocks.vector_source_f(src_data) op = filter.fft_filter_fff(1, taps) - dst = gr.vector_sink_f() + dst = blocks.vector_sink_f() tb.connect(src, op, dst) tb.run() result_data = dst.data() @@ -248,9 +249,9 @@ class test_fft_filter(gr_unittest.TestCase): taps = (2,) nthreads = 2 expected_result = tuple([2 * float(x) for x in (0,1,2,3,4,5,6,7)]) - src = gr.vector_source_f(src_data) + src = blocks.vector_source_f(src_data) op = filter.fft_filter_fff(1, taps, nthreads) - dst = gr.vector_sink_f() + dst = blocks.vector_sink_f() tb.connect(src, op, dst) tb.run() result_data = dst.data() @@ -266,9 +267,9 @@ class test_fft_filter(gr_unittest.TestCase): taps = make_random_float_tuple(ntaps) expected_result = reference_filter_fff(1, taps, src_data) - src = gr.vector_source_f(src_data) + src = blocks.vector_source_f(src_data) op = filter.fft_filter_fff(1, taps) - dst = gr.vector_sink_f() + dst = blocks.vector_sink_f() tb = gr.top_block() tb.connect(src, op, dst) tb.run() @@ -296,9 +297,9 @@ class test_fft_filter(gr_unittest.TestCase): taps = make_random_float_tuple(ntaps) expected_result = reference_filter_fff(1, taps, src_data) - src = gr.vector_source_f(src_data) + src = blocks.vector_source_f(src_data) op = filter.fft_filter_fff(1, taps) - dst = gr.vector_sink_f() + dst = blocks.vector_sink_f() tb = gr.top_block() tb.connect(src, op, dst) tb.run() @@ -317,9 +318,9 @@ class test_fft_filter(gr_unittest.TestCase): taps = make_random_float_tuple(ntaps) expected_result = reference_filter_fff(dec, taps, src_data) - src = gr.vector_source_f(src_data) + src = blocks.vector_source_f(src_data) op = filter.fft_filter_fff(dec, taps) - dst = gr.vector_sink_f() + dst = blocks.vector_sink_f() tb = gr.top_block() tb.connect(src, op, dst) tb.run() @@ -340,9 +341,9 @@ class test_fft_filter(gr_unittest.TestCase): taps = make_random_float_tuple(ntaps) expected_result = reference_filter_fff(dec, taps, src_data) - src = gr.vector_source_f(src_data) + src = blocks.vector_source_f(src_data) op = filter.fft_filter_fff(dec, taps, nthreads) - dst = gr.vector_sink_f() + dst = blocks.vector_sink_f() tb = gr.top_block() tb.connect(src, op, dst) tb.run() diff --git a/gr-filter/python/qa_filter_delay_fc.py b/gr-filter/python/qa_filter_delay_fc.py index 420d6fb05f..9ec1d9d582 100755 --- a/gr-filter/python/qa_filter_delay_fc.py +++ b/gr-filter/python/qa_filter_delay_fc.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2004,2007,2010,2012 Free Software Foundation, Inc. +# Copyright 2004,2007,2010,2012,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -22,6 +22,7 @@ from gnuradio import gr, gr_unittest import filter_swig as filter +import blocks_swig as blocks import math def sin_source_f(samp_rate, freq, amp, N): @@ -114,8 +115,8 @@ class test_filter_delay_fc(gr_unittest.TestCase): ntaps = 51 N = int(ntaps + sampling_freq * 0.10) data = sin_source_f(sampling_freq, sampling_freq * 0.10, 1.0, N) - src1 = gr.vector_source_f(data) - dst2 = gr.vector_sink_c() + src1 = blocks.vector_source_f(data) + dst2 = blocks.vector_sink_c() # calculate taps taps = filter.firdes_hilbert(ntaps) @@ -205,8 +206,8 @@ class test_filter_delay_fc(gr_unittest.TestCase): ntaps = 51 N = int(ntaps + sampling_freq * 0.10) data = sin_source_f(sampling_freq, sampling_freq * 0.10, 1.0, N) - src1 = gr.vector_source_f(data) - dst2 = gr.vector_sink_c() + src1 = blocks.vector_source_f(data) + dst2 = blocks.vector_sink_c() # calculate taps taps = filter.firdes_hilbert(ntaps) @@ -298,13 +299,13 @@ class test_filter_delay_fc(gr_unittest.TestCase): data1 = sin_source_f(sampling_freq, sampling_freq * 0.10, 1.0, N) data2 = cos_source_f(sampling_freq, sampling_freq * 0.10, 1.0, N) - src1 = gr.vector_source_f(data1) - src2 = gr.vector_source_f(data2) + src1 = blocks.vector_source_f(data1) + src2 = blocks.vector_source_f(data2) taps = filter.firdes_hilbert(ntaps) hd = filter.filter_delay_fc(taps) - dst2 = gr.vector_sink_c() + dst2 = blocks.vector_sink_c() tb.connect(src1, (hd,0)) tb.connect(src2, (hd,1)) diff --git a/gr-filter/python/qa_fir_filter.py b/gr-filter/python/qa_fir_filter.py index 2a61498a26..64e60ab295 100755 --- a/gr-filter/python/qa_fir_filter.py +++ b/gr-filter/python/qa_fir_filter.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2008,2010,2012 Free Software Foundation, Inc. +# Copyright 2008,2010,2012,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -21,6 +21,7 @@ from gnuradio import gr, gr_unittest import filter_swig as filter +import blocks_swig as blocks class test_filter(gr_unittest.TestCase): @@ -55,9 +56,9 @@ class test_filter(gr_unittest.TestCase): 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0) - src = gr.vector_source_f(src_data) + src = blocks.vector_source_f(src_data) op = filter.fir_filter_fff(1, 20*[0.5, 0.5]) - dst = gr.vector_sink_f() + dst = blocks.vector_sink_f() self.tb.connect(src, op, dst) self.tb.run() result_data = dst.data() @@ -70,9 +71,9 @@ class test_filter(gr_unittest.TestCase): 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0) - src = gr.vector_source_f(src_data) + src = blocks.vector_source_f(src_data) op = filter.fir_filter_fff(4, 20*[0.5, 0.5]) - dst = gr.vector_sink_f() + dst = blocks.vector_sink_f() self.tb.connect(src, op, dst) self.tb.run() result_data = dst.data() @@ -109,9 +110,9 @@ class test_filter(gr_unittest.TestCase): (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j)) - src = gr.vector_source_c(src_data) + src = blocks.vector_source_c(src_data) op = filter.fir_filter_ccf(1, 20*[0.5, 0.5]) - dst = gr.vector_sink_c() + dst = blocks.vector_sink_c() self.tb.connect(src, op, dst) self.tb.run() result_data = dst.data() @@ -128,9 +129,9 @@ class test_filter(gr_unittest.TestCase): (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j)) - src = gr.vector_source_c(src_data) + src = blocks.vector_source_c(src_data) op = filter.fir_filter_ccf(4, 20*[0.5, 0.5]) - dst = gr.vector_sink_c() + dst = blocks.vector_sink_c() self.tb.connect(src, op, dst) self.tb.run() result_data = dst.data() @@ -172,9 +173,9 @@ class test_filter(gr_unittest.TestCase): (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j)) - src = gr.vector_source_c(src_data) + src = blocks.vector_source_c(src_data) op = filter.fir_filter_ccc(1, 20*[0.5+1j, 0.5+1j]) - dst = gr.vector_sink_c() + dst = blocks.vector_sink_c() self.tb.connect(src, op, dst) self.tb.run() result_data = dst.data() @@ -184,13 +185,13 @@ class test_filter(gr_unittest.TestCase): def test_fir_filter_ccc_002(self): src_data = 10*[1+1j, 2+2j, 3+3j, 4+4j] - # results derived from original gr.fir_filter_ccc + # results derived from original filter.fir_filter_ccc expected_data = ((7.537424837948042e-20+7.537424837948042e-20j), (9.131923434324563e-05+9.131923434324563e-05j), (0.0003317668742965907+0.0003317668742965907j), (0.0007230418268591166+0.0007230418268591166j), (0.0012087896466255188+0.0012087896466255188j), (0.0013292605290189385+0.0013292605290189385j), (0.001120875240303576+0.001120875240303576j), (0.000744672492146492+0.000744672492146492j), (0.000429437990533188+0.000429437990533188j), (2.283908543176949e-05+2.283908543176949e-05j), (-0.0002245186478830874-0.0002245186478830874j), (-0.0001157080550910905-0.0001157080550910905j), (0.00041409023106098175+0.00041409023106098175j), (0.0009017843985930085+0.0009017843985930085j), (0.0012520025484263897+0.0012520025484263897j), (0.0014116164529696107+0.0014116164529696107j), (0.001393353333696723+0.001393353333696723j), (0.000912194955162704+0.000912194955162704j), (0.00022649182938039303+0.00022649182938039303j), (-0.00031363096786662936-0.00031363096786662936j), (-0.0003966730728279799-0.0003966730728279799j), (-0.00023757052258588374-0.00023757052258588374j), (0.00021952332463115454+0.00021952332463115454j), (0.0009092430118471384+0.0009092430118471384j), (0.001662317430600524+0.001662317430600524j), (0.0019024648936465383+0.0019024648936465383j), (0.0015955769922584295+0.0015955769922584295j), (0.0009144138311967254+0.0009144138311967254j), (0.0001872836146503687+0.0001872836146503687j), (-0.000581968342885375-0.000581968342885375j), (-0.0009886166080832481-0.0009886166080832481j), (-0.0007480768254026771-0.0007480768254026771j), (0.00018211957649327815+0.00018211957649327815j), (0.0012042406015098095+0.0012042406015098095j), (0.0020200139842927456+0.0020200139842927456j), (0.0023816542234271765+0.0023816542234271765j), (0.002195809967815876+0.002195809967815876j), (0.0012113333214074373+0.0012113333214074373j), (-0.00014088614261709154-0.00014088614261709154j), (-0.0012574587017297745-0.0012574587017297745j)) taps = filter.firdes.low_pass(1, 1, 0.1, 0.01) - src = gr.vector_source_c(src_data) + src = blocks.vector_source_c(src_data) op = filter.fir_filter_ccc(1, taps) - dst = gr.vector_sink_c() + dst = blocks.vector_sink_c() self.tb.connect(src, op, dst) self.tb.run() result_data = dst.data() @@ -209,9 +210,9 @@ class test_filter(gr_unittest.TestCase): (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j)) - src = gr.vector_source_c(src_data) + src = blocks.vector_source_c(src_data) op = filter.fir_filter_ccc(4, 20*[0.5+1j, 0.5+1j]) - dst = gr.vector_sink_c() + dst = blocks.vector_sink_c() self.tb.connect(src, op, dst) self.tb.run() result_data = dst.data() @@ -252,9 +253,9 @@ class test_filter(gr_unittest.TestCase): (50+100j), (50+100j), (50+100j), (50+100j), (50+100j), (50+100j), (50+100j), (50+100j), (50+100j), (50+100j), (50+100j), (50+100j), (50+100j), (50+100j), (50+100j)) - src = gr.vector_source_s(src_data) + src = blocks.vector_source_s(src_data) op = filter.fir_filter_scc(1, 20*[0.5+1j, 0.5+1j]) - dst = gr.vector_sink_c() + dst = blocks.vector_sink_c() self.tb.connect(src, op, dst) self.tb.run() result_data = dst.data() @@ -271,9 +272,9 @@ class test_filter(gr_unittest.TestCase): (50+100j), (50+100j), (50+100j), (50+100j), (50+100j), (50+100j), (50+100j), (50+100j), (50+100j), (50+100j), (50+100j), (50+100j), (50+100j), (50+100j), (50+100j)) - src = gr.vector_source_s(src_data) + src = blocks.vector_source_s(src_data) op = filter.fir_filter_scc(4, 20*[0.5+1j, 0.5+1j]) - dst = gr.vector_sink_c() + dst = blocks.vector_sink_c() self.tb.connect(src, op, dst) self.tb.run() result_data = dst.data() @@ -291,9 +292,9 @@ class test_filter(gr_unittest.TestCase): 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50) - src = gr.vector_source_f(src_data) + src = blocks.vector_source_f(src_data) op = filter.fir_filter_fsf(1, 20*[0.5, 0.5]) - dst = gr.vector_sink_s() + dst = blocks.vector_sink_s() self.tb.connect(src, op, dst) self.tb.run() result_data = dst.data() @@ -305,9 +306,9 @@ class test_filter(gr_unittest.TestCase): expected_data = (0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50) - src = gr.vector_source_f(src_data) + src = blocks.vector_source_f(src_data) op = filter.fir_filter_fsf(4, 20*[0.5, 0.5]) - dst = gr.vector_sink_s() + dst = blocks.vector_sink_s() self.tb.connect(src, op, dst) self.tb.run() result_data = dst.data() diff --git a/gr-filter/python/qa_fractional_interpolator.py b/gr-filter/python/qa_fractional_interpolator.py index ab4cc4cf9a..177458a47a 100755 --- a/gr-filter/python/qa_fractional_interpolator.py +++ b/gr-filter/python/qa_fractional_interpolator.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2007,2010,2012 Free Software Foundation, Inc. +# Copyright 2007,2010,2012,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -22,6 +22,7 @@ from gnuradio import gr, gr_unittest import filter_swig as filter +import blocks_swig as blocks import math def sig_source_f(samp_rate, freq, amp, N): @@ -50,9 +51,9 @@ class test_fractional_resampler(gr_unittest.TestCase): freq = 10 data = sig_source_f(fs, freq, 1, N) - signal = gr.vector_source_f(data) + signal = blocks.vector_source_f(data) op = filter.fractional_interpolator_ff(0, rrate) - snk = gr.vector_sink_f() + snk = blocks.vector_sink_f() self.tb.connect(signal, op, snk) self.tb.run() @@ -76,9 +77,9 @@ class test_fractional_resampler(gr_unittest.TestCase): freq = 10 data = sig_source_c(fs, freq, 1, N) - signal = gr.vector_source_c(data) + signal = blocks.vector_source_c(data) op = filter.fractional_interpolator_cc(0.0, rrate) - snk = gr.vector_sink_c() + snk = blocks.vector_sink_c() self.tb.connect(signal, op, snk) self.tb.run() diff --git a/gr-filter/python/qa_freq_xlating_fir_filter.py b/gr-filter/python/qa_freq_xlating_fir_filter.py index ee38eb7dff..6fdff372af 100755 --- a/gr-filter/python/qa_freq_xlating_fir_filter.py +++ b/gr-filter/python/qa_freq_xlating_fir_filter.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2008,2010,2012 Free Software Foundation, Inc. +# Copyright 2008,2010,2012,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -21,6 +21,7 @@ from gnuradio import gr, gr_unittest import filter_swig as filter +import blocks_swig as blocks import cmath, math class test_freq_xlating_filter(gr_unittest.TestCase): @@ -102,9 +103,9 @@ class test_freq_xlating_filter(gr_unittest.TestCase): (-0.0016229727771133184+0.0028335191309452057j), (-0.0010890064295381308+0.0037298379465937614j), (-0.00012392725329846144+0.0027196139562875032j)) - src = gr.vector_source_c(self.src_data) + src = blocks.vector_source_c(self.src_data) op = filter.freq_xlating_fir_filter_ccf(1, self.taps, self.fc, self.fs) - dst = gr.vector_sink_c() + dst = blocks.vector_sink_c() self.tb.connect(src, op, dst) self.tb.run() result_data = dst.data() @@ -132,9 +133,9 @@ class test_freq_xlating_filter(gr_unittest.TestCase): (-0.002173811662942171+0.007211671676486731j), (0.0022051059640944004-0.00402153329923749j), (-0.0011226903880015016+0.0009080505697056651j)) - src = gr.vector_source_c(self.src_data) + src = blocks.vector_source_c(self.src_data) op = filter.freq_xlating_fir_filter_ccf(4, self.taps, self.fc, self.fs) - dst = gr.vector_sink_c() + dst = blocks.vector_sink_c() self.tb.connect(src, op, dst) self.tb.run() result_data = dst.data() @@ -162,9 +163,9 @@ class test_freq_xlating_filter(gr_unittest.TestCase): (0.000998671515845-0.00135387131013j), (0.00104933069088-0.00243046949618j), (0.000765930046327-0.0026717747096j)) - src = gr.vector_source_c(self.src_data) + src = blocks.vector_source_c(self.src_data) op = filter.freq_xlating_fir_filter_ccc(1, self.taps, self.fc, self.fs) - dst = gr.vector_sink_c() + dst = blocks.vector_sink_c() self.tb.connect(src, op, dst) self.tb.run() result_data = dst.data() @@ -192,9 +193,9 @@ class test_freq_xlating_filter(gr_unittest.TestCase): (-0.00180401885882+0.00427213776857j), (-0.00122803344857+0.00427243299782j), (0.000414476031438-0.000383919978049j)) - src = gr.vector_source_c(self.src_data) + src = blocks.vector_source_c(self.src_data) op = filter.freq_xlating_fir_filter_ccc(4, self.taps, self.fc, self.fs) - dst = gr.vector_sink_c() + dst = blocks.vector_sink_c() self.tb.connect(src, op, dst) self.tb.run() result_data = dst.data() @@ -222,9 +223,9 @@ class test_freq_xlating_filter(gr_unittest.TestCase): (0.000185727752978-0.000154630601173j), (-0.000141745767905-0.000120098840853j), (-3.9850056055e-07+0.000168364742422j)) - src = gr.vector_source_f(self.src_data) + src = blocks.vector_source_f(self.src_data) op = filter.freq_xlating_fir_filter_fcf(1, self.taps, self.fc, self.fs) - dst = gr.vector_sink_c() + dst = blocks.vector_sink_c() self.tb.connect(src, op, dst) self.tb.run() result_data = dst.data() @@ -252,9 +253,9 @@ class test_freq_xlating_filter(gr_unittest.TestCase): (-0.00010601492977-0.00015005269961j), (-0.000204817260965+0.000160534662427j), (0.000114742244477+0.000205190313864j)) - src = gr.vector_source_f(self.src_data) + src = blocks.vector_source_f(self.src_data) op = filter.freq_xlating_fir_filter_fcf(4, self.taps, self.fc, self.fs) - dst = gr.vector_sink_c() + dst = blocks.vector_sink_c() self.tb.connect(src, op, dst) self.tb.run() result_data = dst.data() @@ -282,9 +283,9 @@ class test_freq_xlating_filter(gr_unittest.TestCase): (-0.000193948610104+0.000113364716526j), (0.000134820176754+0.000142527525895j), (4.74465123261e-05-0.000175131688593j)) - src = gr.vector_source_f(self.src_data) + src = blocks.vector_source_f(self.src_data) op = filter.freq_xlating_fir_filter_fcc(1, self.taps, self.fc, self.fs) - dst = gr.vector_sink_c() + dst = blocks.vector_sink_c() self.tb.connect(src, op, dst) self.tb.run() result_data = dst.data() @@ -312,9 +313,9 @@ class test_freq_xlating_filter(gr_unittest.TestCase): (0.000215422536712+0.000116706112749j), (0.000224391726078-0.000156330308528j), (-5.96956087975e-05-0.000211163976928j)) - src = gr.vector_source_f(self.src_data) + src = blocks.vector_source_f(self.src_data) op = filter.freq_xlating_fir_filter_fcc(4, self.taps, self.fc, self.fs) - dst = gr.vector_sink_c() + dst = blocks.vector_sink_c() self.tb.connect(src, op, dst) self.tb.run() result_data = dst.data() @@ -342,9 +343,9 @@ class test_freq_xlating_filter(gr_unittest.TestCase): (0.128281414509+0.0677760615945j), (0.0748447552323+0.0619902014732j), (0.0512856245041+0.0775099247694j)) - src = gr.vector_source_s(self.src_data) + src = blocks.vector_source_s(self.src_data) op = filter.freq_xlating_fir_filter_scf(1, self.taps, self.fc, self.fs) - dst = gr.vector_sink_c() + dst = blocks.vector_sink_c() self.tb.connect(src, op, dst) self.tb.run() result_data = dst.data() @@ -372,9 +373,9 @@ class test_freq_xlating_filter(gr_unittest.TestCase): (-0.0770940706134-0.230615705252j), (-0.103762261569-0.0382265634835j), (0.11808334291+0.104863762856j)) - src = gr.vector_source_s(self.src_data) + src = blocks.vector_source_s(self.src_data) op = filter.freq_xlating_fir_filter_scf(4, self.taps, self.fc, self.fs) - dst = gr.vector_sink_c() + dst = blocks.vector_sink_c() self.tb.connect(src, op, dst) self.tb.run() result_data = dst.data() @@ -402,9 +403,9 @@ class test_freq_xlating_filter(gr_unittest.TestCase): (-0.0151527002454+0.036265052855j), (0.0199296213686+0.0452499426901j), (0.0122985243797+0.0143278446048j)) - src = gr.vector_source_s(self.src_data) + src = blocks.vector_source_s(self.src_data) op = filter.freq_xlating_fir_filter_scc(1, self.taps, self.fc, self.fs) - dst = gr.vector_sink_c() + dst = blocks.vector_sink_c() self.tb.connect(src, op, dst) self.tb.run() result_data = dst.data() @@ -432,9 +433,9 @@ class test_freq_xlating_filter(gr_unittest.TestCase): (-0.0108893103898-0.0875638127327j), (0.00204296782613-0.0721434056759j), (-0.00527479872108-0.00698097236454j)) - src = gr.vector_source_s(self.src_data) + src = blocks.vector_source_s(self.src_data) op = filter.freq_xlating_fir_filter_scc(4, self.taps, self.fc, self.fs) - dst = gr.vector_sink_c() + dst = blocks.vector_sink_c() self.tb.connect(src, op, dst) self.tb.run() result_data = dst.data() diff --git a/gr-filter/python/qa_hilbert.py b/gr-filter/python/qa_hilbert.py index c3522ed192..9af77e8314 100755 --- a/gr-filter/python/qa_hilbert.py +++ b/gr-filter/python/qa_hilbert.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2004,2007,2010,2012 Free Software Foundation, Inc. +# Copyright 2004,2007,2010,2012,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -22,6 +22,7 @@ from gnuradio import gr, gr_unittest import filter_swig as filter +import blocks_swig as blocks import math def sig_source_f(samp_rate, freq, amp, N): @@ -107,10 +108,10 @@ class test_hilbert(gr_unittest.TestCase): N = int(ntaps + sampling_freq * 0.10) data = sig_source_f(sampling_freq, sampling_freq * 0.10, 1.0, N) - src1 = gr.vector_source_f(data) + src1 = blocks.vector_source_f(data) hilb = filter.hilbert_fc(ntaps) - dst1 = gr.vector_sink_c() + dst1 = blocks.vector_sink_c() tb.connect(src1, hilb) tb.connect(hilb, dst1) tb.run() diff --git a/gr-filter/python/qa_iir_filter.py b/gr-filter/python/qa_iir_filter.py index 645c4b66e7..e341a74c03 100755 --- a/gr-filter/python/qa_iir_filter.py +++ b/gr-filter/python/qa_iir_filter.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2004,2007,2010 Free Software Foundation, Inc. +# Copyright 2004,2007,2010,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -22,6 +22,7 @@ from gnuradio import gr, gr_unittest import filter_swig as filter +import blocks_swig as blocks class test_iir_filter(gr_unittest.TestCase): @@ -36,9 +37,9 @@ class test_iir_filter(gr_unittest.TestCase): fftaps = () fbtaps = () expected_result = (0, 0, 0, 0, 0, 0, 0, 0) - src = gr.vector_source_f(src_data) + src = blocks.vector_source_f(src_data) op = filter.iir_filter_ffd(fftaps, fbtaps) - dst = gr.vector_sink_f() + dst = blocks.vector_sink_f() self.tb.connect(src, op) self.tb.connect(op, dst) self.tb.run() @@ -50,9 +51,9 @@ class test_iir_filter(gr_unittest.TestCase): fftaps = (2,) fbtaps = (0,) expected_result = (2, 4, 6, 8, 10, 12, 14, 16) - src = gr.vector_source_f(src_data) + src = blocks.vector_source_f(src_data) op = filter.iir_filter_ffd(fftaps, fbtaps) - dst = gr.vector_sink_f() + dst = blocks.vector_sink_f() self.tb.connect(src, op) self.tb.connect(op, dst) self.tb.run() @@ -64,9 +65,9 @@ class test_iir_filter(gr_unittest.TestCase): fftaps = (2, 11) fbtaps = (0, 0) expected_result = (2, 15, 28, 41, 54, 67, 80, 93) - src = gr.vector_source_f(src_data) + src = blocks.vector_source_f(src_data) op = filter.iir_filter_ffd(fftaps, fbtaps) - dst = gr.vector_sink_f() + dst = blocks.vector_sink_f() self.tb.connect(src, op) self.tb.connect(op, dst) self.tb.run() @@ -78,9 +79,9 @@ class test_iir_filter(gr_unittest.TestCase): fftaps = (2, 11) fbtaps = (0, -1) expected_result = (2, 13, 15, 26, 28, 39, 41, 52) - src = gr.vector_source_f(src_data) + src = blocks.vector_source_f(src_data) op = filter.iir_filter_ffd(fftaps, fbtaps) - dst = gr.vector_sink_f() + dst = blocks.vector_sink_f() self.tb.connect(src, op) self.tb.connect(op, dst) self.tb.run() @@ -92,9 +93,9 @@ class test_iir_filter(gr_unittest.TestCase): fftaps = (2, 11, 0) fbtaps = (0, -1, 3) expected_result = (2, 13, 21, 59, 58, 186, 68, 583) - src = gr.vector_source_f(src_data) + src = blocks.vector_source_f(src_data) op = filter.iir_filter_ffd(fftaps, fbtaps) - dst = gr.vector_sink_f() + dst = blocks.vector_sink_f() self.tb.connect(src, op) self.tb.connect(op, dst) self.tb.run() @@ -106,12 +107,12 @@ class test_iir_filter(gr_unittest.TestCase): expected_result = (2, 13, 21, 59, 58, 186, 68, 583) fftaps = (2, 1) fbtaps = (0, -1) - src = gr.vector_source_f(src_data) + src = blocks.vector_source_f(src_data) op = filter.iir_filter_ffd(fftaps, fbtaps) fftaps = (2, 11, 0) fbtaps = (0, -1, 3) op.set_taps(fftaps, fbtaps) - dst = gr.vector_sink_f() + dst = blocks.vector_sink_f() self.tb.connect(src, op) self.tb.connect(op, dst) self.tb.run() @@ -123,12 +124,12 @@ class test_iir_filter(gr_unittest.TestCase): expected_result = (2,2,5,5,8,8,11,11) fftaps = (2, 1) fbtaps = (0, -1) - src = gr.vector_source_f(src_data) + src = blocks.vector_source_f(src_data) op = filter.iir_filter_ffd(fftaps, fbtaps) fftaps = (2,0,1) fbtaps = (0, -1) op.set_taps(fftaps, fbtaps) - dst = gr.vector_sink_f() + dst = blocks.vector_sink_f() self.tb.connect(src, op) self.tb.connect(op, dst) self.tb.run() @@ -140,12 +141,12 @@ class test_iir_filter(gr_unittest.TestCase): expected_result = (2,4,4,10,18,14,26,56) fftaps = (2,) fbtaps = (0, 1) - src = gr.vector_source_f(src_data) + src = blocks.vector_source_f(src_data) op = filter.iir_filter_ffd(fftaps, fbtaps) fftaps_data = (1) fbtaps = (0,0, -1,3) op.set_taps(fftaps, fbtaps) - dst = gr.vector_sink_f() + dst = blocks.vector_sink_f() self.tb.connect(src, op) self.tb.connect(op, dst) self.tb.run() diff --git a/gr-filter/python/qa_interp_fir_filter.py b/gr-filter/python/qa_interp_fir_filter.py index 839330539b..243ac7fac6 100755 --- a/gr-filter/python/qa_interp_fir_filter.py +++ b/gr-filter/python/qa_interp_fir_filter.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2004,2007,2010,2012 Free Software Foundation, Inc. +# Copyright 2004,2007,2010,2012,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -22,6 +22,7 @@ from gnuradio import gr, gr_unittest import filter_swig as filter +import blocks_swig as blocks import math class test_interp_fir_filter(gr_unittest.TestCase): @@ -45,9 +46,9 @@ class test_interp_fir_filter(gr_unittest.TestCase): 1300,13017,130170) expected_result = tuple([float(x) for x in xr]) - src = gr.vector_source_f(src_data) + src = blocks.vector_source_f(src_data) op = filter.interp_fir_filter_fff(interpolation, taps) - dst = gr.vector_sink_f() + dst = blocks.vector_sink_f() self.tb.connect(src, op) self.tb.connect(op, dst) self.tb.run() diff --git a/gr-filter/python/qa_pfb_arb_resampler.py b/gr-filter/python/qa_pfb_arb_resampler.py index 98272013ef..504fc815ce 100755 --- a/gr-filter/python/qa_pfb_arb_resampler.py +++ b/gr-filter/python/qa_pfb_arb_resampler.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2012 Free Software Foundation, Inc. +# Copyright 2012,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -22,6 +22,7 @@ from gnuradio import gr, gr_unittest import filter_swig as filter +import blocks_swig as blocks import math def sig_source_c(samp_rate, freq, amp, N): @@ -55,9 +56,9 @@ class test_pfb_arb_resampler(gr_unittest.TestCase): freq = 100 data = sig_source_f(fs, freq, 1, N) - signal = gr.vector_source_f(data) + signal = blocks.vector_source_f(data) pfb = filter.pfb_arb_resampler_fff(rrate, taps) - snk = gr.vector_sink_f() + snk = blocks.vector_sink_f() self.tb.connect(signal, pfb, snk) self.tb.run() @@ -84,9 +85,9 @@ class test_pfb_arb_resampler(gr_unittest.TestCase): freq = 100 data = sig_source_c(fs, freq, 1, N) - signal = gr.vector_source_c(data) + signal = blocks.vector_source_c(data) pfb = filter.pfb_arb_resampler_ccf(rrate, taps) - snk = gr.vector_sink_c() + snk = blocks.vector_sink_c() self.tb.connect(signal, pfb, snk) self.tb.run() diff --git a/gr-filter/python/qa_pfb_channelizer.py b/gr-filter/python/qa_pfb_channelizer.py index 519afa0458..472aa5a73c 100755 --- a/gr-filter/python/qa_pfb_channelizer.py +++ b/gr-filter/python/qa_pfb_channelizer.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2012 Free Software Foundation, Inc. +# Copyright 2012,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -55,7 +55,7 @@ class test_pfb_channelizer(gr_unittest.TestCase): for i in xrange(len(freqs)): f = freqs[i] + (M/2-M+i+1)*fs data = sig_source_c(ifs, f, 1, N) - signals.append(gr.vector_source_c(data)) + signals.append(blocks.vector_source_c(data)) self.tb.connect(signals[i], (add,i)) s2ss = blocks.stream_to_streams(gr.sizeof_gr_complex, M) @@ -65,7 +65,7 @@ class test_pfb_channelizer(gr_unittest.TestCase): snks = list() for i in xrange(M): - snks.append(gr.vector_sink_c()) + snks.append(blocks.vector_sink_c()) self.tb.connect((s2ss,i), (pfb,i)) self.tb.connect((pfb, i), snks[i]) diff --git a/gr-filter/python/qa_pfb_decimator.py b/gr-filter/python/qa_pfb_decimator.py index d20b2fa856..783be05486 100755 --- a/gr-filter/python/qa_pfb_decimator.py +++ b/gr-filter/python/qa_pfb_decimator.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2012 Free Software Foundation, Inc. +# Copyright 2012,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -56,13 +56,13 @@ class test_pfb_decimator(gr_unittest.TestCase): for i in xrange(len(freqs)): f = freqs[i] + (M/2-M+i+1)*fs data = sig_source_c(ifs, f, 1, N) - signals.append(gr.vector_source_c(data)) + signals.append(blocks.vector_source_c(data)) self.tb.connect(signals[i], (add,i)) - head = gr.head(gr.sizeof_gr_complex, N) + head = blocks.head(gr.sizeof_gr_complex, N) s2ss = blocks.stream_to_streams(gr.sizeof_gr_complex, M) pfb = filter.pfb_decimator_ccf(M, taps, channel) - snk = gr.vector_sink_c() + snk = blocks.vector_sink_c() self.tb.connect(add, head, s2ss) for i in xrange(M): @@ -102,12 +102,12 @@ class test_pfb_decimator(gr_unittest.TestCase): for i in xrange(len(freqs)): f = freqs[i] + (M/2-M+i+1)*fs data = sig_source_c(ifs, f, 1, N) - signals.append(gr.vector_source_c(data)) + signals.append(blocks.vector_source_c(data)) self.tb.connect(signals[i], (add,i)) s2ss = blocks.stream_to_streams(gr.sizeof_gr_complex, M) pfb = filter.pfb_decimator_ccf(M, taps, channel) - snk = gr.vector_sink_c() + snk = blocks.vector_sink_c() self.tb.connect(add, s2ss) for i in xrange(M): diff --git a/gr-filter/python/qa_pfb_interpolator.py b/gr-filter/python/qa_pfb_interpolator.py index ffaeee3f68..6788dbf203 100755 --- a/gr-filter/python/qa_pfb_interpolator.py +++ b/gr-filter/python/qa_pfb_interpolator.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2012 Free Software Foundation, Inc. +# Copyright 2012,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -22,6 +22,7 @@ from gnuradio import gr, gr_unittest import filter_swig as filter +import blocks_swig as blocks import math def sig_source_c(samp_rate, freq, amp, N): @@ -50,9 +51,9 @@ class test_pfb_interpolator(gr_unittest.TestCase): freq = 100 data = sig_source_c(fs, freq, 1, N) - signal = gr.vector_source_c(data) + signal = blocks.vector_source_c(data) pfb = filter.pfb_interpolator_ccf(M, taps) - snk = gr.vector_sink_c() + snk = blocks.vector_sink_c() self.tb.connect(signal, pfb) self.tb.connect(pfb, snk) diff --git a/gr-filter/python/qa_pfb_synthesizer.py b/gr-filter/python/qa_pfb_synthesizer.py index 2da02b58d3..aa3c697b93 100755 --- a/gr-filter/python/qa_pfb_synthesizer.py +++ b/gr-filter/python/qa_pfb_synthesizer.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2012 Free Software Foundation, Inc. +# Copyright 2012,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -22,6 +22,7 @@ from gnuradio import gr, gr_unittest import filter_swig as filter +import blocks_swig as blocks import math def sig_source_c(samp_rate, freq, amp, N): @@ -52,10 +53,10 @@ class test_pfb_synthesizer(gr_unittest.TestCase): freqs = [0, 100, 200, -200, -100] for i in xrange(len(freqs)): data = sig_source_c(fs, freqs[i], 1, N) - signals.append(gr.vector_source_c(data)) + signals.append(blocks.vector_source_c(data)) pfb = filter.pfb_synthesizer_ccf(M, taps) - snk = gr.vector_sink_c() + snk = blocks.vector_sink_c() for i in xrange(M): self.tb.connect(signals[i], (pfb,i)) diff --git a/gr-filter/python/qa_rational_resampler.py b/gr-filter/python/qa_rational_resampler.py index eb86ef5425..76930ba052 100755 --- a/gr-filter/python/qa_rational_resampler.py +++ b/gr-filter/python/qa_rational_resampler.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2005,2006,2007,2010 Free Software Foundation, Inc. +# Copyright 2005-2007,2010,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -22,6 +22,7 @@ from gnuradio import gr, gr_unittest import filter_swig as filter +import blocks_swig as blocks import math import random import sys @@ -37,9 +38,9 @@ def random_floats(n): def reference_dec_filter(src_data, decim, taps): tb = gr.top_block() - src = gr.vector_source_f(src_data) + src = blocks.vector_source_f(src_data) op = filter.fir_filter_fff(decim, taps) - dst = gr.vector_sink_f() + dst = blocks.vector_sink_f() tb.connect(src, op, dst) tb.run() result_data = dst.data() @@ -48,9 +49,9 @@ def reference_dec_filter(src_data, decim, taps): def reference_interp_filter(src_data, interp, taps): tb = gr.top_block() - src = gr.vector_source_f(src_data) + src = blocks.vector_source_f(src_data) op = filter.interp_fir_filter_fff(interp, taps) - dst = gr.vector_sink_f() + dst = blocks.vector_sink_f() tb.connect(src, op, dst) tb.run() result_data = dst.data() @@ -59,10 +60,10 @@ def reference_interp_filter(src_data, interp, taps): def reference_interp_dec_filter(src_data, interp, decim, taps): tb = gr.top_block() - src = gr.vector_source_f(src_data) + src = blocks.vector_source_f(src_data) up = filter.interp_fir_filter_fff(interp, (1,)) dn = filter.fir_filter_fff(decim, taps) - dst = gr.vector_sink_f() + dst = blocks.vector_sink_f() tb.connect(src, up, dn, dst) tb.run() result_data = dst.data() @@ -86,9 +87,9 @@ class test_rational_resampler (gr_unittest.TestCase): expected_result = tuple([float(x) for x in xr]) tb = gr.top_block() - src = gr.vector_source_f(src_data) + src = blocks.vector_source_f(src_data) op = filter.rational_resampler_base_fff(1, 1, taps) - dst = gr.vector_sink_f() + dst = blocks.vector_sink_f() tb.connect(src, op) tb.connect(op, dst) tb.run() @@ -109,9 +110,9 @@ class test_rational_resampler (gr_unittest.TestCase): expected_result = tuple([float(x) for x in xr]) tb = gr.top_block() - src = gr.vector_source_f(src_data) + src = blocks.vector_source_f(src_data) op = filter.rational_resampler_base_fff(interpolation, 1, taps) - dst = gr.vector_sink_f() + dst = blocks.vector_sink_f() tb.connect(src, op) tb.connect(op, dst) tb.run() @@ -126,9 +127,9 @@ class test_rational_resampler (gr_unittest.TestCase): expected_result = reference_interp_filter(src_data, interpolation, taps) tb = gr.top_block() - src = gr.vector_source_f(src_data) + src = blocks.vector_source_f(src_data) op = filter.rational_resampler_base_fff(interpolation, 1, taps) - dst = gr.vector_sink_f() + dst = blocks.vector_sink_f() tb.connect(src, op) tb.connect(op, dst) tb.run() @@ -146,9 +147,9 @@ class test_rational_resampler (gr_unittest.TestCase): expected_result = reference_dec_filter(src_data, decimation, taps) tb = gr.top_block() - src = gr.vector_source_f(src_data) + src = blocks.vector_source_f(src_data) op = filter.rational_resampler_base_fff(1, decimation, taps) - dst = gr.vector_sink_f() + dst = blocks.vector_sink_f() tb.connect(src, op) tb.connect(op, dst) tb.run() @@ -176,9 +177,9 @@ class test_rational_resampler (gr_unittest.TestCase): expected_result = reference_dec_filter(src_data, decim, taps) tb = gr.top_block() - src = gr.vector_source_f(src_data) + src = blocks.vector_source_f(src_data) op = filter.rational_resampler_base_fff(1, decim, taps) - dst = gr.vector_sink_f() + dst = blocks.vector_sink_f() tb.connect(src, op, dst) tb.run() tb = None @@ -210,9 +211,9 @@ class test_rational_resampler (gr_unittest.TestCase): expected_result = reference_interp_filter(src_data, interp, taps) tb = gr.top_block() - src = gr.vector_source_f(src_data) + src = blocks.vector_source_f(src_data) op = filter.rational_resampler_base_fff(interp, 1, taps) - dst = gr.vector_sink_f() + dst = blocks.vector_sink_f() tb.connect(src, op, dst) tb.run() tb = None @@ -238,9 +239,9 @@ class test_rational_resampler (gr_unittest.TestCase): expected_result = reference_interp_dec_filter(src_data, interp, decimation, taps) tb = gr.top_block() - src = gr.vector_source_f(src_data) + src = blocks.vector_source_f(src_data) op = filter.rational_resampler_base_fff(interp, decimation, taps) - dst = gr.vector_sink_f() + dst = blocks.vector_sink_f() tb.connect(src, op) tb.connect(op, dst) tb.run() diff --git a/gr-filter/python/qa_single_pole_iir.py b/gr-filter/python/qa_single_pole_iir.py index d28ab643fd..bc2d54c959 100755 --- a/gr-filter/python/qa_single_pole_iir.py +++ b/gr-filter/python/qa_single_pole_iir.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2005,2007,2010 Free Software Foundation, Inc. +# Copyright 2005,2007,2010,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -35,9 +35,9 @@ class test_single_pole_iir_filter(gr_unittest.TestCase): def test_ff_001(self): src_data = (0, 1000, 2000, 3000, 4000, 5000) expected_result = src_data - src = gr.vector_source_f(src_data) + src = blocks.vector_source_f(src_data) op = filter.single_pole_iir_filter_ff(1.0) - dst = gr.vector_sink_f() + dst = blocks.vector_sink_f() self.tb.connect(src, op, dst) self.tb.run() result_data = dst.data() @@ -46,9 +46,9 @@ class test_single_pole_iir_filter(gr_unittest.TestCase): def test_ff_002(self): src_data = (0, 1000, 2000, 3000, 4000, 5000) expected_result = (0, 125, 359.375, 689.453125, 1103.271484, 1590.36255) - src = gr.vector_source_f(src_data) + src = blocks.vector_source_f(src_data) op = filter.single_pole_iir_filter_ff(0.125) - dst = gr.vector_sink_f() + dst = blocks.vector_sink_f() self.tb.connect(src, op, dst) self.tb.run() result_data = dst.data() @@ -58,11 +58,11 @@ class test_single_pole_iir_filter(gr_unittest.TestCase): block_size = 2 src_data = (0, 1000, 2000, 3000, 4000, 5000) expected_result = (0, 125, 250, 484.375, 718.75, 1048.828125) - src = gr.vector_source_f(src_data) + src = blocks.vector_source_f(src_data) s2p = blocks.stream_to_vector(gr.sizeof_float, block_size) op = filter.single_pole_iir_filter_ff (0.125, block_size) p2s = blocks.vector_to_stream(gr.sizeof_float, block_size) - dst = gr.vector_sink_f() + dst = blocks.vector_sink_f() self.tb.connect(src, s2p, op, p2s, dst) self.tb.run() result_data = dst.data() @@ -71,9 +71,9 @@ class test_single_pole_iir_filter(gr_unittest.TestCase): def test_cc_001(self): src_data = (0+0j, 1000+1000j, 2000+2000j, 3000+3000j, 4000+4000j, 5000+5000j) expected_result = src_data - src = gr.vector_source_c(src_data) + src = blocks.vector_source_c(src_data) op = filter.single_pole_iir_filter_cc(1.0) - dst = gr.vector_sink_c() + dst = blocks.vector_sink_c() self.tb.connect(src, op, dst) self.tb.run() result_data = dst.data() @@ -85,9 +85,9 @@ class test_single_pole_iir_filter(gr_unittest.TestCase): expected_result = (complex(0,0), complex(125,-125), complex(359.375,-359.375), complex(689.453125,-689.453125), complex(1103.271484,-1103.271484), complex(1590.36255,-1590.36255)) - src = gr.vector_source_c(src_data) + src = blocks.vector_source_c(src_data) op = filter.single_pole_iir_filter_cc(0.125) - dst = gr.vector_sink_c() + dst = blocks.vector_sink_c() self.tb.connect(src, op, dst) self.tb.run() result_data = dst.data() @@ -100,11 +100,11 @@ class test_single_pole_iir_filter(gr_unittest.TestCase): expected_result = (complex(0,0), complex(125,-125), complex(250,-250), complex(484.375,-484.375), complex(718.75,-718.75), complex(1048.828125,-1048.828125)) - src = gr.vector_source_c(src_data) + src = blocks.vector_source_c(src_data) s2p = blocks.stream_to_vector(gr.sizeof_gr_complex, block_size) op = filter.single_pole_iir_filter_cc(0.125, block_size) p2s = blocks.vector_to_stream(gr.sizeof_gr_complex, block_size) - dst = gr.vector_sink_c() + dst = blocks.vector_sink_c() self.tb.connect(src, s2p, op, p2s, dst) self.tb.run() result_data = dst.data() diff --git a/gr-filter/python/rational_resampler.py b/gr-filter/python/rational_resampler.py index 97df283e67..8f1dc36e0d 100644 --- a/gr-filter/python/rational_resampler.py +++ b/gr-filter/python/rational_resampler.py @@ -20,6 +20,7 @@ # from gnuradio import gr, gru +import filter_swig as filter _plot = None diff --git a/gr-howto-write-a-block/apps/howto_square.grc b/gr-howto-write-a-block/apps/howto_square.grc index 1f3324e4eb..0eea15426c 100644 --- a/gr-howto-write-a-block/apps/howto_square.grc +++ b/gr-howto-write-a-block/apps/howto_square.grc @@ -143,7 +143,7 @@ </param> <param> <key>trig_mode</key> - <value>gr.gr_TRIG_MODE_AUTO</value> + <value>wxgui.TRIG_MODE_AUTO</value> </param> <param> <key>y_axis_label</key> @@ -209,7 +209,7 @@ </param> </block> <block> - <key>gr_vector_source_x</key> + <key>blocks_vector_source_x</key> <param> <key>id</key> <value>src</value> @@ -303,7 +303,7 @@ </param> <param> <key>trig_mode</key> - <value>gr.gr_TRIG_MODE_AUTO</value> + <value>wxgui.TRIG_MODE_AUTO</value> </param> <param> <key>y_axis_label</key> diff --git a/gr-howto-write-a-block/apps/howto_square.py b/gr-howto-write-a-block/apps/howto_square.py index fd03b74c42..818e776232 100755 --- a/gr-howto-write-a-block/apps/howto_square.py +++ b/gr-howto-write-a-block/apps/howto_square.py @@ -30,7 +30,7 @@ class howto_square(grc_wxgui.top_block_gui): # Blocks ################################################## self.thr = blocks.throttle(gr.sizeof_float*1, samp_rate) - self.src = gr.vector_source_f(([float(n)-50 for n in range(100)]), True, 1) + self.src = blocks.vector_source_f(([float(n)-50 for n in range(100)]), True, 1) self.sqr = howto.square_ff() self.sink2 = scopesink2.scope_sink_f( self.GetWin(), @@ -42,7 +42,7 @@ class howto_square(grc_wxgui.top_block_gui): ac_couple=False, xy_mode=False, num_inputs=1, - trig_mode=gr.gr_TRIG_MODE_AUTO, + trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.Add(self.sink2.win) @@ -56,7 +56,7 @@ class howto_square(grc_wxgui.top_block_gui): ac_couple=False, xy_mode=False, num_inputs=1, - trig_mode=gr.gr_TRIG_MODE_AUTO, + trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.Add(self.sink.win) diff --git a/gr-howto-write-a-block/lib/qa_square2_ff.cc b/gr-howto-write-a-block/lib/qa_square2_ff.cc index 672e75691b..b73c7ce1d7 100644 --- a/gr-howto-write-a-block/lib/qa_square2_ff.cc +++ b/gr-howto-write-a-block/lib/qa_square2_ff.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2011,2012 Free Software Foundation, Inc. + * Copyright 2011-2013 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -24,8 +24,8 @@ #include <vector> #include <gr_top_block.h> -#include <gr_vector_source_f.h> -#include <gr_vector_sink_f.h> +#include <blocks/vector_source_f.h> +#include <blocks/vector_sink_f.h> #include <howto/square2_ff.h> namespace gr { @@ -43,8 +43,8 @@ namespace gr { } gr_top_block_sptr tb = gr_make_top_block("dial_tone"); - gr_vector_source_f_sptr src = gr_make_vector_source_f(data); - gr_vector_sink_f_sptr snk = gr_make_vector_sink_f(); + gr::blocks::vector_source_f::sptr src = gr::blocks::vector_source_f::make(data); + gr::blocks::vector_sink_f::sptr snk = gr::blocks::vector_sink_f::make(); square2_ff::sptr op = square2_ff::make(); diff --git a/gr-howto-write-a-block/lib/qa_square_ff.cc b/gr-howto-write-a-block/lib/qa_square_ff.cc index dedd934e16..a8e7ac2b92 100644 --- a/gr-howto-write-a-block/lib/qa_square_ff.cc +++ b/gr-howto-write-a-block/lib/qa_square_ff.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2011,2012 Free Software Foundation, Inc. + * Copyright 2011-2013 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -24,8 +24,8 @@ #include <vector> #include <gr_top_block.h> -#include <gr_vector_source_f.h> -#include <gr_vector_sink_f.h> +#include <blocks/vector_source_f.h> +#include <blocks/vector_sink_f.h> #include <howto/square_ff.h> namespace gr { @@ -43,8 +43,8 @@ namespace gr { } gr_top_block_sptr tb = gr_make_top_block("dial_tone"); - gr_vector_source_f_sptr src = gr_make_vector_source_f(data); - gr_vector_sink_f_sptr snk = gr_make_vector_sink_f(); + gr::blocks::vector_source_f::sptr src = gr::blocks::vector_source_f::make(data); + gr::blocks::vector_sink_f::sptr snk = gr::blocks::vector_sink_f::make(); square_ff::sptr op = square_ff::make(); diff --git a/gr-howto-write-a-block/python/qa_howto.py b/gr-howto-write-a-block/python/qa_howto.py index 203b06922b..7b58c35f4d 100644 --- a/gr-howto-write-a-block/python/qa_howto.py +++ b/gr-howto-write-a-block/python/qa_howto.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2004,2007,2012 Free Software Foundation, Inc. +# Copyright 2004,2007,2012,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -21,6 +21,7 @@ # from gnuradio import gr, gr_unittest +from gnuradio import blocks import howto_swig as howto from square3_ff import square3_ff @@ -35,9 +36,9 @@ class qa_howto(gr_unittest.TestCase): def test_001_square_ff(self): src_data = (-3, 4, -5.5, 2, 3) expected_result = (9, 16, 30.25, 4, 9) - src = gr.vector_source_f(src_data) + src = blocks.vector_source_f(src_data) sqr = howto.square_ff() - dst = gr.vector_sink_f() + dst = blocks.vector_sink_f() self.tb.connect(src, sqr) self.tb.connect(sqr, dst) self.tb.run() @@ -47,9 +48,9 @@ class qa_howto(gr_unittest.TestCase): def test_002_square2_ff(self): src_data = (-3, 4, -5.5, 2, 3) expected_result = (9, 16, 30.25, 4, 9) - src = gr.vector_source_f(src_data) + src = blocks.vector_source_f(src_data) sqr = howto.square2_ff() - dst = gr.vector_sink_f() + dst = blocks.vector_sink_f() self.tb.connect(src, sqr) self.tb.connect(sqr, dst) self.tb.run() @@ -59,9 +60,9 @@ class qa_howto(gr_unittest.TestCase): def test_003_square3_ff (self): src_data = (-3, 4, -5.5, 2, 3) expected_result = (9, 16, 30.25, 4, 9) - src = gr.vector_source_f (src_data) + src = blocks.vector_source_f (src_data) sqr = square3_ff () - dst = gr.vector_sink_f () + dst = blocks.vector_sink_f () self.tb.connect (src, sqr) self.tb.connect (sqr, dst) self.tb.run () diff --git a/gr-noaa/examples/usrp_rx_hrpt.grc b/gr-noaa/examples/usrp_rx_hrpt.grc index 1f61a8880f..56d07446bf 100644 --- a/gr-noaa/examples/usrp_rx_hrpt.grc +++ b/gr-noaa/examples/usrp_rx_hrpt.grc @@ -1667,7 +1667,7 @@ </param> <param> <key>trig_mode</key> - <value>gr.gr_TRIG_MODE_AUTO</value> + <value>wxgui.TRIG_MODE_AUTO</value> </param> <param> <key>y_axis_label</key> diff --git a/gr-pager/apps/usrp_flex_all b/gr-pager/apps/usrp_flex_all index 58fcc0af45..4d950866f0 100755 --- a/gr-pager/apps/usrp_flex_all +++ b/gr-pager/apps/usrp_flex_all @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2006,2007,2009 Free Software Foundation, Inc. +# Copyright 2006,2007,2009,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -105,7 +105,7 @@ class app_top_block(gr.top_block): freq = options.freq-(self.nchan-i)*25e3 if (freq < 929.0e6 or freq > 932.0e6): - self.connect((self.bank, i), gr.null_sink(gr.sizeof_gr_complex)) + self.connect((self.bank, i), blocks.null_sink(gr.sizeof_gr_complex)) else: self.connect((self.bank, i), pager.flex_demod(queue, freq, options.verbose, options.log)) if options.log: diff --git a/gr-pager/apps/usrp_rx_flex.grc b/gr-pager/apps/usrp_rx_flex.grc index 79312a4148..b6833aa526 100644 --- a/gr-pager/apps/usrp_rx_flex.grc +++ b/gr-pager/apps/usrp_rx_flex.grc @@ -1523,10 +1523,10 @@ </param> </block> <block> - <key>gr_null_sink</key> + <key>blocks_null_sink</key> <param> <key>id</key> - <value>gr_null_sink_0</value> + <value>blocks_null_sink_0</value> </param> <param> <key>_enabled</key> @@ -1607,10 +1607,10 @@ </param> </block> <block> - <key>gr_null_sink</key> + <key>blocks_null_sink</key> <param> <key>id</key> - <value>gr_null_sink_0_0</value> + <value>blocks_null_sink_0_0</value> </param> <param> <key>_enabled</key> @@ -1634,10 +1634,10 @@ </param> </block> <block> - <key>gr_null_sink</key> + <key>blocks_null_sink</key> <param> <key>id</key> - <value>gr_null_sink_0_1</value> + <value>blocks_null_sink_0_1</value> </param> <param> <key>_enabled</key> @@ -1661,10 +1661,10 @@ </param> </block> <block> - <key>gr_null_sink</key> + <key>blocks_null_sink</key> <param> <key>id</key> - <value>gr_null_sink_0_2</value> + <value>blocks_null_sink_0_2</value> </param> <param> <key>_enabled</key> @@ -1779,25 +1779,25 @@ </connection> <connection> <source_block_id>pager_flex_deinterleave_0</source_block_id> - <sink_block_id>gr_null_sink_0</sink_block_id> + <sink_block_id>blocks_null_sink_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> <source_block_id>pager_flex_deinterleave_0_1_0</source_block_id> - <sink_block_id>gr_null_sink_0_0</sink_block_id> + <sink_block_id>blocks_null_sink_0_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> <source_block_id>pager_flex_deinterleave_0_1</source_block_id> - <sink_block_id>gr_null_sink_0_1</sink_block_id> + <sink_block_id>blocks_null_sink_0_1</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> <source_block_id>pager_flex_deinterleave_0_0</source_block_id> - <sink_block_id>gr_null_sink_0_2</sink_block_id> + <sink_block_id>blocks_null_sink_0_2</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> diff --git a/gr-pager/apps/usrp_rx_flex.py b/gr-pager/apps/usrp_rx_flex.py index 6bb93ee756..4de4ded9c4 100755 --- a/gr-pager/apps/usrp_rx_flex.py +++ b/gr-pager/apps/usrp_rx_flex.py @@ -7,6 +7,7 @@ from gnuradio import eng_notation from gnuradio import gr +from gnuradio import blocks from gnuradio import filter from gnuradio import pager from gnuradio.eng_option import eng_option @@ -175,10 +176,10 @@ class usrp_rx_flex(grc_wxgui.top_block_gui): ################################################## self.fm_demod = gr.quadrature_demod_cf(demod_k) self.gr_freq_xlating_fir_filter_xxx_0 = gr.freq_xlating_fir_filter_ccc(channel_decim, (channel_taps), band_freq-freq+offset, sample_rate) - self.gr_null_sink_0 = gr.null_sink(gr.sizeof_int*1) - self.gr_null_sink_0_0 = gr.null_sink(gr.sizeof_int*1) - self.gr_null_sink_0_1 = gr.null_sink(gr.sizeof_int*1) - self.gr_null_sink_0_2 = gr.null_sink(gr.sizeof_int*1) + self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_int*1) + self.blocks_null_sink_0_0 = blocks.null_sink(gr.sizeof_int*1) + self.blocks_null_sink_0_1 = blocks.null_sink(gr.sizeof_int*1) + self.blocks_null_sink_0_2 = blocks.null_sink(gr.sizeof_int*1) self.pager_flex_deinterleave_0 = pager.flex_deinterleave() self.pager_flex_deinterleave_0_0 = pager.flex_deinterleave() self.pager_flex_deinterleave_0_1 = pager.flex_deinterleave() @@ -255,10 +256,10 @@ class usrp_rx_flex(grc_wxgui.top_block_gui): self.connect((self.pager_flex_sync_0, 2), (self.pager_flex_deinterleave_0_1, 0)) self.connect((self.pager_flex_sync_0, 0), (self.pager_flex_deinterleave_0, 0)) self.connect((self.pager_flex_sync_0, 3), (self.pager_flex_deinterleave_0_0, 0)) - self.connect((self.pager_flex_deinterleave_0, 0), (self.gr_null_sink_0, 0)) - self.connect((self.pager_flex_deinterleave_0_1_0, 0), (self.gr_null_sink_0_0, 0)) - self.connect((self.pager_flex_deinterleave_0_1, 0), (self.gr_null_sink_0_1, 0)) - self.connect((self.pager_flex_deinterleave_0_0, 0), (self.gr_null_sink_0_2, 0)) + self.connect((self.pager_flex_deinterleave_0, 0), (self.blocks_null_sink_0, 0)) + self.connect((self.pager_flex_deinterleave_0_1_0, 0), (self.blocks_null_sink_0_0, 0)) + self.connect((self.pager_flex_deinterleave_0_1, 0), (self.blocks_null_sink_0_1, 0)) + self.connect((self.pager_flex_deinterleave_0_0, 0), (self.blocks_null_sink_0_2, 0)) def set_config_filename(self, config_filename): self.config_filename = config_filename diff --git a/gr-qtgui/apps/gr_constellation_plot b/gr-qtgui/apps/gr_constellation_plot index 0687443218..559b643c53 100755 --- a/gr-qtgui/apps/gr_constellation_plot +++ b/gr-qtgui/apps/gr_constellation_plot @@ -21,6 +21,7 @@ # from gnuradio import gr +from gnuradio import blocks from gnuradio.eng_option import eng_option from optparse import OptionParser import os, sys @@ -67,7 +68,7 @@ class my_top_block(gr.top_block): self.qapp = QtGui.QApplication(sys.argv) - self.skip = gr.skiphead(gr.sizeof_gr_complex, self._start) + self.skip = blocks.skiphead(gr.sizeof_gr_complex, self._start) self.gui_snk = qtgui.const_sink_c(self._nsamps, "GNU Radio Constellation Plot", self._nsigs) @@ -77,7 +78,7 @@ class my_top_block(gr.top_block): self._data_max = -sys.maxint - 1 for f in filelist: data,_min,_max = read_samples_c(f, self._start, self._nsamps) - self.srcs.append(gr.vector_source_c(data)) + self.srcs.append(blocks.vector_source_c(data)) if(_min < self._data_min): self._data_min = _min diff --git a/gr-qtgui/apps/gr_psd_plot_c b/gr-qtgui/apps/gr_psd_plot_c index f2789ef34b..6ade908bd4 100755 --- a/gr-qtgui/apps/gr_psd_plot_c +++ b/gr-qtgui/apps/gr_psd_plot_c @@ -21,6 +21,7 @@ # from gnuradio import gr +from gnuradio import blocks from gnuradio import filter import scipy @@ -46,7 +47,7 @@ class psd_plot_c(plot_base.plot_base): self.read_samples = plot_base.read_samples_c self.dsize = gr.sizeof_gr_complex - self.src_type = gr.vector_source_c + self.src_type = blocks.vector_source_c self.gui_snk = qtgui.freq_sink_c(self._psd_size, filter.firdes.WIN_BLACKMAN_hARRIS, self._center_freq, self._samp_rate, "GNU Radio PSD Plot", self._nsigs) diff --git a/gr-qtgui/apps/gr_psd_plot_f b/gr-qtgui/apps/gr_psd_plot_f index c6b70baf27..792b04290b 100755 --- a/gr-qtgui/apps/gr_psd_plot_f +++ b/gr-qtgui/apps/gr_psd_plot_f @@ -21,6 +21,7 @@ # from gnuradio import gr +from gnuradio import blocks from gnuradio import filter import scipy @@ -46,7 +47,7 @@ class psd_plot_f(plot_base.plot_base): self.read_samples = plot_base.read_samples_f self.dsize = gr.sizeof_float - self.src_type = gr.vector_source_f + self.src_type = blocks.vector_source_f self.gui_snk = qtgui.freq_sink_f(self._psd_size, filter.firdes.WIN_BLACKMAN_hARRIS, self._center_freq, self._samp_rate, "GNU Radio PSD Plot", self._nsigs) diff --git a/gr-qtgui/apps/gr_spectrogram_plot_c b/gr-qtgui/apps/gr_spectrogram_plot_c index 059f65cd99..bb4fad1b7a 100755 --- a/gr-qtgui/apps/gr_spectrogram_plot_c +++ b/gr-qtgui/apps/gr_spectrogram_plot_c @@ -21,6 +21,7 @@ # from gnuradio import gr +from gnuradio import blocks from gnuradio import filter import scipy @@ -46,7 +47,7 @@ class spectrogram_plot_c(plot_base.plot_base): self.read_samples = plot_base.read_samples_c self.dsize = gr.sizeof_gr_complex - self.src_type = gr.vector_source_c + self.src_type = blocks.vector_source_c self.gui_snk = qtgui.waterfall_sink_c(self._psd_size, filter.firdes.WIN_BLACKMAN_hARRIS, self._center_freq, self._samp_rate, "GNU Radio Spectrogram Plot", self._nsigs) diff --git a/gr-qtgui/apps/gr_spectrogram_plot_f b/gr-qtgui/apps/gr_spectrogram_plot_f index be9c981532..dcb0305bf5 100755 --- a/gr-qtgui/apps/gr_spectrogram_plot_f +++ b/gr-qtgui/apps/gr_spectrogram_plot_f @@ -21,6 +21,7 @@ # from gnuradio import gr +from gnuradio import blocks from gnuradio import filter import scipy @@ -46,7 +47,7 @@ class spectrogram_plot_f(plot_base.plot_base): self.read_samples = plot_base.read_samples_f self.dsize = gr.sizeof_float - self.src_type = gr.vector_source_f + self.src_type = blocks.vector_source_f self.gui_snk = qtgui.waterfall_sink_f(self._psd_size, filter.firdes.WIN_BLACKMAN_hARRIS, self._center_freq, self._samp_rate, "GNU Radio Spectrogram Plot", self._nsigs) diff --git a/gr-qtgui/apps/gr_time_plot_c b/gr-qtgui/apps/gr_time_plot_c index a7c39a24b9..174b3ee1ed 100755 --- a/gr-qtgui/apps/gr_time_plot_c +++ b/gr-qtgui/apps/gr_time_plot_c @@ -21,6 +21,7 @@ # from gnuradio import gr +from gnuradio import blocks import scipy try: @@ -45,7 +46,7 @@ class plot_time_c(plot_base.plot_base): auto_scale) self.read_samples = plot_base.read_samples_c self.dsize = gr.sizeof_gr_complex - self.src_type = gr.vector_source_c + self.src_type = blocks.vector_source_c self.gui_snk = qtgui.time_sink_c(self._nsamps, self._samp_rate, "GNU Radio Time Plot", self._nsigs) self._nsigs *= 2 # complex plots have real/imag diff --git a/gr-qtgui/apps/gr_time_plot_f b/gr-qtgui/apps/gr_time_plot_f index 9b29709b10..9140b61220 100755 --- a/gr-qtgui/apps/gr_time_plot_f +++ b/gr-qtgui/apps/gr_time_plot_f @@ -21,6 +21,7 @@ # from gnuradio import gr +from gnuradio import blocks import scipy try: @@ -45,7 +46,7 @@ class plot_time_f(plot_base.plot_base): auto_scale) self.read_samples = plot_base.read_samples_f self.dsize = gr.sizeof_float - self.src_type = gr.vector_source_f + self.src_type = blocks.vector_source_f self.gui_snk = qtgui.time_sink_f(self._nsamps, self._samp_rate, "GNU Radio Time Plot", self._nsigs) self.setup() diff --git a/gr-qtgui/apps/gr_time_raster_b b/gr-qtgui/apps/gr_time_raster_b index a326a126c4..3e81c317d6 100755 --- a/gr-qtgui/apps/gr_time_raster_b +++ b/gr-qtgui/apps/gr_time_raster_b @@ -21,6 +21,7 @@ # from gnuradio import gr +from gnuradio import blocks import scipy try: @@ -48,7 +49,7 @@ class plot_time_raster_b(plot_base.plot_base): self._ncols = ncols self.read_samples = plot_base.read_samples_b self.dsize = gr.sizeof_char - self.src_type = gr.vector_source_b + self.src_type = blocks.vector_source_b self.gui_snk = qtgui.time_raster_sink_b(self._samp_rate, self._nrows, self._ncols, [], [], "GNU Radio Time Plot", self._nsigs) self.setup() diff --git a/gr-qtgui/apps/gr_time_raster_f b/gr-qtgui/apps/gr_time_raster_f index a6cb897c0b..6b5e5c20e9 100755 --- a/gr-qtgui/apps/gr_time_raster_f +++ b/gr-qtgui/apps/gr_time_raster_f @@ -21,6 +21,7 @@ # from gnuradio import gr +from gnuradio import blocks import scipy try: @@ -48,7 +49,7 @@ class plot_time_raster_f(plot_base.plot_base): self._ncols = ncols self.read_samples = plot_base.read_samples_f self.dsize = gr.sizeof_float - self.src_type = gr.vector_source_f + self.src_type = blocks.vector_source_f self.gui_snk = qtgui.time_raster_sink_f(self._samp_rate, self._nrows, self._ncols, [], [], "GNU Radio Time Plot", self._nsigs) self.setup() diff --git a/gr-qtgui/apps/plot_base.py b/gr-qtgui/apps/plot_base.py index 52c888cff3..b279e1e977 100644 --- a/gr-qtgui/apps/plot_base.py +++ b/gr-qtgui/apps/plot_base.py @@ -91,7 +91,7 @@ def read_samples_b(filename, start, in_size, min_size=0): scipy.int8, gr.sizeof_char) # Bit of a hack since we want to read the data as signed ints, but - # the gr.vector_source_b will only accept unsigned. We read in as + # the blocks.vector_source_b will only accept unsigned. We read in as # signed, do our min/max and things on that, then convert here. d = scipy.array(d, dtype=scipy.uint8).tolist() return d,mn,mx @@ -122,7 +122,7 @@ class source_ints_to_float(gr.hier_block2): gr.hier_block2.__init__(self, "ints_to_floats", gr.io_signature(0, 0, 0), gr.io_signature(1, 1, gr.sizeof_float)) - self.src = gr.vector_source_i(data) + self.src = blocks.vector_source_i(data) self.cvt = blocks.int_to_float() self.connect(self.src, self.cvt, self) @@ -134,7 +134,7 @@ class source_shorts_to_float(gr.hier_block2): gr.hier_block2.__init__(self, "shorts_to_floats", gr.io_signature(0, 0, 0), gr.io_signature(1, 1, gr.sizeof_float)) - self.src = gr.vector_source_s(data) + self.src = blocks.vector_source_s(data) self.cvt = blocks.short_to_float() self.connect(self.src, self.cvt, self) @@ -146,7 +146,7 @@ class source_chars_to_float(gr.hier_block2): gr.hier_block2.__init__(self, "chars_to_floats", gr.io_signature(0, 0, 0), gr.io_signature(1, 1, gr.sizeof_float)) - self.src = gr.vector_source_b(data) + self.src = blocks.vector_source_b(data) self.cvt = blocks.char_to_float() self.connect(self.src, self.cvt, self) diff --git a/gr-qtgui/apps/plot_psd_base.py b/gr-qtgui/apps/plot_psd_base.py index a4a6cb871a..bb1567e014 100644 --- a/gr-qtgui/apps/plot_psd_base.py +++ b/gr-qtgui/apps/plot_psd_base.py @@ -72,7 +72,7 @@ class plot_base(gr.top_block): self.qapp = QtGui.QApplication(sys.argv) def setup(self): - self.skip = gr.skiphead(self.dsize, self._start) + self.skip = blocks.skiphead(self.dsize, self._start) n = 0 self.srcs = list() diff --git a/gr-qtgui/apps/plot_spectrogram_base.py b/gr-qtgui/apps/plot_spectrogram_base.py index adfbfd032f..a3fdf65117 100644 --- a/gr-qtgui/apps/plot_spectrogram_base.py +++ b/gr-qtgui/apps/plot_spectrogram_base.py @@ -72,7 +72,7 @@ class plot_base(gr.top_block): self.qapp = QtGui.QApplication(sys.argv) def setup(self): - self.skip = gr.skiphead(self.dsize, self._start) + self.skip = blocks.skiphead(self.dsize, self._start) n = 0 self.srcs = list() diff --git a/gr-qtgui/apps/plot_time_base.py b/gr-qtgui/apps/plot_time_base.py index c80bace1b6..942500c627 100644 --- a/gr-qtgui/apps/plot_time_base.py +++ b/gr-qtgui/apps/plot_time_base.py @@ -71,7 +71,7 @@ class plot_base(gr.top_block): self.qapp = QtGui.QApplication(sys.argv) def setup(self): - self.skip = gr.skiphead(self.dsize, self._start) + self.skip = blocks.skiphead(self.dsize, self._start) n = 0 self.srcs = list() diff --git a/gr-qtgui/apps/plot_time_raster_base.py b/gr-qtgui/apps/plot_time_raster_base.py index ff3cc2869d..2fc498ba28 100644 --- a/gr-qtgui/apps/plot_time_raster_base.py +++ b/gr-qtgui/apps/plot_time_raster_base.py @@ -71,7 +71,7 @@ class plot_base(gr.top_block): self.qapp = QtGui.QApplication(sys.argv) def setup(self): - self.skip = gr.skiphead(self.dsize, self._start) + self.skip = blocks.skiphead(self.dsize, self._start) n = 0 self.srcs = list() diff --git a/gr-qtgui/apps/qt_digital.py b/gr-qtgui/apps/qt_digital.py index 445d6d4fc1..fef4f448b4 100755 --- a/gr-qtgui/apps/qt_digital.py +++ b/gr-qtgui/apps/qt_digital.py @@ -182,7 +182,7 @@ class my_top_block(gr.top_block): fftsize = 2048 self.data = scipy.random.randint(0, 255, 1000) - self.src = gr.vector_source_b(self.data.tolist(), True) + self.src = blocks.vector_source_b(self.data.tolist(), True) self.mod = digital.dqpsk_mod(self.gray_code, samples_per_symbol=self.sps, excess_bw=self.excess_bw, diff --git a/gr-qtgui/examples/pyqt_time_raster_b.py b/gr-qtgui/examples/pyqt_time_raster_b.py index b29403819d..4cad9de601 100755 --- a/gr-qtgui/examples/pyqt_time_raster_b.py +++ b/gr-qtgui/examples/pyqt_time_raster_b.py @@ -22,6 +22,7 @@ from gnuradio import gr from gnuradio import blocks +from gnuradio import blocks import sys try: @@ -58,10 +59,10 @@ class my_top_block(gr.top_block): nrows = 100 fs = 200 - src0 = gr.vector_source_b(data0, True) - src1 = gr.vector_source_b(data1, True) + src0 = blocks.vector_source_b(data0, True) + src1 = blocks.vector_source_b(data1, True) thr = blocks.throttle(gr.sizeof_char, 50000) - head = gr.head(gr.sizeof_char, 10000000) + head = blocks.head(gr.sizeof_char, 10000000) self.snk1 = qtgui.time_raster_sink_b(fs, nrows, ncols, [], [], "Time Raster Example", 2) diff --git a/gr-qtgui/examples/pyqt_time_raster_f.py b/gr-qtgui/examples/pyqt_time_raster_f.py index 957e694b38..c5261520db 100755 --- a/gr-qtgui/examples/pyqt_time_raster_f.py +++ b/gr-qtgui/examples/pyqt_time_raster_f.py @@ -58,10 +58,10 @@ class my_top_block(gr.top_block): nrows = 100 fs = 200 - src0 = gr.vector_source_f(data0, True) - src1 = gr.vector_source_f(data1, True) + src0 = blocks.vector_source_f(data0, True) + src1 = blocks.vector_source_f(data1, True) thr = blocks.throttle(gr.sizeof_float, 50000) - hed = gr.head(gr.sizeof_float, 10000000) + hed = blocks.head(gr.sizeof_float, 10000000) self.snk1 = qtgui.time_raster_sink_f(fs, nrows, ncols, [], [], "Float Time Raster Example", 2) diff --git a/gr-qtgui/include/qtgui/CMakeLists.txt b/gr-qtgui/include/qtgui/CMakeLists.txt index f3ef6808e8..8f95837fec 100644 --- a/gr-qtgui/include/qtgui/CMakeLists.txt +++ b/gr-qtgui/include/qtgui/CMakeLists.txt @@ -21,19 +21,41 @@ # Install the header files ######################################################################## install(FILES - api.h - time_sink_c.h - time_sink_f.h - time_raster_sink_b.h - time_raster_sink_f.h - freq_sink_c.h - freq_sink_f.h - const_sink_c.h - waterfall_sink_c.h - waterfall_sink_f.h - sink_c.h - sink_f.h - utils.h - DESTINATION ${GR_INCLUDE_DIR}/gnuradio/qtgui - COMPONENT "qtgui_devel" + api.h + CMakeLists.txt + constellationdisplayform.h + ConstellationDisplayPlot.h + const_sink_c.h + displayform.h + DisplayPlot.h + form_menus.h + freqdisplayform.h + freq_sink_c.h + freq_sink_f.h + FrequencyDisplayPlot.h + plot_raster.h + plot_waterfall.h + qtgui_types.h + sink_c.h + sink_f.h + spectrumdisplayform.h + SpectrumGUIClass.h + spectrumUpdateEvents.h + timedisplayform.h + TimeDomainDisplayPlot.h + timerasterdisplayform.h + TimeRasterDisplayPlot.h + timeRasterGlobalData.h + time_raster_sink_b.h + time_raster_sink_f.h + time_sink_c.h + time_sink_f.h + utils.h + waterfalldisplayform.h + WaterfallDisplayPlot.h + waterfallGlobalData.h + waterfall_sink_c.h + waterfall_sink_f.h + DESTINATION ${GR_INCLUDE_DIR}/gnuradio/qtgui + COMPONENT "qtgui_devel" ) diff --git a/gr-qtgui/lib/ConstellationDisplayPlot.h b/gr-qtgui/include/qtgui/ConstellationDisplayPlot.h index b68b01f6d8..2c33a74301 100644 --- a/gr-qtgui/lib/ConstellationDisplayPlot.h +++ b/gr-qtgui/include/qtgui/ConstellationDisplayPlot.h @@ -26,7 +26,7 @@ #include <stdint.h> #include <cstdio> #include <vector> -#include "DisplayPlot.h" +#include <qtgui/DisplayPlot.h> class ConstellationDisplayPlot : public DisplayPlot { diff --git a/gr-qtgui/lib/DisplayPlot.h b/gr-qtgui/include/qtgui/DisplayPlot.h index d9ee16e087..d9ee16e087 100644 --- a/gr-qtgui/lib/DisplayPlot.h +++ b/gr-qtgui/include/qtgui/DisplayPlot.h diff --git a/gr-qtgui/lib/FrequencyDisplayPlot.h b/gr-qtgui/include/qtgui/FrequencyDisplayPlot.h index 22d2be0055..ae438f143f 100644 --- a/gr-qtgui/lib/FrequencyDisplayPlot.h +++ b/gr-qtgui/include/qtgui/FrequencyDisplayPlot.h @@ -26,7 +26,7 @@ #include <stdint.h> #include <cstdio> #include <vector> -#include "DisplayPlot.h" +#include <qtgui/DisplayPlot.h> class FrequencyDisplayPlot: public DisplayPlot { diff --git a/gr-qtgui/lib/SpectrumGUIClass.h b/gr-qtgui/include/qtgui/SpectrumGUIClass.h index 9a2233d168..844c6509d6 100644 --- a/gr-qtgui/lib/SpectrumGUIClass.h +++ b/gr-qtgui/include/qtgui/SpectrumGUIClass.h @@ -28,10 +28,10 @@ #include <qapplication.h> #include <qlabel.h> #include <qslider.h> -#include <spectrumUpdateEvents.h> +#include <qtgui/spectrumUpdateEvents.h> class SpectrumDisplayForm; -#include <spectrumdisplayform.h> +#include <qtgui/spectrumdisplayform.h> #include <cmath> diff --git a/gr-qtgui/lib/TimeDomainDisplayPlot.h b/gr-qtgui/include/qtgui/TimeDomainDisplayPlot.h index 9996f84fc3..f7e695d51b 100644 --- a/gr-qtgui/lib/TimeDomainDisplayPlot.h +++ b/gr-qtgui/include/qtgui/TimeDomainDisplayPlot.h @@ -26,7 +26,7 @@ #include <stdint.h> #include <cstdio> #include <vector> -#include "DisplayPlot.h" +#include <qtgui/DisplayPlot.h> class TimeDomainDisplayPlot: public DisplayPlot { diff --git a/gr-qtgui/lib/TimeRasterDisplayPlot.h b/gr-qtgui/include/qtgui/TimeRasterDisplayPlot.h index e4e292a54d..c1ea427769 100644 --- a/gr-qtgui/lib/TimeRasterDisplayPlot.h +++ b/gr-qtgui/include/qtgui/TimeRasterDisplayPlot.h @@ -27,13 +27,13 @@ #include <cstdio> #include <vector> #include <qwt_plot_rasteritem.h> -#include "DisplayPlot.h" -#include "timeRasterGlobalData.h" -#include "plot_raster.h" +#include <qtgui/DisplayPlot.h> +#include <qtgui/timeRasterGlobalData.h> +#include <qtgui/plot_raster.h> #include <gruel/high_res_timer.h> #if QWT_VERSION < 0x060000 -#include <plot_waterfall.h> +#include <qtgui/plot_waterfall.h> #else #include <qwt_compat.h> #endif diff --git a/gr-qtgui/lib/WaterfallDisplayPlot.h b/gr-qtgui/include/qtgui/WaterfallDisplayPlot.h index 6637adc594..6545774325 100644 --- a/gr-qtgui/lib/WaterfallDisplayPlot.h +++ b/gr-qtgui/include/qtgui/WaterfallDisplayPlot.h @@ -27,12 +27,12 @@ #include <cstdio> #include <vector> #include <qwt_plot_spectrogram.h> -#include "DisplayPlot.h" -#include "waterfallGlobalData.h" +#include <qtgui/DisplayPlot.h> +#include <qtgui/waterfallGlobalData.h> #include <gruel/high_res_timer.h> #if QWT_VERSION < 0x060000 -#include <plot_waterfall.h> +#include <qtgui/plot_waterfall.h> #else #include <qwt_compat.h> #endif diff --git a/gr-qtgui/include/qtgui/const_sink_c.h b/gr-qtgui/include/qtgui/const_sink_c.h index e0c358bcad..b81c53295f 100644 --- a/gr-qtgui/include/qtgui/const_sink_c.h +++ b/gr-qtgui/include/qtgui/const_sink_c.h @@ -28,6 +28,7 @@ #include <gr_sync_block.h> #include <qapplication.h> #include <filter/firdes.h> + namespace gr { namespace qtgui { diff --git a/gr-qtgui/lib/constellationdisplayform.h b/gr-qtgui/include/qtgui/constellationdisplayform.h index 06a8e7ed5f..40cfe8999f 100644 --- a/gr-qtgui/lib/constellationdisplayform.h +++ b/gr-qtgui/include/qtgui/constellationdisplayform.h @@ -23,12 +23,12 @@ #ifndef CONSTELLATION_DISPLAY_FORM_H #define CONSTELLATION_DISPLAY_FORM_H -#include <spectrumUpdateEvents.h> -#include <ConstellationDisplayPlot.h> +#include <qtgui/spectrumUpdateEvents.h> +#include <qtgui/ConstellationDisplayPlot.h> #include <QtGui/QtGui> #include <vector> -#include "displayform.h" +#include <qtgui/displayform.h> class ConstellationDisplayForm : public DisplayForm { diff --git a/gr-qtgui/lib/displayform.h b/gr-qtgui/include/qtgui/displayform.h index 31dc757bb6..47f17ad41d 100644 --- a/gr-qtgui/lib/displayform.h +++ b/gr-qtgui/include/qtgui/displayform.h @@ -23,15 +23,15 @@ #ifndef DISPLAY_FORM_H #define DISPLAY_FORM_H -#include <spectrumUpdateEvents.h> +#include <qtgui/spectrumUpdateEvents.h> #include <QtGui/QtGui> #include <vector> #include <qwt_plot_grid.h> #include <qwt_plot_layout.h> -#include "DisplayPlot.h" -#include "form_menus.h" +#include <qtgui/DisplayPlot.h> +#include <qtgui/form_menus.h> class DisplayForm : public QWidget { diff --git a/gr-qtgui/lib/form_menus.h b/gr-qtgui/include/qtgui/form_menus.h index 63ab35ed95..7f5b8ae6e7 100644 --- a/gr-qtgui/lib/form_menus.h +++ b/gr-qtgui/include/qtgui/form_menus.h @@ -28,7 +28,7 @@ #include <QtGui/QtGui> #include <qwt_symbol.h> #include <filter/firdes.h> -#include "qtgui_types.h" +#include <qtgui/qtgui_types.h> class LineColorMenu: public QMenu { diff --git a/gr-qtgui/lib/freqdisplayform.h b/gr-qtgui/include/qtgui/freqdisplayform.h index b22cd93c51..2daba90919 100644 --- a/gr-qtgui/lib/freqdisplayform.h +++ b/gr-qtgui/include/qtgui/freqdisplayform.h @@ -23,13 +23,13 @@ #ifndef FREQ_DISPLAY_FORM_H #define FREQ_DISPLAY_FORM_H -#include <spectrumUpdateEvents.h> -#include <FrequencyDisplayPlot.h> +#include <qtgui/spectrumUpdateEvents.h> +#include <qtgui/FrequencyDisplayPlot.h> #include <QtGui/QtGui> #include <vector> #include <filter/firdes.h> -#include "displayform.h" +#include <qtgui/displayform.h> class FreqDisplayForm : public DisplayForm { diff --git a/gr-qtgui/lib/plot_raster.h b/gr-qtgui/include/qtgui/plot_raster.h index 7bea0a4d57..5692cc4ba8 100644 --- a/gr-qtgui/lib/plot_raster.h +++ b/gr-qtgui/include/qtgui/plot_raster.h @@ -24,7 +24,7 @@ #define PLOT_TIMERASTER_H #include <qglobal.h> -#include <timeRasterGlobalData.h> +#include <qtgui/timeRasterGlobalData.h> #include <qwt_plot_rasteritem.h> #if QWT_VERSION >= 0x060000 diff --git a/gr-qtgui/lib/plot_waterfall.h b/gr-qtgui/include/qtgui/plot_waterfall.h index 40ee4eccb3..4c764fd764 100644 --- a/gr-qtgui/lib/plot_waterfall.h +++ b/gr-qtgui/include/qtgui/plot_waterfall.h @@ -24,7 +24,7 @@ #define PLOT_WATERFALL_H #include <qglobal.h> -#include <waterfallGlobalData.h> +#include <qtgui/waterfallGlobalData.h> #include <qwt_plot_rasteritem.h> #if QWT_VERSION >= 0x060000 diff --git a/gr-qtgui/lib/qtgui_types.h b/gr-qtgui/include/qtgui/qtgui_types.h index f4b16dfef2..f4b16dfef2 100644 --- a/gr-qtgui/lib/qtgui_types.h +++ b/gr-qtgui/include/qtgui/qtgui_types.h diff --git a/gr-qtgui/lib/spectrumUpdateEvents.h b/gr-qtgui/include/qtgui/spectrumUpdateEvents.h index 97d9c90146..97d9c90146 100644 --- a/gr-qtgui/lib/spectrumUpdateEvents.h +++ b/gr-qtgui/include/qtgui/spectrumUpdateEvents.h diff --git a/gr-qtgui/lib/spectrumdisplayform.h b/gr-qtgui/include/qtgui/spectrumdisplayform.h index c5b714e73f..37a481245c 100644 --- a/gr-qtgui/lib/spectrumdisplayform.h +++ b/gr-qtgui/include/qtgui/spectrumdisplayform.h @@ -23,16 +23,16 @@ #ifndef SPECTRUM_DISPLAY_FORM_H #define SPECTRUM_DISPLAY_FORM_H -#include "spectrumdisplayform.ui.h" +#include <spectrumdisplayform.ui.h> class SpectrumGUIClass; -#include <SpectrumGUIClass.h> +#include <qtgui/SpectrumGUIClass.h> -#include <SpectrumGUIClass.h> -#include <FrequencyDisplayPlot.h> -#include <WaterfallDisplayPlot.h> -#include <TimeDomainDisplayPlot.h> -#include <ConstellationDisplayPlot.h> +#include <qtgui/SpectrumGUIClass.h> +#include <qtgui/FrequencyDisplayPlot.h> +#include <qtgui/WaterfallDisplayPlot.h> +#include <qtgui/TimeDomainDisplayPlot.h> +#include <qtgui/ConstellationDisplayPlot.h> #include <QValidator> #include <QTimer> #include <vector> diff --git a/gr-qtgui/lib/timeRasterGlobalData.h b/gr-qtgui/include/qtgui/timeRasterGlobalData.h index 0a414432d1..0a414432d1 100644 --- a/gr-qtgui/lib/timeRasterGlobalData.h +++ b/gr-qtgui/include/qtgui/timeRasterGlobalData.h diff --git a/gr-qtgui/lib/timedisplayform.h b/gr-qtgui/include/qtgui/timedisplayform.h index 4bc99f622d..4df4698e3f 100644 --- a/gr-qtgui/lib/timedisplayform.h +++ b/gr-qtgui/include/qtgui/timedisplayform.h @@ -23,12 +23,12 @@ #ifndef TIME_DISPLAY_FORM_H #define TIME_DISPLAY_FORM_H -#include <spectrumUpdateEvents.h> -#include <TimeDomainDisplayPlot.h> +#include <qtgui/spectrumUpdateEvents.h> +#include <qtgui/TimeDomainDisplayPlot.h> #include <QtGui/QtGui> #include <vector> -#include "displayform.h" +#include <qtgui/displayform.h> class TimeDisplayForm : public DisplayForm { diff --git a/gr-qtgui/lib/timerasterdisplayform.h b/gr-qtgui/include/qtgui/timerasterdisplayform.h index f5341f5ecf..8c68c52bca 100644 --- a/gr-qtgui/lib/timerasterdisplayform.h +++ b/gr-qtgui/include/qtgui/timerasterdisplayform.h @@ -23,13 +23,13 @@ #ifndef TIMERASTER_DISPLAY_FORM_H #define TIMERASTER_DISPLAY_FORM_H -#include <spectrumUpdateEvents.h> -#include <TimeRasterDisplayPlot.h> +#include <qtgui/spectrumUpdateEvents.h> +#include <qtgui/TimeRasterDisplayPlot.h> #include <QtGui/QtGui> #include <vector> #include <filter/firdes.h> -#include "displayform.h" +#include <qtgui/displayform.h> class TimeRasterDisplayForm : public DisplayForm { diff --git a/gr-qtgui/lib/waterfallGlobalData.h b/gr-qtgui/include/qtgui/waterfallGlobalData.h index 8ab9590d0b..8ab9590d0b 100644 --- a/gr-qtgui/lib/waterfallGlobalData.h +++ b/gr-qtgui/include/qtgui/waterfallGlobalData.h diff --git a/gr-qtgui/lib/waterfalldisplayform.h b/gr-qtgui/include/qtgui/waterfalldisplayform.h index 959f2fea68..56efe4ed27 100644 --- a/gr-qtgui/lib/waterfalldisplayform.h +++ b/gr-qtgui/include/qtgui/waterfalldisplayform.h @@ -23,13 +23,13 @@ #ifndef WATERFALL_DISPLAY_FORM_H #define WATERFALL_DISPLAY_FORM_H -#include <spectrumUpdateEvents.h> -#include <WaterfallDisplayPlot.h> +#include <qtgui/spectrumUpdateEvents.h> +#include <qtgui/WaterfallDisplayPlot.h> #include <QtGui/QtGui> #include <vector> #include <filter/firdes.h> -#include "displayform.h" +#include <qtgui/displayform.h> class WaterfallDisplayForm : public DisplayForm { diff --git a/gr-qtgui/lib/CMakeLists.txt b/gr-qtgui/lib/CMakeLists.txt index ff1e64ce31..fb58c8e097 100644 --- a/gr-qtgui/lib/CMakeLists.txt +++ b/gr-qtgui/lib/CMakeLists.txt @@ -20,21 +20,22 @@ ######################################################################## # Setup the QT file generations stuff ######################################################################## +set(qtgui_mod_includedir ${CMAKE_CURRENT_SOURCE_DIR}/../include/qtgui) set(qtgui_moc_hdrs - spectrumdisplayform.h - displayform.h - timedisplayform.h - timerasterdisplayform.h - freqdisplayform.h - constellationdisplayform.h - waterfalldisplayform.h - form_menus.h - DisplayPlot.h - FrequencyDisplayPlot.h - TimeDomainDisplayPlot.h - TimeRasterDisplayPlot.h - WaterfallDisplayPlot.h - ConstellationDisplayPlot.h + ${qtgui_mod_includedir}/spectrumdisplayform.h + ${qtgui_mod_includedir}/displayform.h + ${qtgui_mod_includedir}/timedisplayform.h + ${qtgui_mod_includedir}/timerasterdisplayform.h + ${qtgui_mod_includedir}/freqdisplayform.h + ${qtgui_mod_includedir}/constellationdisplayform.h + ${qtgui_mod_includedir}/waterfalldisplayform.h + ${qtgui_mod_includedir}/form_menus.h + ${qtgui_mod_includedir}/DisplayPlot.h + ${qtgui_mod_includedir}/FrequencyDisplayPlot.h + ${qtgui_mod_includedir}/TimeDomainDisplayPlot.h + ${qtgui_mod_includedir}/TimeRasterDisplayPlot.h + ${qtgui_mod_includedir}/WaterfallDisplayPlot.h + ${qtgui_mod_includedir}/ConstellationDisplayPlot.h ) QT4_WRAP_CPP(qtgui_moc_srcs ${qtgui_moc_hdrs}) QT4_WRAP_UI(qtgui_ui_hdrs spectrumdisplayform.ui) @@ -147,31 +148,3 @@ add_definitions(-DQWT_DLL) #setup QWT library linkage add_library(gnuradio-qtgui SHARED ${qtgui_srcs}) target_link_libraries(gnuradio-qtgui ${qtgui_libs}) GR_LIBRARY_FOO(gnuradio-qtgui RUNTIME_COMPONENT "qtgui_runtime" DEVEL_COMPONENT "qtgui_devel") - -######################################################################## -# Install the header files -######################################################################## -install(FILES - DisplayPlot.h - FrequencyDisplayPlot.h - TimeDomainDisplayPlot.h - TimeRasterDisplayPlot.h - timeRasterGlobalData.h - WaterfallDisplayPlot.h - waterfallGlobalData.h - ConstellationDisplayPlot.h - plot_waterfall.h - plot_raster.h - spectrumdisplayform.h - displayform.h - timedisplayform.h - timerasterdisplayform.h - freqdisplayform.h - constellationdisplayform.h - waterfalldisplayform.h - form_menus.h - SpectrumGUIClass.h - spectrumUpdateEvents.h - DESTINATION ${GR_INCLUDE_DIR}/gnuradio - COMPONENT "qtgui_devel" -) diff --git a/gr-qtgui/lib/ConstellationDisplayPlot.cc b/gr-qtgui/lib/ConstellationDisplayPlot.cc index f3951534a9..7e2f11e6d6 100644 --- a/gr-qtgui/lib/ConstellationDisplayPlot.cc +++ b/gr-qtgui/lib/ConstellationDisplayPlot.cc @@ -23,7 +23,7 @@ #ifndef CONSTELLATION_DISPLAY_PLOT_C #define CONSTELLATION_DISPLAY_PLOT_C -#include <ConstellationDisplayPlot.h> +#include <qtgui/ConstellationDisplayPlot.h> #include <qwt_scale_draw.h> #include <qwt_legend.h> diff --git a/gr-qtgui/lib/DisplayPlot.cc b/gr-qtgui/lib/DisplayPlot.cc index 1c9de3d0ae..227cf9cc9e 100644 --- a/gr-qtgui/lib/DisplayPlot.cc +++ b/gr-qtgui/lib/DisplayPlot.cc @@ -20,7 +20,7 @@ * Boston, MA 02110-1301, USA. */ -#include <DisplayPlot.h> +#include <qtgui/DisplayPlot.h> #include <qwt_scale_draw.h> #include <qwt_legend.h> diff --git a/gr-qtgui/lib/FrequencyDisplayPlot.cc b/gr-qtgui/lib/FrequencyDisplayPlot.cc index e279155544..56e63100c7 100644 --- a/gr-qtgui/lib/FrequencyDisplayPlot.cc +++ b/gr-qtgui/lib/FrequencyDisplayPlot.cc @@ -23,9 +23,9 @@ #ifndef FREQUENCY_DISPLAY_PLOT_C #define FREQUENCY_DISPLAY_PLOT_C -#include <FrequencyDisplayPlot.h> +#include <qtgui/FrequencyDisplayPlot.h> -#include "qtgui_types.h" +#include <qtgui/qtgui_types.h> #include <qwt_scale_draw.h> #include <qwt_legend.h> #include <qwt_legend_item.h> diff --git a/gr-qtgui/lib/SpectrumGUIClass.cc b/gr-qtgui/lib/SpectrumGUIClass.cc index 40c7fb02b6..328eaa9b6f 100644 --- a/gr-qtgui/lib/SpectrumGUIClass.cc +++ b/gr-qtgui/lib/SpectrumGUIClass.cc @@ -23,7 +23,7 @@ #ifndef SPECTRUM_GUI_CLASS_CPP #define SPECTRUM_GUI_CLASS_CPP -#include <SpectrumGUIClass.h> +#include <qtgui/SpectrumGUIClass.h> //Added by qt3to4: #include <QEvent> #include <QCustomEvent> diff --git a/gr-qtgui/lib/TimeDomainDisplayPlot.cc b/gr-qtgui/lib/TimeDomainDisplayPlot.cc index 032da2547d..13e24c2a97 100644 --- a/gr-qtgui/lib/TimeDomainDisplayPlot.cc +++ b/gr-qtgui/lib/TimeDomainDisplayPlot.cc @@ -23,7 +23,7 @@ #ifndef TIME_DOMAIN_DISPLAY_PLOT_C #define TIME_DOMAIN_DISPLAY_PLOT_C -#include <TimeDomainDisplayPlot.h> +#include <qtgui/TimeDomainDisplayPlot.h> #include <qwt_scale_draw.h> #include <qwt_legend.h> diff --git a/gr-qtgui/lib/TimeRasterDisplayPlot.cc b/gr-qtgui/lib/TimeRasterDisplayPlot.cc index 48fb7f7b4a..66b38c52f2 100644 --- a/gr-qtgui/lib/TimeRasterDisplayPlot.cc +++ b/gr-qtgui/lib/TimeRasterDisplayPlot.cc @@ -23,9 +23,9 @@ #ifndef TIMERASTER_DISPLAY_PLOT_C #define TIMERASTER_DISPLAY_PLOT_C -#include <TimeRasterDisplayPlot.h> +#include <qtgui/TimeRasterDisplayPlot.h> -#include "qtgui_types.h" +#include <qtgui/qtgui_types.h> #include <qwt_color_map.h> #include <qwt_scale_draw.h> #include <qwt_legend.h> diff --git a/gr-qtgui/lib/WaterfallDisplayPlot.cc b/gr-qtgui/lib/WaterfallDisplayPlot.cc index 05c89e3ecb..c1b8fd00c3 100644 --- a/gr-qtgui/lib/WaterfallDisplayPlot.cc +++ b/gr-qtgui/lib/WaterfallDisplayPlot.cc @@ -23,9 +23,9 @@ #ifndef WATERFALL_DISPLAY_PLOT_C #define WATERFALL_DISPLAY_PLOT_C -#include <WaterfallDisplayPlot.h> +#include <qtgui/WaterfallDisplayPlot.h> -#include "qtgui_types.h" +#include <qtgui/qtgui_types.h> #include <qwt_color_map.h> #include <qwt_scale_draw.h> #include <qwt_legend.h> diff --git a/gr-qtgui/lib/const_sink_c_impl.h b/gr-qtgui/lib/const_sink_c_impl.h index 81cdb9881f..b5b0858343 100644 --- a/gr-qtgui/lib/const_sink_c_impl.h +++ b/gr-qtgui/lib/const_sink_c_impl.h @@ -26,7 +26,7 @@ #include <qtgui/const_sink_c.h> #include <gruel/high_res_timer.h> #include <gruel/thread.h> -#include <constellationdisplayform.h> +#include <qtgui/constellationdisplayform.h> namespace gr { namespace qtgui { diff --git a/gr-qtgui/lib/constellationdisplayform.cc b/gr-qtgui/lib/constellationdisplayform.cc index e3c65ec41d..bfd17b9c11 100644 --- a/gr-qtgui/lib/constellationdisplayform.cc +++ b/gr-qtgui/lib/constellationdisplayform.cc @@ -22,7 +22,7 @@ #include <cmath> #include <QMessageBox> -#include <constellationdisplayform.h> +#include <qtgui/constellationdisplayform.h> #include <iostream> ConstellationDisplayForm::ConstellationDisplayForm(int nplots, QWidget* parent) diff --git a/gr-qtgui/lib/displayform.cc b/gr-qtgui/lib/displayform.cc index 276539cdde..089d23804d 100644 --- a/gr-qtgui/lib/displayform.cc +++ b/gr-qtgui/lib/displayform.cc @@ -20,7 +20,7 @@ * Boston, MA 02110-1301, USA. */ -#include <displayform.h> +#include <qtgui/displayform.h> #include <iostream> #include <QPixmap> #include <QFileDialog> diff --git a/gr-qtgui/lib/freq_sink_c_impl.h b/gr-qtgui/lib/freq_sink_c_impl.h index 0567b914c8..e82f5c9ee7 100644 --- a/gr-qtgui/lib/freq_sink_c_impl.h +++ b/gr-qtgui/lib/freq_sink_c_impl.h @@ -28,7 +28,7 @@ #include <fft/fft.h> #include <gruel/high_res_timer.h> #include <gruel/thread.h> -#include <freqdisplayform.h> +#include <qtgui/freqdisplayform.h> namespace gr { namespace qtgui { diff --git a/gr-qtgui/lib/freq_sink_f_impl.h b/gr-qtgui/lib/freq_sink_f_impl.h index b79127f3dd..d3d8851c88 100644 --- a/gr-qtgui/lib/freq_sink_f_impl.h +++ b/gr-qtgui/lib/freq_sink_f_impl.h @@ -28,7 +28,7 @@ #include <fft/fft.h> #include <gruel/high_res_timer.h> #include <gruel/thread.h> -#include <freqdisplayform.h> +#include <qtgui/freqdisplayform.h> namespace gr { namespace qtgui { diff --git a/gr-qtgui/lib/freqdisplayform.cc b/gr-qtgui/lib/freqdisplayform.cc index c90e8b7961..adcc09dc4b 100644 --- a/gr-qtgui/lib/freqdisplayform.cc +++ b/gr-qtgui/lib/freqdisplayform.cc @@ -22,7 +22,7 @@ #include <cmath> #include <QMessageBox> -#include <freqdisplayform.h> +#include <qtgui/freqdisplayform.h> #include <iostream> FreqDisplayForm::FreqDisplayForm(int nplots, QWidget* parent) diff --git a/gr-qtgui/lib/plot_raster.cc b/gr-qtgui/lib/plot_raster.cc index 76bff473e9..6d31a2596c 100644 --- a/gr-qtgui/lib/plot_raster.cc +++ b/gr-qtgui/lib/plot_raster.cc @@ -27,7 +27,7 @@ #include "qwt_painter.h" #include "qwt_scale_map.h" #include "qwt_color_map.h" -#include "plot_raster.h" +#include <qtgui/plot_raster.h> #if QWT_VERSION < 0x060000 #include "qwt_double_interval.h" diff --git a/gr-qtgui/lib/plot_waterfall.cc b/gr-qtgui/lib/plot_waterfall.cc index 84915e3f31..5a378767be 100644 --- a/gr-qtgui/lib/plot_waterfall.cc +++ b/gr-qtgui/lib/plot_waterfall.cc @@ -26,7 +26,7 @@ #include "qwt_painter.h" #include "qwt_scale_map.h" #include "qwt_color_map.h" -#include "plot_waterfall.h" +#include <qtgui/plot_waterfall.h> #if QWT_VERSION < 0x060000 #include "qwt_double_interval.h" diff --git a/gr-qtgui/lib/sink_c_impl.h b/gr-qtgui/lib/sink_c_impl.h index ddfb0865d5..83f542b426 100644 --- a/gr-qtgui/lib/sink_c_impl.h +++ b/gr-qtgui/lib/sink_c_impl.h @@ -27,7 +27,7 @@ #include <filter/firdes.h> #include <fft/fft.h> #include <gruel/high_res_timer.h> -#include <SpectrumGUIClass.h> +#include <qtgui/SpectrumGUIClass.h> namespace gr { namespace qtgui { diff --git a/gr-qtgui/lib/sink_f_impl.h b/gr-qtgui/lib/sink_f_impl.h index 394d5c3428..33dab713f6 100644 --- a/gr-qtgui/lib/sink_f_impl.h +++ b/gr-qtgui/lib/sink_f_impl.h @@ -27,7 +27,7 @@ #include <filter/firdes.h> #include <fft/fft.h> #include <gruel/high_res_timer.h> -#include <SpectrumGUIClass.h> +#include <qtgui/SpectrumGUIClass.h> namespace gr { namespace qtgui { diff --git a/gr-qtgui/lib/spectrumUpdateEvents.cc b/gr-qtgui/lib/spectrumUpdateEvents.cc index bda89651b6..82b195d692 100644 --- a/gr-qtgui/lib/spectrumUpdateEvents.cc +++ b/gr-qtgui/lib/spectrumUpdateEvents.cc @@ -23,7 +23,7 @@ #ifndef SPECTRUM_UPDATE_EVENTS_C #define SPECTRUM_UPDATE_EVENTS_C -#include <spectrumUpdateEvents.h> +#include <qtgui/spectrumUpdateEvents.h> SpectrumUpdateEvent::SpectrumUpdateEvent(const float* fftPoints, const uint64_t numFFTDataPoints, diff --git a/gr-qtgui/lib/spectrumdisplayform.cc b/gr-qtgui/lib/spectrumdisplayform.cc index 8d7caebda8..e4ee028668 100644 --- a/gr-qtgui/lib/spectrumdisplayform.cc +++ b/gr-qtgui/lib/spectrumdisplayform.cc @@ -23,8 +23,8 @@ #include <cmath> #include <QColorDialog> #include <QMessageBox> -#include <spectrumdisplayform.h> -#include "qtgui_types.h" +#include <qtgui/spectrumdisplayform.h> +#include <qtgui/qtgui_types.h> SpectrumDisplayForm::SpectrumDisplayForm(QWidget* parent) : QWidget(parent) diff --git a/gr-qtgui/lib/spectrumdisplayform.ui b/gr-qtgui/lib/spectrumdisplayform.ui index f1e1f08f98..e1ebfa8197 100644 --- a/gr-qtgui/lib/spectrumdisplayform.ui +++ b/gr-qtgui/lib/spectrumdisplayform.ui @@ -522,10 +522,10 @@ <tabstop>WaterfallMinimumIntensitySlider</tabstop> </tabstops> <includes> - <include location="global">SpectrumGUIClass.h</include> - <include location="global">FrequencyDisplayPlot.h</include> - <include location="global">WaterfallDisplayPlot.h</include> - <include location="global">TimeDomainDisplayPlot.h</include> + <include location="global">qtgui/SpectrumGUIClass.h</include> + <include location="global">qtgui/FrequencyDisplayPlot.h</include> + <include location="global">qtgui/WaterfallDisplayPlot.h</include> + <include location="global">qtgui/TimeDomainDisplayPlot.h</include> <include location="global">qvalidator.h</include> <include location="global">vector</include> <include location="local">qwt_slider.h</include> diff --git a/gr-qtgui/lib/timeRasterGlobalData.cc b/gr-qtgui/lib/timeRasterGlobalData.cc index 556196f644..6ebef5f47e 100644 --- a/gr-qtgui/lib/timeRasterGlobalData.cc +++ b/gr-qtgui/lib/timeRasterGlobalData.cc @@ -23,7 +23,7 @@ #ifndef TIMERASTER_GLOBAL_DATA_CPP #define TIMERASTER_GLOBAL_DATA_CPP -#include <timeRasterGlobalData.h> +#include <qtgui/timeRasterGlobalData.h> #include <cstdio> #include <cmath> #include <iostream> diff --git a/gr-qtgui/lib/time_raster_sink_b_impl.h b/gr-qtgui/lib/time_raster_sink_b_impl.h index 68dfa25aac..93d8819fdb 100644 --- a/gr-qtgui/lib/time_raster_sink_b_impl.h +++ b/gr-qtgui/lib/time_raster_sink_b_impl.h @@ -28,7 +28,7 @@ #include <fft/fft.h> #include <gruel/high_res_timer.h> #include <gruel/thread.h> -#include <timerasterdisplayform.h> +#include <qtgui/timerasterdisplayform.h> namespace gr { namespace qtgui { diff --git a/gr-qtgui/lib/time_raster_sink_c_impl.h b/gr-qtgui/lib/time_raster_sink_c_impl.h index f3594d58a5..0e95733853 100644 --- a/gr-qtgui/lib/time_raster_sink_c_impl.h +++ b/gr-qtgui/lib/time_raster_sink_c_impl.h @@ -28,7 +28,7 @@ #include <fft/fft.h> #include <gruel/high_res_timer.h> #include <gruel/thread.h> -#include <time_rasterdisplayform.h> +#include <qtgui/time_rasterdisplayform.h> namespace gr { namespace qtgui { diff --git a/gr-qtgui/lib/time_raster_sink_f_impl.h b/gr-qtgui/lib/time_raster_sink_f_impl.h index 1d7d791202..fcaab8126a 100644 --- a/gr-qtgui/lib/time_raster_sink_f_impl.h +++ b/gr-qtgui/lib/time_raster_sink_f_impl.h @@ -28,7 +28,7 @@ #include <fft/fft.h> #include <gruel/high_res_timer.h> #include <gruel/thread.h> -#include <timerasterdisplayform.h> +#include <qtgui/timerasterdisplayform.h> namespace gr { namespace qtgui { diff --git a/gr-qtgui/lib/time_sink_c_impl.h b/gr-qtgui/lib/time_sink_c_impl.h index 96bdf937b1..5a52a91316 100644 --- a/gr-qtgui/lib/time_sink_c_impl.h +++ b/gr-qtgui/lib/time_sink_c_impl.h @@ -24,7 +24,7 @@ #define INCLUDED_QTGUI_TIME_SINK_C_IMPL_H #include <qtgui/time_sink_c.h> -#include <timedisplayform.h> +#include <qtgui/timedisplayform.h> #include <gruel/thread.h> #include <gruel/high_res_timer.h> diff --git a/gr-qtgui/lib/time_sink_f_impl.h b/gr-qtgui/lib/time_sink_f_impl.h index 522511da01..3d4f6417a6 100644 --- a/gr-qtgui/lib/time_sink_f_impl.h +++ b/gr-qtgui/lib/time_sink_f_impl.h @@ -24,7 +24,7 @@ #define INCLUDED_QTGUI_TIME_SINK_F_IMPL_H #include <qtgui/time_sink_f.h> -#include <timedisplayform.h> +#include <qtgui/timedisplayform.h> #include <gruel/thread.h> #include <gruel/high_res_timer.h> diff --git a/gr-qtgui/lib/timedisplayform.cc b/gr-qtgui/lib/timedisplayform.cc index 5e1fbfb570..3ae6f93d0c 100644 --- a/gr-qtgui/lib/timedisplayform.cc +++ b/gr-qtgui/lib/timedisplayform.cc @@ -22,7 +22,7 @@ #include <cmath> #include <QMessageBox> -#include <timedisplayform.h> +#include <qtgui/timedisplayform.h> #include <iostream> TimeDisplayForm::TimeDisplayForm(int nplots, QWidget* parent) diff --git a/gr-qtgui/lib/timerasterdisplayform.cc b/gr-qtgui/lib/timerasterdisplayform.cc index ed17cf45ce..50c63ad545 100644 --- a/gr-qtgui/lib/timerasterdisplayform.cc +++ b/gr-qtgui/lib/timerasterdisplayform.cc @@ -23,7 +23,7 @@ #include <cmath> #include <QColorDialog> #include <QMessageBox> -#include <timerasterdisplayform.h> +#include <qtgui/timerasterdisplayform.h> #include <iostream> TimeRasterDisplayForm::TimeRasterDisplayForm(int nplots, diff --git a/gr-qtgui/lib/waterfallGlobalData.cc b/gr-qtgui/lib/waterfallGlobalData.cc index 8eb175b2c9..2085acf8fc 100644 --- a/gr-qtgui/lib/waterfallGlobalData.cc +++ b/gr-qtgui/lib/waterfallGlobalData.cc @@ -23,7 +23,7 @@ #ifndef WATERFALL_GLOBAL_DATA_CPP #define WATERFALL_GLOBAL_DATA_CPP -#include <waterfallGlobalData.h> +#include <qtgui/waterfallGlobalData.h> #include <cstdio> WaterfallData::WaterfallData(const double minimumFrequency, diff --git a/gr-qtgui/lib/waterfall_sink_c_impl.h b/gr-qtgui/lib/waterfall_sink_c_impl.h index 1d709c6c5f..d9a90875af 100644 --- a/gr-qtgui/lib/waterfall_sink_c_impl.h +++ b/gr-qtgui/lib/waterfall_sink_c_impl.h @@ -28,7 +28,7 @@ #include <fft/fft.h> #include <gruel/high_res_timer.h> #include <gruel/thread.h> -#include <waterfalldisplayform.h> +#include <qtgui/waterfalldisplayform.h> namespace gr { namespace qtgui { diff --git a/gr-qtgui/lib/waterfall_sink_f_impl.h b/gr-qtgui/lib/waterfall_sink_f_impl.h index 6185a25397..c204ef1509 100644 --- a/gr-qtgui/lib/waterfall_sink_f_impl.h +++ b/gr-qtgui/lib/waterfall_sink_f_impl.h @@ -23,13 +23,12 @@ #ifndef INCLUDED_QTGUI_WATERFALL_SINK_F_IMPL_H #define INCLUDED_QTGUI_WATERFALL_SINK_F_IMPL_H - #include <qtgui/waterfall_sink_f.h> #include <filter/firdes.h> #include <fft/fft.h> #include <gruel/high_res_timer.h> #include <gruel/thread.h> -#include <waterfalldisplayform.h> +#include <qtgui/waterfalldisplayform.h> namespace gr { namespace qtgui { diff --git a/gr-qtgui/lib/waterfalldisplayform.cc b/gr-qtgui/lib/waterfalldisplayform.cc index e42e63fbc4..23b2a486bb 100644 --- a/gr-qtgui/lib/waterfalldisplayform.cc +++ b/gr-qtgui/lib/waterfalldisplayform.cc @@ -23,7 +23,7 @@ #include <cmath> #include <QColorDialog> #include <QMessageBox> -#include <waterfalldisplayform.h> +#include <qtgui/waterfalldisplayform.h> #include <iostream> WaterfallDisplayForm::WaterfallDisplayForm(int nplots, QWidget* parent) diff --git a/gr-shd/apps/shd_rx_cfile b/gr-shd/apps/shd_rx_cfile index ceae858343..37eec05e0e 100755 --- a/gr-shd/apps/shd_rx_cfile +++ b/gr-shd/apps/shd_rx_cfile @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2011 Free Software Foundation, Inc. +# Copyright 2011,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -82,10 +82,10 @@ class rx_cfile_block(gr.top_block): self.connect(self._src, self._sink) else: if options.output_shorts: - self._head = gr.head(gr.sizeof_short*2, + self._head = blocks.head(gr.sizeof_short*2, int(options.nsamples)) else: - self._head = gr.head(gr.sizeof_gr_complex, + self._head = blocks.head(gr.sizeof_gr_complex, int(options.nsamples)) self.connect(self._src, self._head, self._sink) diff --git a/gr-trellis/doc/gr-trellis.xml b/gr-trellis/doc/gr-trellis.xml index 42bd54b32c..6ffbb9ec2c 100644 --- a/gr-trellis/doc/gr-trellis.xml +++ b/gr-trellis/doc/gr-trellis.xml @@ -570,8 +570,8 @@ and an initial state (which is set to 0 in this example). </para> <programlisting> 15 # TX - 16 src = gr.lfsr_32k_source_s() - 17 src_head = gr.head (gr.sizeof_short,Kb/16) # packet size in shorts + 16 src = blocks.lfsr_32k_source_s() + 17 src_head = blocks.head (gr.sizeof_short,Kb/16) # packet size in shorts 18 s2fsmi = blocks.packed_to_unpacked_ss(bitspersymbol,gr.GR_MSB_FIRST) # unpack shorts to symbols compatible with the FSM input cardinality 19 enc = trellis.encoder_ss(f,0) # initial state = 0 </programlisting> @@ -647,7 +647,7 @@ are then packed to shorts and compared with the transmitted sequence. <programlisting> 28 va = trellis.viterbi_s(f,K,0,-1) # Put -1 if the Initial/Final states are not set. 29 fsmi2s = blocks.unpacked_to_packed_ss(bitspersymbol,gr.GR_MSB_FIRST) # pack FSM input symbols to shorts - 30 dst = gr.check_lfsr_32k_s(); + 30 dst = blocks.check_lfsr_32k_s(); </programlisting> @@ -803,7 +803,7 @@ L being the channel length. This is sufficient to drive the initial and final st 22 for i in range(L): # first/last L symbols set to 0 23 packet[i] = 0 24 packet[len(packet)-i-1] = 0 - 25 src = gr.vector_source_s(packet,False) + 25 src = blocks.vector_source_s(packet,False) 26 mod = digital.chunks_to_symbols_sf(modulation[1],modulation[0]) </programlisting> @@ -813,7 +813,7 @@ The modulated symbols are filtered by the ISI channel and AWGN with appropriate </para> <programlisting> 28 # CHANNEL - 29 isi = gr.fir_filter_fff(1,channel) + 29 isi = filter.fir_filter_fff(1,channel) 30 add = blocks.add_ff() 31 noise = analog.noise_source_f(analog.GR_GAUSSIAN,math.sqrt(N0/2),seed) </programlisting> @@ -826,11 +826,11 @@ Also note that the first L observations are irrelevant and thus can be skipped. </para> <programlisting> 33 # RX - 34 skip = gr.skiphead(gr.sizeof_float, L) # skip the first L samples since you know they are coming from the L zero symbols + 34 skip = blocks.skiphead(gr.sizeof_float, L) # skip the first L samples since you know they are coming from the L zero symbols 35 #metrics = trellis.metrics_f(f.O(),dimensionality,tot_constellation,trellis.TRELLIS_EUCLIDEAN) # data preprocessing to generate metrics for Viterbi 36 #va = trellis.viterbi_s(f,K+L,0,0) # Put -1 if the Initial/Final states are not set. 37 va = trellis.viterbi_combined_s(f,K+L,0,0,dimensionality,tot_constellation,trellis.TRELLIS_EUCLIDEAN) # using viterbi_combined_s instead of metrics_f/viterbi_s allows larger packet lengths because metrics_f is complaining for not being able to allocate large buffers. This is due to the large f.O() in this application... - 38 dst = gr.vector_sink_s() + 38 dst = blocks.vector_sink_s() </programlisting> <para> diff --git a/gr-trellis/doc/test_tcm.py b/gr-trellis/doc/test_tcm.py index aa84f55bee..61ab00f1c8 100644 --- a/gr-trellis/doc/test_tcm.py +++ b/gr-trellis/doc/test_tcm.py @@ -19,8 +19,8 @@ def run_test (f,Kb,bitspersymbol,K,dimensionality,constellation,N0,seed): tb = gr.top_block () # TX - src = gr.lfsr_32k_source_s() - src_head = gr.head (gr.sizeof_short,Kb/16) # packet size in shorts + src = blocks.lfsr_32k_source_s() + src_head = blocks.head (gr.sizeof_short,Kb/16) # packet size in shorts s2fsmi = blocks.packed_to_unpacked_ss(bitspersymbol,gr.GR_MSB_FIRST) # unpack shorts to symbols compatible with the FSM input cardinality enc = trellis.encoder_ss(f,0) # initial state = 0 mod = digital.chunks_to_symbols_sf(constellation,dimensionality) @@ -33,7 +33,7 @@ def run_test (f,Kb,bitspersymbol,K,dimensionality,constellation,N0,seed): metrics = trellis.metrics_f(f.O(),dimensionality,constellation,digital.TRELLIS_EUCLIDEAN) # data preprocessing to generate metrics for Viterbi va = trellis.viterbi_s(f,K,0,-1) # Put -1 if the Initial/Final states are not set. fsmi2s = blocks.unpacked_to_packed_ss(bitspersymbol,gr.GR_MSB_FIRST) # pack FSM input symbols to shorts - dst = gr.check_lfsr_32k_s(); + dst = blocks.check_lfsr_32k_s(); tb.connect (src,src_head,s2fsmi,enc,mod) tb.connect (mod,(add,0)) diff --git a/gr-trellis/doc/test_tcm.py.xml b/gr-trellis/doc/test_tcm.py.xml index 96a8042ff7..77009b5859 100644 --- a/gr-trellis/doc/test_tcm.py.xml +++ b/gr-trellis/doc/test_tcm.py.xml @@ -15,8 +15,8 @@ 13 tb = gr.top_block () 14 15 # TX - 16 src = gr.lfsr_32k_source_s() - 17 src_head = gr.head (gr.sizeof_short,Kb/16) # packet size in shorts + 16 src = blocks.lfsr_32k_source_s() + 17 src_head = blocks.head (gr.sizeof_short,Kb/16) # packet size in shorts 18 s2fsmi = blocks.packed_to_unpacked_ss(bitspersymbol,gr.GR_MSB_FIRST) # unpack shorts to symbols compatible with the FSM input cardinality 19 enc = trellis.encoder_ss(f,0) # initial state = 0 20 mod = digital.chunks_to_symbols_sf(constellation,dimensionality) @@ -29,7 +29,7 @@ 27 metrics = trellis.metrics_f(f.O(),dimensionality,constellation,trellis.TRELLIS_EUCLIDEAN) # data preprocessing to generate metrics for Viterbi 28 va = trellis.viterbi_s(f,K,0,-1) # Put -1 if the Initial/Final states are not set. 29 fsmi2s = blocks.unpacked_to_packed_ss(bitspersymbol,gr.GR_MSB_FIRST) # pack FSM input symbols to shorts - 30 dst = gr.check_lfsr_32k_s(); + 30 dst = blocks.check_lfsr_32k_s(); 31 32 tb.connect (src,src_head,s2fsmi,enc,mod) 33 tb.connect (mod,(add,0)) diff --git a/gr-trellis/doc/test_viterbi_equalization1.py b/gr-trellis/doc/test_viterbi_equalization1.py index d53e2b3304..c1a831d0bb 100755 --- a/gr-trellis/doc/test_viterbi_equalization1.py +++ b/gr-trellis/doc/test_viterbi_equalization1.py @@ -28,7 +28,7 @@ def run_test (f,Kb,bitspersymbol,K,channel,modulation,dimensionality,tot_constel for i in range(L): # first/last L symbols set to 0 packet[i] = 0 packet[len(packet)-i-1] = 0 - src = gr.vector_source_s(packet,False) + src = blocks.vector_source_s(packet,False) mod = digital.chunks_to_symbols_sf(modulation[1],modulation[0]) # CHANNEL @@ -37,11 +37,11 @@ def run_test (f,Kb,bitspersymbol,K,channel,modulation,dimensionality,tot_constel noise = analog.noise_source_f(analog.GR_GAUSSIAN,math.sqrt(N0/2),seed) # RX - skip = gr.skiphead(gr.sizeof_float, L) # skip the first L samples since you know they are coming from the L zero symbols + skip = blocks.skiphead(gr.sizeof_float, L) # skip the first L samples since you know they are coming from the L zero symbols #metrics = trellis.metrics_f(f.O(),dimensionality,tot_constellation,digital.TRELLIS_EUCLIDEAN) # data preprocessing to generate metrics for Viterbi #va = trellis.viterbi_s(f,K+L,0,0) # Put -1 if the Initial/Final states are not set. va = trellis.viterbi_combined_s(f,K+L,0,0,dimensionality,tot_constellation,digital.TRELLIS_EUCLIDEAN) # using viterbi_combined_s instead of metrics_f/viterbi_s allows larger packet lengths because metrics_f is complaining for not being able to allocate large buffers. This is due to the large f.O() in this application... - dst = gr.vector_sink_s() + dst = blocks.vector_sink_s() tb.connect (src,mod) tb.connect (mod,isi,(add,0)) diff --git a/gr-trellis/doc/test_viterbi_equalization1.py.xml b/gr-trellis/doc/test_viterbi_equalization1.py.xml index 5aca46ab35..9179f4f156 100644 --- a/gr-trellis/doc/test_viterbi_equalization1.py.xml +++ b/gr-trellis/doc/test_viterbi_equalization1.py.xml @@ -24,7 +24,7 @@ 22 for i in range(L): # first/last L symbols set to 0 23 packet[i] = 0 24 packet[len(packet)-i-1] = 0 - 25 src = gr.vector_source_s(packet,False) + 25 src = blocks.vector_source_s(packet,False) 26 mod = digital.chunks_to_symbols_sf(modulation[1],modulation[0]) 27 28 # CHANNEL @@ -33,11 +33,11 @@ 31 noise = analog.noise_source_f(analog.GR_GAUSSIAN,math.sqrt(N0/2),seed) 32 33 # RX - 34 skip = gr.skiphead(gr.sizeof_float, L) # skip the first L samples since you know they are coming from the L zero symbols + 34 skip = blocks.skiphead(gr.sizeof_float, L) # skip the first L samples since you know they are coming from the L zero symbols 35 #metrics = trellis.metrics_f(f.O(),dimensionality,tot_constellation,trellis.TRELLIS_EUCLIDEAN) # data preprocessing to generate metrics for Viterbi 36 #va = trellis.viterbi_s(f,K+L,0,0) # Put -1 if the Initial/Final states are not set. 37 va = trellis.viterbi_combined_s(f,K+L,0,0,dimensionality,tot_constellation,trellis.TRELLIS_EUCLIDEAN) # using viterbi_combined_s instead of metrics_f/viterbi_s allows larger packet lengths because metrics_f is complaining for not being able to allocate large buffers. This is due to the large f.O() in this application... - 38 dst = gr.vector_sink_s() + 38 dst = blocks.vector_sink_s() 39 40 tb.connect (src,mod) 41 tb.connect (mod,isi,(add,0)) diff --git a/gr-trellis/examples/grc/interference_cancellation.grc b/gr-trellis/examples/grc/interference_cancellation.grc index 29452311c6..4555a244a9 100644 --- a/gr-trellis/examples/grc/interference_cancellation.grc +++ b/gr-trellis/examples/grc/interference_cancellation.grc @@ -969,7 +969,7 @@ </param> <param> <key>trig_mode</key> - <value>gr.gr_TRIG_MODE_AUTO</value> + <value>wxgui.TRIG_MODE_AUTO</value> </param> <param> <key>y_axis_label</key> diff --git a/gr-trellis/examples/grc/pccc.grc b/gr-trellis/examples/grc/pccc.grc index 359cfefc83..c0e587a09e 100644 --- a/gr-trellis/examples/grc/pccc.grc +++ b/gr-trellis/examples/grc/pccc.grc @@ -389,7 +389,7 @@ </param> <param> <key>trig_mode</key> - <value>gr.gr_TRIG_MODE_AUTO</value> + <value>wxgui.TRIG_MODE_AUTO</value> </param> <param> <key>y_axis_label</key> diff --git a/gr-trellis/examples/grc/pccc1.grc b/gr-trellis/examples/grc/pccc1.grc index 8f58404794..4507cae890 100644 --- a/gr-trellis/examples/grc/pccc1.grc +++ b/gr-trellis/examples/grc/pccc1.grc @@ -389,7 +389,7 @@ </param> <param> <key>trig_mode</key> - <value>gr.gr_TRIG_MODE_AUTO</value> + <value>wxgui.TRIG_MODE_AUTO</value> </param> <param> <key>y_axis_label</key> diff --git a/gr-trellis/examples/grc/sccc.grc b/gr-trellis/examples/grc/sccc.grc index ee532da9fe..ec84665c14 100644 --- a/gr-trellis/examples/grc/sccc.grc +++ b/gr-trellis/examples/grc/sccc.grc @@ -395,7 +395,7 @@ </param> <param> <key>trig_mode</key> - <value>gr.gr_TRIG_MODE_AUTO</value> + <value>wxgui.TRIG_MODE_AUTO</value> </param> <param> <key>y_axis_label</key> diff --git a/gr-trellis/examples/grc/sccc1.grc b/gr-trellis/examples/grc/sccc1.grc index fa6506ba18..332ec6bdd7 100644 --- a/gr-trellis/examples/grc/sccc1.grc +++ b/gr-trellis/examples/grc/sccc1.grc @@ -631,7 +631,7 @@ </param> <param> <key>trig_mode</key> - <value>gr.gr_TRIG_MODE_AUTO</value> + <value>wxgui.TRIG_MODE_AUTO</value> </param> <param> <key>y_axis_label</key> diff --git a/gr-trellis/examples/python/test_cpm.py b/gr-trellis/examples/python/test_cpm.py index 8d1e2024c1..99b75a7dd1 100755 --- a/gr-trellis/examples/python/test_cpm.py +++ b/gr-trellis/examples/python/test_cpm.py @@ -93,7 +93,7 @@ def run_test(seed,blocksize): ################################################## # Blocks ################################################## - random_source_x_0 = gr.vector_source_b(data.tolist(), False) + random_source_x_0 = blocks.vector_source_b(data.tolist(), False) digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bf((-1, 1), 1) filter_interp_fir_filter_xxx_0 = filter.interp_fir_filter_fff(Q, p) analog_frequency_modulator_fc_0 = analog.frequency_modulator_fc(2*math.pi*h*(1.0/Q)) @@ -107,11 +107,11 @@ def run_test(seed,blocksize): filter_fir_filter_xxx_0_0 = filter.fir_filter_ccc(Q, MF[0].conjugate()) filter_fir_filter_xxx_0_0_0 = filter.fir_filter_ccc(Q, MF[1].conjugate()) blocks_streams_to_stream_0 = blocks.streams_to_stream(gr.sizeof_gr_complex*1, int(N)) - gr_skiphead_0 = gr.skiphead(gr.sizeof_gr_complex*1, int(N*(1+0))) + blocks_skiphead_0 = blocks.skiphead(gr.sizeof_gr_complex*1, int(N*(1+0))) viterbi = trellis.viterbi_combined_cb(f, head+blocksize+tail, 0, -1, int(N), constellation, digital.TRELLIS_EUCLIDEAN) - gr_vector_sink_x_0 = gr.vector_sink_b() + blocks_vector_sink_x_0 = blocks.vector_sink_b() ################################################## # Connections @@ -127,13 +127,13 @@ def run_test(seed,blocksize): tb.connect((blocks_multiply_vxx_0, 0), (filter_fir_filter_xxx_0_0_0, 0)) tb.connect((filter_fir_filter_xxx_0_0, 0), (blocks_streams_to_stream_0, 0)) tb.connect((filter_fir_filter_xxx_0_0_0, 0), (blocks_streams_to_stream_0, 1)) - tb.connect((blocks_streams_to_stream_0, 0), (gr_skiphead_0, 0)) - tb.connect((gr_skiphead_0, 0), (viterbi, 0)) - tb.connect((viterbi, 0), (gr_vector_sink_x_0, 0)) + tb.connect((blocks_streams_to_stream_0, 0), (blocks_skiphead_0, 0)) + tb.connect((blocks_skiphead_0, 0), (viterbi, 0)) + tb.connect((viterbi, 0), (blocks_vector_sink_x_0, 0)) tb.run() - dataest = gr_vector_sink_x_0.data() + dataest = blocks_vector_sink_x_0.data() #print data #print numpy.array(dataest) perr = 0 diff --git a/gr-trellis/examples/python/test_pccc_turbo1.py b/gr-trellis/examples/python/test_pccc_turbo1.py index bb596f1818..7104aa5039 100755 --- a/gr-trellis/examples/python/test_pccc_turbo1.py +++ b/gr-trellis/examples/python/test_pccc_turbo1.py @@ -19,12 +19,12 @@ def run_test (fo,fi,interleaver,Kb,bitspersymbol,K,dimensionality,constellation, # TX - src = gr.lfsr_32k_source_s() - src_head = gr.head (gr.sizeof_short,Kb/16) # packet size in shorts + src = blocks.lfsr_32k_source_s() + src_head = blocks.head (gr.sizeof_short,Kb/16) # packet size in shorts s2fsmi = blocks.packed_to_unpacked_ss(bitspersymbol,gr.GR_MSB_FIRST) # unpack shorts to symbols compatible with the outer FSM input cardinality - #src = gr.vector_source_s([0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1],False) + #src = blocks.vector_source_s([0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1],False) enc = trellis.pccc_encoder_ss(fo,0,fi,0,interleaver,K) - code = gr.vector_sink_s() + code = blocks.vector_sink_s() mod = digital.chunks_to_symbols_sf(constellation,dimensionality) # CHANNEL @@ -37,7 +37,7 @@ def run_test (fo,fi,interleaver,Kb,bitspersymbol,K,dimensionality,constellation, dec = trellis.pccc_decoder_s(fo,0,-1,fi,0,-1,interleaver,K,IT,trellis.TRELLIS_MIN_SUM) fsmi2s = blocks.unpacked_to_packed_ss(bitspersymbol,gr.GR_MSB_FIRST) # pack FSM input symbols to shorts - dst = gr.check_lfsr_32k_s() + dst = blocks.check_lfsr_32k_s() tb.connect (src,src_head,s2fsmi,enc,mod) #tb.connect (src,enc,mod) diff --git a/gr-trellis/examples/python/test_sccc_hard.py b/gr-trellis/examples/python/test_sccc_hard.py index ec1fdd1bc5..83393df4dc 100755 --- a/gr-trellis/examples/python/test_sccc_hard.py +++ b/gr-trellis/examples/python/test_sccc_hard.py @@ -19,8 +19,8 @@ def run_test (fo,fi,interleaver,Kb,bitspersymbol,K,dimensionality,constellation, # TX - src = gr.lfsr_32k_source_s() - src_head = gr.head (gr.sizeof_short,Kb/16) # packet size in shorts + src = blocks.lfsr_32k_source_s() + src_head = blocks.head(gr.sizeof_short,Kb/16) # packet size in shorts s2fsmi = blocks.packed_to_unpacked_ss(bitspersymbol,gr.GR_MSB_FIRST) # unpack shorts to symbols compatible with the outer FSM input cardinality enc_out = trellis.encoder_ss(fo,0) # initial state = 0 inter = trellis.permutation(interleaver.K(),interleaver.INTER(),1,gr.sizeof_short) @@ -38,7 +38,7 @@ def run_test (fo,fi,interleaver,Kb,bitspersymbol,K,dimensionality,constellation, metrics_out = trellis.metrics_s(fo.O(),1,[0,1,2,3],digital.TRELLIS_HARD_SYMBOL) # data preprocessing to generate metrics for outer Viterbi (hard decisions) va_out = trellis.viterbi_s(fo,K,0,-1) # Put -1 if the Initial/Final states are not set. fsmi2s = blocks.unpacked_to_packed_ss(bitspersymbol,gr.GR_MSB_FIRST) # pack FSM input symbols to shorts - dst = gr.check_lfsr_32k_s() + dst = blocks.check_lfsr_32k_s() tb.connect (src,src_head,s2fsmi,enc_out,inter,enc_in,mod) tb.connect (mod,(add,0)) diff --git a/gr-trellis/examples/python/test_sccc_soft.py b/gr-trellis/examples/python/test_sccc_soft.py index f663c9befd..25d26e0025 100755 --- a/gr-trellis/examples/python/test_sccc_soft.py +++ b/gr-trellis/examples/python/test_sccc_soft.py @@ -19,8 +19,8 @@ def run_test (fo,fi,interleaver,Kb,bitspersymbol,K,dimensionality,constellation, # TX - src = gr.lfsr_32k_source_s() - src_head = gr.head (gr.sizeof_short,Kb/16) # packet size in shorts + src = blocks.lfsr_32k_source_s() + src_head = blocks.head (gr.sizeof_short,Kb/16) # packet size in shorts s2fsmi = blocks.packed_to_unpacked_ss(bitspersymbol,gr.GR_MSB_FIRST) # unpack shorts to symbols compatible with the outer FSM input cardinality enc_out = trellis.encoder_ss(fo,0) # initial state = 0 inter = trellis.permutation(interleaver.K(),interleaver.INTER(),1,gr.sizeof_short) @@ -33,12 +33,12 @@ def run_test (fo,fi,interleaver,Kb,bitspersymbol,K,dimensionality,constellation, # RX metrics_in = trellis.metrics_f(fi.O(),dimensionality,constellation,digital.TRELLIS_EUCLIDEAN) # data preprocessing to generate metrics for innner Viterbi - gnd = gr.vector_source_f([0],True); + gnd = blocks.vector_source_f([0],True); siso_in = trellis.siso_f(fi,K,0,-1,True,False,trellis.TRELLIS_MIN_SUM) # Put -1 if the Initial/Final states are not set. deinter = trellis.permutation(interleaver.K(),interleaver.DEINTER(),fi.I(),gr.sizeof_float) va_out = trellis.viterbi_s(fo,K,0,-1) # Put -1 if the Initial/Final states are not set. fsmi2s = blocks.unpacked_to_packed_ss(bitspersymbol,gr.GR_MSB_FIRST) # pack FSM input symbols to shorts - dst = gr.check_lfsr_32k_s() + dst = blocks.check_lfsr_32k_s() tb.connect (src,src_head,s2fsmi,enc_out,inter,enc_in,mod) tb.connect (mod,(add,0)) diff --git a/gr-trellis/examples/python/test_sccc_turbo.py b/gr-trellis/examples/python/test_sccc_turbo.py index cd974e9941..08004e8a0d 100755 --- a/gr-trellis/examples/python/test_sccc_turbo.py +++ b/gr-trellis/examples/python/test_sccc_turbo.py @@ -17,7 +17,7 @@ except ImportError: def make_rx(tb,fo,fi,dimensionality,constellation,K,interleaver,IT,Es,N0,type): metrics_in = trellis.metrics_f(fi.O(),dimensionality,constellation,digital.TRELLIS_EUCLIDEAN) # data preprocessing to generate metrics for innner Viterbi scale = blocks.multiply_const_ff(1.0/N0) - gnd = gr.vector_source_f([0],True); + gnd = blocks.vector_source_f([0],True); inter=[] deinter=[] @@ -59,8 +59,8 @@ def run_test (fo,fi,interleaver,Kb,bitspersymbol,K,dimensionality,constellation, # TX - src = gr.lfsr_32k_source_s() - src_head = gr.head (gr.sizeof_short,Kb/16) # packet size in shorts + src = blocks.lfsr_32k_source_s() + src_head = blocks.head(gr.sizeof_short,Kb/16) # packet size in shorts s2fsmi = blocks.packed_to_unpacked_ss(bitspersymbol,gr.GR_MSB_FIRST) # unpack shorts to symbols compatible with the outer FSM input cardinality enc_out = trellis.encoder_ss(fo,0) # initial state = 0 inter = trellis.permutation(interleaver.K(),interleaver.INTER(),1,gr.sizeof_short) @@ -75,7 +75,7 @@ def run_test (fo,fi,interleaver,Kb,bitspersymbol,K,dimensionality,constellation, (head,tail) = make_rx(tb,fo,fi,dimensionality,constellation,K,interleaver,IT,Es,N0,trellis.TRELLIS_MIN_SUM) #(head,tail) = make_rx(tb,fo,fi,dimensionality,constellation,K,interleaver,IT,Es,N0,trellis.TRELLIS_SUM_PRODUCT) fsmi2s = blocks.unpacked_to_packed_ss(bitspersymbol,gr.GR_MSB_FIRST) # pack FSM input symbols to shorts - dst = gr.check_lfsr_32k_s() + dst = blocks.check_lfsr_32k_s() tb.connect (src,src_head,s2fsmi,enc_out,inter,enc_in,mod) tb.connect (mod,(add,0)) diff --git a/gr-trellis/examples/python/test_sccc_turbo1.py b/gr-trellis/examples/python/test_sccc_turbo1.py index 93833ec7df..528a79d011 100755 --- a/gr-trellis/examples/python/test_sccc_turbo1.py +++ b/gr-trellis/examples/python/test_sccc_turbo1.py @@ -18,8 +18,8 @@ def run_test (fo,fi,interleaver,Kb,bitspersymbol,K,dimensionality,constellation, tb = gr.top_block () # TX - src = gr.lfsr_32k_source_s() - src_head = gr.head (gr.sizeof_short,Kb/16) # packet size in shorts + src = blocks.lfsr_32k_source_s() + src_head = blocks.head(gr.sizeof_short,Kb/16) # packet size in shorts s2fsmi = blocks.packed_to_unpacked_ss(bitspersymbol,gr.GR_MSB_FIRST) # unpack shorts to symbols compatible with the outer FSM input cardinality enc = trellis.sccc_encoder_ss(fo,0,fi,0,interleaver,K) mod = digital.chunks_to_symbols_sf(constellation,dimensionality) @@ -31,7 +31,7 @@ def run_test (fo,fi,interleaver,Kb,bitspersymbol,K,dimensionality,constellation, # RX dec = trellis.sccc_decoder_combined_fs(fo,0,-1,fi,0,-1,interleaver,K,IT,trellis.TRELLIS_MIN_SUM,dimensionality,constellation,digital.TRELLIS_EUCLIDEAN,1.0) fsmi2s = blocks.unpacked_to_packed_ss(bitspersymbol,gr.GR_MSB_FIRST) # pack FSM input symbols to shorts - dst = gr.check_lfsr_32k_s() + dst = blocks.check_lfsr_32k_s() #tb.connect (src,src_head,s2fsmi,enc_out,inter,enc_in,mod) tb.connect (src,src_head,s2fsmi,enc,mod) diff --git a/gr-trellis/examples/python/test_sccc_turbo2.py b/gr-trellis/examples/python/test_sccc_turbo2.py index 116a2ca6b2..d7f26c4e13 100755 --- a/gr-trellis/examples/python/test_sccc_turbo2.py +++ b/gr-trellis/examples/python/test_sccc_turbo2.py @@ -18,8 +18,8 @@ def run_test (fo,fi,interleaver,Kb,bitspersymbol,K,dimensionality,constellation, tb = gr.top_block () # TX - src = gr.lfsr_32k_source_s() - src_head = gr.head (gr.sizeof_short,Kb/16) # packet size in shorts + src = blocks.lfsr_32k_source_s() + src_head = blocks.head(gr.sizeof_short,Kb/16) # packet size in shorts s2fsmi = blocks.packed_to_unpacked_ss(bitspersymbol,gr.GR_MSB_FIRST) # unpack shorts to symbols compatible with the outer FSM input cardinality enc = trellis.sccc_encoder_ss(fo,0,fi,0,interleaver,K) mod = digital.chunks_to_symbols_sf(constellation,dimensionality) @@ -33,7 +33,7 @@ def run_test (fo,fi,interleaver,Kb,bitspersymbol,K,dimensionality,constellation, scale = blocks.multiply_const_ff(1.0/N0) dec = trellis.sccc_decoder_s(fo,0,-1,fi,0,-1,interleaver,K,IT,trellis.TRELLIS_MIN_SUM) fsmi2s = blocks.unpacked_to_packed_ss(bitspersymbol,gr.GR_MSB_FIRST) # pack FSM input symbols to shorts - dst = gr.check_lfsr_32k_s() + dst = blocks.check_lfsr_32k_s() #tb.connect (src,src_head,s2fsmi,enc_out,inter,enc_in,mod) tb.connect (src,src_head,s2fsmi,enc,mod) diff --git a/gr-trellis/examples/python/test_tcm.py b/gr-trellis/examples/python/test_tcm.py index 8a815ae12a..bf9710aa1c 100755 --- a/gr-trellis/examples/python/test_tcm.py +++ b/gr-trellis/examples/python/test_tcm.py @@ -24,9 +24,9 @@ def run_test (f,Kb,bitspersymbol,K,dimensionality,constellation,N0,seed): #packet = [0]*Kb #for i in range(Kb-1*16): # last 16 bits = 0 to drive the final state to 0 #packet[i] = random.randint(0, 1) # random 0s and 1s - #src = gr.vector_source_s(packet,False) - src = gr.lfsr_32k_source_s() - src_head = gr.head (gr.sizeof_short,Kb/16) # packet size in shorts + #src = blocks.vector_source_s(packet,False) + src = blocks.lfsr_32k_source_s() + src_head = blocks.head(gr.sizeof_short,Kb/16) # packet size in shorts #b2s = blocks.unpacked_to_packed_ss(1,gr.GR_MSB_FIRST) # pack bits in shorts s2fsmi = blocks.packed_to_unpacked_ss(bitspersymbol,gr.GR_MSB_FIRST) # unpack shorts to symbols compatible with the FSM input cardinality enc = trellis.encoder_ss(f,0) # initial state = 0 @@ -41,8 +41,8 @@ def run_test (f,Kb,bitspersymbol,K,dimensionality,constellation,N0,seed): va = trellis.viterbi_s(f,K,0,-1) # Put -1 if the Initial/Final states are not set. fsmi2s = blocks.unpacked_to_packed_ss(bitspersymbol,gr.GR_MSB_FIRST) # pack FSM input symbols to shorts #s2b = blocks.packed_to_unpacked_ss(1,gr.GR_MSB_FIRST) # unpack shorts to bits - #dst = gr.vector_sink_s(); - dst = gr.check_lfsr_32k_s() + #dst = blocks.vector_sink_s(); + dst = blocks.check_lfsr_32k_s() tb.connect (src,src_head,s2fsmi,enc,mod) diff --git a/gr-trellis/examples/python/test_tcm_bit.py b/gr-trellis/examples/python/test_tcm_bit.py index 6308df1d09..7880f0ea53 100755 --- a/gr-trellis/examples/python/test_tcm_bit.py +++ b/gr-trellis/examples/python/test_tcm_bit.py @@ -24,9 +24,9 @@ def run_test (f,Kb,bitspersymbol,K,dimensionality,constellation,N0,seed): # this for loop is TOO slow!!! for i in range(Kb-1*16): # last 16 bits = 0 to drive the final state to 0 packet[i] = random.randint(0, 1) # random 0s and 1s - src = gr.vector_source_s(packet,False) - #src = gr.lfsr_32k_source_s() - #src_head = gr.head (gr.sizeof_short,Kb/16) # packet size in shorts + src = blocks.vector_source_s(packet,False) + #src = blocks.lfsr_32k_source_s() + #src_head = blocks.head (gr.sizeof_short,Kb/16) # packet size in shorts b2s = blocks.unpacked_to_packed_ss(1,gr.GR_MSB_FIRST) # pack bits in shorts s2fsmi = blocks.packed_to_unpacked_ss(bitspersymbol,gr.GR_MSB_FIRST) # unpack shorts to symbols compatible with the FSM input cardinality enc = trellis.encoder_ss(f,0) # initial state = 0 @@ -43,8 +43,8 @@ def run_test (f,Kb,bitspersymbol,K,dimensionality,constellation,N0,seed): va = trellis.viterbi_s(f,K,0,-1) # Put -1 if the Initial/Final states are not set. fsmi2s = blocks.unpacked_to_packed_ss(bitspersymbol,gr.GR_MSB_FIRST) # pack FSM input symbols to shorts s2b = blocks.packed_to_unpacked_ss(1,gr.GR_MSB_FIRST) # unpack shorts to bits - dst = gr.vector_sink_s(); - #dst = gr.check_lfsr_32k_s(); + dst = blocks.vector_sink_s(); + #dst = blocks.check_lfsr_32k_s(); #tb.connect (src,src_head,s2fsmi,enc,mod) diff --git a/gr-trellis/examples/python/test_tcm_combined.py b/gr-trellis/examples/python/test_tcm_combined.py index 198d038ce3..697e3cc64a 100755 --- a/gr-trellis/examples/python/test_tcm_combined.py +++ b/gr-trellis/examples/python/test_tcm_combined.py @@ -19,8 +19,8 @@ def run_test (f,Kb,bitspersymbol,K,dimensionality,constellation,N0,seed): tb = gr.top_block () # TX - src = gr.lfsr_32k_source_s() - src_head = gr.head (gr.sizeof_short,Kb/16) # packet size in shorts + src = blocks.lfsr_32k_source_s() + src_head = blocks.head(gr.sizeof_short,Kb/16) # packet size in shorts s2fsmi = blocks.packed_to_unpacked_ss(bitspersymbol,gr.GR_MSB_FIRST) # unpack shorts to symbols compatible with the FSM input cardinality enc = trellis.encoder_ss(f,0) # initial state = 0 mod = digital.chunks_to_symbols_sf(constellation,dimensionality) @@ -34,7 +34,7 @@ def run_test (f,Kb,bitspersymbol,K,dimensionality,constellation,N0,seed): # RX va = trellis.viterbi_combined_fs(f,K,0,-1,dimensionality,constellation,digital.TRELLIS_EUCLIDEAN) # Put -1 if the Initial/Final states are not set. fsmi2s = blocks.unpacked_to_packed_ss(bitspersymbol,gr.GR_MSB_FIRST) # pack FSM input symbols to shorts - dst = gr.check_lfsr_32k_s(); + dst = blocks.check_lfsr_32k_s(); tb.connect (src,src_head,s2fsmi,enc,mod) diff --git a/gr-trellis/examples/python/test_tcm_parallel.py b/gr-trellis/examples/python/test_tcm_parallel.py index d2527956e9..e4456890f0 100755 --- a/gr-trellis/examples/python/test_tcm_parallel.py +++ b/gr-trellis/examples/python/test_tcm_parallel.py @@ -19,8 +19,8 @@ def run_test (f,Kb,bitspersymbol,K,dimensionality,constellation,N0,seed,P): tb = gr.top_block () # TX - src = gr.lfsr_32k_source_s() - src_head = gr.head (gr.sizeof_short,Kb/16*P) # packet size in shorts + src = blocks.lfsr_32k_source_s() + src_head = blocks.head(gr.sizeof_short,Kb/16*P) # packet size in shorts s2fsmi=blocks.packed_to_unpacked_ss(bitspersymbol,gr.GR_MSB_FIRST) # unpack shorts to symbols compatible with the FSM input cardinality s2p = blocks.stream_to_streams(gr.sizeof_short,P) # serial to parallel enc = trellis.encoder_ss(f,0) # initiali state = 0 @@ -38,7 +38,7 @@ def run_test (f,Kb,bitspersymbol,K,dimensionality,constellation,N0,seed,P): va = trellis.viterbi_s(f,K,0,-1) # Put -1 if the Initial/Final states are not set. p2s = block.streams_to_stream(gr.sizeof_short,P) # parallel to serial fsmi2s=blocks.unpacked_to_packed_ss(bitspersymbol,gr.GR_MSB_FIRST) # pack FSM input symbols to shorts - dst = gr.check_lfsr_32k_s() + dst = blocks.check_lfsr_32k_s() tb.connect (src,src_head,s2fsmi,s2p) for i in range(P): diff --git a/gr-trellis/examples/python/test_turbo_equalization.py b/gr-trellis/examples/python/test_turbo_equalization.py index 41361fd3db..b2d58a6014 100755 --- a/gr-trellis/examples/python/test_turbo_equalization.py +++ b/gr-trellis/examples/python/test_turbo_equalization.py @@ -16,7 +16,7 @@ except ImportError: def make_rx(tb,fo,fi,dimensionality,tot_constellation,K,interleaver,IT,Es,N0,type): metrics_in = trellis.metrics_f(fi.O(),dimensionality,tot_constellation,digital.TRELLIS_EUCLIDEAN) # data preprocessing to generate metrics for innner SISO scale = blocks.multiply_const_ff(1.0/N0) - gnd = gr.vector_source_f([0],True); + gnd = blocks.vector_source_f([0],True); inter=[] deinter=[] @@ -57,8 +57,8 @@ def run_test (fo,fi,interleaver,Kb,bitspersymbol,K,dimensionality,tot_constellat tb = gr.top_block () # TX - src = gr.lfsr_32k_source_s() - src_head = gr.head (gr.sizeof_short,Kb/16) # packet size in shorts + src = blocks.lfsr_32k_source_s() + src_head = blocks.head(gr.sizeof_short,Kb/16) # packet size in shorts s2fsmi = blocks.packed_to_unpacked_ss(bitspersymbol,gr.GR_MSB_FIRST) # unpack shorts to symbols compatible with the iouter FSM input cardinality enc_out = trellis.encoder_ss(fo,0) # initial state = 0 inter = trellis.permutation(interleaver.K(),interleaver.INTER(),1,gr.sizeof_short) @@ -73,7 +73,7 @@ def run_test (fo,fi,interleaver,Kb,bitspersymbol,K,dimensionality,tot_constellat # RX (head,tail) = make_rx(tb,fo,fi,dimensionality,tot_constellation,K,interleaver,IT,Es,N0,trellis.TRELLIS_MIN_SUM) fsmi2s = blocks.unpacked_to_packed_ss(bitspersymbol,gr.GR_MSB_FIRST) # pack FSM input symbols to shorts - dst = gr.check_lfsr_32k_s(); + dst = blocks.check_lfsr_32k_s(); tb.connect (src,src_head,s2fsmi,enc_out,inter,enc_in,mod) tb.connect (mod,(add,0)) diff --git a/gr-trellis/examples/python/test_turbo_equalization1.py b/gr-trellis/examples/python/test_turbo_equalization1.py index ae7e3e374b..5ff21ec757 100755 --- a/gr-trellis/examples/python/test_turbo_equalization1.py +++ b/gr-trellis/examples/python/test_turbo_equalization1.py @@ -17,7 +17,7 @@ except ImportError: def make_rx(tb,fo,fi,dimensionality,tot_constellation,K,interleaver,IT,Es,N0,type): metrics_in = trellis.metrics_f(fi.O(),dimensionality,tot_constellation,digital.TRELLIS_EUCLIDEAN) # data preprocessing to generate metrics for innner SISO scale = blocks.multiply_const_ff(1.0/N0) - gnd = gr.vector_source_f([0],True); + gnd = blocks.vector_source_f([0],True); inter=[] deinter=[] @@ -64,7 +64,7 @@ def run_test (fo,fi,interleaver,Kb,bitspersymbol,K,channel,modulation,dimensiona random.seed(seed) for i in range(len(packet)): packet[i] = random.randint(0, 2**bitspersymbol - 1) # random symbols - src = gr.vector_source_s(packet,False) + src = blocks.vector_source_s(packet,False) enc_out = trellis.encoder_ss(fo,0) # initial state = 0 inter = trellis.permutation(interleaver.K(),interleaver.INTER(),1,gr.sizeof_short) mod = digital.chunks_to_symbols_sf(modulation[1],modulation[0]) @@ -76,7 +76,7 @@ def run_test (fo,fi,interleaver,Kb,bitspersymbol,K,channel,modulation,dimensiona # RX (head,tail) = make_rx(tb,fo,fi,dimensionality,tot_constellation,K,interleaver,IT,Es,N0,trellis.TRELLIS_MIN_SUM) - dst = gr.vector_sink_s(); + dst = blocks.vector_sink_s(); tb.connect (src,enc_out,inter,mod) tb.connect (mod,isi,(add,0)) diff --git a/gr-trellis/examples/python/test_turbo_equalization2.py b/gr-trellis/examples/python/test_turbo_equalization2.py index eed5675fe5..c2af9fbfca 100755 --- a/gr-trellis/examples/python/test_turbo_equalization2.py +++ b/gr-trellis/examples/python/test_turbo_equalization2.py @@ -16,7 +16,7 @@ except ImportError: def make_rx(tb,fo,fi,dimensionality,tot_constellation,K,interleaver,IT,Es,N0,type): scale = blocks.multiply_const_ff(math.sqrt(1.0/N0)) - gnd = gr.vector_source_f([0],True); + gnd = blocks.vector_source_f([0],True); inter=[] deinter=[] @@ -62,7 +62,7 @@ def run_test (fo,fi,interleaver,Kb,bitspersymbol,K,channel,modulation,dimensiona random.seed(seed) for i in range(len(packet)): packet[i] = random.randint(0, 2**bitspersymbol - 1) # random symbols - src = gr.vector_source_s(packet,False) + src = blocks.vector_source_s(packet,False) enc_out = trellis.encoder_ss(fo,0) # initial state = 0 inter = trellis.permutation(interleaver.K(),interleaver.INTER(),1,gr.sizeof_short) mod = digital.chunks_to_symbols_sf(modulation[1],modulation[0]) @@ -74,7 +74,7 @@ def run_test (fo,fi,interleaver,Kb,bitspersymbol,K,channel,modulation,dimensiona # RX (head,tail) = make_rx(tb,fo,fi,dimensionality,tot_constellation,K,interleaver,IT,Es,N0,trellis.TRELLIS_MIN_SUM) - dst = gr.vector_sink_s(); + dst = blocks.vector_sink_s(); tb.connect (src,enc_out,inter,mod) tb.connect (mod,isi,(add,0)) diff --git a/gr-trellis/examples/python/test_viterbi_equalization.py b/gr-trellis/examples/python/test_viterbi_equalization.py index f83125136c..987f171b2a 100755 --- a/gr-trellis/examples/python/test_viterbi_equalization.py +++ b/gr-trellis/examples/python/test_viterbi_equalization.py @@ -17,8 +17,8 @@ def run_test (f,Kb,bitspersymbol,K,dimensionality,tot_constellation,N0,seed): tb = gr.top_block () # TX - src = gr.lfsr_32k_source_s() - src_head = gr.head (gr.sizeof_short,Kb/16) # packet size in shorts + src = blocks.lfsr_32k_source_s() + src_head = blocks.head (gr.sizeof_short,Kb/16) # packet size in shorts s2fsmi = blocks.packed_to_unpacked_ss(bitspersymbol,gr.GR_MSB_FIRST) # unpack shorts to symbols compatible with the FSM input cardinality enc = trellis.encoder_ss(f,0) # initial state = 0 # essentially here we implement the combination of modulation and channel as a memoryless modulation (the memory induced by the channel is hidden in the FSM) @@ -32,7 +32,7 @@ def run_test (f,Kb,bitspersymbol,K,dimensionality,tot_constellation,N0,seed): metrics = trellis.metrics_f(f.O(),dimensionality,tot_constellation,digital.TRELLIS_EUCLIDEAN) # data preprocessing to generate metrics for Viterbi va = trellis.viterbi_s(f,K,0,-1) # Put -1 if the Initial/Final states are not set. fsmi2s = blocks.unpacked_to_packed_ss(bitspersymbol,gr.GR_MSB_FIRST) # pack FSM input symbols to shorts - dst = gr.check_lfsr_32k_s(); + dst = blocks.check_lfsr_32k_s(); tb.connect (src,src_head,s2fsmi,enc,mod) tb.connect (mod,(add,0)) diff --git a/gr-trellis/examples/python/test_viterbi_equalization1.py b/gr-trellis/examples/python/test_viterbi_equalization1.py index df46046ae3..baa6a27f1b 100755 --- a/gr-trellis/examples/python/test_viterbi_equalization1.py +++ b/gr-trellis/examples/python/test_viterbi_equalization1.py @@ -27,7 +27,7 @@ def run_test (f,Kb,bitspersymbol,K,channel,modulation,dimensionality,tot_constel for i in range(L): # first/last L symbols set to 0 packet[i] = 0 packet[len(packet)-i-1] = 0 - src = gr.vector_source_s(packet,False) + src = blocks.vector_source_s(packet,False) mod = digital.chunks_to_symbols_sf(modulation[1],modulation[0]) # CHANNEL @@ -36,11 +36,11 @@ def run_test (f,Kb,bitspersymbol,K,channel,modulation,dimensionality,tot_constel noise = analog.noise_source_f(analog.GR_GAUSSIAN,math.sqrt(N0/2),seed) # RX - skip = gr.skiphead(gr.sizeof_float, L) # skip the first L samples since you know they are coming from the L zero symbols + skip = blocks.skiphead(gr.sizeof_float, L) # skip the first L samples since you know they are coming from the L zero symbols #metrics = trellis.metrics_f(f.O(),dimensionality,tot_constellation,digital.TRELLIS_EUCLIDEAN) # data preprocessing to generate metrics for Viterbi #va = trellis.viterbi_s(f,K+L,-1,0) # Put -1 if the Initial/Final states are not set. va = trellis.viterbi_combined_fs(f,K+L,0,0,dimensionality,tot_constellation,digital.TRELLIS_EUCLIDEAN) # using viterbi_combined_fs instead of metrics_f/viterbi_s allows larger packet lengths because metrics_f is complaining for not being able to allocate large buffers. This is due to the large f.O() in this application... - dst = gr.vector_sink_s() + dst = blocks.vector_sink_s() tb.connect (src,mod) tb.connect (mod,isi,(add,0)) diff --git a/gr-trellis/python/qa_trellis.py b/gr-trellis/python/qa_trellis.py index 983a749af6..b0a2f8a745 100755 --- a/gr-trellis/python/qa_trellis.py +++ b/gr-trellis/python/qa_trellis.py @@ -106,9 +106,9 @@ class trellis_tb(gr.top_block): K = packet_size/bitspersymbol # TX - src = gr.lfsr_32k_source_s() + src = blocks.lfsr_32k_source_s() # packet size in shorts - src_head = gr.head (gr.sizeof_short, packet_size/16) + src_head = blocks.head(gr.sizeof_short, packet_size/16) # unpack shorts to symbols compatible with the FSM input cardinality s2fsmi = blocks.packed_to_unpacked_ss(bitspersymbol, gr.GR_MSB_FIRST) # initial FSM state = 0 @@ -127,7 +127,7 @@ class trellis_tb(gr.top_block): # pack FSM input symbols to shorts fsmi2s = blocks.unpacked_to_packed_ss(bitspersymbol, gr.GR_MSB_FIRST) # check the output - self.dst = gr.check_lfsr_32k_s() + self.dst = blocks.check_lfsr_32k_s() self.connect (src, src_head, s2fsmi, enc, mod) self.connect (mod, (add, 0)) diff --git a/gr-uhd/apps/uhd_fft b/gr-uhd/apps/uhd_fft index 800a5fab84..f16f2d71b5 100755 --- a/gr-uhd/apps/uhd_fft +++ b/gr-uhd/apps/uhd_fft @@ -38,6 +38,10 @@ except ImportError: sys.stderr.write("Error importing GNU Radio's wxgui. Please make sure gr-wxgui is installed.\n") sys.exit(1) +import os +print os.getpid() +raw_input() + class app_top_block(stdgui2.std_top_block): def __init__(self, frame, panel, vbox, argv): stdgui2.std_top_block.__init__(self, frame, panel, vbox, argv) diff --git a/gr-uhd/apps/uhd_rx_cfile b/gr-uhd/apps/uhd_rx_cfile index f9ed392564..5531bb35b8 100755 --- a/gr-uhd/apps/uhd_rx_cfile +++ b/gr-uhd/apps/uhd_rx_cfile @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2012 Free Software Foundation, Inc. +# Copyright 2012,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -83,9 +83,9 @@ class rx_cfile_block(gr.top_block): self.connect(self._u, self._sink) else: if options.output_shorts: - self._head = gr.head(gr.sizeof_short*2, int(options.nsamples)) + self._head = blocks.head(gr.sizeof_short*2, int(options.nsamples)) else: - self._head = gr.head(gr.sizeof_gr_complex, int(options.nsamples)) + self._head = blocks.head(gr.sizeof_gr_complex, int(options.nsamples)) self.connect(self._u, self._head, self._sink) diff --git a/gr-uhd/examples/grc/uhd_const_wave.grc b/gr-uhd/examples/grc/uhd_const_wave.grc index c64721c833..46596109de 100644 --- a/gr-uhd/examples/grc/uhd_const_wave.grc +++ b/gr-uhd/examples/grc/uhd_const_wave.grc @@ -1,27 +1,59 @@ <?xml version='1.0' encoding='ASCII'?> <flow_graph> - <timestamp>Sat Oct 8 10:24:27 2011</timestamp> + <timestamp>Mon Mar 18 11:04:05 2013</timestamp> <block> - <key>const_source_x</key> + <key>options</key> <param> <key>id</key> - <value>const_source_x_0</value> + <value>uhd_const_wave</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>type</key> - <value>complex</value> + <key>title</key> + <value>UHD Constant Wave</value> </param> <param> - <key>const</key> - <value>ampl</value> + <key>author</key> + <value>Example</value> + </param> + <param> + <key>description</key> + <value>Tune UHD Device</value> + </param> + <param> + <key>window_size</key> + <value>1280, 1024</value> + </param> + <param> + <key>generate_options</key> + <value>wx_gui</value> + </param> + <param> + <key>category</key> + <value>Custom</value> + </param> + <param> + <key>run_options</key> + <value>prompt</value> + </param> + <param> + <key>run</key> + <value>True</value> + </param> + <param> + <key>max_nouts</key> + <value>0</value> + </param> + <param> + <key>realtime_scheduling</key> + <value></value> </param> <param> <key>_coordinate</key> - <value>(102, 193)</value> + <value>(10, 10)</value> </param> <param> <key>_rotation</key> @@ -194,54 +226,69 @@ </param> </block> <block> - <key>options</key> + <key>parameter</key> <param> <key>id</key> - <value>uhd_const_wave</value> + <value>address</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>title</key> - <value>UHD Constant Wave</value> + <key>label</key> + <value>IP Address</value> </param> <param> - <key>author</key> - <value>Example</value> + <key>value</key> + <value>addr=192.168.11.2</value> </param> <param> - <key>description</key> - <value>Tune UHD Device</value> + <key>type</key> + <value>string</value> </param> <param> - <key>window_size</key> - <value>1280, 1024</value> + <key>short_id</key> + <value>a</value> </param> <param> - <key>generate_options</key> - <value>wx_gui</value> + <key>_coordinate</key> + <value>(188, 12)</value> </param> <param> - <key>category</key> - <value>Custom</value> + <key>_rotation</key> + <value>0</value> </param> + </block> + <block> + <key>parameter</key> <param> - <key>run_options</key> - <value>prompt</value> + <key>id</key> + <value>samp_rate</value> </param> <param> - <key>run</key> + <key>_enabled</key> <value>True</value> </param> <param> - <key>realtime_scheduling</key> - <value></value> + <key>label</key> + <value>Sample Rate</value> + </param> + <param> + <key>value</key> + <value>1e6</value> + </param> + <param> + <key>type</key> + <value>eng_float</value> + </param> + <param> + <key>short_id</key> + <value>s</value> </param> <param> <key>_coordinate</key> - <value>(10, 10)</value> + <value>(342, 14)</value> </param> <param> <key>_rotation</key> @@ -252,7 +299,7 @@ <key>parameter</key> <param> <key>id</key> - <value>address</value> + <value>freq</value> </param> <param> <key>_enabled</key> @@ -260,23 +307,23 @@ </param> <param> <key>label</key> - <value>IP Address</value> + <value>Default Frequency</value> </param> <param> <key>value</key> - <value>addr=192.168.11.2</value> + <value>2.45e9</value> </param> <param> <key>type</key> - <value>string</value> + <value>eng_float</value> </param> <param> <key>short_id</key> - <value>a</value> + <value>f</value> </param> <param> <key>_coordinate</key> - <value>(188, 12)</value> + <value>(468, 14)</value> </param> <param> <key>_rotation</key> @@ -287,7 +334,7 @@ <key>parameter</key> <param> <key>id</key> - <value>samp_rate</value> + <value>gain</value> </param> <param> <key>_enabled</key> @@ -295,11 +342,11 @@ </param> <param> <key>label</key> - <value>Sample Rate</value> + <value>Default Gain</value> </param> <param> <key>value</key> - <value>1e6</value> + <value>0</value> </param> <param> <key>type</key> @@ -307,11 +354,11 @@ </param> <param> <key>short_id</key> - <value>s</value> + <value>g</value> </param> <param> <key>_coordinate</key> - <value>(342, 14)</value> + <value>(616, 13)</value> </param> <param> <key>_rotation</key> @@ -330,7 +377,15 @@ </param> <param> <key>type</key> - <value>complex</value> + <value>fc32</value> + </param> + <param> + <key>otw</key> + <value></value> + </param> + <param> + <key>stream_args</key> + <value></value> </param> <param> <key>dev_addr</key> @@ -349,7 +404,11 @@ <value>1</value> </param> <param> - <key>ref_source0</key> + <key>clock_source0</key> + <value></value> + </param> + <param> + <key>time_source0</key> <value></value> </param> <param> @@ -357,7 +416,11 @@ <value></value> </param> <param> - <key>ref_source1</key> + <key>clock_source1</key> + <value></value> + </param> + <param> + <key>time_source1</key> <value></value> </param> <param> @@ -365,7 +428,11 @@ <value></value> </param> <param> - <key>ref_source2</key> + <key>clock_source2</key> + <value></value> + </param> + <param> + <key>time_source2</key> <value></value> </param> <param> @@ -373,7 +440,11 @@ <value></value> </param> <param> - <key>ref_source3</key> + <key>clock_source3</key> + <value></value> + </param> + <param> + <key>time_source3</key> <value></value> </param> <param> @@ -381,7 +452,11 @@ <value></value> </param> <param> - <key>ref_source4</key> + <key>clock_source4</key> + <value></value> + </param> + <param> + <key>time_source4</key> <value></value> </param> <param> @@ -389,7 +464,11 @@ <value></value> </param> <param> - <key>ref_source5</key> + <key>clock_source5</key> + <value></value> + </param> + <param> + <key>time_source5</key> <value></value> </param> <param> @@ -397,7 +476,11 @@ <value></value> </param> <param> - <key>ref_source6</key> + <key>clock_source6</key> + <value></value> + </param> + <param> + <key>time_source6</key> <value></value> </param> <param> @@ -405,7 +488,11 @@ <value></value> </param> <param> - <key>ref_source7</key> + <key>clock_source7</key> + <value></value> + </param> + <param> + <key>time_source7</key> <value></value> </param> <param> @@ -942,69 +1029,26 @@ </param> </block> <block> - <key>parameter</key> + <key>analog_const_source_x</key> <param> <key>id</key> - <value>freq</value> + <value>analog_const_source_x_0</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>label</key> - <value>Default Frequency</value> - </param> - <param> - <key>value</key> - <value>2.45e9</value> - </param> - <param> - <key>type</key> - <value>eng_float</value> - </param> - <param> - <key>short_id</key> - <value>f</value> - </param> - <param> - <key>_coordinate</key> - <value>(468, 14)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>parameter</key> - <param> - <key>id</key> - <value>gain</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>label</key> - <value>Default Gain</value> - </param> - <param> - <key>value</key> - <value>0</value> - </param> - <param> <key>type</key> - <value>eng_float</value> + <value>complex</value> </param> <param> - <key>short_id</key> - <value>g</value> + <key>const</key> + <value>ampl</value> </param> <param> <key>_coordinate</key> - <value>(616, 13)</value> + <value>(74, 193)</value> </param> <param> <key>_rotation</key> @@ -1012,7 +1056,7 @@ </param> </block> <connection> - <source_block_id>const_source_x_0</source_block_id> + <source_block_id>analog_const_source_x_0</source_block_id> <sink_block_id>uhd_usrp_sink_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> diff --git a/gr-uhd/examples/grc/uhd_dpsk_mod.grc b/gr-uhd/examples/grc/uhd_dpsk_mod.grc index 9caafbb6ac..8387890372 100644 --- a/gr-uhd/examples/grc/uhd_dpsk_mod.grc +++ b/gr-uhd/examples/grc/uhd_dpsk_mod.grc @@ -226,7 +226,7 @@ </param> <param> <key>trig_mode</key> - <value>gr.gr_TRIG_MODE_AUTO</value> + <value>wxgui.TRIG_MODE_AUTO</value> </param> <param> <key>y_axis_label</key> diff --git a/gr-uhd/examples/grc/uhd_fft.grc b/gr-uhd/examples/grc/uhd_fft.grc index 2582b5e3b1..08e5f70edb 100644 --- a/gr-uhd/examples/grc/uhd_fft.grc +++ b/gr-uhd/examples/grc/uhd_fft.grc @@ -1,6 +1,6 @@ <?xml version='1.0' encoding='ASCII'?> <flow_graph> - <timestamp>Mon Jun 18 14:20:11 2012</timestamp> + <timestamp>Mon Mar 18 15:42:27 2013</timestamp> <block> <key>options</key> <param> @@ -248,7 +248,7 @@ </param> <param> <key>trig_mode</key> - <value>gr.gr_TRIG_MODE_AUTO</value> + <value>wxgui.TRIG_MODE_AUTO</value> </param> <param> <key>y_axis_label</key> @@ -1146,41 +1146,6 @@ </param> </block> <block> - <key>parameter</key> - <param> - <key>id</key> - <value>address</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>label</key> - <value>IP Address</value> - </param> - <param> - <key>value</key> - <value></value> - </param> - <param> - <key>type</key> - <value>string</value> - </param> - <param> - <key>short_id</key> - <value>a</value> - </param> - <param> - <key>_coordinate</key> - <value>(190, 15)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> <key>wxgui_fftsink2</key> <param> <key>id</key> @@ -1507,6 +1472,41 @@ <value>0</value> </param> </block> + <block> + <key>parameter</key> + <param> + <key>id</key> + <value>address</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>label</key> + <value>IP Address</value> + </param> + <param> + <key>value</key> + <value>addr=192.168.11.2</value> + </param> + <param> + <key>type</key> + <value>string</value> + </param> + <param> + <key>short_id</key> + <value>a</value> + </param> + <param> + <key>_coordinate</key> + <value>(190, 15)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> <connection> <source_block_id>uhd_usrp_source_0</source_block_id> <sink_block_id>wxgui_scopesink2_0</sink_block_id> diff --git a/gr-uhd/examples/grc/uhd_rx_dpsk.grc b/gr-uhd/examples/grc/uhd_rx_dpsk.grc index 73848ff3cd..8a9faa4b73 100644 --- a/gr-uhd/examples/grc/uhd_rx_dpsk.grc +++ b/gr-uhd/examples/grc/uhd_rx_dpsk.grc @@ -1,6 +1,6 @@ <?xml version='1.0' encoding='ASCII'?> <flow_graph> - <timestamp>Sat Oct 8 15:08:55 2011</timestamp> + <timestamp>Mon Mar 18 11:10:25 2013</timestamp> <block> <key>options</key> <param> @@ -44,6 +44,10 @@ <value>True</value> </param> <param> + <key>max_nouts</key> + <value>0</value> + </param> + <param> <key>realtime_scheduling</key> <value></value> </param> @@ -310,10 +314,10 @@ </param> </block> <block> - <key>gr_null_sink</key> + <key>blocks_null_sink</key> <param> <key>id</key> - <value>gr_null_sink_0</value> + <value>blocks_null_sink_0</value> </param> <param> <key>_enabled</key> @@ -604,6 +608,10 @@ <value></value> </param> <param> + <key>freqvar</key> + <value>None</value> + </param> + <param> <key>_coordinate</key> <value>(710, 236)</value> </param> @@ -635,20 +643,20 @@ <value>0.35</value> </param> <param> - <key>phase_bw</key> + <key>freq_bw</key> <value>6.28/100.0</value> </param> <param> - <key>timing_bw</key> + <key>phase_bw</key> <value>6.28/100.0</value> </param> <param> - <key>omega_relative_limit</key> - <value>0.005</value> + <key>timing_bw</key> + <value>6.28/100.0</value> </param> <param> - <key>gray_coded</key> - <value>True</value> + <key>mod_code</key> + <value>"gray"</value> </param> <param> <key>verbose</key> @@ -793,7 +801,15 @@ </param> <param> <key>type</key> - <value>complex</value> + <value>fc32</value> + </param> + <param> + <key>otw</key> + <value></value> + </param> + <param> + <key>stream_args</key> + <value></value> </param> <param> <key>dev_addr</key> @@ -812,7 +828,11 @@ <value>1</value> </param> <param> - <key>ref_source0</key> + <key>clock_source0</key> + <value></value> + </param> + <param> + <key>time_source0</key> <value></value> </param> <param> @@ -820,7 +840,11 @@ <value></value> </param> <param> - <key>ref_source1</key> + <key>clock_source1</key> + <value></value> + </param> + <param> + <key>time_source1</key> <value></value> </param> <param> @@ -828,7 +852,11 @@ <value></value> </param> <param> - <key>ref_source2</key> + <key>clock_source2</key> + <value></value> + </param> + <param> + <key>time_source2</key> <value></value> </param> <param> @@ -836,7 +864,11 @@ <value></value> </param> <param> - <key>ref_source3</key> + <key>clock_source3</key> + <value></value> + </param> + <param> + <key>time_source3</key> <value></value> </param> <param> @@ -844,7 +876,11 @@ <value></value> </param> <param> - <key>ref_source4</key> + <key>clock_source4</key> + <value></value> + </param> + <param> + <key>time_source4</key> <value></value> </param> <param> @@ -852,7 +888,11 @@ <value></value> </param> <param> - <key>ref_source5</key> + <key>clock_source5</key> + <value></value> + </param> + <param> + <key>time_source5</key> <value></value> </param> <param> @@ -860,7 +900,11 @@ <value></value> </param> <param> - <key>ref_source6</key> + <key>clock_source6</key> + <value></value> + </param> + <param> + <key>time_source6</key> <value></value> </param> <param> @@ -868,7 +912,11 @@ <value></value> </param> <param> - <key>ref_source7</key> + <key>clock_source7</key> + <value></value> + </param> + <param> + <key>time_source7</key> <value></value> </param> <param> @@ -1406,7 +1454,7 @@ </block> <connection> <source_block_id>digital_dxpsk_demod_0</source_block_id> - <sink_block_id>gr_null_sink_0</sink_block_id> + <sink_block_id>blocks_null_sink_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> diff --git a/gr-uhd/examples/grc/uhd_tx_dpsk.grc b/gr-uhd/examples/grc/uhd_tx_dpsk.grc index 38318bef4b..b5f8e41054 100644 --- a/gr-uhd/examples/grc/uhd_tx_dpsk.grc +++ b/gr-uhd/examples/grc/uhd_tx_dpsk.grc @@ -1,6 +1,65 @@ <?xml version='1.0' encoding='ASCII'?> <flow_graph> - <timestamp>Sat Oct 8 14:55:39 2011</timestamp> + <timestamp>Mon Mar 18 11:11:06 2013</timestamp> + <block> + <key>options</key> + <param> + <key>id</key> + <value>uhd_tx_dpsk</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>title</key> + <value>UHD TX DPSK</value> + </param> + <param> + <key>author</key> + <value></value> + </param> + <param> + <key>description</key> + <value></value> + </param> + <param> + <key>window_size</key> + <value>1280, 1024</value> + </param> + <param> + <key>generate_options</key> + <value>wx_gui</value> + </param> + <param> + <key>category</key> + <value>Custom</value> + </param> + <param> + <key>run_options</key> + <value>prompt</value> + </param> + <param> + <key>run</key> + <value>True</value> + </param> + <param> + <key>max_nouts</key> + <value>0</value> + </param> + <param> + <key>realtime_scheduling</key> + <value></value> + </param> + <param> + <key>_coordinate</key> + <value>(10, 10)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> <block> <key>variable</key> <param> @@ -321,8 +380,8 @@ <value>0.35</value> </param> <param> - <key>gray_coded</key> - <value>True</value> + <key>mod_code</key> + <value>"gray"</value> </param> <param> <key>verbose</key> @@ -423,7 +482,15 @@ </param> <param> <key>type</key> - <value>complex</value> + <value>fc32</value> + </param> + <param> + <key>otw</key> + <value></value> + </param> + <param> + <key>stream_args</key> + <value></value> </param> <param> <key>dev_addr</key> @@ -442,7 +509,11 @@ <value>1</value> </param> <param> - <key>ref_source0</key> + <key>clock_source0</key> + <value></value> + </param> + <param> + <key>time_source0</key> <value></value> </param> <param> @@ -450,7 +521,11 @@ <value></value> </param> <param> - <key>ref_source1</key> + <key>clock_source1</key> + <value></value> + </param> + <param> + <key>time_source1</key> <value></value> </param> <param> @@ -458,7 +533,11 @@ <value></value> </param> <param> - <key>ref_source2</key> + <key>clock_source2</key> + <value></value> + </param> + <param> + <key>time_source2</key> <value></value> </param> <param> @@ -466,7 +545,11 @@ <value></value> </param> <param> - <key>ref_source3</key> + <key>clock_source3</key> + <value></value> + </param> + <param> + <key>time_source3</key> <value></value> </param> <param> @@ -474,7 +557,11 @@ <value></value> </param> <param> - <key>ref_source4</key> + <key>clock_source4</key> + <value></value> + </param> + <param> + <key>time_source4</key> <value></value> </param> <param> @@ -482,7 +569,11 @@ <value></value> </param> <param> - <key>ref_source5</key> + <key>clock_source5</key> + <value></value> + </param> + <param> + <key>time_source5</key> <value></value> </param> <param> @@ -490,7 +581,11 @@ <value></value> </param> <param> - <key>ref_source6</key> + <key>clock_source6</key> + <value></value> + </param> + <param> + <key>time_source6</key> <value></value> </param> <param> @@ -498,7 +593,11 @@ <value></value> </param> <param> - <key>ref_source7</key> + <key>clock_source7</key> + <value></value> + </param> + <param> + <key>time_source7</key> <value></value> </param> <param> @@ -1144,63 +1243,12 @@ <value></value> </param> <param> - <key>_coordinate</key> - <value>(827, 299)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>options</key> - <param> - <key>id</key> - <value>uhd_tx_dpsk</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>title</key> - <value>UHD TX DPSK</value> - </param> - <param> - <key>author</key> - <value></value> - </param> - <param> - <key>description</key> - <value></value> - </param> - <param> - <key>window_size</key> - <value>1280, 1024</value> - </param> - <param> - <key>generate_options</key> - <value>wx_gui</value> - </param> - <param> - <key>category</key> - <value>Custom</value> - </param> - <param> - <key>run_options</key> - <value>prompt</value> - </param> - <param> - <key>run</key> - <value>True</value> - </param> - <param> - <key>realtime_scheduling</key> - <value></value> + <key>freqvar</key> + <value>None</value> </param> <param> <key>_coordinate</key> - <value>(10, 10)</value> + <value>(827, 299)</value> </param> <param> <key>_rotation</key> diff --git a/gr-uhd/examples/grc/uhd_wbfm_receive.grc b/gr-uhd/examples/grc/uhd_wbfm_receive.grc index 943e82cf31..e19015a790 100644 --- a/gr-uhd/examples/grc/uhd_wbfm_receive.grc +++ b/gr-uhd/examples/grc/uhd_wbfm_receive.grc @@ -1,6 +1,6 @@ <?xml version='1.0' encoding='ASCII'?> <flow_graph> - <timestamp>Tue Apr 24 16:59:09 2012</timestamp> + <timestamp>Mon Mar 18 11:13:02 2013</timestamp> <block> <key>options</key> <param> @@ -44,6 +44,10 @@ <value>True</value> </param> <param> + <key>max_nouts</key> + <value>0</value> + </param> + <param> <key>realtime_scheduling</key> <value></value> </param> @@ -1044,41 +1048,6 @@ <key>parameter</key> <param> <key>id</key> - <value>address</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>label</key> - <value>IP Address</value> - </param> - <param> - <key>value</key> - <value>addr=192.168.10.2</value> - </param> - <param> - <key>type</key> - <value>string</value> - </param> - <param> - <key>short_id</key> - <value>a</value> - </param> - <param> - <key>_coordinate</key> - <value>(199, 14)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>parameter</key> - <param> - <key>id</key> <value>samp_rate</value> </param> <param> @@ -1181,33 +1150,6 @@ </param> </block> <block> - <key>blks2_wfm_rcv</key> - <param> - <key>id</key> - <value>blks2_wfm_rcv</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>quad_rate</key> - <value>samp_rate</value> - </param> - <param> - <key>audio_decimation</key> - <value>audio_decim</value> - </param> - <param> - <key>_coordinate</key> - <value>(626, 153)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> <key>low_pass_filter</key> <param> <key>id</key> @@ -1364,6 +1306,10 @@ <value></value> </param> <param> + <key>freqvar</key> + <value>None</value> + </param> + <param> <key>_coordinate</key> <value>(624, 278)</value> </param> @@ -1372,6 +1318,68 @@ <value>0</value> </param> </block> + <block> + <key>analog_wfm_rcv</key> + <param> + <key>id</key> + <value>analog_wfm_rcv</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>quad_rate</key> + <value>samp_rate</value> + </param> + <param> + <key>audio_decimation</key> + <value>audio_decim</value> + </param> + <param> + <key>_coordinate</key> + <value>(625, 153)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>parameter</key> + <param> + <key>id</key> + <value>address</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>label</key> + <value>IP Address</value> + </param> + <param> + <key>value</key> + <value>addr=192.168.10.2</value> + </param> + <param> + <key>type</key> + <value>string</value> + </param> + <param> + <key>short_id</key> + <value>a</value> + </param> + <param> + <key>_coordinate</key> + <value>(199, 14)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> <connection> <source_block_id>blocks_multiply_const_vxx</source_block_id> <sink_block_id>audio_sink</sink_block_id> @@ -1379,14 +1387,14 @@ <sink_key>0</sink_key> </connection> <connection> - <source_block_id>blks2_wfm_rcv</source_block_id> + <source_block_id>analog_wfm_rcv</source_block_id> <sink_block_id>blocks_multiply_const_vxx</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> <source_block_id>low_pass_filter_0</source_block_id> - <sink_block_id>blks2_wfm_rcv</sink_block_id> + <sink_block_id>analog_wfm_rcv</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> diff --git a/gr-uhd/examples/python/max_power.py b/gr-uhd/examples/python/max_power.py index 79fe120641..e1504e5ea2 100755 --- a/gr-uhd/examples/python/max_power.py +++ b/gr-uhd/examples/python/max_power.py @@ -27,6 +27,7 @@ Setup USRP for maximum power consumption. from gnuradio import gr from gnuradio import analog +from gnuradio import blocks from gnuradio import uhd from gnuradio.eng_option import eng_option from optparse import OptionParser @@ -95,7 +96,7 @@ class build_block(gr.top_block): self.u_rx = uhd.usrp_source(device_addr=args, io_type=uhd.io_type.COMPLEX_FLOAT32, num_channels=rx_nchan) - self.rx_dst0 = gr.null_sink(gr.sizeof_gr_complex) + self.rx_dst0 = blocks.null_sink(gr.sizeof_gr_complex) self.u_rx.set_samp_rate(MAX_RATE) diff --git a/gr-uhd/examples/python/usrp_tv_rcv.py b/gr-uhd/examples/python/usrp_tv_rcv.py index d94b651660..301840f41d 100755 --- a/gr-uhd/examples/python/usrp_tv_rcv.py +++ b/gr-uhd/examples/python/usrp_tv_rcv.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2005-2007,2011,2012 Free Software Foundation, Inc. +# Copyright 2005-2007,2011-2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -226,7 +226,7 @@ class tv_rx_block (stdgui2.std_top_block): elif process_type=='do_nullsink': #self.connect (self.src, self.am_demod,self.invert_and_scale,f2uc,video_sink) c2r=blocks.complex_to_real() - nullsink=gr.null_sink(gr.sizeof_float) + nullsink=blocks.null_sink(gr.sizeof_float) self.connect (self.src, c2r,nullsink) #video_sink) elif process_type=='do_tv_sync_corr': frame_size=width*height #int(usrp_rate/25.0) diff --git a/gr-uhd/examples/python/usrp_tv_rcv_nogui.py b/gr-uhd/examples/python/usrp_tv_rcv_nogui.py index 13395cef46..80e2e1c17a 100755 --- a/gr-uhd/examples/python/usrp_tv_rcv_nogui.py +++ b/gr-uhd/examples/python/usrp_tv_rcv_nogui.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2005-2007,2011 Free Software Foundation, Inc. +# Copyright 2005-2007,2011,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -202,7 +202,7 @@ class my_top_block(gr.top_block): if options.nframes is None: self.connect(self.src, self.agc) else: - self.head = gr.head(gr.sizeof_gr_complex, int(options.nframes*width*height)) + self.head = blocks.head(gr.sizeof_gr_complex, int(options.nframes*width*height)) self.connect(self.src, self.head, self.agc) self.connect (self.agc, self.am_demod, self.invert_and_scale, diff --git a/gr-uhd/lib/usrp_sink_impl.cc b/gr-uhd/lib/usrp_sink_impl.cc index 563917abaf..a049e79d8f 100644 --- a/gr-uhd/lib/usrp_sink_impl.cc +++ b/gr-uhd/lib/usrp_sink_impl.cc @@ -571,5 +571,27 @@ namespace gr { return true; } + void + usrp_sink_impl::setup_rpc() + { +#ifdef GR_CTRLPORT + add_rpc_variable( + rpcbasic_sptr(new rpcbasic_register_get<usrp_sink, double>( + alias(), "samp_rate", + &usrp_sink::get_samp_rate, + pmt::mp(100000.0f), pmt::mp(25000000.0f), pmt::mp(1000000.0f), + "sps", "TX Sample Rate", RPC_PRIVLVL_MIN, + DISPTIME | DISPOPTSTRIP))); + + add_rpc_variable( + rpcbasic_sptr(new rpcbasic_register_set<usrp_sink, double>( + alias(), "samp_rate", + &usrp_sink::set_samp_rate, + pmt::mp(100000.0f), pmt::mp(25000000.0f), pmt::mp(1000000.0f), + "sps", "TX Sample Rate", + RPC_PRIVLVL_MIN, DISPNULL))); +#endif /* GR_CTRLPORT */ + } + } /* namespace uhd */ } /* namespace gr */ diff --git a/gr-uhd/lib/usrp_sink_impl.h b/gr-uhd/lib/usrp_sink_impl.h index d630e0f2fc..d2058fb4a8 100644 --- a/gr-uhd/lib/usrp_sink_impl.h +++ b/gr-uhd/lib/usrp_sink_impl.h @@ -56,6 +56,8 @@ namespace gr { const ::uhd::stream_args_t &stream_args); ~usrp_sink_impl(); + void setup_rpc(); + ::uhd::dict<std::string, std::string> get_usrp_info(size_t chan); double get_samp_rate(void); ::uhd::meta_range_t get_samp_rates(void); diff --git a/gr-uhd/lib/usrp_source_impl.cc b/gr-uhd/lib/usrp_source_impl.cc index 9d6a55ae5a..ad3ffef2ad 100644 --- a/gr-uhd/lib/usrp_source_impl.cc +++ b/gr-uhd/lib/usrp_source_impl.cc @@ -624,5 +624,27 @@ namespace gr { return num_samps; } + void + usrp_source_impl::setup_rpc() + { +#ifdef GR_CTRLPORT + add_rpc_variable( + rpcbasic_sptr(new rpcbasic_register_get<usrp_source, double>( + alias(), "samp_rate", + &usrp_source::get_samp_rate, + pmt::mp(100000.0f), pmt::mp(25000000.0f), pmt::mp(1000000.0f), + "sps", "RX Sample Rate", RPC_PRIVLVL_MIN, + DISPTIME | DISPOPTSTRIP))); + + add_rpc_variable( + rpcbasic_sptr(new rpcbasic_register_set<usrp_source, double>( + alias(), "samp_rate", + &usrp_source::set_samp_rate, + pmt::mp(100000.0f), pmt::mp(25000000.0f), pmt::mp(1000000.0f), + "sps", "RX Sample Rate", + RPC_PRIVLVL_MIN, DISPNULL))); +#endif /* GR_CTRLPORT */ + } + } /* namespace uhd */ } /* namespace gr */ diff --git a/gr-uhd/lib/usrp_source_impl.h b/gr-uhd/lib/usrp_source_impl.h index b0b04a795b..e31263bda0 100644 --- a/gr-uhd/lib/usrp_source_impl.h +++ b/gr-uhd/lib/usrp_source_impl.h @@ -56,6 +56,8 @@ namespace gr { const ::uhd::stream_args_t &stream_args); ~usrp_source_impl(); + void setup_rpc(); + // Get Commands ::uhd::dict<std::string, std::string> get_usrp_info(size_t chan); std::string get_subdev_spec(size_t mboard); diff --git a/gr-utils/python/modtool/code_generator.py b/gr-utils/python/modtool/code_generator.py index 525b3d1e9a..fbe9aa92c2 100644 --- a/gr-utils/python/modtool/code_generator.py +++ b/gr-utils/python/modtool/code_generator.py @@ -37,6 +37,7 @@ class GRMTemplate(Cheetah.Template.Template): 'decimator': 'gr_sync_decimator', 'interpolator': 'gr_sync_interpolator', 'general': 'gr_block', + 'tagged_stream': 'gr_tagged_stream_block', 'hier': 'gr_hier_block2', 'noblock': ''} searchList['str_to_fancyc_comment'] = str_to_fancyc_comment diff --git a/gr-utils/python/modtool/modtool_add.py b/gr-utils/python/modtool/modtool_add.py index e1d61cf0fb..81103e460d 100644 --- a/gr-utils/python/modtool/modtool_add.py +++ b/gr-utils/python/modtool/modtool_add.py @@ -37,7 +37,7 @@ class ModToolAdd(ModTool): name = 'add' aliases = ('insert',) _block_types = ('sink', 'source', 'sync', 'decimator', 'interpolator', - 'general', 'hier', 'noblock') + 'general', 'tagged_stream', 'hier', 'noblock') def __init__(self): ModTool.__init__(self) self._add_cc_qa = False @@ -208,7 +208,7 @@ class ModToolAdd(ModTool): fname_h = self._info['blockname'] + '.h' fname_cc = self._info['blockname'] + '.cc' if self._info['blocktype'] in ('source', 'sink', 'sync', 'decimator', - 'interpolator', 'general', 'hier'): + 'interpolator', 'general', 'hier', 'tagged_stream'): fname_cc = self._info['blockname'] + '_impl.cc' self._write_tpl('block_impl_h', 'lib', self._info['blockname'] + '_impl.h') self._write_tpl('block_impl_cpp', 'lib', fname_cc) diff --git a/gr-utils/python/modtool/templates.py b/gr-utils/python/modtool/templates.py index 87eb9f470c..289903348d 100644 --- a/gr-utils/python/modtool/templates.py +++ b/gr-utils/python/modtool/templates.py @@ -57,25 +57,34 @@ namespace gr { class ${blockname}_impl : public ${blockname} { - private: + private: // Nothing to declare in this block. - public: +#if $blocktype == 'tagged_stream' + protected: + int calculate_output_stream_length(const gr_vector_int &ninput_items); + +#end if + public: ${blockname}_impl(${strip_default_values($arglist)}); ~${blockname}_impl(); + // Where all the action really happens #if $blocktype == 'general' void forecast (int noutput_items, gr_vector_int &ninput_items_required); - // Where all the action really happens int general_work(int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items); +#else if $blocktype == 'tagged_stream' + int work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); #else if $blocktype == 'hier' #silent pass #else - // Where all the action really happens int work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items); @@ -125,6 +134,8 @@ namespace gr { #set $decimation = ', <+decimation+>' #else if $blocktype == 'interpolator' #set $decimation = ', <+interpolation+>' +#else if $blocktype == 'tagged_stream' +#set $decimation = ', <+len_tag_key+>' #else #set $decimation = '' #end if @@ -186,6 +197,28 @@ namespace gr { // Tell runtime system how many output items we produced. return noutput_items; } +#else if $blocktype == 'tagged_stream' + int + ${blockname}_impl::calculate_output_stream_length(const gr_vector_int &ninput_items) + { + int noutput_items = /* <+set this+> */; + return noutput_items ; + } + + int + ${blockname}_impl::work (int noutput_items, + gr_vector_int &ninput_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]; + + // Do <+signal processing+> + + // Tell runtime system how many output items we produced. + return noutput_items; + } #else if $blocktype == 'hier' #silent pass #else @@ -230,9 +263,9 @@ namespace gr { */ class ${modname.upper()}_API $blockname { - ${blockname}(${arglist}); - ~${blockname}(); - private: + ${blockname}(${arglist}); + ~${blockname}(); + private: }; #else /*! @@ -242,18 +275,18 @@ namespace gr { */ class ${modname.upper()}_API ${blockname} : virtual public $grblocktype { - public: - typedef boost::shared_ptr<${blockname}> sptr; - - /*! - * \\brief Return a shared_ptr to a new instance of ${modname}::${blockname}. - * - * To avoid accidental use of raw pointers, ${modname}::${blockname}'s - * constructor is in a private implementation - * class. ${modname}::${blockname}::make is the public interface for - * creating new instances. - */ - static sptr make($arglist); + public: + typedef boost::shared_ptr<${blockname}> sptr; + + /*! + * \\brief Return a shared_ptr to a new instance of ${modname}::${blockname}. + * + * To avoid accidental use of raw pointers, ${modname}::${blockname}'s + * constructor is in a private implementation + * class. ${modname}::${blockname}::make is the public interface for + * creating new instances. + */ + static sptr make($arglist); }; #end if diff --git a/gr-vocoder/python/qa_alaw_vocoder.py b/gr-vocoder/python/qa_alaw_vocoder.py index a8d65409e5..50b5f8844a 100755 --- a/gr-vocoder/python/qa_alaw_vocoder.py +++ b/gr-vocoder/python/qa_alaw_vocoder.py @@ -21,7 +21,8 @@ # from gnuradio import gr, gr_unittest -from vocoder_swig import * +import vocoder_swig as vocoder +import blocks_swig as blocks class test_alaw_vocoder (gr_unittest.TestCase): @@ -34,10 +35,10 @@ class test_alaw_vocoder (gr_unittest.TestCase): def test001_module_load (self): data = (8,24,40,56,72,88,104,120,136,152,168,184, 200,216,232,248,264,280,296,312,328,344) - src = gr.vector_source_s(data) - enc = alaw_encode_sb() - dec = alaw_decode_bs() - snk = gr.vector_sink_s() + src = blocks.vector_source_s(data) + enc = vocoder.alaw_encode_sb() + dec = vocoder.alaw_decode_bs() + snk = blocks.vector_sink_s() self.tb.connect(src, enc, dec, snk) self.tb.run() actual_result = snk.data() diff --git a/gr-vocoder/python/qa_codec2_vocoder.py b/gr-vocoder/python/qa_codec2_vocoder.py index 7f38904459..83dbc2eb87 100755 --- a/gr-vocoder/python/qa_codec2_vocoder.py +++ b/gr-vocoder/python/qa_codec2_vocoder.py @@ -21,7 +21,8 @@ # from gnuradio import gr, gr_unittest -from vocoder_swig import * +import vocoder_swig as vocoder +import blocks_swig as blocks class test_codec2_vocoder (gr_unittest.TestCase): @@ -45,10 +46,10 @@ class test_codec2_vocoder (gr_unittest.TestCase): 31,-82,-98,-51,6,93,104,44,-5,-84,-107,-44,45,102,104, 15,-47,-107,-126,-87,-11,89,93,13,-95,-136,-187,-70, -167,216,-70,-103,175,-284,-486) - src = gr.vector_source_s(data) - enc = codec2_encode_sp() - dec = codec2_decode_ps() - snk = gr.vector_sink_s() + src = blocks.vector_source_s(data) + enc = vocoder.codec2_encode_sp() + dec = vocoder.codec2_decode_ps() + snk = blocks.vector_sink_s() self.tb.connect(src, enc, dec, snk) self.tb.run() actual_result = snk.data() diff --git a/gr-vocoder/python/qa_cvsd_vocoder.py b/gr-vocoder/python/qa_cvsd_vocoder.py index 42cb7f19b9..548c877526 100755 --- a/gr-vocoder/python/qa_cvsd_vocoder.py +++ b/gr-vocoder/python/qa_cvsd_vocoder.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2007,2010,2011 Free Software Foundation, Inc. +# Copyright 2007,2010,2011,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -21,8 +21,8 @@ # from gnuradio import gr, gr_unittest -from vocoder_swig import * -from cvsd import * +import vocoder_swig as vocoder +import cvsd import blocks_swig as blocks import filter_swig as filter @@ -35,10 +35,10 @@ class test_cvsd_vocoder (gr_unittest.TestCase): self.tb = None def test001_module_load (self): - raw_enc = cvsd_encode_sb() - raw_dec = cvsd_decode_bs() - hb_enc = cvsd_encode_fb() - hb_dec = cvsd_decode_bf() + raw_enc = vocoder.cvsd_encode_sb() + raw_dec = vocoder.cvsd_decode_bs() + hb_enc = cvsd.cvsd_encode_fb() + hb_dec = cvsd.cvsd_decode_bf() """ Disable for now @@ -100,20 +100,20 @@ class test_cvsd_vocoder (gr_unittest.TestCase): # WARNING: not importing analog in this QA code. # If we enable this, we can probably just create a sin with numpy. src = analog.sig_source_f(sample_rate, analog.GR_SIN_WAVE, 200, 1, 0) - head = gr.head(gr.sizeof_float, 100) + head = blocks.head(gr.sizeof_float, 100) src_scale = blocks.multiply_const_ff(scale_factor) interp = filter.rational_resampler_fff(8, 1) f2s = blocks.float_to_short() - enc = cvsd_vocoder.encode_sb() - dec = cvsd_vocoder.decode_bs() + enc = vocoder.cvsd_vocoder.encode_sb() + dec = vocoder.cvsd_vocoder.decode_bs() s2f = blocks.short_to_float() decim = filter.rational_resampler_fff(1, 8) sink_scale = blocks.multiply_const_ff(1.0/scale_factor) - sink = gr.vector_sink_f() + sink = blocks.vector_sink_f() self.tb.connect(src, src_scale, interp, f2s, enc) self.tb.connect(enc, dec, s2f, decim, sink_scale, head, sink) diff --git a/gr-vocoder/python/qa_g721_vocoder.py b/gr-vocoder/python/qa_g721_vocoder.py index e6ac04e155..ed53771076 100755 --- a/gr-vocoder/python/qa_g721_vocoder.py +++ b/gr-vocoder/python/qa_g721_vocoder.py @@ -21,7 +21,8 @@ # from gnuradio import gr, gr_unittest -from vocoder_swig import * +import vocoder_swig as vocoder +import blocks_swig as blocks class test_g721_vocoder (gr_unittest.TestCase): @@ -34,10 +35,10 @@ class test_g721_vocoder (gr_unittest.TestCase): def test001_module_load (self): data = (8,24,36,52,56,64,76,88,104,124,132,148,172, 196,220,244,280,320,372,416,468,524,580,648) - src = gr.vector_source_s(data) - enc = g721_encode_sb() - dec = g721_decode_bs() - snk = gr.vector_sink_s() + src = blocks.vector_source_s(data) + enc = vocoder.g721_encode_sb() + dec = vocoder.g721_decode_bs() + snk = blocks.vector_sink_s() self.tb.connect(src, enc, dec, snk) self.tb.run() actual_result = snk.data() diff --git a/gr-vocoder/python/qa_g723_24_vocoder.py b/gr-vocoder/python/qa_g723_24_vocoder.py index eda9ed86bd..f473e85677 100755 --- a/gr-vocoder/python/qa_g723_24_vocoder.py +++ b/gr-vocoder/python/qa_g723_24_vocoder.py @@ -21,7 +21,8 @@ # from gnuradio import gr, gr_unittest -from vocoder_swig import * +import vocoder_swig as vocoder +import blocks_swig as blocks class test_g723_24_vocoder (gr_unittest.TestCase): @@ -33,10 +34,10 @@ class test_g723_24_vocoder (gr_unittest.TestCase): def test001_module_load (self): data = (0,16,36,40,68,104,148,220,320,512) - src = gr.vector_source_s(data) - enc = g723_24_encode_sb() - dec = g723_24_decode_bs() - snk = gr.vector_sink_s() + src = blocks.vector_source_s(data) + enc = vocoder.g723_24_encode_sb() + dec = vocoder.g723_24_decode_bs() + snk = blocks.vector_sink_s() self.tb.connect(src, enc, dec, snk) self.tb.run() actual_result = snk.data() diff --git a/gr-vocoder/python/qa_g723_40_vocoder.py b/gr-vocoder/python/qa_g723_40_vocoder.py index db6b7538f3..e7ca4587b7 100755 --- a/gr-vocoder/python/qa_g723_40_vocoder.py +++ b/gr-vocoder/python/qa_g723_40_vocoder.py @@ -21,7 +21,8 @@ # from gnuradio import gr, gr_unittest -from vocoder_swig import * +import vocoder_swig as vocoder +import blocks_swig as blocks class test_g723_40_vocoder (gr_unittest.TestCase): @@ -33,10 +34,10 @@ class test_g723_40_vocoder (gr_unittest.TestCase): def test001_module_load (self): data = (0,8,36,72,100,152,228,316,404,528) - src = gr.vector_source_s(data) - enc = g723_40_encode_sb() - dec = g723_40_decode_bs() - snk = gr.vector_sink_s() + src = blocks.vector_source_s(data) + enc = vocoder.g723_40_encode_sb() + dec = vocoder.g723_40_decode_bs() + snk = blocks.vector_sink_s() self.tb.connect(src, enc, dec, snk) self.tb.run() actual_result = snk.data() diff --git a/gr-vocoder/python/qa_gsm_full_rate.py b/gr-vocoder/python/qa_gsm_full_rate.py index 4a7692ecd4..a62781ea94 100755 --- a/gr-vocoder/python/qa_gsm_full_rate.py +++ b/gr-vocoder/python/qa_gsm_full_rate.py @@ -21,7 +21,8 @@ # from gnuradio import gr, gr_unittest -import vocoder_swig +import vocoder_swig as vocoder +import blocks_swig as blocks class test_gsm_vocoder (gr_unittest.TestCase): @@ -47,10 +48,10 @@ class test_gsm_vocoder (gr_unittest.TestCase): 680,600,240,168,112,408,488,472,608,480,240,232, 208,288,480,600,616,520,176,88,184,296,392,584, 656,552,248,160,144,336,432,512,608,664) - src = gr.vector_source_s(data) - enc = vocoder_swig.gsm_fr_encode_sp() - dec = vocoder_swig.gsm_fr_decode_ps() - snk = gr.vector_sink_s() + src = blocks.vector_source_s(data) + enc = vocoder.gsm_fr_encode_sp() + dec = vocoder.gsm_fr_decode_ps() + snk = blocks.vector_sink_s() self.tb.connect(src, enc, dec, snk) self.tb.run() actual_result = snk.data() diff --git a/gr-vocoder/python/qa_ulaw_vocoder.py b/gr-vocoder/python/qa_ulaw_vocoder.py index a87aae762c..a030e065cc 100755 --- a/gr-vocoder/python/qa_ulaw_vocoder.py +++ b/gr-vocoder/python/qa_ulaw_vocoder.py @@ -21,7 +21,8 @@ # from gnuradio import gr, gr_unittest -from vocoder_swig import * +import vocoder_swig as vocoder +import blocks_swig as blocks class test_ulaw_vocoder (gr_unittest.TestCase): @@ -34,10 +35,10 @@ class test_ulaw_vocoder (gr_unittest.TestCase): def test001_module_load (self): data = (8,24,40,56,72,88,104,120,132,148,164,180, 196,212,228,244,260,276,292,308,324,340) - src = gr.vector_source_s(data) - enc = ulaw_encode_sb() - dec = ulaw_decode_bs() - snk = gr.vector_sink_s() + src = blocks.vector_source_s(data) + enc = vocoder.ulaw_encode_sb() + dec = vocoder.ulaw_decode_bs() + snk = blocks.vector_sink_s() self.tb.connect(src, enc, dec, snk) self.tb.run() actual_result = snk.data() diff --git a/gr-wavelet/python/qa_classify.py b/gr-wavelet/python/qa_classify.py index c2972c92f2..8dfc6ca5f9 100755 --- a/gr-wavelet/python/qa_classify.py +++ b/gr-wavelet/python/qa_classify.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2008,2010 Free Software Foundation, Inc. +# Copyright 2008,2010,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -51,8 +51,8 @@ class test_classify(gr_unittest.TestCase): # def test_000_(self): # src_data = numpy.zeros(10) # trg_data = numpy.zeros(10) -# src = gr.vector_source_f(src_data) -# dst = gr.vector_sink_f() +# src = blocks.vector_source_f(src_data) +# dst = blocks.vector_sink_f() # self.tb.connect(src, dst) # self.tb.run() # rsl_data = dst.data() @@ -66,8 +66,8 @@ class test_classify(gr_unittest.TestCase): def test_001_(self): src_data = numpy.array([-1.0, 1.0, -1.0, 1.0]) trg_data = src_data * 0.5 - src = gr.vector_source_f(src_data) - dst = gr.vector_sink_f() + src = blocks.vector_source_f(src_data) + dst = blocks.vector_sink_f() rail = analog.rail_ff(-0.5, 0.5) self.tb.connect(src, rail) self.tb.connect(rail, dst) @@ -88,9 +88,9 @@ class test_classify(gr_unittest.TestCase): -1.0/5.0]) trg_data = copy.deepcopy(src_data) - src = gr.vector_source_f(src_data, False, len(src_data)) + src = blocks.vector_source_f(src_data, False, len(src_data)) st = blocks.stretch_ff(-1.0/5.0, len(src_data)) - dst = gr.vector_sink_f(len(src_data)) + dst = blocks.vector_sink_f(len(src_data)) self.tb.connect(src, st) self.tb.connect(st, dst) self.tb.run() @@ -107,9 +107,9 @@ class test_classify(gr_unittest.TestCase): trg_grid = copy.deepcopy(src_grid) src_data = (0.0, 1.0, 0.0, 1.0, 0.0) - src = gr.vector_source_f(src_data, False, len(src_grid)) + src = blocks.vector_source_f(src_data, False, len(src_grid)) sq = wavelet_swig.squash_ff(src_grid, trg_grid) - dst = gr.vector_sink_f(len(trg_grid)) + dst = blocks.vector_sink_f(len(trg_grid)) self.tb.connect(src, sq) self.tb.connect(sq, dst) self.tb.run() @@ -133,10 +133,10 @@ class test_classify(gr_unittest.TestCase): # c = w.transform_forward(b, ws) # d = w.transform_inverse(c, ws) # -# src = gr.vector_source_f(b, False, n) +# src = blocks.vector_source_f(b, False, n) # wv = wavelet_swig.wavelet_ff(n, o, True) # -# dst = gr.vector_sink_f(n) +# dst = blocks.vector_sink_f(n) # self.tb.connect(src, wv) # self.tb.connect(wv, dst) # self.tb.run() @@ -162,9 +162,9 @@ class test_classify(gr_unittest.TestCase): wvps[e] = scl*sqr(dwav[k:k+(01<<e)]).sum() k += 01<<e - src = gr.vector_source_f(src_data, False, len(src_data)) + src = blocks.vector_source_f(src_data, False, len(src_data)) kon = wavelet_swig.wvps_ff(len(src_data)) - dst = gr.vector_sink_f(int(math.ceil(math.log(len(src_data), 2)))) + dst = blocks.vector_sink_f(int(math.ceil(math.log(len(src_data), 2)))) self.tb.connect(src, kon) self.tb.connect(kon, dst) diff --git a/gr-wxgui/CMakeLists.txt b/gr-wxgui/CMakeLists.txt index 04c4a26569..52e0a7061d 100644 --- a/gr-wxgui/CMakeLists.txt +++ b/gr-wxgui/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2011 Free Software Foundation, Inc. +# Copyright 2011,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -22,8 +22,8 @@ ######################################################################## include(GrPython) -GR_PYTHON_CHECK_MODULE("wx >= 2.8" wx "wx.version().split()[0] >= '2.8'" WX_FOUND) -GR_PYTHON_CHECK_MODULE("numpy" numpy True NUMPY_FOUND) +GR_PYTHON_CHECK_MODULE("wx >= 2.8" wx "wx.version().split()[0] >= '2.8'" WX_FOUND) +GR_PYTHON_CHECK_MODULE("numpy" numpy True NUMPY_FOUND) ######################################################################## # Register component @@ -50,6 +50,13 @@ GR_REGISTER_COMPONENT("gr-wxgui" ENABLE_GR_WXGUI ######################################################################## if(ENABLE_GR_WXGUI) +GR_SET_GLOBAL(GR_WXGUI_INCLUDE_DIRS + ${CMAKE_CURRENT_SOURCE_DIR}/lib + ${CMAKE_CURRENT_SOURCE_DIR}/include + ${CMAKE_CURRENT_BINARY_DIR}/lib + ${CMAKE_CURRENT_BINARY_DIR}/include +) + ######################################################################## # Setup CPack components ######################################################################## @@ -86,7 +93,10 @@ install( ######################################################################## # Add subdirectories ######################################################################## +add_subdirectory(include/wxgui) +add_subdirectory(lib) add_subdirectory(grc) +add_subdirectory(swig) add_subdirectory(python) endif(ENABLE_GR_WXGUI) diff --git a/gr-wxgui/grc/wxgui_constellationsink2.xml b/gr-wxgui/grc/wxgui_constellationsink2.xml index f9df9d4acd..1c0789e2c0 100644 --- a/gr-wxgui/grc/wxgui_constellationsink2.xml +++ b/gr-wxgui/grc/wxgui_constellationsink2.xml @@ -9,6 +9,7 @@ <key>wxgui_constellationsink2</key> <category>WX GUI Widgets</category> <import>from gnuradio.wxgui import constsink_gl</import> + <import>from gnuradio import wxgui</import> <make>#set $parent = $notebook() and 'self.%s.GetPage(%s)'%$notebook() or 'self' constsink_gl.const_sink_c( $(parent).GetWin(), diff --git a/gr-wxgui/grc/wxgui_fftsink2.xml b/gr-wxgui/grc/wxgui_fftsink2.xml index ff5c47b85c..086f7de753 100644 --- a/gr-wxgui/grc/wxgui_fftsink2.xml +++ b/gr-wxgui/grc/wxgui_fftsink2.xml @@ -10,6 +10,7 @@ <category>WX GUI Widgets</category> <import>from gnuradio.fft import window</import> <import>from gnuradio.wxgui import fftsink2</import> + <import>from gnuradio import wxgui</import> <make>#set $parent = $notebook() and 'self.%s.GetPage(%s)'%$notebook() or 'self' fftsink2.$(type.fcn)( $(parent).GetWin(), diff --git a/gr-wxgui/grc/wxgui_histosink2.xml b/gr-wxgui/grc/wxgui_histosink2.xml index f4f6a29597..39237755e8 100644 --- a/gr-wxgui/grc/wxgui_histosink2.xml +++ b/gr-wxgui/grc/wxgui_histosink2.xml @@ -9,6 +9,7 @@ <key>wxgui_histosink2</key> <category>WX GUI Widgets</category> <import>from gnuradio.wxgui import histosink_gl</import> + <import>from gnuradio import wxgui</import> <make>#set $parent = $notebook() and 'self.%s.GetPage(%s)'%$notebook() or 'self' histosink_gl.histo_sink_f( $(parent).GetWin(), diff --git a/gr-wxgui/grc/wxgui_numbersink2.xml b/gr-wxgui/grc/wxgui_numbersink2.xml index 2559266101..8e47db26e2 100644 --- a/gr-wxgui/grc/wxgui_numbersink2.xml +++ b/gr-wxgui/grc/wxgui_numbersink2.xml @@ -9,6 +9,7 @@ <key>wxgui_numbersink2</key> <category>WX GUI Widgets</category> <import>from gnuradio.wxgui import numbersink2</import> + <import>from gnuradio import wxgui</import> <make>#set $parent = $notebook() and 'self.%s.GetPage(%s)'%$notebook() or 'self' numbersink2.$(type.fcn)( $(parent).GetWin(), diff --git a/gr-wxgui/grc/wxgui_scopesink2.xml b/gr-wxgui/grc/wxgui_scopesink2.xml index dbf983e112..596fe03397 100644 --- a/gr-wxgui/grc/wxgui_scopesink2.xml +++ b/gr-wxgui/grc/wxgui_scopesink2.xml @@ -9,7 +9,7 @@ <key>wxgui_scopesink2</key> <category>WX GUI Widgets</category> <import>from gnuradio.wxgui import scopesink2</import> - <import>from gnuradio import gr</import> + <import>from gnuradio import wxgui</import> <make>#set $parent = $notebook() and 'self.%s.GetPage(%s)'%$notebook() or 'self' scopesink2.$(type.fcn)( $(parent).GetWin(), @@ -143,19 +143,19 @@ $(parent).GridAdd(self.$(id).win, $(', '.join(map(str, $grid_pos())))) <type>enum</type> <option> <name>Auto</name> - <key>gr.gr_TRIG_MODE_AUTO</key> + <key>wxgui.TRIG_MODE_AUTO</key> </option> <option> <name>Normal</name> - <key>gr.gr_TRIG_MODE_NORM</key> + <key>wxgui.TRIG_MODE_NORM</key> </option> <option> <name>Freerun</name> - <key>gr.gr_TRIG_MODE_FREE</key> + <key>wxgui.TRIG_MODE_FREE</key> </option> <option> <name>Stripchart</name> - <key>gr.gr_TRIG_MODE_STRIPCHART</key> + <key>wxgui.TRIG_MODE_STRIPCHART</key> </option> </param> <param> diff --git a/gr-wxgui/grc/wxgui_termsink.xml b/gr-wxgui/grc/wxgui_termsink.xml index 3e35c75788..a13927926b 100644 --- a/gr-wxgui/grc/wxgui_termsink.xml +++ b/gr-wxgui/grc/wxgui_termsink.xml @@ -10,6 +10,7 @@ <category>WX GUI Widgets</category> <import>from gnuradio.wxgui import termsink</import> + <import>from gnuradio import wxgui</import> <make>#set $parent = $notebook() and 'self.%s.GetPage(%s)'%$notebook() or 'self' termsink.termsink( diff --git a/gr-wxgui/grc/wxgui_waterfallsink2.xml b/gr-wxgui/grc/wxgui_waterfallsink2.xml index c02901d336..971e90f413 100644 --- a/gr-wxgui/grc/wxgui_waterfallsink2.xml +++ b/gr-wxgui/grc/wxgui_waterfallsink2.xml @@ -10,6 +10,7 @@ <category>WX GUI Widgets</category> <import>from gnuradio.fft import window</import> <import>from gnuradio.wxgui import waterfallsink2</import> + <import>from gnuradio import wxgui</import> <make>#set $parent = $notebook() and 'self.%s.GetPage(%s)'%$notebook() or 'self' waterfallsink2.$(type.fcn)( $(parent).GetWin(), diff --git a/gr-digital/include/CMakeLists.txt b/gr-wxgui/include/wxgui/CMakeLists.txt index a32f11ed4d..fad84792e1 100644 --- a/gr-digital/include/CMakeLists.txt +++ b/gr-wxgui/include/wxgui/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2011,2012 Free Software Foundation, Inc. +# Copyright 2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -21,14 +21,12 @@ # Install header files ######################################################################## install(FILES - digital_crc32_bb.h - digital_ofdm_carrier_allocator_cvc.h - digital_ofdm_chanest_vcvc.h - digital_ofdm_cyclic_prefixer.h - digital_ofdm_equalizer_base.h - digital_ofdm_equalizer_simpledfe.h - digital_ofdm_equalizer_static.h - digital_ofdm_sync_sc_cfb.h - DESTINATION ${GR_INCLUDE_DIR}/gnuradio - COMPONENT "digital_devel" + api.h + histo_sink_f.h + oscope_guts.h + oscope_sink_f.h + oscope_sink_x.h + trigger_mode.h + DESTINATION ${GR_INCLUDE_DIR}/gnuradio/wxgui + COMPONENT "wxgui_devel" ) diff --git a/gnuradio-core/src/lib/general/gr_null_sink.i b/gr-wxgui/include/wxgui/api.h index 80411f9b74..442e112e4b 100644 --- a/gnuradio-core/src/lib/general/gr_null_sink.i +++ b/gr-wxgui/include/wxgui/api.h @@ -1,6 +1,5 @@ -/* -*- c++ -*- */ /* - * Copyright 2004,2010 Free Software Foundation, Inc. + * Copyright 2013 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,12 +19,15 @@ * Boston, MA 02110-1301, USA. */ -GR_SWIG_BLOCK_MAGIC(gr,null_sink) +#ifndef INCLUDED_WXGUI_API_H +#define INCLUDED_WXGUI_API_H -gr_null_sink_sptr gr_make_null_sink (size_t sizeof_stream_item); +#include <gruel/attributes.h> -class gr_null_sink : public gr_sync_block { -private: - gr_null_sink (size_t sizeof_stream_item); -}; +#ifdef gnuradio_wxgui_EXPORTS +# define WXGUI_API __GR_ATTR_EXPORT +#else +# define WXGUI_API __GR_ATTR_IMPORT +#endif +#endif /* INCLUDED_WXGUI_API_H */ diff --git a/gr-wxgui/include/wxgui/histo_sink_f.h b/gr-wxgui/include/wxgui/histo_sink_f.h new file mode 100644 index 0000000000..f65517ca35 --- /dev/null +++ b/gr-wxgui/include/wxgui/histo_sink_f.h @@ -0,0 +1,55 @@ +/* -*- c++ -*- */ +/* + * Copyright 2009,2013 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_HISTO_SINK_F_H +#define INCLUDED_GR_HISTO_SINK_F_H + +#include <wxgui/api.h> +#include <gr_sync_block.h> +#include <gr_msg_queue.h> + +namespace gr { + namespace wxgui { + + /*! + * \brief Histogram module. + * \ingroup sink_blk + */ + class WXGUI_API histo_sink_f : virtual public gr_sync_block + { + public: + // gr::blocks::histo_sink_f::sptr + typedef boost::shared_ptr<histo_sink_f> sptr; + + static sptr make(gr_msg_queue_sptr msgq); + + virtual unsigned int get_frame_size(void) = 0; + virtual unsigned int get_num_bins(void) = 0; + + virtual void set_frame_size(unsigned int frame_size) = 0; + virtual void set_num_bins(unsigned int num_bins) = 0; + }; + + } /* namespace wxgui */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_HISTO_SINK_F_H */ diff --git a/gr-wxgui/include/wxgui/oscope_guts.h b/gr-wxgui/include/wxgui/oscope_guts.h new file mode 100644 index 0000000000..a6abd81539 --- /dev/null +++ b/gr-wxgui/include/wxgui/oscope_guts.h @@ -0,0 +1,131 @@ +/* -*- c++ -*- */ +/* + * Copyright 2003,2005,2013 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_OSCOPE_GUTS_H +#define INCLUDED_GR_OSCOPE_GUTS_H + +#include <wxgui/api.h> +#include <wxgui/trigger_mode.h> +#include <gr_msg_queue.h> + +namespace gr { + namespace wxgui { + + /*! + * \brief guts of oscilloscope trigger and buffer module + * + * This module processes sets of samples provided the \p + * process_sample method. When appropriate given the updateRate, + * sampleRate and trigger conditions, process_sample will + * periodically write output records of captured data to + * output_fd. For each trigger event, nchannels records will be + * written. Each record consists of get_samples_per_output_record + * binary floats. The trigger instant occurs at the 1/2 way point + * in the buffer. Thus, output records consist of 50% pre-trigger + * data and 50% post-trigger data. + */ + + class WXGUI_API oscope_guts + { + public: + static const int MAX_CHANNELS = 8; + + private: + enum scope_state { HOLD_OFF, LOOK_FOR_TRIGGER, POST_TRIGGER }; + + int d_nchannels; // how many channels + gr_msg_queue_sptr d_msgq; // message queue we stuff output records into + trigger_mode d_trigger_mode; + trigger_slope d_trigger_slope; + int d_trigger_channel; // which channel to watch for trigger condition + double d_sample_rate; // input sample rate in Hz + double d_update_rate; // approx freq to produce an output record (Hz) + double d_trigger_level; + + int d_obi; // output buffer index + float *d_buffer[MAX_CHANNELS]; + + scope_state d_state; + int d_decimator_count; + int d_decimator_count_init; + int d_hold_off_count; + int d_hold_off_count_init; + int d_pre_trigger_count; + int d_post_trigger_count; + int d_post_trigger_count_init; + float d_trigger_off; //%sample trigger is off + + // NOT IMPLEMENTED + oscope_guts(const oscope_guts &rhs); // no copy constructor + oscope_guts &operator= (const oscope_guts &rhs); // no assignment operator + + void trigger_changed(); + void update_rate_or_decimation_changed(); + bool found_trigger(); // returns true if found + void write_output_records(); + + void enter_hold_off(); // called on state entry + void enter_look_for_trigger(); + void enter_post_trigger(); + + public: + // CREATORS + oscope_guts(double sample_rate, gr_msg_queue_sptr msgq); + ~oscope_guts(); + + // MANIPULATORS + + /*! + * \param channel_data points to nchannels float values. These + * are the values for each channel at this sample time. + */ + void process_sample(const float *channel_data); + + bool set_update_rate(double update_rate); + bool set_decimation_count(int decimation_count); + bool set_trigger_channel(int channel); + bool set_trigger_mode(trigger_mode mode); + bool set_trigger_slope(trigger_slope slope); + bool set_trigger_level(double trigger_level); + bool set_trigger_level_auto(); // set to 50% level + bool set_sample_rate(double sample_rate); + bool set_num_channels(int nchannels); + + // ACCESSORS + int num_channels() const; + double sample_rate() const; + double update_rate() const; + int get_decimation_count() const; + int get_trigger_channel() const; + trigger_mode get_trigger_mode() const; + trigger_slope get_trigger_slope() const; + double get_trigger_level() const; + + // # of samples written to each output record. + int get_samples_per_output_record() const; + }; + + } /* namespace wxgui */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_OSCOPE_GUTS_H */ diff --git a/gnuradio-core/src/lib/io/i2c_bbio.h b/gr-wxgui/include/wxgui/oscope_sink_f.h index 6bf47b9cd0..a7c7657d40 100644 --- a/gnuradio-core/src/lib/io/i2c_bbio.h +++ b/gr-wxgui/include/wxgui/oscope_sink_f.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2001,2004 Free Software Foundation, Inc. + * Copyright 2003-2005,2013 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,32 +20,34 @@ * Boston, MA 02110-1301, USA. */ -#ifndef INCLUDED_I2C_BBIO_H -#define INCLUDED_I2C_BBIO_H +#ifndef INCLUDED_GR_OSCOPE_SINK_F_H +#define INCLUDED_GR_OSCOPE_SINK_F_H -#include <gr_core_api.h> -#include <boost/shared_ptr.hpp> +#include <wxgui/api.h> +#include <wxgui/oscope_sink_x.h> +#include <gr_msg_queue.h> -class i2c_bbio; -typedef boost::shared_ptr<i2c_bbio> i2c_bbio_sptr; +namespace gr { + namespace wxgui { + /*! + * \brief Building block for python oscilloscope module. + * \ingroup sink_blk + * + * Accepts multiple float streams. + */ + class WXGUI_API oscope_sink_f + : virtual public oscope_sink_x + { + public: + // gr::blocks::oscope_sink_f::sptr + typedef boost::shared_ptr<oscope_sink_f> sptr; -/*! - * \brief abstract class that implements bit banging i/o for i2c bus. - * \ingroup base - */ -class GR_CORE_API i2c_bbio { - public: - - i2c_bbio () {} - virtual ~i2c_bbio (); + static sptr make(double sampling_rate, gr_msg_queue_sptr msgq); + }; - virtual void set_scl (bool state) = 0; - virtual void set_sda (bool state) = 0; - virtual bool get_sda () = 0; + } /* namespace wxgui */ +} /* namespace gr */ - virtual void lock () = 0; - virtual void unlock () = 0; -}; +#endif /* INCLUDED_GR_OSCOPE_SINK_F_H */ -#endif /* INCLUDED_I2C_BBIO_H */ diff --git a/gr-wxgui/include/wxgui/oscope_sink_x.h b/gr-wxgui/include/wxgui/oscope_sink_x.h new file mode 100644 index 0000000000..17fa9a0f5a --- /dev/null +++ b/gr-wxgui/include/wxgui/oscope_sink_x.h @@ -0,0 +1,91 @@ +/* -*- c++ -*- */ +/* + * Copyright 2003,2004,2013 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_OSCOPE_SINK_X_H +#define INCLUDED_GR_OSCOPE_SINK_X_H + +#include <wxgui/api.h> +#include <wxgui/trigger_mode.h> +#include <wxgui/oscope_guts.h> +#include <gr_sync_block.h> + +namespace gr { + namespace wxgui { + + /*! + * \brief Abstract class for python oscilloscope module. + * \ingroup sink_blk + * + * Don't instantiate this. Use gr::blocks::oscope_sink_f instead. + */ + class WXGUI_API oscope_sink_x : public gr_sync_block + { + protected: + double d_sampling_rate; + oscope_guts *d_guts; + + oscope_sink_x() {}; + oscope_sink_x(const std::string name, + gr_io_signature_sptr input_sig, + double sampling_rate); + public: + virtual ~oscope_sink_x(); + + //// gr::blocks::oscope_sink_x::sptr + //typedef boost::shared_ptr<oscope_sink_x> sptr; + // + //static sptr make(const std::string name, + // gr_io_signature_sptr input_sig, + // double sampling_rate); + + bool set_update_rate(double update_rate); + bool set_decimation_count(int decimation_count); + bool set_trigger_channel(int channel); + bool set_trigger_mode(trigger_mode mode); + bool set_trigger_slope(trigger_slope slope); + bool set_trigger_level(double trigger_level); + bool set_trigger_level_auto(); + bool set_sample_rate(double sample_rate); + bool set_num_channels(int nchannels); + + // ACCESSORS + int num_channels() const; + double sample_rate() const; + double update_rate() const; + int get_decimation_count() const; + int get_trigger_channel() const; + trigger_mode get_trigger_mode() const; + trigger_slope get_trigger_slope() const; + double get_trigger_level() const; + + // # of samples written to each output record. + int get_samples_per_output_record() const; + + virtual int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) = 0; + }; + + } /* namespace wxgui */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_OSCOPE_SINK_X_H */ diff --git a/gnuradio-core/src/lib/io/gr_trigger_mode.h b/gr-wxgui/include/wxgui/trigger_mode.h index be131686b4..11654ef6c5 100644 --- a/gnuradio-core/src/lib/io/gr_trigger_mode.h +++ b/gr-wxgui/include/wxgui/trigger_mode.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2003,2004 Free Software Foundation, Inc. + * Copyright 2003,2004,2013 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -23,16 +23,22 @@ #ifndef INCLUDED_GR_TRIGGER_MODE_H #define INCLUDED_GR_TRIGGER_MODE_H -enum gr_trigger_mode { - gr_TRIG_MODE_FREE, - gr_TRIG_MODE_AUTO, - gr_TRIG_MODE_NORM, - gr_TRIG_MODE_STRIPCHART, -}; +namespace gr { + namespace wxgui { -enum gr_trigger_slope { - gr_TRIG_SLOPE_POS, - gr_TRIG_SLOPE_NEG, -}; + enum trigger_mode { + TRIG_MODE_FREE, + TRIG_MODE_AUTO, + TRIG_MODE_NORM, + TRIG_MODE_STRIPCHART, + }; + + enum trigger_slope { + TRIG_SLOPE_POS, + TRIG_SLOPE_NEG, + }; + + } /* namespace wxgui */ +} /* namespace gr */ #endif /* INCLUDED_GR_TRIGGER_MODE_H */ diff --git a/gr-wxgui/lib/CMakeLists.txt b/gr-wxgui/lib/CMakeLists.txt new file mode 100644 index 0000000000..8c7c56fdcc --- /dev/null +++ b/gr-wxgui/lib/CMakeLists.txt @@ -0,0 +1,78 @@ +# Copyright 2012-2013 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. + +######################################################################## +# Setup the include and linker paths +######################################################################## +include_directories( + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_BINARY_DIR}/../include + ${GR_WXGUI_INCLUDE_DIRS} + ${GNURADIO_CORE_INCLUDE_DIRS} + ${VOLK_INCLUDE_DIRS} + ${GRUEL_INCLUDE_DIRS} + ${Boost_INCLUDE_DIRS} +) + +link_directories(${Boost_LIBRARY_DIRS}) + +if(ENABLE_GR_CTRLPORT) + ADD_DEFINITIONS(-DGR_CTRLPORT) + include_directories(${ICE_INCLUDE_DIR}) +endif(ENABLE_GR_CTRLPORT) + +######################################################################## +# Setup library +######################################################################## +list(APPEND gr_wxgui_sources + histo_sink_f_impl.cc + oscope_guts.cc + oscope_sink_x.cc + oscope_sink_f_impl.cc +) + +#Add Windows DLL resource file if using MSVC +IF(MSVC) + include(${CMAKE_SOURCE_DIR}/cmake/Modules/GrVersion.cmake) + + configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/gnuradio-wxgui.rc.in + ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-wxgui.rc + @ONLY) + + list(APPEND gr_wxgui_sources + ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-wxgui.rc + ) +ENDIF(MSVC) + +list(APPEND wxgui_libs + gnuradio-core + volk + ${Boost_LIBRARIES} + ${BLOCKS_LIBRARIES} + ${LOG4CPP_LIBRARIES} +) + +add_library(gnuradio-wxgui SHARED ${gr_wxgui_sources}) + +target_link_libraries(gnuradio-wxgui ${wxgui_libs}) +GR_LIBRARY_FOO(gnuradio-wxgui + RUNTIME_COMPONENT "wxgui_runtime" + DEVEL_COMPONENT "wxgui_devel") diff --git a/gr-wxgui/lib/gnuradio-wxgui.rc.in b/gr-wxgui/lib/gnuradio-wxgui.rc.in new file mode 100644 index 0000000000..126db75091 --- /dev/null +++ b/gr-wxgui/lib/gnuradio-wxgui.rc.in @@ -0,0 +1,54 @@ +/* -*- c++ -*- */ +/* + * Copyright 2013 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. + */ +#include <afxres.h> + +VS_VERSION_INFO VERSIONINFO + FILEVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + PRODUCTVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + FILEFLAGSMASK 0x3fL +#ifndef NDEBUG + FILEFLAGS 0x0L +#else + FILEFLAGS 0x1L +#endif + FILEOS VOS__WINDOWS32 + FILETYPE VFT_DLL + FILESUBTYPE VFT2_DRV_INSTALLABLE + BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "FileDescription", "gnuradio-blocks" + VALUE "FileVersion", "@VERSION@" + VALUE "InternalName", "gnuradio-blocks.dll" + VALUE "LegalCopyright", "Licensed under GPLv3 or any later version" + VALUE "OriginalFilename", "gnuradio-blocks.dll" + VALUE "ProductName", "gnuradio-blocks" + VALUE "ProductVersion", "@VERSION@" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END + END diff --git a/gr-wxgui/lib/histo_sink_f_impl.cc b/gr-wxgui/lib/histo_sink_f_impl.cc new file mode 100644 index 0000000000..f9459ac8d9 --- /dev/null +++ b/gr-wxgui/lib/histo_sink_f_impl.cc @@ -0,0 +1,186 @@ +/* -*- c++ -*- */ +/* + * Copyright 2009-2011,2013 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 "histo_sink_f_impl.h" +#include <gr_io_signature.h> +#include <boost/math/special_functions/round.hpp> + +namespace gr { + namespace wxgui { + + static float get_clean_num(float num) + { + if(num == 0) + return 0; + /* extract sign and exponent from num */ + int sign = (num < 0) ? -1 : 1; num = fabs(num); + float exponent = floor(log10(num)); + /* search for closest number with base 1, 2, 5, 10 */ + float closest_num = 10*pow(10, exponent); + if(fabs(num - 1*pow(10, exponent)) < fabs(num - closest_num)) + closest_num = 1*pow(10, exponent); + if(fabs(num - 2*pow(10, exponent)) < fabs(num - closest_num)) + closest_num = 2*pow(10, exponent); + if(fabs(num - 5*pow(10, exponent)) < fabs(num - closest_num)) + closest_num = 5*pow(10, exponent); + return sign*closest_num; + } + + histo_sink_f::sptr + histo_sink_f::make(gr_msg_queue_sptr msgq) + { + return gnuradio::get_initial_sptr + (new histo_sink_f_impl(msgq)); + } + + histo_sink_f_impl::histo_sink_f_impl(gr_msg_queue_sptr msgq) + : gr_sync_block("histo_sink_f", + gr_make_io_signature(1, 1, sizeof(float)), + gr_make_io_signature(0, 0, 0)), + d_msgq(msgq), d_num_bins(11), d_frame_size(1000), + d_sample_count(0), d_bins(NULL), d_samps(NULL) + { + //allocate arrays and clear + set_num_bins(d_num_bins); + set_frame_size(d_frame_size); + } + + histo_sink_f_impl::~histo_sink_f_impl(void) + { + delete [] d_samps; + delete [] d_bins; + } + + int + histo_sink_f_impl::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]; + gruel::scoped_lock guard(d_mutex); // hold mutex for duration of this function + for(unsigned int i = 0; i < (unsigned int)noutput_items; i++) { + d_samps[d_sample_count] = in[i]; + d_sample_count++; + /* processed a frame? */ + if(d_sample_count == d_frame_size) { + send_frame(); + clear(); + } + } + return noutput_items; + } + + void + histo_sink_f_impl::send_frame(void) + { + /* output queue full, drop the data */ + if(d_msgq->full_p()) + return; + /* find the minimum and maximum */ + float minimum = d_samps[0]; + float maximum = d_samps[0]; + for(unsigned int i = 0; i < d_frame_size; i++) { + if(d_samps[i] < minimum) minimum = d_samps[i]; + if(d_samps[i] > maximum) maximum = d_samps[i]; + } + minimum = get_clean_num(minimum); + maximum = get_clean_num(maximum); + if(minimum == maximum || minimum > maximum) + return; //useless data or screw up? + /* load the bins */ + int index; + float bin_width = (maximum - minimum)/(d_num_bins-1); + for(unsigned int i = 0; i < d_sample_count; i++) { + index = boost::math::iround((d_samps[i] - minimum)/bin_width); + /* ensure the index range in case a small floating point error is involed */ + if(index < 0) + index = 0; + if(index >= (int)d_num_bins) + index = d_num_bins-1; + d_bins[index]++; + } + /* Build a message to hold the output records */ + gr_message_sptr msg = gr_make_message(0, minimum, maximum, d_num_bins*sizeof(float)); + float *out = (float *)msg->msg(); // get pointer to raw message buffer + /* normalize the bins and put into message */ + for(unsigned int i = 0; i < d_num_bins; i++) { + out[i] = ((float)d_bins[i])/d_frame_size; + } + /* send the message */ + d_msgq->handle(msg); + } + + void + histo_sink_f_impl::clear(void) + { + d_sample_count = 0; + /* zero the bins */ + for(unsigned int i = 0; i < d_num_bins; i++) { + d_bins[i] = 0; + } + } + + /************************************************** + * Getters + **************************************************/ + unsigned int + histo_sink_f_impl::get_frame_size(void) + { + return d_frame_size; + } + + unsigned int + histo_sink_f_impl::get_num_bins(void) + { + return d_num_bins; + } + + /************************************************** + * Setters + **************************************************/ + void + histo_sink_f_impl::set_frame_size(unsigned int frame_size) + { + gruel::scoped_lock guard(d_mutex); // hold mutex for duration of this function + d_frame_size = frame_size; + /* allocate a new sample array */ + delete [] d_samps; + d_samps = new float[d_frame_size]; + clear(); + } + + void + histo_sink_f_impl::set_num_bins(unsigned int num_bins) { + gruel::scoped_lock guard(d_mutex); // hold mutex for duration of this function + d_num_bins = num_bins; + /* allocate a new bin array */ + delete [] d_bins; + d_bins = new unsigned int[d_num_bins]; + clear(); + } + + } /* namespace wxgui */ +} /* namespace gr */ diff --git a/gr-wxgui/lib/histo_sink_f_impl.h b/gr-wxgui/lib/histo_sink_f_impl.h new file mode 100644 index 0000000000..e160e0e550 --- /dev/null +++ b/gr-wxgui/lib/histo_sink_f_impl.h @@ -0,0 +1,63 @@ +/* -*- c++ -*- */ +/* + * Copyright 2009,2013 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_HISTO_SINK_F_IMPL_H +#define INCLUDED_GR_HISTO_SINK_F_IMPL_H + +#include <wxgui/histo_sink_f.h> + +namespace gr { + namespace wxgui { + + class histo_sink_f_impl : public histo_sink_f + { + private: + gr_msg_queue_sptr d_msgq; + unsigned int d_num_bins; + unsigned int d_frame_size; + unsigned int d_sample_count; + unsigned int *d_bins; + float *d_samps; + gruel::mutex d_mutex; + + void send_frame(void); + void clear(void); + + public: + histo_sink_f_impl(gr_msg_queue_sptr msgq); + ~histo_sink_f_impl(void); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + + unsigned int get_frame_size(void); + unsigned int get_num_bins(void); + + void set_frame_size(unsigned int frame_size); + void set_num_bins(unsigned int num_bins); + }; + + } /* namespace wxgui */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_HISTO_SINK_F_IMPL_H */ diff --git a/gr-wxgui/lib/oscope_guts.cc b/gr-wxgui/lib/oscope_guts.cc new file mode 100644 index 0000000000..3d1f085a6f --- /dev/null +++ b/gr-wxgui/lib/oscope_guts.cc @@ -0,0 +1,439 @@ +/* -*- c++ -*- */ +/* + * Copyright 2003,2005,2013 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 <wxgui/oscope_guts.h> +#include <stdexcept> +#include <stdio.h> +#include <algorithm> +#include <unistd.h> +#include <math.h> +#include <assert.h> + +namespace gr { + namespace wxgui { + + /* + * Bad performance if it's large, and flaky triggering if it's too small + */ + static const int OUTPUT_RECORD_SIZE = 1024; // Must be power of 2 + + /* + * For (slow-updated) STRIPCHART triggering, we make the record + * size larger, since we potentially want to be able to "see" + * hours of data. This works as long as the update rates to a + * STRIPCHART are low, which they generally are--that's rather + * what a stripchart is all about! + */ + static const int SCHART_MULT = 8; + + + static inline int + wrap_bi(int buffer_index, int mx) // wrap buffer index + { + return buffer_index & (mx - 1); + } + + static inline int + incr_bi(int buffer_index, int mx) // increment buffer index + { + return wrap_bi(buffer_index + 1, mx); + } + + static inline int + decr_bi(int buffer_index, int mx) // decrement buffer index + { + return wrap_bi(buffer_index - 1, mx); + } + + oscope_guts::oscope_guts(double sample_rate, gr_msg_queue_sptr msgq) + : d_nchannels(1), + d_msgq(msgq), + d_trigger_mode(TRIG_MODE_AUTO), + d_trigger_slope(TRIG_SLOPE_POS), + d_trigger_channel(0), + d_sample_rate(sample_rate), + d_update_rate(20), + d_trigger_level(0), + d_obi(0), + d_state(HOLD_OFF), + d_decimator_count(0), + d_decimator_count_init(1), + d_hold_off_count(0), + d_hold_off_count_init(OUTPUT_RECORD_SIZE/2-1), + d_pre_trigger_count(0), + d_post_trigger_count(0), + d_post_trigger_count_init(OUTPUT_RECORD_SIZE/2) + { + for(int i = 0; i < MAX_CHANNELS; i++) + d_buffer[i] = 0; + + for(int i = 0; i < MAX_CHANNELS; i++) { + d_buffer[i] = new float[OUTPUT_RECORD_SIZE*SCHART_MULT]; + for(int j = 0; j < OUTPUT_RECORD_SIZE*SCHART_MULT; j++) + d_buffer[i][j] = 0.0; + } + + // be sure buffer is full before first write + enter_hold_off(); + update_rate_or_decimation_changed(); + } + + oscope_guts::~oscope_guts() + { + for(int i = 0; i < MAX_CHANNELS; i++) + delete [] d_buffer[i]; + } + + // MANIPULATORS + void + oscope_guts::process_sample(const float *channel_data) + { + d_decimator_count--; + if(d_decimator_count > 0) + return; + + d_decimator_count = d_decimator_count_init; + + if(d_trigger_mode != TRIG_MODE_STRIPCHART) { + for(int i = 0; i < d_nchannels; i++) + d_buffer[i][d_obi] = channel_data[i]; // copy data into buffer + + switch(d_state) { + case HOLD_OFF: + d_hold_off_count--; + if(d_hold_off_count <= 0) + enter_look_for_trigger (); + break; + + case LOOK_FOR_TRIGGER: + if(found_trigger()) + enter_post_trigger(); + break; + + case POST_TRIGGER: + d_post_trigger_count--; + if(d_post_trigger_count <= 0) { + write_output_records(); + enter_hold_off(); + } + break; + + default: + assert(0); + } + + d_obi = incr_bi(d_obi, OUTPUT_RECORD_SIZE); + } + else { + for(int i = 0; i < d_nchannels; i++) { + for(int j = (OUTPUT_RECORD_SIZE*SCHART_MULT)-1; j > 0; j--) { + d_buffer[i][j] = d_buffer[i][j-1]; + } + d_buffer[i][0] = channel_data[i]; + } + d_trigger_off = 0; + write_output_records(); + } + } + + /* + * Functions called on state entry + */ + + void + oscope_guts::enter_hold_off() + { + d_state = HOLD_OFF; + d_hold_off_count = d_hold_off_count_init; + } + + void + oscope_guts::enter_look_for_trigger() + { + d_pre_trigger_count = 0; + d_state = LOOK_FOR_TRIGGER; + } + + void + oscope_guts::enter_post_trigger() + { + d_state = POST_TRIGGER; + d_post_trigger_count = d_post_trigger_count_init; + //ensure that the trigger offset is no more than than half a sample + if(d_trigger_off > .5) + d_trigger_off -= 1; + else + d_post_trigger_count--; + } + + // ---------------------------------------------------------------- + // returns true if trigger found + + bool + oscope_guts::found_trigger() + { + int mx = d_trigger_mode == TRIG_MODE_STRIPCHART ? OUTPUT_RECORD_SIZE*SCHART_MULT : + OUTPUT_RECORD_SIZE; + + float prev_sample = d_buffer[d_trigger_channel][decr_bi(d_obi, mx)]; + float new_sample = d_buffer[d_trigger_channel][d_obi]; + + switch(d_trigger_mode) { + + case TRIG_MODE_AUTO: //too many samples without a trigger + d_pre_trigger_count++; + if(d_pre_trigger_count > OUTPUT_RECORD_SIZE/2) + return true; + + case TRIG_MODE_NORM: //look for trigger + switch(d_trigger_slope) { + + case TRIG_SLOPE_POS: //trigger point in pos slope? + if(new_sample < d_trigger_level || prev_sample >= d_trigger_level) + return false; + break; + + case TRIG_SLOPE_NEG: //trigger point in neg slope? + if(new_sample > d_trigger_level || prev_sample <= d_trigger_level) + return false; + break; + } + + //calculate the trigger offset in % sample + d_trigger_off = (d_trigger_level - prev_sample)/(new_sample - prev_sample); + return true; + + case TRIG_MODE_FREE: //free run mode, always trigger + d_trigger_off = 0; + return true; + + default: + assert(0); + return false; + } + } + + // ---------------------------------------------------------------- + // write output records (duh!) + + void + oscope_guts::write_output_records() + { + int mx; + + mx = d_trigger_mode == TRIG_MODE_STRIPCHART ? + OUTPUT_RECORD_SIZE*SCHART_MULT : OUTPUT_RECORD_SIZE; + + // if the output queue if full, drop the data like its hot. + if(d_msgq->full_p()) + return; + // Build a message to hold the output records + gr_message_sptr msg = + gr_make_message(0, // msg type + d_nchannels, // arg1 for other side + mx, // arg2 for other side + ((d_nchannels * mx) + 1) * sizeof(float)); // sizeof payload + + float *out = (float *)msg->msg(); // get pointer to raw message buffer + + for(int ch = 0; ch < d_nchannels; ch++) { + // note that d_obi + 1 points at the oldest sample in the buffer + for(int i = 0; i < mx; i++) { + out[i] = d_buffer[ch][wrap_bi(d_obi + 1 + i, mx)]; + } + out += mx; + } + //Set the last sample as the trigger offset: + // The non gl scope sink will not look at this last sample. + // The gl scope sink will use this last sample as an offset. + out[0] = d_trigger_off; + d_msgq->handle(msg); // send the msg + } + + // ---------------------------------------------------------------- + + bool + oscope_guts::set_update_rate(double update_rate) + { + d_update_rate = std::min(std::max (1./10., update_rate), d_sample_rate); + update_rate_or_decimation_changed(); + return true; + } + + bool + oscope_guts::set_decimation_count(int decimator_count) + { + decimator_count = std::max(1, decimator_count); + d_decimator_count_init = decimator_count; + update_rate_or_decimation_changed(); + return true; + } + + bool + oscope_guts::set_sample_rate(double sample_rate) + { + d_sample_rate = sample_rate; + return set_update_rate(update_rate()); + } + + void + oscope_guts::update_rate_or_decimation_changed() + { + d_hold_off_count_init = + (int)rint(d_sample_rate / d_update_rate / d_decimator_count_init); + } + + bool + oscope_guts::set_trigger_channel(int channel) + { + if(channel >= 0 && channel < d_nchannels) { + d_trigger_channel = channel; + trigger_changed (); + return true; + } + + return false; + } + + bool + oscope_guts::set_trigger_mode(trigger_mode mode) + { + d_trigger_mode = mode; + trigger_changed(); + return true; + } + + bool + oscope_guts::set_trigger_slope(trigger_slope slope) + { + d_trigger_slope = slope; + trigger_changed(); + return true; + } + + bool + oscope_guts::set_trigger_level(double trigger_level) + { + d_trigger_level = trigger_level; + trigger_changed(); + return true; + } + + bool + oscope_guts::set_trigger_level_auto() + { + // find the level 1/2 way between the min and the max + + float min_v = d_buffer[d_trigger_channel][0]; + float max_v = d_buffer[d_trigger_channel][0]; + + for(int i = 1; i < OUTPUT_RECORD_SIZE; i++) { + min_v = std::min (min_v, d_buffer[d_trigger_channel][i]); + max_v = std::max (max_v, d_buffer[d_trigger_channel][i]); + } + return set_trigger_level((min_v + max_v) * 0.5); + } + + bool + oscope_guts::set_num_channels(int nchannels) + { + if(nchannels > 0 && nchannels <= MAX_CHANNELS) { + d_nchannels = nchannels; + return true; + } + return false; + } + + void + oscope_guts::trigger_changed() + { + enter_look_for_trigger(); + } + + // ACCESSORS + + int + oscope_guts::num_channels() const + { + return d_nchannels; + } + + double + oscope_guts::sample_rate() const + { + return d_sample_rate; + } + + double + oscope_guts::update_rate() const + { + return d_update_rate; + } + + int + oscope_guts::get_decimation_count() const + { + return d_decimator_count_init; + } + + int + oscope_guts::get_trigger_channel() const + { + return d_trigger_channel; + } + + trigger_mode + oscope_guts::get_trigger_mode() const + { + return d_trigger_mode; + } + + trigger_slope + oscope_guts::get_trigger_slope() const + { + return d_trigger_slope; + } + + double + oscope_guts::get_trigger_level() const + { + return d_trigger_level; + } + + int + oscope_guts::get_samples_per_output_record() const + { + int mx; + + mx = OUTPUT_RECORD_SIZE; + if(d_trigger_mode == TRIG_MODE_STRIPCHART) { + mx = OUTPUT_RECORD_SIZE*SCHART_MULT; + } + return mx; + } + + } /* namespace wxgui */ +} /* namespace gr */ diff --git a/gr-wxgui/lib/oscope_sink_f_impl.cc b/gr-wxgui/lib/oscope_sink_f_impl.cc new file mode 100644 index 0000000000..a95bf58827 --- /dev/null +++ b/gr-wxgui/lib/oscope_sink_f_impl.cc @@ -0,0 +1,84 @@ +/* -*- c++ -*- */ +/* + * Copyright 2003-2005,2010,2013 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 "oscope_sink_f_impl.h" +#include <wxgui/oscope_sink_x.h> +#include <wxgui/oscope_guts.h> +#include <gr_io_signature.h> + +namespace gr { + namespace wxgui { + + oscope_sink_f::sptr + oscope_sink_f::make(double sampling_rate, gr_msg_queue_sptr msgq) + { + return gnuradio::get_initial_sptr + (new oscope_sink_f_impl(sampling_rate, msgq)); + } + + oscope_sink_f_impl::oscope_sink_f_impl(double sampling_rate, gr_msg_queue_sptr msgq) + : oscope_sink_x("oscope_sink_f", + gr_make_io_signature(1, oscope_guts::MAX_CHANNELS, + sizeof(float)), + sampling_rate), + d_msgq(msgq) + { + d_guts = new oscope_guts(d_sampling_rate, d_msgq); + } + + oscope_sink_f_impl::~oscope_sink_f_impl() + { + } + + bool + oscope_sink_f_impl::check_topology(int ninputs, int noutputs) + { + GR_LOG_DEBUG(d_logger, "oscopy_sink_f check_topology"); + return d_guts->set_num_channels(ninputs); + } + + int + oscope_sink_f_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + int ni = input_items.size(); + float tmp[oscope_guts::MAX_CHANNELS]; + + for(int i = 0; i < noutput_items; i++) { + + // FIXME for now, copy the data. Fix later if reqd + for(int ch = 0; ch < ni; ch++) + tmp[ch] = ((const float*)input_items[ch])[i]; + + d_guts->process_sample(tmp); + } + + return noutput_items; + } + + } /* namespace wxgui */ +} /* namespace gr */ diff --git a/gnuradio-core/src/lib/io/sdr_1000.h b/gr-wxgui/lib/oscope_sink_f_impl.h index c00608a3a9..6ad28a885f 100644 --- a/gnuradio-core/src/lib/io/sdr_1000.h +++ b/gr-wxgui/lib/oscope_sink_f_impl.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2003,2004 Free Software Foundation, Inc. + * Copyright 2003-2005,2013 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,34 +20,32 @@ * Boston, MA 02110-1301, USA. */ -#ifndef INCLUDED_SDR_1000_H -#define INCLUDED_SDR_1000_H +#ifndef INCLUDED_GR_OSCOPE_SINK_F_IMPL_H +#define INCLUDED_GR_OSCOPE_SINK_F_IMPL_H -#include <gr_core_api.h> -#include <boost/shared_ptr.hpp> +#include <wxgui/oscope_sink_f.h> -class ppio; -typedef boost::shared_ptr<ppio> ppio_sptr; +namespace gr { + namespace wxgui { + class oscope_sink_f_impl : public oscope_sink_f + { + private: + gr_msg_queue_sptr d_msgq; -enum { L_EXT = 0, L_BAND = 1, L_DDS0 = 2, L_DDS1 = 3 }; + public: + oscope_sink_f_impl(double sampling_rate, gr_msg_queue_sptr msgq); + ~oscope_sink_f_impl(); -/*! - * \brief Very low level interface to SDR 1000 xcvr hardware - * \sa sdr_1000.py for a higher level interface. - * \ingroup hardware - */ -class GR_CORE_API sdr_1000_base { - ppio_sptr d_ppio; - int d_shadow[4]; // shadow latches + bool check_topology(int ninputs, int noutputs); -public: + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; - sdr_1000_base (int which_pp); - ~sdr_1000_base (); + } /* namespace wxgui */ +} /* namespace gr */ - void reset (); - void write_latch (int which, int value, int mask); -}; +#endif /* INCLUDED_GR_OSCOPE_SINK_F_IMPL_H */ -#endif /* INCLUDED_SDR_1000_H */ diff --git a/gr-wxgui/lib/oscope_sink_x.cc b/gr-wxgui/lib/oscope_sink_x.cc new file mode 100644 index 0000000000..417442979c --- /dev/null +++ b/gr-wxgui/lib/oscope_sink_x.cc @@ -0,0 +1,161 @@ +/* -*- c++ -*- */ +/* + * Copyright 2003,2004,2013 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 <wxgui/oscope_sink_x.h> +#include <wxgui/oscope_guts.h> +#include <gr_io_signature.h> + +namespace gr { + namespace wxgui { + + oscope_sink_x::oscope_sink_x(const std::string name, + gr_io_signature_sptr input_sig, + double sampling_rate) + : gr_sync_block(name, input_sig, + gr_make_io_signature(0, 0, 0)), + d_sampling_rate(sampling_rate), d_guts(0) + { + } + + oscope_sink_x::~oscope_sink_x() + { + delete d_guts; + } + + // ---------------------------------------------------------------- + + bool + oscope_sink_x::set_update_rate(double update_rate) + { + return d_guts->set_update_rate(update_rate); + } + + bool + oscope_sink_x::set_decimation_count(int decimation_count) + { + return d_guts->set_decimation_count(decimation_count); + } + + bool + oscope_sink_x::set_trigger_channel(int channel) + { + return d_guts->set_trigger_channel(channel); + } + + bool + oscope_sink_x::set_trigger_mode(trigger_mode mode) + { + return d_guts->set_trigger_mode(mode); + } + + bool + oscope_sink_x::set_trigger_slope(trigger_slope slope) + { + return d_guts->set_trigger_slope(slope); + } + + bool + oscope_sink_x::set_trigger_level(double trigger_level) + { + return d_guts->set_trigger_level(trigger_level); + } + + bool + oscope_sink_x::set_trigger_level_auto() + { + return d_guts->set_trigger_level_auto(); + } + + bool + oscope_sink_x::set_sample_rate(double sample_rate) + { + return d_guts->set_sample_rate(sample_rate); + } + + bool + oscope_sink_x::set_num_channels(int nchannels) + { + return d_guts->set_num_channels(nchannels); + } + + // ACCESSORS + + int + oscope_sink_x::num_channels() const + { + return d_guts->num_channels(); + } + + double + oscope_sink_x::sample_rate() const + { + return d_guts->sample_rate(); + } + + double + oscope_sink_x::update_rate() const + { + return d_guts->update_rate(); + } + + int + oscope_sink_x::get_decimation_count() const + { + return d_guts->get_decimation_count(); + } + + int + oscope_sink_x::get_trigger_channel() const + { + return d_guts->get_trigger_channel(); + } + + trigger_mode + oscope_sink_x::get_trigger_mode() const + { + return d_guts->get_trigger_mode(); + } + + trigger_slope + oscope_sink_x::get_trigger_slope() const + { + return d_guts->get_trigger_slope(); + } + + double + oscope_sink_x::get_trigger_level() const + { + return d_guts->get_trigger_level(); + } + + int + oscope_sink_x::get_samples_per_output_record() const + { + return d_guts->get_samples_per_output_record(); + } + + } /* namespace wxgui */ +} /* namespace gr */ diff --git a/gr-wxgui/python/__init__.py b/gr-wxgui/python/__init__.py index 07dbaf1620..dd81647fe9 100644 --- a/gr-wxgui/python/__init__.py +++ b/gr-wxgui/python/__init__.py @@ -22,3 +22,5 @@ ''' Provides a GUI interface using the Wx backend. ''' + +from wxgui_swig import * diff --git a/gr-wxgui/python/common.py b/gr-wxgui/python/common.py index 57fc530f88..48a62a28ab 100644 --- a/gr-wxgui/python/common.py +++ b/gr-wxgui/python/common.py @@ -24,6 +24,7 @@ ################################################## import wx from gnuradio import gr +from gnuradio import blocks RUN_ALWAYS = gr.prefs().get_bool ('wxgui', 'run_always', False) @@ -47,7 +48,7 @@ class wxgui_hb(object): """ try: assert points[0] == self or points[0][0] == self - copy = gr.copy(self._hb.input_signature().sizeof_stream_item(0)) + copy = blocks.copy(self._hb.input_signature().sizeof_stream_item(0)) handler = self._handler_factory(copy.set_enabled) if RUN_ALWAYS == False: handler(False) #initially disable the copy block diff --git a/gr-wxgui/python/constsink_gl.py b/gr-wxgui/python/constsink_gl.py index 0313e7fea0..dea76ea753 100644 --- a/gr-wxgui/python/constsink_gl.py +++ b/gr-wxgui/python/constsink_gl.py @@ -26,6 +26,7 @@ import const_window import common from gnuradio import gr from gnuradio import blocks +from gnuradio import analog from pubsub import pubsub from constants import * import sys @@ -100,7 +101,7 @@ class const_sink_c(gr.hier_block2, common.wxgui_hb): # gain_omega, # omega_limit, #) - agc = gr.feedforward_agc_cc(16, 1) + agc = analog.feedforward_agc_cc(16, 1) msgq = gr.msg_queue(2) sink = blocks.message_sink(gr.sizeof_gr_complex*const_size, msgq, True) #controller diff --git a/gr-wxgui/python/histosink_gl.py b/gr-wxgui/python/histosink_gl.py index 6fa7539aa7..2126d63191 100644 --- a/gr-wxgui/python/histosink_gl.py +++ b/gr-wxgui/python/histosink_gl.py @@ -27,6 +27,7 @@ import common from gnuradio import gr from gnuradio import analog from gnuradio import blocks +from gnuradio import wxgui from pubsub import pubsub from constants import * @@ -55,7 +56,7 @@ class histo_sink_f(gr.hier_block2, common.wxgui_hb): ) #blocks msgq = gr.msg_queue(2) - histo = gr.histo_sink_f(msgq) + histo = wxgui.histo_sink_f(msgq) histo.set_num_bins(num_bins) histo.set_frame_size(frame_size) #controller diff --git a/gr-wxgui/python/scope_window.py b/gr-wxgui/python/scope_window.py index 306e1757f1..357998bf95 100644 --- a/gr-wxgui/python/scope_window.py +++ b/gr-wxgui/python/scope_window.py @@ -30,6 +30,7 @@ import time import pubsub from constants import * from gnuradio import gr #for gr.prefs, trigger modes +from gnuradio import wxgui import forms ################################################## @@ -38,21 +39,21 @@ import forms DEFAULT_FRAME_RATE = gr.prefs().get_long('wxgui', 'scope_rate', 30) PERSIST_ALPHA_MIN_EXP, PERSIST_ALPHA_MAX_EXP = -2, 0 SLIDER_STEPS = 100 -DEFAULT_TRIG_MODE = gr.prefs().get_long('wxgui', 'trig_mode', gr.gr_TRIG_MODE_AUTO) +DEFAULT_TRIG_MODE = gr.prefs().get_long('wxgui', 'trig_mode', wxgui.TRIG_MODE_AUTO) DEFAULT_WIN_SIZE = (600, 300) COUPLING_MODES = ( ('DC', False), ('AC', True), ) TRIGGER_MODES = ( - ('Freerun', gr.gr_TRIG_MODE_FREE), - ('Auto', gr.gr_TRIG_MODE_AUTO), - ('Normal', gr.gr_TRIG_MODE_NORM), - ('Stripchart', gr.gr_TRIG_MODE_STRIPCHART), + ('Freerun', wxgui.TRIG_MODE_FREE), + ('Auto', wxgui.TRIG_MODE_AUTO), + ('Normal', wxgui.TRIG_MODE_NORM), + ('Stripchart', wxgui.TRIG_MODE_STRIPCHART), ) TRIGGER_SLOPES = ( - ('Pos +', gr.gr_TRIG_SLOPE_POS), - ('Neg -', gr.gr_TRIG_SLOPE_NEG), + ('Pos +', wxgui.TRIG_SLOPE_POS), + ('Neg -', wxgui.TRIG_SLOPE_NEG), ) CHANNEL_COLOR_SPECS = ( (0.3, 0.3, 1.0), @@ -281,7 +282,7 @@ class control_panel(wx.Panel): ) def disable_all(trigger_mode): for widget in (trigger_slope_chooser, trigger_channel_chooser, trigger_level_buttons, trigger_level_button): - widget.Disable(trigger_mode == gr.gr_TRIG_MODE_FREE) + widget.Disable(trigger_mode == wxgui.TRIG_MODE_FREE) parent.subscribe(TRIGGER_MODE_KEY, disable_all) disable_all(parent[TRIGGER_MODE_KEY]) ################################################## @@ -480,12 +481,12 @@ class scope_window(wx.Panel, pubsub.pubsub): self[TRIGGER_CHANNEL_KEY] = 0 self[TRIGGER_MODE_KEY] = trig_mode - self[TRIGGER_SLOPE_KEY] = gr.gr_TRIG_SLOPE_POS + self[TRIGGER_SLOPE_KEY] = wxgui.TRIG_SLOPE_POS self[T_FRAC_OFF_KEY] = 0.5 self[USE_PERSISTENCE_KEY] = use_persistence self[PERSIST_ALPHA_KEY] = persist_alpha - if self[TRIGGER_MODE_KEY] == gr.gr_TRIG_MODE_STRIPCHART: + if self[TRIGGER_MODE_KEY] == wxgui.TRIG_MODE_STRIPCHART: self[T_FRAC_OFF_KEY] = 0.0 for i in range(num_inputs): @@ -639,7 +640,7 @@ class scope_window(wx.Panel, pubsub.pubsub): if self[TRIGGER_LEVEL_KEY] < self.get_y_min(): self[TRIGGER_LEVEL_KEY] = self.get_y_min(); return #disable the trigger channel - if not self[TRIGGER_SHOW_KEY] or self[XY_MODE_KEY] or self[TRIGGER_MODE_KEY] == gr.gr_TRIG_MODE_FREE: + if not self[TRIGGER_SHOW_KEY] or self[XY_MODE_KEY] or self[TRIGGER_MODE_KEY] == wxgui.TRIG_MODE_FREE: self.plotter.clear_waveform(channel='Trig') else: #show trigger channel trigger_level = self[TRIGGER_LEVEL_KEY] diff --git a/gr-wxgui/python/scopesink_gl.py b/gr-wxgui/python/scopesink_gl.py index 21d7169026..b2d5670c77 100644 --- a/gr-wxgui/python/scopesink_gl.py +++ b/gr-wxgui/python/scopesink_gl.py @@ -26,6 +26,8 @@ import scope_window import common from gnuradio import gr, filter from gnuradio import blocks +from gnuradio import analog +from gnuradio import wxgui from pubsub import pubsub from constants import * import math @@ -101,7 +103,7 @@ class _scope_sink_base(gr.hier_block2, common.wxgui_hb): ) #scope msgq = gr.msg_queue(2) - scope = gr.oscope_sink_f(sample_rate, msgq) + scope = wxgui.oscope_sink_f(sample_rate, msgq) #controller self.controller = pubsub() self.controller.subscribe(SAMPLE_RATE_KEY, scope.set_sample_rate) @@ -207,12 +209,13 @@ class test_top_block (stdgui2.std_top_block): # Generate a complex sinusoid ampl=1.0e3 - self.src0 = analog.sig_source_c(input_rate, gr.GR_SIN_WAVE, + self.src0 = analog.sig_source_c(input_rate, analog.GR_SIN_WAVE, 25.1e3*input_rate/default_input_rate, ampl) - self.noise = analog.sig_source_c (input_rate, analog.GR_SIN_WAVE, - 11.1*25.1e3*input_rate/default_input_rate, ampl/10) + self.noise = analog.sig_source_c(input_rate, analog.GR_SIN_WAVE, + 11.1*25.1e3*input_rate/default_input_rate, + ampl/10) #self.noise = analog.noise_source_c(analog.GR_GAUSSIAN, ampl/10) - self.combine = analog.add_cc() + self.combine = blocks.add_cc() # We add this throttle block so that this demo doesn't suck down # all the CPU available. You normally wouldn't use it... diff --git a/gr-wxgui/python/scopesink_nongl.py b/gr-wxgui/python/scopesink_nongl.py index 2c5ff9278a..28a473860f 100644 --- a/gr-wxgui/python/scopesink_nongl.py +++ b/gr-wxgui/python/scopesink_nongl.py @@ -23,6 +23,7 @@ from gnuradio import gr, gru, eng_notation from gnuradio import analog from gnuradio import blocks +from gnuradio import wxgui from gnuradio.wxgui import stdgui2 import wx import gnuradio.wxgui.plot as plot @@ -43,7 +44,7 @@ class scope_sink_f(gr.hier_block2): gr.io_signature(0,0,0)) msgq = gr.msg_queue(2) # message queue that holds at most 2 messages - self.guts = gr.oscope_sink_f(sample_rate, msgq) + self.guts = wxgui.oscope_sink_f(sample_rate, msgq) for i in range(num_inputs): self.connect((self, i), (self.guts, i)) @@ -64,7 +65,7 @@ class scope_sink_c(gr.hier_block2): gr.io_signature(0,0,0)) msgq = gr.msg_queue(2) # message queue that holds at most 2 messages - self.guts = gr.oscope_sink_f(sample_rate, msgq) + self.guts = wxgui.oscope_sink_f(sample_rate, msgq) for i in range(num_inputs): c2f = blocks.complex_to_float() self.connect((self, i), c2f) @@ -425,11 +426,11 @@ class scope_window(wx.Panel): sink = self.info.scopesink s = evt.GetString() if s == 'Norm': - sink.set_trigger_mode(gr.gr_TRIG_MODE_NORM) + sink.set_trigger_mode(wxgui.TRIG_MODE_NORM) elif s == 'Auto': - sink.set_trigger_mode(gr.gr_TRIG_MODE_AUTO) + sink.set_trigger_mode(wxgui.TRIG_MODE_AUTO) elif s == 'Free': - sink.set_trigger_mode(gr.gr_TRIG_MODE_FREE) + sink.set_trigger_mode(wxgui.TRIG_MODE_FREE) else: assert 0, "Bad trig_mode_choice string" diff --git a/gr-wxgui/python/waterfallsink_nongl.py b/gr-wxgui/python/waterfallsink_nongl.py index 37b8281927..bd93a84ab7 100644 --- a/gr-wxgui/python/waterfallsink_nongl.py +++ b/gr-wxgui/python/waterfallsink_nongl.py @@ -89,7 +89,7 @@ class waterfall_sink_f(gr.hier_block2, waterfall_sink_base): fft_rate=fft_rate, average=average, avg_alpha=avg_alpha, title=title) - self.s2p = gr.serial_to_parallel(gr.sizeof_float, self.fft_size) + self.s2p = blocks.stream_to_vector(gr.sizeof_float, self.fft_size) self.one_in_n = blocks.keep_one_in_n(gr.sizeof_float * self.fft_size, max(1, int(self.sample_rate/self.fft_size/self.fft_rate))) @@ -120,7 +120,7 @@ class waterfall_sink_c(gr.hier_block2, waterfall_sink_base): fft_rate=fft_rate, average=average, avg_alpha=avg_alpha, title=title) - self.s2p = gr.serial_to_parallel(gr.sizeof_gr_complex, self.fft_size) + self.s2p = blocks.stream_to_vector(gr.sizeof_gr_complex, self.fft_size) self.one_in_n = blocks.keep_one_in_n(gr.sizeof_gr_complex * self.fft_size, max(1, int(self.sample_rate/self.fft_size/self.fft_rate))) diff --git a/gr-wxgui/swig/CMakeLists.txt b/gr-wxgui/swig/CMakeLists.txt new file mode 100644 index 0000000000..16e7d65050 --- /dev/null +++ b/gr-wxgui/swig/CMakeLists.txt @@ -0,0 +1,57 @@ +# Copyright 2013 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. + +######################################################################## +# Setup swig generation +######################################################################## +include(GrPython) +include(GrSwig) + +set(GR_SWIG_INCLUDE_DIRS + ${CMAKE_CURRENT_BINARY_DIR}/../include + ${GR_WXGUI_INCLUDE_DIRS} + ${GNURADIO_CORE_SWIG_INCLUDE_DIRS} + ${GRUEL_INCLUDE_DIRS} + ${Boost_INCLUDE_DIRS} +) + +if(ENABLE_GR_CTRLPORT) + SET(GR_SWIG_FLAGS "-DGR_CTRLPORT") +endif(ENABLE_GR_CTRLPORT) + +set(GR_SWIG_DOC_FILE ${CMAKE_CURRENT_BINARY_DIR}/wxgui_swig_doc.i) +set(GR_SWIG_DOC_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../lib) +set(GR_SWIG_TARGET_DEPS wxgui_generated_includes) +set(GR_SWIG_LIBRARIES gnuradio-wxgui) + +GR_SWIG_MAKE(wxgui_swig wxgui_swig.i) + +GR_SWIG_INSTALL( + TARGETS wxgui_swig + DESTINATION ${GR_PYTHON_DIR}/gnuradio/wxgui + COMPONENT "wxgui_python" +) + +install( + FILES + wxgui_swig.i + ${CMAKE_CURRENT_BINARY_DIR}/wxgui_swig_doc.i + DESTINATION ${GR_INCLUDE_DIR}/gnuradio/swig + COMPONENT "wxgui_swig" +) diff --git a/gnuradio-core/src/lib/gengen/gengen.i b/gr-wxgui/swig/wxgui_swig.i index 7d8c27fe68..1151b17ee5 100644 --- a/gnuradio-core/src/lib/gengen/gengen.i +++ b/gr-wxgui/swig/wxgui_swig.i @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2009 Free Software Foundation, Inc. + * Copyright 2013 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,10 +20,24 @@ * Boston, MA 02110-1301, USA. */ +#define WXGUI_API + +%include "gnuradio.i" + +//load generated python docstrings +%include "wxgui_swig_doc.i" + +%include "wxgui/trigger_mode.h" + %{ -#include "gr_endianness.h" +#include "wxgui/oscope_sink_x.h" +#include "wxgui/histo_sink_f.h" +#include "wxgui/oscope_sink_f.h" %} -%include "gr_endianness.i" +%include "wxgui/oscope_sink_x.h" +%include "wxgui/histo_sink_f.h" +%include "wxgui/oscope_sink_f.h" -%include "gengen_generated.i" +GR_SWIG_BLOCK_MAGIC2(wxgui, histo_sink_f); +GR_SWIG_BLOCK_MAGIC2(wxgui, oscope_sink_f); diff --git a/grc/blocks/CMakeLists.txt b/grc/blocks/CMakeLists.txt index 879c69a8ec..98b6512a09 100644 --- a/grc/blocks/CMakeLists.txt +++ b/grc/blocks/CMakeLists.txt @@ -20,13 +20,4 @@ ######################################################################## file(GLOB xml_files "*.xml") -# Force out the controlport GRC blocks if we've disabled it. -if(NOT ENABLE_GR_CTRLPORT) - list(REMOVE_ITEM xml_files - ${CMAKE_CURRENT_SOURCE_DIR}/gr_ctrlport_viewer.xml - ${CMAKE_CURRENT_SOURCE_DIR}/gr_ctrlport_probe_c.xml - ${CMAKE_CURRENT_SOURCE_DIR}/gr_ctrlport_probe2_c.xml - ) -endif(NOT ENABLE_GR_CTRLPORT) - install(FILES ${xml_files} DESTINATION ${GRC_BLOCKS_DIR} COMPONENT "grc") diff --git a/grc/blocks/block_tree.xml b/grc/blocks/block_tree.xml index e9da1ec880..9614c6ae02 100644 --- a/grc/blocks/block_tree.xml +++ b/grc/blocks/block_tree.xml @@ -8,31 +8,19 @@ <name></name> <!-- Blank for Root Name --> <cat> <name>Sources</name> - <block>gr_vector_source_x</block> <block>random_source_x</block> - <block>gr_null_source</block> <block>blks2_tcp_source</block> <block>pad_source</block> <block>virtual_source</block> </cat> <cat> <name>Sinks</name> - <block>gr_vector_sink_x</block> - <block>gr_null_sink</block> <block>blks2_tcp_sink</block> <block>pad_sink</block> <block>virtual_sink</block> </cat> <cat> - <name>Operators</name> - <block>gr_vector_insert_x</block> - <block>gr_endian_swap</block> - </cat> - <cat> <name>Synchronizers</name> - - <block>gr_mpsk_sync_cc</block> - <block>blks2_packet_decoder</block> <block>blks2_packet_encoder</block> </cat> @@ -58,13 +46,6 @@ <block>blks2_valve</block> <block>blks2_error_rate</block> - <block>gr_head</block> - <block>gr_skiphead</block> - - <block>gr_kludge_copy</block> - <block>gr_copy</block> - <block>gr_nop</block> - <block>xmlrpc_server</block> <block>xmlrpc_client</block> </cat> diff --git a/grc/blocks/gr_feedforward_agc_cc.xml b/grc/blocks/gr_feedforward_agc_cc.xml deleted file mode 100644 index 24e80953f4..0000000000 --- a/grc/blocks/gr_feedforward_agc_cc.xml +++ /dev/null @@ -1,32 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Feed Forward AGC -################################################### - --> -<block> - <name>Feed Forward AGC</name> - <key>gr_feedforward_agc_cc</key> - <import>from gnuradio import gr</import> - <make>gr.feedforward_agc_cc($num_samples, $reference)</make> - <param> - <name>Num Samples</name> - <key>num_samples</key> - <value>1024</value> - <type>int</type> - </param> - <param> - <name>Reference</name> - <key>reference</key> - <value>1.0</value> - <type>real</type> - </param> - <sink> - <name>in</name> - <type>complex</type> - </sink> - <source> - <name>out</name> - <type>complex</type> - </source> -</block> diff --git a/grc/blocks/gr_kludge_copy.xml b/grc/blocks/gr_kludge_copy.xml deleted file mode 100644 index 8058b082db..0000000000 --- a/grc/blocks/gr_kludge_copy.xml +++ /dev/null @@ -1,68 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Kludge Copy -################################################### - --> -<block> - <name>Kludge Copy</name> - <key>gr_kludge_copy</key> - <import>from gnuradio import gr</import> - <make>gr.kludge_copy($type.size*$vlen)</make> - <param> - <name>Type</name> - <key>type</key> - <type>enum</type> - <option> - <name>Complex</name> - <key>complex</key> - <opt>size:gr.sizeof_gr_complex</opt> - </option> - <option> - <name>Float</name> - <key>float</key> - <opt>size:gr.sizeof_float</opt> - </option> - <option> - <name>Int</name> - <key>int</key> - <opt>size:gr.sizeof_int</opt> - </option> - <option> - <name>Short</name> - <key>short</key> - <opt>size:gr.sizeof_short</opt> - </option> - <option> - <name>Byte</name> - <key>byte</key> - <opt>size:gr.sizeof_char</opt> - </option> - </param> - <param> - <name>Num Ports</name> - <key>num_ports</key> - <value>1</value> - <type>int</type> - </param> - <param> - <name>Vec Length</name> - <key>vlen</key> - <value>1</value> - <type>int</type> - </param> - <check>$num_ports > 0</check> - <check>$vlen > 0</check> - <sink> - <name>in</name> - <type>$type</type> - <vlen>$vlen</vlen> - <nports>$num_ports</nports> - </sink> - <source> - <name>out</name> - <type>$type</type> - <vlen>$vlen</vlen> - <nports>$num_ports</nports> - </source> -</block> diff --git a/grc/blocks/gr_mpsk_sync_cc.xml b/grc/blocks/gr_mpsk_sync_cc.xml deleted file mode 100644 index fd08f8340b..0000000000 --- a/grc/blocks/gr_mpsk_sync_cc.xml +++ /dev/null @@ -1,69 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##MPSK Sync -################################################### - --> -<block> - <name>MPSK Sync</name> - <key>gr_mpsk_sync_cc</key> - <import>from gnuradio import gr</import> - <make>gr.mpsk_sync_cc($alpha, $beta, $max_freq, $min_freq, $ref_phase, $omega, $gain_omega, $mu, $gain_mu)</make> - <callback>set_mu($mu)</callback> - <callback>set_gain_mu($gain_mu)</callback> - <callback>set_omega($omega)</callback> - <callback>set_gain_omega($gain_omega)</callback> - <param> - <name>Alpha</name> - <key>alpha</key> - <type>real</type> - </param> - <param> - <name>Beta</name> - <key>beta</key> - <type>real</type> - </param> - <param> - <name>Max Freq</name> - <key>max_freq</key> - <type>real</type> - </param> - <param> - <name>Min Freq</name> - <key>min_freq</key> - <type>real</type> - </param> - <param> - <name>Reference Phase</name> - <key>ref_phase</key> - <type>real</type> - </param> - <param> - <name>Omega</name> - <key>omega</key> - <type>real</type> - </param> - <param> - <name>Gain Omega</name> - <key>gain_omega</key> - <type>real</type> - </param> - <param> - <name>Mu</name> - <key>mu</key> - <type>real</type> - </param> - <param> - <name>Gain Mu</name> - <key>gain_mu</key> - <type>real</type> - </param> - <sink> - <name>in</name> - <type>complex</type> - </sink> - <source> - <name>out</name> - <type>complex</type> - </source> -</block> diff --git a/grc/blocks/random_source_x.xml b/grc/blocks/random_source_x.xml index 800bae7167..f826c77d16 100644 --- a/grc/blocks/random_source_x.xml +++ b/grc/blocks/random_source_x.xml @@ -10,7 +10,7 @@ <key>random_source_x</key> <import>from gnuradio import gr</import> <import>import numpy</import> - <make>gr.vector_source_$(type.fcn)(map(int, numpy.random.randint($min, $max, $num_samps)), $repeat)</make> + <make>blocks.vector_source_$(type.fcn)(map(int, numpy.random.randint($min, $max, $num_samps)), $repeat)</make> <param> <name>Output Type</name> <key>type</key> diff --git a/grc/examples/xmlrpc/xmlrpc_server.grc b/grc/examples/xmlrpc/xmlrpc_server.grc index 7497117f28..3a133fd7c4 100644 --- a/grc/examples/xmlrpc/xmlrpc_server.grc +++ b/grc/examples/xmlrpc/xmlrpc_server.grc @@ -170,7 +170,7 @@ </param> <param> <key>trig_mode</key> - <value>gr.gr_TRIG_MODE_AUTO</value> + <value>wxgui.TRIG_MODE_AUTO</value> </param> <param> <key>y_axis_label</key> diff --git a/grc/grc_gnuradio/blks2/packet.py b/grc/grc_gnuradio/blks2/packet.py index eeadfb4a60..4c7bd235dd 100644 --- a/grc/grc_gnuradio/blks2/packet.py +++ b/grc/grc_gnuradio/blks2/packet.py @@ -1,4 +1,4 @@ -# Copyright 2008, 2009, 2012 Free Software Foundation, Inc. +# Copyright 2008,2009,2012-2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -236,10 +236,12 @@ class packet_demod_base(gr.hier_block2): self.connect(self, packet_sink) self.connect(msg_source, self) if packet_sink._hb.output_signature().sizeof_stream_item(0): - self.connect(packet_sink, gr.null_sink(packet_sink._hb.output_signature().sizeof_stream_item(0))) + self.connect(packet_sink, + blocks.null_sink(packet_sink._hb.output_signature().sizeof_stream_item(0))) def recv_pkt(self, ok, payload): - msg = blocks.message_from_string(payload, 0, self._item_size_out, len(payload)/self._item_size_out) + msg = blocks.message_from_string(payload, 0, self._item_size_out, + len(payload)/self._item_size_out) if ok: self._msgq_out.insert_tail(msg) class packet_demod_b(packet_demod_base): _item_size_out = gr.sizeof_char diff --git a/grc/grc_gnuradio/blks2/selector.py b/grc/grc_gnuradio/blks2/selector.py index f6a8aa79b1..bc393f84b6 100644 --- a/grc/grc_gnuradio/blks2/selector.py +++ b/grc/grc_gnuradio/blks2/selector.py @@ -1,5 +1,5 @@ # -# Copyright 2008 Free Software Foundation, Inc. +# Copyright 2008,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -20,6 +20,7 @@ # from gnuradio import gr +from gnuradio import blocks class selector(gr.hier_block2): """A hier2 block with N inputs and M outputs, where data is only forwarded through input n to output m.""" @@ -40,12 +41,13 @@ class selector(gr.hier_block2): gr.io_signature(num_outputs, num_outputs, item_size), ) #terminator blocks for unused inputs and outputs - self.input_terminators = [gr.null_sink(item_size) for i in range(num_inputs)] - self.output_terminators = [gr.head(item_size, 0) for i in range(num_outputs)] - self.copy = gr.kludge_copy(item_size) + self.input_terminators = [blocks.null_sink(item_size) for i in range(num_inputs)] + self.output_terminators = [blocks.head(item_size, 0) for i in range(num_outputs)] + self.copy = blocks.copy(item_size) #connections for i in range(num_inputs): self.connect((self, i), self.input_terminators[i]) - for i in range(num_outputs): self.connect(gr.null_source(item_size), self.output_terminators[i], (self, i)) + for i in range(num_outputs): self.connect(blocks.null_source(item_size), + self.output_terminators[i], (self, i)) self.item_size = item_size self.input_index = input_index self.output_index = output_index diff --git a/grc/todo.txt b/grc/todo.txt index 1205b3ff6d..cedea72aa3 100644 --- a/grc/todo.txt +++ b/grc/todo.txt @@ -12,11 +12,6 @@ * packet mod: whitening offset * wx min window size in options block * gr_adaptive_fir_ccf -* ofdm - * gr_ofdm_bpsk_demapper - * gr_ofdm_demapper_vcb - * gr_ofdm_frame_sink - * gr_ofdm_mapper_bcv * size params for the graphical sinks * callbacks for set average on fft, waterfall, number sinks * add units to params: Sps, Hz, dB... |