From 9be3761d689f512bd1faaaec40baa41ef15286e2 Mon Sep 17 00:00:00 2001
From: Tom Rondeau <trondeau@vt.edu>
Date: Sun, 24 Jul 2011 17:47:18 -0400
Subject: digital: working digital transmit benchmark script to file.

---
 gr-digital/examples/receive_path.py | 138 ++++++++++++++++++++++++++++++++++++
 1 file changed, 138 insertions(+)
 create mode 100644 gr-digital/examples/receive_path.py

(limited to 'gr-digital/examples/receive_path.py')

diff --git a/gr-digital/examples/receive_path.py b/gr-digital/examples/receive_path.py
new file mode 100644
index 0000000000..0024d6941f
--- /dev/null
+++ b/gr-digital/examples/receive_path.py
@@ -0,0 +1,138 @@
+#!/usr/bin/env python
+#
+# Copyright 2005,2006,2007 Free Software Foundation, Inc.
+# 
+# This file is part of GNU Radio
+# 
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+# 
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with GNU Radio; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+# 
+
+from gnuradio import gr, gru, blks2
+from gnuradio import eng_notation
+import copy
+import sys
+
+# /////////////////////////////////////////////////////////////////////////////
+#                              receive path
+# /////////////////////////////////////////////////////////////////////////////
+
+class receive_path(gr.hier_block2):
+    def __init__(self, demod_class, rx_callback, options):
+	gr.hier_block2.__init__(self, "receive_path",
+				gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature
+				gr.io_signature(0, 0, 0))                    # Output signature
+
+        
+        options = copy.copy(options)    # make a copy so we can destructively modify
+
+        self._verbose            = options.verbose
+        self._bitrate            = options.bitrate         # desired bit rate
+        self._samples_per_symbol = options.samples_per_symbol  # desired samples/symbol
+
+        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
+
+        # 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._samples_per_symbol, # sampling rate
+                                          1.0,                  # midpoint of trans. band
+                                          0.5,                  # width of trans. band
+                                          gr.firdes.WIN_HANN)   # filter type
+        self.channel_filter = gr.fft_filter_ccc(sw_decim, chan_coeffs)
+        
+        # receiver
+        self.packet_receiver = \
+            blks2.demod_pkts(self._demod_class(**demod_kwargs),
+                             access_code=None,
+                             callback=self._rx_callback,
+                             threshold=-1)
+
+        # Carrier Sensing Blocks
+        alpha = 0.001
+        thresh = 30   # in dB, will have to adjust
+        self.probe = gr.probe_avg_mag_sqrd_c(thresh,alpha)
+
+        # Display some information about the setup
+        if self._verbose:
+            self._print_verbage()
+
+	# connect block input to channel filter
+	self.connect(self, self.channel_filter)
+
+        # connect the channel input filter to the carrier power detector
+        self.connect(self.channel_filter, self.probe)
+
+        # connect channel filter to the packet receiver
+        self.connect(self.channel_filter, self.packet_receiver)
+
+    def bitrate(self):
+        return self._bitrate
+
+    def samples_per_symbol(self):
+        return self._samples_per_symbol
+
+    def carrier_sensed(self):
+        """
+        Return True if we think carrier is present.
+        """
+        #return self.probe.level() > X
+        return self.probe.unmuted()
+
+    def carrier_threshold(self):
+        """
+        Return current setting in dB.
+        """
+        return self.probe.threshold()
+
+    def set_carrier_threshold(self, threshold_in_db):
+        """
+        Set carrier threshold.
+
+        @param threshold_in_db: set detection threshold
+        @type threshold_in_db:  float (dB)
+        """
+        self.probe.set_threshold(threshold_in_db)
+    
+        
+    def add_options(normal, expert):
+        """
+        Adds receiver-specific options to the Options Parser
+        """
+        if not normal.has_option("--bitrate"):
+            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="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)")
+
+    # Make a static method to call before instantiation
+    add_options = staticmethod(add_options)
+
+
+    def _print_verbage(self):
+        """
+        Prints information about the receive path
+        """
+        print "\nReceive Path:"
+        print "modulation:      %s"    % (self._demod_class.__name__)
+        print "bitrate:         %sb/s" % (eng_notation.num_to_str(self._bitrate))
+        print "samples/symbol:  %.4f"   % (self._samples_per_symbol)
-- 
cgit v1.2.3


From 8b3c4ccf922c602ae77dad7f3911b16bdd0112d3 Mon Sep 17 00:00:00 2001
From: Tom Rondeau <trondeau@vt.edu>
Date: Tue, 26 Jul 2011 20:59:49 -0400
Subject: digital: reworking code so digital examples work. BPSK seems to work
 fine offline.

---
 gr-digital/examples/benchmark_tx.py    | 13 ++++++-----
 gr-digital/examples/receive_path.py    | 12 +++++-----
 gr-digital/python/Makefile.am          |  3 ---
 gr-digital/python/__init__.py          |  5 ++---
 gr-digital/python/bpsk.py              | 12 ++++++----
 gr-digital/python/d8psk.py             | 11 +++++----
 gr-digital/python/dbpsk.py             | 16 +++++++------
 gr-digital/python/dqpsk.py             | 10 +++++----
 gr-digital/python/generic_mod_demod.py | 31 ++++++++++++-------------
 gr-digital/python/packet_utils.py      |  2 +-
 gr-digital/python/pkt.py               |  7 +++---
 gr-digital/python/psk2.py              |  3 +--
 gr-digital/python/qam.py               |  7 ++----
 gr-digital/python/qpsk.py              | 41 +++++++++++++++++++++++++++++-----
 14 files changed, 105 insertions(+), 68 deletions(-)

(limited to 'gr-digital/examples/receive_path.py')

diff --git a/gr-digital/examples/benchmark_tx.py b/gr-digital/examples/benchmark_tx.py
index 78c1315666..01902c0e37 100755
--- a/gr-digital/examples/benchmark_tx.py
+++ b/gr-digital/examples/benchmark_tx.py
@@ -44,8 +44,11 @@ class my_top_block(gr.top_block):
 
         self.txpath = transmit_path(modulator, options)
 
-        self.sink = gr.file_sink(gr.sizeof_gr_complex, options.to_file)
-        
+        if(options.to_file is not None):
+            self.sink = gr.file_sink(gr.sizeof_gr_complex, options.to_file)
+        else:
+            self.sink = gr.null_sink(gr.sizeof_gr_complex)
+
         self.connect(self.txpath, self.sink)
 
 # /////////////////////////////////////////////////////////////////////////////
@@ -66,7 +69,7 @@ def main():
     expert_grp = parser.add_option_group("Expert")
 
     parser.add_option("-m", "--modulation", type="choice", choices=mods.keys(),
-                      default='dbpsk',
+                      default='psk',
                       help="Select modulation from: %s [default=%%default]"
                             % (', '.join(mods.keys()),))
 
@@ -77,9 +80,9 @@ def main():
     parser.add_option("","--discontinuous", action="store_true", default=False,
                       help="enable discontinous transmission (bursts of 5 packets)")
     parser.add_option("","--from-file", default=None,
-                      help="use file for packet contents")
+                      help="use intput file for packet contents")
     parser.add_option("","--to-file", default=None,
-                      help="use file sink")
+                      help="Output file for modulated samples")
 
     transmit_path.add_options(parser, expert_grp)
 
diff --git a/gr-digital/examples/receive_path.py b/gr-digital/examples/receive_path.py
index 0024d6941f..9bc5f7b8f2 100644
--- a/gr-digital/examples/receive_path.py
+++ b/gr-digital/examples/receive_path.py
@@ -20,8 +20,10 @@
 # Boston, MA 02110-1301, USA.
 # 
 
-from gnuradio import gr, gru, blks2
+from gnuradio import gr, gru
 from gnuradio import eng_notation
+from gnuradio import digital
+
 import copy
 import sys
 
@@ -59,10 +61,10 @@ class receive_path(gr.hier_block2):
         
         # receiver
         self.packet_receiver = \
-            blks2.demod_pkts(self._demod_class(**demod_kwargs),
-                             access_code=None,
-                             callback=self._rx_callback,
-                             threshold=-1)
+            digital.demod_pkts(self._demod_class(**demod_kwargs),
+                               access_code=None,
+                               callback=self._rx_callback,
+                               threshold=-1)
 
         # Carrier Sensing Blocks
         alpha = 0.001
diff --git a/gr-digital/python/Makefile.am b/gr-digital/python/Makefile.am
index 164bafb998..87752e9ae0 100644
--- a/gr-digital/python/Makefile.am
+++ b/gr-digital/python/Makefile.am
@@ -49,9 +49,6 @@ digital_PYTHON = \
 	bpsk.py			\
 	cpm.py			\
 	crc.py			\
-	d8psk.py		\
-	dbpsk.py		\
-	dqpsk.py		\
 	generic_mod_demod.py	\
 	gmsk.py			\
 	modulation_utils.py	\
diff --git a/gr-digital/python/__init__.py b/gr-digital/python/__init__.py
index 73c69bb27b..4046f7fafe 100644
--- a/gr-digital/python/__init__.py
+++ b/gr-digital/python/__init__.py
@@ -22,10 +22,9 @@
 # The presence of this file turns this directory into a Python package
 
 from digital_swig import *
-from dbpsk import *
-from dqpsk import *
-from d8psk import *
 from psk2 import *
+from bpsk import *
+from qpsk import *
 from qam import *
 from pkt import *
 from packet_utils import *
diff --git a/gr-digital/python/bpsk.py b/gr-digital/python/bpsk.py
index 6d2eb5d6d5..51de3ce084 100644
--- a/gr-digital/python/bpsk.py
+++ b/gr-digital/python/bpsk.py
@@ -26,8 +26,10 @@ BPSK modulation and demodulation.
 from math import pi, log
 from cmath import exp
 
-from gnuradio import gr, modulation_utils2
+from gnuradio import gr
 from gnuradio.digital.generic_mod_demod import generic_mod, generic_demod
+import digital_swig
+import modulation_utils2
 
 # Default number of points in constellation.
 _def_constellation_points = 2
@@ -41,7 +43,7 @@ _def_differential = True
 def bpsk_constellation(m=_def_constellation_points):
     if m != _def_constellation_points:
         raise ValueError("BPSK can only have 2 constellation points.")
-    return gr.constellation_bpsk()
+    return digital_swig.constellation_bpsk()
 
 # /////////////////////////////////////////////////////////////////////////////
 #                           BPSK modulator
@@ -61,7 +63,8 @@ class bpsk_mod(generic_mod):
         See generic_mod block for list of parameters.
 	"""
 
-        constellation = gr.constellation_bpsk()
+        constellation_points = _def_constellation_points
+        constellation = digital_swig.constellation_bpsk()
         if constellation_points != 2:
             raise ValueError('Number of constellation points must be 2 for BPSK.')
         super(bpsk_mod, self).__init__(constellation, *args, **kwargs)
@@ -85,7 +88,8 @@ class bpsk_demod(generic_demod):
         See generic_demod block for list of parameters.
         """
 
-        constellation = gr.constellation_bpsk()
+        constellation_points = _def_constellation_points
+        constellation = digital_swig.constellation_bpsk()
         if constellation_points != 2:
             raise ValueError('Number of constellation points must be 2 for BPSK.')
         super(bpsk_demod, self).__init__(constellation, *args, **kwargs)
diff --git a/gr-digital/python/d8psk.py b/gr-digital/python/d8psk.py
index 8bed395a7f..46290faeda 100644
--- a/gr-digital/python/d8psk.py
+++ b/gr-digital/python/d8psk.py
@@ -310,8 +310,9 @@ class d8psk_demod(gr.hier_block2):
         print "Timing alpha gain:   %.2f" % self._timing_alpha
         print "Timing beta gain:    %.2f" % self._timing_beta
         print "Timing max dev:      %.2f" % self._timing_max_dev
-        print "Phase track alpha:   %.2e" % self._phase_alpha
-        print "Phase track beta:    %.2e" % self._phase_beta
+        print "Phase damping fact:  %.2e" % self._phase_damping
+        print "Phase natural freq:  %.2e" % self._phase_natfreq
+
 
     def _setup_logging(self):
         print "Modulation logging turned on."
@@ -343,8 +344,10 @@ class d8psk_demod(gr.hier_block2):
                           help="disable gray coding on modulated bits (PSK)")
         parser.add_option("", "--freq-alpha", type="float", default=_def_freq_alpha,
                           help="set frequency lock loop alpha gain value [default=%default] (PSK)")
-        parser.add_option("", "--phase-alpha", type="float", default=_def_phase_alpha,
-                          help="set phase tracking loop alpha value [default=%default] (PSK)")
+        parser.add_option("", "--phase-natfreq", type="float", default=_def_phase_natfreq,
+                          help="set natural frequency of phase tracking loop [default=%default] (PSK)")
+        parser.add_option("", "--phase-damping", type="float", default=_def_phase_damping,
+                          help="set damping factor of phase tracking loop [default=%default] (PSK)")
         parser.add_option("", "--timing-alpha", type="float", default=_def_timing_alpha,
                           help="set timing symbol sync loop gain alpha value [default=%default] (GMSK/PSK)")
         parser.add_option("", "--timing-beta", type="float", default=_def_timing_beta,
diff --git a/gr-digital/python/dbpsk.py b/gr-digital/python/dbpsk.py
index 1732c44ea0..9e065263f6 100644
--- a/gr-digital/python/dbpsk.py
+++ b/gr-digital/python/dbpsk.py
@@ -100,6 +100,7 @@ class dbpsk_mod(gr.hier_block2):
 
         self.diffenc = gr.diff_encoder_bb(arity)
 
+        
         self.chunks2symbols = gr.chunks_to_symbols_bc(psk.constellation[arity])
 
         # pulse shaping filter
@@ -272,9 +273,8 @@ class dbpsk_demod(gr.hier_block2):
         self.diffdec = gr.diff_phasor_cc()
 
         # find closest constellation point
-        rot = 1
-        rotated_const = map(lambda pt: pt * rot, psk.constellation[arity])
-        self.slicer = digital.constellation_decoder_cb(rotated_const, range(arity))
+        const = digital_swig.constellation_bpsk()
+        self.slicer = digital_swig.constellation_decoder_cb(const.base())
 
         if self._gray_code:
             self.symbol_mapper = gr.map_bb(psk.gray_to_binary[arity])
@@ -312,8 +312,8 @@ class dbpsk_demod(gr.hier_block2):
         print "Timing alpha gain:   %.2e" % self._timing_alpha
         print "Timing beta gain:    %.2e" % self._timing_beta
         print "Timing max dev:      %.2f" % self._timing_max_dev
-        print "Phase track alpha:   %.2e" % self._phase_alpha
-        print "Phase track beta:    %.2e" % self._phase_beta
+        print "Phase damping fact:  %.2e" % self._phase_damping
+        print "Phase natural freq:  %.2e" % self._phase_natfreq
 
     def _setup_logging(self):
         print "Modulation logging turned on."
@@ -345,8 +345,10 @@ class dbpsk_demod(gr.hier_block2):
                           help="disable gray coding on modulated bits (PSK)")
         parser.add_option("", "--freq-alpha", type="float", default=_def_freq_alpha,
                           help="set frequency lock loop alpha gain value [default=%default] (PSK)")
-        parser.add_option("", "--phase-alpha", type="float", default=_def_phase_alpha,
-                          help="set phase tracking loop alpha value [default=%default] (PSK)")
+        parser.add_option("", "--phase-natfreq", type="float", default=_def_phase_natfreq,
+                          help="set natural frequency of phase tracking loop [default=%default] (PSK)")
+        parser.add_option("", "--phase-damping", type="float", default=_def_phase_damping,
+                          help="set damping factor of phase tracking loop [default=%default] (PSK)")
         parser.add_option("", "--timing-alpha", type="float", default=_def_timing_alpha,
                           help="set timing symbol sync loop gain alpha value [default=%default] (GMSK/PSK)")
         parser.add_option("", "--timing-beta", type="float", default=_def_timing_beta,
diff --git a/gr-digital/python/dqpsk.py b/gr-digital/python/dqpsk.py
index 29afd55306..5e17d24bcc 100644
--- a/gr-digital/python/dqpsk.py
+++ b/gr-digital/python/dqpsk.py
@@ -315,8 +315,8 @@ class dqpsk_demod(gr.hier_block2):
         print "Timing alpha gain:   %.2f" % self._timing_alpha
         print "Timing beta gain:    %.2f" % self._timing_beta
         print "Timing max dev:      %.2f" % self._timing_max_dev
-        print "Phase track alpha:   %.2e" % self._phase_alpha
-        print "Phase track beta:    %.2e" % self._phase_beta
+        print "Phase damping fact:  %.2e" % self._phase_damping
+        print "Phase natural freq:  %.2e" % self._phase_natfreq
 
     def _setup_logging(self):
         print "Modulation logging turned on."
@@ -348,8 +348,10 @@ class dqpsk_demod(gr.hier_block2):
                           help="disable gray coding on modulated bits (PSK)")
         parser.add_option("", "--freq-alpha", type="float", default=_def_freq_alpha,
                           help="set frequency lock loop alpha gain value [default=%default] (PSK)")
-        parser.add_option("", "--phase-alpha", type="float", default=_def_phase_alpha,
-                          help="set phase tracking loop alpha value [default=%default] (PSK)")
+        parser.add_option("", "--phase-natfreq", type="float", default=_def_phase_natfreq,
+                          help="set natural frequency of phase tracking loop [default=%default] (PSK)")
+        parser.add_option("", "--phase-damping", type="float", default=_def_phase_damping,
+                          help="set damping factor of phase tracking loop [default=%default] (PSK)")
         parser.add_option("", "--timing-alpha", type="float", default=_def_timing_alpha,
                           help="set timing symbol sync loop gain alpha value [default=%default] (GMSK/PSK)")
         parser.add_option("", "--timing-beta", type="float", default=_def_timing_beta,
diff --git a/gr-digital/python/generic_mod_demod.py b/gr-digital/python/generic_mod_demod.py
index 04302f0a48..1b8603fea6 100644
--- a/gr-digital/python/generic_mod_demod.py
+++ b/gr-digital/python/generic_mod_demod.py
@@ -26,8 +26,7 @@ Generic modulation and demodulation.
 """
 
 from gnuradio import gr
-from gnuradio.modulation_utils2 import extract_kwargs_from_options_for_class
-#from gnuradio.digital.utils import mod_codes
+from modulation_utils2 import extract_kwargs_from_options_for_class
 from utils import mod_codes
 import digital_swig
 
@@ -106,12 +105,10 @@ class generic_mod(gr.hier_block2):
         self._samples_per_symbol = samples_per_symbol
         self._excess_bw = excess_bw
         self._differential = differential
- 
-        if not isinstance(self._samples_per_symbol, int) or self._samples_per_symbol < 2:
-            raise TypeError, ("sbp must be an integer >= 2, is %d" % self._samples_per_symbol)
-        
-	ntaps = 11 * self._samples_per_symbol
 
+        if self._samples_per_symbol < 2:
+            raise TypeError, ("sbp must be >= 2, is %d" % self._samples_per_symbol)
+        
         arity = pow(2,self.bits_per_symbol())
         
         # turn bytes into k-bit vectors
@@ -127,14 +124,15 @@ class generic_mod(gr.hier_block2):
         self.chunks2symbols = gr.chunks_to_symbols_bc(self._constellation.points())
 
         # pulse shaping filter
-	self.rrc_taps = gr.firdes.root_raised_cosine(
-	    self._samples_per_symbol,   # gain (samples_per_symbol since we're
-                                        # interpolating by samples_per_symbol)
-	    self._samples_per_symbol,   # sampling rate
-	    1.0,		        # symbol rate
-	    self._excess_bw,            # excess bandwidth (roll-off factor)
+        nfilts = 32
+        ntaps = nfilts * 11 * int(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
+            1.0,             # symbol rate
+            self._excess_bw, # excess bandwidth (roll-off factor)
             ntaps)
-	self.rrc_filter = gr.interp_fir_filter_ccf(self._samples_per_symbol,
+        self.rrc_filter = gr.pfb_arb_resampler_ccf(self._samples_per_symbol,
                                                    self.rrc_taps)
 
 	# Connect
@@ -255,8 +253,8 @@ class generic_demod(gr.hier_block2):
         self._timing_max_dev=timing_max_dev
         self._differential = differential
 
-        if not isinstance(self._samples_per_symbol, int) or self._samples_per_symbol < 2:
-            raise TypeError, ("sbp must be an integer >= 2, is %d" % self._samples_per_symbol)
+        if self._samples_per_symbol < 2:
+            raise TypeError, ("sbp must be >= 2, is %d" % self._samples_per_symbol)
 
         arity = pow(2,self.bits_per_symbol())
 
@@ -279,7 +277,6 @@ class generic_demod(gr.hier_block2):
                                                 taps, nfilts, nfilts/2, self._timing_max_dev)
         self.time_recov.set_beta(self._timing_beta)
 
-        #self._phase_beta  = 0.25 * self._phase_alpha * self._phase_alpha
         self._phase_beta  = 0.25 * self._phase_alpha * self._phase_alpha
         fmin = -0.25
         fmax = 0.25
diff --git a/gr-digital/python/packet_utils.py b/gr-digital/python/packet_utils.py
index addbf43f57..2e216ff50e 100644
--- a/gr-digital/python/packet_utils.py
+++ b/gr-digital/python/packet_utils.py
@@ -184,7 +184,7 @@ def unmake_packet(whitened_payload_with_crc, whitener_offset=0, dewhitening=True
     else:
         payload_with_crc = (whitened_payload_with_crc)
 
-    ok, payload = gru.check_crc32(payload_with_crc)
+    ok, payload = crc.check_crc32(payload_with_crc)
 
     if 0:
         print "payload_with_crc =", string_to_hex_list(payload_with_crc)
diff --git a/gr-digital/python/pkt.py b/gr-digital/python/pkt.py
index 80001a187b..c9b29bd51a 100644
--- a/gr-digital/python/pkt.py
+++ b/gr-digital/python/pkt.py
@@ -23,6 +23,7 @@ from math import pi
 from gnuradio import gr
 import gnuradio.gr.gr_threading as _threading
 import packet_utils
+import digital_swig
 
 
 # /////////////////////////////////////////////////////////////////////////////
@@ -35,8 +36,8 @@ class mod_pkts(gr.hier_block2):
 
     Send packets by calling send_pkt
     """
-    def __init__(self, modulator, access_code=None, msgq_limit=2, pad_for_usrp=True, use_whitener_offset=False,
-                 modulate=True):
+    def __init__(self, modulator, access_code=None, msgq_limit=2, pad_for_usrp=True,
+                 use_whitener_offset=False, modulate=True):
         """
 	Hierarchical block for sending packets
 
@@ -155,7 +156,7 @@ class demod_pkts(gr.hier_block2):
             threshold = 12              # FIXME raise exception
 
         self._rcvd_pktq = gr.msg_queue()          # holds packets from the PHY
-        self.correlator = gr.correlate_access_code_bb(access_code, threshold)
+        self.correlator = digital_swig.correlate_access_code_bb(access_code, threshold)
 
         self.framer_sink = gr.framer_sink_1(self._rcvd_pktq)
         if self._demodulator is not None:
diff --git a/gr-digital/python/psk2.py b/gr-digital/python/psk2.py
index 6ab398e42c..82781e63b0 100644
--- a/gr-digital/python/psk2.py
+++ b/gr-digital/python/psk2.py
@@ -26,9 +26,8 @@ PSK modulation and demodulation.
 from math import pi, log
 from cmath import exp
 
-from gnuradio import gr, modulation_utils2
 import digital_swig
-#from gnuradio.digital.generic_mod_demod import generic_mod, generic_demod
+import modulation_utils2
 from utils import mod_codes, gray_code
 from generic_mod_demod import generic_mod, generic_demod
 
diff --git a/gr-digital/python/qam.py b/gr-digital/python/qam.py
index 5eb34e4b2d..f29291ce89 100644
--- a/gr-digital/python/qam.py
+++ b/gr-digital/python/qam.py
@@ -25,14 +25,11 @@ QAM modulation and demodulation.
 
 from math import pi, sqrt, log
 
-from gnuradio import gr, modulation_utils2
-#from gnuradio.digital.generic_mod_demod import generic_mod, generic_demod
-#from gnuradio.digital.utils.gray_code import gray_code
-#from gnuradio.digital.utils import mod_codes
-
+from gnuradio import gr
 from generic_mod_demod import generic_mod, generic_demod
 from utils.gray_code import gray_code
 from utils import mod_codes
+import modulation_utils2
 
 # Default number of points in constellation.
 _def_constellation_points = 16
diff --git a/gr-digital/python/qpsk.py b/gr-digital/python/qpsk.py
index ea17244241..91e8b196f4 100644
--- a/gr-digital/python/qpsk.py
+++ b/gr-digital/python/qpsk.py
@@ -26,9 +26,10 @@ Demodulation is not included since the generic_mod_demod
 doesn't work for non-differential encodings.
 """
 
-from gnuradio import gr, modulation_utils2
-from gnuradio.digital.generic_mod_demod import generic_mod
-
+from gnuradio import gr
+from gnuradio.digital.generic_mod_demod import generic_mod, generic_demod
+import digital_swig
+import modulation_utils2
 
 # Default number of points in constellation.
 _def_constellation_points = 4
@@ -43,7 +44,7 @@ _def_gray_coded = True
 def qpsk_constellation(m=_def_constellation_points): 
     if m != _def_constellation_points:
         raise ValueError("QPSK can only have 4 constellation points.")
-    return gr.constellation_qpsk()
+    return digital_swig.constellation_qpsk()
 
 # /////////////////////////////////////////////////////////////////////////////
 #                           QPSK modulator
@@ -65,15 +66,45 @@ class qpsk_mod(generic_mod):
         See generic_mod block for list of parameters.
 	"""
 
-        constellation = gr.constellation_qpsk()
+        constellation_points = _def_constellation_points
+        constellation = digital_swig.constellation_qpsk()
         if constellation_points != 4:
             raise ValueError("QPSK can only have 4 constellation points.")
         if differential or not gray_coded:
             raise ValueError("This QPSK mod/demod works only for gray-coded, non-differential.")
         super(qpsk_mod, self).__init__(constellation, differential, gray_coded, *args, **kwargs)
 
+
+# /////////////////////////////////////////////////////////////////////////////
+#                           QPSK demodulator
+#
+# /////////////////////////////////////////////////////////////////////////////
+
+class qpsk_demod(generic_demod):
+
+    def __init__(self, constellation_points=_def_constellation_points,
+                 *args, **kwargs):
+
+        """
+	Hierarchical block for RRC-filtered QPSK modulation.
+
+	The input is a byte stream (unsigned char) and the
+	output is the complex modulated signal at baseband.
+
+        See generic_demod block for list of parameters.
+        """
+
+        constellation_points = _def_constellation_points
+        constellation = digital_swig.constellation_qpsk()
+        if constellation_points != 4:
+            raise ValueError('Number of constellation points must be 4 for QPSK.')
+        super(qpsk_demod, self).__init__(constellation, *args, **kwargs)
+
+
 #
 # Add these to the mod/demod registry
 #
 modulation_utils2.add_type_1_mod('qpsk', qpsk_mod)
+modulation_utils2.add_type_1_demod('qpsk', qpsk_demod)
 modulation_utils2.add_type_1_constellation('qpsk', qpsk_constellation)
+
-- 
cgit v1.2.3