summaryrefslogtreecommitdiff
path: root/gr-digital/python/ofdm_receiver.py
diff options
context:
space:
mode:
Diffstat (limited to 'gr-digital/python/ofdm_receiver.py')
-rw-r--r--gr-digital/python/ofdm_receiver.py69
1 files changed, 36 insertions, 33 deletions
diff --git a/gr-digital/python/ofdm_receiver.py b/gr-digital/python/ofdm_receiver.py
index 9d4d6e559d..4fbf76251a 100644
--- a/gr-digital/python/ofdm_receiver.py
+++ b/gr-digital/python/ofdm_receiver.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
-# Copyright 2006, 2007, 2008 Free Software Foundation, Inc.
+# Copyright 2006-2008 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -23,13 +23,21 @@
import math
from numpy import fft
from gnuradio import gr
+from gnuradio import analog
+from gnuradio import blocks
+from gnuradio import filter
-import digital_swig
+import digital_swig as digital
from ofdm_sync_pn import ofdm_sync_pn
from ofdm_sync_fixed import ofdm_sync_fixed
from ofdm_sync_pnac import ofdm_sync_pnac
from ofdm_sync_ml import ofdm_sync_ml
+try:
+ from gnuradio import filter
+except ImportError:
+ import filter_swig as filter
+
class ofdm_receiver(gr.hier_block2):
"""
Performs receiver synchronization on OFDM symbols.
@@ -47,18 +55,13 @@ class ofdm_receiver(gr.hier_block2):
The input is the complex modulated signal at baseband.
Synchronized packets are sent back to the demodulator.
- @param fft_length: total number of subcarriers
- @type fft_length: int
- @param cp_length: length of cyclic prefix as specified in subcarriers (<= fft_length)
- @type cp_length: int
- @param occupied_tones: number of subcarriers used for data
- @type occupied_tones: int
- @param snr: estimated signal to noise ratio used to guide cyclic prefix synchronizer
- @type snr: float
- @param ks: known symbols used as preambles to each packet
- @type ks: list of lists
- @param logging: turn file logging on or off
- @type logging: bool
+ Args:
+ fft_length: total number of subcarriers (int)
+ cp_length: length of cyclic prefix as specified in subcarriers (<= fft_length) (int)
+ occupied_tones: number of subcarriers used for data (int)
+ snr: estimated signal to noise ratio used to guide cyclic prefix synchronizer (float)
+ ks: known symbols used as preambles to each packet (list of lists)
+ logging: turn file logging on or off (bool)
"""
gr.hier_block2.__init__(self, "ofdm_receiver",
@@ -67,12 +70,12 @@ class ofdm_receiver(gr.hier_block2):
bw = (float(occupied_tones) / float(fft_length)) / 2.0
tb = bw*0.08
- chan_coeffs = gr.firdes.low_pass (1.0, # gain
- 1.0, # sampling rate
- bw+tb, # midpoint of trans. band
- tb, # width of trans. band
- gr.firdes.WIN_HAMMING) # filter type
- self.chan_filt = gr.fft_filter_ccc(1, chan_coeffs)
+ chan_coeffs = filter.firdes.low_pass (1.0, # gain
+ 1.0, # sampling rate
+ bw+tb, # midpoint of trans. band
+ tb, # width of trans. band
+ filter.firdes.WIN_HAMMING) # filter type
+ self.chan_filt = filter.fft_filter_ccc(1, chan_coeffs)
win = [1 for i in range(fft_length)]
@@ -107,7 +110,7 @@ class ofdm_receiver(gr.hier_block2):
# for testing only; do not user over the air
# remove filter and filter delay for this
elif SYNC == "fixed":
- self.chan_filt = gr.multiply_const_cc(1.0)
+ self.chan_filt = blocks.multiply_const_cc(1.0)
nsymbols = 18 # enter the number of symbols per packet
freq_offset = 0.0 # if you use a frequency offset, enter it here
nco_sensitivity = -2.0/fft_length # correct for fine frequency
@@ -119,11 +122,11 @@ class ofdm_receiver(gr.hier_block2):
# Set up blocks
- self.nco = gr.frequency_modulator_fc(nco_sensitivity) # generate a signal proportional to frequency error of sync block
- self.sigmix = gr.multiply_cc()
- self.sampler = digital_swig.ofdm_sampler(fft_length, fft_length+cp_length)
- self.fft_demod = gr.fft_vcc(fft_length, True, win, True)
- self.ofdm_frame_acq = digital_swig.ofdm_frame_acquisition(occupied_tones,
+ self.nco = analog.frequency_modulator_fc(nco_sensitivity) # generate a signal proportional to frequency error of sync block
+ self.sigmix = blocks.multiply_cc()
+ self.sampler = digital.ofdm_sampler(fft_length, fft_length+cp_length)
+ self.fft_demod = fft.fft_vcc(fft_length, True, win, True)
+ self.ofdm_frame_acq = digital.ofdm_frame_acquisition(occupied_tones,
fft_length,
cp_length, ks[0])
@@ -141,11 +144,11 @@ class ofdm_receiver(gr.hier_block2):
self.connect((self.ofdm_frame_acq,1), (self,1)) # frame and symbol timing, and equalization
if logging:
- self.connect(self.chan_filt, gr.file_sink(gr.sizeof_gr_complex, "ofdm_receiver-chan_filt_c.dat"))
- self.connect(self.fft_demod, gr.file_sink(gr.sizeof_gr_complex*fft_length, "ofdm_receiver-fft_out_c.dat"))
+ self.connect(self.chan_filt, blocks.file_sink(gr.sizeof_gr_complex, "ofdm_receiver-chan_filt_c.dat"))
+ self.connect(self.fft_demod, blocks.file_sink(gr.sizeof_gr_complex*fft_length, "ofdm_receiver-fft_out_c.dat"))
self.connect(self.ofdm_frame_acq,
- gr.file_sink(gr.sizeof_gr_complex*occupied_tones, "ofdm_receiver-frame_acq_c.dat"))
- self.connect((self.ofdm_frame_acq,1), gr.file_sink(1, "ofdm_receiver-found_corr_b.dat"))
- self.connect(self.sampler, gr.file_sink(gr.sizeof_gr_complex*fft_length, "ofdm_receiver-sampler_c.dat"))
- self.connect(self.sigmix, gr.file_sink(gr.sizeof_gr_complex, "ofdm_receiver-sigmix_c.dat"))
- self.connect(self.nco, gr.file_sink(gr.sizeof_gr_complex, "ofdm_receiver-nco_c.dat"))
+ blocks.file_sink(gr.sizeof_gr_complex*occupied_tones, "ofdm_receiver-frame_acq_c.dat"))
+ self.connect((self.ofdm_frame_acq,1), blocks.file_sink(1, "ofdm_receiver-found_corr_b.dat"))
+ self.connect(self.sampler, blocks.file_sink(gr.sizeof_gr_complex*fft_length, "ofdm_receiver-sampler_c.dat"))
+ self.connect(self.sigmix, blocks.file_sink(gr.sizeof_gr_complex, "ofdm_receiver-sigmix_c.dat"))
+ self.connect(self.nco, blocks.file_sink(gr.sizeof_gr_complex, "ofdm_receiver-nco_c.dat"))