Fixed spelling error: s/writeable/writable/g
[debian/gnuradio] / gr-msdd6000 / src / python / benchmark_msdd6000.py
1 #!/usr/bin/env python
2 #
3 # Copyright 2008 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, gr_unittest
24 from gnuradio import msdd
25 from gnuradio.eng_option import eng_option
26 from optparse import OptionParser
27
28 class benchmark_msdd6000(gr.top_block):
29     def __init__(self, address, options):
30         gr.top_block.__init__(self)
31
32         self.frequency = options.frequency
33         self.filename  = options.filename
34         self.decim     = options.decim
35         self.gain      = options.gain
36         self.address   = address
37
38         self.port = 10001
39
40         src = msdd.source_c(0, 1, self.address, self.port)
41         src.set_decim_rate(self.decim)
42         src.set_desired_packet_size(0, 1460)
43         src.set_pga(0, self.gain)
44         src.set_rx_freq(0, self.frequency)
45
46         print "Min PGA: ", src.pga_min()
47         print "Max PGA: ", src.pga_max()
48         print "PGA:     ", src.pga(0)
49         print "Decim:   ", src.decim_rate()
50         print "Freq:    ", src.rx_freq(0)
51         
52         snk = gr.file_sink(gr.sizeof_gr_complex, self.filename)
53         self.connect(src, snk)
54         
55 def main():
56     usage="%prog: [options] host_address"
57     parser = OptionParser(usage=usage, option_class=eng_option, conflict_handler="resolve")
58     parser.add_option("-f", "--frequency", type="eng_float", default=100e6,
59                       help="set frequency (Hz) [default=%default]")
60     parser.add_option("-d", "--decim", type="int", default=256,
61                       help="set decimation rate [default=%default]")
62     parser.add_option("-g", "--gain", type="int", default=32,
63                       help="set receiver gain (dB) [default=%default]")
64     parser.add_option("-F", "--filename", type="string", default="output.dat",
65                       help="set output filename [default=%default]")
66     (options, args) = parser.parse_args ()
67     host_address = args[0]
68
69     tb = benchmark_msdd6000(host_address, options)
70     tb.start()
71     tb.wait()
72
73 if __name__ == '__main__':
74     main()