Imported Upstream version 3.0
[debian/gnuradio] / gnuradio-core / src / python / bin / microtune.py
1 #!/usr/bin/env python
2 # -*- Python -*-
3
4 from gnuradio import gr
5 from gnuradio.eng_option import eng_option
6 from gnuradio.wxgui import stdgui, fftsink
7 from optparse import OptionParser
8 from gnuradio import eng_notation
9
10
11 def main ():
12     parser = OptionParser (option_class=eng_option)
13     parser.add_option ("-g", "--gain", type="eng_float", default=-1,
14                        help="set front end gain to GAIN [0,1000]")
15     parser.add_option ("-f", "--freq", type="eng_float", default=-1,
16                        help="set front end center frequency to FREQ")
17     parser.add_option ("-t", "--type", type="string", default="4937",
18                        help="select eval board type {4937 or 4702}")
19     parser.add_option ("-p", "--port", type="int", default=0,
20                        help="parallel port eval board is attached to")
21     (options, args) = parser.parse_args ()
22
23     if options.type == "4937":
24         front_end = gr.microtune_4937_eval_board (options.port)
25     elif options.type == "4702":
26         front_end = gr.microtune_4702_eval_board (options.port)
27     else:
28         raise RuntimeError, "Invalid board type.  Must be either -t 4937 or -t 4702"
29
30     if options.gain != -1:
31         front_end.set_AGC (options.gain)
32
33     if options.freq != -1:
34         if options.freq < 1e6:
35             options.freq = options.freq * 1e6
36
37         actual = front_end.set_RF_freq (options.freq)
38         print "microtune: actual freq = %s" %  (eng_notation.num_to_str (actual),)
39         
40
41 if __name__ == '__main__':
42     main ()