commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r3558 - in gnuradio/branches/developers/eb/digital-wip


From: eb
Subject: [Commit-gnuradio] r3558 - in gnuradio/branches/developers/eb/digital-wip: gnuradio-core/src/python/gnuradio/blksimpl gnuradio-examples/python/gmsk2
Date: Sun, 17 Sep 2006 00:31:27 -0600 (MDT)

Author: eb
Date: 2006-09-17 00:31:27 -0600 (Sun, 17 Sep 2006)
New Revision: 3558

Modified:
   
gnuradio/branches/developers/eb/digital-wip/gnuradio-core/src/python/gnuradio/blksimpl/gmsk.py
   
gnuradio/branches/developers/eb/digital-wip/gnuradio-examples/python/gmsk2/benchmark_rx.py
   
gnuradio/branches/developers/eb/digital-wip/gnuradio-examples/python/gmsk2/benchmark_tx.py
   
gnuradio/branches/developers/eb/digital-wip/gnuradio-examples/python/gmsk2/receive_path.py
   
gnuradio/branches/developers/eb/digital-wip/gnuradio-examples/python/gmsk2/transmit_path.py
Log:
work-in-progress: benchmark_rx works with gmsk

Modified: 
gnuradio/branches/developers/eb/digital-wip/gnuradio-core/src/python/gnuradio/blksimpl/gmsk.py
===================================================================
--- 
gnuradio/branches/developers/eb/digital-wip/gnuradio-core/src/python/gnuradio/blksimpl/gmsk.py
      2006-09-17 05:23:16 UTC (rev 3557)
+++ 
gnuradio/branches/developers/eb/digital-wip/gnuradio-core/src/python/gnuradio/blksimpl/gmsk.py
      2006-09-17 06:31:27 UTC (rev 3558)
@@ -103,6 +103,16 @@
     bits_per_symbol = staticmethod(bits_per_symbol)      # make it a static 
method.
 
 
+    def add_options(parser):
+        """
+        Adds GMSK modulation-specific options to the standard parser
+        """
+        parser.add_option("", "--bt", type="float", default=0.3,
+                          help="set bandwidth-time product [default=%default] 
(GMSK)")
+    add_options=staticmethod(add_options)
+
+
+    # FIXME factor out the common part and put into another file
     def extract_kwargs_from_options(options):
         """
         Given command line options, create dictionary suitable for passing to 
__init__
@@ -115,25 +125,16 @@
             if hasattr(options, kw):
                 d[kw] = getattr(options, kw)
         return d
-        
     extract_kwargs_from_options=staticmethod(extract_kwargs_from_options)
 
-    def add_options(parser):
-        """
-        Adds GMSK modulation-specific options to the standard parser
-        """
-        parser.add_option("", "--bt", type="float", default=0.3,
-                          help="set bandwidth-time product [default=%default] 
(GMSK)")
-    add_options=staticmethod(add_options)
 
-
     def _print_verbage(self):
         print "bits per symbol = %d" % self.bits_per_symbol()
         print "Gaussian filter bt = %.2f" % self._bt
 
 
     def _setup_logging(self):
-        print "Modulation debugging turned on."
+        print "Modulation logging turned on."
         self._fg.connect(self.nrz,
                          gr.file_sink(gr.sizeof_float, "nrz.dat"))
         self._fg.connect(self.gaussian_filter,
@@ -208,9 +209,9 @@
 
        # the clock recovery block tracks the symbol clock and resamples as 
needed.
        # the output of the block is a stream of soft symbols (float)
-       self.clock_recovery = gr.clock_recovery_mm_ff(self.omega, 
self.gain_omega,
-                                                      self.mu, self.gain_mu,
-                                                      
self.omega_relative_limit)
+       self.clock_recovery = gr.clock_recovery_mm_ff(self._omega, 
self._gain_omega,
+                                                      self._mu, self._gain_mu,
+                                                      
self._omega_relative_limit)
 
         # slice the floats at 0, outputting 1 bit (the LSB of the output byte) 
per sample
         self.slicer = gr.binary_slicer_fb()
@@ -237,29 +238,43 @@
         """
         Adds GMSK demodulation-specific options to the standard parser
         """
-        parser.set_conflict_handler("resolve")
         parser.add_option("", "--omega", type="float", default=None,
-                          help="M&M clock recovery omega [default=%default]")
-        parser.add_option("", "--gain_mu", type="float", default=0.03,
-                          help="M&M clock recovery gain mu [default=%default]")
+                          help="M&M clock recovery omega [default=%default] 
(GMSK)")
+        parser.add_option("", "--gain-mu", type="float", default=0.03,
+                          help="M&M clock recovery gain mu [default=%default] 
(GMSK)")
         parser.add_option("", "--mu", type="float", default=0.5,
-                          help="M&M clock recovery mu [default=%default]")
-        parser.add_option("", "--omega_relative_limit", type="float", 
default=0.0002,
-                          help="M&M clock recovery omega relative limit 
[default=%default]")
-        parser.add_option("", "--freq_error", type="float", default=0.0,
-                          help="M&M clock recovery frequency error 
[default=%default]")
+                          help="M&M clock recovery mu [default=%default] 
(GMSK)")
+        parser.add_option("", "--omega-relative-limit", type="float", 
default=0.0002,
+                          help="M&M clock recovery omega relative limit 
[default=%default] (GMSK)")
+        parser.add_option("", "--freq-error", type="float", default=0.0,
+                          help="M&M clock recovery frequency error 
[default=%default] (GMSK)")
     add_options=staticmethod(add_options)
 
+    # FIXME factor out the common part and put into another file
+    def extract_kwargs_from_options(options):
+        """
+        Given command line options, create dictionary suitable for passing to 
__init__
+        """
+        args, varargs, varkw, defaults = 
inspect.getargspec(gmsk_demod.__init__)
+        assert(args[0] == 'self')
+        assert(args[1] == 'fg')
+        d = {}
+        for kw in args[2:]:
+            if hasattr(options, kw):
+                d[kw] = getattr(options, kw)
+        return d
+    extract_kwargs_from_options=staticmethod(extract_kwargs_from_options)
+
     def _print_verbage(self):
         print "bits per symbol = %d" % self.bits_per_symbol()
-        print "M&M clock recovery omega = %f" % self.omega
-        print "M&M clock recovery gain mu = %f" % self.gain_mu
-        print "M&M clock recovery mu = %f" % self.mu
-        print "M&M clock recovery omega rel. limit = %f" % 
self.omega_relative_limit
-        print "frequency error = %f" % self.freq_error
+        print "M&M clock recovery omega = %f" % self._omega
+        print "M&M clock recovery gain mu = %f" % self._gain_mu
+        print "M&M clock recovery mu = %f" % self._mu
+        print "M&M clock recovery omega rel. limit = %f" % 
self._omega_relative_limit
+        print "frequency error = %f" % self._freq_error
 
     def _setup_logging(self):
-        print "Modulation debugging turned on."
+        print "Demodulation logging turned on."
         self._fg.connect(self.agc,
                         gr.file_sink(gr.sizeof_gr_complex, "agc.dat"))
         self._fg.connect(self.fmdemod,

Modified: 
gnuradio/branches/developers/eb/digital-wip/gnuradio-examples/python/gmsk2/benchmark_rx.py
===================================================================
--- 
gnuradio/branches/developers/eb/digital-wip/gnuradio-examples/python/gmsk2/benchmark_rx.py
  2006-09-17 05:23:16 UTC (rev 3557)
+++ 
gnuradio/branches/developers/eb/digital-wip/gnuradio-examples/python/gmsk2/benchmark_rx.py
  2006-09-17 06:31:27 UTC (rev 3558)
@@ -42,7 +42,7 @@
 
     def __init__(self, demod_class, rx_callback, options):
         gr.flow_graph.__init__(self)
-        self.rxpath = receive_path(self, demod_class, options, rx_callback)
+        self.rxpath = receive_path(self, demod_class, rx_callback, options)
 
 # /////////////////////////////////////////////////////////////////////////////
 #                                   main
@@ -67,25 +67,27 @@
             ok, pktno, n_rcvd, n_right)
 
     # Create Options Parser:
-    parser = OptionParser (option_class=eng_option)
+    parser = OptionParser (option_class=eng_option, conflict_handler="resolve")
     parser.add_option("-m", "--modulation", type="choice", 
choices=blks.demodulators.keys(),
                       default='dbpsk',
-                      help="Set modulation type %s" % blks.demodulators.keys())
+                      help="Select modulation from %s [default=%%default]"
+                            % (', '.join(blks.demodulators.keys()),))
+
+    receive_path.add_options(parser)
+
     mod_grp = parser.add_option_group("Modulation")
     for mod in blks.demodulators.values():
         mod.add_options(mod_grp)
-    receive_path.add_options(parser)
+
     fusb_options.add_options(parser)
-    parser.add_option("", "--debug", action="store_true", default="False",
-                      help="Turn debugging information on (CAUTION: takes up 
lots of diskspace)")
     (options, args) = parser.parse_args ()
 
     if len(args) != 0:
         parser.print_help()
         sys.exit(1)
 
-    if options.freq < 1e6:
-        options.freq *= 1e6
+    #if options.freq < 1e6:
+    #    options.freq *= 1e6
 
     # build the graph
     fg = my_graph(blks.demodulators[options.modulation], rx_callback, options)

Modified: 
gnuradio/branches/developers/eb/digital-wip/gnuradio-examples/python/gmsk2/benchmark_tx.py
===================================================================
--- 
gnuradio/branches/developers/eb/digital-wip/gnuradio-examples/python/gmsk2/benchmark_tx.py
  2006-09-17 05:23:16 UTC (rev 3557)
+++ 
gnuradio/branches/developers/eb/digital-wip/gnuradio-examples/python/gmsk2/benchmark_tx.py
  2006-09-17 06:31:27 UTC (rev 3558)
@@ -56,16 +56,17 @@
         print "ok = %r, payload = '%s'" % (ok, payload)
 
     parser = OptionParser(option_class=eng_option, conflict_handler="resolve")
+    parser.add_option("-m", "--modulation", type="choice", 
choices=blks.modulators.keys(),
+                      default='dbpsk',
+                      help="Select modulation from %s [default=%%default]"
+                            % (', '.join(blks.modulators.keys()),))
+
     parser.add_option("-s", "--size", type="eng_float", default=1500,
                       help="set packet size [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,
                       help="enable discontinous transmission (bursts of 5 
packets)")
-    parser.add_option("-m", "--modulation", type="choice", 
choices=blks.modulators.keys(),
-                      default='dbpsk',
-                      help="Select modulation from %s [default=%%default]"
-                            % (', '.join(blks.modulators.keys()),))
 
     transmit_path.add_options(parser)
 

Modified: 
gnuradio/branches/developers/eb/digital-wip/gnuradio-examples/python/gmsk2/receive_path.py
===================================================================
--- 
gnuradio/branches/developers/eb/digital-wip/gnuradio-examples/python/gmsk2/receive_path.py
  2006-09-17 05:23:16 UTC (rev 3557)
+++ 
gnuradio/branches/developers/eb/digital-wip/gnuradio-examples/python/gmsk2/receive_path.py
  2006-09-17 06:31:27 UTC (rev 3558)
@@ -23,6 +23,7 @@
 from gnuradio import gr, gru, blks
 from gnuradio import usrp
 from gnuradio import eng_notation
+import copy
 
 # from current dir
 from pick_bitrate import pick_rx_bitrate
@@ -32,56 +33,63 @@
 # /////////////////////////////////////////////////////////////////////////////
 
 class receive_path(gr.hier_block):
-    def __init__(self, fg, demodulator, rx_callback, options):
+    def __init__(self, fg, demod_class, rx_callback, options):
 
-        self._center_freq     = options.freq            # tranmitter's center 
frequency
-        self._gain            = options.gain            # transmitter's 
digital gain
-        self._rx_subdev_spec  = options.rx_subdev_spec  # daughterboard to use
-        self._bitrate         = options.bitrate         # desired bit rate
-        self._decim           = options.decim           # Decimating rate for 
the USRP (prelim)
-        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
+        options = copy.copy(options)    # make a copy so we can destructively 
modify
 
-        self._demodulator     = demodulator             # set demodulator class
-        self._rx_callback     = rx_callback             # callback function 
from lower layesr
+        self._verbose            = options.verbose
+        self._rx_freq            = options.rx_freq         # receiver's center 
frequency
+        self._rx_gain            = options.rx_gain         # receiver's gain
+        self._rx_subdev_spec     = options.rx_subdev_spec  # daughterboard to 
use
+        self._bitrate            = options.bitrate         # desired bit rate
+        self._decim              = options.decim           # Decimating rate 
for the USRP (prelim)
+        self._samples_per_symbol = options.samples_per_symbol  # desired 
samples/symbol
+        self._fusb_block_size    = options.fusb_block_size # usb info for USRP
+        self._fusb_nblocks       = options.fusb_nblocks    # usb info for USRP
 
-        # Create the USRP source to get the data
-        self.set_usrp_source()
+        self._rx_callback   = rx_callback      # this callback is fired when 
there's a packet available
+        self._demod_class   = demod_class      # the demodulator_class we're 
using
+
+        # Set up USRP source; also adjusts decim, samples_per_symbol, and 
bitrate
+        self._setup_usrp_source()
         
-        # Create filter to get actual channel we want
+        # copy the final answers back into options for use by demodulator
+        options.samples_per_symbol = self._samples_per_symbol
+        options.bitrate = self._bitrate
+        options.decim = self._decim
+
+        # Get demod_kwargs
+        demod_kwargs = self._demod_class.extract_kwargs_from_options(options)
+
+        # Design filter to get actual channel we want
         sw_decim = 1
         chan_coeffs = gr.firdes.low_pass (1.0,                  # gain
-                                          sw_decim * self._spb, # sampling rate
+                                          sw_decim * self._samples_per_symbol, 
# sampling rate
                                           1.0,                  # midpoint of 
trans. band
                                           0.1,                  # width of 
trans. band
                                           gr.firdes.WIN_HANN)   # filter type 
 
-        # Decimating Channel filter
+        # Decimating channel filter
         # complex in and out, float taps
         self.chan_filt = gr.fft_filter_ccc(sw_decim, chan_coeffs)
         #self.chan_filt = gr.fir_filter_ccf(sw_decim, chan_coeffs)
 
-        # Get demod_kwargs
-        demod_kwargs = blks.kwargs(self._demodulator, [self._spb, self._decim, 
self._bitrate])
-        demod_kwargs['debug']=options.debug
-
         # receiver
         self.packet_receiver = \
             blks.demod_pkts(fg,
-                            self._demodulator(fg, **demod_kwargs),
+                            self._demod_class(fg, **demod_kwargs),
                             access_code=None,
                             callback=self._rx_callback,
                             threshold=-1)
 
-        ok = self.set_freq(self._center_freq)
+        ok = self.set_freq(self._rx_freq)
         if not ok:
-            print "Failed to set Rx frequency to %s" % 
(eng_notation.num_to_str(self._center_freq))
-            raise SystemExit
+            print "Failed to set Rx frequency to %s" % 
(eng_notation.num_to_str(self._rx_freq))
+            raise ValueError
     
         g = self.subdev.gain_range()
-        #self.set_gain((g[0] + g[1])/2)        # set gain to midpoint
-        self.set_gain(g[1])                    # set gain to max
+        self.set_gain((g[0] + g[1])/2)        # set gain to midpoint
+        #self.set_gain(g[1])                    # set gain to max
         self.set_auto_tr(True)                 # enable Auto Transmit/Receive 
switching
 
         # Carrier Sensing Blocks
@@ -91,18 +99,21 @@
         fg.connect(self.chan_filt, self.probe)
 
         # Display some information about the setup
-        if verbose:
+        if self._verbose:
             self._print_verbage()
             
         fg.connect(self.u, self.chan_filt, self.packet_receiver)
         gr.hier_block.__init__(self, fg, None, None)
 
-    def set_usrp_source(self):
+    def _setup_usrp_source(self):
         self.u = usrp.source_c (fusb_block_size=self._fusb_block_size,
                                 fusb_nblocks=self._fusb_nblocks)
         adc_rate = self.u.adc_rate()
 
-        self.set_bitrate(adc_rate)
+        # derive values of bitrate, samples_per_symbol, and decim from desired 
info
+        (self._bitrate, self._samples_per_symbol, self._decim) = \
+            pick_rx_bitrate(self._bitrate, 
self._demod_class.bits_per_symbol(), \
+                            self._samples_per_symbol, self._decim, adc_rate)
 
         self.u.set_decim_rate(self._decim)
 
@@ -113,16 +124,6 @@
 
         self.u.set_mux(usrp.determine_rx_mux_value(self.u, 
self._rx_subdev_spec))
 
-    def set_bitrate(self, adc_rate):
-        """
-        determine best set of bitrate, spb, and decim from desired info
-        @param dac_rate: DAC rate of USRP
-        @type dac_rate: int
-        """
-        (self._bitrate, self._spb, self._decim) = \
-            pick_rx_bitrate(self._bitrate, self._demodulator.bits_per_baud(), \
-                            self._spb, self._decim, adc_rate)
-
     def set_freq(self, target_freq):
         """
         Set the center frequency we're interested in.
@@ -157,8 +158,8 @@
     def bitrate(self):
         return self._bitrate
 
-    def spb(self):
-        return self._spb
+    def samples_per_symbol(self):
+        return self._samples_per_symbol
 
     def decim(self):
         return self._decim
@@ -190,19 +191,20 @@
         """
         Adds receiver-specific options to the Options Parser
         """
-        rx_grp = parser.add_option_group("Receiver Path")
+        parser.add_option("-v", "--verbose", action="store_true", 
default=False)
+        rx_grp = parser.add_option_group("Receive Path")
         rx_grp.add_option("-R", "--rx-subdev-spec", type="subdev", 
default=None,
                           help="select USRP Rx side A or B")
         rx_grp.add_option("", "--rx-freq", type="eng_float", default=None,
                           help="set Rx frequency to FREQ [default=%default]", 
metavar="FREQ")
         rx_grp.add_option("-r", "--bitrate", type="eng_float", default=None,
-                          help="specify bitrate.  spb and interp will be 
derived.")
-        rx_grp.add_option("-S", "--spb", type="int", default=None,
-                          help="set samples/baud [default=%default]")
+                          help="specify bitrate.  samples_per_symbol and decim 
will be derived.")
+        rx_grp.add_option("-S", "--samples-per-symbol", type="int", 
default=None,
+                          help="set samples/symbol [default=%default]")
         rx_grp.add_option("-d", "--decim", type="intx", default=None,
                           help="set fpga decimation rate to DECIM 
[default=%default]")
-        rx_grp.add_option("-g", "--gain", type="eng_float", default=100.0,
-                          help="transmitter gain [default=%default]")
+        rx_grp.add_option("", "--rx-gain", type="eng_float", default=50.0, 
metavar="GAIN",
+                          help="normalized receiver gain: 0 <= GAIN <= 100 
[default=%default]")
     # Make a static method to call before instantiation
     add_options = staticmethod(add_options)
 
@@ -211,10 +213,10 @@
         """
         Prints information about the receive path
         """
-        print "Using RX d'board %s" % (self.subdev.side_and_name(),)
-        print "modulation:      %s" % (self._demodulator.__name__)
-        print "bitrate:         %sb/sec" % 
(eng_notation.num_to_str(self._bitrate))
-        print "samples/symbol:  %3d" % (self._spb)
-        print "decim:           %3d" % (self._decim)
-        print "Center Frequency: %s" % 
(eng_notation.num_to_str(self._center_freq))
-        #print "Center Frequency: %f" % (self._center_freq)
+        print "Using RX d'board %s"    % (self.subdev.side_and_name(),)
+        print "modulation:      %s"    % (self._demod_class.__name__)
+        print "bitrate:         %sb/s" % 
(eng_notation.num_to_str(self._bitrate))
+        print "samples/symbol:  %3d"   % (self._samples_per_symbol)
+        print "decim:           %3d"   % (self._decim)
+        print "Rx Frequency:    %s"    % 
(eng_notation.num_to_str(self._rx_freq))
+        # print "Rx Frequency:    %f"    % (self._rx_freq)

Modified: 
gnuradio/branches/developers/eb/digital-wip/gnuradio-examples/python/gmsk2/transmit_path.py
===================================================================
--- 
gnuradio/branches/developers/eb/digital-wip/gnuradio-examples/python/gmsk2/transmit_path.py
 2006-09-17 05:23:16 UTC (rev 3557)
+++ 
gnuradio/branches/developers/eb/digital-wip/gnuradio-examples/python/gmsk2/transmit_path.py
 2006-09-17 06:31:27 UTC (rev 3558)
@@ -103,7 +103,7 @@
                              fusb_nblocks=self._fusb_nblocks)
         dac_rate = self.u.dac_rate();
 
-        # determine best set of bitrate, samples_per_symbol, and interp from 
desired info
+        # derive values of bitrate, samples_per_symbol, and interp from 
desired info
         (self._bitrate, self._samples_per_symbol, self._interp) = \
             pick_tx_bitrate(self._bitrate, 
self._modulator_class.bits_per_symbol(),
                             self._samples_per_symbol, self._interp, dac_rate)
@@ -179,8 +179,8 @@
                           help="set samples/symbol [default=%default]")
         tx_grp.add_option("-i", "--interp", type="intx", default=None,
                           help="set fpga interpolation rate to INTERP 
[default=%default]")
-        tx_grp.add_option("-g", "--gain", type="eng_float", default=100.0,
-                          help="transmitter gain [default=%default]")
+        tx_grp.add_option("", "--tx-gain", type="eng_float", default=100.0, 
metavar="GAIN",
+                          help="normalized transmitter gain: 0 <= GAIN <= 100 
[default=%default]")
     # Make a static method to call before instantiation
     add_options = staticmethod(add_options)
 





reply via email to

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