2 # Copyright 2006,2007 Free Software Foundation, Inc.
4 # This file is part of GNU Radio
6 # GNU Radio is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3, or (at your option)
11 # GNU Radio is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with GNU Radio; see the file COPYING. If not, write to
18 # the Free Software Foundation, Inc., 51 Franklin Street,
19 # Boston, MA 02110-1301, USA.
22 from gnuradio import gr, gru, optfir, blks2
26 class flex_demod(gr.hier_block2):
28 FLEX pager protocol demodulation block.
30 This block demodulates a band-limited, complex down-converted baseband
31 channel into FLEX protocol frames.
35 def __init__(self, queue, freq=0.0, verbose=False, log=False):
36 gr.hier_block2.__init__(self, "flex_demod",
37 gr.io_signature(1, 1, gr.sizeof_gr_complex),
38 gr.io_signature(0,0,0))
40 k = 25000/(2*pi*1600) # 4800 Hz max deviation
41 quad = gr.quadrature_demod_cf(k)
42 self.connect(self, quad)
44 rsamp = blks2.rational_resampler_fff(16, 25)
45 self.slicer = pager_swig.slicer_fb(5e-6) # DC removal averaging filter constant
46 self.sync = pager_swig.flex_sync()
48 self.connect(quad, rsamp, self.slicer, self.sync)
51 self.connect((self.sync, i), pager_swig.flex_deinterleave(), pager_swig.flex_parse(queue, freq))
54 suffix = '_'+ "%3.3f" % (freq/1e6,) + '.dat'
55 quad_sink = gr.file_sink(gr.sizeof_float, 'quad'+suffix)
56 rsamp_sink = gr.file_sink(gr.sizeof_float, 'rsamp'+suffix)
57 slicer_sink = gr.file_sink(gr.sizeof_char, 'slicer'+suffix)
58 self.connect(rsamp, rsamp_sink)
59 self.connect(quad, quad_sink)
60 self.connect(self.slicer, slicer_sink)
63 return self.slicer.dc_offset()