diff options
author | Tom Rondeau | 2011-04-08 15:37:29 -0400 |
---|---|---|
committer | Tom Rondeau | 2011-04-08 15:37:29 -0400 |
commit | 21b64f070a3eb38ab044529a6ddd9cd6b6d0a2cb (patch) | |
tree | 4e72909a051b0a4ac428252d15f34b53bcc986b6 /gr-usrp2/grc | |
parent | d7093fd06d0ec37f6ba2841d202fe90f4fa3661e (diff) | |
parent | 5c358afd00347f5da7a59dd73ea79cd3df26659d (diff) | |
download | gnuradio-21b64f070a3eb38ab044529a6ddd9cd6b6d0a2cb.tar.gz gnuradio-21b64f070a3eb38ab044529a6ddd9cd6b6d0a2cb.tar.bz2 gnuradio-21b64f070a3eb38ab044529a6ddd9cd6b6d0a2cb.zip |
Merge branch 'master' into constell_obj
Conflicts:
gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.h
gr-audio-oss/src/Makefile.swig.gen
gr-audio/swig/Makefile.swig.gen
Diffstat (limited to 'gr-usrp2/grc')
-rw-r--r-- | gr-usrp2/grc/.gitignore | 2 | ||||
-rw-r--r-- | gr-usrp2/grc/Makefile.am | 33 | ||||
-rw-r--r-- | gr-usrp2/grc/gnuradio-usrp2_probe.desktop | 7 | ||||
-rwxr-xr-x | gr-usrp2/grc/usrp2_probe | 163 | ||||
-rw-r--r-- | gr-usrp2/grc/usrp2_probe.xml | 33 | ||||
-rw-r--r-- | gr-usrp2/grc/usrp2_sink_xxxx.xml | 121 | ||||
-rw-r--r-- | gr-usrp2/grc/usrp2_source_xxxx.xml | 119 |
7 files changed, 478 insertions, 0 deletions
diff --git a/gr-usrp2/grc/.gitignore b/gr-usrp2/grc/.gitignore new file mode 100644 index 000000000..b336cc7ce --- /dev/null +++ b/gr-usrp2/grc/.gitignore @@ -0,0 +1,2 @@ +/Makefile +/Makefile.in diff --git a/gr-usrp2/grc/Makefile.am b/gr-usrp2/grc/Makefile.am new file mode 100644 index 000000000..2502bf363 --- /dev/null +++ b/gr-usrp2/grc/Makefile.am @@ -0,0 +1,33 @@ +# +# Copyright 2011 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio 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 3, or (at your option) +# any later version. +# +# GNU Radio 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 GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +include $(top_srcdir)/Makefile.common + +dist_bin_SCRIPTS = usrp2_probe + +grcblocksdir = $(grc_blocksdir) +dist_grcblocks_DATA = \ + usrp2_probe.xml \ + usrp2_source_xxxx.xml \ + usrp2_sink_xxxx.xml + +ourdatadir = $(pkgdatadir)/grc/freedesktop +dist_ourdata_DATA = gnuradio-usrp2_probe.desktop diff --git a/gr-usrp2/grc/gnuradio-usrp2_probe.desktop b/gr-usrp2/grc/gnuradio-usrp2_probe.desktop new file mode 100644 index 000000000..c71a092b1 --- /dev/null +++ b/gr-usrp2/grc/gnuradio-usrp2_probe.desktop @@ -0,0 +1,7 @@ +[Desktop Entry] +Version=1.0 +Type=Application +Name=USRP2 Probe +Exec=usrp2_probe +Categories=Development; +Icon=gnuradio-grc diff --git a/gr-usrp2/grc/usrp2_probe b/gr-usrp2/grc/usrp2_probe new file mode 100755 index 000000000..38c8f655c --- /dev/null +++ b/gr-usrp2/grc/usrp2_probe @@ -0,0 +1,163 @@ +#!/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/gr-usrp2/grc/usrp2_probe.xml b/gr-usrp2/grc/usrp2_probe.xml new file mode 100644 index 000000000..cc3f9c2fd --- /dev/null +++ b/gr-usrp2/grc/usrp2_probe.xml @@ -0,0 +1,33 @@ +<?xml version="1.0"?> +<!-- +################################################### +##USRP2 Probe: +## This block should not appear in the tree. +################################################### + --> +<block> + <name>USRP2 Probe</name> + <key>usrp2_probe</key> + <make></make> + <param> + <name>Interface</name> + <key>interface</key> + <value></value> + <type>string</type> + </param> + <param> + <name>Type</name> + <key>type</key> + <value>rx</value> + <type>enum</type> + <option> + <name>RX</name> + <key>rx</key> + </option> + <option> + <name>TX</name> + <key>tx</key> + </option> + </param> + <doc>Press "Probe" to retrieve USRP2 information...</doc> +</block> diff --git a/gr-usrp2/grc/usrp2_sink_xxxx.xml b/gr-usrp2/grc/usrp2_sink_xxxx.xml new file mode 100644 index 000000000..74995da99 --- /dev/null +++ b/gr-usrp2/grc/usrp2_sink_xxxx.xml @@ -0,0 +1,121 @@ +<?xml version="1.0"?> +<!-- +################################################### +##USRP2 Sink +## Note: the center freq must be set after the lo offset +################################################### + --> +<block> + <name>USRP2 Sink</name> + <key>usrp2_sink_xxxx</key> + <category>USRP</category> + <import>from gnuradio import usrp2</import> + <make>#if not $interface() and not $mac_addr() +usrp2.sink_$(type.fcn)() +#elif not $mac_addr() +usrp2.sink_$(type.fcn)($interface) +#else +usrp2.sink_$(type.fcn)($interface, $mac_addr) +#end if +self.$(id).set_interp($interpolation) +#if $lo_offset() != float('inf') +self.$(id).set_lo_offset($lo_offset) +#end if +self.$(id).set_center_freq($frequency) +self.$(id).set_gain($gain) +self.$(id).config_mimo($usrp2_clock_src)</make> + <callback>set_interp($interpolation)</callback> + <callback>#if $lo_offset() != float('inf') +self.$(id).set_lo_offset($lo_offset) +#end if +self.$(id).set_center_freq($frequency)</callback> + <callback>set_gain($gain)</callback> + <param> + <name>Output Type</name> + <key>type</key> + <type>enum</type> + <option> + <name>Complex</name> + <key>complex</key> + <opt>fcn:32fc</opt> + <opt>vlen:1</opt> + </option> + <option> + <name>Short</name> + <key>short</key> + <opt>fcn:16sc</opt> + <opt>vlen:2</opt> + </option> + </param> + <param> + <name>Interface</name> + <key>interface</key> + <value></value> + <type>string</type> + </param> + <param> + <name>MAC Addr</name> + <key>mac_addr</key> + <value></value> + <type>string</type> + </param> + <param> + <name>Interpolation</name> + <key>interpolation</key> + <type>int</type> + </param> + <param> + <name>Frequency (Hz)</name> + <key>frequency</key> + <type>real</type> + </param> + <param> + <name>LO Offset (Hz)</name> + <key>lo_offset</key> + <value>float('inf')</value> + <type>real</type> + <hide>#if $lo_offset() == float('inf') then 'part' else 'none'#</hide> + <option> + <name>Default</name> + <key>float('inf')</key> + </option> + </param> + <param> + <name>Gain (dB)</name> + <key>gain</key> + <value>0</value> + <type>real</type> + </param> + <param> + <name>Clock Source</name> + <key>usrp2_clock_src</key> + <value>usrp2.MC_WE_DONT_LOCK</value> + <type>enum</type> + <option> + <name>Internal</name> + <key>usrp2.MC_WE_DONT_LOCK</key> + </option> + <option> + <name>External SMA</name> + <key>usrp2.MC_WE_LOCK_TO_SMA</key> + </option> + <option> + <name>External MIMO</name> + <key>usrp2.MC_WE_LOCK_TO_MIMO</key> + </option> + </param> + <sink> + <name>in</name> + <type>$type</type> + <vlen>$type.vlen</vlen> + </sink> + <doc> +The USRP2 sink inputs 100 Megasamples per second / interpolation. + +Input amplitude should be between 0.0 and 1.0. + +To use the default ethernet device, leave interface blank. \ +For systems with only 1 USRP2, you may leave the mac address blank. \ +For multi-USRP2 systems, specify the mac address in the form 00:50:C2:85:3x:xx. + </doc> +</block> diff --git a/gr-usrp2/grc/usrp2_source_xxxx.xml b/gr-usrp2/grc/usrp2_source_xxxx.xml new file mode 100644 index 000000000..a23c5bc5c --- /dev/null +++ b/gr-usrp2/grc/usrp2_source_xxxx.xml @@ -0,0 +1,119 @@ +<?xml version="1.0"?> +<!-- +################################################### +##USRP2 Source +## Note: the center freq must be set after the lo offset +################################################### + --> +<block> + <name>USRP2 Source</name> + <key>usrp2_source_xxxx</key> + <category>USRP</category> + <import>from gnuradio import usrp2</import> + <make>#if not $interface() and not $mac_addr() +usrp2.source_$(type.fcn)() +#elif not $mac_addr() +usrp2.source_$(type.fcn)($interface) +#else +usrp2.source_$(type.fcn)($interface, $mac_addr) +#end if +self.$(id).set_decim($decimation) +#if $lo_offset() != float('inf') +self.$(id).set_lo_offset($lo_offset) +#end if +self.$(id).set_center_freq($frequency) +self.$(id).set_gain($gain) +self.$(id).config_mimo($usrp2_clock_src)</make> + <callback>set_decim($decimation)</callback> + <callback>#if $lo_offset() != float('inf') +self.$(id).set_lo_offset($lo_offset) +#end if +self.$(id).set_center_freq($frequency)</callback> + <callback>set_gain($gain)</callback> + <param> + <name>Output Type</name> + <key>type</key> + <type>enum</type> + <option> + <name>Complex</name> + <key>complex</key> + <opt>fcn:32fc</opt> + <opt>vlen:1</opt> + </option> + <option> + <name>Short</name> + <key>short</key> + <opt>fcn:16sc</opt> + <opt>vlen:2</opt> + </option> + </param> + <param> + <name>Interface</name> + <key>interface</key> + <value></value> + <type>string</type> + </param> + <param> + <name>MAC Addr</name> + <key>mac_addr</key> + <value></value> + <type>string</type> + </param> + <param> + <name>Decimation</name> + <key>decimation</key> + <type>int</type> + </param> + <param> + <name>Frequency (Hz)</name> + <key>frequency</key> + <type>real</type> + </param> + <param> + <name>LO Offset (Hz)</name> + <key>lo_offset</key> + <value>float('inf')</value> + <type>real</type> + <hide>#if $lo_offset() == float('inf') then 'part' else 'none'#</hide> + <option> + <name>Default</name> + <key>float('inf')</key> + </option> + </param> + <param> + <name>Gain (dB)</name> + <key>gain</key> + <value>0</value> + <type>real</type> + </param> + <param> + <name>Clock Source</name> + <key>usrp2_clock_src</key> + <value>usrp2.MC_WE_DONT_LOCK</value> + <type>enum</type> + <option> + <name>Internal</name> + <key>usrp2.MC_WE_DONT_LOCK</key> + </option> + <option> + <name>External SMA</name> + <key>usrp2.MC_WE_LOCK_TO_SMA</key> + </option> + <option> + <name>External MIMO</name> + <key>usrp2.MC_WE_LOCK_TO_MIMO</key> + </option> + </param> + <source> + <name>out</name> + <type>$type</type> + <vlen>$type.vlen</vlen> + </source> + <doc> +The USRP2 source outputs 100 Megasamples per second / decimation. + +To use the default ethernet device, leave interface blank. \ +For systems with only 1 USRP2, you may leave the mac address blank. \ +For multi-USRP2 systems, specify the mac address in the form 00:50:C2:85:3x:xx. + </doc> +</block> |