commit-gnuradio
[Top][All Lists]
Advanced

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

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


From: eb
Subject: [Commit-gnuradio] r3556 - in gnuradio/branches/developers/eb/digital-wip: gnuradio-core/src/python/gnuradio gnuradio-core/src/python/gnuradio/blksimpl gnuradio-examples/python/channel-coding/fsm_files gnuradio-examples/python/gmsk2
Date: Sat, 16 Sep 2006 22:53:41 -0600 (MDT)

Author: eb
Date: 2006-09-16 22:53:40 -0600 (Sat, 16 Sep 2006)
New Revision: 3556

Modified:
   
gnuradio/branches/developers/eb/digital-wip/gnuradio-core/src/python/gnuradio/blksimpl/bpsk.py
   
gnuradio/branches/developers/eb/digital-wip/gnuradio-core/src/python/gnuradio/blksimpl/dbpsk.py
   
gnuradio/branches/developers/eb/digital-wip/gnuradio-core/src/python/gnuradio/blksimpl/dqpsk.py
   
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/pkt.py
   
gnuradio/branches/developers/eb/digital-wip/gnuradio-core/src/python/gnuradio/blksimpl/qpsk.py
   
gnuradio/branches/developers/eb/digital-wip/gnuradio-core/src/python/gnuradio/packet_utils.py
   
gnuradio/branches/developers/eb/digital-wip/gnuradio-examples/python/channel-coding/fsm_files/
   
gnuradio/branches/developers/eb/digital-wip/gnuradio-examples/python/gmsk2/benchmark_tx.py
   
gnuradio/branches/developers/eb/digital-wip/gnuradio-examples/python/gmsk2/pick_bitrate.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_tx works with gmsk

Modified: 
gnuradio/branches/developers/eb/digital-wip/gnuradio-core/src/python/gnuradio/blksimpl/bpsk.py
===================================================================
--- 
gnuradio/branches/developers/eb/digital-wip/gnuradio-core/src/python/gnuradio/blksimpl/bpsk.py
      2006-09-16 19:29:18 UTC (rev 3555)
+++ 
gnuradio/branches/developers/eb/digital-wip/gnuradio-core/src/python/gnuradio/blksimpl/bpsk.py
      2006-09-17 04:53:40 UTC (rev 3556)
@@ -94,7 +94,7 @@
         self.fg.connect(self.bytes2chunks, self.chunks2symbols, 
self.rrc_filter)
        gr.hier_block.__init__(self, self.fg, self.bytes2chunks, 
self.rrc_filter)
 
-    def samples_per_baud(self):
+    def samples_per_symbol(self):
         return self.spb
 
     def bits_per_baud(self=None):   # staticmethod that's also callable on an 
instance
@@ -226,7 +226,7 @@
                         self.clock_recovery, self.slicer, self.gray_decoder, 
self.unpack)
         gr.hier_block.__init__(self, self.fg, self.preamp, self.unpack)
 
-    def samples_per_baud(self):
+    def samples_per_symbol(self):
         return self.spb
 
     def bits_per_baud(self=None):   # staticmethod that's also callable on an 
instance

Modified: 
gnuradio/branches/developers/eb/digital-wip/gnuradio-core/src/python/gnuradio/blksimpl/dbpsk.py
===================================================================
--- 
gnuradio/branches/developers/eb/digital-wip/gnuradio-core/src/python/gnuradio/blksimpl/dbpsk.py
     2006-09-16 19:29:18 UTC (rev 3555)
+++ 
gnuradio/branches/developers/eb/digital-wip/gnuradio-core/src/python/gnuradio/blksimpl/dbpsk.py
     2006-09-17 04:53:40 UTC (rev 3556)
@@ -106,7 +106,7 @@
        # Initialize base class
        gr.hier_block.__init__(self, self.fg, self.bytes2chunks, 
self.rrc_filter)
 
-    def samples_per_baud(self):
+    def samples_per_symbol(self):
         return self.spb
 
     def bits_per_baud(self=None):   # static method that's also callable on an 
instance
@@ -247,7 +247,7 @@
         #           self.slicer, self.diffdec, self.gray_decoder, self.unpack)
         gr.hier_block.__init__(self, self.fg, self.preamp, self.unpack)
 
-    def samples_per_baud(self):
+    def samples_per_symbol(self):
         return self.spb
 
     def bits_per_baud(self=None):   # staticmethod that's also callable on an 
instance

Modified: 
gnuradio/branches/developers/eb/digital-wip/gnuradio-core/src/python/gnuradio/blksimpl/dqpsk.py
===================================================================
--- 
gnuradio/branches/developers/eb/digital-wip/gnuradio-core/src/python/gnuradio/blksimpl/dqpsk.py
     2006-09-16 19:29:18 UTC (rev 3555)
+++ 
gnuradio/branches/developers/eb/digital-wip/gnuradio-core/src/python/gnuradio/blksimpl/dqpsk.py
     2006-09-17 04:53:40 UTC (rev 3556)
@@ -104,7 +104,7 @@
                         self.chunks2symbols, self.rrc_filter)
        gr.hier_block.__init__(self, self.fg, self.bytes2chunks, 
self.rrc_filter)
 
-    def samples_per_baud(self):
+    def samples_per_symbol(self):
         return self.spb
 
     def bits_per_baud(self=None):   # staticmethod that's also callable on an 
instance
@@ -245,7 +245,7 @@
         #           self.slicer, self.diffdec, self.gray_decoder, self.unpack)
         gr.hier_block.__init__(self, self.fg, self.preamp, self.unpack)
 
-    def samples_per_baud(self):
+    def samples_per_symbol(self):
         return self.spb
 
     def bits_per_baud(self=None):   # staticmethod that's also callable on an 
instance

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-16 19:29:18 UTC (rev 3555)
+++ 
gnuradio/branches/developers/eb/digital-wip/gnuradio-core/src/python/gnuradio/blksimpl/gmsk.py
      2006-09-17 04:53:40 UTC (rev 3556)
@@ -27,6 +27,8 @@
 from gnuradio import gr
 from math import pi
 import Numeric
+from pprint import pprint
+import inspect
 
 # /////////////////////////////////////////////////////////////////////////////
 #                              GMSK modulator
@@ -34,7 +36,7 @@
 
 class gmsk_mod(gr.hier_block):
 
-    def __init__(self, fg, spb=2, bt=0.3, verbose=True, debug=False):
+    def __init__(self, fg, samples_per_symbol=2, bt=0.3, verbose=True, 
debug=False):
         """
        Hierarchical block for Gaussian Minimum Shift Key (GMSK)
        modulation.
@@ -44,8 +46,8 @@
 
        @param fg: flow graph
        @type fg: flow graph
-       @param spb: samples per baud >= 2
-       @type spb: integer
+       @param samples_per_symbol: samples per baud >= 2
+       @type samples_per_symbol: integer
        @param bt: Gaussian filter bandwidth * symbol time
        @type bt: float
         @param verbose: Print information about modulator?
@@ -54,15 +56,15 @@
         @type debug: bool       
        """
 
-        self.fg = fg
-        self.spb = spb
-        self.bt = bt
+        self._fg = fg
+        self._samples_per_symbol = samples_per_symbol
+        self._bt = bt
 
-        if not isinstance(spb, int) or spb < 2:
-            raise TypeError, ("sbp must be an integer >= 2, is %d" % spb)
+        if not isinstance(samples_per_symbol, int) or samples_per_symbol < 2:
+            raise TypeError, ("samples_per_symbol must be an integer >= 2, is 
%d" % samples_per_symbol)
 
-       ntaps = 4 * spb                 # up to 3 bits in filter at once
-       sensitivity = (pi / 2) / spb    # phase change per bit = pi / 2
+       ntaps = 4 * samples_per_symbol                  # up to 3 bits in 
filter at once
+       sensitivity = (pi / 2) / samples_per_symbol     # phase change per bit 
= pi / 2
 
        # Turn it into NRZ data.
        self.nrz = gr.bytes_to_syms()
@@ -71,14 +73,14 @@
         # Generate Gaussian response (Needs to be convolved with window below).
        self.gaussian_taps = gr.firdes.gaussian(
                1,              # gain
-               spb,            # symbol_rate
+               samples_per_symbol,            # symbol_rate
                bt,             # bandwidth * symbol time
                ntaps           # number of taps
                )
 
-       self.sqwave = (1,) * spb       # rectangular window
+       self.sqwave = (1,) * samples_per_symbol       # rectangular window
        self.taps = 
Numeric.convolve(Numeric.array(self.gaussian_taps),Numeric.array(self.sqwave))
-       self.gaussian_filter = gr.interp_fir_filter_fff(spb, self.taps)
+       self.gaussian_filter = gr.interp_fir_filter_fff(samples_per_symbol, 
self.taps)
 
        # FM modulation
        self.fmmod = gr.frequency_modulator_fc(sensitivity)
@@ -90,47 +92,54 @@
             self._setup_logging()
 
        # Connect & Initialize base class
-       self.fg.connect(self.nrz, self.gaussian_filter, self.fmmod)
-       gr.hier_block.__init__(self, self.fg, self.nrz, self.fmmod)
+       self._fg.connect(self.nrz, self.gaussian_filter, self.fmmod)
+       gr.hier_block.__init__(self, self._fg, self.nrz, self.fmmod)
 
-    def samples_per_baud(self):
-        return self.spb
+    def samples_per_symbol(self):
+        return self._samples_per_symbol
 
-    def bits_per_baud(self=None):   # staticmethod that's also callable on an 
instance
+    def bits_per_symbol(self=None):     # staticmethod that's also callable on 
an instance
         return 1
-    bits_per_baud = staticmethod(bits_per_baud)      # make it a static 
method.  RTFM
+    bits_per_baud = staticmethod(bits_per_symbol)      # make it a static 
method.
 
 
-    def arguments(self=None):
-        args = {'spb':2, 'bt':0.3, 'verbose':True, 'debug':False}
-        return args
-    arguments = staticmethod(arguments)
+    def extract_kwargs_from_options(options):
+        """
+        Given command line options, create dictionary suitable for passing to 
__init__
+        """
+        args, varargs, varkw, defaults = inspect.getargspec(gmsk_mod.__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 add_options(parser):
         """
-        Adds modulation-specific options to the standard parser
+        Adds GMSK modulation-specific options to the standard parser
         """
-        from optparse import OptionConflictError
-        try:
-            parser.add_option("", "--bt", type="float", default=0.3,
-                              help="set bandwidth-time product 
[default=%default]")
-        except OptionConflictError:
-            pass
+        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_baud()
-        print "Gaussian filter bt = %.2f" % self.bt
+        print "Gaussian filter bt = %.2f" % self._bt
 
+
     def _setup_logging(self):
         print "Modulation debugging turned on."
-        self.fg.connect(self.nrz,
-                        gr.file_sink(gr.sizeof_float, "nrz.dat"))
-        self.fg.connect(self.gaussian_filter,
-                        gr.file_sink(gr.sizeof_float, "gaussian_filter.dat"))
-        self.fg.connect(self.fmmod,
-                        gr.file_sink(gr.sizeof_gr_complex, "fmmod.dat"))
+        self._fg.connect(self.nrz,
+                         gr.file_sink(gr.sizeof_float, "nrz.dat"))
+        self._fg.connect(self.gaussian_filter,
+                         gr.file_sink(gr.sizeof_float, "gaussian_filter.dat"))
+        self._fg.connect(self.fmmod,
+                         gr.file_sink(gr.sizeof_gr_complex, "fmmod.dat"))
 
 
 
@@ -140,7 +149,7 @@
 
 class gmsk_demod(gr.hier_block):
 
-    def __init__(self, fg, spb=2, omega=None, gain_mu=0.03, mu=0.5,
+    def __init__(self, fg, samples_per_symbol=2, omega=None, gain_mu=0.03, 
mu=0.5,
                  omega_relative_limit=0.000200, freq_error=0.0,
                  verbose=True, debug=False):
         """
@@ -152,8 +161,8 @@
 
        @param fg: flow graph
        @type fg: flow graph
-       @param spb: samples per baud
-       @type spb: integer
+       @param samples_per_symbol: samples per baud
+       @type samples_per_symbol: integer
         @param verbose: Print information about modulator?
         @type verbose: bool
         @param debug: Print modualtion data to files?
@@ -161,7 +170,7 @@
 
         Clock recovery parameters.  These all have reasonble defaults.
         
-        @param omega: nominal relative freq (defaults to spb)
+        @param omega: nominal relative freq (defaults to samples_per_symbol)
         @type omega: float
         @param gain_mu: controls rate of mu adjustment
         @type gain_mu: float
@@ -173,28 +182,28 @@
         @param float
        """
 
-        self.fg = fg
-        self.spb = spb
-        self.omega = omega
-        self.gain_mu = gain_mu
-        self.mu = mu
-        self.omega_relative_limit = omega_relative_limit
-        self.freq_error = freq_error
+        self._fg = fg
+        self._samples_per_symbol = samples_per_symbol
+        self._omega = omega
+        self._gain_mu = gain_mu
+        self._mu = mu
+        self._omega_relative_limit = omega_relative_limit
+        self._freq_error = freq_error
         
-        if spb < 2:
-            raise TypeError, "sbp >= 2, is %f" % spb
+        if samples_per_symbol < 2:
+            raise TypeError, "samples_per_symbol >= 2, is %f" % 
samples_per_symbol
 
-        if self.omega is None:
-            self.omega = spb*(1+self.freq_error)
+        if self._omega is None:
+            self._omega = samples_per_symbol*(1+self._freq_error)
 
-       self.gain_omega = .25*self.gain_mu*self.gain_mu        # critically 
damped
+       self._gain_omega = .25 * self._gain_mu * self._gain_mu        # 
critically damped
 
         # Automatic gain control
         self.preamp = gr.multiply_const_cc(10e-5)
         self.agc = gr.agc_cc(1e-3, 1, 1, 1000)
 
        # Demodulate FM
-       sensitivity = (pi / 2) / spb
+       sensitivity = (pi / 2) / samples_per_symbol
        self.fmdemod = gr.quadrature_demod_cf(1.0 / sensitivity)
 
        # the clock recovery block tracks the symbol clock and resamples as 
needed.
@@ -213,46 +222,36 @@
             self._setup_logging()
 
        # Connect & Initialize base class
-       self.fg.connect(self.preamp, self.agc, self.fmdemod, 
self.clock_recovery, self.slicer)
-       gr.hier_block.__init__(self, self.fg, self.preamp, self.slicer)
+       self._fg.connect(self.preamp, self.agc, self.fmdemod, 
self.clock_recovery, self.slicer)
+       gr.hier_block.__init__(self, self._fg, self.preamp, self.slicer)
 
-    def samples_per_baud(self):
-        return self.spb
+    def samples_per_symbol(self):
+        return self._samples_per_symbol
 
-    def bits_per_baud(self=None):   # staticmethod that's also callable on an 
instance
+    def bits_per_symbol(self=None):   # staticmethod that's also callable on 
an instance
         return 1
-    bits_per_baud = staticmethod(bits_per_baud)      # make it a static 
method.  RTFM
+    bits_per_symbol = staticmethod(bits_per_symbol)      # make it a static 
method.
 
 
-    def arguments(self=None):
-        args = {'spb':2, 'omega':None, 'gain_mu':0.03, 'mu':0.5, \
-               'omega_relative_limit':0.0002, 'freq_error':0.0, \
-               'verbose':True, 'debug':False}
-        return args
-    arguments = staticmethod(arguments)
-
     def add_options(parser):
         """
-        Adds modulation-specific options to the standard parser
+        Adds GMSK demodulation-specific options to the standard parser
         """
-        from optparse import OptionConflictError
-        try:
-            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]")
-            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]")
-        except OptionConflictError:
-            pass
+        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]")
+        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]")
     add_options=staticmethod(add_options)
 
     def _print_verbage(self):
-        print "bits per symbol = %d" % self.bits_per_baud()
+        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
@@ -261,11 +260,11 @@
 
     def _setup_logging(self):
         print "Modulation debugging turned on."
-        self.fg.connect(self.agc,
+        self._fg.connect(self.agc,
                         gr.file_sink(gr.sizeof_gr_complex, "agc.dat"))
-        self.fg.connect(self.fmdemod,
+        self._fg.connect(self.fmdemod,
                         gr.file_sink(gr.sizeof_float, "fmdemod.dat"))
-        self.fg.connect(self.clock_recovery,
+        self._fg.connect(self.clock_recovery,
                         gr.file_sink(gr.sizeof_float, "clock_recovery.dat"))
-        self.fg.connect(self.slicer,
+        self._fg.connect(self.slicer,
                         gr.file_sink(gr.sizeof_char, "slicer.dat"))

Modified: 
gnuradio/branches/developers/eb/digital-wip/gnuradio-core/src/python/gnuradio/blksimpl/pkt.py
===================================================================
--- 
gnuradio/branches/developers/eb/digital-wip/gnuradio-core/src/python/gnuradio/blksimpl/pkt.py
       2006-09-16 19:29:18 UTC (rev 3555)
+++ 
gnuradio/branches/developers/eb/digital-wip/gnuradio-core/src/python/gnuradio/blksimpl/pkt.py
       2006-09-17 04:53:40 UTC (rev 3556)
@@ -81,7 +81,7 @@
         else:
             # print "original_payload =", string_to_hex_list(payload)
             pkt = packet_utils.make_packet(payload,
-                                           self._modulator.samples_per_baud(),
+                                           
self._modulator.samples_per_symbol(),
                                            self._modulator.bits_per_baud(),
                                            self._access_code,
                                            self._pad_for_usrp)

Modified: 
gnuradio/branches/developers/eb/digital-wip/gnuradio-core/src/python/gnuradio/blksimpl/qpsk.py
===================================================================
--- 
gnuradio/branches/developers/eb/digital-wip/gnuradio-core/src/python/gnuradio/blksimpl/qpsk.py
      2006-09-16 19:29:18 UTC (rev 3555)
+++ 
gnuradio/branches/developers/eb/digital-wip/gnuradio-core/src/python/gnuradio/blksimpl/qpsk.py
      2006-09-17 04:53:40 UTC (rev 3556)
@@ -99,7 +99,7 @@
        # Initialize base class
        gr.hier_block.__init__(self, fg, self.bytes2chunks, self.rrc_filter)
 
-    def samples_per_baud(self):
+    def samples_per_symbol(self):
         return self.spb
 
     def bits_per_baud(self=None):   # static method that's also callable on an 
instance
@@ -230,7 +230,7 @@
         # Initialize base class
         gr.hier_block.__init__(self, fg, self.agc, self.unpack)
 
-    def samples_per_baud(self):
+    def samples_per_symbol(self):
         return self.spb
 
     def bits_per_baud(self=None):   # staticmethod that's also callable on an 
instance
@@ -344,7 +344,7 @@
         # Initialize base class
         gr.hier_block.__init__(self, fg, self.agc, self.unpack)
 
-    def samples_per_baud(self):
+    def samples_per_symbol(self):
         return self.spb
 
     def bits_per_baud(self):

Modified: 
gnuradio/branches/developers/eb/digital-wip/gnuradio-core/src/python/gnuradio/packet_utils.py
===================================================================
--- 
gnuradio/branches/developers/eb/digital-wip/gnuradio-core/src/python/gnuradio/packet_utils.py
       2006-09-16 19:29:18 UTC (rev 3555)
+++ 
gnuradio/branches/developers/eb/digital-wip/gnuradio-core/src/python/gnuradio/packet_utils.py
       2006-09-17 04:53:40 UTC (rev 3556)
@@ -97,16 +97,16 @@
 def make_header(payload_len):
     return struct.pack('!HH', payload_len, payload_len)
 
-def make_packet(payload, spb, bits_per_baud, access_code=default_access_code, 
pad_for_usrp=True):
+def make_packet(payload, samples_per_symbol, bits_per_symbol, 
access_code=default_access_code, pad_for_usrp=True):
     """
     Build a packet, given access code and payload.
 
-    @param payload:       packet payload, len [0, 4096]
-    @param spb:           samples per baud (needed for padding calculation)
-    @type  spb:           int
-    @param bits_per_baud: (needed for padding calculation)
-    @type bits_per_baud:  int
-    @param access_code:   string of ascii 0's and 1's
+    @param payload:               packet payload, len [0, 4096]
+    @param samples_per_symbol:    samples per symbol (needed for padding 
calculation)
+    @type  samples_per_symbol:    int
+    @param bits_per_symbol:       (needed for padding calculation)
+    @type bits_per_symbol:        int
+    @param access_code:           string of ascii 0's and 1's
     
     Packet will have access code at the beginning, followed by length, payload
     and finally CRC-32.
@@ -126,12 +126,12 @@
 
     pkt = ''.join((packed_access_code, make_header(L), 
whiten(payload_with_crc), '\x55'))
     if pad_for_usrp:
-        pkt = pkt + (_npadding_bytes(len(pkt), spb, bits_per_baud) * '\x55')
+        pkt = pkt + (_npadding_bytes(len(pkt), samples_per_symbol, 
bits_per_symbol) * '\x55')
 
     #print "make_packet: len(pkt) =", len(pkt)
     return pkt
 
-def _npadding_bytes(pkt_byte_len, spb, bits_per_baud):
+def _npadding_bytes(pkt_byte_len, samples_per_symbol, bits_per_symbol):
     """
     Generate sufficient padding such that each packet ultimately ends
     up being a multiple of 512 bytes when sent across the USB.  We
@@ -140,13 +140,13 @@
     is a multiple of 128 samples.
 
     @param ptk_byte_len: len in bytes of packet, not including padding.
-    @param spb: samples per baud == samples per bit (1 bit / baud with GMSK)
-    @type spb: int
+    @param samples_per_symbol: samples per bit (1 bit / symbolwith GMSK)
+    @type samples_per_symbol: int
 
     @returns number of bytes of padding to append.
     """
     modulus = 128
-    byte_modulus = gru.lcm(modulus/8, spb) * bits_per_baud / spb
+    byte_modulus = gru.lcm(modulus/8, samples_per_symbol) * bits_per_symbol / 
samples_per_symbol
     r = pkt_byte_len % byte_modulus
     if r == 0:
         return 0


Property changes on: 
gnuradio/branches/developers/eb/digital-wip/gnuradio-examples/python/channel-coding/fsm_files
___________________________________________________________________
Name: svn:ignore
   + Makefile
Makefile.in


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-16 19:29:18 UTC (rev 3555)
+++ 
gnuradio/branches/developers/eb/digital-wip/gnuradio-examples/python/gmsk2/benchmark_tx.py
  2006-09-17 04:53:40 UTC (rev 3556)
@@ -55,7 +55,7 @@
     def rx_callback(ok, payload):
         print "ok = %r, payload = '%s'" % (ok, payload)
 
-    parser = OptionParser (option_class=eng_option)
+    parser = OptionParser(option_class=eng_option, conflict_handler="resolve")
     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,
@@ -64,11 +64,15 @@
                       help="enable discontinous transmission (bursts of 5 
packets)")
     parser.add_option("-m", "--modulation", type="choice", 
choices=blks.modulators.keys(),
                       default='dbpsk',
-                      help="Set modulation type %s" % blks.modulators.keys())
+                      help="Select modulation from %s [default=%%default]"
+                            % (', '.join(blks.modulators.keys()),))
+
+    transmit_path.add_options(parser)
+
     mod_grp = parser.add_option_group("Modulation")
     for mod in blks.modulators.values():
         mod.add_options(mod_grp)
-    transmit_path.add_options(parser)
+
     fusb_options.add_options(parser)
     (options, args) = parser.parse_args ()
 
@@ -76,8 +80,8 @@
         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)
 

Modified: 
gnuradio/branches/developers/eb/digital-wip/gnuradio-examples/python/gmsk2/pick_bitrate.py
===================================================================
--- 
gnuradio/branches/developers/eb/digital-wip/gnuradio-examples/python/gmsk2/pick_bitrate.py
  2006-09-16 19:29:18 UTC (rev 3555)
+++ 
gnuradio/branches/developers/eb/digital-wip/gnuradio-examples/python/gmsk2/pick_bitrate.py
  2006-09-17 04:53:40 UTC (rev 3556)
@@ -1,5 +1,5 @@
 #
-# Copyright 2005 Free Software Foundation, Inc.
+# Copyright 2005,2006 Free Software Foundation, Inc.
 # 
 # This file is part of GNU Radio
 # 
@@ -21,36 +21,36 @@
 
 _default_bitrate = 500e3
 
-_valid_spbs = (2,3,4,5,6,7)
+_valid_samples_per_symbol = (2,3,4,5,6,7)
 
 def _gen_tx_info(converter_rate):
     results = []
-    for spb in _valid_spbs:
+    for samples_per_symbol in _valid_samples_per_symbol:
         for interp in range(16, 512 + 1, 4):
-            bitrate = converter_rate / interp / spb
-            results.append((bitrate, spb, interp))
+            bitrate = converter_rate / interp / samples_per_symbol
+            results.append((bitrate, samples_per_symbol, interp))
     results.sort()
     return results
 
 def _gen_rx_info(converter_rate):
     results = []
-    for spb in _valid_spbs:
+    for samples_per_symbol in _valid_samples_per_symbol:
         for decim in range(8, 256 + 1, 2):
-            bitrate = converter_rate / decim / spb
-            results.append((bitrate, spb, decim))
+            bitrate = converter_rate / decim / samples_per_symbol
+            results.append((bitrate, samples_per_symbol, decim))
     results.sort()
     return results
     
-def _filter_info(info, samples_per_baud, xrate):
-    if samples_per_baud is not None:
-        info = [x for x in info if x[1] == samples_per_baud]
+def _filter_info(info, samples_per_symbol, xrate):
+    if samples_per_symbol is not None:
+        info = [x for x in info if x[1] == samples_per_symbol]
     if xrate is not None:
         info = [x for x in info if x[2] == xrate]
     return info
 
 def _pick_best(target_bitrate, bits_per_symbol, info):
     """
-    @returns tuple (bitrate, samples_per_baud, interp_rate_or_decim_rate)
+    @returns tuple (bitrate, samples_per_symbol, interp_rate_or_decim_rate)
     """
     if len(info) == 0:
         raise RuntimeError, "info is zero length!"
@@ -62,7 +62,7 @@
     target_symbolrate = target_bitrate / bits_per_symbol
     
     # Find the closest matching symbol rate.
-    # In the event of a tie, the one with the lowest samples_per_baud wins.
+    # In the event of a tie, the one with the lowest samples_per_symbol wins.
     # (We already sorted them, so the first one is the one we take)
 
     best = info[0]
@@ -76,30 +76,30 @@
     # convert symbol rate back to bit rate
     return ((best[0] * bits_per_symbol),) + best[1:]
 
-def _pick_bitrate(bitrate, bits_per_symbol, samples_per_baud,
+def _pick_bitrate(bitrate, bits_per_symbol, samples_per_symbol,
                   xrate, converter_rate, gen_info):
     """
-    @returns tuple (bitrate, samples_per_baud, interp_rate_or_decim_rate)
+    @returns tuple (bitrate, samples_per_symbol, interp_rate_or_decim_rate)
     """
     if not isinstance(bits_per_symbol, int) or bits_per_symbol < 1:
         raise ValueError, "bits_per_symbol must be an int >= 1"
     
-    if samples_per_baud is not None and xrate is not None:  # completely 
determined
-        return (float(converter_rate) / xrate / samples_per_baud,
-                samples_per_baud, xrate)
+    if samples_per_symbol is not None and xrate is not None:  # completely 
determined
+        return (float(converter_rate) / xrate / samples_per_symbol,
+                samples_per_symbol, xrate)
 
-    if bitrate is None and samples_per_baud is None and xrate is None:
+    if bitrate is None and samples_per_symbol is None and xrate is None:
         bitrate = _default_bitrate
 
     # now we have a target bitrate and possibly an xrate or
-    # samples_per_baud constraint, but not both of them.
+    # samples_per_symbol constraint, but not both of them.
 
     return _pick_best(bitrate, bits_per_symbol,
-                      _filter_info(gen_info(converter_rate), samples_per_baud, 
xrate))
+                      _filter_info(gen_info(converter_rate), 
samples_per_symbol, xrate))
     
 # 
---------------------------------------------------------------------------------------
 
-def pick_tx_bitrate(bitrate, bits_per_symbol, samples_per_baud,
+def pick_tx_bitrate(bitrate, bits_per_symbol, samples_per_symbol,
                     interp_rate, converter_rate=128e6):
     """
     Given the 4 input parameters, return at configuration that matches
@@ -108,20 +108,20 @@
     @type bitrate: number or None
     @param bits_per_symbol: E.g., BPSK -> 1, QPSK -> 2, 8-PSK -> 3
     @type bits_per_symbol: integer >= 1
-    @param samples_per_baud: samples/baud (aka samples/symbol)
-    @type samples_per_baud: number or None
+    @param samples_per_symbol: samples/baud (aka samples/symbol)
+    @type samples_per_symbol: number or None
     @param interp_rate: USRP interpolation factor
     @type interp_rate: integer or None
     @param converter_rate: converter sample rate in Hz
     @type converter_rate: number
 
-    @returns tuple (bitrate, samples_per_baud, interp_rate)
+    @returns tuple (bitrate, samples_per_symbol, interp_rate)
     """
-    return _pick_bitrate(bitrate, bits_per_symbol, samples_per_baud,
+    return _pick_bitrate(bitrate, bits_per_symbol, samples_per_symbol,
                          interp_rate, converter_rate, _gen_tx_info)
 
 
-def pick_rx_bitrate(bitrate, bits_per_symbol, samples_per_baud,
+def pick_rx_bitrate(bitrate, bits_per_symbol, samples_per_symbol,
                     decim_rate, converter_rate=64e6):
     """
     Given the 4 input parameters, return at configuration that matches
@@ -130,14 +130,14 @@
     @type bitrate: number or None
     @param bits_per_symbol: E.g., BPSK -> 1, QPSK -> 2, 8-PSK -> 3
     @type bits_per_symbol: integer >= 1
-    @param samples_per_baud: samples/baud (aka samples/symbol)
-    @type samples_per_baud: number or None
+    @param samples_per_symbol: samples/baud (aka samples/symbol)
+    @type samples_per_symbol: number or None
     @param decim_rate: USRP decimation factor
     @type decim_rate: integer or None
     @param converter_rate: converter sample rate in Hz
     @type converter_rate: number
 
-    @returns tuple (bitrate, samples_per_baud, decim_rate)
+    @returns tuple (bitrate, samples_per_symbol, decim_rate)
     """
-    return _pick_bitrate(bitrate, bits_per_symbol, samples_per_baud,
+    return _pick_bitrate(bitrate, bits_per_symbol, samples_per_symbol,
                          decim_rate, converter_rate, _gen_rx_info)

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-16 19:29:18 UTC (rev 3555)
+++ 
gnuradio/branches/developers/eb/digital-wip/gnuradio-examples/python/gmsk2/receive_path.py
  2006-09-17 04:53:40 UTC (rev 3556)
@@ -32,7 +32,7 @@
 # /////////////////////////////////////////////////////////////////////////////
 
 class receive_path(gr.hier_block):
-    def __init__(self, fg, demodulator, rx_callback, options, verbose=True):
+    def __init__(self, fg, demodulator, rx_callback, options):
 
         self._center_freq     = options.freq            # tranmitter's center 
frequency
         self._gain            = options.gain            # transmitter's 
digital gain
@@ -92,7 +92,7 @@
 
         # Display some information about the setup
         if verbose:
-            self.verbose()
+            self._print_verbage()
             
         fg.connect(self.u, self.chan_filt, self.packet_receiver)
         gr.hier_block.__init__(self, fg, None, None)
@@ -185,18 +185,6 @@
         """
         self.probe.set_threshold(threshold_in_db)
     
-    def verbose(self):
-        """
-        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 "spb:        %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)
-
         
     def add_options(parser):
         """
@@ -205,9 +193,8 @@
         rx_grp = parser.add_option_group("Receiver 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("-f", "--freq", type="eng_float", default=423.1e6,
-                          help="set Tx and Rx frequency to FREQ 
[default=%default]",
-                          metavar="FREQ")
+        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,
@@ -219,3 +206,15 @@
     # Make a static method to call before instantiation
     add_options = staticmethod(add_options)
 
+
+    def _print_verbage(self):
+        """
+        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)

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-16 19:29:18 UTC (rev 3555)
+++ 
gnuradio/branches/developers/eb/digital-wip/gnuradio-examples/python/gmsk2/transmit_path.py
 2006-09-17 04:53:40 UTC (rev 3556)
@@ -31,12 +31,13 @@
 # /////////////////////////////////////////////////////////////////////////////
 
 class transmit_path(gr.hier_block): 
-    def __init__(self, fg, modulator, options, verbose=True):
+    def __init__(self, fg, modulator, options):
         '''
         See below for what options should hold
         '''
 
-        self._center_freq     = options.freq            # tranmitter's center 
frequency
+        self._verbose         = options.verbose
+        self._tx_freq         = options.tx_freq         # tranmitter's center 
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
@@ -48,21 +49,21 @@
         self._modulator       = modulator               # the modulator we are 
using
     
         # Set up USRP sink; also adjusts interp, spb, and bitrate
-        self.set_usrp_sink()
+        self._setup_usrp_sink()
 
         # Get mod_kwargs
-        mod_kwargs = blks.kwargs(self._modulator, [self._spb, self._interp, 
self._bitrate])
+        mod_kwargs = self._modulator.extract_kwargs_from_options(options)
 
-        # Set carrier frequency of USRP
-        ok = self.set_freq(self._center_freq)
+        # Set center frequency of USRP
+        ok = self.set_freq(self._tx_freq)
         if not ok:
             print "Failed to set Tx frequency to %s" % 
(eng_notation.num_to_str(options.freq),)
-            raise SystemExit
+            raise ValueError
     
         # transmitter
         self.packet_transmitter = \
             blks.mod_pkts(fg,
-                          self._modulator(fg, debug=options.debug, 
**mod_kwargs),
+                          self._modulator(fg, **mod_kwargs),
                           access_code=None,
                           msgq_limit=4,
                           pad_for_usrp=True)
@@ -77,20 +78,20 @@
         self.set_auto_tr(True)
 
         # Display some information about the setup
-        if verbose:
-            self.verbose()
+        if self._verbose:
+            self._print_verbage()
 
         # 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):
+    def _setup_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)
+        self.u = usrp.sink_c(fusb_block_size=self._fusb_block_size,
+                             fusb_nblocks=self._fusb_nblocks)
         dac_rate = self.u.dac_rate();
 
         self.set_bitrate(dac_rate)
@@ -159,27 +160,16 @@
     def interp(self):
         return self._interp
 
-    def verbose(self):
-        """
-        Prints information about the transmit path
-        """
-        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 "Center Frequency: %s" % 
(eng_notation.num_to_str(self._center_freq))
-        print "Using TX d'board %s" % (self.subdev.side_and_name(),)
-        
     def add_options(parser):
         """
         Adds transmitter-specific options to the Options Parser
         """
+        parser.add_option("-v", "--verbose", action="store_true", 
default=False)
         tx_grp = parser.add_option_group("Transmit Path")
         tx_grp.add_option("-T", "--tx-subdev-spec", type="subdev", 
default=None,
                           help="select USRP Tx side A or B")
-        tx_grp.add_option("-f", "--freq", type="eng_float", default=423.1e6,
-                          help="set Tx and Rx frequency to FREQ 
[default=%default]",
-                          metavar="FREQ")
+        tx_grp.add_option("", "--tx-freq", type="eng_float", default=None,
+                          help="set transmit frequency to FREQ 
[default=%default]", metavar="FREQ")
         tx_grp.add_option("-r", "--bitrate", type="eng_float", default=None,
                           help="specify bitrate.  spb and interp will be 
derived.")
         tx_grp.add_option("-S", "--spb", type="int", default=None,
@@ -190,3 +180,15 @@
                           help="transmitter gain [default=%default]")
     # Make a static method to call before instantiation
     add_options = staticmethod(add_options)
+
+    def _print_verbage(self):
+        """
+        Prints information about the transmit path
+        """
+        print "Using TX d'board %s" % (self.subdev.side_and_name(),)
+        print "modulation:      %s" % (self._modulator.__name__)
+        print "bitrate:         %sb/sec" % 
(eng_notation.num_to_str(self._bitrate))
+        print "samples/symbol:  %3d" % (self._spb)
+        print "interp:          %3d" % (self._interp)
+        print "Tx Frequency:    %s" % (eng_notation.num_to_str(self._tx_freq))
+        





reply via email to

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