summaryrefslogtreecommitdiff
path: root/gnuradio-core/src/python
diff options
context:
space:
mode:
Diffstat (limited to 'gnuradio-core/src/python')
-rw-r--r--gnuradio-core/src/python/gnuradio/Makefile.am2
-rw-r--r--gnuradio-core/src/python/gnuradio/blks2impl/logpwrfft.py8
-rw-r--r--gnuradio-core/src/python/gnuradio/blks2impl/ofdm.py75
-rw-r--r--gnuradio-core/src/python/gnuradio/modulation_utils2.py20
-rw-r--r--gnuradio-core/src/python/gnuradio/vocoder/Makefile.am26
-rw-r--r--gnuradio-core/src/python/gnuradio/vocoder/__init__.py1
6 files changed, 48 insertions, 84 deletions
diff --git a/gnuradio-core/src/python/gnuradio/Makefile.am b/gnuradio-core/src/python/gnuradio/Makefile.am
index 30b5d02ab..289e37662 100644
--- a/gnuradio-core/src/python/gnuradio/Makefile.am
+++ b/gnuradio-core/src/python/gnuradio/Makefile.am
@@ -22,7 +22,7 @@
include $(top_srcdir)/Makefile.common
if PYTHON
-SUBDIRS = gr gru gruimpl blks2 blks2impl vocoder
+SUBDIRS = gr gru gruimpl blks2 blks2impl
grpython_PYTHON = \
__init__.py \
diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/logpwrfft.py b/gnuradio-core/src/python/gnuradio/blks2impl/logpwrfft.py
index 200c4cfbe..6f7fc520f 100644
--- a/gnuradio-core/src/python/gnuradio/blks2impl/logpwrfft.py
+++ b/gnuradio-core/src/python/gnuradio/blks2impl/logpwrfft.py
@@ -54,13 +54,13 @@ class _logpwrfft_base(gr.hier_block2):
fft = self._fft_block[0](fft_size, True, fft_window)
window_power = sum(map(lambda x: x*x, fft_window))
- c2mag = gr.complex_to_mag(fft_size)
+ c2magsq = gr.complex_to_mag_squared(fft_size)
self._avg = gr.single_pole_iir_filter_ff(1.0, fft_size)
- self._log = gr.nlog10_ff(20, fft_size,
+ self._log = gr.nlog10_ff(10, fft_size,
-20*math.log10(fft_size) # Adjust for number of bins
-10*math.log10(window_power/fft_size) # Adjust for windowing loss
- -20*math.log10(ref_scale/2)+3.0) # Adjust for reference scale
- self.connect(self, self._sd, fft, c2mag, self._avg, self._log, self)
+ -20*math.log10(ref_scale/2)) # Adjust for reference scale
+ self.connect(self, self._sd, fft, c2magsq, self._avg, self._log, self)
self._average = average
self._avg_alpha = avg_alpha
diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/ofdm.py b/gnuradio-core/src/python/gnuradio/blks2impl/ofdm.py
index 3b1cd12ac..2663f7cf8 100644
--- a/gnuradio-core/src/python/gnuradio/blks2impl/ofdm.py
+++ b/gnuradio-core/src/python/gnuradio/blks2impl/ofdm.py
@@ -21,26 +21,12 @@
#
import math
-from gnuradio import gr, ofdm_packet_utils, modulation_utils2
+from gnuradio import gr, ofdm_packet_utils
import gnuradio.gr.gr_threading as _threading
import psk, qam
from gnuradio.blks2impl.ofdm_receiver import ofdm_receiver
-def _add_common_options(normal, expert):
- """
- Adds OFDM-specific options to the Options Parser that are common
- both to the modulator and demodulator.
- """
- mods_list = ", ".join(modulation_utils2.type_1_constellations().keys())
- normal.add_option("-m", "--modulation", type="string", default="psk",
- help="set modulation type (" + mods_list + ") [default=%default]")
- expert.add_option("", "--fft-length", type="intx", default=512,
- help="set the number of FFT bins [default=%default]")
- expert.add_option("", "--occupied-tones", type="intx", default=200,
- help="set the number of occupied FFT bins [default=%default]")
- expert.add_option("", "--cp-length", type="intx", default=128,
- help="set the number of bits in the cyclic prefix [default=%default]")
# /////////////////////////////////////////////////////////////////////////////
# mod/demod with packets as i/o
@@ -75,8 +61,6 @@ class ofdm_mod(gr.hier_block2):
self._fft_length = options.fft_length
self._occupied_tones = options.occupied_tones
self._cp_length = options.cp_length
-
- arity = options.constellation_points
win = [] #[1 for i in range(self._fft_length)]
@@ -98,9 +82,19 @@ class ofdm_mod(gr.hier_block2):
symbol_length = options.fft_length + options.cp_length
- const = modulation_utils2.type_1_constellations()[self._modulation](arity).points()
-
- self._pkt_input = gr.ofdm_mapper_bcv(const, msgq_limit,
+ mods = {"bpsk": 2, "qpsk": 4, "8psk": 8, "qam8": 8, "qam16": 16, "qam64": 64, "qam256": 256}
+ arity = mods[self._modulation]
+
+ rot = 1
+ if self._modulation == "qpsk":
+ rot = (0.707+0.707j)
+
+ if(self._modulation.find("psk") >= 0):
+ rotated_const = map(lambda pt: pt * rot, psk.gray_constellation[arity])
+ elif(self._modulation.find("qam") >= 0):
+ rotated_const = map(lambda pt: pt * rot, qam.constellation[arity])
+ #print rotated_const
+ self._pkt_input = gr.ofdm_mapper_bcv(rotated_const, msgq_limit,
options.occupied_tones, options.fft_length)
self.preambles = gr.ofdm_insert_preamble(self._fft_length, padded_preambles)
@@ -146,10 +140,14 @@ class ofdm_mod(gr.hier_block2):
"""
Adds OFDM-specific options to the Options Parser
"""
- _add_common_options(normal, expert)
- for mod in modulation_utils2.type_1_mods().values():
- mod.add_options(expert)
-
+ normal.add_option("-m", "--modulation", type="string", default="bpsk",
+ help="set modulation type (bpsk, qpsk, 8psk, qam{16,64}) [default=%default]")
+ expert.add_option("", "--fft-length", type="intx", default=512,
+ help="set the number of FFT bins [default=%default]")
+ expert.add_option("", "--occupied-tones", type="intx", default=200,
+ help="set the number of occupied FFT bins [default=%default]")
+ expert.add_option("", "--cp-length", type="intx", default=128,
+ help="set the number of bits in the cyclic prefix [default=%default]")
# Make a static method to call before instantiation
add_options = staticmethod(add_options)
@@ -198,9 +196,6 @@ class ofdm_demod(gr.hier_block2):
self._cp_length = options.cp_length
self._snr = options.snr
- arity = options.constellation_points
- print("con points is %s" % options.constellation_points)
-
# Use freq domain to get doubled-up known symbol for correlation in time domain
zeros_on_left = int(math.ceil((self._fft_length - self._occupied_tones)/2.0))
ksfreq = known_symbols_4512_3[0:self._occupied_tones]
@@ -216,11 +211,22 @@ class ofdm_demod(gr.hier_block2):
self._occupied_tones, self._snr, preambles,
options.log)
- constell = modulation_utils2.type_1_constellations()[self._modulation](arity)
+ mods = {"bpsk": 2, "qpsk": 4, "8psk": 8, "qam8": 8, "qam16": 16, "qam64": 64, "qam256": 256}
+ arity = mods[self._modulation]
+
+ rot = 1
+ if self._modulation == "qpsk":
+ rot = (0.707+0.707j)
+
+ if(self._modulation.find("psk") >= 0):
+ rotated_const = map(lambda pt: pt * rot, psk.gray_constellation[arity])
+ elif(self._modulation.find("qam") >= 0):
+ rotated_const = map(lambda pt: pt * rot, qam.constellation[arity])
+ #print rotated_const
phgain = 0.25
frgain = phgain*phgain / 4.0
- self.ofdm_demod = gr.ofdm_frame_sink2(constell.base(),
+ self.ofdm_demod = gr.ofdm_frame_sink(rotated_const, range(arity),
self._rcvd_pktq,
self._occupied_tones,
phgain, frgain)
@@ -247,9 +253,14 @@ class ofdm_demod(gr.hier_block2):
"""
Adds OFDM-specific options to the Options Parser
"""
- _add_common_options(normal, expert)
- for mod in modulation_utils2.type_1_mods().values():
- mod.add_options(expert)
+ normal.add_option("-m", "--modulation", type="string", default="bpsk",
+ help="set modulation type (bpsk or qpsk) [default=%default]")
+ expert.add_option("", "--fft-length", type="intx", default=512,
+ help="set the number of FFT bins [default=%default]")
+ expert.add_option("", "--occupied-tones", type="intx", default=200,
+ help="set the number of occupied FFT bins [default=%default]")
+ expert.add_option("", "--cp-length", type="intx", default=128,
+ help="set the number of bits in the cyclic prefix [default=%default]")
# Make a static method to call before instantiation
add_options = staticmethod(add_options)
diff --git a/gnuradio-core/src/python/gnuradio/modulation_utils2.py b/gnuradio-core/src/python/gnuradio/modulation_utils2.py
index f30055f4a..c5dba3e79 100644
--- a/gnuradio-core/src/python/gnuradio/modulation_utils2.py
+++ b/gnuradio-core/src/python/gnuradio/modulation_utils2.py
@@ -47,15 +47,6 @@ def type_1_demods():
def add_type_1_demod(name, demod_class):
_type_1_demodulators[name] = demod_class
-# Also record the constellation making functions of the modulations
-_type_1_constellations = {}
-
-def type_1_constellations():
- return _type_1_constellations
-
-def add_type_1_constellation(name, constellation):
- _type_1_constellations[name] = constellation
-
def extract_kwargs_from_options(function, excluded_args, options):
"""
@@ -88,14 +79,3 @@ def extract_kwargs_from_options(function, excluded_args, options):
if getattr(options, kw) is not None:
d[kw] = getattr(options, kw)
return d
-
-def extract_kwargs_from_options_for_class(cls, options):
- """
- Given command line options, create dictionary suitable for passing to __init__
- """
- d = extract_kwargs_from_options(
- cls.__init__, ('self',), options)
- for base in cls.__bases__:
- if hasattr(base, 'extract_kwargs_from_options'):
- d.update(base.extract_kwargs_from_options(options))
- return d
diff --git a/gnuradio-core/src/python/gnuradio/vocoder/Makefile.am b/gnuradio-core/src/python/gnuradio/vocoder/Makefile.am
deleted file mode 100644
index 69c140c10..000000000
--- a/gnuradio-core/src/python/gnuradio/vocoder/Makefile.am
+++ /dev/null
@@ -1,26 +0,0 @@
-#
-# Copyright 2004,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.
-#
-
-include $(top_srcdir)/Makefile.common
-
-grvocoderpythondir = $(grpythondir)/vocoder
-grvocoderpython_PYTHON = \
- __init__.py
diff --git a/gnuradio-core/src/python/gnuradio/vocoder/__init__.py b/gnuradio-core/src/python/gnuradio/vocoder/__init__.py
deleted file mode 100644
index a4917cf64..000000000
--- a/gnuradio-core/src/python/gnuradio/vocoder/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-# make this a package