Imported Upstream version 3.2.2
[debian/gnuradio] / gnuradio-core / src / python / gnuradio / blks2impl / ofdm_sync_fixed.py
1 #!/usr/bin/env python
2 #
3 # Copyright 2007 Free Software Foundation, Inc.
4
5 # This file is part of GNU Radio
6
7 # GNU Radio is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3, or (at your option)
10 # any later version.
11
12 # GNU Radio is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU General Public License for more details.
16
17 # You should have received a copy of the GNU General Public License
18 # along with GNU Radio; see the file COPYING.  If not, write to
19 # the Free Software Foundation, Inc., 51 Franklin Street,
20 # Boston, MA 02110-1301, USA.
21
22
23 import math
24 from gnuradio import gr
25
26 class ofdm_sync_fixed(gr.hier_block2):
27     def __init__(self, fft_length, cp_length, nsymbols, freq_offset, logging=False):
28
29         gr.hier_block2.__init__(self, "ofdm_sync_fixed",
30                                 gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature
31                                 gr.io_signature2(2, 2, gr.sizeof_float, gr.sizeof_char)) # Output signature
32
33         # Use a fixed trigger point instead of sync block
34         symbol_length = fft_length + cp_length
35         pkt_length = nsymbols*symbol_length
36         data = (pkt_length)*[0,]
37         data[(symbol_length)-1] = 1
38         self.peak_trigger = gr.vector_source_b(data, True)
39
40         # Use a pre-defined frequency offset
41         foffset = (pkt_length)*[math.pi*freq_offset,]
42         self.frequency_offset = gr.vector_source_f(foffset, True)
43
44         self.connect(self, gr.null_sink(gr.sizeof_gr_complex))
45         self.connect(self.frequency_offset, (self,0))
46         self.connect(self.peak_trigger, (self,1))
47
48         if logging:
49             self.connect(self.peak_trigger, gr.file_sink(gr.sizeof_char, "ofdm_sync_fixed-peaks_b.dat"))
50