summaryrefslogtreecommitdiff
path: root/grc/scripts
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2011-03-13 17:33:33 -0700
committerJosh Blum <josh@joshknows.com>2011-03-13 17:33:33 -0700
commit07bd878bc30f7ab54afc1e2f0055419388c3c992 (patch)
tree4e8113c440c8c287ea4a8239879d1cebd9e419ed /grc/scripts
parentb812a91c0beb33ff755f4426f36a2a3e2c9b295c (diff)
grc: moved all usrp1 and usrp2 stuff out of grc and into gr-usrp*/grc
Moved grc xml files, python wrappers (USRP1 only), probe apps + freedesktop files. When the gr-usrp and gr-usrp2 directories are removed, grc will not have to change. Minor change: the freedesktop files are always installed now. This does not mean that they are installed properly with xdg, it just means that the runtime can have access to the icons.
Diffstat (limited to 'grc/scripts')
-rw-r--r--grc/scripts/Makefile.am4
-rwxr-xr-xgrc/scripts/usrp2_probe163
-rwxr-xr-xgrc/scripts/usrp_probe115
3 files changed, 2 insertions, 280 deletions
diff --git a/grc/scripts/Makefile.am b/grc/scripts/Makefile.am
index 9019ec5cc9..84e2759dca 100644
--- a/grc/scripts/Makefile.am
+++ b/grc/scripts/Makefile.am
@@ -1,5 +1,5 @@
#
-# Copyright 2008, 2009, 2010 Free Software Foundation, Inc.
+# Copyright 2008-2011 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -21,4 +21,4 @@
include $(top_srcdir)/Makefile.common
-dist_bin_SCRIPTS = gnuradio-companion usrp2_probe usrp_probe
+dist_bin_SCRIPTS = gnuradio-companion
diff --git a/grc/scripts/usrp2_probe b/grc/scripts/usrp2_probe
deleted file mode 100755
index 38c8f655ce..0000000000
--- a/grc/scripts/usrp2_probe
+++ /dev/null
@@ -1,163 +0,0 @@
-#!/usr/bin/env python
-"""
-Copyright 2009 Free Software Foundation, Inc.
-This file is part of GNU Radio
-
-GNU Radio Companion is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-GNU Radio Companion is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
-"""
-
-from gnuradio import usrp2
-import subprocess
-import os
-
-import pygtk
-pygtk.require('2.0')
-import gtk
-import gobject
-
-from gnuradio.grc.gui.Dialogs import TextDisplay
-
-from gnuradio.grc.python.Platform import Platform
-platform = Platform()
-
-flow_graph = platform.get_new_flow_graph()
-block = flow_graph.get_new_block('usrp2_probe')
-
-##all params
-usrp_interface_param = block.get_param('interface')
-usrp_type_param = block.get_param('type')
-
-def get_input(param):
- param.validate()
- input = param.get_input()
- return input
-
-class USRP2ProbeWindow(gtk.Window):
- """
- The main window for USRP Dignostics.
- """
-
- def delete_event(self, widget, event, data=None): return False
-
- def destroy(self, widget, data=None): gtk.main_quit()
-
- def __init__(self):
- """
- USRP2ProbeWindow contructor.
- Create a new gtk Dialog with a close button, USRP2 input paramaters, and output labels.
- """
- self.usrp2_macs = list()
- gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)
- #quit signals
- self.connect("delete_event", self.delete_event)
- self.connect("destroy", self.destroy)
- #set the title
- self.set_title('USRP2 Probe')
- #create decorative frame
- frame = gtk.Frame()
- self.add(frame)
- #create vbox for storage
- vbox = gtk.VBox()
- frame.add(vbox)
- vbox.pack_start(get_input(usrp_interface_param), False)
- vbox.pack_start(get_input(usrp_type_param), False)
- #make the tree model for holding mac addrs
- self.treestore = gtk.TreeStore(gobject.TYPE_STRING)
- self.treeview = gtk.TreeView(self.treestore)
- self.treeview.set_enable_search(False) #disable pop up search box
- self.treeview.add_events(gtk.gdk.BUTTON_PRESS_MASK)
- self.treeview.connect('button_press_event', self._handle_selection)
- selection = self.treeview.get_selection()
- selection.set_mode('single')
- selection.connect('changed', self._handle_selection)
- renderer = gtk.CellRendererText()
- column = gtk.TreeViewColumn('Select a USRP2 MAC Address', renderer, text=0)
- self.treeview.append_column(column)
- vbox.pack_start(self.treeview, False)
- #create probe button
- self.probe_button = gtk.Button('Probe')
- self.probe_button.connect('clicked', self._probe_usrp2)
- vbox.pack_start(self.probe_button, False)
- #Create a text box for USRP queries
- self.query_buffer = TextDisplay()
- self.query_buffer.set_text(block.get_doc())
- vbox.pack_start(self.query_buffer)
- self.show_all()
- self.treeview.hide()
-
- def _probe_usrp2(self, widget=None):
- """Probe the USRP2 device and copy the results into the query text box."""
- #call find usrps
- args = ['find_usrps']
- interface = usrp_interface_param.evaluate()
- if interface: args.extend(['-e', interface])
- p = subprocess.Popen(args=args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=False, universal_newlines=True)
- msg = p.stdout.read()
- #extract mac addrs
- self.usrp2_macs = sorted(map(lambda l: l.split()[0], filter(lambda l: l.count(':') >= 5, msg.strip().splitlines())))
- #set the tree store with the mac addrs
- self.treestore.clear()
- for usrp2_mac in self.usrp2_macs: self.treestore.append(None, (usrp2_mac,))
- #set the text with the error message for 0 found, hide the list
- #when only 1 usrp2, auto handle selection, hide the list
- #for multiple usrp2, show the list
- if not self.usrp2_macs:
- self.treeview.hide()
- self.query_buffer.set_text(msg)
- elif len(self.usrp2_macs) == 1:
- self.treeview.hide()
- self.query_buffer.set_text('')
- self._handle_selection()
- else:
- self.treeview.show()
- self.query_buffer.set_text('')
-
- def _handle_selection(self, *args, **kwargs):
- """A selection change or click occured."""
- #get the mac addr
- selection = self.treeview.get_selection()
- treestore, iter = selection.get_selected()
- mac_addr = iter and treestore.get_value(iter, 0) or ''
- if not mac_addr and len(self.usrp2_macs) > 1:
- return #no empty mac addrs for when multiple found
- #make the usrp2 object
- make, rate_attr = {
- 'rx': (usrp2.source_32fc, 'adc_rate'),
- 'tx': (usrp2.sink_32fc, 'dac_rate'),
- }[usrp_type_param.evaluate()]
- interface = usrp_interface_param.evaluate()
- try:
- if not interface and not mac_addr: u = make()
- elif not mac_addr: u = make(interface)
- else: u = make(interface, mac_addr)
- msg = ">>> USRP2 Probe\n"
- msg = "%s\nMAC Addr:\n\t%s\n"%(msg, u.mac_addr())
- msg = "%s\nName (ID):\n\t%s\n"%(msg, u.daughterboard_id())
- msg = "%s\nConverter Rate:\n\t%s Hz\n"%(msg, getattr(u, rate_attr)())
- gain_min, gain_max, gain_step = u.gain_range()
- 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)
- freq_min, freq_max = u.freq_range()
- msg = "%s\nFreq Range (min, max):\n\t%s Hz\n\t%s Hz\n"%(msg, freq_min, freq_max)
- self.query_buffer.set_text(msg)
- except Exception, e: #display the error message
- self.query_buffer.set_text('>>> Error\n%s'%str(e))
-
-if __name__ == '__main__':
- #setup icon using icon theme
- try: gtk.window_set_default_icon(gtk.IconTheme().load_icon('gnuradio-grc', 256, 0))
- except: pass
- #enter the mainloop
- USRP2ProbeWindow()
- gtk.main()
diff --git a/grc/scripts/usrp_probe b/grc/scripts/usrp_probe
deleted file mode 100755
index d2e92e7530..0000000000
--- a/grc/scripts/usrp_probe
+++ /dev/null
@@ -1,115 +0,0 @@
-#!/usr/bin/env python
-"""
-Copyright 2009 Free Software Foundation, Inc.
-This file is part of GNU Radio
-
-GNU Radio Companion is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-GNU Radio Companion is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
-"""
-
-from gnuradio import usrp
-import os
-
-import pygtk
-pygtk.require('2.0')
-import gtk
-
-from gnuradio.grc.gui.Dialogs import TextDisplay
-
-from gnuradio.grc.python.Platform import Platform
-platform = Platform()
-
-flow_graph = platform.get_new_flow_graph()
-block = flow_graph.get_new_block('usrp_probe')
-
-##all params
-usrp_which_param = block.get_param('which')
-usrp_dboard_param = block.get_param('dboard')
-
-def get_input(param):
- param.validate()
- input = param.get_input()
- return input
-
-class USRPProbeWindow(gtk.Window):
- """
- The main window for USRP Dignostics.
- """
-
- def delete_event(self, widget, event, data=None): return False
-
- def destroy(self, widget, data=None): gtk.main_quit()
-
- def __init__(self):
- """
- USRPProbeWindow contructor.
- Create a new gtk Dialog with a close button, USRP input paramaters, and output labels.
- """
- gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)
- #quit signals
- self.connect("delete_event", self.delete_event)
- self.connect("destroy", self.destroy)
- #set the title
- self.set_title('USRP Probe')
- #create decorative frame
- frame = gtk.Frame()
- self.add(frame)
- #create vbox for storage
- vbox = gtk.VBox()
- frame.add(vbox)
- vbox.pack_start(get_input(usrp_which_param), False)
- vbox.pack_start(get_input(usrp_dboard_param), False)
- self.probe_button = gtk.Button('Probe')
- self.probe_button.connect('clicked', self._probe_usrp)
- vbox.pack_start(self.probe_button, False)
- #Create a text box for USRP queries
- self.query_buffer = TextDisplay()
- self.query_buffer.set_text(block.get_doc())
- vbox.pack_start(self.query_buffer)
- self.show_all()
-
- def _probe_usrp(self, widget=None):
- """Probe the USRP device and copy the results into the query text box."""
- dboard = usrp_dboard_param.evaluate()
- side = {'a': 0, 'b': 1}[dboard[-1]]
- if dboard.startswith('rx'): make = usrp.source_c
- elif dboard.startswith('tx'): make = usrp.sink_c
- try:
- u = make(which=usrp_which_param.evaluate())
- subdev_spec = (side, 0)
- subdev = usrp.selected_subdev(u, subdev_spec) #get the subdev
- msg = ">>> USRP Probe\n"
- msg = "%s\nName:\n\t%s\n"%(msg, str(subdev.name()))
- msg = "%s\nConverter Rate:\n\t%s\n"%(msg, u.converter_rate())
- msg = "%s\nUses Quadrature:\n\t%s\n"%(msg, str(subdev.is_quadrature()))
- gain_min, gain_max, gain_step = subdev.gain_range()
- 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)
- freq_min, freq_max, freq_step = subdev.freq_range()
- 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)
- self.query_buffer.set_text(msg)
- except Exception, e: #display the error message
- self.query_buffer.set_text('''\
->>> Error\n%s
-
-If the USRP cannot be found, make sure that the USRP is plugged-in and restart this program. \
-If the problem persists, there may be a problem with you gnuradio installation or USB 2.0.
-'''%str(e))
-
-if __name__ == '__main__':
- #setup icon using icon theme
- try: gtk.window_set_default_icon(gtk.IconTheme().load_icon('gnuradio-grc', 256, 0))
- except: pass
- #enter the mainloop
- USRPProbeWindow()
- gtk.main()