3 # Copyright 2006,2007,2009 Free Software Foundation, Inc.
5 # This file is part of GNU Radio
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)
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.
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.
23 from gnuradio import gr, gru, usrp, optfir, eng_notation, blks2, pager
24 from gnuradio.eng_option import eng_option
25 from optparse import OptionParser
26 from string import split, join, printable
29 class app_top_block(gr.top_block):
30 def __init__(self, options, queue):
31 gr.top_block.__init__(self, "usrp_flex_all")
33 if options.from_file is not None:
34 src = gr.file_source(gr.sizeof_gr_complex, options.from_file)
36 print "Reading samples from file", options.from_file
39 if options.rx_subdev_spec is None:
40 options.rx_subdev_spec = usrp.pick_rx_subdevice(src)
41 subdev = usrp.selected_subdev(src, options.rx_subdev_spec)
42 src.set_mux(usrp.determine_rx_mux_value(src, options.rx_subdev_spec))
43 src.set_decim_rate(20)
44 result = usrp.tune(src, 0, subdev, 930.5125e6+options.calibration)
46 print "Using", subdev.name(), " for receiving."
47 print "Tuned USRP to", 930.5125e6+options.calibration
49 taps = gr.firdes.low_pass(1.0,
56 print "Channel filter has", len(taps), "taps"
58 bank = blks2.analysis_filterbank(128, taps)
59 self.connect(src, bank)
61 if options.log and options.from_file == None:
62 src_sink = gr.file_sink(gr.sizeof_gr_complex, 'usrp.dat')
63 self.connect(src, src_sink)
69 freq = 928.9e6+(i-64)*25e3
71 if (freq < 929.0e6 or freq > 932.0e6):
72 self.connect((bank, i), gr.null_sink(gr.sizeof_gr_complex))
74 self.connect((bank, i), pager.flex_demod(queue, freq, options.verbose, options.log))
76 self.connect((bank, i), gr.file_sink(gr.sizeof_gr_complex, 'chan_'+'%3.3f'%(freq/1e6)+'.dat'))
79 parser = OptionParser(option_class=eng_option)
80 parser.add_option("-R", "--rx-subdev-spec", type="subdev",
81 help="select USRP Rx side A or B (default=first daughterboard found)")
82 parser.add_option("-c", "--calibration", type="eng_float", default=0.0,
83 help="set frequency offset to Hz", metavar="Hz")
84 parser.add_option("-g", "--gain", type="int",
85 help="set RF gain", metavar="dB")
86 parser.add_option("-F", "--from-file", default=None,
87 help="Read from file instead of USRP")
88 parser.add_option("-l", "--log", action="store_true", default=False,
89 help="log flowgraph to files (LOTS of data)")
90 parser.add_option("-v", "--verbose", action="store_true", default=False,
91 help="display debug output")
92 (options, args) = parser.parse_args()
97 queue = gr.msg_queue()
98 tb = app_top_block(options, queue)
99 runner = pager.queue_runner(queue)
103 except KeyboardInterrupt:
108 if __name__ == "__main__":