3 Copyright 2009 Free Software Foundation, Inc.
4 This file is part of GNU Radio
6 GNU Radio Companion is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation; either version 2
9 of the License, or (at your option) any later version.
11 GNU Radio Companion is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
21 from gnuradio import usrp
28 from gnuradio.grc.gui.Dialogs import TextDisplay
30 from gnuradio.grc.python.Platform import Platform
33 flow_graph = platform.get_new_flow_graph()
34 block = flow_graph.get_new_block('usrp_probe')
37 usrp_which_param = block.get_param('which')
38 usrp_dboard_param = block.get_param('dboard')
42 input = param.get_input()
45 class USRPProbeWindow(gtk.Window):
47 The main window for USRP Dignostics.
50 def delete_event(self, widget, event, data=None): return False
52 def destroy(self, widget, data=None): gtk.main_quit()
56 USRPProbeWindow contructor.
57 Create a new gtk Dialog with a close button, USRP input paramaters, and output labels.
59 gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)
61 self.connect("delete_event", self.delete_event)
62 self.connect("destroy", self.destroy)
64 self.set_title('USRP Probe')
65 #create decorative frame
68 #create vbox for storage
71 vbox.pack_start(get_input(usrp_which_param), False)
72 vbox.pack_start(get_input(usrp_dboard_param), False)
73 self.probe_button = gtk.Button('Probe')
74 self.probe_button.connect('clicked', self._probe_usrp)
75 vbox.pack_start(self.probe_button, False)
76 #Create a text box for USRP queries
77 self.query_buffer = TextDisplay()
78 self.query_buffer.set_text(block.get_doc())
79 vbox.pack_start(self.query_buffer)
82 def _probe_usrp(self, widget=None):
83 """Probe the USRP device and copy the results into the query text box."""
84 dboard = usrp_dboard_param.evaluate()
85 side = {'a': 0, 'b': 1}[dboard[-1]]
86 if dboard.startswith('rx'): make = usrp.source_c
87 elif dboard.startswith('tx'): make = usrp.sink_c
89 u = make(which=usrp_which_param.evaluate())
90 subdev_spec = (side, 0)
91 subdev = usrp.selected_subdev(u, subdev_spec) #get the subdev
92 msg = ">>> USRP Probe\n"
93 msg = "%s\nName:\n\t%s\n"%(msg, str(subdev.name()))
94 msg = "%s\nConverter Rate:\n\t%s\n"%(msg, u.converter_rate())
95 msg = "%s\nUses Quadrature:\n\t%s\n"%(msg, str(subdev.is_quadrature()))
96 gain_min, gain_max, gain_step = subdev.gain_range()
97 msg = "%s\nGain Range (min, max, step size):\n\t%s\n\t%s\n\t%s\n"%(msg, gain_min, gain_max, gain_step)
98 freq_min, freq_max, freq_step = subdev.freq_range()
99 msg = "%s\nFreq Range (min, max, step size):\n\t%s\n\t%s\n\t%s\n"%(msg, freq_min, freq_max, freq_step)
100 self.query_buffer.set_text(msg)
101 except Exception, e: #display the error message
102 self.query_buffer.set_text('''\
105 If the USRP cannot be found, make sure that the USRP is plugged-in and restart this program. \
106 If the problem persists, there may be a problem with you gnuradio installation or USB 2.0.
109 if __name__ == '__main__':
110 #setup icon using icon theme
111 try: gtk.window_set_default_icon(gtk.IconTheme().load_icon('gnuradio-grc', 256, 0))