diff options
author | Josh Blum | 2011-10-17 23:40:51 -0700 |
---|---|---|
committer | Josh Blum | 2011-10-17 23:40:51 -0700 |
commit | 161910c66e88c081d267f4b2b699f7431f287279 (patch) | |
tree | 86500bb995f5afeece82042eb29eeb3716151d1d | |
parent | 41ce01bd6f602009b83422550b0b91bddd830c84 (diff) | |
parent | f664585ddddeb040d1cd285d0b9dfb41c4979b91 (diff) | |
download | gnuradio-161910c66e88c081d267f4b2b699f7431f287279.tar.gz gnuradio-161910c66e88c081d267f4b2b699f7431f287279.tar.bz2 gnuradio-161910c66e88c081d267f4b2b699f7431f287279.zip |
Merge branch 'next' of http://gnuradio.org/git/gnuradio into next
Conflicts:
gnuradio-core/src/lib/filter/gr_dc_blocker_cc.h
gnuradio-core/src/lib/filter/gr_dc_blocker_ff.h
gnuradio-core/src/lib/general/gr_ofdm_demapper_vcb.h
gr-digital/include/digital_ofdm_cyclic_prefixer.h
gr-digital/include/digital_ofdm_frame_acquisition.h
gr-digital/include/digital_ofdm_frame_sink.h
gr-digital/include/digital_ofdm_insert_preamble.h
gr-digital/include/digital_ofdm_mapper_bcv.h
gr-digital/include/digital_ofdm_sampler.h
124 files changed, 2004 insertions, 2879 deletions
diff --git a/config/ax_boost_base.m4 b/config/ax_boost_base.m4 index e9d42ee9a..f2a7f6e83 100644 --- a/config/ax_boost_base.m4 +++ b/config/ax_boost_base.m4 @@ -305,7 +305,7 @@ dnl $2 is AC_LANG_PROGRAM argument 1 dnl $3 is AC_LANG_PROGRAM argument 2 dnl $4 is cv variable name. E.g., ax_cv_boost_thread AC_DEFUN([_AX_BOOST_CHECK_],[ - _AX_BOOST_WITH($1) + _AX_BOOST_WITH([$1]) if test "$want_boost" = "yes"; then AC_REQUIRE([AC_PROG_CC]) AC_REQUIRE([AC_PROG_CXX]) diff --git a/config/grc_gnuradio_examples.m4 b/config/grc_gnuradio_examples.m4 index 9a32e5ab9..f6e964765 100644 --- a/config/grc_gnuradio_examples.m4 +++ b/config/grc_gnuradio_examples.m4 @@ -31,7 +31,6 @@ AC_DEFUN([GRC_GNURADIO_EXAMPLES],[ gnuradio-examples/python/mp-sched/Makefile \ gnuradio-examples/python/multi_usrp/Makefile \ gnuradio-examples/python/network/Makefile \ - gnuradio-examples/python/ofdm/Makefile \ gnuradio-examples/python/pfb/Makefile \ gnuradio-examples/python/tags/Makefile \ gnuradio-examples/waveforms/Makefile \ diff --git a/gnuradio-core/src/guile/tests/general_ctors.test b/gnuradio-core/src/guile/tests/general_ctors.test index a0e39855c..ca4d60460 100644 --- a/gnuradio-core/src/guile/tests/general_ctors.test +++ b/gnuradio-core/src/guile/tests/general_ctors.test @@ -209,28 +209,6 @@ ;;; ./general/gr_null_source.h (pass-if (true? (gr:null-source 1))) -;;; ./general/gr_ofdm_cyclic_prefixer.h -(pass-if (true? (gr:ofdm-cyclic-prefixer 1 1))) - -;;; ./general/gr_ofdm_frame_acquisition.h -(pass-if (true? (gr:ofdm-frame-acquisition 1 1 1 #(1+3i 23+5i) 1))) - -;;; ./general/gr_ofdm_frame_sink.h -(pass-if (true? (gr:ofdm-frame-sink #(1+3i 23+5i) #(0 1) (gr:msg-queue) 128 0.25 0))) - -;;; ./general/gr_ofdm_insert_preamble.h FIXME: "Wrong type argument in position ~A: ~S" -;;; WONTFIX: Need vector<vector<complex<float>>> -;;(pass-if (true? (gr:ofdm-insert-preamble 2 #(#(1+3i 23+5i) #(1+3i 23+5i))))) - -;;; ./general/gr_ofdm_mapper_bcv.h -(pass-if (true? (gr:ofdm-mapper-bcv #(0+1i 0-1i) 1 100 128))) -(pass-if-throw "confirm throw gr:ofdm-mapper-bcv" #t - (true? (gr:ofdm-mapper-bcv #(0+1i 0-1i) 1 10 128))) - - -;;; ./general/gr_ofdm_sampler.h -(pass-if (true? (gr:ofdm-sampler 1 1 1))) - ;;; ./general/gr_pa_2x2_phase_combiner.h (pass-if (true? (gr:pa-2x2-phase-combiner))) diff --git a/gnuradio-core/src/lib/filter/gr_dc_blocker_cc.h b/gnuradio-core/src/lib/filter/gr_dc_blocker_cc.h index 3a9d364d4..cb449f3ec 100644 --- a/gnuradio-core/src/lib/filter/gr_dc_blocker_cc.h +++ b/gnuradio-core/src/lib/filter/gr_dc_blocker_cc.h @@ -28,18 +28,33 @@ #include <gr_sync_block.h> #include <deque> +class GR_CORE_API moving_averager_c +{ +public: + moving_averager_c(int D); + ~moving_averager_c(); + + gr_complex filter(gr_complex x); + gr_complex delayed_sig() { return d_out; } + +private: + int d_length; + gr_complex d_out, d_out_d1, d_out_d2; + std::deque<gr_complex> d_delay_line; +}; + class gr_dc_blocker_cc; typedef boost::shared_ptr<gr_dc_blocker_cc> gr_dc_blocker_cc_sptr; GR_CORE_API gr_dc_blocker_cc_sptr gr_make_dc_blocker_cc (int D=32, bool long_form=true); /*! * \class gr_dc_blocker_cc - * \brief a computationally efficient controllabel DC blocker + * \brief a computationally efficient controllable DC blocker * * \ingroup filter_blk * * This block implements a computationally efficient DC blocker that produces - * a tigher notch filter around DC for a smaller group delay than an + * a tighter notch filter around DC for a smaller group delay than an * equivalent FIR filter or using a single pole IIR filter (though the IIR * filter is computationally cheaper). * @@ -58,21 +73,6 @@ GR_CORE_API gr_dc_blocker_cc_sptr gr_make_dc_blocker_cc (int D=32, bool long_for * <B><EM>R. Yates, "DC Blocker Algorithms," IEEE Signal Processing Magazine, * Mar. 2008, pp 132-134.</EM></B> */ -class GR_CORE_API moving_averager_c -{ -public: - moving_averager_c(int D); - ~moving_averager_c(); - - gr_complex filter(gr_complex x); - gr_complex delayed_sig() { return d_out; } - -private: - int d_length; - gr_complex d_out, d_out_d1, d_out_d2; - std::deque<gr_complex> d_delay_line; -}; - class GR_CORE_API gr_dc_blocker_cc : public gr_sync_block { private: @@ -81,7 +81,7 @@ class GR_CORE_API gr_dc_blocker_cc : public gr_sync_block * \param D (int) the length of the delay line * \param long_form (bool) whether to use long (true, default) or short form */ - GR_CORE_API friend gr_dc_blocker_cc_sptr gr_make_dc_blocker_cc (int D, bool long_form); + friend GR_CORE_API gr_dc_blocker_cc_sptr gr_make_dc_blocker_cc (int D, bool long_form); int d_length; bool d_long_form; diff --git a/gnuradio-core/src/lib/filter/gr_dc_blocker_ff.h b/gnuradio-core/src/lib/filter/gr_dc_blocker_ff.h index 6045b69de..a7e8f1c27 100644 --- a/gnuradio-core/src/lib/filter/gr_dc_blocker_ff.h +++ b/gnuradio-core/src/lib/filter/gr_dc_blocker_ff.h @@ -28,18 +28,34 @@ #include <gr_sync_block.h> #include <deque> +class GR_CORE_API moving_averager_f +{ +public: + moving_averager_f(int D); + ~moving_averager_f(); + + float filter(float x); + float delayed_sig() { return d_out; } + +private: + int d_length; + float d_out, d_out_d1, d_out_d2; + std::deque<float> d_delay_line; +}; + + class gr_dc_blocker_ff; typedef boost::shared_ptr<gr_dc_blocker_ff> gr_dc_blocker_ff_sptr; GR_CORE_API gr_dc_blocker_ff_sptr gr_make_dc_blocker_ff (int D=32, bool long_form=true); /*! * \class gr_dc_blocker_ff - * \brief a computationally efficient controllabel DC blocker + * \brief a computationally efficient controllable DC blocker * * \ingroup filter_blk * * This block implements a computationally efficient DC blocker that produces - * a tigher notch filter around DC for a smaller group delay than an + * a tighter notch filter around DC for a smaller group delay than an * equivalent FIR filter or using a single pole IIR filter (though the IIR * filter is computationally cheaper). * @@ -58,21 +74,6 @@ GR_CORE_API gr_dc_blocker_ff_sptr gr_make_dc_blocker_ff (int D=32, bool long_for * <B><EM>R. Yates, "DC Blocker Algorithms," IEEE Signal Processing Magazine, * Mar. 2008, pp 132-134.</EM></B> */ -class GR_CORE_API moving_averager_f -{ -public: - moving_averager_f(int D); - ~moving_averager_f(); - - float filter(float x); - float delayed_sig() { return d_out; } - -private: - int d_length; - float d_out, d_out_d1, d_out_d2; - std::deque<float> d_delay_line; -}; - class GR_CORE_API gr_dc_blocker_ff : public gr_sync_block { private: @@ -81,7 +82,7 @@ class GR_CORE_API gr_dc_blocker_ff : public gr_sync_block * \param D (int) the length of the delay line * \param long_form (bool) whether to use long (true, default) or short form */ - GR_CORE_API friend gr_dc_blocker_ff_sptr gr_make_dc_blocker_ff (int D, bool long_form); + friend GR_CORE_API gr_dc_blocker_ff_sptr gr_make_dc_blocker_ff (int D, bool long_form); int d_length; bool d_long_form; diff --git a/gnuradio-core/src/lib/general/CMakeLists.txt b/gnuradio-core/src/lib/general/CMakeLists.txt index 0445e251e..7d61e9e0e 100644 --- a/gnuradio-core/src/lib/general/CMakeLists.txt +++ b/gnuradio-core/src/lib/general/CMakeLists.txt @@ -228,14 +228,6 @@ set(gr_core_general_triple_threats gr_nop gr_null_sink gr_null_source - gr_ofdm_frame_acquisition - gr_ofdm_cyclic_prefixer - gr_ofdm_demapper_vcb - gr_ofdm_mapper_bcv - gr_ofdm_frame_sink - #gr_ofdm_frame_sink2 #cannot build yet... - gr_ofdm_insert_preamble - gr_ofdm_sampler gr_pa_2x2_phase_combiner gr_packet_sink gr_peak_detector2_fb diff --git a/gnuradio-core/src/lib/general/Makefile.am b/gnuradio-core/src/lib/general/Makefile.am index e389e05e1..5915ff45b 100644 --- a/gnuradio-core/src/lib/general/Makefile.am +++ b/gnuradio-core/src/lib/general/Makefile.am @@ -96,13 +96,6 @@ libgeneral_la_SOURCES = \ gr_nop.cc \ gr_null_sink.cc \ gr_null_source.cc \ - gr_ofdm_frame_acquisition.cc \ - gr_ofdm_cyclic_prefixer.cc \ - gr_ofdm_demapper_vcb.cc \ - gr_ofdm_mapper_bcv.cc \ - gr_ofdm_frame_sink.cc \ - gr_ofdm_insert_preamble.cc \ - gr_ofdm_sampler.cc \ gr_pa_2x2_phase_combiner.cc \ gr_packet_sink.cc \ gr_peak_detector2_fb.cc \ @@ -252,13 +245,6 @@ grinclude_HEADERS = \ gr_nop.h \ gr_null_sink.h \ gr_null_source.h \ - gr_ofdm_frame_acquisition.h \ - gr_ofdm_cyclic_prefixer.h \ - gr_ofdm_demapper_vcb.h \ - gr_ofdm_mapper_bcv.h \ - gr_ofdm_frame_sink.h \ - gr_ofdm_insert_preamble.h \ - gr_ofdm_sampler.h \ gr_pa_2x2_phase_combiner.h \ gr_packet_sink.h \ gr_peak_detector2_fb.h \ @@ -411,13 +397,6 @@ swiginclude_HEADERS = \ gr_nop.i \ gr_null_sink.i \ gr_null_source.i \ - gr_ofdm_frame_acquisition.i \ - gr_ofdm_cyclic_prefixer.i \ - gr_ofdm_demapper_vcb.i \ - gr_ofdm_mapper_bcv.i \ - gr_ofdm_frame_sink.i \ - gr_ofdm_insert_preamble.i \ - gr_ofdm_sampler.i \ gr_pa_2x2_phase_combiner.i \ gr_packet_sink.i \ gr_peak_detector2_fb.i \ diff --git a/gnuradio-core/src/lib/general/general.i b/gnuradio-core/src/lib/general/general.i index 107f5c9ea..3e9a01a66 100644 --- a/gnuradio-core/src/lib/general/general.i +++ b/gnuradio-core/src/lib/general/general.i @@ -89,13 +89,6 @@ #include <gr_probe_avg_mag_sqrd_cf.h> #include <gr_probe_avg_mag_sqrd_f.h> #include <gr_probe_signal_f.h> -#include <gr_ofdm_frame_acquisition.h> -#include <gr_ofdm_cyclic_prefixer.h> -#include <gr_ofdm_mapper_bcv.h> -#include <gr_ofdm_frame_sink.h> - //#include <gr_ofdm_frame_sink2.h> -#include <gr_ofdm_insert_preamble.h> -#include <gr_ofdm_sampler.h> #include <gr_regenerate_bb.h> #include <gr_pa_2x2_phase_combiner.h> #include <gr_kludge_copy.h> @@ -208,13 +201,6 @@ %include "gr_probe_avg_mag_sqrd_cf.i" %include "gr_probe_avg_mag_sqrd_f.i" %include "gr_probe_signal_f.i" -%include "gr_ofdm_frame_acquisition.i" -%include "gr_ofdm_cyclic_prefixer.i" -%include "gr_ofdm_mapper_bcv.i" -%include "gr_ofdm_frame_sink.i" - //%include "gr_ofdm_frame_sink2.i" -%include "gr_ofdm_insert_preamble.i" -%include "gr_ofdm_sampler.i" %include "gr_regenerate_bb.i" %include "gr_pa_2x2_phase_combiner.i" %include "gr_kludge_copy.i" diff --git a/gnuradio-core/src/lib/general/gr_int_to_float.h b/gnuradio-core/src/lib/general/gr_int_to_float.h index dac7be9c4..9af381ba9 100644 --- a/gnuradio-core/src/lib/general/gr_int_to_float.h +++ b/gnuradio-core/src/lib/general/gr_int_to_float.h @@ -33,7 +33,7 @@ GR_CORE_API gr_int_to_float_sptr gr_make_int_to_float (); /*! - * \brief Convert stream of short to a stream of float + * \brief Convert stream of int to a stream of float * \ingroup converter_blk */ diff --git a/gnuradio-core/src/lib/general/gr_ofdm_cyclic_prefixer.i b/gnuradio-core/src/lib/general/gr_ofdm_cyclic_prefixer.i deleted file mode 100644 index 9fd8521a2..000000000 --- a/gnuradio-core/src/lib/general/gr_ofdm_cyclic_prefixer.i +++ /dev/null @@ -1,34 +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,ofdm_cyclic_prefixer) - -gr_ofdm_cyclic_prefixer_sptr -gr_make_ofdm_cyclic_prefixer (size_t input_size, size_t output_size); - -class gr_ofdm_cyclic_prefixer : public gr_sync_interpolator -{ - protected: - gr_ofdm_cyclic_prefixer (size_t input_size, size_t output_size); - - public: -}; diff --git a/gnuradio-core/src/lib/general/gr_ofdm_demapper_vcb.cc b/gnuradio-core/src/lib/general/gr_ofdm_demapper_vcb.cc deleted file mode 100644 index 4da7690b1..000000000 --- a/gnuradio-core/src/lib/general/gr_ofdm_demapper_vcb.cc +++ /dev/null @@ -1,41 +0,0 @@ -/* -*- 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 <gr_ofdm_demapper_vcb.h> -#include <gr_io_signature.h> - -gr_ofdm_demapper_vcb::~gr_ofdm_demapper_vcb(void) -{ -} - -gr_ofdm_demapper_vcb::gr_ofdm_demapper_vcb (unsigned bits_per_symbol,unsigned int vlen) - : gr_sync_decimator ("ofdm_demapper_vcb", - gr_make_io_signature (1, 1, sizeof(gr_complex)*vlen), - gr_make_io_signature (1, 1, sizeof(unsigned char)), - bits_per_symbol) -{ -} - diff --git a/gnuradio-core/src/lib/general/gr_ofdm_demapper_vcb.h b/gnuradio-core/src/lib/general/gr_ofdm_demapper_vcb.h deleted file mode 100644 index d12e007df..000000000 --- a/gnuradio-core/src/lib/general/gr_ofdm_demapper_vcb.h +++ /dev/null @@ -1,57 +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_DEMAPPER_VCB_H -#define INCLUDED_GR_OFDM_DEMAPPER_VCB_H - -#include <gr_core_api.h> -#include <gr_sync_decimator.h> - -class gr_ofdm_demapper_vcb; -typedef boost::shared_ptr<gr_ofdm_demapper_vcb> gr_ofdm_demapper_vcb_sptr; - -GR_CORE_API gr_ofdm_demapper_vcb_sptr -gr_make_ofdm_demapper_vcb (unsigned int bits_per_symbol, unsigned int vlen); - - -/*! - * \brief take a stream of vectors in from an FFT and demodulate to a stream of - * bits. Abstract class must be subclassed with specific mapping. - * - * \ingroup demodulation_blk - * \ingroup ofdm_blk - */ -class GR_CORE_API gr_ofdm_demapper_vcb : public gr_sync_decimator -{ - friend GR_CORE_API gr_ofdm_demapper_vcb_sptr - gr_make_ofdm_demapper_vcb (unsigned int bits_per_symbol, unsigned int vlen); - -protected: - gr_ofdm_demapper_vcb (unsigned int bits_per_symbol, unsigned int vlen); - -public: - ~gr_ofdm_demapper_vcb(void); -}; - - - -#endif diff --git a/gnuradio-core/src/python/gnuradio/CMakeLists.txt b/gnuradio-core/src/python/gnuradio/CMakeLists.txt index fffef834e..8d04b183d 100644 --- a/gnuradio-core/src/python/gnuradio/CMakeLists.txt +++ b/gnuradio-core/src/python/gnuradio/CMakeLists.txt @@ -29,8 +29,6 @@ GR_PYTHON_INSTALL(FILES __init__.py eng_notation.py eng_option.py - modulation_utils2.py - ofdm_packet_utils.py gr_unittest.py gr_xmlrunner.py optfir.py diff --git a/gnuradio-core/src/python/gnuradio/Makefile.am b/gnuradio-core/src/python/gnuradio/Makefile.am index 289e37662..066cc6d73 100644 --- a/gnuradio-core/src/python/gnuradio/Makefile.am +++ b/gnuradio-core/src/python/gnuradio/Makefile.am @@ -28,8 +28,6 @@ grpython_PYTHON = \ __init__.py \ eng_notation.py \ eng_option.py \ - modulation_utils2.py \ - ofdm_packet_utils.py \ gr_unittest.py \ gr_xmlrunner.py \ optfir.py \ diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/CMakeLists.txt b/gnuradio-core/src/python/gnuradio/blks2impl/CMakeLists.txt index 09797b961..dd0c201a3 100644 --- a/gnuradio-core/src/python/gnuradio/blks2impl/CMakeLists.txt +++ b/gnuradio-core/src/python/gnuradio/blks2impl/CMakeLists.txt @@ -30,18 +30,10 @@ GR_PYTHON_INSTALL(FILES logpwrfft.py nbfm_rx.py nbfm_tx.py - ofdm.py - ofdm_receiver.py - ofdm_sync_fixed.py - ofdm_sync_pn.py - ofdm_sync_pnac.py - ofdm_sync_ml.py pfb_arb_resampler.py pfb_channelizer.py pfb_decimator.py pfb_interpolator.py - psk.py - qam.py rational_resampler.py standard_squelch.py stream_to_vector_decimator.py diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/Makefile.am b/gnuradio-core/src/python/gnuradio/blks2impl/Makefile.am index 9665dde0b..5c627b873 100644 --- a/gnuradio-core/src/python/gnuradio/blks2impl/Makefile.am +++ b/gnuradio-core/src/python/gnuradio/blks2impl/Makefile.am @@ -37,18 +37,10 @@ grblkspython_PYTHON = \ logpwrfft.py \ nbfm_rx.py \ nbfm_tx.py \ - ofdm.py \ - ofdm_receiver.py \ - ofdm_sync_fixed.py \ - ofdm_sync_pn.py \ - ofdm_sync_pnac.py \ - ofdm_sync_ml.py \ pfb_arb_resampler.py \ pfb_channelizer.py \ pfb_decimator.py \ pfb_interpolator.py \ - psk.py \ - qam.py \ rational_resampler.py \ standard_squelch.py \ stream_to_vector_decimator.py \ diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/ofdm.py b/gnuradio-core/src/python/gnuradio/blks2impl/ofdm.py deleted file mode 100644 index 2663f7cf8..000000000 --- a/gnuradio-core/src/python/gnuradio/blks2impl/ofdm.py +++ /dev/null @@ -1,299 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2006,2007,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. -# - -import math -from gnuradio import gr, ofdm_packet_utils -import gnuradio.gr.gr_threading as _threading -import psk, qam - -from gnuradio.blks2impl.ofdm_receiver import ofdm_receiver - - -# ///////////////////////////////////////////////////////////////////////////// -# mod/demod with packets as i/o -# ///////////////////////////////////////////////////////////////////////////// - -class ofdm_mod(gr.hier_block2): - """ - Modulates an OFDM stream. Based on the options fft_length, occupied_tones, and - cp_length, this block creates OFDM symbols using a specified modulation option. - - Send packets by calling send_pkt - """ - def __init__(self, options, msgq_limit=2, pad_for_usrp=True): - """ - Hierarchical block for sending packets - - Packets to be sent are enqueued by calling send_pkt. - The output is the complex modulated signal at baseband. - - @param options: pass modulation options from higher layers (fft length, occupied tones, etc.) - @param msgq_limit: maximum number of messages in message queue - @type msgq_limit: int - @param pad_for_usrp: If true, packets are padded such that they end up a multiple of 128 samples - """ - - gr.hier_block2.__init__(self, "ofdm_mod", - gr.io_signature(0, 0, 0), # Input signature - gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature - - self._pad_for_usrp = pad_for_usrp - self._modulation = options.modulation - self._fft_length = options.fft_length - self._occupied_tones = options.occupied_tones - self._cp_length = options.cp_length - - win = [] #[1 for i in range(self._fft_length)] - - # Use freq domain to get doubled-up known symbol for correlation in time domain - zeros_on_left = int(math.ceil((self._fft_length - self._occupied_tones)/2.0)) - ksfreq = known_symbols_4512_3[0:self._occupied_tones] - for i in range(len(ksfreq)): - if((zeros_on_left + i) & 1): - ksfreq[i] = 0 - - # hard-coded known symbols - preambles = (ksfreq,) - - padded_preambles = list() - for pre in preambles: - padded = self._fft_length*[0,] - padded[zeros_on_left : zeros_on_left + self._occupied_tones] = pre - padded_preambles.append(padded) - - symbol_length = options.fft_length + options.cp_length - - mods = {"bpsk": 2, "qpsk": 4, "8psk": 8, "qam8": 8, "qam16": 16, "qam64": 64, "qam256": 256} - arity = mods[self._modulation] - - rot = 1 - if self._modulation == "qpsk": - rot = (0.707+0.707j) - - if(self._modulation.find("psk") >= 0): - rotated_const = map(lambda pt: pt * rot, psk.gray_constellation[arity]) - elif(self._modulation.find("qam") >= 0): - rotated_const = map(lambda pt: pt * rot, qam.constellation[arity]) - #print rotated_const - self._pkt_input = gr.ofdm_mapper_bcv(rotated_const, msgq_limit, - options.occupied_tones, options.fft_length) - - self.preambles = gr.ofdm_insert_preamble(self._fft_length, padded_preambles) - self.ifft = gr.fft_vcc(self._fft_length, False, win, True) - self.cp_adder = gr.ofdm_cyclic_prefixer(self._fft_length, symbol_length) - self.scale = gr.multiply_const_cc(1.0 / math.sqrt(self._fft_length)) - - self.connect((self._pkt_input, 0), (self.preambles, 0)) - self.connect((self._pkt_input, 1), (self.preambles, 1)) - self.connect(self.preambles, self.ifft, self.cp_adder, self.scale, self) - - if options.verbose: - self._print_verbage() - - if options.log: - self.connect(self._pkt_input, gr.file_sink(gr.sizeof_gr_complex*options.fft_length, - "ofdm_mapper_c.dat")) - self.connect(self.preambles, gr.file_sink(gr.sizeof_gr_complex*options.fft_length, - "ofdm_preambles.dat")) - self.connect(self.ifft, gr.file_sink(gr.sizeof_gr_complex*options.fft_length, - "ofdm_ifft_c.dat")) - self.connect(self.cp_adder, gr.file_sink(gr.sizeof_gr_complex, - "ofdm_cp_adder_c.dat")) - - def send_pkt(self, payload='', eof=False): - """ - Send the payload. - - @param payload: data to send - @type payload: string - """ - if eof: - msg = gr.message(1) # tell self._pkt_input we're not sending any more packets - else: - # print "original_payload =", string_to_hex_list(payload) - pkt = ofdm_packet_utils.make_packet(payload, 1, 1, self._pad_for_usrp, whitening=True) - - #print "pkt =", string_to_hex_list(pkt) - msg = gr.message_from_string(pkt) - self._pkt_input.msgq().insert_tail(msg) - - def add_options(normal, expert): - """ - Adds OFDM-specific options to the Options Parser - """ - normal.add_option("-m", "--modulation", type="string", default="bpsk", - help="set modulation type (bpsk, qpsk, 8psk, qam{16,64}) [default=%default]") - expert.add_option("", "--fft-length", type="intx", default=512, - help="set the number of FFT bins [default=%default]") - expert.add_option("", "--occupied-tones", type="intx", default=200, - help="set the number of occupied FFT bins [default=%default]") - expert.add_option("", "--cp-length", type="intx", default=128, - help="set the number of bits in the cyclic prefix [default=%default]") - # Make a static method to call before instantiation - add_options = staticmethod(add_options) - - def _print_verbage(self): - """ - Prints information about the OFDM modulator - """ - print "\nOFDM Modulator:" - print "Modulation Type: %s" % (self._modulation) - print "FFT length: %3d" % (self._fft_length) - print "Occupied Tones: %3d" % (self._occupied_tones) - print "CP length: %3d" % (self._cp_length) - - -class ofdm_demod(gr.hier_block2): - """ - Demodulates a received OFDM stream. Based on the options fft_length, occupied_tones, and - cp_length, this block performs synchronization, FFT, and demodulation of incoming OFDM - symbols and passes packets up the a higher layer. - - The input is complex baseband. When packets are demodulated, they are passed to the - app via the callback. - """ - - def __init__(self, options, callback=None): - """ - Hierarchical block for demodulating and deframing packets. - - The input is the complex modulated signal at baseband. - Demodulated packets are sent to the handler. - - @param options: pass modulation options from higher layers (fft length, occupied tones, etc.) - @param callback: function of two args: ok, payload - @type callback: ok: bool; payload: string - """ - gr.hier_block2.__init__(self, "ofdm_demod", - gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature - gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature - - - self._rcvd_pktq = gr.msg_queue() # holds packets from the PHY - - self._modulation = options.modulation - self._fft_length = options.fft_length - self._occupied_tones = options.occupied_tones - self._cp_length = options.cp_length - self._snr = options.snr - - # Use freq domain to get doubled-up known symbol for correlation in time domain - zeros_on_left = int(math.ceil((self._fft_length - self._occupied_tones)/2.0)) - ksfreq = known_symbols_4512_3[0:self._occupied_tones] - for i in range(len(ksfreq)): - if((zeros_on_left + i) & 1): - ksfreq[i] = 0 - - # hard-coded known symbols - preambles = (ksfreq,) - - symbol_length = self._fft_length + self._cp_length - self.ofdm_recv = ofdm_receiver(self._fft_length, self._cp_length, - self._occupied_tones, self._snr, preambles, - options.log) - - mods = {"bpsk": 2, "qpsk": 4, "8psk": 8, "qam8": 8, "qam16": 16, "qam64": 64, "qam256": 256} - arity = mods[self._modulation] - - rot = 1 - if self._modulation == "qpsk": - rot = (0.707+0.707j) - - if(self._modulation.find("psk") >= 0): - rotated_const = map(lambda pt: pt * rot, psk.gray_constellation[arity]) - elif(self._modulation.find("qam") >= 0): - rotated_const = map(lambda pt: pt * rot, qam.constellation[arity]) - #print rotated_const - - phgain = 0.25 - frgain = phgain*phgain / 4.0 - self.ofdm_demod = gr.ofdm_frame_sink(rotated_const, range(arity), - self._rcvd_pktq, - self._occupied_tones, - phgain, frgain) - - self.connect(self, self.ofdm_recv) - self.connect((self.ofdm_recv, 0), (self.ofdm_demod, 0)) - self.connect((self.ofdm_recv, 1), (self.ofdm_demod, 1)) - - # added output signature to work around bug, though it might not be a bad - # thing to export, anyway - self.connect(self.ofdm_recv.chan_filt, self) - - if options.log: - self.connect(self.ofdm_demod, gr.file_sink(gr.sizeof_gr_complex*self._occupied_tones, "ofdm_frame_sink_c.dat")) - else: - self.connect(self.ofdm_demod, gr.null_sink(gr.sizeof_gr_complex*self._occupied_tones)) - - if options.verbose: - self._print_verbage() - - self._watcher = _queue_watcher_thread(self._rcvd_pktq, callback) - - def add_options(normal, expert): - """ - Adds OFDM-specific options to the Options Parser - """ - normal.add_option("-m", "--modulation", type="string", default="bpsk", - help="set modulation type (bpsk or qpsk) [default=%default]") - expert.add_option("", "--fft-length", type="intx", default=512, - help="set the number of FFT bins [default=%default]") - expert.add_option("", "--occupied-tones", type="intx", default=200, - help="set the number of occupied FFT bins [default=%default]") - expert.add_option("", "--cp-length", type="intx", default=128, - help="set the number of bits in the cyclic prefix [default=%default]") - # Make a static method to call before instantiation - add_options = staticmethod(add_options) - - def _print_verbage(self): - """ - Prints information about the OFDM demodulator - """ - print "\nOFDM Demodulator:" - print "Modulation Type: %s" % (self._modulation) - print "FFT length: %3d" % (self._fft_length) - print "Occupied Tones: %3d" % (self._occupied_tones) - print "CP length: %3d" % (self._cp_length) - - - -class _queue_watcher_thread(_threading.Thread): - def __init__(self, rcvd_pktq, callback): - _threading.Thread.__init__(self) - self.setDaemon(1) - self.rcvd_pktq = rcvd_pktq - self.callback = callback - self.keep_running = True - self.start() - - - def run(self): - while self.keep_running: - msg = self.rcvd_pktq.delete_head() - ok, payload = ofdm_packet_utils.unmake_packet(msg.to_string()) - if self.callback: - self.callback(ok, payload) - -# Generating known symbols with: -# i = [2*random.randint(0,1)-1 for i in range(4512)] - -known_symbols_4512_3 = [-1, -1, 1, -1, 1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, -1, 1, -1, 1, -1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1, 1, 1, -1, 1, 1, 1, -1, 1, -1, 1, 1, -1, -1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, -1, 1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, -1, -1, -1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1, -1, -1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, 1, 1, 1, -1, 1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, -1, -1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, 1, 1, -1, -1, 1, 1, -1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1, 1, -1, 1, -1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, 1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, 1, -1, -1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, -1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, 1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, 1, -1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, 1, 1, -1, 1, 1, 1, -1, -1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, -1, -1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, 1, 1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, -1, 1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, -1, 1, 1, -1, 1, 1, 1, -1, 1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, 1, 1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, -1, 1, 1, -1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, 1, -1, 1, -1, 1, -1, 1, -1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, -1, 1, -1, 1, -1, -1, 1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, 1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, -1, -1, -1, 1, 1, -1, 1, -1, -1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, 1, 1, -1, -1, -1, -1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, -1, 1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, -1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 1, 1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, -1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, -1, 1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, 1, -1, -1, 1, 1, 1, 1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, 1, -1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, 1, -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, 1, -1, 1, -1, -1, 1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, 1, 1, 1, -1, 1, -1, 1, -1, -1, -1, 1, -1, -1, 1, -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, -1, -1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, 1, 1, -1, 1, -1, 1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, 1, -1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, -1, 1, -1, 1, -1, -1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, 1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, 1, -1, 1, -1] diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/psk.py b/gnuradio-core/src/python/gnuradio/blks2impl/psk.py deleted file mode 100644 index acedf3b69..000000000 --- a/gnuradio-core/src/python/gnuradio/blks2impl/psk.py +++ /dev/null @@ -1,94 +0,0 @@ -# -# Copyright 2005,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. -# - -from math import pi, sqrt, log10 -import math, cmath - -# The following algorithm generates Gray coded constellations for M-PSK for M=[2,4,8] -def make_gray_constellation(m): - # number of bits/symbol (log2(M)) - k = int(log10(m) / log10(2.0)) - - coeff = 1 - const_map = [] - bits = [0]*3 - for i in range(m): - # get a vector of the k bits to use in this mapping - bits[3-k:3] = [((i&(0x01 << k-j-1)) >> k-j-1) for j in range(k)] - - theta = -(2*bits[0]-1)*(2*pi/m)*(bits[0]+abs(bits[1]-bits[2])+2*bits[1]) - re = math.cos(theta) - im = math.sin(theta) - const_map.append(complex(re, im)) # plug it into the constellation - - # return the constellation; by default, it is normalized - return const_map - -# This makes a constellation that increments around the unit circle -def make_constellation(m): - return [cmath.exp(i * 2 * pi / m * 1j) for i in range(m)] - -# Common definition of constellations for Tx and Rx -constellation = { - 2 : make_constellation(2), # BPSK - 4 : make_constellation(4), # QPSK - 8 : make_constellation(8) # 8PSK - } - -gray_constellation = { - 2 : make_gray_constellation(2), # BPSK - 4 : make_gray_constellation(4), # QPSK - 8 : make_gray_constellation(8) # 8PSK - } - -# ----------------------- -# Do Gray code -# ----------------------- -# binary to gray coding -- constellation does Gray coding -binary_to_gray = { - 2 : range(2), - 4 : [0,1,3,2], - 8 : [0, 1, 3, 2, 7, 6, 4, 5] - } - -# gray to binary -gray_to_binary = { - 2 : range(2), - 4 : [0,1,3,2], - 8 : [0, 1, 3, 2, 6, 7, 5, 4] - } - -# ----------------------- -# Don't Gray code -# ----------------------- -# identity mapping -binary_to_ungray = { - 2 : range(2), - 4 : range(4), - 8 : range(8) - } - -# identity mapping -ungray_to_binary = { - 2 : range(2), - 4 : range(4), - 8 : range(8) - } diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/qam.py b/gnuradio-core/src/python/gnuradio/blks2impl/qam.py deleted file mode 100644 index 22b1e1dab..000000000 --- a/gnuradio-core/src/python/gnuradio/blks2impl/qam.py +++ /dev/null @@ -1,113 +0,0 @@ -# -# Copyright 2005,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. -# - -from math import pi, sqrt -import math - -# These constellations are generated for Gray coding when symbos [1, ..., m] are used -# Mapping to Gray coding is therefore unnecessary - -def make_constellation(m): - # number of bits/symbol (log2(M)) - k = int(math.log10(m) / math.log10(2.0)) - - coeff = 1 - const_map = [] - for i in range(m): - a = (i&(0x01 << k-1)) >> k-1 - b = (i&(0x01 << k-2)) >> k-2 - bits_i = [((i&(0x01 << k-j-1)) >> k-j-1) for j in range(2, k, 2)] - bits_q = [((i&(0x01 << k-j-1)) >> k-j-1) for j in range(3, k, 2)] - - ss = 0 - ll = len(bits_i) - for ii in range(ll): - rr = 0 - for jj in range(ll-ii): - rr = abs(bits_i[jj] - rr) - ss += rr*pow(2.0, ii+1) - re = (2*a-1)*(ss+1) - - ss = 0 - ll = len(bits_q) - for ii in range(ll): - rr = 0 - for jj in range(ll-ii): - rr = abs(bits_q[jj] - rr) - ss += rr*pow(2.0, ii+1) - im = (2*b-1)*(ss+1) - - a = max(re, im) - if a > coeff: - coeff = a - const_map.append(complex(re, im)) - - norm_map = [complex(i.real/coeff, i.imag/coeff) for i in const_map] - return norm_map - -# Common definition of constellations for Tx and Rx -constellation = { - 4 : make_constellation(4), # QAM4 (QPSK) - 8 : make_constellation(8), # QAM8 - 16: make_constellation(16), # QAM16 - 64: make_constellation(64), # QAM64 - 256: make_constellation(256) # QAM256 - } - -# ----------------------- -# Do Gray code -# ----------------------- -# binary to gray coding -binary_to_gray = { - 4 : range(4), - 8 : range(8), - 16: range(16), - 64: range(64), - 256: range(256) - } - -# gray to binary -gray_to_binary = { - 4 : range(4), - 8 : range(8), - 16: range(16), - 64: range(64), - 256: range(256) - } - -# ----------------------- -# Don't Gray code -# ----------------------- -# identity mapping -binary_to_ungray = { - 4 : range(4), - 8 : range(8), - 16: range(16), - 64: range(64) - } - -# identity mapping -ungray_to_binary = { - 4 : range(4), - 8 : range(8), - 16: range(16), - 64: range(64) - } diff --git a/gnuradio-core/src/python/gnuradio/gr/Makefile.am b/gnuradio-core/src/python/gnuradio/gr/Makefile.am index 7bf1c0827..0960323dc 100644 --- a/gnuradio-core/src/python/gnuradio/gr/Makefile.am +++ b/gnuradio-core/src/python/gnuradio/gr/Makefile.am @@ -79,7 +79,6 @@ noinst_PYTHON = \ qa_mute.py \ qa_nlog10.py \ qa_noise.py \ - qa_ofdm_insert_preamble.py \ qa_packed_to_unpacked.py \ qa_pipe_fittings.py \ qa_pll_carriertracking.py \ diff --git a/gnuradio-core/src/python/gnuradio/modulation_utils2.py b/gnuradio-core/src/python/gnuradio/modulation_utils2.py deleted file mode 100644 index c5dba3e79..000000000 --- a/gnuradio-core/src/python/gnuradio/modulation_utils2.py +++ /dev/null @@ -1,81 +0,0 @@ -# -# 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 this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -# - -""" -Miscellaneous utilities for managing mods and demods, as well as other items -useful in dealing with generalized handling of different modulations and demods. -""" - -import inspect - - -# Type 1 modulators accept a stream of bytes on their input and produce complex baseband output -_type_1_modulators = {} - -def type_1_mods(): - return _type_1_modulators - -def add_type_1_mod(name, mod_class): - _type_1_modulators[name] = mod_class - - -# Type 1 demodulators accept complex baseband input and produce a stream of bits, packed -# 1 bit / byte as their output. Their output is completely unambiguous. There is no need -# to resolve phase or polarity ambiguities. -_type_1_demodulators = {} - -def type_1_demods(): - return _type_1_demodulators - -def add_type_1_demod(name, demod_class): - _type_1_demodulators[name] = demod_class - - -def extract_kwargs_from_options(function, excluded_args, options): - """ - Given a function, a list of excluded arguments and the result of - parsing command line options, create a dictionary of key word - arguments suitable for passing to the function. The dictionary - will be populated with key/value pairs where the keys are those - that are common to the function's argument list (minus the - excluded_args) and the attributes in options. The values are the - corresponding values from options unless that value is None. - In that case, the corresponding dictionary entry is not populated. - - (This allows different modulations that have the same parameter - names, but different default values to coexist. The downside is - that --help in the option parser will list the default as None, - but in that case the default provided in the __init__ argument - list will be used since there is no kwargs entry.) - - @param function: the function whose parameter list will be examined - @param excluded_args: function arguments that are NOT to be added to the dictionary - @type excluded_args: sequence of strings - @param options: result of command argument parsing - @type options: optparse.Values - """ - # Try this in C++ ;) - args, varargs, varkw, defaults = inspect.getargspec(function) - d = {} - for kw in [a for a in args if a not in excluded_args]: - if hasattr(options, kw): - if getattr(options, kw) is not None: - d[kw] = getattr(options, kw) - return d diff --git a/gnuradio-examples/python/Makefile.am b/gnuradio-examples/python/Makefile.am index a32f1fa86..80a319dd7 100644 --- a/gnuradio-examples/python/Makefile.am +++ b/gnuradio-examples/python/Makefile.am @@ -25,6 +25,5 @@ SUBDIRS = \ mp-sched \ multi_usrp \ network \ - ofdm \ pfb \ tags diff --git a/gnuradio-examples/python/ofdm/.gitignore b/gnuradio-examples/python/ofdm/.gitignore deleted file mode 100644 index 2f6a10e95..000000000 --- a/gnuradio-examples/python/ofdm/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -/Makefile -/Makefile.in -/*.pyc -/*.dat diff --git a/gnuradio-examples/python/ofdm/Makefile.am b/gnuradio-examples/python/ofdm/Makefile.am deleted file mode 100644 index fc7156b4c..000000000 --- a/gnuradio-examples/python/ofdm/Makefile.am +++ /dev/null @@ -1,42 +0,0 @@ -# -# Copyright 2007,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. -# - -include $(top_srcdir)/Makefile.common - -ourdatadir = $(exampledir)/ofdm - -dist_ourdata_DATA = \ - ofdm_sync.m \ - ofdm_sync_pn.m \ - fusb_options.py \ - plot_ofdm.m \ - pick_bitrate.py \ - receive_path.py \ - transmit_path.py - -dist_ourdata_SCRIPTS = \ - benchmark_ofdm.py \ - benchmark_ofdm_rx.py \ - benchmark_ofdm_tx.py \ - fftshift.py \ - ofdm_mod_demod_test.py \ - tunnel.py - diff --git a/gnuradio-examples/python/ofdm/benchmark_ofdm.py b/gnuradio-examples/python/ofdm/benchmark_ofdm.py deleted file mode 100755 index 6d6ca9f2a..000000000 --- a/gnuradio-examples/python/ofdm/benchmark_ofdm.py +++ /dev/null @@ -1,187 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2006, 2007, 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 gnuradio import gr, blks2 -from gnuradio import eng_notation -from gnuradio.eng_option import eng_option -from optparse import OptionParser - -import random, time, struct, sys, math, os - -# from current dir -from transmit_path import transmit_path -from receive_path import receive_path - - -class my_top_block(gr.top_block): - def __init__(self, callback, options): - gr.top_block.__init__(self) - - if not options.channel_off: - SNR = 10.0**(options.snr/10.0) - power_in_signal = abs(options.tx_amplitude)**2.0 - noise_power_in_channel = power_in_signal/SNR - noise_voltage = math.sqrt(noise_power_in_channel/2.0) - print "Noise voltage: ", noise_voltage - - frequency_offset = options.frequency_offset / options.fft_length - print "Frequency offset: ", frequency_offset - - if options.multipath_on: - taps = [1.0, .2, 0.0, .1, .08, -.4, .12, -.2, 0, 0, 0, .3] - else: - taps = [1.0, 0.0] - - else: - noise_voltage = 0.0 - frequency_offset = 0.0 - taps = [1.0, 0.0] - - symbols_per_packet = math.ceil(((4+options.size+4) * 8) / options.occupied_tones) - samples_per_packet = (symbols_per_packet+2) * (options.fft_length+options.cp_length) - print "Symbols per Packet: ", symbols_per_packet - print "Samples per Packet: ", samples_per_packet - if options.discontinuous: - stream_size = [100000, int(options.discontinuous*samples_per_packet)] - else: - stream_size = [0, 100000] - - z = [0,] - self.zeros = gr.vector_source_c(z, True) - self.txpath = transmit_path(options) - - #self.mux = gr.stream_mux(gr.sizeof_gr_complex, stream_size) - self.throttle = gr.throttle(gr.sizeof_gr_complex, options.sample_rate) - self.channel = gr.channel_model(noise_voltage, frequency_offset, - options.clockrate_ratio, taps) - self.rxpath = receive_path(callback, options) - - #self.connect(self.zeros, (self.mux,0)) - #self.connect(self.txpath, (self.mux,1)) - #self.connect(self.mux, self.throttle, self.channel, self.rxpath) - #self.connect(self.mux, self.throttle, self.rxpath) - self.connect(self.txpath, self.throttle, self.channel, self.rxpath) - - if options.log: - self.connect(self.txpath, gr.file_sink(gr.sizeof_gr_complex, "txpath.dat")) - #self.connect(self.mux, gr.file_sink(gr.sizeof_gr_complex, "mux.dat")) - #self.connect(self.channel, gr.file_sink(gr.sizeof_gr_complex, "channel.dat")) - -# ///////////////////////////////////////////////////////////////////////////// -# main -# ///////////////////////////////////////////////////////////////////////////// - -def main(): - global n_rcvd, n_right - - n_rcvd = 0 - n_right = 0 - - def send_pkt(payload='', eof=False): - return tb.txpath.send_pkt(payload, eof) - - def rx_callback(ok, payload): - global n_rcvd, n_right - n_rcvd += 1 - (pktno,) = struct.unpack('!H', payload[0:2]) - if ok: - n_right += 1 - print "ok: %r \t pktno: %d \t n_rcvd: %d \t n_right: %d" % (ok, pktno, n_rcvd, n_right) - - printlst = list() - for x in payload[2:]: - t = hex(ord(x)).replace('0x', '') - if(len(t) == 1): - t = '0' + t - printlst.append(t) - printable = ''.join(printlst) - - print printable - print "\n" - - parser = OptionParser(option_class=eng_option, conflict_handler="resolve") - expert_grp = parser.add_option_group("Expert") - parser.add_option("-s", "--size", type="eng_float", default=400, - help="set packet size [default=%default]") - parser.add_option("-M", "--megabytes", type="eng_float", default=1.0, - help="set megabytes to transmit [default=%default]") - parser.add_option("-r", "--sample-rate", type="eng_float", default=1e5, - help="limit sample rate to RATE in throttle (%default)") - parser.add_option("", "--snr", type="eng_float", default=30, - help="set the SNR of the channel in dB [default=%default]") - parser.add_option("", "--frequency-offset", type="eng_float", default=0, - help="set frequency offset introduced by channel [default=%default]") - parser.add_option("", "--clockrate-ratio", type="eng_float", default=1.0, - help="set clock rate ratio (sample rate difference) between two systems [default=%default]") - parser.add_option("","--discontinuous", type="int", default=0, - help="enable discontinous transmission, burst of N packets [Default is continuous]") - parser.add_option("","--channel-off", action="store_true", default=False, - help="Turns AWGN, freq offset channel off") - parser.add_option("","--multipath-on", action="store_true", default=False, - help="enable multipath") - - transmit_path.add_options(parser, expert_grp) - receive_path.add_options(parser, expert_grp) - blks2.ofdm_mod.add_options(parser, expert_grp) - blks2.ofdm_demod.add_options(parser, expert_grp) - - (options, args) = parser.parse_args () - - # build the graph - tb = my_top_block(rx_callback, options) - - r = gr.enable_realtime_scheduling() - # if r != gr.RT_OK: - # print "Warning: failed to enable realtime scheduling" - - tb.start() # start flow graph - - # generate and send packets - nbytes = int(1e6 * options.megabytes) - n = 0 - pktno = 0 - pkt_size = int(options.size) - - while n < nbytes: - #r = ''.join([chr(random.randint(0,255)) for i in range(pkt_size-2)]) - #pkt_contents = struct.pack('!H', pktno) + r - - pkt_contents = struct.pack('!H', pktno) + (pkt_size - 2) * chr(pktno & 0xff) - - send_pkt(pkt_contents) - n += pkt_size - #sys.stderr.write('.') - #if options.discontinuous and pktno % 5 == 4: - # time.sleep(1) - pktno += 1 - - send_pkt(eof=True) - tb.wait() # wait for it to finish - - -if __name__ == '__main__': - try: - main() - except KeyboardInterrupt: - pass - - diff --git a/gnuradio-examples/python/ofdm/benchmark_ofdm_rx.py b/gnuradio-examples/python/ofdm/benchmark_ofdm_rx.py deleted file mode 100755 index cb9649a6c..000000000 --- a/gnuradio-examples/python/ofdm/benchmark_ofdm_rx.py +++ /dev/null @@ -1,212 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2006, 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. -# - -from gnuradio import gr, blks2 -from gnuradio import usrp -from gnuradio import eng_notation -from gnuradio.eng_option import eng_option -from optparse import OptionParser - -import struct, sys - -# from current dir -from receive_path import receive_path -import fusb_options - -class my_top_block(gr.top_block): - def __init__(self, callback, options): - gr.top_block.__init__(self) - - self._rx_freq = options.rx_freq # receiver's center frequency - self._rx_gain = options.rx_gain # receiver's gain - self._rx_subdev_spec = options.rx_subdev_spec # daughterboard to use - self._decim = options.decim # Decimating rate for the USRP (prelim) - self._fusb_block_size = options.fusb_block_size # usb info for USRP - self._fusb_nblocks = options.fusb_nblocks # usb info for USRP - - if self._rx_freq is None: - sys.stderr.write("-f FREQ or --freq FREQ or --rx-freq FREQ must be specified\n") - raise SystemExit - - # Set up USRP source - self._setup_usrp_source() - ok = self.set_freq(self._rx_freq) - if not ok: - print "Failed to set Rx frequency to %s" % (eng_notation.num_to_str(self._rx_freq)) - raise ValueError, eng_notation.num_to_str(self._rx_freq) - g = self.subdev.gain_range() - if options.show_rx_gain_range: - print "Rx Gain Range: minimum = %g, maximum = %g, step size = %g" \ - % (g[0], g[1], g[2]) - self.set_gain(options.rx_gain) - self.set_auto_tr(True) # enable Auto Transmit/Receive switching - - # Set up receive path - self.rxpath = receive_path(callback, options) - - self.connect(self.u, self.rxpath) - - def _setup_usrp_source(self): - self.u = usrp.source_c (fusb_block_size=self._fusb_block_size, - fusb_nblocks=self._fusb_nblocks) - adc_rate = self.u.adc_rate() - - self.u.set_decim_rate(self._decim) - - # determine the daughterboard subdevice we're using - if self._rx_subdev_spec is None: - self._rx_subdev_spec = usrp.pick_rx_subdevice(self.u) - self.subdev = usrp.selected_subdev(self.u, self._rx_subdev_spec) - - self.u.set_mux(usrp.determine_rx_mux_value(self.u, self._rx_subdev_spec)) - - def set_freq(self, target_freq): - """ - Set the center frequency we're interested in. - - @param target_freq: frequency in Hz - @rypte: bool - - Tuning is a two step process. First we ask the front-end to - tune as close to the desired frequency as it can. Then we use - the result of that operation and our target_frequency to - determine the value for the digital up converter. - """ - r = self.u.tune(0, self.subdev, target_freq) - if r: - return True - - return False - - def set_gain(self, gain): - """ - Sets the analog gain in the USRP - """ - if gain is None: - r = self.subdev.gain_range() - gain = (r[0] + r[1])/2 # set gain to midpoint - self.gain = gain - return self.subdev.set_gain(gain) - - def set_auto_tr(self, enable): - return self.subdev.set_auto_tr(enable) - - def decim(self): - return self._decim - - def add_options(normal, expert): - """ - Adds usrp-specific options to the Options Parser - """ - add_freq_option(normal) - normal.add_option("-R", "--rx-subdev-spec", type="subdev", default=None, - help="select USRP Rx side A or B") - normal.add_option("", "--rx-gain", type="eng_float", default=None, metavar="GAIN", - help="set receiver gain in dB [default=midpoint]. See also --show-rx-gain-range") - normal.add_option("", "--show-rx-gain-range", action="store_true", default=False, - help="print min and max Rx gain available on selected daughterboard") - normal.add_option("-v", "--verbose", action="store_true", default=False) - - expert.add_option("", "--rx-freq", type="eng_float", default=None, - help="set Rx frequency to FREQ [default=%default]", metavar="FREQ") - expert.add_option("-d", "--decim", type="intx", default=128, - help="set fpga decimation rate to DECIM [default=%default]") - expert.add_option("", "--snr", type="eng_float", default=30, - help="set the SNR of the channel in dB [default=%default]") - - - # Make a static method to call before instantiation - add_options = staticmethod(add_options) - -def add_freq_option(parser): - """ - Hackery that has the -f / --freq option set both tx_freq and rx_freq - """ - def freq_callback(option, opt_str, value, parser): - parser.values.rx_freq = value - parser.values.tx_freq = value - - if not parser.has_option('--freq'): - parser.add_option('-f', '--freq', type="eng_float", - action="callback", callback=freq_callback, - help="set Tx and/or Rx frequency to FREQ [default=%default]", - metavar="FREQ") - -# ///////////////////////////////////////////////////////////////////////////// -# main -# ///////////////////////////////////////////////////////////////////////////// - -def main(): - - global n_rcvd, n_right - - n_rcvd = 0 - n_right = 0 - - def rx_callback(ok, payload): - global n_rcvd, n_right - n_rcvd += 1 - (pktno,) = struct.unpack('!H', payload[0:2]) - if ok: - n_right += 1 - print "ok: %r \t pktno: %d \t n_rcvd: %d \t n_right: %d" % (ok, pktno, n_rcvd, n_right) - - if 0: - printlst = list() - for x in payload[2:]: - t = hex(ord(x)).replace('0x', '') - if(len(t) == 1): - t = '0' + t - printlst.append(t) - printable = ''.join(printlst) - - print printable - print "\n" - - parser = OptionParser(option_class=eng_option, conflict_handler="resolve") - expert_grp = parser.add_option_group("Expert") - parser.add_option("","--discontinuous", action="store_true", default=False, - help="enable discontinuous") - - my_top_block.add_options(parser, expert_grp) - receive_path.add_options(parser, expert_grp) - blks2.ofdm_mod.add_options(parser, expert_grp) - blks2.ofdm_demod.add_options(parser, expert_grp) - fusb_options.add_options(expert_grp) - - (options, args) = parser.parse_args () - - # build the graph - tb = my_top_block(rx_callback, options) - - r = gr.enable_realtime_scheduling() - if r != gr.RT_OK: - print "Warning: failed to enable realtime scheduling" - - tb.start() # start flow graph - tb.wait() # wait for it to finish - -if __name__ == '__main__': - try: - main() - except KeyboardInterrupt: - pass diff --git a/gnuradio-examples/python/ofdm/benchmark_ofdm_tx.py b/gnuradio-examples/python/ofdm/benchmark_ofdm_tx.py deleted file mode 100755 index 918ff0842..000000000 --- a/gnuradio-examples/python/ofdm/benchmark_ofdm_tx.py +++ /dev/null @@ -1,219 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2005, 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. -# - -from gnuradio import gr, blks2 -from gnuradio import usrp -from gnuradio import eng_notation -from gnuradio.eng_option import eng_option -from optparse import OptionParser - -import time, struct, sys - -# from current dir -from transmit_path import transmit_path -from pick_bitrate import pick_tx_bitrate -import fusb_options - -class my_top_block(gr.top_block): - def __init__(self, options): - gr.top_block.__init__(self) - - self._tx_freq = options.tx_freq # tranmitter's center frequency - self._tx_subdev_spec = options.tx_subdev_spec # daughterboard to use - self._interp = options.interp # interpolating rate for the USRP (prelim) - self._fusb_block_size = options.fusb_block_size # usb info for USRP - self._fusb_nblocks = options.fusb_nblocks # usb info for USRP - - if self._tx_freq is None: - sys.stderr.write("-f FREQ or --freq FREQ or --tx-freq FREQ must be specified\n") - raise SystemExit - - # Set up USRP sink; also adjusts interp, and bitrate - self._setup_usrp_sink() - - # copy the final answers back into options for use by modulator - #options.bitrate = self._bitrate - - self.txpath = transmit_path(options) - - self.connect(self.txpath, self.u) - - def _setup_usrp_sink(self): - """ - Creates a USRP sink, determines the settings for best bitrate, - and attaches to the transmitter's subdevice. - """ - self.u = usrp.sink_c(fusb_block_size=self._fusb_block_size, - fusb_nblocks=self._fusb_nblocks) - - self.u.set_interp_rate(self._interp) - - # determine the daughterboard subdevice we're using - if self._tx_subdev_spec is None: - self._tx_subdev_spec = usrp.pick_tx_subdevice(self.u) - self.u.set_mux(usrp.determine_tx_mux_value(self.u, self._tx_subdev_spec)) - self.subdev = usrp.selected_subdev(self.u, self._tx_subdev_spec) - - # Set center frequency of USRP - ok = self.set_freq(self._tx_freq) - if not ok: - print "Failed to set Tx frequency to %s" % (eng_notation.num_to_str(self._tx_freq),) - raise ValueError - - # Set the USRP for maximum transmit gain - # (Note that on the RFX cards this is a nop.) - self.set_gain(self.subdev.gain_range()[1]) - - # enable Auto Transmit/Receive switching - self.set_auto_tr(True) - - def set_freq(self, target_freq): - """ - Set the center frequency we're interested in. - - @param target_freq: frequency in Hz - @rypte: bool - - Tuning is a two step process. First we ask the front-end to - tune as close to the desired frequency as it can. Then we use - the result of that operation and our target_frequency to - determine the value for the digital up converter. - """ - r = self.u.tune(self.subdev.which(), self.subdev, target_freq) - if r: - return True - - return False - - def set_gain(self, gain): - """ - Sets the analog gain in the USRP - """ - self.gain = gain - self.subdev.set_gain(gain) - - def set_auto_tr(self, enable): - """ - Turns on auto transmit/receive of USRP daughterboard (if exits; else ignored) - """ - return self.subdev.set_auto_tr(enable) - - def interp(self): - return self._interp - - def add_options(normal, expert): - """ - Adds usrp-specific options to the Options Parser - """ - add_freq_option(normal) - normal.add_option("-T", "--tx-subdev-spec", type="subdev", default=None, - help="select USRP Tx side A or B") - normal.add_option("-v", "--verbose", action="store_true", default=False) - - expert.add_option("", "--tx-freq", type="eng_float", default=None, - help="set transmit frequency to FREQ [default=%default]", metavar="FREQ") - expert.add_option("-i", "--interp", type="intx", default=256, - help="set fpga interpolation rate to INTERP [default=%default]") - # Make a static method to call before instantiation - add_options = staticmethod(add_options) - - def _print_verbage(self): - """ - Prints information about the transmit path - """ - print "Using TX d'board %s" % (self.subdev.side_and_name(),) - print "modulation: %s" % (self._modulator_class.__name__) - print "interp: %3d" % (self._interp) - print "Tx Frequency: %s" % (eng_notation.num_to_str(self._tx_freq)) - - -def add_freq_option(parser): - """ - Hackery that has the -f / --freq option set both tx_freq and rx_freq - """ - def freq_callback(option, opt_str, value, parser): - parser.values.rx_freq = value - parser.values.tx_freq = value - - if not parser.has_option('--freq'): - parser.add_option('-f', '--freq', type="eng_float", - action="callback", callback=freq_callback, - help="set Tx and/or Rx frequency to FREQ [default=%default]", - metavar="FREQ") - -# ///////////////////////////////////////////////////////////////////////////// -# main -# ///////////////////////////////////////////////////////////////////////////// - -def main(): - - def send_pkt(payload='', eof=False): - return tb.txpath.send_pkt(payload, eof) - - parser = OptionParser(option_class=eng_option, conflict_handler="resolve") - expert_grp = parser.add_option_group("Expert") - parser.add_option("-s", "--size", type="eng_float", default=400, - help="set packet size [default=%default]") - parser.add_option("-M", "--megabytes", type="eng_float", default=1.0, - help="set megabytes to transmit [default=%default]") - parser.add_option("","--discontinuous", action="store_true", default=False, - help="enable discontinuous mode") - - my_top_block.add_options(parser, expert_grp) - transmit_path.add_options(parser, expert_grp) - blks2.ofdm_mod.add_options(parser, expert_grp) - blks2.ofdm_demod.add_options(parser, expert_grp) - fusb_options.add_options(expert_grp) - - (options, args) = parser.parse_args () - - # build the graph - tb = my_top_block(options) - - r = gr.enable_realtime_scheduling() - if r != gr.RT_OK: - print "Warning: failed to enable realtime scheduling" - - tb.start() # start flow graph - - # generate and send packets - nbytes = int(1e6 * options.megabytes) - n = 0 - pktno = 0 - pkt_size = int(options.size) - - while n < nbytes: - send_pkt(struct.pack('!H', pktno) + (pkt_size - 2) * chr(pktno & 0xff)) - n += pkt_size - sys.stderr.write('.') - if options.discontinuous and pktno % 5 == 1: - time.sleep(1) - pktno += 1 - - send_pkt(eof=True) - tb.wait() # wait for it to finish - -if __name__ == '__main__': - try: - main() - except KeyboardInterrupt: - pass diff --git a/gnuradio-examples/python/ofdm/fftshift.py b/gnuradio-examples/python/ofdm/fftshift.py deleted file mode 100755 index 98abf5d4b..000000000 --- a/gnuradio-examples/python/ofdm/fftshift.py +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/env python - -from gnuradio import gr - -class my_top_block(gr.top_block): - def __init__(self): - gr.top_block.__init__(self) - - length = 101 - - data_r = range(length) - data_i = range(length,2*length) - src_r = gr.vector_source_s(data_r, False) - src_i = gr.vector_source_s(data_i, False) - s2f_r = gr.short_to_float() - s2f_i = gr.short_to_float() - f2c = gr.float_to_complex() - s2v = gr.stream_to_vector(gr.sizeof_gr_complex, length) - - shift = True - ifft = gr.fft_vcc(length, False, [], shift) - fft = gr.fft_vcc(length, True, [], shift) - - v2s = gr.vector_to_stream(gr.sizeof_gr_complex, length) - snk_in = gr.file_sink(gr.sizeof_gr_complex, "fftshift.in") - snk_out = gr.file_sink(gr.sizeof_gr_complex, "fftshift.out") - - self.connect(src_r, s2f_r, (f2c,0)) - self.connect(src_i, s2f_i, (f2c,1)) - self.connect(f2c, snk_in) - self.connect(f2c, s2v, ifft, fft, v2s, snk_out) - - -def main(): - tb = my_top_block() - tb.start() - tb.wait() - -if __name__ == "__main__": - try: - main() - except KeyboardInterrupt: - pass - diff --git a/gnuradio-examples/python/ofdm/fusb_options.py b/gnuradio-examples/python/ofdm/fusb_options.py deleted file mode 100644 index 153e06bea..000000000 --- a/gnuradio-examples/python/ofdm/fusb_options.py +++ /dev/null @@ -1,31 +0,0 @@ -# -# 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. -# - -def add_options(parser): - """ - Add Fast USB specifc options to command line parser. - - @param parser: instance of OptionParser - """ - parser.add_option("-B", "--fusb-block-size", type="int", default=0, - help="specify fast usb block size [default=%default]") - parser.add_option("-N", "--fusb-nblocks", type="int", default=0, - help="specify number of fast usb blocks [default=%default]") diff --git a/gnuradio-examples/python/ofdm/pick_bitrate.py b/gnuradio-examples/python/ofdm/pick_bitrate.py deleted file mode 100644 index 82a476888..000000000 --- a/gnuradio-examples/python/ofdm/pick_bitrate.py +++ /dev/null @@ -1,143 +0,0 @@ -# -# Copyright 2005,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. -# - -_default_bitrate = 500e3 - -_valid_samples_per_symbol = (2,3,4,5,6,7) - -def _gen_tx_info(converter_rate): - results = [] - for samples_per_symbol in _valid_samples_per_symbol: - for interp in range(16, 512 + 1, 4): - bitrate = converter_rate / interp / samples_per_symbol - results.append((bitrate, samples_per_symbol, interp)) - results.sort() - return results - -def _gen_rx_info(converter_rate): - results = [] - for samples_per_symbol in _valid_samples_per_symbol: - for decim in range(8, 256 + 1, 2): - bitrate = converter_rate / decim / samples_per_symbol - results.append((bitrate, samples_per_symbol, decim)) - results.sort() - return results - -def _filter_info(info, samples_per_symbol, xrate): - if samples_per_symbol is not None: - info = [x for x in info if x[1] == samples_per_symbol] - if xrate is not None: - info = [x for x in info if x[2] == xrate] - return info - -def _pick_best(target_bitrate, bits_per_symbol, info): - """ - @returns tuple (bitrate, samples_per_symbol, interp_rate_or_decim_rate) - """ - if len(info) == 0: - raise RuntimeError, "info is zero length!" - - if target_bitrate is None: # return the fastest one - return info[-1] - - # convert bit rate to symbol rate - target_symbolrate = target_bitrate / bits_per_symbol - - # Find the closest matching symbol rate. - # In the event of a tie, the one with the lowest samples_per_symbol wins. - # (We already sorted them, so the first one is the one we take) - - best = info[0] - best_delta = abs(target_symbolrate - best[0]) - for x in info[1:]: - delta = abs(target_symbolrate - x[0]) - if delta < best_delta: - best_delta = delta - best = x - - # convert symbol rate back to bit rate - return ((best[0] * bits_per_symbol),) + best[1:] - -def _pick_bitrate(bitrate, bits_per_symbol, samples_per_symbol, - xrate, converter_rate, gen_info): - """ - @returns tuple (bitrate, samples_per_symbol, interp_rate_or_decim_rate) - """ - if not isinstance(bits_per_symbol, int) or bits_per_symbol < 1: - raise ValueError, "bits_per_symbol must be an int >= 1" - - if samples_per_symbol is not None and xrate is not None: # completely determined - return (float(converter_rate) / xrate / samples_per_symbol, - samples_per_symbol, xrate) - - if bitrate is None and samples_per_symbol is None and xrate is None: - bitrate = _default_bitrate - - # now we have a target bitrate and possibly an xrate or - # samples_per_symbol constraint, but not both of them. - - return _pick_best(bitrate, bits_per_symbol, - _filter_info(gen_info(converter_rate), samples_per_symbol, xrate)) - -# --------------------------------------------------------------------------------------- - -def pick_tx_bitrate(bitrate, bits_per_symbol, samples_per_symbol, - interp_rate, converter_rate=128e6): - """ - Given the 4 input parameters, return at configuration that matches - - @param bitrate: desired bitrate or None - @type bitrate: number or None - @param bits_per_symbol: E.g., BPSK -> 1, QPSK -> 2, 8-PSK -> 3 - @type bits_per_symbol: integer >= 1 - @param samples_per_symbol: samples/baud (aka samples/symbol) - @type samples_per_symbol: number or None - @param interp_rate: USRP interpolation factor - @type interp_rate: integer or None - @param converter_rate: converter sample rate in Hz - @type converter_rate: number - - @returns tuple (bitrate, samples_per_symbol, interp_rate) - """ - return _pick_bitrate(bitrate, bits_per_symbol, samples_per_symbol, - interp_rate, converter_rate, _gen_tx_info) - - -def pick_rx_bitrate(bitrate, bits_per_symbol, samples_per_symbol, - decim_rate, converter_rate=64e6): - """ - Given the 4 input parameters, return at configuration that matches - - @param bitrate: desired bitrate or None - @type bitrate: number or None - @param bits_per_symbol: E.g., BPSK -> 1, QPSK -> 2, 8-PSK -> 3 - @type bits_per_symbol: integer >= 1 - @param samples_per_symbol: samples/baud (aka samples/symbol) - @type samples_per_symbol: number or None - @param decim_rate: USRP decimation factor - @type decim_rate: integer or None - @param converter_rate: converter sample rate in Hz - @type converter_rate: number - - @returns tuple (bitrate, samples_per_symbol, decim_rate) - """ - return _pick_bitrate(bitrate, bits_per_symbol, samples_per_symbol, - decim_rate, converter_rate, _gen_rx_info) diff --git a/gnuradio-examples/python/ofdm/tunnel.py b/gnuradio-examples/python/ofdm/tunnel.py deleted file mode 100755 index 7e75c3ee8..000000000 --- a/gnuradio-examples/python/ofdm/tunnel.py +++ /dev/null @@ -1,435 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2005,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 2, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along 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 code sets up up a virtual ethernet interface (typically gr0), -# and relays packets between the interface and the GNU Radio PHY+MAC -# -# What this means in plain language, is that if you've got a couple -# of USRPs on different machines, and if you run this code on those -# machines, you can talk between them using normal TCP/IP networking. -# -# ///////////////////////////////////////////////////////////////////////////// - - -from gnuradio import gr, gru, blks2 -from gnuradio import usrp -from gnuradio import eng_notation -from gnuradio.eng_option import eng_option -from optparse import OptionParser - -import random -import time -import struct -import sys -import os - -# from current dir -from transmit_path import transmit_path -from receive_path import receive_path -import fusb_options - -#print os.getpid() -#raw_input('Attach and press enter') - - -# ///////////////////////////////////////////////////////////////////////////// -# -# Use the Universal TUN/TAP device driver to move packets to/from kernel -# -# See /usr/src/linux/Documentation/networking/tuntap.txt -# -# ///////////////////////////////////////////////////////////////////////////// - -# Linux specific... -# TUNSETIFF ifr flags from <linux/tun_if.h> - -IFF_TUN = 0x0001 # tunnel IP packets -IFF_TAP = 0x0002 # tunnel ethernet frames -IFF_NO_PI = 0x1000 # don't pass extra packet info -IFF_ONE_QUEUE = 0x2000 # beats me ;) - -def open_tun_interface(tun_device_filename): - from fcntl import ioctl - - mode = IFF_TAP | IFF_NO_PI - TUNSETIFF = 0x400454ca - - tun = os.open(tun_device_filename, os.O_RDWR) - ifs = ioctl(tun, TUNSETIFF, struct.pack("16sH", "gr%d", mode)) - ifname = ifs[:16].strip("\x00") - return (tun, ifname) - - -# ///////////////////////////////////////////////////////////////////////////// -# the flow graph -# ///////////////////////////////////////////////////////////////////////////// - -class usrp_graph(gr.top_block): - def __init__(self, callback, options): - gr.top_block.__init__(self) - - self._tx_freq = options.tx_freq # tranmitter's center frequency - self._tx_subdev_spec = options.tx_subdev_spec # daughterboard to use - self._interp = options.interp # interpolating rate for the USRP (prelim) - self._rx_freq = options.rx_freq # receiver's center frequency - self._rx_gain = options.rx_gain # receiver's gain - self._rx_subdev_spec = options.rx_subdev_spec # daughterboard to use - self._decim = options.decim # Decimating rate for the USRP (prelim) - self._fusb_block_size = options.fusb_block_size # usb info for USRP - self._fusb_nblocks = options.fusb_nblocks # usb info for USRP - - if self._tx_freq is None: - sys.stderr.write("-f FREQ or --freq FREQ or --tx-freq FREQ must be specified\n") - raise SystemExit - - if self._rx_freq is None: - sys.stderr.write("-f FREQ or --freq FREQ or --rx-freq FREQ must be specified\n") - raise SystemExit - - # Set up USRP sink and source - self._setup_usrp_sink() - self._setup_usrp_source() - - # Set center frequency of USRP - ok = self.set_freq(self._tx_freq) - if not ok: - print "Failed to set Tx frequency to %s" % (eng_notation.num_to_str(self._tx_freq),) - raise ValueError - - # copy the final answers back into options for use by modulator - #options.bitrate = self._bitrate - - self.txpath = transmit_path(options) - self.rxpath = receive_path(callback, options) - - self.connect(self.txpath, self.u_snk) - self.connect(self.u_src, self.rxpath) - - def carrier_sensed(self): - """ - Return True if the receive path thinks there's carrier - """ - return self.rxpath.carrier_sensed() - - def _setup_usrp_sink(self): - """ - Creates a USRP sink, determines the settings for best bitrate, - and attaches to the transmitter's subdevice. - """ - self.u_snk = usrp.sink_c(fusb_block_size=self._fusb_block_size, - fusb_nblocks=self._fusb_nblocks) - - self.u_snk.set_interp_rate(self._interp) - - # determine the daughterboard subdevice we're using - if self._tx_subdev_spec is None: - self._tx_subdev_spec = usrp.pick_tx_subdevice(self.u_snk) - self.u_snk.set_mux(usrp.determine_tx_mux_value(self.u_snk, self._tx_subdev_spec)) - self.subdev = usrp.selected_subdev(self.u_snk, self._tx_subdev_spec) - - # Set the USRP for maximum transmit gain - # (Note that on the RFX cards this is a nop.) - self.set_gain(self.subdev.gain_range()[1]) - - # enable Auto Transmit/Receive switching - self.set_auto_tr(True) - - def _setup_usrp_source(self): - self.u_src = usrp.source_c (fusb_block_size=self._fusb_block_size, - fusb_nblocks=self._fusb_nblocks) - adc_rate = self.u_src.adc_rate() - - self.u_src.set_decim_rate(self._decim) - - # determine the daughterboard subdevice we're using - if self._rx_subdev_spec is None: - self._rx_subdev_spec = usrp.pick_rx_subdevice(self.u_src) - self.subdev = usrp.selected_subdev(self.u_src, self._rx_subdev_spec) - - self.u_src.set_mux(usrp.determine_rx_mux_value(self.u_src, self._rx_subdev_spec)) - - def set_freq(self, target_freq): - """ - Set the center frequency we're interested in. - - @param target_freq: frequency in Hz - @rypte: bool - - Tuning is a two step process. First we ask the front-end to - tune as close to the desired frequency as it can. Then we use - the result of that operation and our target_frequency to - determine the value for the digital up converter. - """ - r_snk = self.u_snk.tune(self.subdev.which(), self.subdev, target_freq) - r_src = self.u_src.tune(self.subdev.which(), self.subdev, target_freq) - if r_snk and r_src: - return True - - return False - - def set_gain(self, gain): - """ - Sets the analog gain in the USRP - """ - self.gain = gain - self.subdev.set_gain(gain) - - def set_auto_tr(self, enable): - """ - Turns on auto transmit/receive of USRP daughterboard (if exits; else ignored) - """ - return self.subdev.set_auto_tr(enable) - - def interp(self): - return self._interp - - def add_options(normal, expert): - """ - Adds usrp-specific options to the Options Parser - """ - add_freq_option(normal) - normal.add_option("-T", "--tx-subdev-spec", type="subdev", default=None, - help="select USRP Tx side A or B") - normal.add_option("-v", "--verbose", action="store_true", default=False) - - expert.add_option("", "--tx-freq", type="eng_float", default=None, - help="set transmit frequency to FREQ [default=%default]", metavar="FREQ") - expert.add_option("-i", "--interp", type="intx", default=256, - help="set fpga interpolation rate to INTERP [default=%default]") - normal.add_option("-R", "--rx-subdev-spec", type="subdev", default=None, - help="select USRP Rx side A or B") - normal.add_option("", "--rx-gain", type="eng_float", default=None, metavar="GAIN", - help="set receiver gain in dB [default=midpoint]. See also --show-rx-gain-range") - normal.add_option("", "--show-rx-gain-range", action="store_true", default=False, - help="print min and max Rx gain available on selected daughterboard") - normal.add_option("-v", "--verbose", action="store_true", default=False) - - expert.add_option("", "--rx-freq", type="eng_float", default=None, - help="set Rx frequency to FREQ [default=%default]", metavar="FREQ") - expert.add_option("-d", "--decim", type="intx", default=128, - help="set fpga decimation rate to DECIM [default=%default]") - expert.add_option("", "--snr", type="eng_float", default=30, - help="set the SNR of the channel in dB [default=%default]") - - # Make a static method to call before instantiation - add_options = staticmethod(add_options) - - def _print_verbage(self): - """ - Prints information about the transmit path - """ - print "Using TX d'board %s" % (self.subdev.side_and_name(),) - print "modulation: %s" % (self._modulator_class.__name__) - print "interp: %3d" % (self._interp) - print "Tx Frequency: %s" % (eng_notation.num_to_str(self._tx_freq)) - -def add_freq_option(parser): - """ - Hackery that has the -f / --freq option set both tx_freq and rx_freq - """ - def freq_callback(option, opt_str, value, parser): - parser.values.rx_freq = value - parser.values.tx_freq = value - - if not parser.has_option('--freq'): - parser.add_option('-f', '--freq', type="eng_float", - action="callback", callback=freq_callback, - help="set Tx and/or Rx frequency to FREQ [default=%default]", - metavar="FREQ") - - -# ///////////////////////////////////////////////////////////////////////////// -# Carrier Sense MAC -# ///////////////////////////////////////////////////////////////////////////// - -class cs_mac(object): - """ - Prototype carrier sense MAC - - Reads packets from the TUN/TAP interface, and sends them to the PHY. - Receives packets from the PHY via phy_rx_callback, and sends them - into the TUN/TAP interface. - - Of course, we're not restricted to getting packets via TUN/TAP, this - is just an example. - """ - def __init__(self, tun_fd, verbose=False): - self.tun_fd = tun_fd # file descriptor for TUN/TAP interface - self.verbose = verbose - self.tb = None # top block (access to PHY) - - def set_flow_graph(self, tb): - self.tb = tb - - def phy_rx_callback(self, ok, payload): - """ - Invoked by thread associated with PHY to pass received packet up. - - @param ok: bool indicating whether payload CRC was OK - @param payload: contents of the packet (string) - """ - if self.verbose: - print "Rx: ok = %r len(payload) = %4d" % (ok, len(payload)) - if ok: - os.write(self.tun_fd, payload) - - def main_loop(self): - """ - Main loop for MAC. - Only returns if we get an error reading from TUN. - - FIXME: may want to check for EINTR and EAGAIN and reissue read - """ - min_delay = 0.001 # seconds - - while 1: - payload = os.read(self.tun_fd, 10*1024) - if not payload: - self.tb.txpath.send_pkt(eof=True) - break - - if self.verbose: - print "Tx: len(payload) = %4d" % (len(payload),) - - delay = min_delay - while self.tb.carrier_sensed(): - sys.stderr.write('B') - time.sleep(delay) - if delay < 0.050: - delay = delay * 2 # exponential back-off - - self.tb.txpath.send_pkt(payload) - - -# ///////////////////////////////////////////////////////////////////////////// -# main -# ///////////////////////////////////////////////////////////////////////////// - -def main(): - - parser = OptionParser (option_class=eng_option, conflict_handler="resolve") - expert_grp = parser.add_option_group("Expert") - - parser.add_option("-m", "--modulation", type="choice", choices=['bpsk', 'qpsk'], - default='bpsk', - help="Select modulation from: bpsk, qpsk [default=%%default]") - - parser.add_option("-v","--verbose", action="store_true", default=False) - expert_grp.add_option("-c", "--carrier-threshold", type="eng_float", default=30, - help="set carrier detect threshold (dB) [default=%default]") - expert_grp.add_option("","--tun-device-filename", default="/dev/net/tun", - help="path to tun device file [default=%default]") - - usrp_graph.add_options(parser, expert_grp) - transmit_path.add_options(parser, expert_grp) - receive_path.add_options(parser, expert_grp) - blks2.ofdm_mod.add_options(parser, expert_grp) - blks2.ofdm_demod.add_options(parser, expert_grp) - - fusb_options.add_options(expert_grp) - - (options, args) = parser.parse_args () - if len(args) != 0: - parser.print_help(sys.stderr) - sys.exit(1) - - if options.rx_freq is None or options.tx_freq is None: - sys.stderr.write("You must specify -f FREQ or --freq FREQ\n") - parser.print_help(sys.stderr) - sys.exit(1) - - # open the TUN/TAP interface - (tun_fd, tun_ifname) = open_tun_interface(options.tun_device_filename) - - # Attempt to enable realtime scheduling - r = gr.enable_realtime_scheduling() - if r == gr.RT_OK: - realtime = True - else: - realtime = False - print "Note: failed to enable realtime scheduling" - - - # If the user hasn't set the fusb_* parameters on the command line, - # pick some values that will reduce latency. - - if options.fusb_block_size == 0 and options.fusb_nblocks == 0: - if realtime: # be more aggressive - options.fusb_block_size = gr.prefs().get_long('fusb', 'rt_block_size', 1024) - options.fusb_nblocks = gr.prefs().get_long('fusb', 'rt_nblocks', 16) - else: - options.fusb_block_size = gr.prefs().get_long('fusb', 'block_size', 4096) - options.fusb_nblocks = gr.prefs().get_long('fusb', 'nblocks', 16) - - #print "fusb_block_size =", options.fusb_block_size - #print "fusb_nblocks =", options.fusb_nblocks - - # instantiate the MAC - mac = cs_mac(tun_fd, verbose=True) - - - # build the graph (PHY) - tb = usrp_graph(mac.phy_rx_callback, options) - - mac.set_flow_graph(tb) # give the MAC a handle for the PHY - - #if fg.txpath.bitrate() != fg.rxpath.bitrate(): - # print "WARNING: Transmit bitrate = %sb/sec, Receive bitrate = %sb/sec" % ( - # eng_notation.num_to_str(fg.txpath.bitrate()), - # eng_notation.num_to_str(fg.rxpath.bitrate())) - - print "modulation: %s" % (options.modulation,) - print "freq: %s" % (eng_notation.num_to_str(options.tx_freq)) - #print "bitrate: %sb/sec" % (eng_notation.num_to_str(fg.txpath.bitrate()),) - #print "samples/symbol: %3d" % (fg.txpath.samples_per_symbol(),) - #print "interp: %3d" % (fg.txpath.interp(),) - #print "decim: %3d" % (fg.rxpath.decim(),) - - tb.rxpath.set_carrier_threshold(options.carrier_threshold) - print "Carrier sense threshold:", options.carrier_threshold, "dB" - - print - print "Allocated virtual ethernet interface: %s" % (tun_ifname,) - print "You must now use ifconfig to set its IP address. E.g.," - print - print " $ sudo ifconfig %s 192.168.200.1" % (tun_ifname,) - print - print "Be sure to use a different address in the same subnet for each machine." - print - - - tb.start() # Start executing the flow graph (runs in separate threads) - - mac.main_loop() # don't expect this to return... - - tb.stop() # but if it does, tell flow graph to stop. - tb.wait() # wait for it to finish - - -if __name__ == '__main__': - try: - main() - except KeyboardInterrupt: - pass diff --git a/gr-digital/examples/CMakeLists.txt b/gr-digital/examples/CMakeLists.txt index 9632c1638..2645557cc 100644 --- a/gr-digital/examples/CMakeLists.txt +++ b/gr-digital/examples/CMakeLists.txt @@ -20,18 +20,26 @@ include(GrPython) GR_PYTHON_INSTALL(PROGRAMS - transmit_path.py - receive_path.py - uhd_interface.py - benchmark_tx.py - benchmark_rx.py - tx_voice.py - rx_voice.py + example_costas.py + example_fll.py + example_timing.py run_length.py gen_whitener.py - digital_bert_rx.py - digital_bert_tx.py - tunnel.py DESTINATION ${GR_PKG_DATA_DIR}/examples/digital COMPONENT "digital_python" ) + +GR_PYTHON_INSTALL(PROGRAMS + narrowband/transmit_path.py + narrowband/receive_path.py + narrowband/uhd_interface.py + narrowband/benchmark_tx.py + narrowband/benchmark_rx.py + narrowband/tx_voice.py + narrowband/rx_voice.py + narrowband/digital_bert_rx.py + narrowband/digital_bert_tx.py + narrowband/tunnel.py + DESTINATION ${GR_PKG_DATA_DIR}/examples/digital/narrowband + COMPONENT "digital_python" +) diff --git a/gr-digital/examples/Makefile.am b/gr-digital/examples/Makefile.am index dc8aba6ca..3841bbd0e 100644 --- a/gr-digital/examples/Makefile.am +++ b/gr-digital/examples/Makefile.am @@ -21,24 +21,26 @@ include $(top_srcdir)/Makefile.common -ourdatadir = $(exampledir)/digital +dig_examples_prefix= $(exampledir)/digital -noinst_PYTHON = \ - example_costas.py \ - example_fll.py \ - example_timing.py +basicdatadir = $(dig_examples_prefix) +dist_basicdata_SCRIPTS = \ + example_costas.py \ + example_fll.py \ + example_timing.py \ + run_length.py \ + gen_whitener.py -dist_ourdata_SCRIPTS = \ - transmit_path.py \ - receive_path.py \ - uhd_interface.py \ - benchmark_tx.py \ - benchmark_rx.py \ - tx_voice.py \ - rx_voice.py \ - run_length.py \ - gen_whitener.py \ - digital_bert_rx.py \ - digital_bert_tx.py \ - tunnel.py +nbdatadir = $(dig_examples_prefix)/narrowband +dist_nbdata_SCRIPTS = \ + narrowband/transmit_path.py \ + narrowband/receive_path.py \ + narrowband/uhd_interface.py \ + narrowband/benchmark_tx.py \ + narrowband/benchmark_rx.py \ + narrowband/tx_voice.py \ + narrowband/rx_voice.py \ + narrowband/digital_bert_rx.py \ + narrowband/digital_bert_tx.py \ + narrowband/tunnel.py diff --git a/gr-digital/examples/benchmark_add_channel.py b/gr-digital/examples/narrowband/benchmark_add_channel.py index def1f8267..841833a08 100755 --- a/gr-digital/examples/benchmark_add_channel.py +++ b/gr-digital/examples/narrowband/benchmark_add_channel.py @@ -37,11 +37,9 @@ class my_top_block(gr.top_block): phase_offset = options.phase_offset*(math.pi/180.0) # calculate noise voltage from SNR - # FIXME: normalize to signal amplitude - power_in_signal = abs(1.0)**2 + power_in_signal = abs(options.tx_amplitude)**2 noise_power = power_in_signal/SNR noise_voltage = math.sqrt(noise_power) - print noise_voltage self.src = gr.file_source(gr.sizeof_gr_complex, ifile) #self.throttle = gr.throttle(gr.sizeof_gr_complex, options.sample_rate) @@ -74,6 +72,9 @@ def main(): help="set phase offset (in degrees) between Tx and Rx [default=%default]") parser.add_option("-m", "--use-multipath", action="store_true", default=False, help="Use a multipath channel [default=%default]") + parser.add_option("", "--tx-amplitude", type="eng_float", + default=1.0, + help="tell the simulator the signal amplitude [default=%default]") (options, args) = parser.parse_args () diff --git a/gr-digital/examples/benchmark_rx.py b/gr-digital/examples/narrowband/benchmark_rx.py index c586cc8fe..65aac3638 100755 --- a/gr-digital/examples/benchmark_rx.py +++ b/gr-digital/examples/narrowband/benchmark_rx.py @@ -32,7 +32,6 @@ from gnuradio import digital from receive_path import receive_path from uhd_interface import uhd_receiver -import random import struct import sys @@ -52,8 +51,10 @@ class my_top_block(gr.top_block): options.samples_per_symbol = self.source._sps elif(options.from_file is not None): + sys.stderr.write(("Reading samples from '%s'.\n\n" % (options.from_file))) self.source = gr.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) # Set up receive path @@ -86,7 +87,7 @@ def main(): print "ok = %5s pktno = %4d n_rcvd = %4d n_right = %4d" % ( ok, pktno, n_rcvd, n_right) - demods = digital.modulation_utils2.type_1_demods() + demods = digital.modulation_utils.type_1_demods() # Create Options Parser: parser = OptionParser (option_class=eng_option, conflict_handler="resolve") diff --git a/gr-digital/examples/benchmark_tx.py b/gr-digital/examples/narrowband/benchmark_tx.py index a4396dd98..1fd881981 100755 --- a/gr-digital/examples/benchmark_tx.py +++ b/gr-digital/examples/narrowband/benchmark_tx.py @@ -32,7 +32,7 @@ from gnuradio import digital from transmit_path import transmit_path from uhd_interface import uhd_transmitter -import random, time, struct, sys +import time, struct, sys #import os #print os.getpid() @@ -50,8 +50,10 @@ class my_top_block(gr.top_block): options.samples_per_symbol = self.sink._sps elif(options.to_file is not None): + sys.stderr.write(("Saving samples to '%s'.\n\n" % (options.to_file))) self.sink = gr.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) # do this after for any adjustments to the options that may @@ -69,10 +71,7 @@ def main(): def send_pkt(payload='', eof=False): return tb.txpath.send_pkt(payload, eof) - def rx_callback(ok, payload): - print "ok = %r, payload = '%s'" % (ok, payload) - - mods = digital.modulation_utils2.type_1_mods() + mods = digital.modulation_utils.type_1_mods() parser = OptionParser(option_class=eng_option, conflict_handler="resolve") expert_grp = parser.add_option_group("Expert") diff --git a/gr-digital/examples/digital_bert_rx.py b/gr-digital/examples/narrowband/digital_bert_rx.py index 9ee1f5ee8..9878f55e1 100755 --- a/gr-digital/examples/digital_bert_rx.py +++ b/gr-digital/examples/narrowband/digital_bert_rx.py @@ -178,7 +178,7 @@ def get_options(demods): uhd_receiver.add_options(parser) - demods = digital.modulation_utils2.type_1_demods() + demods = digital.modulation_utils.type_1_demods() for mod in demods.values(): mod.add_options(parser) @@ -191,7 +191,7 @@ def get_options(demods): if __name__ == "__main__": - demods = digital.modulation_utils2.type_1_demods() + demods = digital.modulation_utils.type_1_demods() (options, args) = get_options(demods) diff --git a/gr-digital/examples/digital_bert_tx.py b/gr-digital/examples/narrowband/digital_bert_tx.py index 6b544c7f7..96cb338fe 100755 --- a/gr-digital/examples/digital_bert_tx.py +++ b/gr-digital/examples/narrowband/digital_bert_tx.py @@ -122,7 +122,7 @@ def get_options(mods): return (options, args) if __name__ == "__main__": - mods = digital.modulation_utils2.type_1_mods() + mods = digital.modulation_utils.type_1_mods() (options, args) = get_options(mods) diff --git a/gr-digital/examples/receive_path.py b/gr-digital/examples/narrowband/receive_path.py index 1c5e58963..1c5e58963 100644 --- a/gr-digital/examples/receive_path.py +++ b/gr-digital/examples/narrowband/receive_path.py diff --git a/gr-digital/examples/rx_voice.py b/gr-digital/examples/narrowband/rx_voice.py index b58704e16..42d7b893b 100755 --- a/gr-digital/examples/rx_voice.py +++ b/gr-digital/examples/narrowband/rx_voice.py @@ -114,7 +114,7 @@ def main(): print "ok = %r n_rcvd = %4d n_right = %4d" % ( ok, n_rcvd, n_right) - demods = digital.modulation_utils2.type_1_demods() + demods = digital.modulation_utils.type_1_demods() # Create Options Parser: parser = OptionParser (option_class=eng_option, conflict_handler="resolve") diff --git a/gr-digital/examples/transmit_path.py b/gr-digital/examples/narrowband/transmit_path.py index 3af37f330..4d6162ed6 100644 --- a/gr-digital/examples/transmit_path.py +++ b/gr-digital/examples/narrowband/transmit_path.py @@ -19,7 +19,7 @@ # Boston, MA 02110-1301, USA. # -from gnuradio import gr, gru +from gnuradio import gr from gnuradio import eng_notation from gnuradio import digital @@ -96,15 +96,20 @@ class transmit_path(gr.hier_block2): Adds transmitter-specific options to the Options Parser """ if not normal.has_option('--bitrate'): - normal.add_option("-r", "--bitrate", type="eng_float", default=100e3, + normal.add_option("-r", "--bitrate", type="eng_float", + default=100e3, help="specify bitrate [default=%default].") - normal.add_option("", "--tx-amplitude", type="eng_float", default=0.250, metavar="AMPL", + normal.add_option("", "--tx-amplitude", type="eng_float", + default=0.250, metavar="AMPL", help="set transmitter digital amplitude: 0 <= AMPL < 1 [default=%default]") - normal.add_option("-v", "--verbose", action="store_true", default=False) + normal.add_option("-v", "--verbose", action="store_true", + default=False) - expert.add_option("-S", "--samples-per-symbol", type="float", default=2, + expert.add_option("-S", "--samples-per-symbol", type="float", + default=2, help="set samples/symbol [default=%default]") - expert.add_option("", "--log", action="store_true", default=False, + expert.add_option("", "--log", action="store_true", + default=False, help="Log all parts of flow graph to file (CAUTION: lots of data)") # Make a static method to call before instantiation @@ -117,5 +122,5 @@ class transmit_path(gr.hier_block2): print "Tx amplitude %s" % (self._tx_amplitude) print "modulation: %s" % (self._modulator_class.__name__) print "bitrate: %sb/s" % (eng_notation.num_to_str(self._bitrate)) - print "samples/symbol: %.4f" % (self.samples_per_symbol()) + print "samples/symbol: %.4f" % (self.samples_per_symbol()) print "Differential: %s" % (self.differential()) diff --git a/gr-digital/examples/tunnel.py b/gr-digital/examples/narrowband/tunnel.py index d25594df5..7f40bb1c3 100755 --- a/gr-digital/examples/tunnel.py +++ b/gr-digital/examples/narrowband/tunnel.py @@ -35,7 +35,7 @@ # //////////////////////////////////////////////////////////////////// -from gnuradio import gr, digital, uhd +from gnuradio import gr, digital from gnuradio import eng_notation from gnuradio.eng_option import eng_option from optparse import OptionParser @@ -118,6 +118,14 @@ class my_top_block(gr.top_block): """ return self.rxpath.carrier_sensed() + def set_freq(self, target_freq): + """ + Set the center frequency we're interested in. + """ + + self.sink.set_freq(target_freq) + self.source.set_freq(target_freq) + # //////////////////////////////////////////////////////////////////// # Carrier Sense MAC @@ -189,8 +197,8 @@ class cs_mac(object): def main(): - mods = digital.modulation_utils2.type_1_mods() - demods = digital.modulation_utils2.type_1_demods() + mods = digital.modulation_utils.type_1_mods() + demods = digital.modulation_utils.type_1_demods() parser = OptionParser (option_class=eng_option, conflict_handler="resolve") expert_grp = parser.add_option_group("Expert") diff --git a/gr-digital/examples/tx_voice.py b/gr-digital/examples/narrowband/tx_voice.py index eabb5e3c3..3d767a077 100755 --- a/gr-digital/examples/tx_voice.py +++ b/gr-digital/examples/narrowband/tx_voice.py @@ -102,7 +102,7 @@ def main(): def rx_callback(ok, payload): print "ok = %r, payload = '%s'" % (ok, payload) - mods = digital.modulation_utils2.type_1_mods() + mods = digital.modulation_utils.type_1_mods() parser = OptionParser(option_class=eng_option, conflict_handler="resolve") expert_grp = parser.add_option_group("Expert") diff --git a/gr-digital/examples/uhd_interface.py b/gr-digital/examples/narrowband/uhd_interface.py index 8420f3eec..8420f3eec 100644 --- a/gr-digital/examples/uhd_interface.py +++ b/gr-digital/examples/narrowband/uhd_interface.py diff --git a/gr-digital/examples/ofdm/benchmark_add_channel.py b/gr-digital/examples/ofdm/benchmark_add_channel.py new file mode 100755 index 000000000..01776d209 --- /dev/null +++ b/gr-digital/examples/ofdm/benchmark_add_channel.py @@ -0,0 +1,110 @@ +#!/usr/bin/env python +# +# 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. +# + +from gnuradio import gr +from gnuradio import eng_notation +from gnuradio.eng_option import eng_option +from optparse import OptionParser + +import random, math, sys + +class my_top_block(gr.top_block): + def __init__(self, ifile, ofile, options): + gr.top_block.__init__(self) + + SNR = 10.0**(options.snr/10.0) + time_offset = options.time_offset + phase_offset = options.phase_offset*(math.pi/180.0) + + # calculate noise voltage from SNR + power_in_signal = abs(options.tx_amplitude)**2 + noise_power = power_in_signal/SNR + noise_voltage = math.sqrt(noise_power) + print "Noise voltage: ", noise_voltage + + frequency_offset = options.frequency_offset / options.fft_length + + self.src = gr.file_source(gr.sizeof_gr_complex, ifile) + #self.throttle = gr.throttle(gr.sizeof_gr_complex, options.sample_rate) + self.channel = gr.channel_model(noise_voltage, frequency_offset, + time_offset, noise_seed=random.randint(0,100000)) + self.phase = gr.multiply_const_cc(complex(math.cos(phase_offset), + math.sin(phase_offset))) + self.snk = gr.file_sink(gr.sizeof_gr_complex, ofile) + + self.connect(self.src, self.channel, self.phase, self.snk) + + +# ///////////////////////////////////////////////////////////////////////////// +# main +# ///////////////////////////////////////////////////////////////////////////// + +def main(): + # Create Options Parser: + usage = "benchmack_add_channel.py [options] <input file> <output file>" + parser = OptionParser (usage=usage, option_class=eng_option, conflict_handler="resolve") + parser.add_option("-n", "--snr", type="eng_float", default=30, + help="set the SNR of the channel in dB [default=%default]") + parser.add_option("", "--seed", action="store_true", default=False, + help="use a random seed for AWGN noise [default=%default]") + parser.add_option("-f", "--frequency-offset", type="eng_float", default=0, + help="set frequency offset introduced by channel [default=%default]") + parser.add_option("-t", "--time-offset", type="eng_float", default=1.0, + help="set timing offset between Tx and Rx [default=%default]") + parser.add_option("-p", "--phase-offset", type="eng_float", default=0, + help="set phase offset (in degrees) between Tx and Rx [default=%default]") + parser.add_option("-m", "--use-multipath", action="store_true", default=False, + help="Use a multipath channel [default=%default]") + parser.add_option("", "--fft-length", type="intx", default=None, + help="set the number of FFT bins [default=%default]") + parser.add_option("", "--tx-amplitude", type="eng_float", + default=1.0, + help="tell the simulator the signal amplitude [default=%default]") + + (options, args) = parser.parse_args () + + if len(args) != 2: + parser.print_help(sys.stderr) + sys.exit(1) + + if options.fft_length is None: + sys.stderr.write("Please enter the FFT length of the OFDM signal.\n") + sys.exit(1) + + ifile = args[0] + ofile = args[1] + + # build the graph + tb = my_top_block(ifile, ofile, options) + + r = gr.enable_realtime_scheduling() + if r != gr.RT_OK: + print "Warning: Failed to enable realtime scheduling." + + tb.start() # start flow graph + tb.wait() # wait for it to finish + +if __name__ == '__main__': + try: + main() + except KeyboardInterrupt: + pass diff --git a/gr-digital/examples/ofdm/benchmark_rx.py b/gr-digital/examples/ofdm/benchmark_rx.py new file mode 100755 index 000000000..f2ed3b8ff --- /dev/null +++ b/gr-digital/examples/ofdm/benchmark_rx.py @@ -0,0 +1,122 @@ +#!/usr/bin/env python +# +# Copyright 2006,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. +# + +from gnuradio import gr, blks2 +from gnuradio import eng_notation +from gnuradio.eng_option import eng_option +from optparse import OptionParser + +from gnuradio import digital + +# from current dir +from receive_path import receive_path +from uhd_interface import uhd_receiver + +import struct, sys + +class my_top_block(gr.top_block): + def __init__(self, callback, options): + gr.top_block.__init__(self) + + if(options.rx_freq is not None): + self.source = uhd_receiver(options.address, + options.bandwidth, + options.rx_freq, options.rx_gain, + options.antenna, options.verbose) + elif(options.from_file is not None): + self.source = gr.file_source(gr.sizeof_gr_complex, options.from_file) + else: + self.source = gr.null_source(gr.sizeof_gr_complex) + + # Set up receive path + # do this after for any adjustments to the options that may + # occur in the sinks (specifically the UHD sink) + self.rxpath = receive_path(callback, options) + + self.connect(self.source, self.rxpath) + + +# ///////////////////////////////////////////////////////////////////////////// +# main +# ///////////////////////////////////////////////////////////////////////////// + +def main(): + + global n_rcvd, n_right + + n_rcvd = 0 + n_right = 0 + + def rx_callback(ok, payload): + global n_rcvd, n_right + n_rcvd += 1 + (pktno,) = struct.unpack('!H', payload[0:2]) + if ok: + n_right += 1 + print "ok: %r \t pktno: %d \t n_rcvd: %d \t n_right: %d" % (ok, pktno, n_rcvd, n_right) + + if 0: + printlst = list() + for x in payload[2:]: + t = hex(ord(x)).replace('0x', '') + if(len(t) == 1): + t = '0' + t + printlst.append(t) + printable = ''.join(printlst) + + print printable + print "\n" + + parser = OptionParser(option_class=eng_option, conflict_handler="resolve") + expert_grp = parser.add_option_group("Expert") + parser.add_option("","--discontinuous", action="store_true", default=False, + help="enable discontinuous") + parser.add_option("","--from-file", default=None, + help="input file of samples to demod") + + receive_path.add_options(parser, expert_grp) + uhd_receiver.add_options(parser) + digital.ofdm_demod.add_options(parser, expert_grp) + + (options, args) = parser.parse_args () + + if options.from_file is None: + if options.rx_freq is None: + sys.stderr.write("You must specify -f FREQ or --freq FREQ\n") + parser.print_help(sys.stderr) + sys.exit(1) + + # build the graph + tb = my_top_block(rx_callback, options) + + r = gr.enable_realtime_scheduling() + if r != gr.RT_OK: + print "Warning: failed to enable realtime scheduling" + + tb.start() # start flow graph + tb.wait() # wait for it to finish + +if __name__ == '__main__': + try: + main() + except KeyboardInterrupt: + pass diff --git a/gr-digital/examples/ofdm/benchmark_tx.py b/gr-digital/examples/ofdm/benchmark_tx.py new file mode 100755 index 000000000..ad3609b52 --- /dev/null +++ b/gr-digital/examples/ofdm/benchmark_tx.py @@ -0,0 +1,121 @@ +#!/usr/bin/env python +# +# Copyright 2005,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. +# + +from gnuradio import gr +from gnuradio import eng_notation +from gnuradio.eng_option import eng_option +from optparse import OptionParser +import time, struct, sys + +from gnuradio import digital + +# from current dir +from transmit_path import transmit_path +from uhd_interface import uhd_transmitter + +class my_top_block(gr.top_block): + def __init__(self, options): + gr.top_block.__init__(self) + + if(options.tx_freq is not None): + self.sink = uhd_transmitter(options.address, + options.bandwidth, + options.tx_freq, options.tx_gain, + options.antenna, options.verbose) + elif(options.to_file is not None): + self.sink = gr.file_sink(gr.sizeof_gr_complex, options.to_file) + else: + self.sink = gr.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) + self.txpath = transmit_path(options) + + self.connect(self.txpath, self.sink) + +# ///////////////////////////////////////////////////////////////////////////// +# main +# ///////////////////////////////////////////////////////////////////////////// + +def main(): + + def send_pkt(payload='', eof=False): + return tb.txpath.send_pkt(payload, eof) + + parser = OptionParser(option_class=eng_option, conflict_handler="resolve") + expert_grp = parser.add_option_group("Expert") + parser.add_option("-s", "--size", type="eng_float", default=400, + help="set packet size [default=%default]") + parser.add_option("-M", "--megabytes", type="eng_float", default=1.0, + help="set megabytes to transmit [default=%default]") + parser.add_option("","--discontinuous", action="store_true", default=False, + help="enable discontinuous mode") + parser.add_option("","--from-file", default=None, + help="use intput file for packet contents") + parser.add_option("","--to-file", default=None, + help="Output file for modulated samples") + + transmit_path.add_options(parser, expert_grp) + digital.ofdm_mod.add_options(parser, expert_grp) + uhd_transmitter.add_options(parser) + + (options, args) = parser.parse_args () + + # build the graph + tb = my_top_block(options) + + r = gr.enable_realtime_scheduling() + if r != gr.RT_OK: + print "Warning: failed to enable realtime scheduling" + + tb.start() # start flow graph + + # generate and send packets + nbytes = int(1e6 * options.megabytes) + n = 0 + pktno = 0 + pkt_size = int(options.size) + + while n < nbytes: + if options.from_file is None: + data = (pkt_size - 2) * chr(pktno & 0xff) + else: + data = source_file.read(pkt_size - 2) + if data == '': + break; + + payload = struct.pack('!H', pktno & 0xffff) + data + send_pkt(payload) + n += len(payload) + sys.stderr.write('.') + if options.discontinuous and pktno % 5 == 4: + time.sleep(1) + pktno += 1 + + send_pkt(eof=True) + tb.wait() # wait for it to finish + +if __name__ == '__main__': + try: + main() + except KeyboardInterrupt: + pass diff --git a/gnuradio-examples/python/ofdm/gr_plot_ofdm.py b/gr-digital/examples/ofdm/gr_plot_ofdm.py index b24855148..b24855148 100755 --- a/gnuradio-examples/python/ofdm/gr_plot_ofdm.py +++ b/gr-digital/examples/ofdm/gr_plot_ofdm.py diff --git a/gnuradio-examples/python/ofdm/ofdm_mod_demod_test.py b/gr-digital/examples/ofdm/ofdm_mod_demod_test.py index b1521da6d..b1521da6d 100755 --- a/gnuradio-examples/python/ofdm/ofdm_mod_demod_test.py +++ b/gr-digital/examples/ofdm/ofdm_mod_demod_test.py diff --git a/gnuradio-examples/python/ofdm/ofdm_sync.m b/gr-digital/examples/ofdm/ofdm_sync.m index d5df42137..d5df42137 100644 --- a/gnuradio-examples/python/ofdm/ofdm_sync.m +++ b/gr-digital/examples/ofdm/ofdm_sync.m diff --git a/gnuradio-examples/python/ofdm/ofdm_sync_pn.m b/gr-digital/examples/ofdm/ofdm_sync_pn.m index d93c0ca92..d93c0ca92 100644 --- a/gnuradio-examples/python/ofdm/ofdm_sync_pn.m +++ b/gr-digital/examples/ofdm/ofdm_sync_pn.m diff --git a/gnuradio-examples/python/ofdm/plot_ofdm.m b/gr-digital/examples/ofdm/plot_ofdm.m index 2a649b5f5..2a649b5f5 100755 --- a/gnuradio-examples/python/ofdm/plot_ofdm.m +++ b/gr-digital/examples/ofdm/plot_ofdm.m diff --git a/gnuradio-examples/python/ofdm/receive_path.py b/gr-digital/examples/ofdm/receive_path.py index b758bc4d0..e1c7868a0 100644 --- a/gnuradio-examples/python/ofdm/receive_path.py +++ b/gr-digital/examples/ofdm/receive_path.py @@ -1,6 +1,5 @@ -#!/usr/bin/env python # -# Copyright 2005,2006 Free Software Foundation, Inc. +# Copyright 2005,2006,2011 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -20,15 +19,13 @@ # Boston, MA 02110-1301, USA. # -from gnuradio import gr, gru, blks2 -from gnuradio import usrp +from gnuradio import gr from gnuradio import eng_notation +from gnuradio import digital + import copy import sys -# from current dir -from pick_bitrate import pick_rx_bitrate - # ///////////////////////////////////////////////////////////////////////////// # receive path # ///////////////////////////////////////////////////////////////////////////// @@ -37,8 +34,8 @@ class receive_path(gr.hier_block2): def __init__(self, rx_callback, options): gr.hier_block2.__init__(self, "receive_path", - gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature - gr.io_signature(0, 0, 0)) # Output signature + gr.io_signature(1, 1, gr.sizeof_gr_complex), + gr.io_signature(0, 0, 0)) options = copy.copy(options) # make a copy so we can destructively modify @@ -48,8 +45,8 @@ class receive_path(gr.hier_block2): self._rx_callback = rx_callback # this callback is fired when there's a packet available # receiver - self.ofdm_rx = \ - blks2.ofdm_demod(options, callback=self._rx_callback) + self.ofdm_rx = digital.ofdm_demod(options, + callback=self._rx_callback) # Carrier Sensing Blocks alpha = 0.001 @@ -90,6 +87,9 @@ class receive_path(gr.hier_block2): """ Adds receiver-specific options to the Options Parser """ + normal.add_option("-W", "--bandwidth", type="eng_float", + default=500e3, + help="set symbol bandwidth [default=%default]") normal.add_option("-v", "--verbose", action="store_true", default=False) expert.add_option("", "--log", action="store_true", default=False, help="Log all parts of flow graph to files (CAUTION: lots of data)") diff --git a/gnuradio-examples/python/ofdm/transmit_path.py b/gr-digital/examples/ofdm/transmit_path.py index 44c7331b0..ec357d617 100644 --- a/gnuradio-examples/python/ofdm/transmit_path.py +++ b/gr-digital/examples/ofdm/transmit_path.py @@ -1,5 +1,5 @@ # -# Copyright 2005,2006 Free Software Foundation, Inc. +# Copyright 2005,2006,2011 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -19,9 +19,9 @@ # Boston, MA 02110-1301, USA. # -from gnuradio import gr, gru, blks2 -from gnuradio import usrp +from gnuradio import gr from gnuradio import eng_notation +from gnuradio import digital import copy import sys @@ -37,16 +37,17 @@ class transmit_path(gr.hier_block2): ''' gr.hier_block2.__init__(self, "transmit_path", - gr.io_signature(0, 0, 0), # Input signature - gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature + gr.io_signature(0, 0, 0), + gr.io_signature(1, 1, gr.sizeof_gr_complex)) options = copy.copy(options) # make a copy so we can destructively modify - self._verbose = options.verbose # turn verbose mode on/off - self._tx_amplitude = options.tx_amplitude # digital amplitude sent to USRP + self._verbose = options.verbose # turn verbose mode on/off + self._tx_amplitude = options.tx_amplitude # digital amp sent to radio - self.ofdm_tx = \ - blks2.ofdm_mod(options, msgq_limit=4, pad_for_usrp=False) + self.ofdm_tx = digital.ofdm_mod(options, + msgq_limit=4, + pad_for_usrp=False) self.amp = gr.multiply_const_cc(1) self.set_tx_amplitude(self._tx_amplitude) @@ -61,9 +62,9 @@ class transmit_path(gr.hier_block2): def set_tx_amplitude(self, ampl): """ Sets the transmit amplitude sent to the USRP - @param: ampl 0 <= ampl < 32768. Try 8000 + @param: ampl 0 <= ampl < 1.0. Try 0.10 """ - self._tx_amplitude = max(0.0, min(ampl, 32767.0)) + self._tx_amplitude = max(0.0, min(ampl, 1)) self.amp.set_k(self._tx_amplitude) def send_pkt(self, payload='', eof=False): @@ -76,10 +77,16 @@ class transmit_path(gr.hier_block2): """ Adds transmitter-specific options to the Options Parser """ - normal.add_option("", "--tx-amplitude", type="eng_float", default=200, metavar="AMPL", - help="set transmitter digital amplitude: 0 <= AMPL < 32768 [default=%default]") - normal.add_option("-v", "--verbose", action="store_true", default=False) - expert.add_option("", "--log", action="store_true", default=False, + normal.add_option("", "--tx-amplitude", type="eng_float", + default=0.1, metavar="AMPL", + help="set transmitter digital amplitude: 0 <= AMPL < 1.0 [default=%default]") + normal.add_option("-W", "--bandwidth", type="eng_float", + default=500e3, + help="set symbol bandwidth [default=%default]") + normal.add_option("-v", "--verbose", action="store_true", + default=False) + expert.add_option("", "--log", action="store_true", + default=False, help="Log all parts of flow graph to file (CAUTION: lots of data)") # Make a static method to call before instantiation @@ -89,5 +96,5 @@ class transmit_path(gr.hier_block2): """ Prints information about the transmit path """ - print "Tx amplitude %s" % (self._tx_amplitude) + print "Tx amplitude %s" % (self._tx_amplitude) diff --git a/gr-digital/examples/ofdm/tunnel.py b/gr-digital/examples/ofdm/tunnel.py new file mode 100755 index 000000000..74f2667fa --- /dev/null +++ b/gr-digital/examples/ofdm/tunnel.py @@ -0,0 +1,267 @@ +#!/usr/bin/env python +# +# Copyright 2005,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 2, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along 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 code sets up up a virtual ethernet interface (typically gr0), +# and relays packets between the interface and the GNU Radio PHY+MAC +# +# What this means in plain language, is that if you've got a couple +# of USRPs on different machines, and if you run this code on those +# machines, you can talk between them using normal TCP/IP networking. +# +# ///////////////////////////////////////////////////////////////////////////// + + +from gnuradio import gr, digital +from gnuradio import eng_notation +from gnuradio.eng_option import eng_option +from optparse import OptionParser + +# from current dir +from receive_path import receive_path +from transmit_path import transmit_path +from uhd_interface import uhd_transmitter +from uhd_interface import uhd_receiver + +import os, sys +import random, time, struct + +#print os.getpid() +#raw_input('Attach and press enter') + + +# ///////////////////////////////////////////////////////////////////////////// +# +# Use the Universal TUN/TAP device driver to move packets to/from kernel +# +# See /usr/src/linux/Documentation/networking/tuntap.txt +# +# ///////////////////////////////////////////////////////////////////////////// + +# Linux specific... +# TUNSETIFF ifr flags from <linux/tun_if.h> + +IFF_TUN = 0x0001 # tunnel IP packets +IFF_TAP = 0x0002 # tunnel ethernet frames +IFF_NO_PI = 0x1000 # don't pass extra packet info +IFF_ONE_QUEUE = 0x2000 # beats me ;) + +def open_tun_interface(tun_device_filename): + from fcntl import ioctl + + mode = IFF_TAP | IFF_NO_PI + TUNSETIFF = 0x400454ca + + tun = os.open(tun_device_filename, os.O_RDWR) + ifs = ioctl(tun, TUNSETIFF, struct.pack("16sH", "gr%d", mode)) + ifname = ifs[:16].strip("\x00") + return (tun, ifname) + + +# ///////////////////////////////////////////////////////////////////////////// +# the flow graph +# ///////////////////////////////////////////////////////////////////////////// + +class my_top_block(gr.top_block): + def __init__(self, callback, options): + gr.top_block.__init__(self) + + self.source = uhd_receiver(options.address, + options.bandwidth, + options.rx_freq, options.rx_gain, + options.antenna, options.verbose) + + self.sink = uhd_transmitter(options.address, + options.bandwidth, + options.tx_freq, options.tx_gain, + options.antenna, options.verbose) + + self.txpath = transmit_path(options) + self.rxpath = receive_path(callback, options) + + self.connect(self.txpath, self.sink) + self.connect(self.source, self.rxpath) + + def carrier_sensed(self): + """ + Return True if the receive path thinks there's carrier + """ + return self.rxpath.carrier_sensed() + + def set_freq(self, target_freq): + """ + Set the center frequency we're interested in. + """ + self.u_snk.set_freq(target_freq) + self.u_src.set_freq(target_freq) + + +# ///////////////////////////////////////////////////////////////////////////// +# Carrier Sense MAC +# ///////////////////////////////////////////////////////////////////////////// + +class cs_mac(object): + """ + Prototype carrier sense MAC + + Reads packets from the TUN/TAP interface, and sends them to the PHY. + Receives packets from the PHY via phy_rx_callback, and sends them + into the TUN/TAP interface. + + Of course, we're not restricted to getting packets via TUN/TAP, this + is just an example. + """ + def __init__(self, tun_fd, verbose=False): + self.tun_fd = tun_fd # file descriptor for TUN/TAP interface + self.verbose = verbose + self.tb = None # top block (access to PHY) + + def set_flow_graph(self, tb): + self.tb = tb + + def phy_rx_callback(self, ok, payload): + """ + Invoked by thread associated with PHY to pass received packet up. + + @param ok: bool indicating whether payload CRC was OK + @param payload: contents of the packet (string) + """ + if self.verbose: + print "Rx: ok = %r len(payload) = %4d" % (ok, len(payload)) + if ok: + os.write(self.tun_fd, payload) + + def main_loop(self): + """ + Main loop for MAC. + Only returns if we get an error reading from TUN. + + FIXME: may want to check for EINTR and EAGAIN and reissue read + """ + min_delay = 0.001 # seconds + + while 1: + payload = os.read(self.tun_fd, 10*1024) + if not payload: + self.tb.txpath.send_pkt(eof=True) + break + + if self.verbose: + print "Tx: len(payload) = %4d" % (len(payload),) + + delay = min_delay + while self.tb.carrier_sensed(): + sys.stderr.write('B') + time.sleep(delay) + if delay < 0.050: + delay = delay * 2 # exponential back-off + + self.tb.txpath.send_pkt(payload) + + +# ///////////////////////////////////////////////////////////////////////////// +# main +# ///////////////////////////////////////////////////////////////////////////// + +def main(): + + parser = OptionParser (option_class=eng_option, conflict_handler="resolve") + expert_grp = parser.add_option_group("Expert") + + parser.add_option("-m", "--modulation", type="choice", choices=['bpsk', 'qpsk'], + default='bpsk', + help="Select modulation from: bpsk, qpsk [default=%%default]") + + parser.add_option("-v","--verbose", action="store_true", default=False) + expert_grp.add_option("-c", "--carrier-threshold", type="eng_float", default=30, + help="set carrier detect threshold (dB) [default=%default]") + expert_grp.add_option("","--tun-device-filename", default="/dev/net/tun", + help="path to tun device file [default=%default]") + + digital.ofdm_mod.add_options(parser, expert_grp) + digital.ofdm_demod.add_options(parser, expert_grp) + transmit_path.add_options(parser, expert_grp) + receive_path.add_options(parser, expert_grp) + uhd_receiver.add_options(parser) + uhd_transmitter.add_options(parser) + + (options, args) = parser.parse_args () + if len(args) != 0: + parser.print_help(sys.stderr) + sys.exit(1) + + if options.rx_freq is None or options.tx_freq is None: + sys.stderr.write("You must specify -f FREQ or --freq FREQ\n") + parser.print_help(sys.stderr) + sys.exit(1) + + # open the TUN/TAP interface + (tun_fd, tun_ifname) = open_tun_interface(options.tun_device_filename) + + # Attempt to enable realtime scheduling + r = gr.enable_realtime_scheduling() + if r == gr.RT_OK: + realtime = True + else: + realtime = False + print "Note: failed to enable realtime scheduling" + + # instantiate the MAC + mac = cs_mac(tun_fd, verbose=True) + + + # build the graph (PHY) + tb = my_top_block(mac.phy_rx_callback, options) + + mac.set_flow_graph(tb) # give the MAC a handle for the PHY + + print "modulation: %s" % (options.modulation,) + print "freq: %s" % (eng_notation.num_to_str(options.tx_freq)) + + tb.rxpath.set_carrier_threshold(options.carrier_threshold) + print "Carrier sense threshold:", options.carrier_threshold, "dB" + + print + print "Allocated virtual ethernet interface: %s" % (tun_ifname,) + print "You must now use ifconfig to set its IP address. E.g.," + print + print " $ sudo ifconfig %s 192.168.200.1" % (tun_ifname,) + print + print "Be sure to use a different address in the same subnet for each machine." + print + + + tb.start() # Start executing the flow graph (runs in separate threads) + + mac.main_loop() # don't expect this to return... + + tb.stop() # but if it does, tell flow graph to stop. + tb.wait() # wait for it to finish + + +if __name__ == '__main__': + try: + main() + except KeyboardInterrupt: + pass diff --git a/gr-digital/examples/ofdm/uhd_interface.py b/gr-digital/examples/ofdm/uhd_interface.py new file mode 100644 index 000000000..d03bd7f46 --- /dev/null +++ b/gr-digital/examples/ofdm/uhd_interface.py @@ -0,0 +1,199 @@ +#!/usr/bin/env python +# +# 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. +# + +from gnuradio import gr, uhd +from gnuradio import eng_notation +from gnuradio.eng_option import eng_option +from optparse import OptionParser + +import sys + +def add_freq_option(parser): + """ + Hackery that has the -f / --freq option set both tx_freq and rx_freq + """ + def freq_callback(option, opt_str, value, parser): + parser.values.rx_freq = value + parser.values.tx_freq = value + + if not parser.has_option('--freq'): + parser.add_option('-f', '--freq', type="eng_float", + action="callback", callback=freq_callback, + help="set Tx and/or Rx frequency to FREQ [default=%default]", + metavar="FREQ") + +class uhd_interface: + def __init__(self, istx, address, bandwidth, freq=None, + gain=None, antenna=None): + + if(istx): + self.u = uhd.usrp_sink(device_addr=address, + io_type=uhd.io_type.COMPLEX_FLOAT32, + num_channels=1) + else: + self.u = uhd.usrp_source(device_addr=address, + io_type=uhd.io_type.COMPLEX_FLOAT32, + num_channels=1) + + self._addr = address + self._ant = antenna + self._gain = self.set_gain(gain) + self._freq = self.set_freq(freq) + + self._rate = self.set_sample_rate(bandwidth) + + if(antenna): + self.u.set_antenna(antenna, 0) + + def set_sample_rate(self, bandwidth): + self.u.set_samp_rate(bandwidth) + actual_bw = self.u.get_samp_rate() + + return actual_bw + + def get_sample_rate(self): + return self.u.get_samp_rate() + + def set_gain(self, gain=None): + if gain is None: + # if no gain was specified, use the mid-point in dB + g = self.u.get_gain_range() + gain = float(g.start()+g.stop())/2 + print "\nNo gain specified." + print "Setting gain to %f (from [%f, %f])" % \ + (gain, g.start(), g.stop()) + + self.u.set_gain(gain, 0) + return gain + + def set_freq(self, freq=None): + if(freq is None): + sys.stderr.write("You must specify -f FREQ or --freq FREQ\n") + sys.exit(1) + + r = self.u.set_center_freq(freq, 0) + if r: + return freq + else: + frange = self.u.get_freq_range() + sys.stderr.write(("\nRequested frequency (%f) out or range [%f, %f]\n") % \ + (freq, frange.start(), frange.stop())) + sys.exit(1) + +#-------------------------------------------------------------------# +# TRANSMITTER +#-------------------------------------------------------------------# + +class uhd_transmitter(uhd_interface, gr.hier_block2): + def __init__(self, address, bandwidth, freq=None, gain=None, + antenna=None, verbose=False): + gr.hier_block2.__init__(self, "uhd_transmitter", + gr.io_signature(1,1,gr.sizeof_gr_complex), + gr.io_signature(0,0,0)) + + # Set up the UHD interface as a transmitter + uhd_interface.__init__(self, True, address, bandwidth, + freq, gain, antenna) + + self.connect(self, self.u) + + if(verbose): + self._print_verbage() + + def add_options(parser): + add_freq_option(parser) + parser.add_option("-a", "--address", type="string", default="addr=192.168.10.2", + help="Address of UHD device, [default=%default]") + parser.add_option("-A", "--antenna", type="string", default=None, + help="select Rx Antenna where appropriate") + parser.add_option("", "--tx-freq", type="eng_float", default=None, + help="set transmit frequency to FREQ [default=%default]", + metavar="FREQ") + parser.add_option("", "--tx-gain", type="eng_float", default=None, + help="set transmit gain in dB (default is midpoint)") + parser.add_option("-v", "--verbose", action="store_true", default=False) + + # Make a static method to call before instantiation + add_options = staticmethod(add_options) + + def _print_verbage(self): + """ + Prints information about the UHD transmitter + """ + print "\nUHD Transmitter:" + print "Address: %s" % (self._addr) + print "Freq: %sHz" % (eng_notation.num_to_str(self._freq)) + print "Gain: %f dB" % (self._gain) + print "Sample Rate: %ssps" % (eng_notation.num_to_str(self._rate)) + print "Antenna: %s" % (self._ant) + + + +#-------------------------------------------------------------------# +# RECEIVER +#-------------------------------------------------------------------# + + +class uhd_receiver(uhd_interface, gr.hier_block2): + def __init__(self, address, bandwidth, freq=None, gain=None, + antenna=None, verbose=False): + gr.hier_block2.__init__(self, "uhd_receiver", + gr.io_signature(0,0,0), + gr.io_signature(1,1,gr.sizeof_gr_complex)) + + # Set up the UHD interface as a receiver + uhd_interface.__init__(self, False, address, bandwidth, + freq, gain, antenna) + + self.connect(self.u, self) + + if(verbose): + self._print_verbage() + + def add_options(parser): + add_freq_option(parser) + parser.add_option("-a", "--address", type="string", default="addr=192.168.10.2", + help="Address of UHD device, [default=%default]") + parser.add_option("-A", "--antenna", type="string", default=None, + help="select Rx Antenna where appropriate") + parser.add_option("", "--rx-freq", type="eng_float", default=None, + help="set receive frequency to FREQ [default=%default]", + metavar="FREQ") + parser.add_option("", "--rx-gain", type="eng_float", default=None, + help="set receive gain in dB (default is midpoint)") + if not parser.has_option("--verbose"): + parser.add_option("-v", "--verbose", action="store_true", default=False) + + # Make a static method to call before instantiation + add_options = staticmethod(add_options) + + def _print_verbage(self): + """ + Prints information about the UHD transmitter + """ + print "\nUHD Receiver:" + print "Address: %s" % (self._addr) + print "Freq: %sHz" % (eng_notation.num_to_str(self._freq)) + print "Gain: %f dB" % (self._gain) + print "Sample Rate: %ssps" % (eng_notation.num_to_str(self._rate)) + print "Antenna: %s" % (self._ant) + diff --git a/gr-digital/grc/Makefile.am b/gr-digital/grc/Makefile.am index e4426e721..ef4e38600 100644 --- a/gr-digital/grc/Makefile.am +++ b/gr-digital/grc/Makefile.am @@ -40,4 +40,11 @@ dist_grcblocks_DATA = \ digital_psk_mod.xml \ digital_psk_demod.xml \ digital_qam_mod.xml \ - digital_qam_demod.xml + digital_qam_demod.xml \ + digital_ofdm_mod.xml \ + digital_ofdm_demod.xml \ + digital_ofdm_cyclic_prefixer.xml \ + digital_ofdm_frame_acquisition.xml \ + digital_ofdm_insert_preamble.xml \ + digital_ofdm_sampler.xml \ + digital_ofdm_sync_pn.xml diff --git a/gr-digital/grc/digital_block_tree.xml b/gr-digital/grc/digital_block_tree.xml index 088fe1c10..816df7f45 100644 --- a/gr-digital/grc/digital_block_tree.xml +++ b/gr-digital/grc/digital_block_tree.xml @@ -50,4 +50,14 @@ <block>digital_qam_mod</block> <block>digital_qam_demod</block> </cat> + <cat> + <name>OFDM</name> + <block>digital_ofdm_mod</block> + <block>digital_ofdm_demod</block> + <block>digital_ofdm_cyclic_prefixer</block> + <block>digital_ofdm_frame_acquisition</block> + <block>digital_ofdm_insert_preamble</block> + <block>digital_ofdm_sampler</block> + <block>digital_ofdm_sync_pn</block> + </cat> </cat> diff --git a/gr-digital/grc/digital_ofdm_cyclic_prefixer.xml b/gr-digital/grc/digital_ofdm_cyclic_prefixer.xml new file mode 100644 index 000000000..d5e5d3894 --- /dev/null +++ b/gr-digital/grc/digital_ofdm_cyclic_prefixer.xml @@ -0,0 +1,52 @@ +<?xml version="1.0"?> +<!-- + Copyright 2011 Free Software Foundation, Inc. + + This file is part of GNU Radio + + GNU Radio is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + GNU Radio is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GNU Radio; see the file COPYING. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, + Boston, MA 02110-1301, USA. +--> + +<!-- +################################################### +##OFDM Cyclic Prefixer +################################################### + --> +<block> + <name>OFDM Cyclic Prefixer</name> + <key>digital_ofdm_cyclic_prefixer</key> + <import>from gnuradio import digital</import> + <make>digital.ofdm_cyclic_prefixer($input_size, $output_size)</make> + <param> + <name>Input Size</name> + <key>input_size</key> + <type>int</type> + </param> + <param> + <name>Output Size</name> + <key>output_size</key> + <type>int</type> + </param> + <sink> + <name>in</name> + <type>complex</type> + <vlen>$input_size</vlen> + </sink> + <source> + <name>out</name> + <type>complex</type> + </source> +</block> diff --git a/grc/blocks/blks2_ofdm_demod.xml b/gr-digital/grc/digital_ofdm_demod.xml index ac5ee4795..9f3a83715 100644 --- a/grc/blocks/blks2_ofdm_demod.xml +++ b/gr-digital/grc/digital_ofdm_demod.xml @@ -1,15 +1,36 @@ <?xml version="1.0"?> <!-- + Copyright 2011 Free Software Foundation, Inc. + + This file is part of GNU Radio + + GNU Radio is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + GNU Radio is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GNU Radio; see the file COPYING. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, + Boston, MA 02110-1301, USA. +--> + +<!-- ################################################### ##OFDM Demod ################################################### --> <block> <name>OFDM Demod</name> - <key>blks2_ofdm_demod</key> + <key>digital_ofdm_demod</key> <import>from grc_gnuradio import blks2 as grc_blks2</import> - <import>from gnuradio import blks2</import> - <make>grc_blks2.packet_demod_$(type.fcn)(blks2.ofdm_demod( + <import>from gnuradio import digital</import> + <make>grc_blks2.packet_demod_$(type.fcn)(digital.ofdm_demod( options=grc_blks2.options( modulation="$modulation", fft_length=$fft_length, diff --git a/gr-digital/grc/digital_ofdm_frame_acquisition.xml b/gr-digital/grc/digital_ofdm_frame_acquisition.xml new file mode 100644 index 000000000..2545f18e6 --- /dev/null +++ b/gr-digital/grc/digital_ofdm_frame_acquisition.xml @@ -0,0 +1,77 @@ +<?xml version="1.0"?> +<!-- + Copyright 2011 Free Software Foundation, Inc. + + This file is part of GNU Radio + + GNU Radio is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + GNU Radio is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GNU Radio; see the file COPYING. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, + Boston, MA 02110-1301, USA. +--> + +<!-- +################################################### +##OFDM Frame Acquisition +################################################### + --> +<block> + <name>OFDM Frame Acquisition</name> + <key>digital_ofdm_frame_acquisition</key> + <import>from gnuradio import digital</import> + <make>digital.ofdm_frame_acquisition($occupied_carriers, $fft_length, $cplen, $known_symbol, $max_fft_shift_len)</make> + <param> + <name>Occupied Carriers</name> + <key>occupied_carriers</key> + <type>int</type> + </param> + <param> + <name>FFT Length</name> + <key>fft_length</key> + <type>int</type> + </param> + <param> + <name>CP Length</name> + <key>cplen</key> + <type>int</type> + </param> + <param> + <name>Preamble</name> + <key>known_symbol</key> + <type>complex_vector</type> + </param> + <param> + <name>Max FFT Shift</name> + <key>max_fft_shift_len</key> + <type>int</type> + </param> + <sink> + <name>in</name> + <type>complex</type> + <vlen>$fft_length</vlen> + </sink> + <sink> + <name>flag</name> + <type>byte</type> + <vlen>$fft_length</vlen> + </sink> + <source> + <name>out</name> + <type>complex</type> + <vlen>$occupied_carriers</vlen> + </source> + <source> + <name>flag</name> + <type>byte</type> + </source> +</block> diff --git a/gr-digital/grc/digital_ofdm_insert_preamble.xml b/gr-digital/grc/digital_ofdm_insert_preamble.xml new file mode 100644 index 000000000..33a93058f --- /dev/null +++ b/gr-digital/grc/digital_ofdm_insert_preamble.xml @@ -0,0 +1,57 @@ +<?xml version="1.0"?> +<!-- + Copyright 2011 Free Software Foundation, Inc. + + This file is part of GNU Radio + + GNU Radio is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + GNU Radio is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GNU Radio; see the file COPYING. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, + Boston, MA 02110-1301, USA. +--> + +<!-- +################################################### +##OFDM Insert Preamble +################################################### + --> +<block> + <name>OFDM Insert Preamble</name> + <key>digital_ofdm_insert_preamble</key> + <import>from gnuradio import digital</import> + <make>digital.ofdm_insert_preamble($fft_length, $preamble)</make> + <param> + <name>FFT Length</name> + <key>fft_length</key> + <type>int</type> + </param> + <param> + <name>Preamble</name> + <key>preamble</key> + <type>raw</type> + </param> + <sink> + <name>in</name> + <type>complex</type> + <vlen>$fft_length</vlen> + </sink> + <sink> + <name>flag</name> + <type>byte</type> + </sink> + <source> + <name>out</name> + <type>complex</type> + <vlen>$fft_length</vlen> + </source> +</block> diff --git a/grc/blocks/blks2_ofdm_mod.xml b/gr-digital/grc/digital_ofdm_mod.xml index 2c54d10f4..24cb2aa33 100644 --- a/grc/blocks/blks2_ofdm_mod.xml +++ b/gr-digital/grc/digital_ofdm_mod.xml @@ -1,15 +1,36 @@ <?xml version="1.0"?> <!-- + Copyright 2011 Free Software Foundation, Inc. + + This file is part of GNU Radio + + GNU Radio is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + GNU Radio is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GNU Radio; see the file COPYING. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, + Boston, MA 02110-1301, USA. +--> + +<!-- ################################################### ##OFDM Mod ################################################### --> <block> <name>OFDM Mod</name> - <key>blks2_ofdm_mod</key> + <key>digital_ofdm_mod</key> <import>from grc_gnuradio import blks2 as grc_blks2</import> - <import>from gnuradio import blks2</import> - <make>grc_blks2.packet_mod_$(type.fcn)(blks2.ofdm_mod( + <import>from gnuradio import digital</import> + <make>grc_blks2.packet_mod_$(type.fcn)(digital.ofdm_mod( options=grc_blks2.options( modulation="$modulation", fft_length=$fft_length, diff --git a/gr-digital/grc/digital_ofdm_sampler.xml b/gr-digital/grc/digital_ofdm_sampler.xml new file mode 100644 index 000000000..1be0d11f3 --- /dev/null +++ b/gr-digital/grc/digital_ofdm_sampler.xml @@ -0,0 +1,67 @@ +<?xml version="1.0"?> +<!-- + Copyright 2011 Free Software Foundation, Inc. + + This file is part of GNU Radio + + GNU Radio is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + GNU Radio is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GNU Radio; see the file COPYING. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, + Boston, MA 02110-1301, USA. +--> + +<!-- +################################################### +##OFDM Sampler +################################################### + --> +<block> + <name>OFDM Sampler</name> + <key>digital_ofdm_sampler</key> + <import>from gnuradio import digital</import> + <make>digital.ofdm_sampler($fft_length, $symbol_length, $timeout)</make> + <param> + <name>FFT Length</name> + <key>fft_length</key> + <type>int</type> + </param> + <param> + <name>Symbol Length</name> + <key>symbol_length</key> + <type>int</type> + </param> + <param> + <name>Timeout</name> + <key>timeout</key> + <type>int</type> + <value>1000</value> + </param> + <sink> + <name>in</name> + <type>complex</type> + </sink> + <sink> + <name>flag</name> + <type>byte</type> + </sink> + <source> + <name>out</name> + <type>complex</type> + <vlen>$fft_length</vlen> + </source> + <source> + <name>flag</name> + <type>byte</type> + <vlen>$fft_length</vlen> + </source> +</block> diff --git a/gr-digital/grc/digital_ofdm_sync_pn.xml b/gr-digital/grc/digital_ofdm_sync_pn.xml new file mode 100644 index 000000000..ac0bbfe88 --- /dev/null +++ b/gr-digital/grc/digital_ofdm_sync_pn.xml @@ -0,0 +1,61 @@ +<?xml version="1.0"?> +<!-- + Copyright 2011 Free Software Foundation, Inc. + + This file is part of GNU Radio + + GNU Radio is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + GNU Radio is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GNU Radio; see the file COPYING. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, + Boston, MA 02110-1301, USA. +--> + +<!-- +################################################### +##OFDM Synchronizer - PN based +################################################### + --> +<block> + <name>OFDM Sync PN</name> + <key>digital_ofdm_sync_pn</key> + <import>from gnuradio import digital</import> + <make>digital.ofdm_sync_pn($fft_length, $cp_length, $logging)</make> + <param> + <name>FFT Length</name> + <key>fft_length</key> + <type>int</type> + </param> + <param> + <name>CP Length</name> + <key>cp_length</key> + <type>int</type> + </param> + <param> + <name>Logging</name> + <key>logging</key> + <type>bool</type> + <value>False</value> + </param> + <sink> + <name>in</name> + <type>complex</type> + </sink> + <source> + <name>fine freq</name> + <type>float</type> + </source> + <source> + <name>timing sig</name> + <type>byte</type> + </source> +</block> diff --git a/gr-digital/grc/digital_psk_mod.xml b/gr-digital/grc/digital_psk_mod.xml index 34ed42c97..cafcf4e50 100644 --- a/gr-digital/grc/digital_psk_mod.xml +++ b/gr-digital/grc/digital_psk_mod.xml @@ -30,7 +30,7 @@ <name>PSK Mod</name> <key>digital_psk_mod</key> <import>from gnuradio import digital</import> - <make>digital.psk2.psk_mod( + <make>digital.psk.psk_mod( constellation_points=$constellation_points, mod_code=$mod_code, differential=$differential, diff --git a/gr-digital/include/CMakeLists.txt b/gr-digital/include/CMakeLists.txt index f5d4d76b6..cf20bd1e7 100644 --- a/gr-digital/include/CMakeLists.txt +++ b/gr-digital/include/CMakeLists.txt @@ -37,6 +37,12 @@ install(FILES digital_kurtotic_equalizer_cc.h digital_metric_type.h digital_mpsk_receiver_cc.h + digital_ofdm_cyclic_prefixer.h + digital_ofdm_frame_acquisition.h + digital_ofdm_frame_sink.h + digital_ofdm_insert_preamble.h + digital_ofdm_mapper_bcv.h + digital_ofdm_sampler.h digital_gmskmod_bc.h digital_cpmmod_bc.h DESTINATION ${GR_INCLUDE_DIR}/gnuradio diff --git a/gr-digital/include/Makefile.am b/gr-digital/include/Makefile.am index 346d036ce..8ce3a94e8 100644 --- a/gr-digital/include/Makefile.am +++ b/gr-digital/include/Makefile.am @@ -39,6 +39,12 @@ grinclude_HEADERS = \ digital_kurtotic_equalizer_cc.h \ digital_metric_type.h \ digital_mpsk_receiver_cc.h \ + digital_ofdm_cyclic_prefixer.h \ + digital_ofdm_frame_acquisition.h \ + digital_ofdm_frame_sink.h \ + digital_ofdm_insert_preamble.h \ + digital_ofdm_mapper_bcv.h \ + digital_ofdm_sampler.h \ digital_gmskmod_bc.h \ digital_cpmmod_bc.h diff --git a/gr-digital/include/digital_clock_recovery_mm_cc.h b/gr-digital/include/digital_clock_recovery_mm_cc.h index f8d973765..a2577d537 100644 --- a/gr-digital/include/digital_clock_recovery_mm_cc.h +++ b/gr-digital/include/digital_clock_recovery_mm_cc.h @@ -44,12 +44,15 @@ digital_make_clock_recovery_mm_cc (float omega, float gain_omega, * \ingroup sync_blk * \ingroup digital * - * This implements the Mueller and Müller (M&M) discrete-time error-tracking synchronizer. + * This implements the Mueller and Müller (M&M) discrete-time + * error-tracking synchronizer. + * * The complex version here is based on: * Modified Mueller and Muller clock recovery circuit * Based: - * G. R. Danesfahani, T.G. Jeans, "Optimisation of modified Mueller and Muller - * algorithm," Electronics Letters, Vol. 31, no. 13, 22 June 1995, pp. 1032 - 1033. + * G. R. Danesfahani, T.G. Jeans, "Optimisation of modified Mueller + * and Muller algorithm," Electronics Letters, Vol. 31, no. 13, 22 + * June 1995, pp. 1032 - 1033. */ class DIGITAL_API digital_clock_recovery_mm_cc : public gr_block { diff --git a/gnuradio-core/src/lib/general/gr_ofdm_cyclic_prefixer.h b/gr-digital/include/digital_ofdm_cyclic_prefixer.h index 1ed68aa58..1b9682bb3 100644 --- a/gnuradio-core/src/lib/general/gr_ofdm_cyclic_prefixer.h +++ b/gr-digital/include/digital_ofdm_cyclic_prefixer.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2005,2006 Free Software Foundation, Inc. + * Copyright 2004-2006,2011 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,18 +20,18 @@ * Boston, MA 02110-1301, USA. */ -#ifndef INCLUDED_GR_OFDM_CYCLIC_PREFIXER_H -#define INCLUDED_GR_OFDM_CYCLIC_PREFIXER_H +#ifndef INCLUDED_DIGITAL_OFDM_CYCLIC_PREFIXER_H +#define INCLUDED_DIGITAL_OFDM_CYCLIC_PREFIXER_H -#include <gr_core_api.h> +#include <digital_api.h> #include <gr_sync_interpolator.h> #include <stdio.h> -class gr_ofdm_cyclic_prefixer; -typedef boost::shared_ptr<gr_ofdm_cyclic_prefixer> gr_ofdm_cyclic_prefixer_sptr; +class digital_ofdm_cyclic_prefixer; +typedef boost::shared_ptr<digital_ofdm_cyclic_prefixer> digital_ofdm_cyclic_prefixer_sptr; -GR_CORE_API gr_ofdm_cyclic_prefixer_sptr -gr_make_ofdm_cyclic_prefixer (size_t input_size, size_t output_size); +DIGITAL_API digital_ofdm_cyclic_prefixer_sptr +digital_make_ofdm_cyclic_prefixer (size_t input_size, size_t output_size); /*! @@ -39,13 +39,13 @@ gr_make_ofdm_cyclic_prefixer (size_t input_size, size_t output_size); * symbol(vector) and converts vector to a stream output_size long. * \ingroup ofdm_blk */ -class GR_CORE_API gr_ofdm_cyclic_prefixer : public gr_sync_interpolator +class DIGITAL_API digital_ofdm_cyclic_prefixer : public gr_sync_interpolator { - friend GR_CORE_API gr_ofdm_cyclic_prefixer_sptr - gr_make_ofdm_cyclic_prefixer (size_t input_size, size_t output_size); + friend DIGITAL_API digital_ofdm_cyclic_prefixer_sptr + digital_make_ofdm_cyclic_prefixer (size_t input_size, size_t output_size); protected: - gr_ofdm_cyclic_prefixer (size_t input_size, size_t output_size); + digital_ofdm_cyclic_prefixer (size_t input_size, size_t output_size); public: int work (int noutput_items, @@ -56,4 +56,4 @@ class GR_CORE_API gr_ofdm_cyclic_prefixer : public gr_sync_interpolator size_t d_output_size; }; -#endif /* INCLUDED_GR_OFDM_CYCLIC_PREFIXER_H */ +#endif /* INCLUDED_DIGITAL_OFDM_CYCLIC_PREFIXER_H */ diff --git a/gnuradio-core/src/lib/general/gr_ofdm_frame_acquisition.h b/gr-digital/include/digital_ofdm_frame_acquisition.h index 63c1af086..9c2f60233 100644 --- a/gnuradio-core/src/lib/general/gr_ofdm_frame_acquisition.h +++ b/gr-digital/include/digital_ofdm_frame_acquisition.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2006, 2007 Free Software Foundation, Inc. + * Copyright 2006,2007,2011 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,19 +20,18 @@ * Boston, MA 02110-1301, USA. */ -#ifndef INCLUDED_GR_OFDM_FRAME_ACQUISITION_H -#define INCLUDED_GR_OFDM_FRAME_ACQUISITION_H +#ifndef INCLUDED_DIGITAL_OFDM_FRAME_ACQUISITION_H +#define INCLUDED_DIGITAL_OFDM_FRAME_ACQUISITION_H - -#include <gr_core_api.h> +#include <digital_api.h> #include <gr_block.h> #include <vector> -class gr_ofdm_frame_acquisition; -typedef boost::shared_ptr<gr_ofdm_frame_acquisition> gr_ofdm_frame_acquisition_sptr; +class digital_ofdm_frame_acquisition; +typedef boost::shared_ptr<digital_ofdm_frame_acquisition> digital_ofdm_frame_acquisition_sptr; -GR_CORE_API gr_ofdm_frame_acquisition_sptr -gr_make_ofdm_frame_acquisition (unsigned int occupied_carriers, unsigned int fft_length, +digital_ofdm_frame_acquisition_sptr +DIGITAL_API digital_make_ofdm_frame_acquisition (unsigned int occupied_carriers, unsigned int fft_length, unsigned int cplen, const std::vector<gr_complex> &known_symbol, unsigned int max_fft_shift_len=10); @@ -55,7 +54,7 @@ gr_make_ofdm_frame_acquisition (unsigned int occupied_carriers, unsigned int fft * distortion caused by the channel. */ -class GR_CORE_API gr_ofdm_frame_acquisition : public gr_block +class DIGITAL_API digital_ofdm_frame_acquisition : public gr_block { /*! * \brief Build an OFDM correlator and equalizer. @@ -66,14 +65,14 @@ class GR_CORE_API gr_ofdm_frame_acquisition : public gr_block * start of a frame (usually a BPSK PN sequence) * \param max_fft_shift_len Set's the maximum distance you can look between bins for correlation */ - friend GR_CORE_API gr_ofdm_frame_acquisition_sptr - gr_make_ofdm_frame_acquisition (unsigned int occupied_carriers, unsigned int fft_length, + friend DIGITAL_API digital_ofdm_frame_acquisition_sptr + digital_make_ofdm_frame_acquisition (unsigned int occupied_carriers, unsigned int fft_length, unsigned int cplen, const std::vector<gr_complex> &known_symbol, unsigned int max_fft_shift_len); protected: - gr_ofdm_frame_acquisition (unsigned int occupied_carriers, unsigned int fft_length, + digital_ofdm_frame_acquisition (unsigned int occupied_carriers, unsigned int fft_length, unsigned int cplen, const std::vector<gr_complex> &known_symbol, unsigned int max_fft_shift_len); @@ -106,7 +105,7 @@ protected: */ float snr() { return d_snr_est; } - ~gr_ofdm_frame_acquisition(void); + ~digital_ofdm_frame_acquisition(void); int general_work(int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, diff --git a/gnuradio-core/src/lib/general/gr_ofdm_frame_sink.h b/gr-digital/include/digital_ofdm_frame_sink.h index d3c1d761d..5785d4be7 100644 --- a/gnuradio-core/src/lib/general/gr_ofdm_frame_sink.h +++ b/gr-digital/include/digital_ofdm_frame_sink.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2007 Free Software Foundation, Inc. + * Copyright 2007,2011 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,21 +20,21 @@ * Boston, MA 02110-1301, USA. */ -#ifndef INCLUDED_GR_OFDM_FRAME_SINK_H -#define INCLUDED_GR_OFDM_FRAME_SINK_H +#ifndef INCLUDED_DIGITAL_OFDM_FRAME_SINK_H +#define INCLUDED_DIGITAL_OFDM_FRAME_SINK_H -#include <gr_core_api.h> +#include <digital_api.h> #include <gr_sync_block.h> #include <gr_msg_queue.h> -class gr_ofdm_frame_sink; -typedef boost::shared_ptr<gr_ofdm_frame_sink> gr_ofdm_frame_sink_sptr; +class digital_ofdm_frame_sink; +typedef boost::shared_ptr<digital_ofdm_frame_sink> digital_ofdm_frame_sink_sptr; -GR_CORE_API gr_ofdm_frame_sink_sptr -gr_make_ofdm_frame_sink (const std::vector<gr_complex> &sym_position, - const std::vector<unsigned char> &sym_value_out, - gr_msg_queue_sptr target_queue, unsigned int occupied_tones, - float phase_gain=0.25, float freq_gain=0.25*0.25/4.0); +DIGITAL_API digital_ofdm_frame_sink_sptr +digital_make_ofdm_frame_sink (const std::vector<gr_complex> &sym_position, + const std::vector<unsigned char> &sym_value_out, + 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 @@ -46,13 +46,13 @@ gr_make_ofdm_frame_sink (const std::vector<gr_complex> &sym_position, * 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_sink : public gr_sync_block +class DIGITAL_API digital_ofdm_frame_sink : public gr_sync_block { - friend GR_CORE_API gr_ofdm_frame_sink_sptr - gr_make_ofdm_frame_sink (const std::vector<gr_complex> &sym_position, - const std::vector<unsigned char> &sym_value_out, - gr_msg_queue_sptr target_queue, unsigned int occupied_tones, - float phase_gain, float freq_gain); + friend DIGITAL_API digital_ofdm_frame_sink_sptr + digital_make_ofdm_frame_sink (const std::vector<gr_complex> &sym_position, + const std::vector<unsigned char> &sym_value_out, + 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}; @@ -94,10 +94,10 @@ class GR_CORE_API gr_ofdm_frame_sink : public gr_sync_block std::vector<int> d_subcarrier_map; protected: - gr_ofdm_frame_sink(const std::vector<gr_complex> &sym_position, - const std::vector<unsigned char> &sym_value_out, - gr_msg_queue_sptr target_queue, unsigned int occupied_tones, - float phase_gain, float freq_gain); + digital_ofdm_frame_sink(const std::vector<gr_complex> &sym_position, + const std::vector<unsigned char> &sym_value_out, + gr_msg_queue_sptr target_queue, unsigned int occupied_tones, + float phase_gain, float freq_gain); void enter_search(); void enter_have_sync(); @@ -117,7 +117,7 @@ class GR_CORE_API gr_ofdm_frame_sink : public gr_sync_block const std::vector<unsigned char> &sym_value_out); public: - ~gr_ofdm_frame_sink(); + ~digital_ofdm_frame_sink(); int work(int noutput_items, gr_vector_const_void_star &input_items, diff --git a/gnuradio-core/src/lib/general/gr_ofdm_insert_preamble.h b/gr-digital/include/digital_ofdm_insert_preamble.h index 10025dd14..6f9dae5d6 100644 --- a/gnuradio-core/src/lib/general/gr_ofdm_insert_preamble.h +++ b/gr-digital/include/digital_ofdm_insert_preamble.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2007 Free Software Foundation, Inc. + * Copyright 2007,2011 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -19,19 +19,19 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#ifndef INCLUDED_GR_OFDM_INSERT_PREAMBLE_H -#define INCLUDED_GR_OFDM_INSERT_PREAMBLE_H +#ifndef INCLUDED_DIGITAL_OFDM_INSERT_PREAMBLE_H +#define INCLUDED_DIGITAL_OFDM_INSERT_PREAMBLE_H -#include <gr_core_api.h> +#include <digital_api.h> #include <gr_block.h> #include <vector> -class gr_ofdm_insert_preamble; -typedef boost::shared_ptr<gr_ofdm_insert_preamble> gr_ofdm_insert_preamble_sptr; +class digital_ofdm_insert_preamble; +typedef boost::shared_ptr<digital_ofdm_insert_preamble> digital_ofdm_insert_preamble_sptr; -GR_CORE_API gr_ofdm_insert_preamble_sptr -gr_make_ofdm_insert_preamble(int fft_length, - const std::vector<std::vector<gr_complex> > &preamble); +DIGITAL_API digital_ofdm_insert_preamble_sptr +digital_make_ofdm_insert_preamble(int fft_length, + const std::vector<std::vector<gr_complex> > &preamble); /*! * \brief insert "pre-modulated" preamble symbols before each payload. @@ -63,15 +63,15 @@ gr_make_ofdm_insert_preamble(int fft_length, * \param preamble vector of symbols that represent the pre-modulated preamble. */ -class GR_CORE_API gr_ofdm_insert_preamble : public gr_block +class DIGITAL_API digital_ofdm_insert_preamble : public gr_block { - friend GR_CORE_API gr_ofdm_insert_preamble_sptr - gr_make_ofdm_insert_preamble(int fft_length, - const std::vector<std::vector<gr_complex> > &preamble); + friend DIGITAL_API digital_ofdm_insert_preamble_sptr + digital_make_ofdm_insert_preamble(int fft_length, + const std::vector<std::vector<gr_complex> > &preamble); protected: - gr_ofdm_insert_preamble(int fft_length, - const std::vector<std::vector<gr_complex> > &preamble); + digital_ofdm_insert_preamble(int fft_length, + const std::vector<std::vector<gr_complex> > &preamble); private: enum state_t { @@ -94,7 +94,7 @@ private: public: - ~gr_ofdm_insert_preamble(); + ~digital_ofdm_insert_preamble(); int general_work (int noutput_items, gr_vector_int &ninput_items, @@ -102,4 +102,4 @@ public: gr_vector_void_star &output_items); }; -#endif /* INCLUDED_GR_OFDM_INSERT_PREAMBLE_H */ +#endif /* INCLUDED_DIGITAL_OFDM_INSERT_PREAMBLE_H */ diff --git a/gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.h b/gr-digital/include/digital_ofdm_mapper_bcv.h index f33ca4253..daed1eab2 100644 --- a/gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.h +++ b/gr-digital/include/digital_ofdm_mapper_bcv.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2006,2007 Free Software Foundation, Inc. + * Copyright 2006,2007,2011 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,20 +20,20 @@ * Boston, MA 02110-1301, USA. */ -#ifndef INCLUDED_GR_OFDM_MAPPER_BCV_H -#define INCLUDED_GR_OFDM_MAPPER_BCV_H +#ifndef INCLUDED_DIGITAL_OFDM_MAPPER_BCV_H +#define INCLUDED_DIGITAL_OFDM_MAPPER_BCV_H -#include <gr_core_api.h> +#include <digital_api.h> #include <gr_sync_block.h> #include <gr_message.h> #include <gr_msg_queue.h> -class gr_ofdm_mapper_bcv; -typedef boost::shared_ptr<gr_ofdm_mapper_bcv> gr_ofdm_mapper_bcv_sptr; +class digital_ofdm_mapper_bcv; +typedef boost::shared_ptr<digital_ofdm_mapper_bcv> digital_ofdm_mapper_bcv_sptr; -GR_CORE_API gr_ofdm_mapper_bcv_sptr -gr_make_ofdm_mapper_bcv (const std::vector<gr_complex> &constellation, unsigned msgq_limit, - unsigned occupied_carriers, unsigned int fft_length); +DIGITAL_API digital_ofdm_mapper_bcv_sptr +digital_make_ofdm_mapper_bcv (const std::vector<gr_complex> &constellation, unsigned msgq_limit, + unsigned occupied_carriers, unsigned int fft_length); /*! * \brief take a stream of bytes in and map to a vector of complex @@ -43,14 +43,14 @@ gr_make_ofdm_mapper_bcv (const std::vector<gr_complex> &constellation, unsigned * \ingroup ofdm_blk */ -class GR_CORE_API gr_ofdm_mapper_bcv : public gr_sync_block +class DIGITAL_API digital_ofdm_mapper_bcv : public gr_sync_block { - friend GR_CORE_API gr_ofdm_mapper_bcv_sptr - gr_make_ofdm_mapper_bcv (const std::vector<gr_complex> &constellation, unsigned msgq_limit, + friend DIGITAL_API digital_ofdm_mapper_bcv_sptr + digital_make_ofdm_mapper_bcv (const std::vector<gr_complex> &constellation, unsigned msgq_limit, + unsigned occupied_carriers, unsigned int fft_length); +protected: + digital_ofdm_mapper_bcv (const std::vector<gr_complex> &constellation, unsigned msgq_limit, unsigned occupied_carriers, unsigned int fft_length); - protected: - gr_ofdm_mapper_bcv (const std::vector<gr_complex> &constellation, unsigned msgq_limit, - unsigned occupied_carriers, unsigned int fft_length); private: std::vector<gr_complex> d_constellation; @@ -75,7 +75,7 @@ class GR_CORE_API gr_ofdm_mapper_bcv : public gr_sync_block int randsym(); public: - ~gr_ofdm_mapper_bcv(void); + ~digital_ofdm_mapper_bcv(void); gr_msg_queue_sptr msgq() const { return d_msgq; } diff --git a/gnuradio-core/src/lib/general/gr_ofdm_sampler.h b/gr-digital/include/digital_ofdm_sampler.h index 6e9dddada..9c54e4e77 100644 --- a/gnuradio-core/src/lib/general/gr_ofdm_sampler.h +++ b/gr-digital/include/digital_ofdm_sampler.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2007 Free Software Foundation, Inc. + * Copyright 2007,2011 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,32 +20,32 @@ * Boston, MA 02110-1301, USA. */ -#ifndef INCLUDED_GR_OFDM_SAMPLER_H -#define INCLUDED_GR_OFDM_SAMPLER_H +#ifndef INCLUDED_DIGITAL_OFDM_SAMPLER_H +#define INCLUDED_DIGITAL_OFDM_SAMPLER_H -#include <gr_core_api.h> +#include <digital_api.h> #include <gr_sync_block.h> -class gr_ofdm_sampler; -typedef boost::shared_ptr<gr_ofdm_sampler> gr_ofdm_sampler_sptr; +class digital_ofdm_sampler; +typedef boost::shared_ptr<digital_ofdm_sampler> digital_ofdm_sampler_sptr; -GR_CORE_API gr_ofdm_sampler_sptr gr_make_ofdm_sampler (unsigned int fft_length, - unsigned int symbol_length, - unsigned int timeout=1000); +DIGITAL_API digital_ofdm_sampler_sptr digital_make_ofdm_sampler (unsigned int fft_length, + unsigned int symbol_length, + unsigned int timeout=1000); /*! * \brief does the rest of the OFDM stuff * \ingroup ofdm_blk */ -class GR_CORE_API gr_ofdm_sampler : public gr_block +class DIGITAL_API digital_ofdm_sampler : public gr_block { - friend GR_CORE_API gr_ofdm_sampler_sptr gr_make_ofdm_sampler (unsigned int fft_length, - unsigned int symbol_length, - unsigned int timeout); + friend DIGITAL_API digital_ofdm_sampler_sptr digital_make_ofdm_sampler (unsigned int fft_length, + unsigned int symbol_length, + unsigned int timeout); - gr_ofdm_sampler (unsigned int fft_length, - unsigned int symbol_length, - unsigned int timeout); + digital_ofdm_sampler (unsigned int fft_length, + unsigned int symbol_length, + unsigned int timeout); private: enum state_t {STATE_NO_SIG, STATE_PREAMBLE, STATE_FRAME}; diff --git a/gr-digital/lib/CMakeLists.txt b/gr-digital/lib/CMakeLists.txt index c100453c2..9417dc355 100644 --- a/gr-digital/lib/CMakeLists.txt +++ b/gr-digital/lib/CMakeLists.txt @@ -46,6 +46,12 @@ list(APPEND gr_digital_sources digital_lms_dd_equalizer_cc.cc digital_kurtotic_equalizer_cc.cc digital_mpsk_receiver_cc.cc + digital_ofdm_cyclic_prefixer.cc + digital_ofdm_frame_acquisition.cc + digital_ofdm_frame_sink.cc + digital_ofdm_insert_preamble.cc + digital_ofdm_mapper_bcv.cc + digital_ofdm_sampler.cc digital_gmskmod_bc.cc digital_cpmmod_bc.cc ) diff --git a/gr-digital/lib/Makefile.am b/gr-digital/lib/Makefile.am index 17baf2101..2860974ca 100644 --- a/gr-digital/lib/Makefile.am +++ b/gr-digital/lib/Makefile.am @@ -41,6 +41,12 @@ libgnuradio_digital_la_SOURCES = \ digital_lms_dd_equalizer_cc.cc \ digital_kurtotic_equalizer_cc.cc \ digital_mpsk_receiver_cc.cc \ + digital_ofdm_cyclic_prefixer.cc \ + digital_ofdm_frame_acquisition.cc \ + digital_ofdm_frame_sink.cc \ + digital_ofdm_insert_preamble.cc \ + digital_ofdm_mapper_bcv.cc \ + digital_ofdm_sampler.cc \ digital_gmskmod_bc.cc \ digital_cpmmod_bc.cc diff --git a/gnuradio-core/src/lib/general/gr_ofdm_cyclic_prefixer.cc b/gr-digital/lib/digital_ofdm_cyclic_prefixer.cc index fb40a3035..192af2591 100644 --- a/gnuradio-core/src/lib/general/gr_ofdm_cyclic_prefixer.cc +++ b/gr-digital/lib/digital_ofdm_cyclic_prefixer.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2006,2010 Free Software Foundation, Inc. + * Copyright 2004,2006,2010,2011 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -24,16 +24,18 @@ #include "config.h" #endif -#include <gr_ofdm_cyclic_prefixer.h> +#include <digital_ofdm_cyclic_prefixer.h> #include <gr_io_signature.h> -gr_ofdm_cyclic_prefixer_sptr -gr_make_ofdm_cyclic_prefixer (size_t input_size, size_t output_size) +digital_ofdm_cyclic_prefixer_sptr +digital_make_ofdm_cyclic_prefixer (size_t input_size, size_t output_size) { - return gnuradio::get_initial_sptr(new gr_ofdm_cyclic_prefixer (input_size, output_size)); + return gnuradio::get_initial_sptr(new digital_ofdm_cyclic_prefixer (input_size, + output_size)); } -gr_ofdm_cyclic_prefixer::gr_ofdm_cyclic_prefixer (size_t input_size, size_t output_size) +digital_ofdm_cyclic_prefixer::digital_ofdm_cyclic_prefixer (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)), @@ -45,9 +47,9 @@ gr_ofdm_cyclic_prefixer::gr_ofdm_cyclic_prefixer (size_t input_size, size_t outp } int -gr_ofdm_cyclic_prefixer::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) +digital_ofdm_cyclic_prefixer::work (int noutput_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]; diff --git a/gnuradio-core/src/lib/general/gr_ofdm_frame_acquisition.cc b/gr-digital/lib/digital_ofdm_frame_acquisition.cc index 201375597..93b58aeca 100644 --- a/gnuradio-core/src/lib/general/gr_ofdm_frame_acquisition.cc +++ b/gr-digital/lib/digital_ofdm_frame_acquisition.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2006,2007,2008,2010 Free Software Foundation, Inc. + * Copyright 2006-2008,2010,2011 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -24,7 +24,7 @@ #include "config.h" #endif -#include <gr_ofdm_frame_acquisition.h> +#include <digital_ofdm_frame_acquisition.h> #include <gr_io_signature.h> #include <gr_expj.h> #include <gr_math.h> @@ -34,20 +34,22 @@ #define M_TWOPI (2*M_PI) #define MAX_NUM_SYMBOLS 1000 -gr_ofdm_frame_acquisition_sptr -gr_make_ofdm_frame_acquisition (unsigned int occupied_carriers, unsigned int fft_length, - unsigned int cplen, - const std::vector<gr_complex> &known_symbol, - unsigned int max_fft_shift_len) +digital_ofdm_frame_acquisition_sptr +digital_make_ofdm_frame_acquisition (unsigned int occupied_carriers, + unsigned int fft_length, + unsigned int cplen, + const std::vector<gr_complex> &known_symbol, + unsigned int max_fft_shift_len) { - return gnuradio::get_initial_sptr(new gr_ofdm_frame_acquisition (occupied_carriers, fft_length, cplen, + return gnuradio::get_initial_sptr(new digital_ofdm_frame_acquisition (occupied_carriers, fft_length, cplen, known_symbol, max_fft_shift_len)); } -gr_ofdm_frame_acquisition::gr_ofdm_frame_acquisition (unsigned occupied_carriers, unsigned int fft_length, - unsigned int cplen, - const std::vector<gr_complex> &known_symbol, - unsigned int max_fft_shift_len) +digital_ofdm_frame_acquisition::digital_ofdm_frame_acquisition (unsigned occupied_carriers, + unsigned int fft_length, + unsigned int cplen, + const std::vector<gr_complex> &known_symbol, + unsigned int max_fft_shift_len) : gr_block ("ofdm_frame_acquisition", gr_make_io_signature2 (2, 2, sizeof(gr_complex)*fft_length, sizeof(char)*fft_length), gr_make_io_signature2 (2, 2, sizeof(gr_complex)*occupied_carriers, sizeof(char))), @@ -78,13 +80,13 @@ gr_ofdm_frame_acquisition::gr_ofdm_frame_acquisition (unsigned occupied_carriers } } -gr_ofdm_frame_acquisition::~gr_ofdm_frame_acquisition(void) +digital_ofdm_frame_acquisition::~digital_ofdm_frame_acquisition(void) { delete [] d_phase_lut; } void -gr_ofdm_frame_acquisition::forecast (int noutput_items, gr_vector_int &ninput_items_required) +digital_ofdm_frame_acquisition::forecast (int noutput_items, gr_vector_int &ninput_items_required) { unsigned ninputs = ninput_items_required.size (); for (unsigned i = 0; i < ninputs; i++) @@ -92,7 +94,7 @@ gr_ofdm_frame_acquisition::forecast (int noutput_items, gr_vector_int &ninput_it } gr_complex -gr_ofdm_frame_acquisition::coarse_freq_comp(int freq_delta, int symbol_count) +digital_ofdm_frame_acquisition::coarse_freq_comp(int freq_delta, int symbol_count) { // return gr_complex(cos(-M_TWOPI*freq_delta*d_cplen/d_fft_length*symbol_count), // sin(-M_TWOPI*freq_delta*d_cplen/d_fft_length*symbol_count)); @@ -103,7 +105,7 @@ gr_ofdm_frame_acquisition::coarse_freq_comp(int freq_delta, int symbol_count) } void -gr_ofdm_frame_acquisition::correlate(const gr_complex *symbol, int zeros_on_left) +digital_ofdm_frame_acquisition::correlate(const gr_complex *symbol, int zeros_on_left) { unsigned int i,j; @@ -131,7 +133,7 @@ gr_ofdm_frame_acquisition::correlate(const gr_complex *symbol, int zeros_on_left } void -gr_ofdm_frame_acquisition::calculate_equalizer(const gr_complex *symbol, int zeros_on_left) +digital_ofdm_frame_acquisition::calculate_equalizer(const gr_complex *symbol, int zeros_on_left) { unsigned int i=0; @@ -169,10 +171,10 @@ gr_ofdm_frame_acquisition::calculate_equalizer(const gr_complex *symbol, int zer } int -gr_ofdm_frame_acquisition::general_work(int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) +digital_ofdm_frame_acquisition::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 *symbol = (const gr_complex *)input_items[0]; const char *signal_in = (const char *)input_items[1]; diff --git a/gnuradio-core/src/lib/general/gr_ofdm_frame_sink.cc b/gr-digital/lib/digital_ofdm_frame_sink.cc index 279945766..f8fb1bbb1 100644 --- a/gnuradio-core/src/lib/general/gr_ofdm_frame_sink.cc +++ b/gr-digital/lib/digital_ofdm_frame_sink.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2007,2008,2010 Free Software Foundation, Inc. + * Copyright 2007,2008,2010,2011 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -24,7 +24,7 @@ #include "config.h" #endif -#include <gr_ofdm_frame_sink.h> +#include <digital_ofdm_frame_sink.h> #include <gr_io_signature.h> #include <gr_expj.h> #include <gr_math.h> @@ -37,7 +37,7 @@ #define VERBOSE 0 inline void -gr_ofdm_frame_sink::enter_search() +digital_ofdm_frame_sink::enter_search() { if (VERBOSE) fprintf(stderr, "@ enter_search\n"); @@ -47,7 +47,7 @@ gr_ofdm_frame_sink::enter_search() } inline void -gr_ofdm_frame_sink::enter_have_sync() +digital_ofdm_frame_sink::enter_have_sync() { if (VERBOSE) fprintf(stderr, "@ enter_have_sync\n"); @@ -68,7 +68,7 @@ gr_ofdm_frame_sink::enter_have_sync() } inline void -gr_ofdm_frame_sink::enter_have_header() +digital_ofdm_frame_sink::enter_have_header() { d_state = STATE_HAVE_HEADER; @@ -85,7 +85,7 @@ gr_ofdm_frame_sink::enter_have_header() } -unsigned char gr_ofdm_frame_sink::slicer(const gr_complex x) +unsigned char digital_ofdm_frame_sink::slicer(const gr_complex x) { unsigned int table_size = d_sym_value_out.size(); unsigned int min_index = 0; @@ -102,8 +102,8 @@ unsigned char gr_ofdm_frame_sink::slicer(const gr_complex x) return d_sym_value_out[min_index]; } -unsigned int gr_ofdm_frame_sink::demapper(const gr_complex *in, - unsigned char *out) +unsigned int digital_ofdm_frame_sink::demapper(const gr_complex *in, + unsigned char *out) { unsigned int i=0, bytes_produced=0; gr_complex carrier; @@ -178,22 +178,22 @@ unsigned int gr_ofdm_frame_sink::demapper(const gr_complex *in, } -gr_ofdm_frame_sink_sptr -gr_make_ofdm_frame_sink(const std::vector<gr_complex> &sym_position, - const std::vector<unsigned char> &sym_value_out, - gr_msg_queue_sptr target_queue, unsigned int occupied_carriers, - float phase_gain, float freq_gain) +digital_ofdm_frame_sink_sptr +digital_make_ofdm_frame_sink(const std::vector<gr_complex> &sym_position, + const std::vector<unsigned char> &sym_value_out, + 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_sink(sym_position, sym_value_out, - target_queue, occupied_carriers, - phase_gain, freq_gain)); + return gnuradio::get_initial_sptr(new digital_ofdm_frame_sink(sym_position, sym_value_out, + target_queue, occupied_carriers, + phase_gain, freq_gain)); } -gr_ofdm_frame_sink::gr_ofdm_frame_sink(const std::vector<gr_complex> &sym_position, - const std::vector<unsigned char> &sym_value_out, - gr_msg_queue_sptr target_queue, unsigned int occupied_carriers, - float phase_gain, float freq_gain) +digital_ofdm_frame_sink::digital_ofdm_frame_sink(const std::vector<gr_complex> &sym_position, + const std::vector<unsigned char> &sym_value_out, + gr_msg_queue_sptr target_queue, unsigned int occupied_carriers, + float phase_gain, float freq_gain) : gr_sync_block ("ofdm_frame_sink", gr_make_io_signature2 (2, 2, sizeof(gr_complex)*occupied_carriers, sizeof(char)), gr_make_io_signature (1, 1, sizeof(gr_complex)*occupied_carriers)), @@ -252,7 +252,7 @@ gr_ofdm_frame_sink::gr_ofdm_frame_sink(const std::vector<gr_complex> &sym_positi // 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"); + throw std::invalid_argument("digital_ofdm_mapper_bcv: subcarriers allocated exceeds size of occupied carriers"); } d_bytes_out = new unsigned char[d_occupied_carriers]; @@ -264,14 +264,14 @@ gr_ofdm_frame_sink::gr_ofdm_frame_sink(const std::vector<gr_complex> &sym_positi enter_search(); } -gr_ofdm_frame_sink::~gr_ofdm_frame_sink () +digital_ofdm_frame_sink::~digital_ofdm_frame_sink () { delete [] d_bytes_out; } bool -gr_ofdm_frame_sink::set_sym_value_out(const std::vector<gr_complex> &sym_position, - const std::vector<unsigned char> &sym_value_out) +digital_ofdm_frame_sink::set_sym_value_out(const std::vector<gr_complex> &sym_position, + const std::vector<unsigned char> &sym_value_out) { if (sym_position.size() != sym_value_out.size()) return false; @@ -288,9 +288,9 @@ gr_ofdm_frame_sink::set_sym_value_out(const std::vector<gr_complex> &sym_positio int -gr_ofdm_frame_sink::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) +digital_ofdm_frame_sink::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]; diff --git a/gnuradio-core/src/lib/general/gr_ofdm_insert_preamble.cc b/gr-digital/lib/digital_ofdm_insert_preamble.cc index ed10c94a8..a46133643 100644 --- a/gnuradio-core/src/lib/general/gr_ofdm_insert_preamble.cc +++ b/gr-digital/lib/digital_ofdm_insert_preamble.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2007,2010 Free Software Foundation, Inc. + * Copyright 2007,2010,2011 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -23,21 +23,21 @@ #include <config.h> #endif -#include <gr_ofdm_insert_preamble.h> +#include <digital_ofdm_insert_preamble.h> #include <gr_io_signature.h> #include <stdexcept> #include <iostream> #include <string.h> -gr_ofdm_insert_preamble_sptr -gr_make_ofdm_insert_preamble(int fft_length, - const std::vector<std::vector<gr_complex> > &preamble) +digital_ofdm_insert_preamble_sptr +digital_make_ofdm_insert_preamble(int fft_length, + const std::vector<std::vector<gr_complex> > &preamble) { - return gnuradio::get_initial_sptr(new gr_ofdm_insert_preamble(fft_length, - preamble)); + return gnuradio::get_initial_sptr(new digital_ofdm_insert_preamble(fft_length, + preamble)); } -gr_ofdm_insert_preamble::gr_ofdm_insert_preamble +digital_ofdm_insert_preamble::digital_ofdm_insert_preamble (int fft_length, const std::vector<std::vector<gr_complex> > &preamble) : gr_block("ofdm_insert_preamble", @@ -56,22 +56,22 @@ gr_ofdm_insert_preamble::gr_ofdm_insert_preamble // sanity check preamble symbols for (size_t i = 0; i < d_preamble.size(); i++){ if (d_preamble[i].size() != (size_t) d_fft_length) - throw std::invalid_argument("gr_ofdm_insert_preamble: invalid length for preamble symbol"); + throw std::invalid_argument("digital_ofdm_insert_preamble: invalid length for preamble symbol"); } enter_idle(); } -gr_ofdm_insert_preamble::~gr_ofdm_insert_preamble() +digital_ofdm_insert_preamble::~digital_ofdm_insert_preamble() { } int -gr_ofdm_insert_preamble::general_work (int noutput_items, - gr_vector_int &ninput_items_v, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) +digital_ofdm_insert_preamble::general_work (int noutput_items, + gr_vector_int &ninput_items_v, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) { int ninput_items = std::min(ninput_items_v[0], ninput_items_v[1]); const gr_complex *in_sym = (const gr_complex *) input_items[0]; @@ -149,7 +149,7 @@ gr_ofdm_insert_preamble::general_work (int noutput_items, break; default: - std::cerr << "gr_ofdm_insert_preamble: (can't happen) invalid state, resetting\n"; + std::cerr << "digital_ofdm_insert_preamble: (can't happen) invalid state, resetting\n"; enter_idle(); } } @@ -159,7 +159,7 @@ gr_ofdm_insert_preamble::general_work (int noutput_items, } void -gr_ofdm_insert_preamble::enter_idle() +digital_ofdm_insert_preamble::enter_idle() { d_state = ST_IDLE; d_nsymbols_output = 0; @@ -167,7 +167,7 @@ gr_ofdm_insert_preamble::enter_idle() } void -gr_ofdm_insert_preamble::enter_preamble() +digital_ofdm_insert_preamble::enter_preamble() { d_state = ST_PREAMBLE; d_nsymbols_output = 0; @@ -175,13 +175,13 @@ gr_ofdm_insert_preamble::enter_preamble() } void -gr_ofdm_insert_preamble::enter_first_payload() +digital_ofdm_insert_preamble::enter_first_payload() { d_state = ST_FIRST_PAYLOAD; } void -gr_ofdm_insert_preamble::enter_payload() +digital_ofdm_insert_preamble::enter_payload() { d_state = ST_PAYLOAD; } diff --git a/gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.cc b/gr-digital/lib/digital_ofdm_mapper_bcv.cc index cc4aba0cb..cf3d08703 100644 --- a/gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.cc +++ b/gr-digital/lib/digital_ofdm_mapper_bcv.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2006,2007,2008,2010 Free Software Foundation, Inc. + * Copyright 2006-2008,2010,2011 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -25,22 +25,22 @@ #include "config.h" #endif -#include <gr_ofdm_mapper_bcv.h> +#include <digital_ofdm_mapper_bcv.h> #include <gr_io_signature.h> #include <stdexcept> #include <string.h> -gr_ofdm_mapper_bcv_sptr -gr_make_ofdm_mapper_bcv (const std::vector<gr_complex> &constellation, unsigned int msgq_limit, - unsigned int occupied_carriers, unsigned int fft_length) +digital_ofdm_mapper_bcv_sptr +digital_make_ofdm_mapper_bcv (const std::vector<gr_complex> &constellation, unsigned int msgq_limit, + unsigned int occupied_carriers, unsigned int fft_length) { - return gnuradio::get_initial_sptr(new gr_ofdm_mapper_bcv (constellation, msgq_limit, - occupied_carriers, fft_length)); + return gnuradio::get_initial_sptr(new digital_ofdm_mapper_bcv (constellation, msgq_limit, + occupied_carriers, fft_length)); } // Consumes 1 packet and produces as many OFDM symbols of fft_length to hold the full packet -gr_ofdm_mapper_bcv::gr_ofdm_mapper_bcv (const std::vector<gr_complex> &constellation, unsigned int msgq_limit, - unsigned int occupied_carriers, unsigned int fft_length) +digital_ofdm_mapper_bcv::digital_ofdm_mapper_bcv (const std::vector<gr_complex> &constellation, unsigned int msgq_limit, + unsigned int occupied_carriers, unsigned int fft_length) : gr_sync_block ("ofdm_mapper_bcv", gr_make_io_signature (0, 0, 0), gr_make_io_signature2 (1, 2, sizeof(gr_complex)*fft_length, sizeof(char))), @@ -54,7 +54,7 @@ gr_ofdm_mapper_bcv::gr_ofdm_mapper_bcv (const std::vector<gr_complex> &constella d_nresid(0) { if (!(d_occupied_carriers <= d_fft_length)) - throw std::invalid_argument("gr_ofdm_mapper_bcv: occupied carriers must be <= fft_length"); + throw std::invalid_argument("digital_ofdm_mapper_bcv: occupied carriers must be <= fft_length"); // this is not the final form of this solution since we still use the occupied_tones concept, // which would get us into trouble if the number of carriers we seek is greater than the occupied carriers. @@ -110,25 +110,25 @@ gr_ofdm_mapper_bcv::gr_ofdm_mapper_bcv (const std::vector<gr_complex> &constella // 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"); + throw std::invalid_argument("digital_ofdm_mapper_bcv: subcarriers allocated exceeds size of occupied carriers"); } d_nbits = (unsigned long)ceil(log10(float(d_constellation.size())) / log10(2.0)); } -gr_ofdm_mapper_bcv::~gr_ofdm_mapper_bcv(void) +digital_ofdm_mapper_bcv::~digital_ofdm_mapper_bcv(void) { } -int gr_ofdm_mapper_bcv::randsym() +int digital_ofdm_mapper_bcv::randsym() { return (rand() % d_constellation.size()); } int -gr_ofdm_mapper_bcv::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) +digital_ofdm_mapper_bcv::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) { gr_complex *out = (gr_complex *)output_items[0]; diff --git a/gnuradio-core/src/lib/general/gr_ofdm_sampler.cc b/gr-digital/lib/digital_ofdm_sampler.cc index f9a53c87f..cab8c2ba9 100644 --- a/gnuradio-core/src/lib/general/gr_ofdm_sampler.cc +++ b/gr-digital/lib/digital_ofdm_sampler.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2007,2008,2010 Free Software Foundation, Inc. + * Copyright 2007,2008,2010,2011 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -24,22 +24,22 @@ #include "config.h" #endif -#include <gr_ofdm_sampler.h> +#include <digital_ofdm_sampler.h> #include <gr_io_signature.h> #include <gr_expj.h> #include <cstdio> -gr_ofdm_sampler_sptr -gr_make_ofdm_sampler (unsigned int fft_length, - unsigned int symbol_length, - unsigned int timeout) +digital_ofdm_sampler_sptr +digital_make_ofdm_sampler (unsigned int fft_length, + unsigned int symbol_length, + unsigned int timeout) { - return gnuradio::get_initial_sptr(new gr_ofdm_sampler (fft_length, symbol_length, timeout)); + return gnuradio::get_initial_sptr(new digital_ofdm_sampler (fft_length, symbol_length, timeout)); } -gr_ofdm_sampler::gr_ofdm_sampler (unsigned int fft_length, - unsigned int symbol_length, - unsigned int timeout) +digital_ofdm_sampler::digital_ofdm_sampler (unsigned int fft_length, + unsigned int symbol_length, + unsigned int timeout) : gr_block ("ofdm_sampler", gr_make_io_signature2 (2, 2, sizeof (gr_complex), sizeof(char)), gr_make_io_signature2 (2, 2, sizeof (gr_complex)*fft_length, sizeof(char)*fft_length)), @@ -49,7 +49,7 @@ gr_ofdm_sampler::gr_ofdm_sampler (unsigned int fft_length, } void -gr_ofdm_sampler::forecast (int noutput_items, gr_vector_int &ninput_items_required) +digital_ofdm_sampler::forecast (int noutput_items, gr_vector_int &ninput_items_required) { // FIXME do we need more //int nreqd = (noutput_items-1) * d_symbol_length + d_fft_length; @@ -61,10 +61,10 @@ gr_ofdm_sampler::forecast (int noutput_items, gr_vector_int &ninput_items_requir int -gr_ofdm_sampler::general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) +digital_ofdm_sampler::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 *iptr = (const gr_complex *) input_items[0]; const char *trigger = (const char *) input_items[1]; diff --git a/gr-digital/python/CMakeLists.txt b/gr-digital/python/CMakeLists.txt index 7f810f14d..905626b8b 100644 --- a/gr-digital/python/CMakeLists.txt +++ b/gr-digital/python/CMakeLists.txt @@ -30,11 +30,17 @@ GR_PYTHON_INSTALL( crc.py generic_mod_demod.py gmsk.py - modulation_utils2.py + modulation_utils.py + ofdm.py + ofdm_packet_utils.py + ofdm_receiver.py + ofdm_sync_fixed.py + ofdm_sync_ml.py + ofdm_sync_pnac.py + ofdm_sync_pn.py packet_utils.py pkt.py psk.py - psk2.py qam.py qpsk.py DESTINATION ${GR_PYTHON_DIR}/gnuradio/digital @@ -66,6 +72,6 @@ foreach(py_qa_test_file ${py_qa_test_files}) ${CMAKE_BINARY_DIR}/gr-digital/swig ) set(GR_TEST_TARGET_DEPS gruel gnuradio-core gnuradio-digital) - GR_ADD_TEST(${py_qa_test_name} ${PYTHON_EXECUTABLE} ${py_qa_test_file}) + GR_ADD_TEST(${py_qa_test_name} ${PYTHON_EXECUTABLE} ${PYTHON_DASH_B} ${py_qa_test_file}) endforeach(py_qa_test_file) endif(ENABLE_TESTING) diff --git a/gr-digital/python/Makefile.am b/gr-digital/python/Makefile.am index cd98fe2d4..ead6f7dfd 100644 --- a/gr-digital/python/Makefile.am +++ b/gr-digital/python/Makefile.am @@ -44,7 +44,8 @@ noinst_PYTHON = \ qa_crc32.py \ qa_fll_band_edge.py \ qa_lms_equalizer.py \ - qa_mpsk_receiver.py + qa_mpsk_receiver.py \ + qa_ofdm_insert_preamble.py digital_PYTHON = \ __init__.py \ @@ -53,11 +54,17 @@ digital_PYTHON = \ crc.py \ generic_mod_demod.py \ gmsk.py \ - modulation_utils2.py \ + modulation_utils.py \ + ofdm.py \ + ofdm_packet_utils.py \ + ofdm_receiver.py \ + ofdm_sync_fixed.py \ + ofdm_sync_ml.py \ + ofdm_sync_pnac.py \ + ofdm_sync_pn.py \ packet_utils.py \ pkt.py \ psk.py \ - psk2.py \ qam.py \ qpsk.py endif diff --git a/gr-digital/python/__init__.py b/gr-digital/python/__init__.py index ca46dcfdb..7c76183c9 100644 --- a/gr-digital/python/__init__.py +++ b/gr-digital/python/__init__.py @@ -26,12 +26,21 @@ utilities, and examples for doing digital modulation and demodulation. # The presence of this file turns this directory into a Python package from digital_swig import * -from psk2 import * +from psk import * +from qam import * from bpsk import * from qpsk import * -from qam import * from gmsk import * +from cpm import * from pkt import * from crc import * -from packet_utils import * -from modulation_utils2 import * +from modulation_utils import * +from ofdm import * +from ofdm_receiver import * +from ofdm_sync_fixed import * +from ofdm_sync_ml import * +from ofdm_sync_pnac import * +from ofdm_sync_pn import * + +import packet_utils +import ofdm_packet_utils diff --git a/gr-digital/python/bpsk.py b/gr-digital/python/bpsk.py index 58a8289a5..0d8f05c4c 100644 --- a/gr-digital/python/bpsk.py +++ b/gr-digital/python/bpsk.py @@ -29,7 +29,7 @@ from cmath import exp from gnuradio import gr from gnuradio.digital.generic_mod_demod import generic_mod, generic_demod import digital_swig -import modulation_utils2 +import modulation_utils # Default number of points in constellation. _def_constellation_points = 2 @@ -163,9 +163,9 @@ class dbpsk_demod(generic_demod): # # Add these to the mod/demod registry # -modulation_utils2.add_type_1_mod('bpsk', bpsk_mod) -modulation_utils2.add_type_1_demod('bpsk', bpsk_demod) -modulation_utils2.add_type_1_constellation('bpsk', bpsk_constellation) -modulation_utils2.add_type_1_mod('dbpsk', dbpsk_mod) -modulation_utils2.add_type_1_demod('dbpsk', dbpsk_demod) -modulation_utils2.add_type_1_constellation('dbpsk', dbpsk_constellation) +modulation_utils.add_type_1_mod('bpsk', bpsk_mod) +modulation_utils.add_type_1_demod('bpsk', bpsk_demod) +modulation_utils.add_type_1_constellation('bpsk', bpsk_constellation) +modulation_utils.add_type_1_mod('dbpsk', dbpsk_mod) +modulation_utils.add_type_1_demod('dbpsk', dbpsk_demod) +modulation_utils.add_type_1_constellation('dbpsk', dbpsk_constellation) diff --git a/gr-digital/python/cpm.py b/gr-digital/python/cpm.py index 8f593cd51..05032336d 100644 --- a/gr-digital/python/cpm.py +++ b/gr-digital/python/cpm.py @@ -2,7 +2,7 @@ # CPM modulation and demodulation. # # -# Copyright 2005,2006,2007 Free Software Foundation, Inc. +# Copyright 2005-2007,2011 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -24,12 +24,12 @@ # See gnuradio-examples/python/digital for examples -from gnuradio import gr -from gnuradio import modulation_utils +from gnuradio import gr, blks2 from math import pi import numpy -from pprint import pprint -import inspect + +import digital_swig +import modulation_utils # default values (used in __init__ and add_options) _def_samples_per_symbol = 2 @@ -97,7 +97,7 @@ class cpm_mod(gr.hier_block2): @type debug: bool """ - gr.hier_block2.__init__("cpm_mod", + gr.hier_block2.__init__(self, "cpm_mod", gr.io_signature(1, 1, gr.sizeof_char), # Input signature gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature @@ -116,14 +116,14 @@ class cpm_mod(gr.hier_block2): self._generic_taps=numpy.array(generic_taps) - if not isinstance(samples_per_symbol, int) or samples_per_symbol < 2: - raise TypeError, ("samples_per_symbol must be an integer >= 2, is %r" % (samples_per_symbol,)) + if samples_per_symbol < 2: + raise TypeError, ("samples_per_symbol must be >= 2, is %r" % (samples_per_symbol,)) self.nsymbols = 2**bits_per_symbol - self.sym_alphabet=numpy.arange(-(self.nsymbols-1),self.nsymbols,2) + self.sym_alphabet = numpy.arange(-(self.nsymbols-1),self.nsymbols,2).tolist() - self.ntaps = self._symbols_per_pulse * samples_per_symbol + self.ntaps = int(self._symbols_per_pulse * samples_per_symbol) sensitivity = 2 * pi * h_numerator / h_denominator / samples_per_symbol # Unpack Bytes into bits_per_symbol groups @@ -153,7 +153,7 @@ class cpm_mod(gr.hier_block2): else: raise TypeError, ("cpm_type must be an integer in {0,1,2,3}, is %r" % (cpm_type,)) - self.filter = gr.interp_fir_filter_fff(samples_per_symbol, self.taps) + self.filter = blks2.pfb_arb_resampler_fff(samples_per_symbol, self.taps) # FM modulation self.fmmod = gr.frequency_modulator_fc(sensitivity) @@ -167,26 +167,26 @@ class cpm_mod(gr.hier_block2): # Connect self.connect(self, self.B2s, self.pam, self.filter, self.fmmod, self) - #def samples_per_symbol(self): - #return self._samples_per_symbol + def samples_per_symbol(self): + return self._samples_per_symbol - #def bits_per_symbol(self): - #return self._bits_per_symbol + def bits_per_symbol(self): + return self._bits_per_symbol - #def h_numerator(self): - #return self._h_numerator + def h_numerator(self): + return self._h_numerator - #def h_denominator(self): - #return self._h_denominator + def h_denominator(self): + return self._h_denominator - #def cpm_type(self): - #return self._cpm_type + def cpm_type(self): + return self._cpm_type - #def bt(self): - #return self._bt + def bt(self): + return self._bt - #def symbols_per_pulse(self): - #return self._symbols_per_pulse + def symbols_per_pulse(self): + return self._symbols_per_pulse def _print_verbage(self): @@ -228,7 +228,7 @@ class cpm_mod(gr.hier_block2): Given command line options, create dictionary suitable for passing to __init__ """ return modulation_utils.extract_kwargs_from_options(cpm_mod.__init__, - ('self',), options) + ('self',), options) extract_kwargs_from_options=staticmethod(extract_kwargs_from_options) @@ -240,8 +240,6 @@ class cpm_mod(gr.hier_block2): # Not yet implemented # - - # # Add these to the mod/demod registry # diff --git a/gr-digital/python/generic_mod_demod.py b/gr-digital/python/generic_mod_demod.py index dec96e455..ae876e108 100644 --- a/gr-digital/python/generic_mod_demod.py +++ b/gr-digital/python/generic_mod_demod.py @@ -26,7 +26,7 @@ Generic modulation and demodulation. """ from gnuradio import gr -from modulation_utils2 import extract_kwargs_from_options_for_class +from modulation_utils import extract_kwargs_from_options_for_class from utils import mod_codes import digital_swig import math diff --git a/gr-digital/python/gmsk.py b/gr-digital/python/gmsk.py index c7a50f422..70fa197e3 100644 --- a/gr-digital/python/gmsk.py +++ b/gr-digital/python/gmsk.py @@ -26,7 +26,7 @@ from gnuradio import gr import digital_swig -import modulation_utils2 +import modulation_utils from math import pi import numpy @@ -151,7 +151,7 @@ class gmsk_mod(gr.hier_block2): """ Given command line options, create dictionary suitable for passing to __init__ """ - return modulation_utils2.extract_kwargs_from_options(gmsk_mod.__init__, + return modulation_utils.extract_kwargs_from_options(gmsk_mod.__init__, ('self',), options) extract_kwargs_from_options=staticmethod(extract_kwargs_from_options) @@ -265,12 +265,12 @@ class gmsk_demod(gr.hier_block2): """ Given command line options, create dictionary suitable for passing to __init__ """ - return modulation_utils2.extract_kwargs_from_options(gmsk_demod.__init__, + return modulation_utils.extract_kwargs_from_options(gmsk_demod.__init__, ('self',), options) extract_kwargs_from_options=staticmethod(extract_kwargs_from_options) # # Add these to the mod/demod registry # -modulation_utils2.add_type_1_mod('gmsk', gmsk_mod) -modulation_utils2.add_type_1_demod('gmsk', gmsk_demod) +modulation_utils.add_type_1_mod('gmsk', gmsk_mod) +modulation_utils.add_type_1_demod('gmsk', gmsk_demod) diff --git a/gr-digital/python/modulation_utils2.py b/gr-digital/python/modulation_utils.py index cb3a9812d..cb3a9812d 100644 --- a/gr-digital/python/modulation_utils2.py +++ b/gr-digital/python/modulation_utils.py diff --git a/gr-digital/python/ofdm.py b/gr-digital/python/ofdm.py index e05f074f4..9f57920ef 100644 --- a/gr-digital/python/ofdm.py +++ b/gr-digital/python/ofdm.py @@ -21,32 +21,13 @@ # import math -from gnuradio import gr, ofdm_packet_utils, modulation_utils2 +from gnuradio import gr +import digital_swig +import ofdm_packet_utils +from ofdm_receiver import ofdm_receiver import gnuradio.gr.gr_threading as _threading import psk, qam -from gnuradio.blks2impl.ofdm_receiver import ofdm_receiver - -def _add_common_options(normal, expert): - """ - Adds OFDM-specific options to the Options Parser that are common - both to the modulator and demodulator. - """ - mods_list = ", ".join(modulation_utils2.type_1_constellations().keys()) - print dir(modulation_utils2) - print "MODS LIST: ", mods_list - print modulation_utils2.type_1_mods() - normal.add_option("-m", "--modulation", type="string", default="psk", - help="set modulation type (" + mods_list + ") [default=%default]") - normal.add_option("-c", "--constellation-points", type="int", default=2, - help="set number of constellation points [default=%default]") - expert.add_option("", "--fft-length", type="intx", default=512, - help="set the number of FFT bins [default=%default]") - expert.add_option("", "--occupied-tones", type="intx", default=200, - help="set the number of occupied FFT bins [default=%default]") - expert.add_option("", "--cp-length", type="intx", default=128, - help="set the number of bits in the cyclic prefix [default=%default]") - # ///////////////////////////////////////////////////////////////////////////// # mod/demod with packets as i/o # ///////////////////////////////////////////////////////////////////////////// @@ -81,9 +62,6 @@ class ofdm_mod(gr.hier_block2): self._occupied_tones = options.occupied_tones self._cp_length = options.cp_length - print (options) - arity = options.constellation_points - win = [] #[1 for i in range(self._fft_length)] # Use freq domain to get doubled-up known symbol for correlation in time domain @@ -104,15 +82,31 @@ class ofdm_mod(gr.hier_block2): symbol_length = options.fft_length + options.cp_length - print modulation_utils2.type_1_constellations - const = modulation_utils2.type_1_constellations()[self._modulation](arity).points() - - self._pkt_input = gr.ofdm_mapper_bcv(const, msgq_limit, - options.occupied_tones, options.fft_length) + mods = {"bpsk": 2, "qpsk": 4, "8psk": 8, "qam8": 8, "qam16": 16, "qam64": 64, "qam256": 256} + arity = mods[self._modulation] - self.preambles = gr.ofdm_insert_preamble(self._fft_length, padded_preambles) + rot = 1 + if self._modulation == "qpsk": + rot = (0.707+0.707j) + + # FIXME: pass the constellation objects instead of just the points + if(self._modulation.find("psk") >= 0): + constel = psk.psk_constellation(arity) + rotated_const = map(lambda pt: pt * rot, constel.points()) + elif(self._modulation.find("qam") >= 0): + constel = qam.qam_constellation(arity) + rotated_const = map(lambda pt: pt * rot, constel.points()) + #print rotated_const + self._pkt_input = digital_swig.ofdm_mapper_bcv(rotated_const, + msgq_limit, + options.occupied_tones, + options.fft_length) + + self.preambles = digital_swig.ofdm_insert_preamble(self._fft_length, + padded_preambles) self.ifft = gr.fft_vcc(self._fft_length, False, win, True) - self.cp_adder = gr.ofdm_cyclic_prefixer(self._fft_length, symbol_length) + self.cp_adder = digital_swig.ofdm_cyclic_prefixer(self._fft_length, + symbol_length) self.scale = gr.multiply_const_cc(1.0 / math.sqrt(self._fft_length)) self.connect((self._pkt_input, 0), (self.preambles, 0)) @@ -143,7 +137,9 @@ class ofdm_mod(gr.hier_block2): msg = gr.message(1) # tell self._pkt_input we're not sending any more packets else: # print "original_payload =", string_to_hex_list(payload) - pkt = ofdm_packet_utils.make_packet(payload, 1, 1, self._pad_for_usrp, whitening=True) + pkt = ofdm_packet_utils.make_packet(payload, 1, 1, + self._pad_for_usrp, + whitening=True) #print "pkt =", string_to_hex_list(pkt) msg = gr.message_from_string(pkt) @@ -153,10 +149,14 @@ class ofdm_mod(gr.hier_block2): """ Adds OFDM-specific options to the Options Parser """ - _add_common_options(normal, expert) - for mod in modulation_utils2.type_1_mods().values(): - mod.add_options(expert) - + normal.add_option("-m", "--modulation", type="string", default="bpsk", + help="set modulation type (bpsk, qpsk, 8psk, qam{16,64}) [default=%default]") + expert.add_option("", "--fft-length", type="intx", default=512, + help="set the number of FFT bins [default=%default]") + expert.add_option("", "--occupied-tones", type="intx", default=200, + help="set the number of occupied FFT bins [default=%default]") + expert.add_option("", "--cp-length", type="intx", default=128, + help="set the number of bits in the cyclic prefix [default=%default]") # Make a static method to call before instantiation add_options = staticmethod(add_options) @@ -205,9 +205,6 @@ class ofdm_demod(gr.hier_block2): self._cp_length = options.cp_length self._snr = options.snr - arity = options.constellation_points - print("con points is %s" % options.constellation_points) - # Use freq domain to get doubled-up known symbol for correlation in time domain zeros_on_left = int(math.ceil((self._fft_length - self._occupied_tones)/2.0)) ksfreq = known_symbols_4512_3[0:self._occupied_tones] @@ -217,20 +214,36 @@ class ofdm_demod(gr.hier_block2): # hard-coded known symbols preambles = (ksfreq,) - + symbol_length = self._fft_length + self._cp_length - self.ofdm_recv = ofdm_receiver(self._fft_length, self._cp_length, - self._occupied_tones, self._snr, preambles, + self.ofdm_recv = ofdm_receiver(self._fft_length, + self._cp_length, + self._occupied_tones, + self._snr, preambles, options.log) - constell = modulation_utils2.type_1_constellations()[self._modulation](arity) + mods = {"bpsk": 2, "qpsk": 4, "8psk": 8, "qam8": 8, "qam16": 16, "qam64": 64, "qam256": 256} + arity = mods[self._modulation] + + rot = 1 + if self._modulation == "qpsk": + rot = (0.707+0.707j) + + # FIXME: pass the constellation objects instead of just the points + if(self._modulation.find("psk") >= 0): + constel = psk.psk_constellation(arity) + rotated_const = map(lambda pt: pt * rot, constel.points()) + elif(self._modulation.find("qam") >= 0): + constel = qam.qam_constellation(arity) + rotated_const = map(lambda pt: pt * rot, constel.points()) + #print rotated_const phgain = 0.25 frgain = phgain*phgain / 4.0 - self.ofdm_demod = gr.ofdm_frame_sink2(constell.base(), - self._rcvd_pktq, - self._occupied_tones, - phgain, frgain) + self.ofdm_demod = digital_swig.ofdm_frame_sink(rotated_const, range(arity), + self._rcvd_pktq, + self._occupied_tones, + phgain, frgain) self.connect(self, self.ofdm_recv) self.connect((self.ofdm_recv, 0), (self.ofdm_demod, 0)) @@ -241,9 +254,12 @@ class ofdm_demod(gr.hier_block2): self.connect(self.ofdm_recv.chan_filt, self) if options.log: - self.connect(self.ofdm_demod, gr.file_sink(gr.sizeof_gr_complex*self._occupied_tones, "ofdm_frame_sink_c.dat")) + self.connect(self.ofdm_demod, + gr.file_sink(gr.sizeof_gr_complex*self._occupied_tones, + "ofdm_frame_sink_c.dat")) else: - self.connect(self.ofdm_demod, gr.null_sink(gr.sizeof_gr_complex*self._occupied_tones)) + self.connect(self.ofdm_demod, + gr.null_sink(gr.sizeof_gr_complex*self._occupied_tones)) if options.verbose: self._print_verbage() @@ -254,9 +270,16 @@ class ofdm_demod(gr.hier_block2): """ Adds OFDM-specific options to the Options Parser """ - _add_common_options(normal, expert) - for mod in modulation_utils2.type_1_mods().values(): - mod.add_options(expert) + normal.add_option("-m", "--modulation", type="string", default="bpsk", + help="set modulation type (bpsk or qpsk) [default=%default]") + expert.add_option("", "--fft-length", type="intx", default=512, + help="set the number of FFT bins [default=%default]") + expert.add_option("", "--occupied-tones", type="intx", default=200, + help="set the number of occupied FFT bins [default=%default]") + expert.add_option("", "--cp-length", type="intx", default=128, + help="set the number of bits in the cyclic prefix [default=%default]") + expert.add_option("", "--snr", type="float", default=30.0, + help="SNR estimate [default=%default]") # Make a static method to call before instantiation add_options = staticmethod(add_options) diff --git a/gnuradio-core/src/python/gnuradio/ofdm_packet_utils.py b/gr-digital/python/ofdm_packet_utils.py index f151ffe74..d0000e6db 100644 --- a/gnuradio-core/src/python/gnuradio/ofdm_packet_utils.py +++ b/gr-digital/python/ofdm_packet_utils.py @@ -22,6 +22,7 @@ import struct import numpy from gnuradio import gru +import crc def conv_packed_binary_string_to_1_0_string(s): """ @@ -116,7 +117,7 @@ def make_packet(payload, samples_per_symbol, bits_per_symbol, if not whitener_offset >=0 and whitener_offset < 16: raise ValueError, "whitener_offset must be between 0 and 15, inclusive (%i)" % (whitener_offset,) - payload_with_crc = gru.gen_and_append_crc32(payload) + payload_with_crc = crc.gen_and_append_crc32(payload) #print "outbound crc =", string_to_hex_list(payload_with_crc[-4:]) L = len(payload_with_crc) @@ -180,7 +181,7 @@ def unmake_packet(whitened_payload_with_crc, whitener_offset=0, dewhitening=1): else: payload_with_crc = whitened_payload_with_crc - ok, payload = gru.check_crc32(payload_with_crc) + ok, payload = crc.check_crc32(payload_with_crc) if 0: print "payload_with_crc =", string_to_hex_list(payload_with_crc) diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/ofdm_receiver.py b/gr-digital/python/ofdm_receiver.py index 56ae0c0f0..9d4d6e559 100644 --- a/gnuradio-core/src/python/gnuradio/blks2impl/ofdm_receiver.py +++ b/gr-digital/python/ofdm_receiver.py @@ -23,10 +23,12 @@ import math from numpy import fft from gnuradio import gr -from gnuradio.blks2impl.ofdm_sync_ml import ofdm_sync_ml -from gnuradio.blks2impl.ofdm_sync_pn import ofdm_sync_pn -from gnuradio.blks2impl.ofdm_sync_pnac import ofdm_sync_pnac -from gnuradio.blks2impl.ofdm_sync_fixed import ofdm_sync_fixed + +import digital_swig +from ofdm_sync_pn import ofdm_sync_pn +from ofdm_sync_fixed import ofdm_sync_fixed +from ofdm_sync_pnac import ofdm_sync_pnac +from ofdm_sync_ml import ofdm_sync_ml class ofdm_receiver(gr.hier_block2): """ @@ -85,29 +87,45 @@ class ofdm_receiver(gr.hier_block2): SYNC = "pn" if SYNC == "ml": - nco_sensitivity = -1.0/fft_length # correct for fine frequency - self.ofdm_sync = ofdm_sync_ml(fft_length, cp_length, snr, ks0time, logging) + nco_sensitivity = -1.0/fft_length # correct for fine frequency + self.ofdm_sync = ofdm_sync_ml(fft_length, + cp_length, + snr, + ks0time, + logging) elif SYNC == "pn": - nco_sensitivity = -2.0/fft_length # correct for fine frequency - self.ofdm_sync = ofdm_sync_pn(fft_length, cp_length, logging) + nco_sensitivity = -2.0/fft_length # correct for fine frequency + self.ofdm_sync = ofdm_sync_pn(fft_length, + cp_length, + logging) elif SYNC == "pnac": - nco_sensitivity = -2.0/fft_length # correct for fine frequency - self.ofdm_sync = ofdm_sync_pnac(fft_length, cp_length, ks0time, logging) - elif SYNC == "fixed": # for testing only; do not user over the air - self.chan_filt = gr.multiply_const_cc(1.0) # remove filter and filter delay for this - nsymbols = 18 # enter the number of symbols per packet - freq_offset = 0.0 # if you use a frequency offset, enter it here - nco_sensitivity = -2.0/fft_length # correct for fine frequency - self.ofdm_sync = ofdm_sync_fixed(fft_length, cp_length, nsymbols, freq_offset, logging) + nco_sensitivity = -2.0/fft_length # correct for fine frequency + self.ofdm_sync = ofdm_sync_pnac(fft_length, + cp_length, + ks0time, + logging) + # for testing only; do not user over the air + # remove filter and filter delay for this + elif SYNC == "fixed": + self.chan_filt = gr.multiply_const_cc(1.0) + nsymbols = 18 # enter the number of symbols per packet + freq_offset = 0.0 # if you use a frequency offset, enter it here + nco_sensitivity = -2.0/fft_length # correct for fine frequency + self.ofdm_sync = ofdm_sync_fixed(fft_length, + cp_length, + nsymbols, + freq_offset, + logging) # Set up blocks self.nco = gr.frequency_modulator_fc(nco_sensitivity) # generate a signal proportional to frequency error of sync block self.sigmix = gr.multiply_cc() - self.sampler = gr.ofdm_sampler(fft_length, fft_length+cp_length) + self.sampler = digital_swig.ofdm_sampler(fft_length, fft_length+cp_length) self.fft_demod = gr.fft_vcc(fft_length, True, win, True) - self.ofdm_frame_acq = gr.ofdm_frame_acquisition(occupied_tones, fft_length, - cp_length, ks[0]) + self.ofdm_frame_acq = digital_swig.ofdm_frame_acquisition(occupied_tones, + fft_length, + cp_length, ks[0]) self.connect(self, self.chan_filt) # filter the input channel self.connect(self.chan_filt, self.ofdm_sync) # into the synchronization alg. diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/ofdm_sync_fixed.py b/gr-digital/python/ofdm_sync_fixed.py index 9bac789bf..9bac789bf 100644 --- a/gnuradio-core/src/python/gnuradio/blks2impl/ofdm_sync_fixed.py +++ b/gr-digital/python/ofdm_sync_fixed.py diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/ofdm_sync_ml.py b/gr-digital/python/ofdm_sync_ml.py index 7c75d7f1d..7c75d7f1d 100644 --- a/gnuradio-core/src/python/gnuradio/blks2impl/ofdm_sync_ml.py +++ b/gr-digital/python/ofdm_sync_ml.py diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/ofdm_sync_pn.py b/gr-digital/python/ofdm_sync_pn.py index 05b1de2e1..05b1de2e1 100644 --- a/gnuradio-core/src/python/gnuradio/blks2impl/ofdm_sync_pn.py +++ b/gr-digital/python/ofdm_sync_pn.py diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/ofdm_sync_pnac.py b/gr-digital/python/ofdm_sync_pnac.py index 10a125964..10a125964 100644 --- a/gnuradio-core/src/python/gnuradio/blks2impl/ofdm_sync_pnac.py +++ b/gr-digital/python/ofdm_sync_pnac.py diff --git a/gr-digital/python/psk.py b/gr-digital/python/psk.py index acedf3b69..58f6787f0 100644 --- a/gr-digital/python/psk.py +++ b/gr-digital/python/psk.py @@ -1,5 +1,5 @@ # -# Copyright 2005,2006 Free Software Foundation, Inc. +# Copyright 2005,2006,2011 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -19,76 +19,104 @@ # Boston, MA 02110-1301, USA. # -from math import pi, sqrt, log10 -import math, cmath - -# The following algorithm generates Gray coded constellations for M-PSK for M=[2,4,8] -def make_gray_constellation(m): - # number of bits/symbol (log2(M)) - k = int(log10(m) / log10(2.0)) - - coeff = 1 - const_map = [] - bits = [0]*3 - for i in range(m): - # get a vector of the k bits to use in this mapping - bits[3-k:3] = [((i&(0x01 << k-j-1)) >> k-j-1) for j in range(k)] - - theta = -(2*bits[0]-1)*(2*pi/m)*(bits[0]+abs(bits[1]-bits[2])+2*bits[1]) - re = math.cos(theta) - im = math.sin(theta) - const_map.append(complex(re, im)) # plug it into the constellation +""" +PSK modulation and demodulation. +""" + +from math import pi, log +from cmath import exp + +import digital_swig +import modulation_utils +from utils import mod_codes, gray_code +from generic_mod_demod import generic_mod, generic_demod + +# Default number of points in constellation. +_def_constellation_points = 4 +# The default encoding (e.g. gray-code, set-partition) +_def_mod_code = mod_codes.GRAY_CODE + +def create_encodings(mod_code, arity): + post_diff_code = None + if mod_code not in mod_codes.codes: + raise ValueError('That modulation code does not exist.') + if mod_code == mod_codes.GRAY_CODE: + pre_diff_code = gray_code.gray_code(arity) + elif mod_code == mod_codes.SET_PARTITION_CODE: + pre_diff_code = set_partition_code.set_partition_code(arity) + elif mod_code == mod_codes.NO_CODE: + pre_diff_code = [] + else: + raise ValueError('That modulation code is not implemented for this constellation.') + return (pre_diff_code, post_diff_code) - # return the constellation; by default, it is normalized - return const_map - -# This makes a constellation that increments around the unit circle -def make_constellation(m): - return [cmath.exp(i * 2 * pi / m * 1j) for i in range(m)] - -# Common definition of constellations for Tx and Rx -constellation = { - 2 : make_constellation(2), # BPSK - 4 : make_constellation(4), # QPSK - 8 : make_constellation(8) # 8PSK - } - -gray_constellation = { - 2 : make_gray_constellation(2), # BPSK - 4 : make_gray_constellation(4), # QPSK - 8 : make_gray_constellation(8) # 8PSK - } - -# ----------------------- -# Do Gray code -# ----------------------- -# binary to gray coding -- constellation does Gray coding -binary_to_gray = { - 2 : range(2), - 4 : [0,1,3,2], - 8 : [0, 1, 3, 2, 7, 6, 4, 5] - } - -# gray to binary -gray_to_binary = { - 2 : range(2), - 4 : [0,1,3,2], - 8 : [0, 1, 3, 2, 6, 7, 5, 4] - } - -# ----------------------- -# Don't Gray code -# ----------------------- -# identity mapping -binary_to_ungray = { - 2 : range(2), - 4 : range(4), - 8 : range(8) - } - -# identity mapping -ungray_to_binary = { - 2 : range(2), - 4 : range(4), - 8 : range(8) - } +# ///////////////////////////////////////////////////////////////////////////// +# PSK constellation +# ///////////////////////////////////////////////////////////////////////////// + +def psk_constellation(m=_def_constellation_points, mod_code=_def_mod_code): + """ + Creates a PSK constellation object. + """ + k = log(m) / log(2.0) + if (k != int(k)): + raise StandardError('Number of constellation points must be a power of two.') + points = [exp(2*pi*(0+1j)*i/m) for i in range(0,m)] + pre_diff_code, post_diff_code = create_encodings(mod_code, m) + if post_diff_code is not None: + inverse_post_diff_code = mod_codes.invert_code(post_diff_code) + points = [points[x] for x in inverse_post_diff_code] + constellation = digital_swig.constellation_psk(points, pre_diff_code, m) + return constellation + +# ///////////////////////////////////////////////////////////////////////////// +# PSK modulator +# ///////////////////////////////////////////////////////////////////////////// + +class psk_mod(generic_mod): + + def __init__(self, constellation_points=_def_constellation_points, + mod_code=_def_mod_code, + *args, **kwargs): + + """ + Hierarchical block for RRC-filtered PSK modulation. + + The input is a byte stream (unsigned char) and the + output is the complex modulated signal at baseband. + + See generic_mod block for list of parameters. + """ + + constellation = psk_constellation(constellation_points, mod_code) + super(psk_mod, self).__init__(constellation, *args, **kwargs) + +# ///////////////////////////////////////////////////////////////////////////// +# PSK demodulator +# +# ///////////////////////////////////////////////////////////////////////////// + +class psk_demod(generic_demod): + + def __init__(self, constellation_points=_def_constellation_points, + mod_code=_def_mod_code, + *args, **kwargs): + + """ + Hierarchical block for RRC-filtered PSK modulation. + + The input is a byte stream (unsigned char) and the + output is the complex modulated signal at baseband. + + See generic_demod block for list of parameters. + """ + + constellation = psk_constellation(constellation_points, mod_code) + super(psk_demod, self).__init__(constellation, *args, **kwargs) + +# +# Add these to the mod/demod registry +# +modulation_utils.add_type_1_mod('psk', psk_mod) +modulation_utils.add_type_1_demod('psk', psk_demod) +modulation_utils.add_type_1_constellation('psk', psk_constellation) diff --git a/gr-digital/python/psk2.py b/gr-digital/python/psk2.py deleted file mode 100644 index 82781e63b..000000000 --- a/gr-digital/python/psk2.py +++ /dev/null @@ -1,122 +0,0 @@ -# -# Copyright 2005,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. -# - -""" -PSK modulation and demodulation. -""" - -from math import pi, log -from cmath import exp - -import digital_swig -import modulation_utils2 -from utils import mod_codes, gray_code -from generic_mod_demod import generic_mod, generic_demod - -# Default number of points in constellation. -_def_constellation_points = 4 -# The default encoding (e.g. gray-code, set-partition) -_def_mod_code = mod_codes.GRAY_CODE - -def create_encodings(mod_code, arity): - post_diff_code = None - if mod_code not in mod_codes.codes: - raise ValueError('That modulation code does not exist.') - if mod_code == mod_codes.GRAY_CODE: - pre_diff_code = gray_code.gray_code(arity) - elif mod_code == mod_codes.SET_PARTITION_CODE: - pre_diff_code = set_partition_code.set_partition_code(arity) - elif mod_code == mod_codes.NO_CODE: - pre_diff_code = [] - else: - raise ValueError('That modulation code is not implemented for this constellation.') - return (pre_diff_code, post_diff_code) - -# ///////////////////////////////////////////////////////////////////////////// -# PSK constellation -# ///////////////////////////////////////////////////////////////////////////// - -def psk_constellation(m=_def_constellation_points, mod_code=_def_mod_code): - """ - Creates a PSK constellation object. - """ - k = log(m) / log(2.0) - if (k != int(k)): - raise StandardError('Number of constellation points must be a power of two.') - points = [exp(2*pi*(0+1j)*i/m) for i in range(0,m)] - pre_diff_code, post_diff_code = create_encodings(mod_code, m) - if post_diff_code is not None: - inverse_post_diff_code = mod_codes.invert_code(post_diff_code) - points = [points[x] for x in inverse_post_diff_code] - constellation = digital_swig.constellation_psk(points, pre_diff_code, m) - return constellation - -# ///////////////////////////////////////////////////////////////////////////// -# PSK modulator -# ///////////////////////////////////////////////////////////////////////////// - -class psk_mod(generic_mod): - - def __init__(self, constellation_points=_def_constellation_points, - mod_code=_def_mod_code, - *args, **kwargs): - - """ - Hierarchical block for RRC-filtered PSK modulation. - - The input is a byte stream (unsigned char) and the - output is the complex modulated signal at baseband. - - See generic_mod block for list of parameters. - """ - - constellation = psk_constellation(constellation_points, mod_code) - super(psk_mod, self).__init__(constellation, *args, **kwargs) - -# ///////////////////////////////////////////////////////////////////////////// -# PSK demodulator -# -# ///////////////////////////////////////////////////////////////////////////// - -class psk_demod(generic_demod): - - def __init__(self, constellation_points=_def_constellation_points, - mod_code=_def_mod_code, - *args, **kwargs): - - """ - Hierarchical block for RRC-filtered PSK modulation. - - The input is a byte stream (unsigned char) and the - output is the complex modulated signal at baseband. - - See generic_demod block for list of parameters. - """ - - constellation = psk_constellation(constellation_points, mod_code) - super(psk_demod, self).__init__(constellation, *args, **kwargs) - -# -# Add these to the mod/demod registry -# -modulation_utils2.add_type_1_mod('psk', psk_mod) -modulation_utils2.add_type_1_demod('psk', psk_demod) -modulation_utils2.add_type_1_constellation('psk', psk_constellation) diff --git a/gr-digital/python/qa_clock_recovery_mm.py b/gr-digital/python/qa_clock_recovery_mm.py index 5ef86eda0..f4c345b03 100755 --- a/gr-digital/python/qa_clock_recovery_mm.py +++ b/gr-digital/python/qa_clock_recovery_mm.py @@ -21,7 +21,7 @@ # from gnuradio import gr, gr_unittest -import digital_swig, psk2 +import digital_swig import random, cmath class test_clock_recovery_mm(gr_unittest.TestCase): diff --git a/gr-digital/python/qa_constellation.py b/gr-digital/python/qa_constellation.py index 264ff7de6..b17d2a0fc 100755 --- a/gr-digital/python/qa_constellation.py +++ b/gr-digital/python/qa_constellation.py @@ -28,7 +28,7 @@ from utils import mod_codes import digital_swig # import from local folder -import psk2 +import psk import qam tested_mod_codes = (mod_codes.NO_CODE, mod_codes.GRAY_CODE) @@ -65,7 +65,7 @@ def threed_constell(): return digital_swig.constellation_calcdist(points, [], rot_sym, dim) tested_constellation_info = ( - (psk2.psk_constellation, + (psk.psk_constellation, {'m': (2, 4, 8, 16, 32, 64), 'mod_code': tested_mod_codes, }, True, None), diff --git a/gr-digital/python/qa_costas_loop_cc.py b/gr-digital/python/qa_costas_loop_cc.py index 124159dba..75fdbc2f8 100755 --- a/gr-digital/python/qa_costas_loop_cc.py +++ b/gr-digital/python/qa_costas_loop_cc.py @@ -21,7 +21,7 @@ # from gnuradio import gr, gr_unittest -import digital_swig, psk2 +import digital_swig, psk import random, cmath class test_costas_loop_cc(gr_unittest.TestCase): @@ -125,7 +125,7 @@ class test_costas_loop_cc(gr_unittest.TestCase): self.test = digital_swig.costas_loop_cc(natfreq, order) rot = cmath.exp(-cmath.pi/8.0j) # rotate to match Costas rotation - const = psk2.psk_constellation(order) + const = psk.psk_constellation(order) data = [random.randint(0,7) for i in xrange(100)] data = [2*rot*const.points()[d] for d in data] diff --git a/gr-digital/python/qa_mpsk_receiver.py b/gr-digital/python/qa_mpsk_receiver.py index 6531e59f7..e1f16ee67 100755 --- a/gr-digital/python/qa_mpsk_receiver.py +++ b/gr-digital/python/qa_mpsk_receiver.py @@ -21,7 +21,7 @@ # from gnuradio import gr, gr_unittest -import digital_swig, psk2 +import digital_swig import random, cmath class test_mpsk_receiver(gr_unittest.TestCase): diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_ofdm_insert_preamble.py b/gr-digital/python/qa_ofdm_insert_preamble.py index d69f5ca5b..c45893fa3 100755 --- a/gnuradio-core/src/python/gnuradio/gr/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 Free Software Foundation, Inc. +# Copyright 2007,2010,2011 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -22,6 +22,7 @@ from gnuradio import gr, gr_unittest from pprint import pprint +import digital_swig class test_ofdm_insert_preamble (gr_unittest.TestCase): @@ -40,7 +41,7 @@ class test_ofdm_insert_preamble (gr_unittest.TestCase): # print "len(v) = %d" % (len(v)) - op = gr.ofdm_insert_preamble(fft_length, preamble) + op = digital_swig.ofdm_insert_preamble(fft_length, preamble) v2s = gr.vector_to_stream(gr.sizeof_gr_complex, fft_length) dst0 = gr.vector_sink_c() diff --git a/gr-digital/python/qam.py b/gr-digital/python/qam.py index a5a2e6c2c..5b1f7683b 100644 --- a/gr-digital/python/qam.py +++ b/gr-digital/python/qam.py @@ -29,7 +29,8 @@ from gnuradio import gr from generic_mod_demod import generic_mod, generic_demod from utils.gray_code import gray_code from utils import mod_codes -import modulation_utils2 +import modulation_utils +import digital_swig # Default number of points in constellation. _def_constellation_points = 16 @@ -164,7 +165,8 @@ def qam_constellation(constellation_points=_def_constellation_points, # No pre-diff code # Should add one so that we can gray-code the quadrant bits too. pre_diff_code = [] - constellation = gr.constellation_rect(points, pre_diff_code, 4, side, side, width, width) + constellation = digital_swig.constellation_rect(points, pre_diff_code, 4, + side, side, width, width) return constellation # ///////////////////////////////////////////////////////////////////////////// @@ -222,6 +224,6 @@ class qam_demod(generic_demod): # # Add these to the mod/demod registry # -modulation_utils2.add_type_1_mod('qam', qam_mod) -modulation_utils2.add_type_1_demod('qam', qam_demod) -modulation_utils2.add_type_1_constellation('qam', qam_constellation) +modulation_utils.add_type_1_mod('qam', qam_mod) +modulation_utils.add_type_1_demod('qam', qam_demod) +modulation_utils.add_type_1_constellation('qam', qam_constellation) diff --git a/gr-digital/python/qpsk.py b/gr-digital/python/qpsk.py index 481b7cb5b..be21fd76f 100644 --- a/gr-digital/python/qpsk.py +++ b/gr-digital/python/qpsk.py @@ -28,7 +28,7 @@ Demodulation is not included since the generic_mod_demod from gnuradio import gr from gnuradio.digital.generic_mod_demod import generic_mod, generic_demod import digital_swig -import modulation_utils2 +import modulation_utils # Default number of points in constellation. _def_constellation_points = 4 @@ -167,10 +167,10 @@ class dqpsk_demod(generic_demod): # # Add these to the mod/demod registry # -modulation_utils2.add_type_1_mod('qpsk', qpsk_mod) -modulation_utils2.add_type_1_demod('qpsk', qpsk_demod) -modulation_utils2.add_type_1_constellation('qpsk', qpsk_constellation) -modulation_utils2.add_type_1_mod('dqpsk', dqpsk_mod) -modulation_utils2.add_type_1_demod('dqpsk', dqpsk_demod) -modulation_utils2.add_type_1_constellation('dqpsk', dqpsk_constellation) +modulation_utils.add_type_1_mod('qpsk', qpsk_mod) +modulation_utils.add_type_1_demod('qpsk', qpsk_demod) +modulation_utils.add_type_1_constellation('qpsk', qpsk_constellation) +modulation_utils.add_type_1_mod('dqpsk', dqpsk_mod) +modulation_utils.add_type_1_demod('dqpsk', dqpsk_demod) +modulation_utils.add_type_1_constellation('dqpsk', dqpsk_constellation) diff --git a/gr-digital/swig/CMakeLists.txt b/gr-digital/swig/CMakeLists.txt index 3df218d6e..4f4e51e33 100644 --- a/gr-digital/swig/CMakeLists.txt +++ b/gr-digital/swig/CMakeLists.txt @@ -54,6 +54,12 @@ install( digital_lms_dd_equalizer_cc.i digital_kurtotic_equalizer_cc.i digital_mpsk_receiver_cc.i + digital_ofdm_cyclic_prefixer.i + digital_ofdm_frame_acquisition.i + digital_ofdm_frame_sink.i + digital_ofdm_insert_preamble.i + digital_ofdm_mapper_bcv.i + digital_ofdm_sampler.i digital_gmskmod_bc.i digital_cpmmod_bc.i DESTINATION ${GR_INCLUDE_DIR}/gnuradio/swig diff --git a/gr-digital/swig/Makefile.am b/gr-digital/swig/Makefile.am index abc24be19..1afa44743 100644 --- a/gr-digital/swig/Makefile.am +++ b/gr-digital/swig/Makefile.am @@ -71,6 +71,12 @@ digital_swig_swiginclude_headers = \ digital_lms_dd_equalizer_cc.i \ digital_kurtotic_equalizer_cc.i \ digital_mpsk_receiver_cc.i \ + digital_ofdm_cyclic_prefixer.i \ + digital_ofdm_frame_acquisition.i \ + digital_ofdm_frame_sink.i \ + digital_ofdm_insert_preamble.i \ + digital_ofdm_mapper_bcv.i \ + digital_ofdm_sampler.i \ digital_gmskmod_bc.i \ digital_cpmmod_bc.i diff --git a/gnuradio-core/src/lib/general/gr_ofdm_demapper_vcb.i b/gr-digital/swig/digital_ofdm_cyclic_prefixer.i index e786c70f5..56d1629a8 100644 --- a/gnuradio-core/src/lib/general/gr_ofdm_demapper_vcb.i +++ b/gr-digital/swig/digital_ofdm_cyclic_prefixer.i @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2006 Free Software Foundation, Inc. + * Copyright 2006,2009,2011 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,17 +20,15 @@ * Boston, MA 02110-1301, USA. */ -GR_SWIG_BLOCK_MAGIC(gr,ofdm_mapper_bcv) +GR_SWIG_BLOCK_MAGIC(digital,ofdm_cyclic_prefixer) -gr_ofdm_mapper_bcv_sptr -gr_make_ofdm_mapper_bcv (unsigned int bits_per_symbol, - unsigned int vlen); +digital_ofdm_cyclic_prefixer_sptr +digital_make_ofdm_cyclic_prefixer (size_t input_size, size_t output_size); -class gr_ofdm_mapper_bcv : public gr_sync_decimator +class digital_ofdm_cyclic_prefixer : public gr_sync_interpolator { protected: - gr_ofdm_mapper_bcv (unsigned int bits_per_symbol, - unsigned int vlen); + digital_ofdm_cyclic_prefixer (size_t input_size, size_t output_size); public: }; diff --git a/gnuradio-core/src/lib/general/gr_ofdm_frame_acquisition.i b/gr-digital/swig/digital_ofdm_frame_acquisition.i index 0fd0bc58b..b61297bde 100644 --- a/gnuradio-core/src/lib/general/gr_ofdm_frame_acquisition.i +++ b/gr-digital/swig/digital_ofdm_frame_acquisition.i @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2006, 2007 Free Software Foundation, Inc. + * Copyright 2006,2007,2011 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -22,23 +22,23 @@ #include <vector> -GR_SWIG_BLOCK_MAGIC(gr,ofdm_frame_acquisition); +GR_SWIG_BLOCK_MAGIC(digital,ofdm_frame_acquisition); -gr_ofdm_frame_acquisition_sptr -gr_make_ofdm_frame_acquisition (unsigned int occupied_carriers, - unsigned int fft_length, - unsigned int cplen, - const std::vector<gr_complex> &known_symbol, - unsigned int max_fft_shift_len=4); +digital_ofdm_frame_acquisition_sptr +digital_make_ofdm_frame_acquisition (unsigned int occupied_carriers, + unsigned int fft_length, + unsigned int cplen, + const std::vector<gr_complex> &known_symbol, + unsigned int max_fft_shift_len=4); -class gr_ofdm_frame_acquisition : public gr_sync_decimator +class digital_ofdm_frame_acquisition : public gr_sync_decimator { protected: - gr_ofdm_frame_acquisition (unsigned int occupied_carriers, - unsigned int fft_length, - unsigned int cplen, - const std::vector<gr_complex> &known_symbol, - unsigned int max_fft_shift_len); + digital_ofdm_frame_acquisition (unsigned int occupied_carriers, + unsigned int fft_length, + unsigned int cplen, + const std::vector<gr_complex> &known_symbol, + unsigned int max_fft_shift_len); public: float snr() { return d_snr_est; } diff --git a/gnuradio-core/src/lib/general/gr_ofdm_frame_sink.i b/gr-digital/swig/digital_ofdm_frame_sink.i index 38ab50e97..cd3fa1422 100644 --- a/gnuradio-core/src/lib/general/gr_ofdm_frame_sink.i +++ b/gr-digital/swig/digital_ofdm_frame_sink.i @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2007 Free Software Foundation, Inc. + * Copyright 2007,2011 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,22 +20,22 @@ * Boston, MA 02110-1301, USA. */ -GR_SWIG_BLOCK_MAGIC(gr,ofdm_frame_sink); +GR_SWIG_BLOCK_MAGIC(digital,ofdm_frame_sink); -gr_ofdm_frame_sink_sptr -gr_make_ofdm_frame_sink(const std::vector<gr_complex> &sym_position, - const std::vector<unsigned char> &sym_value_out, - gr_msg_queue_sptr target_queue, unsigned int occupied_tones, - float phase_gain=0.25, float freq_gain=0.25*0.25/4); +digital_ofdm_frame_sink_sptr +digital_make_ofdm_frame_sink(const std::vector<gr_complex> &sym_position, + const std::vector<unsigned char> &sym_value_out, + 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_sink : public gr_sync_block +class digital_ofdm_frame_sink : public gr_sync_block { protected: - gr_ofdm_frame_sink(const std::vector<gr_complex> &sym_position, - const std::vector<unsigned char> &sym_value_out, - gr_msg_queue_sptr target_queue, unsigned int occupied_tones, - float phase_gain, float freq_gain); + digital_ofdm_frame_sink(const std::vector<gr_complex> &sym_position, + const std::vector<unsigned char> &sym_value_out, + gr_msg_queue_sptr target_queue, unsigned int occupied_tones, + float phase_gain, float freq_gain); public: - ~gr_ofdm_frame_sink(); + ~digital_ofdm_frame_sink(); }; diff --git a/gnuradio-core/src/lib/general/gr_ofdm_insert_preamble.i b/gr-digital/swig/digital_ofdm_insert_preamble.i index e33bd63a0..5f7b16369 100644 --- a/gnuradio-core/src/lib/general/gr_ofdm_insert_preamble.i +++ b/gr-digital/swig/digital_ofdm_insert_preamble.i @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2007 Free Software Foundation, Inc. + * Copyright 2007,2011 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,16 +20,16 @@ * Boston, MA 02110-1301, USA. */ -GR_SWIG_BLOCK_MAGIC(gr,ofdm_insert_preamble); +GR_SWIG_BLOCK_MAGIC(digital,ofdm_insert_preamble); -gr_ofdm_insert_preamble_sptr -gr_make_ofdm_insert_preamble(int fft_length, - const std::vector<std::vector<gr_complex> > &preamble); +digital_ofdm_insert_preamble_sptr +digital_make_ofdm_insert_preamble(int fft_length, + const std::vector<std::vector<gr_complex> > &preamble); -class gr_ofdm_insert_preamble : public gr_block +class digital_ofdm_insert_preamble : public gr_block { protected: - gr_ofdm_insert_preamble(int fft_length, - const std::vector<std::vector<gr_complex> > &preamble); + digital_ofdm_insert_preamble(int fft_length, + const std::vector<std::vector<gr_complex> > &preamble); }; diff --git a/gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.i b/gr-digital/swig/digital_ofdm_mapper_bcv.i index 3850220ba..4e9aaba7d 100644 --- a/gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.i +++ b/gr-digital/swig/digital_ofdm_mapper_bcv.i @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2006,2007 Free Software Foundation, Inc. + * Copyright 2006,2007,2011 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,22 +20,22 @@ * Boston, MA 02110-1301, USA. */ -GR_SWIG_BLOCK_MAGIC(gr,ofdm_mapper_bcv); +GR_SWIG_BLOCK_MAGIC(digital,ofdm_mapper_bcv); -gr_ofdm_mapper_bcv_sptr -gr_make_ofdm_mapper_bcv (const std::vector<gr_complex> &constellation, - unsigned int msgq_limit, - unsigned int bits_per_symbol, - unsigned int fft_length) throw(std::exception); +digital_ofdm_mapper_bcv_sptr +digital_make_ofdm_mapper_bcv (const std::vector<gr_complex> &constellation, + unsigned int msgq_limit, + unsigned int bits_per_symbol, + unsigned int fft_length) throw(std::exception); -class gr_ofdm_mapper_bcv : public gr_sync_block +class digital_ofdm_mapper_bcv : public gr_sync_block { protected: - gr_ofdm_mapper_bcv (const std::vector<gr_complex> &constellation, - unsigned int msgq_limit, - unsigned int bits_per_symbol, - unsigned int fft_length); + digital_ofdm_mapper_bcv (const std::vector<gr_complex> &constellation, + unsigned int msgq_limit, + unsigned int bits_per_symbol, + unsigned int fft_length); public: gr_msg_queue_sptr msgq(); diff --git a/gnuradio-core/src/lib/general/gr_ofdm_sampler.i b/gr-digital/swig/digital_ofdm_sampler.i index 601330b07..91056c320 100644 --- a/gnuradio-core/src/lib/general/gr_ofdm_sampler.i +++ b/gr-digital/swig/digital_ofdm_sampler.i @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2007 Free Software Foundation, Inc. + * Copyright 2007,2011 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,16 +20,16 @@ * Boston, MA 02110-1301, USA. */ -GR_SWIG_BLOCK_MAGIC(gr,ofdm_sampler) +GR_SWIG_BLOCK_MAGIC(digital,ofdm_sampler) - gr_ofdm_sampler_sptr gr_make_ofdm_sampler (unsigned int fft_length, - unsigned int symbol_length, - unsigned int timeout=1000); + digital_ofdm_sampler_sptr digital_make_ofdm_sampler (unsigned int fft_length, + unsigned int symbol_length, + unsigned int timeout=1000); -class gr_ofdm_sampler : public gr_sync_block +class digital_ofdm_sampler : public gr_sync_block { private: - gr_ofdm_sampler (unsigned int fft_length, - unsigned int symbol_length, - unsigned int timeout); + digital_ofdm_sampler (unsigned int fft_length, + unsigned int symbol_length, + unsigned int timeout); }; diff --git a/gr-digital/swig/digital_swig.i b/gr-digital/swig/digital_swig.i index 2e3a3242e..3e3a63b61 100644 --- a/gr-digital/swig/digital_swig.i +++ b/gr-digital/swig/digital_swig.i @@ -38,6 +38,12 @@ #include "digital_kurtotic_equalizer_cc.h" #include "digital_lms_dd_equalizer_cc.h" #include "digital_mpsk_receiver_cc.h" +#include "digital_ofdm_cyclic_prefixer.h" +#include "digital_ofdm_frame_acquisition.h" +#include "digital_ofdm_frame_sink.h" +#include "digital_ofdm_insert_preamble.h" +#include "digital_ofdm_mapper_bcv.h" +#include "digital_ofdm_sampler.h" #include "digital_cpmmod_bc.h" #include "digital_gmskmod_bc.h" %} @@ -56,6 +62,12 @@ %include "digital_kurtotic_equalizer_cc.i" %include "digital_lms_dd_equalizer_cc.i" %include "digital_mpsk_receiver_cc.i" +%include "digital_ofdm_cyclic_prefixer.i" +%include "digital_ofdm_frame_acquisition.i" +%include "digital_ofdm_frame_sink.i" +%include "digital_ofdm_insert_preamble.i" +%include "digital_ofdm_mapper_bcv.i" +%include "digital_ofdm_sampler.i" %include "digital_cpmmod_bc.i" %include "digital_gmskmod_bc.i" diff --git a/gr-qtgui/lib/WaterfallDisplayPlot.cc b/gr-qtgui/lib/WaterfallDisplayPlot.cc index 7abd9aeef..94a8e6210 100644 --- a/gr-qtgui/lib/WaterfallDisplayPlot.cc +++ b/gr-qtgui/lib/WaterfallDisplayPlot.cc @@ -318,7 +318,7 @@ WaterfallDisplayPlot::WaterfallDisplayPlot(QWidget* parent) #else d_spectrogram = new QwtPlotSpectrogram("Spectrogram"); - d_spectrogram->setData(*d_data); + d_spectrogram->setData(d_data); d_spectrogram->setDisplayMode(QwtPlotSpectrogram::ImageMode, true); d_spectrogram->setColorMap(new ColorMap_MultiColor()); #endif diff --git a/gr-qtgui/lib/plot_waterfall.cc b/gr-qtgui/lib/plot_waterfall.cc index 527eea22e..dbba657b8 100644 --- a/gr-qtgui/lib/plot_waterfall.cc +++ b/gr-qtgui/lib/plot_waterfall.cc @@ -180,12 +180,17 @@ QImage PlotWaterfall::renderImage(const QwtScaleMap &xMap, if ( area.isEmpty() ) return QImage(); +#if QWT_VERSION < 0x060000 QRect rect = transform(xMap, yMap, area); + const QSize res = d_data->data->rasterHint(area); +#else + QRect rect(0,0,0,0); + const QSize res(0,0); +#endif QwtScaleMap xxMap = xMap; QwtScaleMap yyMap = yMap; - const QSize res = d_data->data->rasterHint(area); if ( res.isValid() ) { /* diff --git a/gr-qtgui/lib/plot_waterfall.h b/gr-qtgui/lib/plot_waterfall.h index d4cb8d6da..1613dd8de 100644 --- a/gr-qtgui/lib/plot_waterfall.h +++ b/gr-qtgui/lib/plot_waterfall.h @@ -37,9 +37,8 @@ public: #if QWT_VERSION < 0x060000 virtual QwtDoubleRect boundingRect() const; -#endif - virtual QSize rasterHint(const QwtDoubleRect &) const; +#endif virtual int rtti() const; diff --git a/grc/blocks/Makefile.am b/grc/blocks/Makefile.am index 9813154bd..5fff38f1f 100644 --- a/grc/blocks/Makefile.am +++ b/grc/blocks/Makefile.am @@ -39,8 +39,6 @@ dist_ourdata_DATA = \ blks2_logpwrfft_x.xml \ blks2_nbfm_rx.xml \ blks2_nbfm_tx.xml \ - blks2_ofdm_demod.xml \ - blks2_ofdm_mod.xml \ blks2_packet_decoder.xml \ blks2_packet_encoder.xml \ blks2_pfb_arb_resampler.xml \ diff --git a/grc/blocks/block_tree.xml b/grc/blocks/block_tree.xml index ea7d744d4..a7a90c4ac 100644 --- a/grc/blocks/block_tree.xml +++ b/grc/blocks/block_tree.xml @@ -215,9 +215,6 @@ <block>blks2_qamx_mod</block> <block>blks2_qamx_demod</block> - - <block>blks2_ofdm_mod</block> - <block>blks2_ofdm_demod</block> </cat> <cat> <name>Error Correction</name> diff --git a/grc/blocks/gr_dc_blocker.xml b/grc/blocks/gr_dc_blocker.xml index e5aeeb031..05c342074 100644 --- a/grc/blocks/gr_dc_blocker.xml +++ b/grc/blocks/gr_dc_blocker.xml @@ -9,7 +9,7 @@ <key>gr_dc_blocker</key> <import>from gnuradio import gr</import> <make>gr.dc_blocker_$(type)($length, $long_form)</make> - <!-- <callback>set_length($lenght)</callback> --> + <!-- <callback>set_length($length)</callback> --> <param> <name>Type</name> <key>type</key> diff --git a/grc/python/extract_docs.py b/grc/python/extract_docs.py index aa85397f9..be55fd239 100644 --- a/grc/python/extract_docs.py +++ b/grc/python/extract_docs.py @@ -26,6 +26,8 @@ DOXYGEN_NAME_XPATH = '/doxygen/compounddef/compoundname' DOXYGEN_BRIEFDESC_GR_XPATH = '/doxygen/compounddef/briefdescription' DOXYGEN_DETAILDESC_GR_XPATH = '/doxygen/compounddef/detaileddescription' +GROUP_KEYS = "gr|usrp2|trellis|noaa|vocoder|digital" + def extract_txt(xml): """ Recursivly pull the text out of an xml tree. @@ -63,7 +65,8 @@ def _extract(key): #extract descriptions comp_name = extract_txt(xml.xpath(DOXYGEN_NAME_XPATH)[0]).strip() comp_name = ' --- ' + comp_name + ' --- ' - if re.match('(gr|usrp2|trellis|noaa)_.*', key): +# if re.match('(gr|usrp2|trellis|noaa)_.*', key): + if re.match(('(%s)_.*' % GROUP_KEYS), key): brief_desc = extract_txt(xml.xpath(DOXYGEN_BRIEFDESC_GR_XPATH)[0]).strip() detailed_desc = extract_txt(xml.xpath(DOXYGEN_DETAILDESC_GR_XPATH)[0]).strip() else: diff --git a/volk/config/ax_boost_base.m4 b/volk/config/ax_boost_base.m4 index e9790227e..f2a7f6e83 100644 --- a/volk/config/ax_boost_base.m4 +++ b/volk/config/ax_boost_base.m4 @@ -276,7 +276,7 @@ AC_DEFUN([_AX_BOOST_CHECK_LIB_],[ dnl $1 is unit name. E.g., boost_thread AC_DEFUN([_AX_BOOST_WITH],[ - _AX_BOOST_WITH_($1,m4_bpatsubst($1,_,-)) + _AX_BOOST_WITH_([$1], [m4_bpatsubst($1,_,-)]) ]) dnl $1 is unit name. E.g., boost_thread @@ -305,7 +305,7 @@ dnl $2 is AC_LANG_PROGRAM argument 1 dnl $3 is AC_LANG_PROGRAM argument 2 dnl $4 is cv variable name. E.g., ax_cv_boost_thread AC_DEFUN([_AX_BOOST_CHECK_],[ - _AX_BOOST_WITH($1) + _AX_BOOST_WITH([$1]) if test "$want_boost" = "yes"; then AC_REQUIRE([AC_PROG_CC]) AC_REQUIRE([AC_PROG_CXX]) @@ -315,9 +315,9 @@ AC_DEFUN([_AX_BOOST_CHECK_],[ LDFLAGS="$LDFLAGS $BOOST_LDFLAGS" AC_CACHE_CHECK([whether the boost::m4_substr([$1],6) includes are available], [$4], [AC_LANG_PUSH([C++]) - AC_COMPILE_IFELSE(AC_LANG_PROGRAM([$2],[$3]),[$4]=yes,[$4]=no) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$2],[$3])], [[$4]=yes], [[$4]=no]) AC_LANG_POP([C++]) - ]) + ]) if test "$[$4]" = "yes"; then _AX_BOOST_CHECK_LIB([$1]) fi @@ -330,5 +330,5 @@ dnl $1 is unit name. E.g., boost_thread dnl $2 is AC_LANG_PROGRAM argument 1 dnl $3 is AC_LANG_PROGRAM argument 2 AC_DEFUN([_AX_BOOST_CHECK],[ - _AX_BOOST_CHECK_($1,$2,$3,ax_cv_$1) + _AX_BOOST_CHECK_([$1], [$2], [$3], [ax_cv_$1]) ]) |