From 598924aa8be0740583d9d32f99269e1e55134b6e Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Fri, 26 Feb 2010 10:11:39 -0500 Subject: [PATCH] Fixing a few bugs in handling of real samples per symbol. --- gnuradio-core/src/python/gnuradio/blks2impl/dqpsk2.py | 6 +++--- gnuradio-examples/python/digital/pick_bitrate2.py | 5 ++--- gnuradio-examples/python/digital/receive_path.py | 2 +- gnuradio-examples/python/digital/transmit_path.py | 2 +- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/dqpsk2.py b/gnuradio-core/src/python/gnuradio/blks2impl/dqpsk2.py index 9fae6acc..96cf0144 100644 --- a/gnuradio-core/src/python/gnuradio/blks2impl/dqpsk2.py +++ b/gnuradio-core/src/python/gnuradio/blks2impl/dqpsk2.py @@ -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 diff --git a/gnuradio-examples/python/digital/pick_bitrate2.py b/gnuradio-examples/python/digital/pick_bitrate2.py index 23081117..92539560 100644 --- a/gnuradio-examples/python/digital/pick_bitrate2.py +++ b/gnuradio-examples/python/digital/pick_bitrate2.py @@ -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)) diff --git a/gnuradio-examples/python/digital/receive_path.py b/gnuradio-examples/python/digital/receive_path.py index 7df945ed..0024d694 100644 --- a/gnuradio-examples/python/digital/receive_path.py +++ b/gnuradio-examples/python/digital/receive_path.py @@ -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)") diff --git a/gnuradio-examples/python/digital/transmit_path.py b/gnuradio-examples/python/digital/transmit_path.py index ba0c434d..86ebf75c 100644 --- a/gnuradio-examples/python/digital/transmit_path.py +++ b/gnuradio-examples/python/digital/transmit_path.py @@ -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)") -- 2.30.2