diff options
-rw-r--r-- | gnuradio-core/src/python/gnuradio/Makefile.am | 2 | ||||
-rw-r--r-- | gnuradio-core/src/python/gnuradio/modulation_utils2.py | 81 | ||||
-rwxr-xr-x | gr-digital/examples/ofdm/benchmark_ofdm_tx.py | 6 | ||||
-rw-r--r-- | gr-digital/examples/ofdm/transmit_path.py | 6 | ||||
-rw-r--r-- | gr-digital/python/Makefile.am | 7 | ||||
-rw-r--r-- | gr-digital/python/__init__.py | 10 | ||||
-rw-r--r-- | gr-digital/python/ofdm.py | 19 | ||||
-rw-r--r-- | gr-digital/python/ofdm_packet_utils.py (renamed from gnuradio-core/src/python/gnuradio/ofdm_packet_utils.py) | 4 | ||||
-rw-r--r-- | gr-digital/python/ofdm_receiver.py | 47 |
9 files changed, 67 insertions, 115 deletions
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/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/gr-digital/examples/ofdm/benchmark_ofdm_tx.py b/gr-digital/examples/ofdm/benchmark_ofdm_tx.py index 02bbeb971..fb4d97302 100755 --- a/gr-digital/examples/ofdm/benchmark_ofdm_tx.py +++ b/gr-digital/examples/ofdm/benchmark_ofdm_tx.py @@ -20,12 +20,14 @@ # Boston, MA 02110-1301, USA. # -from gnuradio import gr, blks2 +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 @@ -75,7 +77,7 @@ def main(): help="Output file for modulated samples") transmit_path.add_options(parser, expert_grp) - blks2.ofdm_mod.add_options(parser, expert_grp) + digital.ofdm_mod.add_options(parser, expert_grp) uhd_transmitter.add_options(parser) (options, args) = parser.parse_args () diff --git a/gr-digital/examples/ofdm/transmit_path.py b/gr-digital/examples/ofdm/transmit_path.py index c5a7fd53d..854cfd51f 100644 --- a/gr-digital/examples/ofdm/transmit_path.py +++ b/gr-digital/examples/ofdm/transmit_path.py @@ -45,9 +45,9 @@ class transmit_path(gr.hier_block2): 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) diff --git a/gr-digital/python/Makefile.am b/gr-digital/python/Makefile.am index cd98fe2d4..9c7d557ca 100644 --- a/gr-digital/python/Makefile.am +++ b/gr-digital/python/Makefile.am @@ -54,6 +54,13 @@ digital_PYTHON = \ generic_mod_demod.py \ gmsk.py \ modulation_utils2.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 \ diff --git a/gr-digital/python/__init__.py b/gr-digital/python/__init__.py index ca46dcfdb..fa6ba1e8b 100644 --- a/gr-digital/python/__init__.py +++ b/gr-digital/python/__init__.py @@ -33,5 +33,13 @@ from qam import * from gmsk import * from pkt import * from crc import * -from packet_utils import * from modulation_utils2 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/ofdm.py b/gr-digital/python/ofdm.py index 2663f7cf8..806f0a7ad 100644 --- a/gr-digital/python/ofdm.py +++ b/gr-digital/python/ofdm.py @@ -21,13 +21,12 @@ # import math -from gnuradio import gr, ofdm_packet_utils +from gnuradio import gr +import digital_swig +import 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 # ///////////////////////////////////////////////////////////////////////////// @@ -130,7 +129,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) @@ -207,9 +208,11 @@ class ofdm_demod(gr.hier_block2): 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) + self.ofdm_recv = digital_swig.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] diff --git a/gnuradio-core/src/python/gnuradio/ofdm_packet_utils.py b/gr-digital/python/ofdm_packet_utils.py index f151ffe74..ccd4be27c 100644 --- a/gnuradio-core/src/python/gnuradio/ofdm_packet_utils.py +++ b/gr-digital/python/ofdm_packet_utils.py @@ -22,6 +22,8 @@ import struct import numpy from gnuradio import gru +import digital_swig +import crc def conv_packed_binary_string_to_1_0_string(s): """ @@ -116,7 +118,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) diff --git a/gr-digital/python/ofdm_receiver.py b/gr-digital/python/ofdm_receiver.py index 56ae0c0f0..d89c79c4d 100644 --- a/gr-digital/python/ofdm_receiver.py +++ b/gr-digital/python/ofdm_receiver.py @@ -23,10 +23,7 @@ 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 class ofdm_receiver(gr.hier_block2): """ @@ -85,20 +82,35 @@ 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 = digital_swig.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 = digital_swig.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 = digital_swig.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 = digital_swig.ofdm_sync_fixed(fft_length, + cp_length, + nsymbols, + freq_offset, + logging) # Set up blocks @@ -106,7 +118,8 @@ class ofdm_receiver(gr.hier_block2): self.sigmix = gr.multiply_cc() self.sampler = gr.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, + self.ofdm_frame_acq = gr.ofdm_frame_acquisition(occupied_tones, + fft_length, cp_length, ks[0]) self.connect(self, self.chan_filt) # filter the input channel |