diff options
author | Tom Rondeau | 2011-10-12 17:01:44 -0400 |
---|---|---|
committer | Tom Rondeau | 2011-10-12 17:01:44 -0400 |
commit | 5f0bc5a2096012d6a94f72e20190ab8b3e0b4f88 (patch) | |
tree | 465294556e9209c9a0f864e171d6823e6da11053 | |
parent | d1e3108c8705289d194300ca9fad1c22f579be9b (diff) | |
download | gnuradio-5f0bc5a2096012d6a94f72e20190ab8b3e0b4f88.tar.gz gnuradio-5f0bc5a2096012d6a94f72e20190ab8b3e0b4f88.tar.bz2 gnuradio-5f0bc5a2096012d6a94f72e20190ab8b3e0b4f88.zip |
digital: wip: moved all OFDM examples and blks2impl to gr-digital.
21 files changed, 43 insertions, 2177 deletions
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/python/gnuradio/blks2impl/Makefile.am b/gnuradio-core/src/python/gnuradio/blks2impl/Makefile.am index 9665dde0b..3ddf99b5d 100644 --- a/gnuradio-core/src/python/gnuradio/blks2impl/Makefile.am +++ b/gnuradio-core/src/python/gnuradio/blks2impl/Makefile.am @@ -37,12 +37,6 @@ 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 \ 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-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/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/gr_plot_ofdm.py b/gnuradio-examples/python/ofdm/gr_plot_ofdm.py deleted file mode 100755 index b24855148..000000000 --- a/gnuradio-examples/python/ofdm/gr_plot_ofdm.py +++ /dev/null @@ -1,278 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 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. -# - -import math, struct, sys -from optparse import OptionParser -from math import log10 - -try: - import scipy - from scipy import fftpack -except ImportError: - print "Error: Program requires scipy (see: www.scipy.org)." - sys.exit(1) - -try: - from pylab import * - from matplotlib.font_manager import fontManager, FontProperties -except ImportError: - print "Error: Program requires matplotlib (see: matplotlib.sourceforge.net)." - sys.exit(1) - -matplotlib.interactive(True) -matplotlib.use('TkAgg') - -class draw_constellation: - def __init__(self, options): - derot_file = "ofdm_frame_sink_c.dat" - acq_file = "ofdm_frame_acq_c.dat" - fft_file = "ofdm_receiver-fft_out_c.dat" - - self.h_derot_file = open(derot_file, "r") - self.h_acq_file = open(acq_file, "r") - self.h_fft_file = open(fft_file, "r") - - self.occ_tones = options.occ_tones - self.fft_size = options.fft_size - self.symbol = options.start - self.sample_rate = options.sample_rate - - self.axis_font_size = 16 - self.label_font_size = 18 - self.title_font_size = 20 - self.text_size = 22 - - # Setup PLOT - self.fig = figure(1, figsize=(14, 9), facecolor='w') - rcParams['xtick.labelsize'] = self.axis_font_size - rcParams['ytick.labelsize'] = self.axis_font_size - - self.text_sym = figtext(0.05, 0.95, ("Symbol: %s" % self.symbol), weight="heavy", size=self.text_size) - - self.make_plots() - - self.button_left_axes = self.fig.add_axes([0.45, 0.01, 0.05, 0.05], frameon=True) - self.button_left = Button(self.button_left_axes, "<") - self.button_left_callback = self.button_left.on_clicked(self.button_left_click) - - self.button_right_axes = self.fig.add_axes([0.50, 0.01, 0.05, 0.05], frameon=True) - self.button_right = Button(self.button_right_axes, ">") - self.button_right_callback = self.button_right.on_clicked(self.button_right_click) - - self.xlim = self.sp_eq.get_xlim() - - self.manager = get_current_fig_manager() - #connect('draw_event', self.zoom) - connect('key_press_event', self.click) - show() - - def get_data(self): - self.text_sym.set_text("Symbol: %d" % (self.symbol)) - - derot_data = scipy.fromfile(self.h_derot_file, dtype=scipy.complex64, count=self.occ_tones) - acq_data = scipy.fromfile(self.h_acq_file, dtype=scipy.complex64, count=self.occ_tones) - fft_data = scipy.fromfile(self.h_fft_file, dtype=scipy.complex64, count=self.fft_size) - if(len(acq_data) == 0): - print "End of File" - else: - self.acq_data_reals = [r.real for r in acq_data] - self.acq_data_imags = [i.imag for i in acq_data] - self.derot_data_reals = [r.real for r in derot_data] - self.derot_data_imags = [i.imag for i in derot_data] - - self.unequalized_angle = [math.atan2(x.imag, x.real) for x in fft_data] - self.equalized_angle = [math.atan2(x.imag, x.real) for x in acq_data] - self.derot_equalized_angle = [math.atan2(x.imag, x.real) for x in derot_data] - - self.time = [i*(1/self.sample_rate) for i in range(len(acq_data))] - ffttime = [i*(1/self.sample_rate) for i in range(len(fft_data))] - - self.freq = self.get_freq(ffttime, self.sample_rate) - - for i in range(len(fft_data)): - if(abs(fft_data[i]) == 0.0): - fft_data[i] = complex(1e-6,1e-6) - self.fft_data = [20*log10(abs(f)) for f in fft_data] - - def get_freq(self, time, sample_rate, T=1): - N = len(time) - Fs = 1.0 / (max(time) - min(time)) - Fn = 0.5 * sample_rate - freq = [-Fn + i*Fs for i in range(N)] - return freq - - def make_plots(self): - self.h_acq_file.seek(8*self.symbol*self.occ_tones, 0) - self.h_fft_file.seek(8*self.symbol*self.fft_size, 0) - self.h_derot_file.seek(8*self.symbol*self.occ_tones, 0) - - self.get_data() - - # Subplot: constellation of rotated symbols - self.sp_const = self.fig.add_subplot(4,1,1, position=[0.15, 0.55, 0.3, 0.35]) - self.sp_const.set_title(("Constellation"), fontsize=self.title_font_size, fontweight="bold") - self.sp_const.set_xlabel("Inphase", fontsize=self.label_font_size, fontweight="bold") - self.sp_const.set_ylabel("Qaudrature", fontsize=self.label_font_size, fontweight="bold") - self.plot_const = plot(self.acq_data_reals, self.acq_data_imags, 'bo') - self.plot_const += plot(self.derot_data_reals, self.derot_data_imags, 'ro') - self.sp_const.axis([-2, 2, -2, 2]) - - # Subplot: unequalized angle - self.sp_uneq = self.fig.add_subplot(4,2,1, position=[0.575, 0.55, 0.3, 0.35]) - self.sp_uneq.set_title(("Unequalized Angle"), fontsize=self.title_font_size, fontweight="bold") - self.sp_uneq.set_xlabel("Time (s)", fontsize=self.label_font_size, fontweight="bold") - self.sp_uneq.set_ylabel("Angle", fontsize=self.label_font_size, fontweight="bold") - uneqscale = range(len(self.unequalized_angle)) - self.plot_uneq = plot(uneqscale, self.unequalized_angle, 'bo') - - # Subplot: equalized angle - self.sp_eq = self.fig.add_subplot(4,1,2, position=[0.15, 0.1, 0.3, 0.35]) - self.sp_eq.set_title(("Equalized Angle"), fontsize=self.title_font_size, fontweight="bold") - self.sp_eq.set_xlabel("Time (s)", fontsize=self.label_font_size, fontweight="bold") - self.sp_eq.set_ylabel("Angle", fontsize=self.label_font_size, fontweight="bold") - eqscale = range(len(self.equalized_angle)) - self.plot_eq = plot(eqscale, self.equalized_angle, 'bo') - self.plot_eq += plot(eqscale, self.derot_equalized_angle, 'ro', markersize=4) - - # Subplot: FFT - self.sp_fft = self.fig.add_subplot(4,2,2, position=[0.575, 0.1, 0.3, 0.35]) - self.sp_fft.set_title(("FFT"), fontsize=self.title_font_size, fontweight="bold") - self.sp_fft.set_xlabel("Frequency (MHz)", fontsize=self.label_font_size, fontweight="bold") - self.sp_fft.set_ylabel("Power (dBm)", fontsize=self.label_font_size, fontweight="bold") - self.plot_fft = plot(self.freq, self.fft_data, '-bo') - - draw() - - def update_plots(self): - eqscale = range(len(self.equalized_angle)) - uneqscale = range(len(self.unequalized_angle)) - self.plot_eq[0].set_data([eqscale, self.equalized_angle]) - self.plot_eq[1].set_data([eqscale, self.derot_equalized_angle]) - self.plot_uneq[0].set_data([uneqscale, self.unequalized_angle]) - self.sp_eq.set_ylim([-4, 4]) - self.sp_uneq.set_ylim([-4, 4]) - - #self.sp_iq.axis([min(self.time), max(self.time), - # 1.5*min([min(self.acq_data_reals), min(self.acq_data_imags)]), - # 1.5*max([max(self.acq_data_reals), max(self.acq_data_imags)])]) - - self.plot_const[0].set_data([self.acq_data_reals, self.acq_data_imags]) - self.plot_const[1].set_data([self.derot_data_reals, self.derot_data_imags]) - self.sp_const.axis([-2, 2, -2, 2]) - - self.plot_fft[0].set_data([self.freq, self.fft_data]) - - draw() - - def zoom(self, event): - newxlim = self.sp_eq.get_xlim() - if(newxlim != self.xlim): - self.xlim = newxlim - r = self.reals[int(ceil(self.xlim[0])) : int(ceil(self.xlim[1]))] - i = self.imags[int(ceil(self.xlim[0])) : int(ceil(self.xlim[1]))] - - self.plot_const[0].set_data(r, i) - self.sp_const.axis([-2, 2, -2, 2]) - self.manager.canvas.draw() - draw() - - def click(self, event): - forward_valid_keys = [" ", "down", "right"] - backward_valid_keys = ["up", "left"] - - if(find(event.key, forward_valid_keys)): - self.step_forward() - - elif(find(event.key, backward_valid_keys)): - self.step_backward() - - def button_left_click(self, event): - self.step_backward() - - def button_right_click(self, event): - self.step_forward() - - def step_forward(self): - self.symbol += 1 - self.get_data() - self.update_plots() - - def step_backward(self): - # Step back in file position - self.symbol -= 1 - if(self.h_acq_file.tell() >= 16*self.occ_tones): - self.h_acq_file.seek(-16*self.occ_tones, 1) - else: - self.symbol = 0 - self.h_acq_file.seek(-self.h_acq_file.tell(),1) - - - if(self.h_derot_file.tell() >= 16*self.occ_tones): - self.h_derot_file.seek(-16*self.occ_tones, 1) - else: - self.symbol = 0 - self.h_derot_file.seek(-self.h_derot_file.tell(),1) - - - if(self.h_fft_file.tell() >= 16*self.fft_size): - self.h_fft_file.seek(-16*self.fft_size, 1) - else: - self.symbol = 0 - self.h_fft_file.seek(-self.h_fft_file.tell(),1) - - self.get_data() - self.update_plots() - - - -#FIXME: there must be a way to do this with a Python builtin -def find(item_in, list_search): - for l in list_search: - if item_in == l: - return True - return False - -def main(): - usage="%prog: [options]" - - parser = OptionParser(conflict_handler="resolve", usage=usage) - parser.add_option("", "--fft-size", type="int", default=512, - help="Specify the size of the FFT [default=%default]") - parser.add_option("", "--occ-tones", type="int", default=200, - help="Specify the number of occupied tones [default=%default]") - parser.add_option("-s", "--start", type="int", default=0, - help="Specify the starting symbol to plot [default=%default]") - parser.add_option("-R", "--sample-rate", type="float", default=1.0, - help="Set the sampler rate of the data [default=%default]") - - (options, args) = parser.parse_args () - - dc = draw_constellation(options) - -if __name__ == "__main__": - try: - main() - except KeyboardInterrupt: - pass - - - diff --git a/gnuradio-examples/python/ofdm/ofdm_mod_demod_test.py b/gnuradio-examples/python/ofdm/ofdm_mod_demod_test.py deleted file mode 100755 index b1521da6d..000000000 --- a/gnuradio-examples/python/ofdm/ofdm_mod_demod_test.py +++ /dev/null @@ -1,179 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2005,2006,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. -# - -from gnuradio import gr, ofdm_packet_utils -import gnuradio.gr.gr_threading as _threading -from gnuradio import eng_notation -from gnuradio.eng_option import eng_option -from optparse import OptionParser - -import random, time, struct, sys, math, os - -class my_top_block(gr.top_block): - def __init__(self, callback, options): - gr.top_block.__init__(self) - - # hard-coded known symbol - ks1 = known_symbols_4512_1[0:options.occupied_tones] - ks2 = known_symbols_4512_2[0:options.occupied_tones] - - self._rcvd_pktq = gr.msg_queue() - - # accepts messages from the outside world - self.ofdm_mapper = gr.ofdm_bpsk_mapper(4, options.occupied_tones, options.fft_length, ks1, ks2) - self.ofdm_corr = gr.ofdm_correlator(options.occupied_tones, options.fft_length, 0, ks1, ks2) - self.ofdm_framer = gr.ofdm_frame_sink(self._rcvd_pktq, options.occupied_tones) - - if 0: # set to 1 to put the correlator in the path to take over the signalling - self.connect((self.ofdm_mapper, 0), (self.ofdm_corr, 0)) - self.connect((self.ofdm_corr, 0), (self.ofdm_framer, 0)) - self.connect((self.ofdm_corr, 1), (self.ofdm_framer, 1)) - - self.connect((self.ofdm_mapper,0), gr.file_sink(gr.sizeof_gr_complex*options.fft_length, "ofdm_mapper.dat")) - self.connect((self.ofdm_corr,0), gr.file_sink(gr.sizeof_gr_complex*options.occupied_tones, "ofdm_corr.dat")) - self.connect((self.ofdm_corr,1), gr.file_sink(gr.sizeof_char, "ofdm_sig.dat")) - - else: - self.connect((self.ofdm_mapper, 0), (self.ofdm_framer, 0)) - self.connect((self.ofdm_mapper, 1), (self.ofdm_framer, 1)) - - self.connect((self.ofdm_mapper,0), gr.file_sink(gr.sizeof_gr_complex*options.fft_length, "ofdm_mapper.dat")) - self.connect((self.ofdm_mapper,1), gr.file_sink(gr.sizeof_char, "ofdm_sig.dat")) - - self._watcher = _queue_watcher_thread(self._rcvd_pktq, callback) - - def send_pkt(self, payload='', eof=False): - if eof: - msg = gr.message(1) - else: - pkt = ofdm_packet_utils.make_packet(payload, 1, 1, False, whiten=False) - msg = gr.message_from_string(pkt) - self.ofdm_mapper.msgq().insert_tail(msg) - -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(), whiten=False) - if self.callback: - self.callback(ok, payload) - -# ///////////////////////////////////////////////////////////////////////////// -# main -# ///////////////////////////////////////////////////////////////////////////// - -def main(): - ''' Use this program to tie the OFDM modulators straight into the frame sink, with or without - the correlator in between. This is for testing of the modulators and demodulators only without - receiver and sync functionality.''' - - global n_rcvd, n_right - - n_rcvd = 0 - n_right = 0 - - def send_pkt(payload='', eof=False): - return fg.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 = parser.add_option_group("Expert") - parser.add_option("-s", "--size", type="eng_float", default=1450, - help="set packet size [default=%default]") - parser.add_option("-M", "--megabytes", type="eng_float", default=1.0, - help="set megabytes to transmit [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("", "--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]") - - (options, args) = parser.parse_args () - - # build the graph - tb = my_top_block(rx_callback, options) - - 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 - pktno += 1 - - send_pkt(eof=True) - tb.wait() # wait for it to finish - -known_symbols_4512_1 = [-1, 1, 1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, -1, 1, -1, 1, -1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, -1, -1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, 1, 1, 1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1, 1, -1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, 1, 1, -1, -1, 1, -1, 1, -1, 1, 1, -1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1, 1, -1, -1, -1, 1, -1, 1, 1, 1, -1, 1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, 1, 1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, 1, -1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, 1, 1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, 1, 1, 1, -1, -1, -1, 1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, -1, 1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, -1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, -1, -1, -1, 1, 1, -1, 1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, -1, 1, -1, 1, 1, -1, -1, -1, -1, -1, -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, 1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, -1, -1, -1, 1, -1, 1, 1, 1, -1, -1, 1, -1, 1, -1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, 1, -1, 1, -1, 1, -1, -1, 1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, 1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, 1, 1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, 1, -1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, 1, -1, -1, 1, -1, 1, -1, 1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, -1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, -1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, 1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, 1, -1, 1, 1, 1, -1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 1, 1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, 1, -1, -1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, -1, 1, 1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, -1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, -1, -1, -1, 1, -1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 1, -1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, -1, -1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, -1, -1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, -1, -1, -1, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, -1, 1, -1, 1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, -1, -1, 1] - -known_symbols_4512_2 = [1, 1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, 1, 1, -1, 1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, 1, 1, -1, 1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, 1, -1, -1, 1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, 1, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, 1, -1, 1, 1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, -1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, 1, -1, 1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, 1, -1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, -1, 1, 1, -1, 1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, -1, -1, 1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, -1, 1, 1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, 1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1, 1, -1, 1, 1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, 1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, 1, -1, 1, -1, -1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, -1, -1, 1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, 1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, 1, 1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, 1, -1, 1, -1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, -1, 1, -1, -1, 1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, 1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, 1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, -1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, -1, 1, 1, 1, 1, -1, 1, -1, 1, 1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, 1, -1, -1, 1, -1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, 1, -1, -1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, 1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, 1, -1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, 1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, -1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 1, -1, -1, -1, 1, -1, -1, 1, -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, 1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, 1, 1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1] - - -if __name__ == '__main__': - try: - main() - except KeyboardInterrupt: - pass - diff --git a/gnuradio-examples/python/ofdm/ofdm_sync.m b/gnuradio-examples/python/ofdm/ofdm_sync.m deleted file mode 100644 index d5df42137..000000000 --- a/gnuradio-examples/python/ofdm/ofdm_sync.m +++ /dev/null @@ -1,28 +0,0 @@ -% - -function [theta, g, g1, k, h] = ofdm_sync(signal,SNR,FFTSIZE,CPLEN) - - rho = SNR/(SNR+1); - - d = abs(signal).^2; - g = [ zeros(1,FFTSIZE) signal(1:max(size(signal))-FFTSIZE) ]; - g1 = conj(g); - f = abs(g).^2; - c = d + f; - moving_sum_taps = rho/2 * ones(1,CPLEN); - b = conv(c,moving_sum_taps); - b = b(1:max(size(signal))); - %b = b(CPLEN:max(size(b))); - - k = g1 .* signal; - - moving_sum_taps2 = ones(1, CPLEN); - h = conv(k,moving_sum_taps2); - h = h(1:max(size(signal))); - %h = h(CPLEN:max(size(h))); - - a = abs(h); - - theta = a-b; - -endfunction diff --git a/gnuradio-examples/python/ofdm/ofdm_sync_pn.m b/gnuradio-examples/python/ofdm/ofdm_sync_pn.m deleted file mode 100644 index d93c0ca92..000000000 --- a/gnuradio-examples/python/ofdm/ofdm_sync_pn.m +++ /dev/null @@ -1,21 +0,0 @@ -mf = read_float_binary('ofdm_sync_pn-mf_f.dat'); -theta_pn = read_float_binary('ofdm_sync_pn-theta_f.dat'); -peaks_pn = read_char_binary('ofdm_sync_pn-peaks_b.dat'); -regen_pn = read_char_binary('ofdm_sync_pn-regen_b.dat'); -angle_pn = read_float_binary('ofdm_sync_pn-epsilon_f.dat'); - -plot(mf, 'k') -hold -plot(theta_pn, 'g'); -plot(peaks_pn, 'r'); -plot(regen_pn, 'b'); -xlim([100, 50000]); -ylim([0, 1]) -i = find(peaks_pn); -i(100:200) -hold off - -ipeaks = find(peaks_pn); -dpeaks = diff(ipeaks); -hist(dpeaks, 30) -set(gca, 'FontSize', 30, 'FontWeight', 'Bold'); diff --git a/gnuradio-examples/python/ofdm/plot_ofdm.m b/gnuradio-examples/python/ofdm/plot_ofdm.m deleted file mode 100755 index 2a649b5f5..000000000 --- a/gnuradio-examples/python/ofdm/plot_ofdm.m +++ /dev/null @@ -1,74 +0,0 @@ -function plot_ofdm(fft_size, occ_tones) - -ofdm = read_complex_binary('ofdm_frame_acq_c.dat'); -ofdm_split = split_vect(ofdm, occ_tones); - -ofdm_derot = read_complex_binary('ofdm_frame_sink_c.dat'); -ofdm_derot_split = split_vect(ofdm_derot, occ_tones); - -fftc = read_complex_binary('fft_out_c.dat'); -fftc_split = split_vect(fftc, fft_size); - -size(ofdm_split) -size(ofdm_derot_split) -disp "DEROTATED SPLIT" -ofdm_derot(1:100) - - -figure(1) -#set(gcf, 'Position', [50 50 1000 600]); - -a = size(ofdm_split); -if nargin == 3 - maxcount = count; - if maxcount > a(1) - error('plot_ofdm:tolong', 'Requested count size exceeds size of vectors'); - end -else - maxcount = a(1); -end - -for i = 1:size(ofdm_split)[0] - x = ofdm_split(i,:); - y = fftc_split(i+1,:); - - subplot(2,2,1); - plot(real(x), imag(x), 'bo'); - #set(gca, 'FontSize', 30, 'FontWeight', 'Bold'); - axis([-1.5, 1.5, -1.5, 1.5]) - #title('I&Q Constellation', 'FontSize', 36); - #xlabel('Inphase', 'FontSize', 32); - #ylabel('Quadrature', 'FontSize', 32); - - subplot(2,2,3); - plot(angle(x*j), 'bo'); - #set(gca, 'FontSize', 30, 'FontWeight', 'Bold'); - axis([0, occ_tones, -3.5, 3.5]) - #title('Equalized Symbol Angle', 'FontSize', 36); - #xlabel('Bin Number (Occ. Tones)', 'FontSize', 32); - #ylabel('Symbol Angle', 'FontSize', 32); - - subplot(2,2,2); - plot(angle(y*j), 'bo'); - #set(gca, 'FontSize', 30, 'FontWeight', 'Bold'); - axis([0, fft_size, -3.5, 3.5]) - #title('Unequalized Symbol Angle', 'FontSize', 36); - #xlabel('Bin Number (FFT Size)', 'FontSize', 32); - #ylabel('Symbol Angle', 'FontSize', 32); - - Y = 20*log10(abs(y) ./ max(abs(y))); - subplot(2,2,4); - plot(Y, 'b-'); - #set(gca, 'FontSize', 30, 'FontWeight', 'Bold'); - axis([0, fft_size, -50, 1]); - #title('Frequency Domain of Unequalized Rx', 'FontSize', 36); - #xlabel('Bin Number (FFT Size)', 'FontSize', 32); - #ylabel('Power (dB)', 'FontSize', 32); - - #N = 20*log10(var(abs(x)-1)); - - disp(sprintf('Symbol Number: %d\n', i)) - #disp(sprintf('\tFreq Error: %f\n', anglesh_pn(1+(i-1)*fft_size))) - pause - -end diff --git a/gnuradio-examples/python/ofdm/receive_path.py b/gnuradio-examples/python/ofdm/receive_path.py deleted file mode 100644 index b758bc4d0..000000000 --- a/gnuradio-examples/python/ofdm/receive_path.py +++ /dev/null @@ -1,105 +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, gru, blks2 -from gnuradio import usrp -from gnuradio import eng_notation -import copy -import sys - -# from current dir -from pick_bitrate import pick_rx_bitrate - -# ///////////////////////////////////////////////////////////////////////////// -# receive path -# ///////////////////////////////////////////////////////////////////////////// - -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 - - - options = copy.copy(options) # make a copy so we can destructively modify - - self._verbose = options.verbose - self._log = options.log - 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) - - # Carrier Sensing Blocks - alpha = 0.001 - thresh = 30 # in dB, will have to adjust - self.probe = gr.probe_avg_mag_sqrd_c(thresh,alpha) - - self.connect(self, self.ofdm_rx) - self.connect(self.ofdm_rx, self.probe) - - # Display some information about the setup - if self._verbose: - self._print_verbage() - - def carrier_sensed(self): - """ - Return True if we think carrier is present. - """ - #return self.probe.level() > X - return self.probe.unmuted() - - def carrier_threshold(self): - """ - Return current setting in dB. - """ - return self.probe.threshold() - - def set_carrier_threshold(self, threshold_in_db): - """ - Set carrier threshold. - - @param threshold_in_db: set detection threshold - @type threshold_in_db: float (dB) - """ - self.probe.set_threshold(threshold_in_db) - - - def add_options(normal, expert): - """ - Adds receiver-specific options to the Options Parser - """ - 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)") - - # Make a static method to call before instantiation - add_options = staticmethod(add_options) - - - def _print_verbage(self): - """ - Prints information about the receive path - """ - pass diff --git a/gnuradio-examples/python/ofdm/transmit_path.py b/gnuradio-examples/python/ofdm/transmit_path.py deleted file mode 100644 index 44c7331b0..000000000 --- a/gnuradio-examples/python/ofdm/transmit_path.py +++ /dev/null @@ -1,93 +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 gnuradio import gr, gru, blks2 -from gnuradio import usrp -from gnuradio import eng_notation - -import copy -import sys - -# ///////////////////////////////////////////////////////////////////////////// -# transmit path -# ///////////////////////////////////////////////////////////////////////////// - -class transmit_path(gr.hier_block2): - def __init__(self, options): - ''' - See below for what options should hold - ''' - - 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 - - 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.ofdm_tx = \ - blks2.ofdm_mod(options, msgq_limit=4, pad_for_usrp=False) - - self.amp = gr.multiply_const_cc(1) - self.set_tx_amplitude(self._tx_amplitude) - - # Display some information about the setup - if self._verbose: - self._print_verbage() - - # Create and setup transmit path flow graph - self.connect(self.ofdm_tx, self.amp, self) - - def set_tx_amplitude(self, ampl): - """ - Sets the transmit amplitude sent to the USRP - @param: ampl 0 <= ampl < 32768. Try 8000 - """ - self._tx_amplitude = max(0.0, min(ampl, 32767.0)) - self.amp.set_k(self._tx_amplitude) - - def send_pkt(self, payload='', eof=False): - """ - Calls the transmitter method to send a packet - """ - return self.ofdm_tx.send_pkt(payload, eof) - - def add_options(normal, expert): - """ - 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, - help="Log all parts of flow graph to file (CAUTION: lots of data)") - - # Make a static method to call before instantiation - add_options = staticmethod(add_options) - - def _print_verbage(self): - """ - Prints information about the transmit path - """ - print "Tx amplitude %s" % (self._tx_amplitude) - 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/python/ofdm.py b/gr-digital/python/ofdm.py index e05f074f4..2663f7cf8 100644 --- a/gr-digital/python/ofdm.py +++ b/gr-digital/python/ofdm.py @@ -21,31 +21,12 @@ # import math -from gnuradio import gr, ofdm_packet_utils, modulation_utils2 +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 -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,10 +82,19 @@ 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, + 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) @@ -153,10 +140,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 +196,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] @@ -223,11 +211,22 @@ class ofdm_demod(gr.hier_block2): 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) + + 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_sink2(constell.base(), + self.ofdm_demod = gr.ofdm_frame_sink(rotated_const, range(arity), self._rcvd_pktq, self._occupied_tones, phgain, frgain) @@ -254,9 +253,14 @@ 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]") # Make a static method to call before instantiation add_options = staticmethod(add_options) diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/ofdm_receiver.py b/gr-digital/python/ofdm_receiver.py index 56ae0c0f0..56ae0c0f0 100644 --- a/gnuradio-core/src/python/gnuradio/blks2impl/ofdm_receiver.py +++ b/gr-digital/python/ofdm_receiver.py 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 |