2 # Copyright 2006 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 2, 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, blks
30 FLEX pager protocol demodulation block.
32 This block demodulates a band-limited, complex down-converted baseband
33 channel into FLEX protocol frames.
37 RSAMP - Resample incoming stream to 16000 sps
38 QUAD - Quadrature demodulator converts FSK to baseband amplitudes
39 LPF - Low pass filter to remove noise prior to slicer
40 SLICER - Converts input to one of four symbols (0, 1, 2, 3)
41 SYNC - Converts symbol stream to four phases of FLEX blocks
42 DEINTx - Deinterleaves FLEX blocks into datawords
43 PARSEx - Parse a single FLEX phase worth of data words into pages
47 @param channel_rate: incoming sample rate of the baseband channel
48 @type sample_rate: integer
52 def __init__(self, fg, channel_rate, queue):
53 k = chan_rate/(2*pi*4800) # 4800 Hz max deviation
54 QUAD = gr.quadrature_demod_cf(k)
57 if channel_rate != chan_rate:
58 interp = gru.lcm(channel_rate, chan_rate)/channel_rate
59 decim = gru.lcm(channel_rate, chan_rate)/chan_rate
60 RESAMP = blks.rational_resampler_ccf(fg, interp, decim)
63 taps = optfir.low_pass(1.0, chan_rate, 3200, 6400, 0.1, 60)
64 LPF = gr.fir_filter_fff(1, taps)
65 SLICER = pager_swig.slicer_fb(.001, .00001) # Attack, decay
66 SYNC = pager_swig.flex_sync(chan_rate)
68 if channel_rate != chan_rate:
69 fg.connect(RESAMP, QUAD, LPF, SLICER, SYNC)
71 fg.connect(QUAD, LPF, SLICER, SYNC)
73 DEINTA = pager_swig.flex_deinterleave()
74 PARSEA = pager_swig.flex_parse(queue)
76 DEINTB = pager_swig.flex_deinterleave()
77 PARSEB = pager_swig.flex_parse(queue)
79 DEINTC = pager_swig.flex_deinterleave()
80 PARSEC = pager_swig.flex_parse(queue)
82 DEINTD = pager_swig.flex_deinterleave()
83 PARSED = pager_swig.flex_parse(queue)
85 fg.connect((SYNC, 0), DEINTA, PARSEA)
86 fg.connect((SYNC, 1), DEINTB, PARSEB)
87 fg.connect((SYNC, 2), DEINTC, PARSEC)
88 fg.connect((SYNC, 3), DEINTD, PARSED)