commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] r10960 - gnuradio/branches/features/experimental-gui


From: jblum
Subject: [Commit-gnuradio] r10960 - gnuradio/branches/features/experimental-gui
Date: Tue, 5 May 2009 14:00:10 -0600 (MDT)

Author: jblum
Date: 2009-05-05 14:00:09 -0600 (Tue, 05 May 2009)
New Revision: 10960

Added:
   gnuradio/branches/features/experimental-gui/generic_usrp.py
   gnuradio/branches/features/experimental-gui/usrp_options.py
Modified:
   gnuradio/branches/features/experimental-gui/usrp2_siggen.py
   gnuradio/branches/features/experimental-gui/usrp2_siggen_gui.py
Log:
Work on converting usrp2 siggen/gui to generic usrp stuff.
One set of python files will support all usrp models.



Copied: gnuradio/branches/features/experimental-gui/generic_usrp.py (from rev 
10958, gnuradio/trunk/gnuradio-examples/python/digital/generic_usrp.py)
===================================================================
--- gnuradio/branches/features/experimental-gui/generic_usrp.py                 
        (rev 0)
+++ gnuradio/branches/features/experimental-gui/generic_usrp.py 2009-05-05 
20:00:09 UTC (rev 10960)
@@ -0,0 +1,193 @@
+#
+# Copyright 2009 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.
+#
+
+USRP_TYPE = 'usrp'
+USRP2_TYPE = 'usrp2'
+
+from gnuradio import gr, usrp, usrp2
+
+########################################################################
+# generic usrp common stuff
+########################################################################
+class _generic_usrp_base(object):
+
+    def __init__(self, which=0, subdev_spec=None, interface="", mac_addr="", 
fusb_block_size=0, fusb_nblocks=0, usrpx=None):
+        self._gain = 0
+        self._usrpx = usrpx
+        #usrp options
+        self._which = which
+        self._subdev_spec = subdev_spec
+        #usrp2 options
+        self._interface = interface
+        self._mac_addr = mac_addr
+        #fusb options
+        self._fusb_block_size = fusb_block_size
+        self._fusb_nblocks = fusb_nblocks
+
+    def __str__(self):
+        if self._type == USRP_TYPE: return self._subdev.side_and_name()
+        elif self._type == USRP2_TYPE:
+            return 'Interface: %s    MAC Address: %s    D-Board ID: 0x%x\n'%(
+                self._u.interface_name(), self._u.mac_addr(), 
self._u.daughterboard_id())
+
+    def gain(self): return self._gain
+
+    def set_gain(self, gain=None):
+        if gain is None:
+            r = self.gain_range()
+            gain = (r[0] + r[1])/2               # set gain to midpoint
+        self._gain = gain
+        if self._type == USRP_TYPE: return self._subdev.set_gain(gain)
+        elif self._type == USRP2_TYPE: return self._u.set_gain(gain)
+
+    def gain_range(self):
+        if self._type == USRP_TYPE: return self._subdev.gain_range()
+        elif self._type == USRP2_TYPE: return self._u.gain_range()
+
+    def set_center_freq(self, target_freq):
+        if self._type == USRP_TYPE:
+            return self._u.tune(self._dxc, self._subdev, target_freq)
+        elif self._type == USRP2_TYPE:
+            return self._u.set_center_freq(target_freq)
+
+    def freq_range(self):
+        if self._type == USRP_TYPE: return self._subdev.freq_range()
+        elif self._type == USRP2_TYPE: return self._u.freq_range()
+
+    def set_auto_tr(self, enable):
+        if self._type == USRP_TYPE: return self._subdev.set_auto_tr(enable)
+
+    def __del__(self):
+        # Avoid weak reference error
+        if self._type == USRP_TYPE: del self._subdev
+
+########################################################################
+# generic usrp source
+########################################################################
+class generic_usrp_source_c(_generic_usrp_base, gr.hier_block2):
+    """
+    Create a generic usrp source that represents usrp and usrp2.
+    Take usrp and usrp2 constructor arguments and try to figure out usrp or 
usrp2.
+    Provide generic access methods so the API looks the same for both.
+    """
+
+    def __init__(self, **kwargs):
+        _generic_usrp_base.__init__(self, **kwargs)
+        gr.hier_block2.__init__(self, "generic_usrp_source",
+            gr.io_signature(0, 0, 0), # Input signature
+            gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature
+        #pick usrp or usrp2
+        if self._usrpx == '1' or self._subdev_spec:
+            self._setup_usrp_source()
+        elif self._usrpx == '2' or self._mac_addr:
+            self._setup_usrp2_source()
+        else: #automatic
+            try: self._setup_usrp2_source()
+            except: self._setup_usrp_source()
+        self.connect(self._u, self)
+        self.set_auto_tr(True)
+
+    ####################################################################
+    # generic access methods
+    ####################################################################
+    def set_decim(self, decim):
+        if self._type == USRP_TYPE: return self._u.set_decim_rate(decim)
+        elif self._type == USRP2_TYPE: return self._u.set_decim(decim)
+
+    def adc_rate(self): return self._u.adc_rate()
+
+    ####################################################################
+    # setup usrp methods
+    ####################################################################
+    def _setup_usrp_source(self):
+        self._type = USRP_TYPE
+        self._u = usrp.source_c (self._which,
+                                fusb_block_size=self._fusb_block_size,
+                                fusb_nblocks=self._fusb_nblocks)
+        # determine the daughterboard subdevice we're using
+        if self._subdev_spec is None:
+            self._subdev_spec = usrp.pick_rx_subdevice(self._u)
+        self._subdev = usrp.selected_subdev(self._u, self._subdev_spec)
+        self._u.set_mux(usrp.determine_rx_mux_value(self._u, 
self._subdev_spec))
+        self._dxc = 0
+
+    def _setup_usrp2_source(self):
+        self._type = USRP2_TYPE
+        self._u = usrp2.source_32fc(self._interface, self._mac_addr)
+
+########################################################################
+# generic usrp sink
+########################################################################
+class generic_usrp_sink_c(_generic_usrp_base, gr.hier_block2):
+    """
+    Create a generic usrp sink that represents usrp and usrp2.
+    Take usrp and usrp2 constructor arguments and try to figure out usrp or 
usrp2.
+    Provide generic access methods so the API looks the same for both.
+    """
+
+    def __init__(self, **kwargs):
+        _generic_usrp_base.__init__(self, **kwargs)
+        gr.hier_block2.__init__(self, "generic_usrp_sink",
+            gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature
+            gr.io_signature(0, 0, 0)) # Output signature
+
+        #pick usrp or usrp2
+        if self._usrpx == '1' or self._subdev_spec:
+            self._setup_usrp_source()
+        elif self._usrpx == '2' or self._mac_addr:
+            self._setup_usrp2_source()
+        else: #automatic
+            try: self._setup_usrp2_source()
+            except: self._setup_usrp_source()
+        self.connect(self, self._u)
+        self.set_auto_tr(True)
+
+    ####################################################################
+    # generic access methods
+    ####################################################################
+    def set_interp(self, interp):
+        if self._type == USRP_TYPE: return self._u.set_interp_rate(interp)
+        elif self._type == USRP2_TYPE: return self._u.set_interp(interp)
+
+    def dac_rate(self): return self._u.dac_rate()
+
+    def ampl_range(self):
+        if self._type == USRP_TYPE: return (0.0, 2.**15-1)
+        elif self._type == USRP2_TYPE: return (0.0, 1.0)
+
+    ####################################################################
+    # setup usrp methods
+    ####################################################################
+    def _setup_usrp_source(self):
+        self._type = USRP_TYPE
+        self._u = usrp.sink_c (self._which,
+                                fusb_block_size=self._fusb_block_size,
+                                fusb_nblocks=self._fusb_nblocks)
+        # determine the daughterboard subdevice we're using
+        if self._subdev_spec is None:
+            self._subdev_spec = usrp.pick_tx_subdevice(self._u)
+        self._subdev = usrp.selected_subdev(self._u, self._subdev_spec)
+        self._u.set_mux(usrp.determine_tx_mux_value(self._u, 
self._subdev_spec))
+        self._dxc = self._subdev.which()
+
+    def _setup_usrp2_source(self):
+        self._type = USRP2_TYPE
+        self._u = usrp2.sink_32fc(self._interface, self._mac_addr)

Modified: gnuradio/branches/features/experimental-gui/usrp2_siggen.py
===================================================================
--- gnuradio/branches/features/experimental-gui/usrp2_siggen.py 2009-05-05 
19:34:05 UTC (rev 10959)
+++ gnuradio/branches/features/experimental-gui/usrp2_siggen.py 2009-05-05 
20:00:09 UTC (rev 10960)
@@ -20,10 +20,9 @@
 # Boston, MA 02110-1301, USA.
 # 
 
-INTERFACE_KEY = 'interface'
-MAC_ADDR_KEY = 'mac_addr'
-DBOARD_ID_KEY = 'dboard_id'
-ETH_RATE_KEY = 'eth_rate'
+DESC_KEY = 'desc'
+SAMP_RATE_KEY = 'samp_rate'
+LINK_RATE_KEY = 'link_rate'
 DAC_RATE_KEY = 'dac_rate'
 INTERP_KEY = 'interp'
 GAIN_KEY = 'gain'
@@ -32,39 +31,25 @@
 BB_FREQ_KEY = 'bb_freq'
 LO_OFFSET_KEY = 'lo_offset'
 AMPLITUDE_KEY = 'amplitude'
+AMPL_RANGE_KEY = 'ampl_range'
 WAVEFORM_FREQ_KEY = 'waveform_freq'
 WAVEFORM_OFFSET_KEY = 'waveform_offset'
 WAVEFORM2_FREQ_KEY = 'waveform2_freq'
 FREQ_RANGE_KEY = 'freq_range'
 GAIN_RANGE_KEY = 'gain_range'
-GIGE_RATE_KEY = 'gige'
 TYPE_KEY = 'type'
 
 def setter(ps, key, val): ps[key] = val
 
-from gnuradio import gr, eng_notation, usrp2
+from gnuradio import gr, eng_notation
 from gnuradio.gr.pubsub import pubsub
 from gnuradio.eng_option import eng_option
 from optparse import OptionParser
 import sys
 import math
+#from this local folder
+import usrp_options
 
-class dummy_usrp2(gr.hier_block2):
-       def __init__(self, *args, **kwargs):
-               gr.hier_block2.__init__(self,
-               "dummy usrp2", gr.io_signature(1, 1, gr.sizeof_gr_complex), 
gr.io_signature(0, 0, 0))
-               self.connect(self, gr.throttle(gr.sizeof_gr_complex, 50000), 
gr.null_sink(gr.sizeof_gr_complex))
-       def dac_rate(self): return int(100e6)
-       def mac_addr(self): return 'ff:ff:ff:ff:ff'
-       def daughterboard_id(self): return -1
-       def set_center_freq(self, *args, **kwargs): pass
-       def set_interp(self, *args, **kwargs): return True
-       def gain_range(self, *args, **kwargs): return (0., 1., .1)
-       def set_gain(self, *args, **kwargs): return True
-       def freq_range(self, *args, **kwargs): return (-100e6, 100e6)
-       def interface_name(self, *args, **kwargs): return 'eth-x'
-#usrp2.sink_32fc = dummy_usrp2
-
 n2s = eng_notation.num_to_str
 
 waveforms = { gr.GR_SIN_WAVE   : "Complex Sinusoid",
@@ -84,14 +69,14 @@
         pubsub.__init__(self)
         self._verbose = options.verbose
         #initialize values from options
-        self.set_usrp2(options)
-        self.subscribe(INTERP_KEY, lambda i: setter(self, ETH_RATE_KEY, 
self[DAC_RATE_KEY]/i))
-        self.subscribe(ETH_RATE_KEY, lambda e: setter(self, GIGE_RATE_KEY, 
e*32))
-        self[INTERP_KEY] = options.interp
-        self[GAIN_KEY] = options.gain
+        self._setup_usrpx(options)
+        self.subscribe(INTERP_KEY, lambda i: setter(self, SAMP_RATE_KEY, 
self[DAC_RATE_KEY]/i))
+        self.subscribe(SAMP_RATE_KEY, lambda e: setter(self, LINK_RATE_KEY, 
e*32))
+        self[INTERP_KEY] = options.interp or 16
+        self[GAIN_KEY] = options.tx_gain
         self[TX_FREQ_KEY] = options.tx_freq
         self[LO_OFFSET_KEY] = options.lo_offset
-        self[AMPLITUDE_KEY] = options.amplitude
+        self._set_tx_amplitude(options.amplitude)
         self[WAVEFORM_FREQ_KEY] = options.waveform_freq
         self[WAVEFORM_OFFSET_KEY] = options.offset
         self[WAVEFORM2_FREQ_KEY] = options.waveform2_freq
@@ -112,19 +97,24 @@
             self[key] = self[key]
         self[TYPE_KEY] = options.type #set type last
 
-    def set_usrp2(self, options):
-        self._u = usrp2.sink_32fc(options.interface, options.mac_addr)
-        self.publish(INTERFACE_KEY, self._u.interface_name)
-        self.publish(MAC_ADDR_KEY, self._u.mac_addr)
-        self.publish(DBOARD_ID_KEY, lambda: hex(self._u.daughterboard_id()))
+    def _setup_usrpx(self, options):
+        self._u = usrp_options.create_usrp_sink(options)
+        self.publish(DESC_KEY, lambda: str(self._u))
         self.publish(DAC_RATE_KEY, self._u.dac_rate)
         self.publish(FREQ_RANGE_KEY, self._u.freq_range)
         self.publish(GAIN_RANGE_KEY, self._u.gain_range)
-        if self._verbose:
-            print "Network interface:", self[INTERFACE_KEY]
-            print "Network address:", self[MAC_ADDR_KEY]
-            print "Daughterboard ID:", self[DBOARD_ID_KEY]
+        self.publish(AMPL_RANGE_KEY, self._u.ampl_range)
+        if self._verbose: print str(self._u)
 
+    def _set_tx_amplitude(self, ampl):
+        """
+        Sets the transmit amplitude sent to the USRP
+        @param ampl the amplitude or None for automatic
+        """
+        ampl_range = self[AMPL_RANGE_KEY]
+        if ampl is None: ampl = (ampl_range[1] - ampl_range[0])*0.15 + 
ampl_range[0]
+        self[AMPLITUDE_KEY] = max(ampl_range[0], min(ampl, ampl_range[1]))
+
     def set_interp(self, interp):
         if interp < 4 or interp > 512: # FIXME get from flowgraph
             if self._verbose: print "Interpolation rate out of range:", interp
@@ -135,16 +125,16 @@
 
         if self._verbose:
             print "USRP2 interpolation rate:", self[INTERP_KEY]
-            print "USRP2 IF bandwidth: %sHz" % (n2s(self[ETH_RATE_KEY]),)
+            print "USRP2 IF bandwidth: %sHz" % (n2s(self[SAMP_RATE_KEY]),)
 
         if self[TYPE_KEY] in (gr.GR_SIN_WAVE, gr.GR_CONST_WAVE):
-            self._src.set_sampling_freq(self[ETH_RATE_KEY])
+            self._src.set_sampling_freq(self[SAMP_RATE_KEY])
         elif self[TYPE_KEY] == "2tone":
-            self._src1.set_sampling_freq(self[ETH_RATE_KEY])
-            self._src2.set_sampling_freq(self[ETH_RATE_KEY])
+            self._src1.set_sampling_freq(self[SAMP_RATE_KEY])
+            self._src2.set_sampling_freq(self[SAMP_RATE_KEY])
         elif self[TYPE_KEY] == "sweep":
-            self._src1.set_sampling_freq(self[ETH_RATE_KEY])
-            
self._src2.set_sampling_freq(self[WAVEFORM_FREQ_KEY]*2*math.pi/self[ETH_RATE_KEY])
+            self._src1.set_sampling_freq(self[SAMP_RATE_KEY])
+            
self._src2.set_sampling_freq(self[WAVEFORM_FREQ_KEY]*2*math.pi/self[SAMP_RATE_KEY])
         else:
             return True # Waveform not yet set
         
@@ -216,9 +206,8 @@
     def set_waveform(self, type):
         self.lock()
         self.disconnect_all()
-
         if type == gr.GR_SIN_WAVE or type == gr.GR_CONST_WAVE:
-            self._src = gr.sig_source_c(self[ETH_RATE_KEY],      # Sample rate
+            self._src = gr.sig_source_c(self[SAMP_RATE_KEY],      # Sample rate
                                         type,                # Waveform type
                                         self[WAVEFORM_FREQ_KEY], # Waveform 
frequency
                                         self[AMPLITUDE_KEY],     # Waveform 
amplitude
@@ -226,7 +215,7 @@
         elif type == gr.GR_GAUSSIAN or type == gr.GR_UNIFORM:
             self._src = gr.noise_source_c(type, self[AMPLITUDE_KEY])
         elif type == "2tone":
-            self._src1 = gr.sig_source_c(self[ETH_RATE_KEY],
+            self._src1 = gr.sig_source_c(self[SAMP_RATE_KEY],
                                          gr.GR_SIN_WAVE,
                                          self[WAVEFORM_FREQ_KEY],
                                          self[AMPLITUDE_KEY]/2.0,
@@ -234,7 +223,7 @@
             if(self[WAVEFORM2_FREQ_KEY] is None):
                 self[WAVEFORM2_FREQ_KEY] = -self[WAVEFORM_FREQ_KEY]
 
-            self._src2 = gr.sig_source_c(self[ETH_RATE_KEY],
+            self._src2 = gr.sig_source_c(self[SAMP_RATE_KEY],
                                          gr.GR_SIN_WAVE,
                                          self[WAVEFORM2_FREQ_KEY],
                                          self[AMPLITUDE_KEY]/2.0,
@@ -250,12 +239,12 @@
             if self[WAVEFORM2_FREQ_KEY] is None:
                 self[WAVEFORM2_FREQ_KEY] = 0.1
 
-            self._src1 = gr.sig_source_f(self[ETH_RATE_KEY],
+            self._src1 = gr.sig_source_f(self[SAMP_RATE_KEY],
                                          gr.GR_TRI_WAVE,
                                          self[WAVEFORM2_FREQ_KEY],
                                          1.0,
                                          -0.5)
-            self._src2 = 
gr.frequency_modulator_fc(self[WAVEFORM_FREQ_KEY]*2*math.pi/self[ETH_RATE_KEY])
+            self._src2 = 
gr.frequency_modulator_fc(self[WAVEFORM_FREQ_KEY]*2*math.pi/self[SAMP_RATE_KEY])
             self._src = gr.multiply_const_cc(self[AMPLITUDE_KEY])
             self.connect(self._src1,self._src2,self._src)
         else:
@@ -300,22 +289,14 @@
     usage="%prog: [options]"
 
     parser = OptionParser(option_class=eng_option, usage=usage)
-
-    parser.add_option("-e", "--interface", type="string", default="eth0",
-                      help="Use specified Ethernet interface 
[default=%default]")
-    parser.add_option("-m", "--mac-addr", type="string", default="",
-                      help="Use USRP2 at specified MAC address 
[default=None]")  
-    parser.add_option("-i", "--interp", type="int", default=16, 
metavar="INTERP",
-                      help="Set FPGA interpolation rate of INTERP 
[default=%default]")
+    usrp_options.add_tx_options(parser)
     parser.add_option("-f", "--tx-freq", type="eng_float", default=None,
                       help="Set carrier frequency to FREQ 
[default=mid-point]", metavar="FREQ")
     parser.add_option("--lo-offset", type="eng_float", default=None,
                       help="set daughterboard LO offset to OFFSET [default=hw 
default]")
-    parser.add_option("-g", "--gain", type="eng_float", default=None,
-                      help="Set TX gain to GAIN [default=mid-point]")
-    parser.add_option("-w", "--waveform-freq", type="eng_float", default=0,
+    parser.add_option("-x", "--waveform-freq", type="eng_float", default=0,
                       help="Set baseband waveform frequency to FREQ 
[default=%default]")
-    parser.add_option("-x", "--waveform2-freq", type="eng_float", default=None,
+    parser.add_option("-y", "--waveform2-freq", type="eng_float", default=None,
                       help="Set 2nd waveform frequency to FREQ 
[default=%default]")
     parser.add_option("--sine", dest="type", action="store_const", 
const=gr.GR_SIN_WAVE,
                       help="Generate a carrier modulated by a complex sine 
wave", default=gr.GR_SIN_WAVE)
@@ -331,8 +312,8 @@
                       help="Generate Two Tone signal for IMD testing")
     parser.add_option("--sweep", dest="type", action="store_const", 
const="sweep",
                       help="Generate a swept sine wave")
-    parser.add_option("-a", "--amplitude", type="eng_float", default=0.1,
-                      help="Set output amplitude to AMPL (0.0-1.0) 
[default=%default]", metavar="AMPL")
+    parser.add_option("-a", "--amplitude", type="eng_float", default=None,
+                      help="Set output amplitude to AMPL [default=auto]", 
metavar="AMPL")
     parser.add_option("-v", "--verbose", action="store_true", default=False,
                       help="Use verbose console output [default=%default]")
 

Modified: gnuradio/branches/features/experimental-gui/usrp2_siggen_gui.py
===================================================================
--- gnuradio/branches/features/experimental-gui/usrp2_siggen_gui.py     
2009-05-05 19:34:05 UTC (rev 10959)
+++ gnuradio/branches/features/experimental-gui/usrp2_siggen_gui.py     
2009-05-05 20:00:09 UTC (rev 10960)
@@ -195,13 +195,14 @@
         self.vbox.AddSpacer(10)
         self.vbox.AddStretchSpacer()
         lvl_hbox.AddSpacer(5)
+        ampl_range = self.tb[usrp2_siggen.AMPL_RANGE_KEY]
         forms.text_box(
             parent=self.panel, sizer=lvl_hbox,
             proportion=1,
             converter=forms.float_converter(),
             ps=self.tb,
             key=usrp2_siggen.AMPLITUDE_KEY,
-            label="Level (0.0-1.0)",
+            label="Level",
         )
         lvl_hbox.AddSpacer(10)
         forms.log_slider(
@@ -210,7 +211,7 @@
             ps=self.tb,
             key=usrp2_siggen.AMPLITUDE_KEY,
             min_exp=-5,
-            max_exp=0,
+            max_exp=math.log(ampl_range[1], 10),
             base=10,
             step_size=1,
         )
@@ -256,50 +257,32 @@
             parent=self.panel, sizer=sam_hbox,
             label='Sample Rate (sps)',
             ps=self.tb,
-            key=usrp2_siggen.ETH_RATE_KEY,
+            key=usrp2_siggen.SAMP_RATE_KEY,
             converter=forms.float_converter(),
         )
         sam_hbox.AddStretchSpacer(20)
         forms.static_text(
             parent=self.panel, sizer=sam_hbox,
-            label='GbE Rate (bits/sec)',
+            label='Link Rate (bits/sec)',
             ps=self.tb,
-            key=usrp2_siggen.GIGE_RATE_KEY,
+            key=usrp2_siggen.LINK_RATE_KEY,
             converter=forms.float_converter(),
         )
         sam_hbox.AddSpacer(5)
         ##################################################
-        # USRP2 controls
+        # USRP status
         ##################################################
-        u2_hbox = forms.static_box_sizer(parent=self.panel, label="USRP2 
Hardware", orient=wx.HORIZONTAL, bold=True)
+        u2_hbox = forms.static_box_sizer(parent=self.panel, label="USRP 
Status", orient=wx.HORIZONTAL, bold=True)
         self.vbox.Add(u2_hbox, 0, wx.EXPAND)
         self.vbox.AddSpacer(10)
         self.vbox.AddStretchSpacer()
-        u2_hbox.AddSpacer(5)
+        u2_hbox.AddSpacer(10)
         forms.static_text(
             parent=self.panel, sizer=u2_hbox,
-            label='Interface',
             ps=self.tb,
-            key=usrp2_siggen.INTERFACE_KEY,
+            key=usrp2_siggen.DESC_KEY,
             converter=forms.str_converter(),
         )
-        u2_hbox.AddStretchSpacer(20)
-        forms.static_text(
-            parent=self.panel, sizer=u2_hbox,
-            label='MAC Address',
-            ps=self.tb,
-            key=usrp2_siggen.MAC_ADDR_KEY,
-            converter=forms.str_converter(),
-        )
-        u2_hbox.AddStretchSpacer(20)
-        forms.static_text(
-            parent=self.panel, sizer=u2_hbox,
-            label='Daughterboard ID',
-            ps=self.tb,
-            key=usrp2_siggen.DBOARD_ID_KEY,
-            converter=forms.str_converter(),
-        )
-        u2_hbox.AddSpacer(5)
         self.vbox.AddSpacer(5)
         self.vbox.AddStretchSpacer()
 
@@ -316,7 +299,7 @@
                       gui=app_gui,                     # User interface class
                       options=options,                 # Command line options
                       args=args,                       # Command line args
-                      title="USRP2 Signal Generator",  # Top window title
+                      title="USRP Signal Generator",  # Top window title
                       nstatus=1,                       # Number of status lines
                       start=True,                      # Whether to start 
flowgraph
                       realtime=True)                   # Whether to set 
realtime priority

Copied: gnuradio/branches/features/experimental-gui/usrp_options.py (from rev 
10958, gnuradio/trunk/gnuradio-examples/python/digital/usrp_options.py)
===================================================================
--- gnuradio/branches/features/experimental-gui/usrp_options.py                 
        (rev 0)
+++ gnuradio/branches/features/experimental-gui/usrp_options.py 2009-05-05 
20:00:09 UTC (rev 10960)
@@ -0,0 +1,113 @@
+#
+# Copyright 2009 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.
+#
+
+import generic_usrp
+
+def _add_options(parser, expert):
+    """
+    Add options to manually choose between usrp or usrp2.
+    Add options for usb. Add options common to source and sink.
+    @param parser: instance of OptionParser
+    """
+    #pick usrp or usrp2
+    parser.add_option("-u", "--usrpx", type="string", default=None,
+                      help="specify which usrp model: 1 for USRP, 2 for USRP2 
[default=auto]")
+    #fast usb options
+    if expert: expert.add_option("-B", "--fusb-block-size", type="int", 
default=0,
+                      help="specify fast usb block size [default=%default]")
+    if expert: expert.add_option("-N", "--fusb-nblocks", type="int", default=0,
+                      help="specify number of fast usb blocks 
[default=%default]")
+    #usrp options
+    parser.add_option("-w", "--which", type="int", default=0,
+                      help="select USRP board [default=%default]")
+    #usrp2 options
+    parser.add_option("-e", "--interface", type="string", default="eth0",
+                      help="Use USRP2 at specified Ethernet interface 
[default=%default]")
+    parser.add_option("-m", "--mac-addr", type="string", default="",
+                      help="Use USRP2 at specified MAC address [default=None]")
+
+def _ensure_values(options):
+    """
+    Ensure that expert options exist even if they did not get added to the 
parser.
+    @param options the parsed options
+    """
+    options.ensure_value('fusb_block_size', 0)
+    options.ensure_value('fusb_nblocks', 0)
+
+def add_rx_options(parser, expert=None):
+    """
+    Add receive specific usrp options.
+    @param parser: instance of OptionParser
+    """
+    parser.add_option("-R", "--rx-subdev-spec", type="subdev", default=None,
+                      help="select USRP Rx side A or B")
+    parser.add_option("--rx-gain", type="eng_float", default=None, 
metavar="GAIN",
+                      help="set receiver gain in dB [default=midpoint].  See 
also --show-rx-gain-range")
+    parser.add_option("--show-rx-gain-range", action="store_true", 
default=False, 
+                      help="print min and max Rx gain available on selected 
daughterboard")
+    parser.add_option("-d", "--decim", type="intx", default=None,
+                      help="set fpga decimation rate to DECIM 
[default=%default]")
+    _add_options(parser, expert)
+
+def create_usrp_source(options):
+    _ensure_values(options)
+    u = generic_usrp.generic_usrp_source_c(
+        usrpx=options.usrpx,
+        which=options.which,
+        subdev_spec=options.rx_subdev_spec,
+        interface=options.interface,
+        mac_addr=options.mac_addr,
+        fusb_block_size=options.fusb_block_size,
+        fusb_nblocks=options.fusb_nblocks,
+    )
+    if options.show_rx_gain_range:
+        print "Rx Gain Range: minimum = %g, maximum = %g, step size = 
%g"%tuple(u.gain_range())
+    return u
+
+def add_tx_options(parser, expert=None):
+    """
+    Add transmit specific usrp options.
+    @param parser: instance of OptionParser
+    """
+    parser.add_option("-T", "--tx-subdev-spec", type="subdev", default=None,
+                      help="select USRP Rx side A or B")
+    parser.add_option("--tx-gain", type="eng_float", default=None, 
metavar="GAIN",
+                      help="set transmitter gain in dB [default=midpoint].  
See also --show-tx-gain-range")
+    parser.add_option("--show-tx-gain-range", action="store_true", 
default=False, 
+                      help="print min and max Tx gain available on selected 
daughterboard")
+    parser.add_option("-i", "--interp", type="intx", default=None,
+                      help="set fpga interpolation rate to INTERP 
[default=%default]")
+    _add_options(parser, expert)
+
+def create_usrp_sink(options):
+    _ensure_values(options)
+    u = generic_usrp.generic_usrp_sink_c(
+        usrpx=options.usrpx,
+        which=options.which,
+        subdev_spec=options.tx_subdev_spec,
+        interface=options.interface,
+        mac_addr=options.mac_addr,
+        fusb_block_size=options.fusb_block_size,
+        fusb_nblocks=options.fusb_nblocks,
+    )
+    if options.show_tx_gain_range:
+        print "Tx Gain Range: minimum = %g, maximum = %g, step size = 
%g"%tuple(u.gain_range())
+    return u





reply via email to

[Prev in Thread] Current Thread [Next in Thread]