summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gnuradio-core/src/python/gnuradio/blks2impl/ofdm.py75
1 files changed, 32 insertions, 43 deletions
diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/ofdm.py b/gnuradio-core/src/python/gnuradio/blks2impl/ofdm.py
index 2663f7cf8..7e01e67b4 100644
--- a/gnuradio-core/src/python/gnuradio/blks2impl/ofdm.py
+++ b/gnuradio-core/src/python/gnuradio/blks2impl/ofdm.py
@@ -21,12 +21,26 @@
#
import math
-from gnuradio import gr, ofdm_packet_utils
+from gnuradio import gr, ofdm_packet_utils, modulation_utils2
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_mods().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
@@ -61,6 +75,8 @@ 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)]
@@ -82,19 +98,9 @@ class ofdm_mod(gr.hier_block2):
symbol_length = options.fft_length + options.cp_length
- 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,
+ const = modulation_utils2.type_1_constellations()[self._modulation](arity).points()
+
+ self._pkt_input = gr.ofdm_mapper_bcv(const, msgq_limit,
options.occupied_tones, options.fft_length)
self.preambles = gr.ofdm_insert_preamble(self._fft_length, padded_preambles)
@@ -140,14 +146,10 @@ class ofdm_mod(gr.hier_block2):
"""
Adds OFDM-specific options to the Options Parser
"""
- 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]")
+ _add_common_options(normal, expert)
+ for mod in modulation_utils2.type_1_mods().values():
+ mod.add_options(expert)
+
# Make a static method to call before instantiation
add_options = staticmethod(add_options)
@@ -196,6 +198,9 @@ 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]
@@ -211,22 +216,11 @@ class ofdm_demod(gr.hier_block2):
self._occupied_tones, self._snr, preambles,
options.log)
- 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
+ constell = modulation_utils2.type_1_constellations()[self._modulation](arity).points()
phgain = 0.25
frgain = phgain*phgain / 4.0
- self.ofdm_demod = gr.ofdm_frame_sink(rotated_const, range(arity),
+ self.ofdm_demod = gr.ofdm_frame_sink(constell, range(arity),
self._rcvd_pktq,
self._occupied_tones,
phgain, frgain)
@@ -253,14 +247,9 @@ class ofdm_demod(gr.hier_block2):
"""
Adds OFDM-specific options to the Options Parser
"""
- 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]")
+ _add_common_options(normal, expert)
+ for demod in modulation_utils2.type_1_demods().values():
+ demod.add_options(expert)
# Make a static method to call before instantiation
add_options = staticmethod(add_options)