3 # Copyright 2008 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
24 from gnuradio import msdd
25 from gnuradio.eng_option import eng_option
26 from optparse import OptionParser
29 class benchmark_msdd6000(gr.top_block):
30 def __init__(self, address, options):
31 gr.top_block.__init__(self)
33 # Extract the initial options
34 self.frequency = options.frequency
35 self.filename = options.filename
36 self.decim = options.decim
37 self.gain = options.gain
38 self.address = address
40 # Set up and initialize the MSDD receiver
41 self.port = 10001 # required port
42 self.src = msdd.source_c(0, 1, self.address, self.port)
43 self.src.set_decim_rate(self.decim)
44 self.src.set_desired_packet_size(0, 1460)
45 self.src.set_pga(0, self.gain)
46 self.src.set_rx_freq(0, self.frequency)
49 print "Min PGA: ", self.src.pga_min()
50 print "Max PGA: ", self.src.pga_max()
51 print "PGA: ", self.src.pga(0)
52 print "Decim: ", self.src.decim_rate()
53 print "Freq: ", self.src.rx_freq(0)
55 # Build a file sink to save the info for post analysis
56 self.snk = gr.file_sink(gr.sizeof_gr_complex, self.filename)
58 # Connect the reciever source to file sink
59 self.connect(self.src, self.snk)
62 ''' This is a simple little script to play with retunning of the MSDD board.
63 You can cycle through frequencies or the attenuation of the board here.
66 usage="%prog: [options] host_address"
67 parser = OptionParser(usage=usage, option_class=eng_option, conflict_handler="resolve")
68 parser.add_option("-f", "--frequency", type="eng_float", default=100e6,
69 help="set frequency (Hz) [default=%default]")
70 parser.add_option("-d", "--decim", type="int", default=256,
71 help="set decimation rate [default=%default]")
72 parser.add_option("-g", "--gain", type="int", default=32,
73 help="set receiver gain (dB) [default=%default]")
74 parser.add_option("-F", "--filename", type="string", default="output.dat",
75 help="set output filename [default=%default]")
76 (options, args) = parser.parse_args ()
77 host_address = args[0]
79 # Set up benchmark system that simply connects the MSDD source to a file sink
80 tb = benchmark_msdd6000(host_address, options)
81 tb.start() # start it here
83 # Adjust your parameters here. Use the time.sleep(x) function to set a wait period
84 # between adjusting the parameter.
88 freq = (tb.src.rx_freq(0) + 1) * 1e6
89 tb.src.set_rx_freq(0, freq)
90 print "Setting frequency: ", freq
92 pga = tb.src.pga(0)+10
93 tb.src.set_pga(0, pga)
94 print "Setting PGA: ", pga
96 tb.stop() # stop the radio
98 if __name__ == '__main__':