commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r10905 - gnuradio/branches/developers/jblum/digital


From: jblum
Subject: [Commit-gnuradio] r10905 - gnuradio/branches/developers/jblum/digital
Date: Fri, 24 Apr 2009 15:45:28 -0600 (MDT)

Author: jblum
Date: 2009-04-24 15:45:28 -0600 (Fri, 24 Apr 2009)
New Revision: 10905

Modified:
   gnuradio/branches/developers/jblum/digital/generic_usrp.py
   gnuradio/branches/developers/jblum/digital/transmit_path.py
Log:
generic usrp stuff tested, working in tunnel.py

Modified: gnuradio/branches/developers/jblum/digital/generic_usrp.py
===================================================================
--- gnuradio/branches/developers/jblum/digital/generic_usrp.py  2009-04-24 
21:22:05 UTC (rev 10904)
+++ gnuradio/branches/developers/jblum/digital/generic_usrp.py  2009-04-24 
21:45:28 UTC (rev 10905)
@@ -1,23 +1,23 @@
 #
 # 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'
@@ -25,39 +25,35 @@
 from gnuradio import gr, usrp, usrp2
 
 ########################################################################
-# common usrp options
-########################################################################
-def add_options(normal, 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
-    """
-    if normal.has_option("usrp2"): return
-    #pick usrp or usrp2
-    normal.add_option("--usrp2", action="store_true", default=False,
-                      help="Use USRP2 [default=auto]")
-    normal.add_option("--usrp", action="store_true", default=False,
-                      help="Use USRP [default=auto]")
-    #fast usb options
-    expert.add_option("-B", "--fusb-block-size", type="int", default=0,
-                      help="specify fast usb block size [default=%default]")
-    expert.add_option("-N", "--fusb-nblocks", type="int", default=0,
-                      help="specify number of fast usb blocks 
[default=%default]")
-    #usrp options
-    normal.add_option("-w", "--which", type="int", default=0,
-                      help="select USRP board [default=%default]")
-    #usrp2 options
-    normal.add_option("-e", "--interface", type="string", default="eth0",
-                      help="Use specified Ethernet interface 
[default=%default]")
-    normal.add_option("-m", "--mac-addr", type="string", default="",
-                      help="Use USRP2 at specified MAC address [default=None]")
-
-########################################################################
 # generic usrp common stuff
 ########################################################################
 class _generic_usrp_base(object):
 
+    @staticmethod
+    def add_options(normal, 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
+        """
+        if normal.has_option("usrpx"): return
+        #pick usrp or usrp2
+        normal.add_option("-u", "--usrpx", type="string", default=None,
+                          help="specify which usrp model: 1 for USRP, 2 for 
USRP2 [default=auto]")
+        #fast usb options
+        expert.add_option("-B", "--fusb-block-size", type="int", default=0,
+                          help="specify fast usb block size 
[default=%default]")
+        expert.add_option("-N", "--fusb-nblocks", type="int", default=0,
+                          help="specify number of fast usb blocks 
[default=%default]")
+        #usrp options
+        normal.add_option("-w", "--which", type="int", default=0,
+                          help="select USRP board [default=%default]")
+        #usrp2 options
+        normal.add_option("-e", "--interface", type="string", default="eth0",
+                          help="Use specified Ethernet interface 
[default=%default]")
+        normal.add_option("-m", "--mac-addr", type="string", default="",
+                          help="Use USRP2 at specified MAC address 
[default=None]")
+
     def __str__(self):
         if self._type == USRP_TYPE: return self._subdev.side_and_name()
         elif self._type == USRP2_TYPE: return "D-Board ID 
0x%x\n"%self._u.daughterboard_id()
@@ -69,7 +65,8 @@
             r = self.gain_range()
             gain = (r[0] + r[1])/2               # set gain to midpoint
         self._gain = gain
-        return self._u.set_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()
@@ -81,6 +78,10 @@
         elif self._type == USRP2_TYPE:
             return self._u.set_center_freq(target_freq)
 
+    def __del__(self):
+        # Avoid weak reference error
+        if self._type == USRP_TYPE: del self._subdev
+
 ########################################################################
 # generic usrp source
 ########################################################################
@@ -95,7 +96,7 @@
     def add_options(normal, expert):
         normal.add_option("-R", "--rx-subdev-spec", type="subdev", 
default=None,
                           help="select USRP Rx side A or B")
-        add_options(normal, expert)
+        _generic_usrp_base.add_options(normal, expert)
 
     def __init__(self, options):
         gr.hier_block2.__init__(self, "generic_usrp_source",
@@ -112,9 +113,9 @@
         self._mac_addr = options.mac_addr
 
         #pick usrp or usrp2
-        if options.usrp or self._rx_subdev_spec:
+        if options.usrpx == '1' or self._rx_subdev_spec:
             self._setup_usrp_source()
-        elif options.usrp2 or self._mac_addr:
+        elif options.usrpx == '2' or self._mac_addr:
             self._setup_usrp2_source()
         else: #automatic
             try: self._setup_usrp2_source()
@@ -127,7 +128,7 @@
     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()
 
     ####################################################################
@@ -145,15 +146,11 @@
         self._subdev.set_auto_tr(True)
         self._type = USRP_TYPE
         self._dc = 0
-    
+
     def _setup_usrp2_source(self):
         self._u = usrp2.source_32fc(self._interface, self._mac_addr)
         self._type = USRP2_TYPE
 
-    def __del__(self):
-        # Avoid weak reference error
-        if self._type == USRP_TYPE: del self._subdev
-
 ########################################################################
 # generic usrp sink
 ########################################################################
@@ -168,7 +165,7 @@
     def add_options(normal, expert):
         normal.add_option("-T", "--tx-subdev-spec", type="subdev", 
default=None,
                           help="select USRP Tx side A or B")
-        add_options(normal, expert)
+        _generic_usrp_base.add_options(normal, expert)
 
     def __init__(self, options):
         gr.hier_block2.__init__(self, "generic_usrp_sink",
@@ -185,9 +182,9 @@
         self._mac_addr = options.mac_addr
 
         #pick usrp or usrp2
-        if options.usrp or self._tx_subdev_spec:
+        if options.usrpx == '1' or self._tx_subdev_spec:
             self._setup_usrp_source()
-        elif options.usrp2 or self._mac_addr:
+        elif options.usrpx == '2' or self._mac_addr:
             self._setup_usrp2_source()
         else: #automatic
             try: self._setup_usrp2_source()
@@ -200,7 +197,7 @@
     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):
@@ -222,11 +219,7 @@
         self._subdev.set_auto_tr(True)
         self._type = USRP_TYPE
         self._dc = self._subdev.which()
-    
+
     def _setup_usrp2_source(self):
         self._u = usrp2.sink_32fc(self._interface, self._mac_addr)
         self._type = USRP2_TYPE
-
-    def __del__(self):
-        # Avoid weak reference error
-        if self._type == USRP_TYPE: del self._subdev

Modified: gnuradio/branches/developers/jblum/digital/transmit_path.py
===================================================================
--- gnuradio/branches/developers/jblum/digital/transmit_path.py 2009-04-24 
21:22:05 UTC (rev 10904)
+++ gnuradio/branches/developers/jblum/digital/transmit_path.py 2009-04-24 
21:45:28 UTC (rev 10905)
@@ -62,6 +62,9 @@
         # Set up USRP sink; also adjusts interp, samples_per_symbol, and 
bitrate
         self._setup_usrp_sink(options)
 
+        if options.show_tx_ampl_range:
+            print "Tx Amplitude Range: minimum = %g, maximum = 
%g"%tuple(self.u.ampl_range())
+
         # copy the final answers back into options for use by modulator
         options.samples_per_symbol = self._samples_per_symbol
         options.bitrate = self._bitrate
@@ -138,9 +141,10 @@
     def set_tx_amplitude(self, ampl):
         """
         Sets the transmit amplitude sent to the USRP
-        @param: ampl 0 <= ampl < 32768.  Try 8000
+        @param ampl the amplitude or None for automatic
         """
         ampl_range = self.u.ampl_range()
+        if ampl is None: ampl = (ampl_range[0] + ampl_range[1])/2.
         self._tx_amplitude = max(ampl_range[0], min(ampl, ampl_range[1]))
         self.amp.set_k(self._tx_amplitude)
 
@@ -168,8 +172,10 @@
             normal.add_option("-r", "--bitrate", type="eng_float", 
default=None,
                               help="specify bitrate.  samples-per-symbol and 
interp/decim will be derived.")
         generic_usrp.generic_usrp_sink_c.add_options(normal, expert)
-        normal.add_option("--tx-amplitude", type="eng_float", default=12000, 
metavar="AMPL",
-                          help="set transmitter digital amplitude: 0 <= AMPL < 
32768 [default=%default]")
+        normal.add_option("--tx-amplitude", type="eng_float", default=None, 
metavar="AMPL",
+                          help="set transmitter digital amplitude 
[default=midpoint].  See also --show-tx-ampl-range")
+        normal.add_option("--show-tx-ampl-range", action="store_true", 
default=False, 
+                          help="print min and max Tx amplitude available")
         normal.add_option("-v", "--verbose", action="store_true", 
default=False)
         expert.add_option("-S", "--samples-per-symbol", type="int", 
default=None,
                           help="set samples/symbol [default=%default]")





reply via email to

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