summaryrefslogtreecommitdiff
path: root/gr-digital/python/qpsk.py
diff options
context:
space:
mode:
authorTom Rondeau2011-07-26 20:59:49 -0400
committerTom Rondeau2011-07-26 20:59:49 -0400
commit8b3c4ccf922c602ae77dad7f3911b16bdd0112d3 (patch)
treee87bdb4b6cddfe1ab4721736c0a95185eb95253d /gr-digital/python/qpsk.py
parentebcf1e9e180c7a8e9147ce441c5e9ab9056ecb13 (diff)
downloadgnuradio-8b3c4ccf922c602ae77dad7f3911b16bdd0112d3.tar.gz
gnuradio-8b3c4ccf922c602ae77dad7f3911b16bdd0112d3.tar.bz2
gnuradio-8b3c4ccf922c602ae77dad7f3911b16bdd0112d3.zip
digital: reworking code so digital examples work. BPSK seems to work fine offline.
Diffstat (limited to 'gr-digital/python/qpsk.py')
-rw-r--r--gr-digital/python/qpsk.py41
1 files changed, 36 insertions, 5 deletions
diff --git a/gr-digital/python/qpsk.py b/gr-digital/python/qpsk.py
index ea1724424..91e8b196f 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)
+