Fixing a few bugs in handling of real samples per symbol.
authorTom Rondeau <trondeau@vt.edu>
Fri, 26 Feb 2010 15:11:39 +0000 (10:11 -0500)
committerTom Rondeau <trondeau@vt.edu>
Fri, 26 Feb 2010 15:11:39 +0000 (10:11 -0500)
gnuradio-core/src/python/gnuradio/blks2impl/dqpsk2.py
gnuradio-examples/python/digital/pick_bitrate2.py
gnuradio-examples/python/digital/receive_path.py
gnuradio-examples/python/digital/transmit_path.py

index 9fae6accac07c14cf5aff158d8b6f2dde0bbbd22..96cf0144f2010ef98ffc8f5884777c851c3a7c5a 100644 (file)
@@ -83,8 +83,8 @@ class dqpsk2_mod(gr.hier_block2):
         self._excess_bw = excess_bw
         self._gray_code = gray_code
 
-        if not isinstance(samples_per_symbol, int) or samples_per_symbol < 2:
-            raise TypeError, ("sbp must be an integer >= 2, is %d" % samples_per_symbol)
+        if samples_per_symbol < 2:
+            raise TypeError, ("sbp must be >= 2, is %f" % samples_per_symbol)
 
        ntaps = 11 * samples_per_symbol
  
@@ -107,7 +107,7 @@ class dqpsk2_mod(gr.hier_block2):
 
         # pulse shaping filter
         nfilts = 32
-        ntaps = nfilts * 11 * self._samples_per_symbol      # make nfilts filters of ntaps each
+        ntaps = 11 * int(nfilts * self._samples_per_symbol)  # make nfilts filters of ntaps each
         self.rrc_taps = gr.firdes.root_raised_cosine(
             nfilts,          # gain
             nfilts,          # sampling rate based on 32 filters in resampler
index 23081117c9ee8809f54819d570b3eb4be88cd7e9..92539560c3427515c96588537d5436d88f66f28c 100644 (file)
@@ -68,8 +68,7 @@ def _pick_bitrate(bitrate, bits_per_symbol, samples_per_symbol,
         try:
             xrate = rate
         except UnboundLocalError:
-            print "Requested bitrate out of bounds"
-            sys.exit(1)
+            raise ValueError("Requested bitrate out of bounds")
             
         samples_per_symbol = converter_rate / bits_per_symbol / rate / bitrate
         bitrate = converter_rate / bits_per_symbol / xrate / samples_per_symbol
@@ -100,7 +99,7 @@ def _pick_bitrate(bitrate, bits_per_symbol, samples_per_symbol,
         raise ValueError(("Invalid rate (rate = %d)" % xrate))
     if((samples_per_symbol < _sps_min) or (samples_per_symbol > _sps_max)):
         raise ValueError(("Invalid samples per symbol (sps = %.2f). Must be in [%.0f, %.0f]." \
-                          % (xrate, _sps_min, _sps_max)))
+                          % (samples_per_symbol, _sps_min, _sps_max)))
         
     return (bitrate, samples_per_symbol, int(xrate))
 
index 7df945ed00474c05dbcb5d9a5467e273d4bff30c..0024d6941f714778d61c43b040a2aeb575c95816 100644 (file)
@@ -119,7 +119,7 @@ class receive_path(gr.hier_block2):
             normal.add_option("-r", "--bitrate", type="eng_float", default=100e3,
                               help="specify bitrate [default=%default].")
         normal.add_option("-v", "--verbose", action="store_true", default=False)
-        expert.add_option("-S", "--samples-per-symbol", type="int", default=None,
+        expert.add_option("-S", "--samples-per-symbol", type="float", default=None,
                           help="set samples/symbol [default=%default]")
         expert.add_option("", "--log", action="store_true", default=False,
                           help="Log all parts of flow graph to files (CAUTION: lots of data)")
index ba0c434da27e67e30ec7b194e3595f06588c6478..86ebf75c3e87b70482f5a110b7dc664450ee16f3 100644 (file)
@@ -99,7 +99,7 @@ class transmit_path(gr.hier_block2):
                           help="set transmitter digital amplitude: 0 <= AMPL < 1 [default=%default]")
         normal.add_option("-v", "--verbose", action="store_true", default=False)
 
-        expert.add_option("-S", "--samples-per-symbol", type="int", default=None,
+        expert.add_option("-S", "--samples-per-symbol", type="float", default=None,
                           help="set samples/symbol [default=%default]")
         expert.add_option("", "--log", action="store_true", default=False,
                           help="Log all parts of flow graph to file (CAUTION: lots of data)")