summaryrefslogtreecommitdiff
path: root/gnuradio-core/src/python/gnuradio/blks2impl
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2011-07-28 17:02:58 -0700
committerJosh Blum <josh@joshknows.com>2011-07-28 17:02:58 -0700
commit8bc1c4dc5a8d31594e8768a10e05b4b0172e733e (patch)
treefcb957028a108ca719a6cb879e7d62713b35ba1c /gnuradio-core/src/python/gnuradio/blks2impl
parent8c824bf2e3e6758aff05ee4b5f4d3f106a13c672 (diff)
parent8b3c4ccf922c602ae77dad7f3911b16bdd0112d3 (diff)
Merge branch 'digital' of https://github.com/trondeau/gnuradio into digital
Conflicts: gnuradio-core/src/lib/filter/gr_cma_equalizer_cc.h gnuradio-core/src/lib/general/gr_constellation_decoder_cb.h gnuradio-core/src/lib/general/gr_costas_loop_cc.h gnuradio-core/src/lib/general/gr_lms_dfe_cc.h gnuradio-core/src/lib/general/gr_lms_dfe_ff.h gr-digital/lib/Makefile.am gr-digital/lib/digital_binary_slicer_fb.h gr-digital/lib/digital_clock_recovery_mm_cc.h gr-digital/lib/digital_clock_recovery_mm_ff.h gr-digital/lib/digital_correlate_access_code_bb.h gr-digital/lib/digital_crc32.h gr-digital/lib/digital_mpsk_receiver_cc.h gr-digital/python/Makefile.am gr-digital/python/__init__.py gr-digital/python/generic_mod_demod.py gr-digital/python/pkt.py gr-digital/python/psk2.py gr-digital/python/qam.py
Diffstat (limited to 'gnuradio-core/src/python/gnuradio/blks2impl')
-rw-r--r--gnuradio-core/src/python/gnuradio/blks2impl/CMakeLists.txt12
-rw-r--r--gnuradio-core/src/python/gnuradio/blks2impl/Makefile.am12
-rw-r--r--gnuradio-core/src/python/gnuradio/blks2impl/cpm.py249
-rw-r--r--gnuradio-core/src/python/gnuradio/blks2impl/d8psk.py363
-rw-r--r--gnuradio-core/src/python/gnuradio/blks2impl/dbpsk.py363
-rw-r--r--gnuradio-core/src/python/gnuradio/blks2impl/dbpsk2.py369
-rw-r--r--gnuradio-core/src/python/gnuradio/blks2impl/dqpsk.py363
-rw-r--r--gnuradio-core/src/python/gnuradio/blks2impl/dqpsk2.py377
-rw-r--r--gnuradio-core/src/python/gnuradio/blks2impl/gmsk.py292
-rw-r--r--gnuradio-core/src/python/gnuradio/blks2impl/pkt.py164
-rw-r--r--gnuradio-core/src/python/gnuradio/blks2impl/qam16.py208
-rw-r--r--gnuradio-core/src/python/gnuradio/blks2impl/qam256.py209
-rw-r--r--gnuradio-core/src/python/gnuradio/blks2impl/qam64.py208
-rw-r--r--gnuradio-core/src/python/gnuradio/blks2impl/qam8.py209
14 files changed, 0 insertions, 3398 deletions
diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/CMakeLists.txt b/gnuradio-core/src/python/gnuradio/blks2impl/CMakeLists.txt
index 235cf35bed..8b0baedd92 100644
--- a/gnuradio-core/src/python/gnuradio/blks2impl/CMakeLists.txt
+++ b/gnuradio-core/src/python/gnuradio/blks2impl/CMakeLists.txt
@@ -23,17 +23,10 @@ GR_PYTHON_INSTALL(FILES
__init__.py
am_demod.py
channel_model.py
- dbpsk.py
- dbpsk2.py
- dqpsk.py
- dqpsk2.py
- d8psk.py
filterbank.py
fm_demod.py
fm_emph.py
generic_usrp.py
- gmsk.py
- cpm.py
logpwrfft.py
nbfm_rx.py
nbfm_tx.py
@@ -47,13 +40,8 @@ GR_PYTHON_INSTALL(FILES
pfb_channelizer.py
pfb_decimator.py
pfb_interpolator.py
- pkt.py
psk.py
qam.py
- qam8.py
- qam16.py
- qam64.py
- qam256.py
rational_resampler.py
standard_squelch.py
stream_to_vector_decimator.py
diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/Makefile.am b/gnuradio-core/src/python/gnuradio/blks2impl/Makefile.am
index 7b24fb69d7..9665dde0b8 100644
--- a/gnuradio-core/src/python/gnuradio/blks2impl/Makefile.am
+++ b/gnuradio-core/src/python/gnuradio/blks2impl/Makefile.am
@@ -30,17 +30,10 @@ grblkspython_PYTHON = \
__init__.py \
am_demod.py \
channel_model.py \
- dbpsk.py \
- dbpsk2.py \
- dqpsk.py \
- dqpsk2.py \
- d8psk.py \
filterbank.py \
fm_demod.py \
fm_emph.py \
generic_usrp.py \
- gmsk.py \
- cpm.py \
logpwrfft.py \
nbfm_rx.py \
nbfm_tx.py \
@@ -54,13 +47,8 @@ grblkspython_PYTHON = \
pfb_channelizer.py \
pfb_decimator.py \
pfb_interpolator.py \
- pkt.py \
psk.py \
qam.py \
- qam8.py \
- qam16.py \
- qam64.py \
- qam256.py \
rational_resampler.py \
standard_squelch.py \
stream_to_vector_decimator.py \
diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/cpm.py b/gnuradio-core/src/python/gnuradio/blks2impl/cpm.py
deleted file mode 100644
index 8f593cd51e..0000000000
--- a/gnuradio-core/src/python/gnuradio/blks2impl/cpm.py
+++ /dev/null
@@ -1,249 +0,0 @@
-#
-# CPM modulation and demodulation.
-#
-#
-# 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.
-#
-
-# See gnuradio-examples/python/digital for examples
-
-from gnuradio import gr
-from gnuradio import modulation_utils
-from math import pi
-import numpy
-from pprint import pprint
-import inspect
-
-# default values (used in __init__ and add_options)
-_def_samples_per_symbol = 2
-_def_bits_per_symbol = 1
-_def_h_numerator = 1
-_def_h_denominator = 2
-_def_cpm_type = 0 # 0=CPFSK, 1=GMSK, 2=RC, 3=GENERAL
-_def_bt = 0.35
-_def_symbols_per_pulse = 1
-_def_generic_taps = numpy.empty(1)
-_def_verbose = False
-_def_log = False
-
-
-# /////////////////////////////////////////////////////////////////////////////
-# CPM modulator
-# /////////////////////////////////////////////////////////////////////////////
-
-class cpm_mod(gr.hier_block2):
- def __init__(self,
- samples_per_symbol=_def_samples_per_symbol,
- bits_per_symbol=_def_bits_per_symbol,
- h_numerator=_def_h_numerator,
- h_denominator=_def_h_denominator,
- cpm_type=_def_cpm_type,
- bt=_def_bt,
- symbols_per_pulse=_def_symbols_per_pulse,
- generic_taps=_def_generic_taps,
- verbose=_def_verbose,
- log=_def_log):
- """
- Hierarchical block for Continuous Phase
- modulation.
-
- The input is a byte stream (unsigned char)
- representing packed bits and the
- output is the complex modulated signal at baseband.
-
- See Proakis for definition of generic CPM signals:
- s(t)=exp(j phi(t))
- phi(t)= 2 pi h int_0^t f(t') dt'
- f(t)=sum_k a_k g(t-kT)
- (normalizing assumption: int_0^infty g(t) dt = 1/2)
-
- @param samples_per_symbol: samples per baud >= 2
- @type samples_per_symbol: integer
- @param bits_per_symbol: bits per symbol
- @type bits_per_symbol: integer
- @param h_numerator: numerator of modulation index
- @type h_numerator: integer
- @param h_denominator: denominator of modulation index (numerator and denominator must be relative primes)
- @type h_denominator: integer
- @param cpm_type: supported types are: 0=CPFSK, 1=GMSK, 2=RC, 3=GENERAL
- @type cpm_type: integer
- @param bt: bandwidth symbol time product for GMSK
- @type bt: float
- @param symbols_per_pulse: shaping pulse duration in symbols
- @type symbols_per_pulse: integer
- @param generic_taps: define a generic CPM pulse shape (sum = samples_per_symbol/2)
- @type generic_taps: array of floats
-
- @param verbose: Print information about modulator?
- @type verbose: bool
- @param debug: Print modulation data to files?
- @type debug: bool
- """
-
- gr.hier_block2.__init__("cpm_mod",
- gr.io_signature(1, 1, gr.sizeof_char), # Input signature
- gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature
-
- self._samples_per_symbol = samples_per_symbol
- self._bits_per_symbol = bits_per_symbol
- self._h_numerator = h_numerator
- self._h_denominator = h_denominator
- self._cpm_type = cpm_type
- self._bt=bt
- if cpm_type == 0 or cpm_type == 2 or cpm_type == 3: # CPFSK, RC, Generic
- self._symbols_per_pulse = symbols_per_pulse
- elif cpm_type == 1: # GMSK
- self._symbols_per_pulse = 4
- else:
- raise TypeError, ("cpm_type must be an integer in {0,1,2,3}, is %r" % (cpm_type,))
-
- self._generic_taps=numpy.array(generic_taps)
-
- if not isinstance(samples_per_symbol, int) or samples_per_symbol < 2:
- raise TypeError, ("samples_per_symbol must be an integer >= 2, is %r" % (samples_per_symbol,))
-
- self.nsymbols = 2**bits_per_symbol
- self.sym_alphabet=numpy.arange(-(self.nsymbols-1),self.nsymbols,2)
-
-
- self.ntaps = self._symbols_per_pulse * samples_per_symbol
- sensitivity = 2 * pi * h_numerator / h_denominator / samples_per_symbol
-
- # Unpack Bytes into bits_per_symbol groups
- self.B2s = gr.packed_to_unpacked_bb(bits_per_symbol,gr.GR_MSB_FIRST)
-
-
- # Turn it into symmetric PAM data.
- self.pam = gr.chunks_to_symbols_bf(self.sym_alphabet,1)
-
- # Generate pulse (sum of taps = samples_per_symbol/2)
- if cpm_type == 0: # CPFSK
- self.taps= (1.0/self._symbols_per_pulse/2,) * self.ntaps
- elif cpm_type == 1: # GMSK
- gaussian_taps = gr.firdes.gaussian(
- 1.0/2, # gain
- samples_per_symbol, # symbol_rate
- bt, # bandwidth * symbol time
- self.ntaps # number of taps
- )
- sqwave = (1,) * samples_per_symbol # rectangular window
- self.taps = numpy.convolve(numpy.array(gaussian_taps),numpy.array(sqwave))
- elif cpm_type == 2: # Raised Cosine
- # generalize it for arbitrary roll-off factor
- self.taps = (1-numpy.cos(2*pi*numpy.arange(0,self.ntaps)/samples_per_symbol/self._symbols_per_pulse))/(2*self._symbols_per_pulse)
- elif cpm_type == 3: # Generic CPM
- self.taps = generic_taps
- else:
- raise TypeError, ("cpm_type must be an integer in {0,1,2,3}, is %r" % (cpm_type,))
-
- self.filter = gr.interp_fir_filter_fff(samples_per_symbol, self.taps)
-
- # FM modulation
- self.fmmod = gr.frequency_modulator_fc(sensitivity)
-
- if verbose:
- self._print_verbage()
-
- if log:
- self._setup_logging()
-
- # Connect
- self.connect(self, self.B2s, self.pam, self.filter, self.fmmod, self)
-
- #def samples_per_symbol(self):
- #return self._samples_per_symbol
-
- #def bits_per_symbol(self):
- #return self._bits_per_symbol
-
- #def h_numerator(self):
- #return self._h_numerator
-
- #def h_denominator(self):
- #return self._h_denominator
-
- #def cpm_type(self):
- #return self._cpm_type
-
- #def bt(self):
- #return self._bt
-
- #def symbols_per_pulse(self):
- #return self._symbols_per_pulse
-
-
- def _print_verbage(self):
- print "Samples per symbol = %d" % self._samples_per_symbol
- print "Bits per symbol = %d" % self._bits_per_symbol
- print "h = " , self._h_numerator , " / " , self._h_denominator
- print "Symbol alphabet = " , self.sym_alphabet
- print "Symbols per pulse = %d" % self._symbols_per_pulse
- print "taps = " , self.taps
-
- print "CPM type = %d" % self._cpm_type
- if self._cpm_type == 1:
- print "Gaussian filter BT = %.2f" % self._bt
-
-
- def _setup_logging(self):
- print "Modulation logging turned on."
- self.connect(self.B2s,
- gr.file_sink(gr.sizeof_float, "symbols.dat"))
- self.connect(self.pam,
- gr.file_sink(gr.sizeof_float, "pam.dat"))
- self.connect(self.filter,
- gr.file_sink(gr.sizeof_float, "filter.dat"))
- self.connect(self.fmmod,
- gr.file_sink(gr.sizeof_gr_complex, "fmmod.dat"))
-
-
- def add_options(parser):
- """
- Adds CPM modulation-specific options to the standard parser
- """
- parser.add_option("", "--bt", type="float", default=_def_bt,
- help="set bandwidth-time product [default=%default] (GMSK)")
- add_options=staticmethod(add_options)
-
-
- def extract_kwargs_from_options(options):
- """
- Given command line options, create dictionary suitable for passing to __init__
- """
- return modulation_utils.extract_kwargs_from_options(cpm_mod.__init__,
- ('self',), options)
- extract_kwargs_from_options=staticmethod(extract_kwargs_from_options)
-
-
-
-# /////////////////////////////////////////////////////////////////////////////
-# CPM demodulator
-# /////////////////////////////////////////////////////////////////////////////
-#
-# Not yet implemented
-#
-
-
-
-#
-# Add these to the mod/demod registry
-#
-modulation_utils.add_type_1_mod('cpm', cpm_mod)
-#modulation_utils.add_type_1_demod('cpm', cpm_demod)
diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/d8psk.py b/gnuradio-core/src/python/gnuradio/blks2impl/d8psk.py
deleted file mode 100644
index 67cf9f5696..0000000000
--- a/gnuradio-core/src/python/gnuradio/blks2impl/d8psk.py
+++ /dev/null
@@ -1,363 +0,0 @@
-#
-# 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.
-#
-
-# See gnuradio-examples/python/digital for examples
-
-"""
-differential 8PSK modulation and demodulation.
-"""
-
-from gnuradio import gr, gru, modulation_utils
-from math import pi, sqrt
-import psk
-import cmath
-from pprint import pprint
-
-# default values (used in __init__ and add_options)
-_def_samples_per_symbol = 3
-_def_excess_bw = 0.35
-_def_gray_code = True
-_def_verbose = False
-_def_log = False
-
-_def_costas_alpha = 0.175
-_def_gain_mu = 0.175
-_def_mu = 0.5
-_def_omega_relative_limit = 0.005
-
-
-# /////////////////////////////////////////////////////////////////////////////
-# D8PSK modulator
-# /////////////////////////////////////////////////////////////////////////////
-
-class d8psk_mod(gr.hier_block2):
-
- def __init__(self,
- samples_per_symbol=_def_samples_per_symbol,
- excess_bw=_def_excess_bw,
- gray_code=_def_gray_code,
- verbose=_def_verbose,
- log=_def_log):
- """
- 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.
-
- @param samples_per_symbol: samples per symbol >= 2
- @type samples_per_symbol: integer
- @param excess_bw: Root-raised cosine filter excess bandwidth
- @type excess_bw: float
- @param gray_code: Tell modulator to Gray code the bits
- @type gray_code: bool
- @param verbose: Print information about modulator?
- @type verbose: bool
- @param debug: Print modualtion data to files?
- @type debug: bool
- """
-
- gr.hier_block2.__init__(self, "d8psk_mod",
- gr.io_signature(1, 1, gr.sizeof_char), # Input signature
- gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature
-
- self._samples_per_symbol = samples_per_symbol
- 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)
-
- ntaps = 11 * samples_per_symbol
-
- arity = pow(2,self.bits_per_symbol())
-
- # turn bytes into k-bit vectors
- self.bytes2chunks = \
- gr.packed_to_unpacked_bb(self.bits_per_symbol(), gr.GR_MSB_FIRST)
-
- if self._gray_code:
- self.symbol_mapper = gr.map_bb(psk.binary_to_gray[arity])
- else:
- self.symbol_mapper = gr.map_bb(psk.binary_to_ungray[arity])
-
- self.diffenc = gr.diff_encoder_bb(arity)
-
- rot = 1
- rotated_const = map(lambda pt: pt * rot, psk.constellation[arity])
- self.chunks2symbols = gr.chunks_to_symbols_bc(rotated_const)
-
- # pulse shaping filter
- self.rrc_taps = gr.firdes.root_raised_cosine(
- self._samples_per_symbol, # gain (sps since we're interpolating by sps)
- self._samples_per_symbol, # sampling rate
- 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_taps)
-
- if verbose:
- self._print_verbage()
-
- if log:
- self._setup_logging()
-
- # Connect & Initialize base class
- self.connect(self, self.bytes2chunks, self.symbol_mapper, self.diffenc,
- self.chunks2symbols, self.rrc_filter, self)
-
- def samples_per_symbol(self):
- return self._samples_per_symbol
-
- def bits_per_symbol(self=None): # staticmethod that's also callable on an instance
- return 3
- bits_per_symbol = staticmethod(bits_per_symbol) # make it a static method. RTFM
-
- def _print_verbage(self):
- print "bits per symbol = %d" % self.bits_per_symbol()
- print "Gray code = %s" % self._gray_code
- print "RS roll-off factor = %f" % self._excess_bw
-
- def _setup_logging(self):
- print "Modulation logging turned on."
- self.connect(self.bytes2chunks,
- gr.file_sink(gr.sizeof_char, "tx_bytes2chunks.dat"))
- self.connect(self.symbol_mapper,
- gr.file_sink(gr.sizeof_char, "tx_graycoder.dat"))
- self.connect(self.diffenc,
- gr.file_sink(gr.sizeof_char, "tx_diffenc.dat"))
- self.connect(self.chunks2symbols,
- gr.file_sink(gr.sizeof_gr_complex, "tx_chunks2symbols.dat"))
- self.connect(self.rrc_filter,
- gr.file_sink(gr.sizeof_gr_complex, "tx_rrc_filter.dat"))
-
- def add_options(parser):
- """
- Adds 8PSK modulation-specific options to the standard parser
- """
- parser.add_option("", "--excess-bw", type="float", default=_def_excess_bw,
- help="set RRC excess bandwith factor [default=%default] (PSK)")
- parser.add_option("", "--no-gray-code", dest="gray_code",
- action="store_false", default=_def_gray_code,
- help="disable gray coding on modulated bits (PSK)")
- add_options=staticmethod(add_options)
-
-
- def extract_kwargs_from_options(options):
- """
- Given command line options, create dictionary suitable for passing to __init__
- """
- return modulation_utils.extract_kwargs_from_options(d8psk_mod.__init__,
- ('self',), options)
- extract_kwargs_from_options=staticmethod(extract_kwargs_from_options)
-
-
-# /////////////////////////////////////////////////////////////////////////////
-# D8PSK demodulator
-#
-# Differentially coherent detection of differentially encoded 8psk
-# /////////////////////////////////////////////////////////////////////////////
-
-class d8psk_demod(gr.hier_block2):
-
- def __init__(self,
- samples_per_symbol=_def_samples_per_symbol,
- excess_bw=_def_excess_bw,
- costas_alpha=_def_costas_alpha,
- gain_mu=_def_gain_mu,
- mu=_def_mu,
- omega_relative_limit=_def_omega_relative_limit,
- gray_code=_def_gray_code,
- verbose=_def_verbose,
- log=_def_log):
- """
- Hierarchical block for RRC-filtered DQPSK demodulation
-
- The input is the complex modulated signal at baseband.
- The output is a stream of bits packed 1 bit per byte (LSB)
-
- @param samples_per_symbol: samples per symbol >= 2
- @type samples_per_symbol: float
- @param excess_bw: Root-raised cosine filter excess bandwidth
- @type excess_bw: float
- @param costas_alpha: loop filter gain
- @type costas_alphas: float
- @param gain_mu: for M&M block
- @type gain_mu: float
- @param mu: for M&M block
- @type mu: float
- @param omega_relative_limit: for M&M block
- @type omega_relative_limit: float
- @param gray_code: Tell modulator to Gray code the bits
- @type gray_code: bool
- @param verbose: Print information about modulator?
- @type verbose: bool
- @param debug: Print modualtion data to files?
- @type debug: bool
- """
-
- gr.hier_block2.__init__(self, "d8psk_demod",
- gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature
- gr.io_signature(1, 1, gr.sizeof_char)) # Output signature
-
- self._samples_per_symbol = samples_per_symbol
- self._excess_bw = excess_bw
- self._costas_alpha = costas_alpha
- self._mm_gain_mu = gain_mu
- self._mm_mu = mu
- self._mm_omega_relative_limit = omega_relative_limit
- self._gray_code = gray_code
-
- if samples_per_symbol < 2:
- raise TypeError, "sbp must be >= 2, is %d" % samples_per_symbol
-
- arity = pow(2,self.bits_per_symbol())
-
- # Automatic gain control
- scale = (1.0/16384.0)
- self.pre_scaler = gr.multiply_const_cc(scale) # scale the signal from full-range to +-1
- #self.agc = gr.agc_cc(1e-2, 1, 1, 100)
- self.agc = gr.agc2_cc(1e-1, 1e-2, 1, 1, 100)
- #self.agc = gr.feedforward_agc_cc(16, 1.0)
-
- # RRC data filter
- ntaps = 11 * samples_per_symbol
- self.rrc_taps = gr.firdes.root_raised_cosine(
- 1.0, # gain
- self._samples_per_symbol, # sampling rate
- 1.0, # symbol rate
- self._excess_bw, # excess bandwidth (roll-off factor)
- ntaps)
- self.rrc_filter=gr.interp_fir_filter_ccf(1, self.rrc_taps)
-
- # symbol clock recovery
- self._mm_omega = self._samples_per_symbol
- self._mm_gain_omega = .25 * self._mm_gain_mu * self._mm_gain_mu
- self._costas_beta = 0.25 * self._costas_alpha * self._costas_alpha
- fmin = -0.025
- fmax = 0.025
-
- self.receiver=gr.mpsk_receiver_cc(arity, 0,
- self._costas_alpha, self._costas_beta,
- fmin, fmax,
- self._mm_mu, self._mm_gain_mu,
- self._mm_omega, self._mm_gain_omega,
- self._mm_omega_relative_limit)
-
- # Perform Differential decoding on the constellation
- self.diffdec = gr.diff_phasor_cc()
-
- # find closest constellation point
- rot = 1
- rotated_const = map(lambda pt: pt * rot, psk.constellation[arity])
- self.slicer = gr.constellation_decoder_cb(rotated_const, range(arity))
-
- if self._gray_code:
- self.symbol_mapper = gr.map_bb(psk.gray_to_binary[arity])
- else:
- self.symbol_mapper = gr.map_bb(psk.ungray_to_binary[arity])
-
-
- # unpack the k bit vector into a stream of bits
- self.unpack = gr.unpack_k_bits_bb(self.bits_per_symbol())
-
- if verbose:
- self._print_verbage()
-
- if log:
- self._setup_logging()
-
- # Connect
- self.connect(self, self.pre_scaler, self.agc, self.rrc_filter, self.receiver,
- self.diffdec, self.slicer, self.symbol_mapper, self.unpack, self)
-
- def samples_per_symbol(self):
- return self._samples_per_symbol
-
- def bits_per_symbol(self=None): # staticmethod that's also callable on an instance
- return 3
- bits_per_symbol = staticmethod(bits_per_symbol) # make it a static method. RTFM
-
- def _print_verbage(self):
- print "\nDemodulator:"
- print "bits per symbol: %d" % self.bits_per_symbol()
- print "Gray code: %s" % self._gray_code
- print "RRC roll-off factor: %.2f" % self._excess_bw
- print "Costas Loop alpha: %.2e" % self._costas_alpha
- print "Costas Loop beta: %.2e" % self._costas_beta
- print "M&M mu: %.2f" % self._mm_mu
- print "M&M mu gain: %.2e" % self._mm_gain_mu
- print "M&M omega: %.2f" % self._mm_omega
- print "M&M omega gain: %.2e" % self._mm_gain_omega
- print "M&M omega limit: %.2f" % self._mm_omega_relative_limit
-
-
- def _setup_logging(self):
- print "Modulation logging turned on."
- self.connect(self.pre_scaler,
- gr.file_sink(gr.sizeof_gr_complex, "rx_prescaler.dat"))
- self.connect(self.agc,
- gr.file_sink(gr.sizeof_gr_complex, "rx_agc.dat"))
- self.connect(self.rrc_filter,
- gr.file_sink(gr.sizeof_gr_complex, "rx_rrc_filter.dat"))
- self.connect(self.receiver,
- gr.file_sink(gr.sizeof_gr_complex, "rx_receiver.dat"))
- self.connect(self.diffdec,
- gr.file_sink(gr.sizeof_gr_complex, "rx_diffdec.dat"))
- self.connect(self.slicer,
- gr.file_sink(gr.sizeof_char, "rx_slicer.dat"))
- self.connect(self.symbol_mapper,
- gr.file_sink(gr.sizeof_char, "rx_gray_decoder.dat"))
- self.connect(self.unpack,
- gr.file_sink(gr.sizeof_char, "rx_unpack.dat"))
-
- def add_options(parser):
- """
- Adds modulation-specific options to the standard parser
- """
- parser.add_option("", "--excess-bw", type="float", default=_def_excess_bw,
- help="set RRC excess bandwith factor [default=%default] (PSK)")
- parser.add_option("", "--no-gray-code", dest="gray_code",
- action="store_false", default=_def_gray_code,
- help="disable gray coding on modulated bits (PSK)")
- parser.add_option("", "--costas-alpha", type="float", default=_def_costas_alpha,
- help="set Costas loop alpha value [default=%default] (PSK)")
- parser.add_option("", "--gain-mu", type="float", default=_def_gain_mu,
- help="set M&M symbol sync loop gain mu value [default=%default] (PSK)")
- parser.add_option("", "--mu", type="float", default=_def_mu,
- help="set M&M symbol sync loop mu value [default=%default] (PSK)")
- add_options=staticmethod(add_options)
-
- def extract_kwargs_from_options(options):
- """
- Given command line options, create dictionary suitable for passing to __init__
- """
- return modulation_utils.extract_kwargs_from_options(
- d8psk_demod.__init__, ('self',), options)
- extract_kwargs_from_options=staticmethod(extract_kwargs_from_options)
-
-
-#
-# Add these to the mod/demod registry
-#
-# NOT READY TO BE USED YET -- ENABLE AT YOUR OWN RISK
-modulation_utils.add_type_1_mod('d8psk', d8psk_mod)
-modulation_utils.add_type_1_demod('d8psk', d8psk_demod)
diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/dbpsk.py b/gnuradio-core/src/python/gnuradio/blks2impl/dbpsk.py
deleted file mode 100644
index 55e4890f30..0000000000
--- a/gnuradio-core/src/python/gnuradio/blks2impl/dbpsk.py
+++ /dev/null
@@ -1,363 +0,0 @@
-#
-# Copyright 2005,2006,2007,2009 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.
-#
-
-# See gnuradio-examples/python/digital for examples
-
-"""
-differential BPSK modulation and demodulation.
-"""
-
-from gnuradio import gr, gru, modulation_utils
-from math import pi, sqrt
-import psk
-import cmath
-from pprint import pprint
-
-# default values (used in __init__ and add_options)
-_def_samples_per_symbol = 2
-_def_excess_bw = 0.35
-_def_gray_code = True
-_def_verbose = False
-_def_log = False
-
-_def_costas_alpha = 0.1
-_def_gain_mu = None
-_def_mu = 0.5
-_def_omega_relative_limit = 0.005
-
-
-# /////////////////////////////////////////////////////////////////////////////
-# DBPSK modulator
-# /////////////////////////////////////////////////////////////////////////////
-
-class dbpsk_mod(gr.hier_block2):
-
- def __init__(self,
- samples_per_symbol=_def_samples_per_symbol,
- excess_bw=_def_excess_bw,
- gray_code=_def_gray_code,
- verbose=_def_verbose,
- log=_def_log):
- """
- Hierarchical block for RRC-filtered differential BPSK modulation.
-
- The input is a byte stream (unsigned char) and the
- output is the complex modulated signal at baseband.
-
- @param samples_per_symbol: samples per baud >= 2
- @type samples_per_symbol: integer
- @param excess_bw: Root-raised cosine filter excess bandwidth
- @type excess_bw: float
- @param gray_code: Tell modulator to Gray code the bits
- @type gray_code: bool
- @param verbose: Print information about modulator?
- @type verbose: bool
- @param log: Log modulation data to files?
- @type log: bool
- """
-
- gr.hier_block2.__init__(self, "dbpsk_mod",
- gr.io_signature(1, 1, gr.sizeof_char), # Input signature
- gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature
-
- self._samples_per_symbol = samples_per_symbol
- self._excess_bw = excess_bw
- self._gray_code = gray_code
-
- 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
-
- arity = pow(2,self.bits_per_symbol())
-
- # turn bytes into k-bit vectors
- self.bytes2chunks = \
- gr.packed_to_unpacked_bb(self.bits_per_symbol(), gr.GR_MSB_FIRST)
-
- if self._gray_code:
- self.symbol_mapper = gr.map_bb(psk.binary_to_gray[arity])
- else:
- self.symbol_mapper = gr.map_bb(psk.binary_to_ungray[arity])
-
- self.diffenc = gr.diff_encoder_bb(arity)
-
- self.chunks2symbols = gr.chunks_to_symbols_bc(psk.constellation[arity])
-
- # 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)
- ntaps)
- self.rrc_filter = gr.interp_fir_filter_ccf(self._samples_per_symbol,
- self.rrc_taps)
-
- # Connect
- self.connect(self, self.bytes2chunks, self.symbol_mapper, self.diffenc,
- self.chunks2symbols, self.rrc_filter, self)
-
- if verbose:
- self._print_verbage()
-
- if log:
- self._setup_logging()
-
-
- def samples_per_symbol(self):
- return self._samples_per_symbol
-
- def bits_per_symbol(self=None): # static method that's also callable on an instance
- return 1
- bits_per_symbol = staticmethod(bits_per_symbol) # make it a static method. RTFM
-
- def add_options(parser):
- """
- Adds DBPSK modulation-specific options to the standard parser
- """
- parser.add_option("", "--excess-bw", type="float", default=_def_excess_bw,
- help="set RRC excess bandwith factor [default=%default]")
- parser.add_option("", "--no-gray-code", dest="gray_code",
- action="store_false", default=True,
- help="disable gray coding on modulated bits (PSK)")
- add_options=staticmethod(add_options)
-
- def extract_kwargs_from_options(options):
- """
- Given command line options, create dictionary suitable for passing to __init__
- """
- return modulation_utils.extract_kwargs_from_options(dbpsk_mod.__init__,
- ('self',), options)
- extract_kwargs_from_options=staticmethod(extract_kwargs_from_options)
-
-
- def _print_verbage(self):
- print "\nModulator:"
- print "bits per symbol: %d" % self.bits_per_symbol()
- print "Gray code: %s" % self._gray_code
- print "RRC roll-off factor: %.2f" % self._excess_bw
-
- def _setup_logging(self):
- print "Modulation logging turned on."
- self.connect(self.bytes2chunks,
- gr.file_sink(gr.sizeof_char, "tx_bytes2chunks.dat"))
- self.connect(self.symbol_mapper,
- gr.file_sink(gr.sizeof_char, "tx_graycoder.dat"))
- self.connect(self.diffenc,
- gr.file_sink(gr.sizeof_char, "tx_diffenc.dat"))
- self.connect(self.chunks2symbols,
- gr.file_sink(gr.sizeof_gr_complex, "tx_chunks2symbols.dat"))
- self.connect(self.rrc_filter,
- gr.file_sink(gr.sizeof_gr_complex, "tx_rrc_filter.dat"))
-
-
-# /////////////////////////////////////////////////////////////////////////////
-# DBPSK demodulator
-#
-# Differentially coherent detection of differentially encoded BPSK
-# /////////////////////////////////////////////////////////////////////////////
-
-class dbpsk_demod(gr.hier_block2):
-
- def __init__(self,
- samples_per_symbol=_def_samples_per_symbol,
- excess_bw=_def_excess_bw,
- costas_alpha=_def_costas_alpha,
- gain_mu=_def_gain_mu,
- mu=_def_mu,
- omega_relative_limit=_def_omega_relative_limit,
- gray_code=_def_gray_code,
- verbose=_def_verbose,
- log=_def_log):
- """
- Hierarchical block for RRC-filtered differential BPSK demodulation
-
- The input is the complex modulated signal at baseband.
- The output is a stream of bits packed 1 bit per byte (LSB)
-
- @param samples_per_symbol: samples per symbol >= 2
- @type samples_per_symbol: float
- @param excess_bw: Root-raised cosine filter excess bandwidth
- @type excess_bw: float
- @param costas_alpha: loop filter gain
- @type costas_alphas: float
- @param gain_mu: for M&M block
- @type gain_mu: float
- @param mu: for M&M block
- @type mu: float
- @param omega_relative_limit: for M&M block
- @type omega_relative_limit: float
- @param gray_code: Tell modulator to Gray code the bits
- @type gray_code: bool
- @param verbose: Print information about modulator?
- @type verbose: bool
- @param debug: Print modualtion data to files?
- @type debug: bool
- """
-
- gr.hier_block2.__init__(self, "dbpsk_demod",
- gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature
- gr.io_signature(1, 1, gr.sizeof_char)) # Output signature
-
- self._samples_per_symbol = samples_per_symbol
- self._excess_bw = excess_bw
- self._costas_alpha = costas_alpha
- self._mm_gain_mu = gain_mu
- self._mm_mu = mu
- self._mm_omega_relative_limit = omega_relative_limit
- self._gray_code = gray_code
-
- if samples_per_symbol < 2:
- raise TypeError, "samples_per_symbol must be >= 2, is %r" % (samples_per_symbol,)
-
- arity = pow(2,self.bits_per_symbol())
-
- # Automatic gain control
- #scale = (1.0/16384.0)
- #self.pre_scaler = gr.multiply_const_cc(scale) # scale the signal from full-range to +-1
- self.agc = gr.agc2_cc(0.6e-1, 1e-3, 1, 1, 100)
- #self.agc = gr.feedforward_agc_cc(16, 2.0)
-
- # RRC data filter
- ntaps = 11 * samples_per_symbol
- self.rrc_taps = gr.firdes.root_raised_cosine(
- 1.0, # gain
- self._samples_per_symbol, # sampling rate
- 1.0, # symbol rate
- self._excess_bw, # excess bandwidth (roll-off factor)
- ntaps)
- self.rrc_filter=gr.interp_fir_filter_ccf(1, self.rrc_taps)
-
- # symbol clock recovery
- if not self._mm_gain_mu:
- self._mm_gain_mu = 0.1
-
- self._mm_omega = self._samples_per_symbol
- self._mm_gain_omega = .25 * self._mm_gain_mu * self._mm_gain_mu
- self._costas_beta = 0.25 * self._costas_alpha * self._costas_alpha
- fmin = -0.25
- fmax = 0.25
-
- self.receiver=gr.mpsk_receiver_cc(arity, 0,
- self._costas_alpha, self._costas_beta,
- fmin, fmax,
- self._mm_mu, self._mm_gain_mu,
- self._mm_omega, self._mm_gain_omega,
- self._mm_omega_relative_limit)
-
- # Do differential decoding based on phase change of symbols
- self.diffdec = gr.diff_phasor_cc()
-
- # find closest constellation point
- rot = 1
- rotated_const = map(lambda pt: pt * rot, psk.constellation[arity])
- self.slicer = gr.constellation_decoder_cb(rotated_const, range(arity))
-
- if self._gray_code:
- self.symbol_mapper = gr.map_bb(psk.gray_to_binary[arity])
- else:
- self.symbol_mapper = gr.map_bb(psk.ungray_to_binary[arity])
-
- # unpack the k bit vector into a stream of bits
- self.unpack = gr.unpack_k_bits_bb(self.bits_per_symbol())
-
- if verbose:
- self._print_verbage()
-
- if log:
- self._setup_logging()
-
- # Connect and Initialize base class
- self.connect(self, self.agc, self.rrc_filter, self.receiver,
- self.diffdec, self.slicer, self.symbol_mapper, self.unpack, self)
-
- def samples_per_symbol(self):
- return self._samples_per_symbol
-
- def bits_per_symbol(self=None): # staticmethod that's also callable on an instance
- return 1
- bits_per_symbol = staticmethod(bits_per_symbol) # make it a static method. RTFM
-
- def _print_verbage(self):
- print "\nDemodulator:"
- print "bits per symbol: %d" % self.bits_per_symbol()
- print "Gray code: %s" % self._gray_code
- print "RRC roll-off factor: %.2f" % self._excess_bw
- print "Costas Loop alpha: %.2e" % self._costas_alpha
- print "Costas Loop beta: %.2e" % self._costas_beta
- print "M&M mu: %.2f" % self._mm_mu
- print "M&M mu gain: %.2e" % self._mm_gain_mu
- print "M&M omega: %.2f" % self._mm_omega
- print "M&M omega gain: %.2e" % self._mm_gain_omega
- print "M&M omega limit: %.2f" % self._mm_omega_relative_limit
-
- def _setup_logging(self):
- print "Modulation logging turned on."
- self.connect(self.pre_scaler,
- gr.file_sink(gr.sizeof_gr_complex, "rx_prescaler.dat"))
- self.connect(self.agc,
- gr.file_sink(gr.sizeof_gr_complex, "rx_agc.dat"))
- self.connect(self.rrc_filter,
- gr.file_sink(gr.sizeof_gr_complex, "rx_rrc_filter.dat"))
- self.connect(self.receiver,
- gr.file_sink(gr.sizeof_gr_complex, "rx_receiver.dat"))
- self.connect(self.diffdec,
- gr.file_sink(gr.sizeof_gr_complex, "rx_diffdec.dat"))
- self.connect(self.slicer,
- gr.file_sink(gr.sizeof_char, "rx_slicer.dat"))
- self.connect(self.symbol_mapper,
- gr.file_sink(gr.sizeof_char, "rx_symbol_mapper.dat"))
- self.connect(self.unpack,
- gr.file_sink(gr.sizeof_char, "rx_unpack.dat"))
-
- def add_options(parser):
- """
- Adds DBPSK demodulation-specific options to the standard parser
- """
- parser.add_option("", "--excess-bw", type="float", default=_def_excess_bw,
- help="set RRC excess bandwith factor [default=%default] (PSK)")
- parser.add_option("", "--no-gray-code", dest="gray_code",
- action="store_false", default=_def_gray_code,
- help="disable gray coding on modulated bits (PSK)")
- parser.add_option("", "--costas-alpha", type="float", default=None,
- help="set Costas loop alpha value [default=%default] (PSK)")
- parser.add_option("", "--gain-mu", type="float", default=_def_gain_mu,
- help="set M&M symbol sync loop gain mu value [default=%default] (GMSK/PSK)")
- parser.add_option("", "--mu", type="float", default=_def_mu,
- help="set M&M symbol sync loop mu value [default=%default] (GMSK/PSK)")
- parser.add_option("", "--omega-relative-limit", type="float", default=_def_omega_relative_limit,
- help="M&M clock recovery omega relative limit [default=%default] (GMSK/PSK)")
- add_options=staticmethod(add_options)
-
- def extract_kwargs_from_options(options):
- """
- Given command line options, create dictionary suitable for passing to __init__
- """
- return modulation_utils.extract_kwargs_from_options(
- dbpsk_demod.__init__, ('self',), options)
- extract_kwargs_from_options=staticmethod(extract_kwargs_from_options)
-#
-# Add these to the mod/demod registry
-#
-modulation_utils.add_type_1_mod('dbpsk', dbpsk_mod)
-modulation_utils.add_type_1_demod('dbpsk', dbpsk_demod)
diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/dbpsk2.py b/gnuradio-core/src/python/gnuradio/blks2impl/dbpsk2.py
deleted file mode 100644
index d7bcf53907..0000000000
--- a/gnuradio-core/src/python/gnuradio/blks2impl/dbpsk2.py
+++ /dev/null
@@ -1,369 +0,0 @@
-#
-# Copyright 2009,2010 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.
-#
-
-# See gnuradio-examples/python/digital for examples
-
-"""
-differential BPSK modulation and demodulation.
-"""
-
-from gnuradio import gr, gru, modulation_utils2
-from math import pi, sqrt, ceil
-import psk
-import cmath
-from pprint import pprint
-
-# default values (used in __init__ and add_options)
-_def_samples_per_symbol = 2
-_def_excess_bw = 0.35
-_def_gray_code = True
-_def_verbose = False
-_def_log = False
-
-_def_freq_alpha = 0.010
-_def_phase_alpha = 0.1
-_def_timing_alpha = 0.100
-_def_timing_beta = 0.010
-_def_timing_max_dev = 1.5
-
-
-# /////////////////////////////////////////////////////////////////////////////
-# DBPSK modulator
-# /////////////////////////////////////////////////////////////////////////////
-
-class dbpsk2_mod(gr.hier_block2):
-
- def __init__(self,
- samples_per_symbol=_def_samples_per_symbol,
- excess_bw=_def_excess_bw,
- gray_code=_def_gray_code,
- verbose=_def_verbose,
- log=_def_log):
- """
- Hierarchical block for RRC-filtered differential BPSK modulation.
-
- The input is a byte stream (unsigned char) and the
- output is the complex modulated signal at baseband.
-
- @param samples_per_symbol: samples per baud >= 2
- @type samples_per_symbol: integer
- @param excess_bw: Root-raised cosine filter excess bandwidth
- @type excess_bw: float
- @param gray_code: Tell modulator to Gray code the bits
- @type gray_code: bool
- @param verbose: Print information about modulator?
- @type verbose: bool
- @param log: Log modulation data to files?
- @type log: bool
- """
-
- gr.hier_block2.__init__(self, "dbpsk_mod",
- gr.io_signature(1, 1, gr.sizeof_char), # Input signature
- gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature
-
- self._samples_per_symbol = samples_per_symbol
- self._excess_bw = excess_bw
- self._gray_code = gray_code
-
- if self._samples_per_symbol < 2:
- raise TypeError, ("sbp must be an integer >= 2, is %d" % self._samples_per_symbol)
-
- arity = pow(2,self.bits_per_symbol())
-
- # turn bytes into k-bit vectors
- self.bytes2chunks = \
- gr.packed_to_unpacked_bb(self.bits_per_symbol(), gr.GR_MSB_FIRST)
-
- if self._gray_code:
- self.symbol_mapper = gr.map_bb(psk.binary_to_gray[arity])
- else:
- self.symbol_mapper = gr.map_bb(psk.binary_to_ungray[arity])
-
- self.diffenc = gr.diff_encoder_bb(arity)
-
- self.chunks2symbols = gr.chunks_to_symbols_bc(psk.constellation[arity])
-
- # pulse shaping filter
- 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.pfb_arb_resampler_ccf(self._samples_per_symbol, self.rrc_taps)
-
- # Connect
- self.connect(self, self.bytes2chunks, self.symbol_mapper, self.diffenc,
- self.chunks2symbols, self.rrc_filter, self)
-
- if verbose:
- self._print_verbage()
-
- if log:
- self._setup_logging()
-
-
- def samples_per_symbol(self):
- return self._samples_per_symbol
-
- def bits_per_symbol(self=None): # static method that's also callable on an instance
- return 1
- bits_per_symbol = staticmethod(bits_per_symbol) # make it a static method. RTFM
-
- def add_options(parser):
- """
- Adds DBPSK modulation-specific options to the standard parser
- """
- parser.add_option("", "--excess-bw", type="float", default=_def_excess_bw,
- help="set RRC excess bandwith factor [default=%default]")
- parser.add_option("", "--no-gray-code", dest="gray_code",
- action="store_false", default=True,
- help="disable gray coding on modulated bits (PSK)")
- add_options=staticmethod(add_options)
-
- def extract_kwargs_from_options(options):
- """
- Given command line options, create dictionary suitable for passing to __init__
- """
- return modulation_utils2.extract_kwargs_from_options(dbpsk2_mod.__init__,
- ('self',), options)
- extract_kwargs_from_options=staticmethod(extract_kwargs_from_options)
-
-
- def _print_verbage(self):
- print "\nModulator:"
- print "bits per symbol: %d" % self.bits_per_symbol()
- print "Gray code: %s" % self._gray_code
- print "RRC roll-off factor: %.2f" % self._excess_bw
-
- def _setup_logging(self):
- print "Modulation logging turned on."
- self.connect(self.bytes2chunks,
- gr.file_sink(gr.sizeof_char, "tx_bytes2chunks.dat"))
- self.connect(self.symbol_mapper,
- gr.file_sink(gr.sizeof_char, "tx_graycoder.dat"))
- self.connect(self.diffenc,
- gr.file_sink(gr.sizeof_char, "tx_diffenc.dat"))
- self.connect(self.chunks2symbols,
- gr.file_sink(gr.sizeof_gr_complex, "tx_chunks2symbols.dat"))
- self.connect(self.rrc_filter,
- gr.file_sink(gr.sizeof_gr_complex, "tx_rrc_filter.dat"))
-
-
-# /////////////////////////////////////////////////////////////////////////////
-# DBPSK demodulator
-#
-# Differentially coherent detection of differentially encoded BPSK
-# /////////////////////////////////////////////////////////////////////////////
-
-class dbpsk2_demod(gr.hier_block2):
-
- def __init__(self,
- samples_per_symbol=_def_samples_per_symbol,
- excess_bw=_def_excess_bw,
- freq_alpha=_def_freq_alpha,
- phase_alpha=_def_phase_alpha,
- timing_alpha=_def_timing_alpha,
- timing_max_dev=_def_timing_max_dev,
- gray_code=_def_gray_code,
- verbose=_def_verbose,
- log=_def_log,
- sync_out=False):
- """
- Hierarchical block for RRC-filtered differential BPSK demodulation
-
- The input is the complex modulated signal at baseband.
- The output is a stream of bits packed 1 bit per byte (LSB)
-
- @param samples_per_symbol: samples per symbol >= 2
- @type samples_per_symbol: float
- @param excess_bw: Root-raised cosine filter excess bandwidth
- @type excess_bw: float
- @param freq_alpha: loop filter gain for frequency recovery
- @type freq_alpha: float
- @param phase_alpha: loop filter gain for phase/fine frequency recovery
- @type phase_alpha: float
- @param timing_alpha: loop alpha gain for timing recovery
- @type timing_alpha: float
- @param timing_max: timing loop maximum rate deviations
- @type timing_max: float
- @param gray_code: Tell modulator to Gray code the bits
- @type gray_code: bool
- @param verbose: Print information about modulator?
- @type verbose: bool
- @param log: Print modualtion data to files?
- @type log: bool
- @param sync_out: Output a sync signal on :1?
- @type sync_out: bool
- """
- if sync_out: io_sig_out = gr.io_signaturev(2, 2, (gr.sizeof_char, gr.sizeof_gr_complex))
- else: io_sig_out = gr.io_signature(1, 1, gr.sizeof_char)
-
- gr.hier_block2.__init__(self, "dqpsk2_demod",
- gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature
- io_sig_out) # Output signature
-
- self._samples_per_symbol = samples_per_symbol
- self._excess_bw = excess_bw
- self._freq_alpha = freq_alpha
- self._freq_beta = 0.10*self._freq_alpha
- self._phase_alpha = phase_alpha
- self._timing_alpha = timing_alpha
- self._timing_beta = _def_timing_beta
- self._timing_max_dev=timing_max_dev
- self._gray_code = gray_code
-
- if samples_per_symbol < 2:
- raise TypeError, "samples_per_symbol must be >= 2, is %r" % (samples_per_symbol,)
-
- arity = pow(2,self.bits_per_symbol())
-
- # Automatic gain control
- self.agc = gr.agc2_cc(0.6e-1, 1e-3, 1, 1, 100)
- #self.agc = gr.feedforward_agc_cc(16, 1.0)
-
- # Frequency correction
- self.freq_recov = gr.fll_band_edge_cc(self._samples_per_symbol, self._excess_bw,
- 11*int(self._samples_per_symbol),
- self._freq_alpha, self._freq_beta)
-
- # symbol timing recovery with RRC data filter
- nfilts = 32
- ntaps = 11 * int(self._samples_per_symbol*nfilts)
- taps = gr.firdes.root_raised_cosine(nfilts, nfilts,
- 1.0/float(self._samples_per_symbol),
- self._excess_bw, ntaps)
- self.time_recov = gr.pfb_clock_sync_ccf(self._samples_per_symbol,
- self._timing_alpha,
- taps, nfilts, nfilts/2, self._timing_max_dev)
- self.time_recov.set_beta(self._timing_beta)
-
- # Perform phase / fine frequency correction
- self._phase_beta = 0.25 * self._phase_alpha * self._phase_alpha
- # Allow a frequency swing of +/- half of the sample rate
- fmin = -0.5
- fmax = 0.5
-
- self.phase_recov = gr.costas_loop_cc(self._phase_alpha,
- self._phase_beta,
- fmax, fmin, arity)
-
- # Do differential decoding based on phase change of symbols
- self.diffdec = gr.diff_phasor_cc()
-
- # find closest constellation point
- rot = 1
- rotated_const = map(lambda pt: pt * rot, psk.constellation[arity])
- self.slicer = gr.constellation_decoder_cb(rotated_const, range(arity))
-
- if self._gray_code:
- self.symbol_mapper = gr.map_bb(psk.gray_to_binary[arity])
- else:
- self.symbol_mapper = gr.map_bb(psk.ungray_to_binary[arity])
-
- # unpack the k bit vector into a stream of bits
- self.unpack = gr.unpack_k_bits_bb(self.bits_per_symbol())
-
- if verbose:
- self._print_verbage()
-
- if log:
- self._setup_logging()
-
- # Connect
- self.connect(self, self.agc,
- self.freq_recov, self.time_recov, self.phase_recov,
- self.diffdec, self.slicer, self.symbol_mapper, self.unpack, self)
- if sync_out: self.connect(self.time_recov, (self, 1))
-
- def samples_per_symbol(self):
- return self._samples_per_symbol
-
- def bits_per_symbol(self=None): # staticmethod that's also callable on an instance
- return 1
- bits_per_symbol = staticmethod(bits_per_symbol) # make it a static method. RTFM
-
- def _print_verbage(self):
- print "\nDemodulator:"
- print "bits per symbol: %d" % self.bits_per_symbol()
- print "Gray code: %s" % self._gray_code
- print "RRC roll-off factor: %.2f" % self._excess_bw
- print "FLL gain: %.2e" % self._freq_alpha
- 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
-
- def _setup_logging(self):
- print "Modulation logging turned on."
- self.connect(self.agc,
- gr.file_sink(gr.sizeof_gr_complex, "rx_agc.dat"))
- self.connect(self.freq_recov,
- gr.file_sink(gr.sizeof_gr_complex, "rx_freq_recov.dat"))
- self.connect(self.time_recov,
- gr.file_sink(gr.sizeof_gr_complex, "rx_time_recov.dat"))
- self.connect(self.phase_recov,
- gr.file_sink(gr.sizeof_gr_complex, "rx_phase_recov.dat"))
- self.connect(self.diffdec,
- gr.file_sink(gr.sizeof_gr_complex, "rx_diffdec.dat"))
- self.connect(self.slicer,
- gr.file_sink(gr.sizeof_char, "rx_slicer.dat"))
- self.connect(self.symbol_mapper,
- gr.file_sink(gr.sizeof_char, "rx_symbol_mapper.dat"))
- self.connect(self.unpack,
- gr.file_sink(gr.sizeof_char, "rx_unpack.dat"))
-
- def add_options(parser):
- """
- Adds DBPSK demodulation-specific options to the standard parser
- """
- parser.add_option("", "--excess-bw", type="float", default=_def_excess_bw,
- help="set RRC excess bandwith factor [default=%default] (PSK)")
- parser.add_option("", "--no-gray-code", dest="gray_code",
- action="store_false", default=_def_gray_code,
- 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("", "--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,
- help="set timing symbol sync loop gain beta value [default=%default] (GMSK/PSK)")
- parser.add_option("", "--timing-max-dev", type="float", default=_def_timing_max_dev,
- help="set timing symbol sync loop maximum deviation [default=%default] (GMSK/PSK)")
- add_options=staticmethod(add_options)
-
- def extract_kwargs_from_options(options):
- """
- Given command line options, create dictionary suitable for passing to __init__
- """
- return modulation_utils2.extract_kwargs_from_options(
- dbpsk2_demod.__init__, ('self',), options)
- extract_kwargs_from_options=staticmethod(extract_kwargs_from_options)
-#
-# Add these to the mod/demod registry
-#
-modulation_utils2.add_type_1_mod('dbpsk2', dbpsk2_mod)
-modulation_utils2.add_type_1_demod('dbpsk2', dbpsk2_demod)
diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/dqpsk.py b/gnuradio-core/src/python/gnuradio/blks2impl/dqpsk.py
deleted file mode 100644
index 42d5341685..0000000000
--- a/gnuradio-core/src/python/gnuradio/blks2impl/dqpsk.py
+++ /dev/null
@@ -1,363 +0,0 @@
-#
-# Copyright 2005,2006,2007,2009 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.
-#
-
-# See gnuradio-examples/python/digital for examples
-
-"""
-differential QPSK modulation and demodulation.
-"""
-
-from gnuradio import gr, gru, modulation_utils
-from math import pi, sqrt
-import psk
-import cmath
-from pprint import pprint
-
-# default values (used in __init__ and add_options)
-_def_samples_per_symbol = 2
-_def_excess_bw = 0.35
-_def_gray_code = True
-_def_verbose = False
-_def_log = False
-
-_def_costas_alpha = 0.15
-_def_gain_mu = None
-_def_mu = 0.5
-_def_omega_relative_limit = 0.005
-
-
-# /////////////////////////////////////////////////////////////////////////////
-# DQPSK modulator
-# /////////////////////////////////////////////////////////////////////////////
-
-class dqpsk_mod(gr.hier_block2):
-
- def __init__(self,
- samples_per_symbol=_def_samples_per_symbol,
- excess_bw=_def_excess_bw,
- gray_code=_def_gray_code,
- verbose=_def_verbose,
- log=_def_log):
- """
- 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.
-
- @param samples_per_symbol: samples per symbol >= 2
- @type samples_per_symbol: integer
- @param excess_bw: Root-raised cosine filter excess bandwidth
- @type excess_bw: float
- @param gray_code: Tell modulator to Gray code the bits
- @type gray_code: bool
- @param verbose: Print information about modulator?
- @type verbose: bool
- @param debug: Print modualtion data to files?
- @type debug: bool
- """
-
- gr.hier_block2.__init__(self, "dqpsk_mod",
- gr.io_signature(1, 1, gr.sizeof_char), # Input signature
- gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature
-
- self._samples_per_symbol = samples_per_symbol
- 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)
-
- ntaps = 11 * samples_per_symbol
-
- arity = pow(2,self.bits_per_symbol())
-
- # turn bytes into k-bit vectors
- self.bytes2chunks = \
- gr.packed_to_unpacked_bb(self.bits_per_symbol(), gr.GR_MSB_FIRST)
-
- if self._gray_code:
- self.symbol_mapper = gr.map_bb(psk.binary_to_gray[arity])
- else:
- self.symbol_mapper = gr.map_bb(psk.binary_to_ungray[arity])
-
- self.diffenc = gr.diff_encoder_bb(arity)
-
- rot = .707 + .707j
- rotated_const = map(lambda pt: pt * rot, psk.constellation[arity])
- self.chunks2symbols = gr.chunks_to_symbols_bc(rotated_const)
-
- # pulse shaping filter
- self.rrc_taps = gr.firdes.root_raised_cosine(
- self._samples_per_symbol, # gain (sps since we're interpolating by sps)
- self._samples_per_symbol, # sampling rate
- 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_taps)
-
- if verbose:
- self._print_verbage()
-
- if log:
- self._setup_logging()
-
- # Connect & Initialize base class
- self.connect(self, self.bytes2chunks, self.symbol_mapper, self.diffenc,
- self.chunks2symbols, self.rrc_filter, self)
-
- def samples_per_symbol(self):
- return self._samples_per_symbol
-
- def bits_per_symbol(self=None): # staticmethod that's also callable on an instance
- return 2
- bits_per_symbol = staticmethod(bits_per_symbol) # make it a static method. RTFM
-
- def _print_verbage(self):
- print "\nModulator:"
- print "bits per symbol: %d" % self.bits_per_symbol()
- print "Gray code: %s" % self._gray_code
- print "RRS roll-off factor: %f" % self._excess_bw
-
- def _setup_logging(self):
- print "Modulation logging turned on."
- self.connect(self.bytes2chunks,
- gr.file_sink(gr.sizeof_char, "tx_bytes2chunks.dat"))
- self.connect(self.symbol_mapper,
- gr.file_sink(gr.sizeof_char, "tx_graycoder.dat"))
- self.connect(self.diffenc,
- gr.file_sink(gr.sizeof_char, "tx_diffenc.dat"))
- self.connect(self.chunks2symbols,
- gr.file_sink(gr.sizeof_gr_complex, "tx_chunks2symbols.dat"))
- self.connect(self.rrc_filter,
- gr.file_sink(gr.sizeof_gr_complex, "tx_rrc_filter.dat"))
-
- def add_options(parser):
- """
- Adds QPSK modulation-specific options to the standard parser
- """
- parser.add_option("", "--excess-bw", type="float", default=_def_excess_bw,
- help="set RRC excess bandwith factor [default=%default] (PSK)")
- parser.add_option("", "--no-gray-code", dest="gray_code",
- action="store_false", default=_def_gray_code,
- help="disable gray coding on modulated bits (PSK)")
- add_options=staticmethod(add_options)
-
-
- def extract_kwargs_from_options(options):
- """
- Given command line options, create dictionary suitable for passing to __init__
- """
- return modulation_utils.extract_kwargs_from_options(dqpsk_mod.__init__,
- ('self',), options)
- extract_kwargs_from_options=staticmethod(extract_kwargs_from_options)
-
-
-# /////////////////////////////////////////////////////////////////////////////
-# DQPSK demodulator
-#
-# Differentially coherent detection of differentially encoded qpsk
-# /////////////////////////////////////////////////////////////////////////////
-
-class dqpsk_demod(gr.hier_block2):
-
- def __init__(self,
- samples_per_symbol=_def_samples_per_symbol,
- excess_bw=_def_excess_bw,
- costas_alpha=_def_costas_alpha,
- gain_mu=_def_gain_mu,
- mu=_def_mu,
- omega_relative_limit=_def_omega_relative_limit,
- gray_code=_def_gray_code,
- verbose=_def_verbose,
- log=_def_log):
- """
- Hierarchical block for RRC-filtered DQPSK demodulation
-
- The input is the complex modulated signal at baseband.
- The output is a stream of bits packed 1 bit per byte (LSB)
-
- @param samples_per_symbol: samples per symbol >= 2
- @type samples_per_symbol: float
- @param excess_bw: Root-raised cosine filter excess bandwidth
- @type excess_bw: float
- @param costas_alpha: loop filter gain
- @type costas_alphas: float
- @param gain_mu: for M&M block
- @type gain_mu: float
- @param mu: for M&M block
- @type mu: float
- @param omega_relative_limit: for M&M block
- @type omega_relative_limit: float
- @param gray_code: Tell modulator to Gray code the bits
- @type gray_code: bool
- @param verbose: Print information about modulator?
- @type verbose: bool
- @param debug: Print modualtion data to files?
- @type debug: bool
- """
-
- gr.hier_block2.__init__(self, "dqpsk_demod",
- gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature
- gr.io_signature(1, 1, gr.sizeof_char)) # Output signature
-
- self._samples_per_symbol = samples_per_symbol
- self._excess_bw = excess_bw
- self._costas_alpha = costas_alpha
- self._mm_gain_mu = gain_mu
- self._mm_mu = mu
- self._mm_omega_relative_limit = omega_relative_limit
- self._gray_code = gray_code
-
- if samples_per_symbol < 2:
- raise TypeError, "sbp must be >= 2, is %d" % samples_per_symbol
-
- arity = pow(2,self.bits_per_symbol())
-
- # Automatic gain control
- scale = (1.0/16384.0)
- self.pre_scaler = gr.multiply_const_cc(scale) # scale the signal from full-range to +-1
- #self.agc = gr.agc2_cc(0.6e-1, 1e-3, 1, 1, 100)
- self.agc = gr.feedforward_agc_cc(16, 2.0)
-
- # RRC data filter
- ntaps = 11 * samples_per_symbol
- self.rrc_taps = gr.firdes.root_raised_cosine(
- 1.0, # gain
- self._samples_per_symbol, # sampling rate
- 1.0, # symbol rate
- self._excess_bw, # excess bandwidth (roll-off factor)
- ntaps)
- self.rrc_filter=gr.interp_fir_filter_ccf(1, self.rrc_taps)
-
- if not self._mm_gain_mu:
- sbs_to_mm = {2: 0.050, 3: 0.075, 4: 0.11, 5: 0.125, 6: 0.15, 7: 0.15}
- self._mm_gain_mu = sbs_to_mm[samples_per_symbol]
-
- self._mm_omega = self._samples_per_symbol
- self._mm_gain_omega = .25 * self._mm_gain_mu * self._mm_gain_mu
- self._costas_beta = 0.25 * self._costas_alpha * self._costas_alpha
- fmin = -0.25
- fmax = 0.25
-
- self.receiver=gr.mpsk_receiver_cc(arity, pi/4.0,
- self._costas_alpha, self._costas_beta,
- fmin, fmax,
- self._mm_mu, self._mm_gain_mu,
- self._mm_omega, self._mm_gain_omega,
- self._mm_omega_relative_limit)
-
- # Perform Differential decoding on the constellation
- self.diffdec = gr.diff_phasor_cc()
-
- # find closest constellation point
- rot = 1
- rotated_const = map(lambda pt: pt * rot, psk.constellation[arity])
- self.slicer = gr.constellation_decoder_cb(rotated_const, range(arity))
-
- if self._gray_code:
- self.symbol_mapper = gr.map_bb(psk.gray_to_binary[arity])
- else:
- self.symbol_mapper = gr.map_bb(psk.ungray_to_binary[arity])
-
- # unpack the k bit vector into a stream of bits
- self.unpack = gr.unpack_k_bits_bb(self.bits_per_symbol())
-
- if verbose:
- self._print_verbage()
-
- if log:
- self._setup_logging()
-
- # Connect & Initialize base class
- self.connect(self, self.pre_scaler, self.agc, self.rrc_filter, self.receiver,
- self.diffdec, self.slicer, self.symbol_mapper, self.unpack, self)
-
- def samples_per_symbol(self):
- return self._samples_per_symbol
-
- def bits_per_symbol(self=None): # staticmethod that's also callable on an instance
- return 2
- bits_per_symbol = staticmethod(bits_per_symbol) # make it a static method. RTFM
-
- def _print_verbage(self):
- print "\nDemodulator:"
- print "bits per symbol: %d" % self.bits_per_symbol()
- print "Gray code: %s" % self._gray_code
- print "RRC roll-off factor: %.2f" % self._excess_bw
- print "Costas Loop alpha: %.2e" % self._costas_alpha
- print "Costas Loop beta: %.2e" % self._costas_beta
- print "M&M mu: %.2f" % self._mm_mu
- print "M&M mu gain: %.2e" % self._mm_gain_mu
- print "M&M omega: %.2f" % self._mm_omega
- print "M&M omega gain: %.2e" % self._mm_gain_omega
- print "M&M omega limit: %.2f" % self._mm_omega_relative_limit
-
- def _setup_logging(self):
- print "Modulation logging turned on."
- self.connect(self.pre_scaler,
- gr.file_sink(gr.sizeof_gr_complex, "rx_prescaler.dat"))
- self.connect(self.agc,
- gr.file_sink(gr.sizeof_gr_complex, "rx_agc.dat"))
- self.connect(self.rrc_filter,
- gr.file_sink(gr.sizeof_gr_complex, "rx_rrc_filter.dat"))
- self.connect(self.receiver,
- gr.file_sink(gr.sizeof_gr_complex, "rx_receiver.dat"))
- self.connect(self.diffdec,
- gr.file_sink(gr.sizeof_gr_complex, "rx_diffdec.dat"))
- self.connect(self.slicer,
- gr.file_sink(gr.sizeof_char, "rx_slicer.dat"))
- self.connect(self.symbol_mapper,
- gr.file_sink(gr.sizeof_char, "rx_gray_decoder.dat"))
- self.connect(self.unpack,
- gr.file_sink(gr.sizeof_char, "rx_unpack.dat"))
-
- def add_options(parser):
- """
- Adds modulation-specific options to the standard parser
- """
- parser.add_option("", "--excess-bw", type="float", default=_def_excess_bw,
- help="set RRC excess bandwith factor [default=%default] (PSK)")
- parser.add_option("", "--no-gray-code", dest="gray_code",
- action="store_false", default=_def_gray_code,
- help="disable gray coding on modulated bits (PSK)")
- parser.add_option("", "--costas-alpha", type="float", default=_def_costas_alpha,
- help="set Costas loop alpha value [default=%default] (PSK)")
- parser.add_option("", "--gain-mu", type="float", default=_def_gain_mu,
- help="set M&M symbol sync loop gain mu value [default=%default] (PSK)")
- parser.add_option("", "--mu", type="float", default=_def_mu,
- help="set M&M symbol sync loop mu value [default=%default] (PSK)")
- add_options=staticmethod(add_options)
-
- def extract_kwargs_from_options(options):
- """
- Given command line options, create dictionary suitable for passing to __init__
- """
- return modulation_utils.extract_kwargs_from_options(
- dqpsk_demod.__init__, ('self',), options)
- extract_kwargs_from_options=staticmethod(extract_kwargs_from_options)
-
-
-#
-# Add these to the mod/demod registry
-#
-modulation_utils.add_type_1_mod('dqpsk', dqpsk_mod)
-modulation_utils.add_type_1_demod('dqpsk', dqpsk_demod)
diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/dqpsk2.py b/gnuradio-core/src/python/gnuradio/blks2impl/dqpsk2.py
deleted file mode 100644
index e1e627707b..0000000000
--- a/gnuradio-core/src/python/gnuradio/blks2impl/dqpsk2.py
+++ /dev/null
@@ -1,377 +0,0 @@
-#
-# Copyright 2009,2010 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.
-#
-
-# See gnuradio-examples/python/digital for examples
-
-"""
-differential QPSK modulation and demodulation.
-"""
-
-from gnuradio import gr, gru, modulation_utils2
-from math import pi, sqrt
-import psk
-import cmath
-from pprint import pprint
-
-# default values (used in __init__ and add_options)
-_def_samples_per_symbol = 2
-_def_excess_bw = 0.35
-_def_gray_code = True
-_def_verbose = False
-_def_log = False
-
-_def_freq_alpha = 0.010
-_def_phase_alpha = 0.01
-_def_timing_alpha = 0.100
-_def_timing_beta = 0.010
-_def_timing_max_dev = 1.5
-
-
-# /////////////////////////////////////////////////////////////////////////////
-# DQPSK modulator
-# /////////////////////////////////////////////////////////////////////////////
-
-class dqpsk2_mod(gr.hier_block2):
-
- def __init__(self,
- samples_per_symbol=_def_samples_per_symbol,
- excess_bw=_def_excess_bw,
- gray_code=_def_gray_code,
- verbose=_def_verbose,
- log=_def_log):
- """
- 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.
-
- @param samples_per_symbol: samples per symbol >= 2
- @type samples_per_symbol: integer
- @param excess_bw: Root-raised cosine filter excess bandwidth
- @type excess_bw: float
- @param gray_code: Tell modulator to Gray code the bits
- @type gray_code: bool
- @param verbose: Print information about modulator?
- @type verbose: bool
- @param debug: Print modualtion data to files?
- @type debug: bool
- """
-
- gr.hier_block2.__init__(self, "dqpsk2_mod",
- gr.io_signature(1, 1, gr.sizeof_char), # Input signature
- gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature
-
- self._samples_per_symbol = samples_per_symbol
- self._excess_bw = excess_bw
- self._gray_code = gray_code
-
- if samples_per_symbol < 2:
- raise TypeError, ("sbp must be >= 2, is %f" % samples_per_symbol)
-
- ntaps = 11 * samples_per_symbol
-
- arity = pow(2,self.bits_per_symbol())
-
- # turn bytes into k-bit vectors
- self.bytes2chunks = \
- gr.packed_to_unpacked_bb(self.bits_per_symbol(), gr.GR_MSB_FIRST)
-
- if self._gray_code:
- self.symbol_mapper = gr.map_bb(psk.binary_to_gray[arity])
- else:
- self.symbol_mapper = gr.map_bb(psk.binary_to_ungray[arity])
-
- self.diffenc = gr.diff_encoder_bb(arity)
-
- rot = .707 + .707j
- rotated_const = map(lambda pt: pt * rot, psk.constellation[arity])
- self.chunks2symbols = gr.chunks_to_symbols_bc(rotated_const)
-
- # pulse shaping filter
- nfilts = 32
- 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
- 1.0, # symbol rate
- self._excess_bw, # excess bandwidth (roll-off factor)
- ntaps)
- self.rrc_filter = gr.pfb_arb_resampler_ccf(self._samples_per_symbol, self.rrc_taps)
-
- if verbose:
- self._print_verbage()
-
- if log:
- self._setup_logging()
-
- # Connect & Initialize base class
- self.connect(self, self.bytes2chunks, self.symbol_mapper, self.diffenc,
- self.chunks2symbols, self.rrc_filter, self)
-
- def samples_per_symbol(self):
- return self._samples_per_symbol
-
- def bits_per_symbol(self=None): # staticmethod that's also callable on an instance
- return 2
- bits_per_symbol = staticmethod(bits_per_symbol) # make it a static method. RTFM
-
- def _print_verbage(self):
- print "\nModulator:"
- print "bits per symbol: %d" % self.bits_per_symbol()
- print "Gray code: %s" % self._gray_code
- print "RRS roll-off factor: %f" % self._excess_bw
-
- def _setup_logging(self):
- print "Modulation logging turned on."
- self.connect(self.bytes2chunks,
- gr.file_sink(gr.sizeof_char, "tx_bytes2chunks.dat"))
- self.connect(self.symbol_mapper,
- gr.file_sink(gr.sizeof_char, "tx_graycoder.dat"))
- self.connect(self.diffenc,
- gr.file_sink(gr.sizeof_char, "tx_diffenc.dat"))
- self.connect(self.chunks2symbols,
- gr.file_sink(gr.sizeof_gr_complex, "tx_chunks2symbols.dat"))
- self.connect(self.rrc_filter,
- gr.file_sink(gr.sizeof_gr_complex, "tx_rrc_filter.dat"))
-
- def add_options(parser):
- """
- Adds QPSK modulation-specific options to the standard parser
- """
- parser.add_option("", "--excess-bw", type="float", default=_def_excess_bw,
- help="set RRC excess bandwith factor [default=%default] (PSK)")
- parser.add_option("", "--no-gray-code", dest="gray_code",
- action="store_false", default=_def_gray_code,
- help="disable gray coding on modulated bits (PSK)")
- add_options=staticmethod(add_options)
-
-
- def extract_kwargs_from_options(options):
- """
- Given command line options, create dictionary suitable for passing to __init__
- """
- return modulation_utils2.extract_kwargs_from_options(dqpsk2_mod.__init__,
- ('self',), options)
- extract_kwargs_from_options=staticmethod(extract_kwargs_from_options)
-
-
-# /////////////////////////////////////////////////////////////////////////////
-# DQPSK demodulator
-#
-# Differentially coherent detection of differentially encoded qpsk
-# /////////////////////////////////////////////////////////////////////////////
-
-class dqpsk2_demod(gr.hier_block2):
-
- def __init__(self,
- samples_per_symbol=_def_samples_per_symbol,
- excess_bw=_def_excess_bw,
- freq_alpha=_def_freq_alpha,
- phase_alpha=_def_phase_alpha,
- timing_alpha=_def_timing_alpha,
- timing_max_dev=_def_timing_max_dev,
- gray_code=_def_gray_code,
- verbose=_def_verbose,
- log=_def_log,
- sync_out=False):
- """
- Hierarchical block for RRC-filtered DQPSK demodulation
-
- The input is the complex modulated signal at baseband.
- The output is a stream of bits packed 1 bit per byte (LSB)
-
- @param samples_per_symbol: samples per symbol >= 2
- @type samples_per_symbol: float
- @param excess_bw: Root-raised cosine filter excess bandwidth
- @type excess_bw: float
- @param freq_alpha: loop filter gain for frequency recovery
- @type freq_alpha: float
- @param phase_alpha: loop filter gain
- @type phase_alphas: float
- @param timing_alpha: timing loop alpha gain
- @type timing_alpha: float
- @param timing_max: timing loop maximum rate deviations
- @type timing_max: float
- @param gray_code: Tell modulator to Gray code the bits
- @type gray_code: bool
- @param verbose: Print information about modulator?
- @type verbose: bool
- @param log: Print modualtion data to files?
- @type log: bool
- @param sync_out: Output a sync signal on :1?
- @type sync_out: bool
- """
- if sync_out: io_sig_out = gr.io_signaturev(2, 2, (gr.sizeof_char, gr.sizeof_gr_complex))
- else: io_sig_out = gr.io_signature(1, 1, gr.sizeof_char)
-
- gr.hier_block2.__init__(self, "dqpsk2_demod",
- gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature
- io_sig_out) # Output signature
-
- self._samples_per_symbol = samples_per_symbol
- self._excess_bw = excess_bw
- self._freq_alpha = freq_alpha
- self._freq_beta = 0.25*self._freq_alpha**2
- self._phase_alpha = phase_alpha
- self._timing_alpha = timing_alpha
- self._timing_beta = _def_timing_beta
- self._timing_max_dev=timing_max_dev
- self._gray_code = gray_code
-
- if samples_per_symbol < 2:
- raise TypeError, "sbp must be >= 2, is %d" % samples_per_symbol
-
- arity = pow(2,self.bits_per_symbol())
-
- # Automatic gain control
- self.agc = gr.agc2_cc(0.6e-1, 1e-3, 1, 1, 100)
- #self.agc = gr.feedforward_agc_cc(16, 2.0)
-
- # Frequency correction
- self.freq_recov = gr.fll_band_edge_cc(self._samples_per_symbol, self._excess_bw,
- 11*int(self._samples_per_symbol),
- self._freq_alpha, self._freq_beta)
-
-
- # symbol timing recovery with RRC data filter
- nfilts = 32
- ntaps = 11 * int(samples_per_symbol*nfilts)
- taps = gr.firdes.root_raised_cosine(nfilts, nfilts,
- 1.0/float(self._samples_per_symbol),
- self._excess_bw, ntaps)
- self.time_recov = gr.pfb_clock_sync_ccf(self._samples_per_symbol,
- self._timing_alpha,
- taps, nfilts, nfilts/2, self._timing_max_dev)
- self.time_recov.set_beta(self._timing_beta)
-
-
- # Perform phase / fine frequency correction
- self._phase_beta = 0.25 * self._phase_alpha * self._phase_alpha
- # Allow a frequency swing of +/- half of the sample rate
- fmin = -0.5
- fmax = 0.5
-
- self.phase_recov = gr.costas_loop_cc(self._phase_alpha,
- self._phase_beta,
- fmax, fmin, arity)
-
-
- # Perform Differential decoding on the constellation
- self.diffdec = gr.diff_phasor_cc()
-
- # find closest constellation point
- rot = 1
- rotated_const = map(lambda pt: pt * rot, psk.constellation[arity])
- self.slicer = gr.constellation_decoder_cb(rotated_const, range(arity))
-
- if self._gray_code:
- self.symbol_mapper = gr.map_bb(psk.gray_to_binary[arity])
- else:
- self.symbol_mapper = gr.map_bb(psk.ungray_to_binary[arity])
-
- # unpack the k bit vector into a stream of bits
- self.unpack = gr.unpack_k_bits_bb(self.bits_per_symbol())
-
- if verbose:
- self._print_verbage()
-
- if log:
- self._setup_logging()
-
- # Connect
- self.connect(self, self.agc,
- self.freq_recov, self.time_recov, self.phase_recov,
- self.diffdec, self.slicer, self.symbol_mapper, self.unpack, self)
- if sync_out: self.connect(self.time_recov, (self, 1))
-
- def samples_per_symbol(self):
- return self._samples_per_symbol
-
- def bits_per_symbol(self=None): # staticmethod that's also callable on an instance
- return 2
- bits_per_symbol = staticmethod(bits_per_symbol) # make it a static method. RTFM
-
- def _print_verbage(self):
- print "\nDemodulator:"
- print "bits per symbol: %d" % self.bits_per_symbol()
- print "Gray code: %s" % self._gray_code
- print "RRC roll-off factor: %.2f" % self._excess_bw
- print "FLL gain: %.2f" % self._freq_alpha
- 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
-
- def _setup_logging(self):
- print "Modulation logging turned on."
- self.connect(self.agc,
- gr.file_sink(gr.sizeof_gr_complex, "rx_agc.dat"))
- self.connect(self.freq_recov,
- gr.file_sink(gr.sizeof_gr_complex, "rx_freq_recov.dat"))
- self.connect(self.time_recov,
- gr.file_sink(gr.sizeof_gr_complex, "rx_time_recov.dat"))
- self.connect(self.phase_recov,
- gr.file_sink(gr.sizeof_gr_complex, "rx_phase_recov.dat"))
- self.connect(self.diffdec,
- gr.file_sink(gr.sizeof_gr_complex, "rx_diffdec.dat"))
- self.connect(self.slicer,
- gr.file_sink(gr.sizeof_char, "rx_slicer.dat"))
- self.connect(self.symbol_mapper,
- gr.file_sink(gr.sizeof_char, "rx_gray_decoder.dat"))
- self.connect(self.unpack,
- gr.file_sink(gr.sizeof_char, "rx_unpack.dat"))
-
- def add_options(parser):
- """
- Adds DQPSK demodulation-specific options to the standard parser
- """
- parser.add_option("", "--excess-bw", type="float", default=_def_excess_bw,
- help="set RRC excess bandwith factor [default=%default] (PSK)")
- parser.add_option("", "--no-gray-code", dest="gray_code",
- action="store_false", default=_def_gray_code,
- 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("", "--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,
- help="set timing symbol sync loop gain beta value [default=%default] (GMSK/PSK)")
- parser.add_option("", "--timing-max-dev", type="float", default=_def_timing_max_dev,
- help="set timing symbol sync loop maximum deviation [default=%default] (GMSK/PSK)")
- add_options=staticmethod(add_options)
-
- def extract_kwargs_from_options(options):
- """
- Given command line options, create dictionary suitable for passing to __init__
- """
- return modulation_utils2.extract_kwargs_from_options(
- dqpsk2_demod.__init__, ('self',), options)
- extract_kwargs_from_options=staticmethod(extract_kwargs_from_options)
-
-
-#
-# Add these to the mod/demod registry
-#
-modulation_utils2.add_type_1_mod('dqpsk2', dqpsk2_mod)
-modulation_utils2.add_type_1_demod('dqpsk2', dqpsk2_demod)
diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/gmsk.py b/gnuradio-core/src/python/gnuradio/blks2impl/gmsk.py
deleted file mode 100644
index 3b6c016a0b..0000000000
--- a/gnuradio-core/src/python/gnuradio/blks2impl/gmsk.py
+++ /dev/null
@@ -1,292 +0,0 @@
-#
-# GMSK modulation and demodulation.
-#
-#
-# 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.
-#
-
-# See gnuradio-examples/python/digital for examples
-
-from gnuradio import gr
-from gnuradio import modulation_utils
-from math import pi
-import numpy
-from pprint import pprint
-import inspect
-
-# default values (used in __init__ and add_options)
-_def_samples_per_symbol = 2
-_def_bt = 0.35
-_def_verbose = False
-_def_log = False
-
-_def_gain_mu = None
-_def_mu = 0.5
-_def_freq_error = 0.0
-_def_omega_relative_limit = 0.005
-
-
-# /////////////////////////////////////////////////////////////////////////////
-# GMSK modulator
-# /////////////////////////////////////////////////////////////////////////////
-
-class gmsk_mod(gr.hier_block2):
-
- def __init__(self,
- samples_per_symbol=_def_samples_per_symbol,
- bt=_def_bt,
- verbose=_def_verbose,
- log=_def_log):
- """
- Hierarchical block for Gaussian Minimum Shift Key (GMSK)
- modulation.
-
- The input is a byte stream (unsigned char) and the
- output is the complex modulated signal at baseband.
-
- @param samples_per_symbol: samples per baud >= 2
- @type samples_per_symbol: integer
- @param bt: Gaussian filter bandwidth * symbol time
- @type bt: float
- @param verbose: Print information about modulator?
- @type verbose: bool
- @param debug: Print modualtion data to files?
- @type debug: bool
- """
-
- gr.hier_block2.__init__(self, "gmsk_mod",
- gr.io_signature(1, 1, gr.sizeof_char), # Input signature
- gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature
-
- self._samples_per_symbol = samples_per_symbol
- self._bt = bt
-
- if not isinstance(samples_per_symbol, int) or samples_per_symbol < 2:
- raise TypeError, ("samples_per_symbol must be an integer >= 2, is %r" % (samples_per_symbol,))
-
- ntaps = 4 * samples_per_symbol # up to 3 bits in filter at once
- sensitivity = (pi / 2) / samples_per_symbol # phase change per bit = pi / 2
-
- # Turn it into NRZ data.
- self.nrz = gr.bytes_to_syms()
-
- # Form Gaussian filter
- # Generate Gaussian response (Needs to be convolved with window below).
- self.gaussian_taps = gr.firdes.gaussian(
- 1, # gain
- samples_per_symbol, # symbol_rate
- bt, # bandwidth * symbol time
- ntaps # number of taps
- )
-
- self.sqwave = (1,) * samples_per_symbol # rectangular window
- self.taps = numpy.convolve(numpy.array(self.gaussian_taps),numpy.array(self.sqwave))
- self.gaussian_filter = gr.interp_fir_filter_fff(samples_per_symbol, self.taps)
-
- # FM modulation
- self.fmmod = gr.frequency_modulator_fc(sensitivity)
-
- if verbose:
- self._print_verbage()
-
- if log:
- self._setup_logging()
-
- # Connect & Initialize base class
- self.connect(self, self.nrz, self.gaussian_filter, self.fmmod, self)
-
- def samples_per_symbol(self):
- return self._samples_per_symbol
-
- def bits_per_symbol(self=None): # staticmethod that's also callable on an instance
- return 1
- bits_per_symbol = staticmethod(bits_per_symbol) # make it a static method.
-
-
- def _print_verbage(self):
- print "bits per symbol = %d" % self.bits_per_symbol()
- print "Gaussian filter bt = %.2f" % self._bt
-
-
- def _setup_logging(self):
- print "Modulation logging turned on."
- self.connect(self.nrz,
- gr.file_sink(gr.sizeof_float, "nrz.dat"))
- self.connect(self.gaussian_filter,
- gr.file_sink(gr.sizeof_float, "gaussian_filter.dat"))
- self.connect(self.fmmod,
- gr.file_sink(gr.sizeof_gr_complex, "fmmod.dat"))
-
-
- def add_options(parser):
- """
- Adds GMSK modulation-specific options to the standard parser
- """
- parser.add_option("", "--bt", type="float", default=_def_bt,
- help="set bandwidth-time product [default=%default] (GMSK)")
- add_options=staticmethod(add_options)
-
-
- def extract_kwargs_from_options(options):
- """
- Given command line options, create dictionary suitable for passing to __init__
- """
- return modulation_utils.extract_kwargs_from_options(gmsk_mod.__init__,
- ('self',), options)
- extract_kwargs_from_options=staticmethod(extract_kwargs_from_options)
-
-
-
-# /////////////////////////////////////////////////////////////////////////////
-# GMSK demodulator
-# /////////////////////////////////////////////////////////////////////////////
-
-class gmsk_demod(gr.hier_block2):
-
- def __init__(self,
- samples_per_symbol=_def_samples_per_symbol,
- gain_mu=_def_gain_mu,
- mu=_def_mu,
- omega_relative_limit=_def_omega_relative_limit,
- freq_error=_def_freq_error,
- verbose=_def_verbose,
- log=_def_log):
- """
- Hierarchical block for Gaussian Minimum Shift Key (GMSK)
- demodulation.
-
- The input is the complex modulated signal at baseband.
- The output is a stream of bits packed 1 bit per byte (the LSB)
-
- @param samples_per_symbol: samples per baud
- @type samples_per_symbol: integer
- @param verbose: Print information about modulator?
- @type verbose: bool
- @param log: Print modualtion data to files?
- @type log: bool
-
- Clock recovery parameters. These all have reasonble defaults.
-
- @param gain_mu: controls rate of mu adjustment
- @type gain_mu: float
- @param mu: fractional delay [0.0, 1.0]
- @type mu: float
- @param omega_relative_limit: sets max variation in omega
- @type omega_relative_limit: float, typically 0.000200 (200 ppm)
- @param freq_error: bit rate error as a fraction
- @param float
- """
-
- gr.hier_block2.__init__(self, "gmsk_demod",
- gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature
- gr.io_signature(1, 1, gr.sizeof_char)) # Output signature
-
- self._samples_per_symbol = samples_per_symbol
- self._gain_mu = gain_mu
- self._mu = mu
- self._omega_relative_limit = omega_relative_limit
- self._freq_error = freq_error
-
- if samples_per_symbol < 2:
- raise TypeError, "samples_per_symbol >= 2, is %f" % samples_per_symbol
-
- self._omega = samples_per_symbol*(1+self._freq_error)
-
- if not self._gain_mu:
- self._gain_mu = 0.175
-
- self._gain_omega = .25 * self._gain_mu * self._gain_mu # critically damped
-
- # Demodulate FM
- sensitivity = (pi / 2) / samples_per_symbol
- self.fmdemod = gr.quadrature_demod_cf(1.0 / sensitivity)
-
- # the clock recovery block tracks the symbol clock and resamples as needed.
- # the output of the block is a stream of soft symbols (float)
- self.clock_recovery = gr.clock_recovery_mm_ff(self._omega, self._gain_omega,
- self._mu, self._gain_mu,
- self._omega_relative_limit)
-
- # slice the floats at 0, outputting 1 bit (the LSB of the output byte) per sample
- self.slicer = gr.binary_slicer_fb()
-
- if verbose:
- self._print_verbage()
-
- if log:
- self._setup_logging()
-
- # Connect & Initialize base class
- self.connect(self, self.fmdemod, self.clock_recovery, self.slicer, self)
-
- def samples_per_symbol(self):
- return self._samples_per_symbol
-
- def bits_per_symbol(self=None): # staticmethod that's also callable on an instance
- return 1
- bits_per_symbol = staticmethod(bits_per_symbol) # make it a static method.
-
-
- def _print_verbage(self):
- print "bits per symbol = %d" % self.bits_per_symbol()
- print "M&M clock recovery omega = %f" % self._omega
- print "M&M clock recovery gain mu = %f" % self._gain_mu
- print "M&M clock recovery mu = %f" % self._mu
- print "M&M clock recovery omega rel. limit = %f" % self._omega_relative_limit
- print "frequency error = %f" % self._freq_error
-
-
- def _setup_logging(self):
- print "Demodulation logging turned on."
- self.connect(self.fmdemod,
- gr.file_sink(gr.sizeof_float, "fmdemod.dat"))
- self.connect(self.clock_recovery,
- gr.file_sink(gr.sizeof_float, "clock_recovery.dat"))
- self.connect(self.slicer,
- gr.file_sink(gr.sizeof_char, "slicer.dat"))
-
- def add_options(parser):
- """
- Adds GMSK demodulation-specific options to the standard parser
- """
- parser.add_option("", "--gain-mu", type="float", default=_def_gain_mu,
- help="M&M clock recovery gain mu [default=%default] (GMSK/PSK)")
- parser.add_option("", "--mu", type="float", default=_def_mu,
- help="M&M clock recovery mu [default=%default] (GMSK/PSK)")
- parser.add_option("", "--omega-relative-limit", type="float", default=_def_omega_relative_limit,
- help="M&M clock recovery omega relative limit [default=%default] (GMSK/PSK)")
- parser.add_option("", "--freq-error", type="float", default=_def_freq_error,
- help="M&M clock recovery frequency error [default=%default] (GMSK)")
- add_options=staticmethod(add_options)
-
- def extract_kwargs_from_options(options):
- """
- Given command line options, create dictionary suitable for passing to __init__
- """
- return modulation_utils.extract_kwargs_from_options(gmsk_demod.__init__,
- ('self',), options)
- extract_kwargs_from_options=staticmethod(extract_kwargs_from_options)
-
-
-#
-# Add these to the mod/demod registry
-#
-modulation_utils.add_type_1_mod('gmsk', gmsk_mod)
-modulation_utils.add_type_1_demod('gmsk', gmsk_demod)
diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/pkt.py b/gnuradio-core/src/python/gnuradio/blks2impl/pkt.py
deleted file mode 100644
index 908437ef2b..0000000000
--- a/gnuradio-core/src/python/gnuradio/blks2impl/pkt.py
+++ /dev/null
@@ -1,164 +0,0 @@
-#
-# 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 math import pi
-from gnuradio import gr, packet_utils
-import gnuradio.gr.gr_threading as _threading
-
-
-# /////////////////////////////////////////////////////////////////////////////
-# mod/demod with packets as i/o
-# /////////////////////////////////////////////////////////////////////////////
-
-class mod_pkts(gr.hier_block2):
- """
- Wrap an arbitrary digital modulator in our packet handling framework.
-
- Send packets by calling send_pkt
- """
- def __init__(self, modulator, access_code=None, msgq_limit=2, pad_for_usrp=True, use_whitener_offset=False):
- """
- Hierarchical block for sending packets
-
- Packets to be sent are enqueued by calling send_pkt.
- The output is the complex modulated signal at baseband.
-
- @param modulator: instance of modulator class (gr_block or hier_block2)
- @type modulator: complex baseband out
- @param access_code: AKA sync vector
- @type access_code: string of 1's and 0's between 1 and 64 long
- @param msgq_limit: maximum number of messages in message queue
- @type msgq_limit: int
- @param pad_for_usrp: If true, packets are padded such that they end up a multiple of 128 samples
- @param use_whitener_offset: If true, start of whitener XOR string is incremented each packet
-
- See gmsk_mod for remaining parameters
- """
-
- gr.hier_block2.__init__(self, "mod_pkts",
- gr.io_signature(0, 0, 0), # Input signature
- gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature
-
- self._modulator = modulator
- self._pad_for_usrp = pad_for_usrp
- self._use_whitener_offset = use_whitener_offset
- self._whitener_offset = 0
-
- if access_code is None:
- access_code = packet_utils.default_access_code
- if not packet_utils.is_1_0_string(access_code):
- raise ValueError, "Invalid access_code %r. Must be string of 1's and 0's" % (access_code,)
- self._access_code = access_code
-
- # accepts messages from the outside world
- self._pkt_input = gr.message_source(gr.sizeof_char, msgq_limit)
- self.connect(self._pkt_input, self._modulator, self)
-
- def send_pkt(self, payload='', eof=False):
- """
- Send the payload.
-
- @param payload: data to send
- @type payload: string
- """
- if eof:
- msg = gr.message(1) # tell self._pkt_input we're not sending any more packets
- else:
- # print "original_payload =", string_to_hex_list(payload)
- pkt = packet_utils.make_packet(payload,
- self._modulator.samples_per_symbol(),
- self._modulator.bits_per_symbol(),
- self._access_code,
- self._pad_for_usrp,
- self._whitener_offset)
- #print "pkt =", string_to_hex_list(pkt)
- msg = gr.message_from_string(pkt)
- if self._use_whitener_offset is True:
- self._whitener_offset = (self._whitener_offset + 1) % 16
-
- self._pkt_input.msgq().insert_tail(msg)
-
-
-
-class demod_pkts(gr.hier_block2):
- """
- Wrap an arbitrary digital demodulator in our packet handling framework.
-
- The input is complex baseband. When packets are demodulated, they are passed to the
- app via the callback.
- """
-
- def __init__(self, demodulator, access_code=None, callback=None, threshold=-1):
- """
- Hierarchical block for demodulating and deframing packets.
-
- The input is the complex modulated signal at baseband.
- Demodulated packets are sent to the handler.
-
- @param demodulator: instance of demodulator class (gr_block or hier_block2)
- @type demodulator: complex baseband in
- @param access_code: AKA sync vector
- @type access_code: string of 1's and 0's
- @param callback: function of two args: ok, payload
- @type callback: ok: bool; payload: string
- @param threshold: detect access_code with up to threshold bits wrong (-1 -> use default)
- @type threshold: int
- """
-
- gr.hier_block2.__init__(self, "demod_pkts",
- gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature
- gr.io_signature(0, 0, 0)) # Output signature
-
- self._demodulator = demodulator
- if access_code is None:
- access_code = packet_utils.default_access_code
- if not packet_utils.is_1_0_string(access_code):
- raise ValueError, "Invalid access_code %r. Must be string of 1's and 0's" % (access_code,)
- self._access_code = access_code
-
- if threshold == -1:
- 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.framer_sink = gr.framer_sink_1(self._rcvd_pktq)
- self.connect(self, self._demodulator, self.correlator, self.framer_sink)
-
- self._watcher = _queue_watcher_thread(self._rcvd_pktq, callback)
-
-
-class _queue_watcher_thread(_threading.Thread):
- def __init__(self, rcvd_pktq, callback):
- _threading.Thread.__init__(self)
- self.setDaemon(1)
- self.rcvd_pktq = rcvd_pktq
- self.callback = callback
- self.keep_running = True
- self.start()
-
-
- def run(self):
- while self.keep_running:
- msg = self.rcvd_pktq.delete_head()
- ok, payload = packet_utils.unmake_packet(msg.to_string(), int(msg.arg1()))
- if self.callback:
- self.callback(ok, payload)
diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/qam16.py b/gnuradio-core/src/python/gnuradio/blks2impl/qam16.py
deleted file mode 100644
index 0bdb9c6fb8..0000000000
--- a/gnuradio-core/src/python/gnuradio/blks2impl/qam16.py
+++ /dev/null
@@ -1,208 +0,0 @@
-#
-# 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.
-#
-
-# See gnuradio-examples/python/digital for examples
-
-"""
-QAM16 modulation and demodulation.
-"""
-
-from gnuradio import gr, gru, modulation_utils
-from math import pi, sqrt
-import qam
-import cmath
-from pprint import pprint
-
-# default values (used in __init__ and add_options)
-_def_samples_per_symbol = 2
-_def_excess_bw = 0.35
-_def_gray_code = True
-_def_verbose = False
-_def_log = False
-
-_def_costas_alpha = None
-_def_gain_mu = 0.03
-_def_mu = 0.05
-_def_omega_relative_limit = 0.005
-
-
-# /////////////////////////////////////////////////////////////////////////////
-# QAM16 modulator
-# /////////////////////////////////////////////////////////////////////////////
-
-class qam16_mod(gr.hier_block2):
-
- def __init__(self,
- samples_per_symbol=_def_samples_per_symbol,
- excess_bw=_def_excess_bw,
- gray_code=_def_gray_code,
- verbose=_def_verbose,
- log=_def_log):
-
- """
- 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.
-
- @param samples_per_symbol: samples per symbol >= 2
- @type samples_per_symbol: integer
- @param excess_bw: Root-raised cosine filter excess bandwidth
- @type excess_bw: float
- @param gray_code: Tell modulator to Gray code the bits
- @type gray_code: bool
- @param verbose: Print information about modulator?
- @type verbose: bool
- @param debug: Print modualtion data to files?
- @type debug: bool
- """
-
- gr.hier_block2.__init__(self, "qam16_mod",
- gr.io_signature(1, 1, gr.sizeof_char), # Input signature
- gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature
-
- self._samples_per_symbol = samples_per_symbol
- 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)
-
- ntaps = 11 * samples_per_symbol
-
- arity = pow(2, self.bits_per_symbol())
-
- # turn bytes into k-bit vectors
- self.bytes2chunks = \
- gr.packed_to_unpacked_bb(self.bits_per_symbol(), gr.GR_MSB_FIRST)
-
- if self._gray_code:
- self.symbol_mapper = gr.map_bb(qam.binary_to_gray[arity])
- else:
- self.symbol_mapper = gr.map_bb(qam.binary_to_ungray[arity])
-
- self.diffenc = gr.diff_encoder_bb(arity)
-
- rot = 1.0
- print "constellation with %d arity" % arity
- rotated_const = map(lambda pt: pt * rot, qam.constellation[arity])
- self.chunks2symbols = gr.chunks_to_symbols_bc(rotated_const)
-
- # pulse shaping filter
- self.rrc_taps = gr.firdes.root_raised_cosine(
- self._samples_per_symbol, # gain (sps since we're interpolating by sps)
- self._samples_per_symbol, # sampling rate
- 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_taps)
-
- if verbose:
- self._print_verbage()
-
- if log:
- self._setup_logging()
-
- # Connect
- self.connect(self, self.bytes2chunks, self.symbol_mapper, self.diffenc,
- self.chunks2symbols, self.rrc_filter, self)
-
- def samples_per_symbol(self):
- return self._samples_per_symbol
-
- def bits_per_symbol(self=None): # staticmethod that's also callable on an instance
- return 4
- bits_per_symbol = staticmethod(bits_per_symbol) # make it a static method. RTFM
-
- def _print_verbage(self):
- print "bits per symbol = %d" % self.bits_per_symbol()
- print "Gray code = %s" % self._gray_code
- print "RRS roll-off factor = %f" % self._excess_bw
-
- def _setup_logging(self):
- print "Modulation logging turned on."
- self.connect(self.bytes2chunks,
- gr.file_sink(gr.sizeof_char, "bytes2chunks.dat"))
- self.connect(self.symbol_mapper,
- gr.file_sink(gr.sizeof_char, "graycoder.dat"))
- self.connect(self.diffenc,
- gr.file_sink(gr.sizeof_char, "diffenc.dat"))
- self.connect(self.chunks2symbols,
- gr.file_sink(gr.sizeof_gr_complex, "chunks2symbols.dat"))
- self.connect(self.rrc_filter,
- gr.file_sink(gr.sizeof_gr_complex, "rrc_filter.dat"))
-
- def add_options(parser):
- """
- Adds QAM modulation-specific options to the standard parser
- """
- parser.add_option("", "--excess-bw", type="float", default=_def_excess_bw,
- help="set RRC excess bandwith factor [default=%default] (PSK)")
- parser.add_option("", "--no-gray-code", dest="gray_code",
- action="store_false", default=_def_gray_code,
- help="disable gray coding on modulated bits (PSK)")
- add_options=staticmethod(add_options)
-
-
- def extract_kwargs_from_options(options):
- """
- Given command line options, create dictionary suitable for passing to __init__
- """
- return modulation_utils.extract_kwargs_from_options(qam16_mod.__init__,
- ('self',), options)
- extract_kwargs_from_options=staticmethod(extract_kwargs_from_options)
-
-
-# /////////////////////////////////////////////////////////////////////////////
-# QAM16 demodulator
-#
-# /////////////////////////////////////////////////////////////////////////////
-
-class qam16_demod(gr.hier_block2):
-
- def __init__(self,
- samples_per_symbol=_def_samples_per_symbol,
- excess_bw=_def_excess_bw,
- costas_alpha=_def_costas_alpha,
- gain_mu=_def_gain_mu,
- mu=_def_mu,
- omega_relative_limit=_def_omega_relative_limit,
- gray_code=_def_gray_code,
- verbose=_def_verbose,
- log=_def_log):
-
- gr.hier_block2.__init__(self, "qam16_demod",
- gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature
- gr.io_signature(1, 1, gr.sizeof_char)) # Output signature
- # do this
- pass
-
- def bits_per_symbol(self=None): # staticmethod that's also callable on an instance
- return 4
- bits_per_symbol = staticmethod(bits_per_symbol) # make it a static method. RTFM
-
-#
-# Add these to the mod/demod registry
-#
-# NOT READY TO BE USED YET -- ENABLE AT YOUR OWN RISK
-#modulation_utils.add_type_1_mod('qam16', qam16_mod)
-#modulation_utils.add_type_1_demod('qam16', qam16_demod)
diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/qam256.py b/gnuradio-core/src/python/gnuradio/blks2impl/qam256.py
deleted file mode 100644
index fc455f17c1..0000000000
--- a/gnuradio-core/src/python/gnuradio/blks2impl/qam256.py
+++ /dev/null
@@ -1,209 +0,0 @@
-#
-# 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.
-#
-
-# See gnuradio-examples/python/digital for examples
-
-"""
-QAM256 modulation and demodulation.
-"""
-
-from gnuradio import gr, gru, modulation_utils
-from math import pi, sqrt
-import qam
-import cmath
-from pprint import pprint
-
-# default values (used in __init__ and add_options)
-_def_samples_per_symbol = 2
-_def_excess_bw = 0.35
-_def_gray_code = True
-_def_verbose = False
-_def_log = False
-
-_def_costas_alpha = None
-_def_gain_mu = 0.03
-_def_mu = 0.05
-_def_omega_relative_limit = 0.005
-
-
-# /////////////////////////////////////////////////////////////////////////////
-# QAM256 modulator
-# /////////////////////////////////////////////////////////////////////////////
-
-class qam256_mod(gr.hier_block2):
-
- def __init__(self,
- samples_per_symbol=_def_samples_per_symbol,
- excess_bw=_def_excess_bw,
- gray_code=_def_gray_code,
- verbose=_def_verbose,
- log=_def_log):
-
- """
- 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.
-
- @param samples_per_symbol: samples per symbol >= 2
- @type samples_per_symbol: integer
- @param excess_bw: Root-raised cosine filter excess bandwidth
- @type excess_bw: float
- @param gray_code: Tell modulator to Gray code the bits
- @type gray_code: bool
- @param verbose: Print information about modulator?
- @type verbose: bool
- @param debug: Print modualtion data to files?
- @type debug: bool
- """
-
- gr.hier_block2.__init__(self, "qam256_mod",
- gr.io_signature(1, 1, gr.sizeof_char), # Input signature
- gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature
-
- self._samples_per_symbol = samples_per_symbol
- 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)
-
- ntaps = 11 * samples_per_symbol
-
- arity = pow(2, self.bits_per_symbol())
-
- # turn bytes into k-bit vectors
- self.bytes2chunks = \
- gr.packed_to_unpacked_bb(self.bits_per_symbol(), gr.GR_MSB_FIRST)
-
- if self._gray_code:
- self.symbol_mapper = gr.map_bb(qam.binary_to_gray[arity])
- else:
- self.symbol_mapper = gr.map_bb(qam.binary_to_ungray[arity])
-
- self.diffenc = gr.diff_encoder_bb(arity)
-
- rot = 1.0
- print "constellation with %d arity" % arity
- rotated_const = map(lambda pt: pt * rot, qam.constellation[arity])
- self.chunks2symbols = gr.chunks_to_symbols_bc(rotated_const)
-
- # pulse shaping filter
- self.rrc_taps = gr.firdes.root_raised_cosine(
- self._samples_per_symbol, # gain (sps since we're interpolating by sps)
- self._samples_per_symbol, # sampling rate
- 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_taps)
-
- if verbose:
- self._print_verbage()
-
- if log:
- self._setup_logging()
-
- # Connect
- self.connect(self, self.bytes2chunks, self.symbol_mapper, self.diffenc,
- self.chunks2symbols, self.rrc_filter, self)
-
- def samples_per_symbol(self):
- return self._samples_per_symbol
-
- def bits_per_symbol(self=None): # staticmethod that's also callable on an instance
- return 8
- bits_per_symbol = staticmethod(bits_per_symbol) # make it a static method. RTFM
-
- def _print_verbage(self):
- print "bits per symbol = %d" % self.bits_per_symbol()
- print "Gray code = %s" % self._gray_code
- print "RRS roll-off factor = %f" % self._excess_bw
-
- def _setup_logging(self):
- print "Modulation logging turned on."
- self.connect(self.bytes2chunks,
- gr.file_sink(gr.sizeof_char, "bytes2chunks.dat"))
- self.connect(self.symbol_mapper,
- gr.file_sink(gr.sizeof_char, "graycoder.dat"))
- self.connect(self.diffenc,
- gr.file_sink(gr.sizeof_char, "diffenc.dat"))
- self.connect(self.chunks2symbols,
- gr.file_sink(gr.sizeof_gr_complex, "chunks2symbols.dat"))
- self.connect(self.rrc_filter,
- gr.file_sink(gr.sizeof_gr_complex, "rrc_filter.dat"))
-
- def add_options(parser):
- """
- Adds QAM modulation-specific options to the standard parser
- """
- parser.add_option("", "--excess-bw", type="float", default=_def_excess_bw,
- help="set RRC excess bandwith factor [default=%default] (PSK)")
- parser.add_option("", "--no-gray-code", dest="gray_code",
- action="store_false", default=_def_gray_code,
- help="disable gray coding on modulated bits (PSK)")
- add_options=staticmethod(add_options)
-
-
- def extract_kwargs_from_options(options):
- """
- Given command line options, create dictionary suitable for passing to __init__
- """
- return modulation_utils.extract_kwargs_from_options(qam256_mod.__init__,
- ('self',), options)
- extract_kwargs_from_options=staticmethod(extract_kwargs_from_options)
-
-
-# /////////////////////////////////////////////////////////////////////////////
-# QAM256 demodulator
-#
-# /////////////////////////////////////////////////////////////////////////////
-
-class qam256_demod(gr.hier_block2):
-
- def __init__(self,
- samples_per_symbol=_def_samples_per_symbol,
- excess_bw=_def_excess_bw,
- costas_alpha=_def_costas_alpha,
- gain_mu=_def_gain_mu,
- mu=_def_mu,
- omega_relative_limit=_def_omega_relative_limit,
- gray_code=_def_gray_code,
- verbose=_def_verbose,
- log=_def_log):
-
- gr.hier_block2.__init__(self, "qam256_demod",
- gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature
- gr.io_signature(1, 1, gr.sizeof_char)) # Output signature
-
- # do this
- pass
-
- def bits_per_symbol(self=None): # staticmethod that's also callable on an instance
- return 8
- bits_per_symbol = staticmethod(bits_per_symbol) # make it a static method. RTFM
-
-#
-# Add these to the mod/demod registry
-#
-# NOT READY TO BE USED YET -- ENABLE AT YOUR OWN RISK
-#modulation_utils.add_type_1_mod('qam256', qam256_mod)
-#modulation_utils.add_type_1_demod('qam256', qam256_demod)
diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/qam64.py b/gnuradio-core/src/python/gnuradio/blks2impl/qam64.py
deleted file mode 100644
index 5509f37458..0000000000
--- a/gnuradio-core/src/python/gnuradio/blks2impl/qam64.py
+++ /dev/null
@@ -1,208 +0,0 @@
-#
-# 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.
-#
-
-# See gnuradio-examples/python/digital for examples
-
-"""
-differential QPSK modulation and demodulation.
-"""
-
-from gnuradio import gr, gru, modulation_utils
-from math import pi, sqrt
-import qam
-import cmath
-from pprint import pprint
-
-# default values (used in __init__ and add_options)
-_def_samples_per_symbol = 2
-_def_excess_bw = 0.35
-_def_gray_code = True
-_def_verbose = False
-_def_log = False
-
-_def_costas_alpha = None
-_def_gain_mu = 0.03
-_def_mu = 0.05
-_def_omega_relative_limit = 0.005
-
-
-# /////////////////////////////////////////////////////////////////////////////
-# QAM64 modulator
-# /////////////////////////////////////////////////////////////////////////////
-
-class qam64_mod(gr.hier_block2):
-
- def __init__(self,
- samples_per_symbol=_def_samples_per_symbol,
- excess_bw=_def_excess_bw,
- gray_code=_def_gray_code,
- verbose=_def_verbose,
- log=_def_log):
-
- """
- 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.
-
- @param samples_per_symbol: samples per symbol >= 2
- @type samples_per_symbol: integer
- @param excess_bw: Root-raised cosine filter excess bandwidth
- @type excess_bw: float
- @param gray_code: Tell modulator to Gray code the bits
- @type gray_code: bool
- @param verbose: Print information about modulator?
- @type verbose: bool
- @param debug: Print modualtion data to files?
- @type debug: bool
- """
-
- gr.hier_block2.__init__(self, "qam64_mod",
- gr.io_signature(1, 1, gr.sizeof_char), # Input signature
- gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature
- self._samples_per_symbol = samples_per_symbol
- 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)
-
- ntaps = 11 * samples_per_symbol
-
- arity = pow(2, self.bits_per_symbol())
-
- # turn bytes into k-bit vectors
- self.bytes2chunks = \
- gr.packed_to_unpacked_bb(self.bits_per_symbol(), gr.GR_MSB_FIRST)
-
- if self._gray_code:
- self.symbol_mapper = gr.map_bb(qam.binary_to_gray[arity])
- else:
- self.symbol_mapper = gr.map_bb(qam.binary_to_ungray[arity])
-
- self.diffenc = gr.diff_encoder_bb(arity)
-
- rot = 1.0
- print "constellation with %d arity" % arity
- rotated_const = map(lambda pt: pt * rot, qam.constellation[arity])
- self.chunks2symbols = gr.chunks_to_symbols_bc(rotated_const)
-
- # pulse shaping filter
- self.rrc_taps = gr.firdes.root_raised_cosine(
- self._samples_per_symbol, # gain (sps since we're interpolating by sps)
- self._samples_per_symbol, # sampling rate
- 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_taps)
-
- if verbose:
- self._print_verbage()
-
- if log:
- self._setup_logging()
-
- # Connect
- self.connect(self, self.bytes2chunks, self.symbol_mapper, self.diffenc,
- self.chunks2symbols, self.rrc_filter, self)
-
- def samples_per_symbol(self):
- return self._samples_per_symbol
-
- def bits_per_symbol(self=None): # staticmethod that's also callable on an instance
- return 6
- bits_per_symbol = staticmethod(bits_per_symbol) # make it a static method. RTFM
-
- def _print_verbage(self):
- print "bits per symbol = %d" % self.bits_per_symbol()
- print "Gray code = %s" % self._gray_code
- print "RRS roll-off factor = %f" % self._excess_bw
-
- def _setup_logging(self):
- print "Modulation logging turned on."
- self.connect(self.bytes2chunks,
- gr.file_sink(gr.sizeof_char, "bytes2chunks.dat"))
- self.connect(self.symbol_mapper,
- gr.file_sink(gr.sizeof_char, "graycoder.dat"))
- self.connect(self.diffenc,
- gr.file_sink(gr.sizeof_char, "diffenc.dat"))
- self.connect(self.chunks2symbols,
- gr.file_sink(gr.sizeof_gr_complex, "chunks2symbols.dat"))
- self.connect(self.rrc_filter,
- gr.file_sink(gr.sizeof_gr_complex, "rrc_filter.dat"))
-
- def add_options(parser):
- """
- Adds QAM modulation-specific options to the standard parser
- """
- parser.add_option("", "--excess-bw", type="float", default=_def_excess_bw,
- help="set RRC excess bandwith factor [default=%default] (PSK)")
- parser.add_option("", "--no-gray-code", dest="gray_code",
- action="store_false", default=_def_gray_code,
- help="disable gray coding on modulated bits (PSK)")
- add_options=staticmethod(add_options)
-
-
- def extract_kwargs_from_options(options):
- """
- Given command line options, create dictionary suitable for passing to __init__
- """
- return modulation_utils.extract_kwargs_from_options(qam64_mod.__init__,
- ('self',), options)
- extract_kwargs_from_options=staticmethod(extract_kwargs_from_options)
-
-
-# /////////////////////////////////////////////////////////////////////////////
-# QAM16 demodulator
-#
-# /////////////////////////////////////////////////////////////////////////////
-
-class qam64_demod(gr.hier_block2):
-
- def __init__(self,
- samples_per_symbol=_def_samples_per_symbol,
- excess_bw=_def_excess_bw,
- costas_alpha=_def_costas_alpha,
- gain_mu=_def_gain_mu,
- mu=_def_mu,
- omega_relative_limit=_def_omega_relative_limit,
- gray_code=_def_gray_code,
- verbose=_def_verbose,
- log=_def_log):
-
- gr.hier_block2.__init__(self, "qam64_demod",
- gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature
- gr.io_signature(1, 1, gr.sizeof_char)) # Output signature
-
- # do this
- pass
-
- def bits_per_symbol(self=None): # staticmethod that's also callable on an instance
- return 6
- bits_per_symbol = staticmethod(bits_per_symbol) # make it a static method. RTFM
-
-#
-# Add these to the mod/demod registry
-#
-# NOT READY TO BE USED YET -- ENABLE AT YOUR OWN RISK
-#modulation_utils.add_type_1_mod('qam64', qam64_mod)
-#modulation_utils.add_type_1_demod('qam16', qam16_demod)
diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/qam8.py b/gnuradio-core/src/python/gnuradio/blks2impl/qam8.py
deleted file mode 100644
index 6a7b355978..0000000000
--- a/gnuradio-core/src/python/gnuradio/blks2impl/qam8.py
+++ /dev/null
@@ -1,209 +0,0 @@
-#
-# 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.
-#
-
-# See gnuradio-examples/python/digital for examples
-
-"""
-QAM8 modulation and demodulation.
-"""
-
-from gnuradio import gr, gru, modulation_utils
-from math import pi, sqrt
-import qam
-import cmath
-from pprint import pprint
-
-# default values (used in __init__ and add_options)
-_def_samples_per_symbol = 2
-_def_excess_bw = 0.35
-_def_gray_code = True
-_def_verbose = False
-_def_log = False
-
-_def_costas_alpha = None
-_def_gain_mu = 0.03
-_def_mu = 0.05
-_def_omega_relative_limit = 0.005
-
-
-# /////////////////////////////////////////////////////////////////////////////
-# QAM8 modulator
-# /////////////////////////////////////////////////////////////////////////////
-
-class qam8_mod(gr.hier_block2):
-
- def __init__(self,
- samples_per_symbol=_def_samples_per_symbol,
- excess_bw=_def_excess_bw,
- gray_code=_def_gray_code,
- verbose=_def_verbose,
- log=_def_log):
-
- """
- 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.
-
- @param samples_per_symbol: samples per symbol >= 2
- @type samples_per_symbol: integer
- @param excess_bw: Root-raised cosine filter excess bandwidth
- @type excess_bw: float
- @param gray_code: Tell modulator to Gray code the bits
- @type gray_code: bool
- @param verbose: Print information about modulator?
- @type verbose: bool
- @param debug: Print modualtion data to files?
- @type debug: bool
- """
-
- gr.hier_block2.__init__(self, "qam8_mod",
- gr.io_signature(1, 1, gr.sizeof_char), # Input signature
- gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature
-
- self._samples_per_symbol = samples_per_symbol
- 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)
-
- ntaps = 11 * samples_per_symbol
-
- arity = pow(2, self.bits_per_symbol())
-
- # turn bytes into k-bit vectors
- self.bytes2chunks = \
- gr.packed_to_unpacked_bb(self.bits_per_symbol(), gr.GR_MSB_FIRST)
-
- if self._gray_code:
- self.symbol_mapper = gr.map_bb(qam.binary_to_gray[arity])
- else:
- self.symbol_mapper = gr.map_bb(qam.binary_to_ungray[arity])
-
- self.diffenc = gr.diff_encoder_bb(arity)
-
- rot = 1.0
- print "constellation with %d arity" % arity
- rotated_const = map(lambda pt: pt * rot, qam.constellation[arity])
- self.chunks2symbols = gr.chunks_to_symbols_bc(rotated_const)
-
- # pulse shaping filter
- self.rrc_taps = gr.firdes.root_raised_cosine(
- self._samples_per_symbol, # gain (sps since we're interpolating by sps)
- self._samples_per_symbol, # sampling rate
- 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_taps)
-
- if verbose:
- self._print_verbage()
-
- if log:
- self._setup_logging()
-
- # Connect
- self.connect(self, self.bytes2chunks, self.symbol_mapper, self.diffenc,
- self.chunks2symbols, self.rrc_filter, self)
-
- def samples_per_symbol(self):
- return self._samples_per_symbol
-
- def bits_per_symbol(self=None): # staticmethod that's also callable on an instance
- return 3
- bits_per_symbol = staticmethod(bits_per_symbol) # make it a static method. RTFM
-
- def _print_verbage(self):
- print "bits per symbol = %d" % self.bits_per_symbol()
- print "Gray code = %s" % self._gray_code
- print "RRS roll-off factor = %f" % self._excess_bw
-
- def _setup_logging(self):
- print "Modulation logging turned on."
- self.connect(self.bytes2chunks,
- gr.file_sink(gr.sizeof_char, "bytes2chunks.dat"))
- self.connect(self.symbol_mapper,
- gr.file_sink(gr.sizeof_char, "graycoder.dat"))
- self.connect(self.diffenc,
- gr.file_sink(gr.sizeof_char, "diffenc.dat"))
- self.connect(self.chunks2symbols,
- gr.file_sink(gr.sizeof_gr_complex, "chunks2symbols.dat"))
- self.connect(self.rrc_filter,
- gr.file_sink(gr.sizeof_gr_complex, "rrc_filter.dat"))
-
- def add_options(parser):
- """
- Adds QAM modulation-specific options to the standard parser
- """
- parser.add_option("", "--excess-bw", type="float", default=_def_excess_bw,
- help="set RRC excess bandwith factor [default=%default] (PSK)")
- parser.add_option("", "--no-gray-code", dest="gray_code",
- action="store_false", default=_def_gray_code,
- help="disable gray coding on modulated bits (PSK)")
- add_options=staticmethod(add_options)
-
-
- def extract_kwargs_from_options(options):
- """
- Given command line options, create dictionary suitable for passing to __init__
- """
- return modulation_utils.extract_kwargs_from_options(qam8_mod.__init__,
- ('self',), options)
- extract_kwargs_from_options=staticmethod(extract_kwargs_from_options)
-
-
-# /////////////////////////////////////////////////////////////////////////////
-# QAM8 demodulator
-#
-# /////////////////////////////////////////////////////////////////////////////
-
-class qam8_demod(gr.hier_block2):
-
- def __init__(self,
- samples_per_symbol=_def_samples_per_symbol,
- excess_bw=_def_excess_bw,
- costas_alpha=_def_costas_alpha,
- gain_mu=_def_gain_mu,
- mu=_def_mu,
- omega_relative_limit=_def_omega_relative_limit,
- gray_code=_def_gray_code,
- verbose=_def_verbose,
- log=_def_log):
-
- gr.hier_block2.__init__(self, "qam8_demod",
- gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature
- gr.io_signature(1, 1, gr.sizeof_char)) # Output signature
-
- # do this
- pass
-
- def bits_per_symbol(self=None): # staticmethod that's also callable on an instance
- return 3
- bits_per_symbol = staticmethod(bits_per_symbol) # make it a static method. RTFM
-
-#
-# Add these to the mod/demod registry
-#
-# NOT READY TO BE USED YET -- ENABLE AT YOUR OWN RISK
-modulation_utils.add_type_1_mod('qam8', qam8_mod)
-#modulation_utils.add_type_1_demod('qam8', qam8_demod)