Merge r6461:6464 from jcorgan/t162-staging into trunk.
[debian/gnuradio] / gnuradio-examples / python / dect / usrp_dect.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 from gnuradio import gr, eng_notation
24 from gnuradio.eng_option import eng_option
25 from optparse import OptionParser
26 from dect_receiver import dect_receiver
27 import sys
28
29 def main():
30         parser = OptionParser(option_class=eng_option)
31         parser.add_option("-R", "--rx-subdev-spec", type="subdev", default=None,
32                           help="select USRP Rx side A or B (default=first one with a daughterboard)")
33         parser.add_option("-f", "--freq", type="eng_float", default=None,
34                           help="set frequency to FREQ", metavar="FREQ")
35         parser.add_option("", "--calibration", type="eng_float", default=0.0,
36                           help="set frequency calibration offset to FREQ")
37         parser.add_option("-g", "--gain", type="eng_float", default=None,
38                           help="set gain in dB (default is midpoint)")
39         parser.add_option("-v", "--verbose", action="store_true", default=False,
40                           help="print extra debugging info")
41         parser.add_option("", "--log-baseband", default=None,
42                           help="log filtered baseband to file")
43         parser.add_option("", "--log-demod", default=None,
44                           help="log demodulator output to file")
45         (options, args) = parser.parse_args()
46
47         if len(sys.argv) == 1 or len(args) != 0:
48             parser.print_help()
49             sys.exit(1)
50         
51         # Create an instance of a hierarchical block
52         top_block = dect_receiver(options)
53                               
54         try:    
55             # Run forever
56             top_block.run()
57         except KeyboardInterrupt:
58             # Ctrl-C exits
59             pass
60
61 if __name__ == '__main__':
62     main ()