commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r3493 - in gnuradio/branches/developers/trondeau/wip:


From: trondeau
Subject: [Commit-gnuradio] r3493 - in gnuradio/branches/developers/trondeau/wip: gnuradio-core/src/python/gnuradio/blksimpl gnuradio-examples/python/gmsk2
Date: Wed, 6 Sep 2006 07:21:41 -0600 (MDT)

Author: trondeau
Date: 2006-09-06 07:21:41 -0600 (Wed, 06 Sep 2006)
New Revision: 3493

Modified:
   
gnuradio/branches/developers/trondeau/wip/gnuradio-core/src/python/gnuradio/blksimpl/qpsk.py
   
gnuradio/branches/developers/trondeau/wip/gnuradio-examples/python/gmsk2/benchmark_tx.py
   
gnuradio/branches/developers/trondeau/wip/gnuradio-examples/python/gmsk2/transmit_path.py
Log:
working on digital modulation transmitter reconfiguration

Modified: 
gnuradio/branches/developers/trondeau/wip/gnuradio-core/src/python/gnuradio/blksimpl/qpsk.py
===================================================================
--- 
gnuradio/branches/developers/trondeau/wip/gnuradio-core/src/python/gnuradio/blksimpl/qpsk.py
        2006-09-06 02:47:59 UTC (rev 3492)
+++ 
gnuradio/branches/developers/trondeau/wip/gnuradio-core/src/python/gnuradio/blksimpl/qpsk.py
        2006-09-06 13:21:41 UTC (rev 3493)
@@ -102,7 +102,7 @@
     def samples_per_baud(self):
         return self.spb
 
-    def bits_per_baud(self=None):   # staticmethod that's also callable on an 
instance
+    def bits_per_baud(self=None):   # static method that's also callable on an 
instance
         return 2
     bits_per_baud = staticmethod(bits_per_baud)      # make it a static 
method.  RTFM
 

Modified: 
gnuradio/branches/developers/trondeau/wip/gnuradio-examples/python/gmsk2/benchmark_tx.py
===================================================================
--- 
gnuradio/branches/developers/trondeau/wip/gnuradio-examples/python/gmsk2/benchmark_tx.py
    2006-09-06 02:47:59 UTC (rev 3492)
+++ 
gnuradio/branches/developers/trondeau/wip/gnuradio-examples/python/gmsk2/benchmark_tx.py
    2006-09-06 13:21:41 UTC (rev 3493)
@@ -29,7 +29,7 @@
 import random, time, struct, sys
 
 # from current dir
-from transmit_path import transmit_path
+import transmit_path
 import fusb_options
 
 #import os 
@@ -38,12 +38,12 @@
 
 
 def mod_callback(option, opt, value, parser):
-    parser.values.modulation = getattr(blks, value + "_mod")
+    parser.values.modulator = getattr(blks, value + "_mod")
 
 class my_graph(gr.flow_graph):
-    def __init__(self, options, mod_kwargs):
+    def __init__(self, modulator, options):
         gr.flow_graph.__init__(self)
-        self.txpath = transmit_path(self, options, mod_kwargs)
+        self.txpath = transmit_path.transmit_path(self, modulator, options)
 
 
 # /////////////////////////////////////////////////////////////////////////////
@@ -59,21 +59,8 @@
         print "ok = %r, payload = '%s'" % (ok, payload)
 
     parser = OptionParser (option_class=eng_option)
-    parser.add_option("-T", "--tx-subdev-spec", type="subdev", default=None,
-                      help="select USRP Tx side A or B")
-    parser.add_option("-f", "--freq", type="eng_float", default=423.1e6,
-                      help="set Tx and Rx frequency to FREQ 
[default=%default]",
-                      metavar="FREQ")
-    parser.add_option("-r", "--bitrate", type="eng_float", default=500e3,
-                      help="specify bitrate.  spb and interp will be derived.")
-    parser.add_option("-S", "--spb", type="int", default=2,
-                      help="set samples/baud [default=%default]")
-    parser.add_option("-i", "--interp", type="intx", default=None,
-                      help="set fpga interpolation rate to INTERP 
[default=%default]")
     parser.add_option("-s", "--size", type="eng_float", default=1500,
                       help="set packet size [default=%default]")
-    parser.add_option("-g", "--gain", type="eng_float", default=100.0,
-                      help="transmitter gain [default=%default]")
     parser.add_option("-M", "--megabytes", type="eng_float", default=1.0,
                       help="set megabytes to transmit [default=%default]")
     parser.add_option("","--discontinuous", action="store_true", default=False,
@@ -89,6 +76,7 @@
     parser.add_option("", "--no-gray-code", action="store_false", default=True,
                       help="Don't use gray coding on modulated bits 
[default=%default]")
 
+    transmit_path.add_options(parser)
     fusb_options.add_options(parser)
     (options, args) = parser.parse_args ()
 
@@ -96,33 +84,18 @@
         parser.print_help()
         sys.exit(1)
 
-        if options.freq < 1e6:
-            options.freq *= 1e6
+    if options.freq < 1e6:
+        options.freq *= 1e6
 
     pkt_size = int(options.size)
 
     # If not specified in arguments, get default modulation set to callable 
object
-    if options.modulation == parser.get_default_values().modulation:
-        options.modulation = getattr(blks, options.modulation + "_mod")
+    if not hasattr(options, 'modulation'):
+        options.modulator = getattr(blks, options.modulation + "_mod")
 
-    mod_kwargs = options.modulation.arguments()
-    for key in mod_kwargs:
-        if(hasattr(options, key)):
-            mod_kwargs[key] = getattr(options,key)
-
     # build the graph
-    fg = my_graph(options, mod_kwargs)
+    fg = my_graph(options.modulator, options)
 
-    print "modulation: %s" % (options.modulation.__name__)
-    print "bitrate: %sb/sec" % (eng_notation.num_to_str(fg.txpath.bitrate()),)
-    print "spb:     %3d" % (fg.txpath.spb(),)
-    print "interp:  %3d" % (fg.txpath.interp(),)
-
-    ok = fg.txpath.set_freq(options.freq)
-    if not ok:
-        print "Failed to set Tx frequency to %s" % 
(eng_notation.num_to_str(options.freq),)
-        raise SystemExit
-
     r = gr.enable_realtime_scheduling()
     if r != gr.RT_OK:
         print "Warning: failed to enable realtime scheduling"

Modified: 
gnuradio/branches/developers/trondeau/wip/gnuradio-examples/python/gmsk2/transmit_path.py
===================================================================
--- 
gnuradio/branches/developers/trondeau/wip/gnuradio-examples/python/gmsk2/transmit_path.py
   2006-09-06 02:47:59 UTC (rev 3492)
+++ 
gnuradio/branches/developers/trondeau/wip/gnuradio-examples/python/gmsk2/transmit_path.py
   2006-09-06 13:21:41 UTC (rev 3493)
@@ -21,6 +21,7 @@
 
 from gnuradio import gr, gru, blks
 from gnuradio import usrp
+from gnuradio import eng_notation
 
 # from current dir
 from pick_bitrate import pick_tx_bitrate
@@ -30,11 +31,12 @@
 # /////////////////////////////////////////////////////////////////////////////
 
 class transmit_path(gr.hier_block): 
-    def __init__(self, fg, options, mod_kwargs):
+    def __init__(self, fg, modulator, options):
         '''
         See below for what options should hold
         '''
 
+        self._carrier_freq    = options.freq            # tranmitter's carrier 
frequency
         self._gain            = options.gain            # transmitter's 
digital gain
         self._tx_subdev_spec  = options.tx_subdev_spec  # daughterboard to use
         self._bitrate         = options.bitrate         # desired bit rate
@@ -42,17 +44,62 @@
         self._spb             = options.spb             # desired samples/baud
         self._fusb_block_size = options.fusb_block_size # usb info for USRP
         self._fusb_nblocks    = options.fusb_nblocks    # usb info for USRP
-        self._modulation      = options.modulation      # the modulator we are 
using
 
+        self._modulator       = modulator               # the modulator we are 
using
+    
+        # Set up USRP sink; also adjusts interp, spb, and bitrate
+        self.set_usrp_sink()
+
+        mod_kwargs = options.modulator.arguments()
+        for key in mod_kwargs:
+            if(hasattr(options, key)):
+                mod_kwargs[key] = getattr(options,key)
+        mod_kwargs['spb'] = self._spb
+        print mod_kwargs
+
+        # Set carrier frequency of USRP
+        ok = self.set_freq(self._carrier_freq)
+        if not ok:
+            print "Failed to set Tx frequency to %s" % 
(eng_notation.num_to_str(options.freq),)
+            raise SystemExit
+    
+        # transmitter
+        self.packet_transmitter = \
+            blks.mod_pkts(fg,
+                          self._modulator(fg, **mod_kwargs),
+                          access_code=None,
+                          msgq_limit=4,
+                          pad_for_usrp=True)
+
+        # Set gains: digital and USRP
+        self.amp = gr.multiply_const_cc (self._gain)
+        self.set_gain(self.subdev.gain_range()[1])    # set max Tx gain
+
+        # enable Auto Transmit/Receive switching
+        self.set_auto_tr(True)
+
+        # Display some information about the setup
+        print "modulation: %s" % (self._modulator.__name__)
+        print "bitrate:    %sb/sec" % (eng_notation.num_to_str(self._bitrate))
+        print "spb:        %3d" % (self._spb)
+        print "interp:     %3d" % (self._interp)
+        print "Using TX d'board %s" % (self.subdev.side_and_name(),)
+
+        # Create and setup transmit path flow graph
+        fg.connect(self.packet_transmitter, self.amp, self.u)
+        gr.hier_block.__init__(self, fg, None, None)
+
+    def set_usrp_sink(self):
+        """
+        Creates a USRP sink, determines the settings for best bitrate,
+        and attaches to the transmitter's subdevice.
+        """
         self.u = usrp.sink_c (fusb_block_size=self._fusb_block_size,
                               fusb_nblocks=self._fusb_nblocks)
         dac_rate = self.u.dac_rate();
 
-        # determine best set of bitrate, spb, and interp from desired info
-        (self._bitrate, self._spb, self._interp) = \
-            pick_tx_bitrate(self._bitrate, self._modulation.bits_per_baud(), \
-                            self._spb, self._interp, dac_rate)
-
+        self.set_bitrate(dac_rate)
+        
         self.u.set_interp_rate(self._interp)
 
         # determine the daughterboard subdevice we're using
@@ -61,24 +108,15 @@
         self.u.set_mux(usrp.determine_tx_mux_value(self.u, 
self._tx_subdev_spec))
         self.subdev = usrp.selected_subdev(self.u, self._tx_subdev_spec)
 
-        print "Using TX d'board %s" % (self.subdev.side_and_name(),)
 
-        # transmitter
-        self.packet_transmitter = \
-            blks.mod_pkts(fg,
-                          self._modulation(fg, **mod_kwargs),
-                          access_code=None,
-                          msgq_limit=4,
-                          pad_for_usrp=True)
+    def set_bitrate(self, dac_rate):
+        # determine best set of bitrate, spb, and interp from desired info
+        (self._bitrate, self._spb, self._interp) = \
+            pick_tx_bitrate(self._bitrate, self._modulator.bits_per_baud(), \
+                            self._spb, self._interp, dac_rate)
 
-        self.amp = gr.multiply_const_cc (self._gain)
+        print self._spb
 
-        fg.connect(self.packet_transmitter, self.amp, self.u)
-        gr.hier_block.__init__(self, fg, None, None)
-
-        self.set_gain(self.subdev.gain_range()[1])  # set max Tx gain
-        self.set_auto_tr(True)                      # enable Auto 
Transmit/Receive switching
-
     def set_freq(self, target_freq):
         """
         Set the center frequency we're interested in.
@@ -115,3 +153,22 @@
 
     def interp(self):
         return self._interp
+
+def add_options(parser):
+    """
+    Adds transmitter-specific options to the Options Parser
+    """
+    parser.add_option("-T", "--tx-subdev-spec", type="subdev", default=None,
+                      help="select USRP Tx side A or B")
+    parser.add_option("-f", "--freq", type="eng_float", default=423.1e6,
+                      help="set Tx and Rx frequency to FREQ 
[default=%default]",
+                      metavar="FREQ")
+    parser.add_option("-r", "--bitrate", type="eng_float", default=500e3,
+                      help="specify bitrate.  spb and interp will be derived.")
+    parser.add_option("-S", "--spb", type="int", default=None,
+                      help="set samples/baud [default=%default]")
+    parser.add_option("-i", "--interp", type="intx", default=None,
+                      help="set fpga interpolation rate to INTERP 
[default=%default]")
+    parser.add_option("-g", "--gain", type="eng_float", default=100.0,
+                      help="transmitter gain [default=%default]")
+    





reply via email to

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