From 5429a1e3abf3e5c1aeadc0253169233faee46cc8 Mon Sep 17 00:00:00 2001 From: Mike Jameson Date: Mon, 25 Aug 2014 14:33:49 +0100 Subject: [PATCH] updated uhd-tetra_demod.py and cqpsk.py for GNU Radio v3.74 compatibility --- src/demod/python/cqpsk.py | 45 +++++++++++++++-------------- src/demod/python/uhd-tetra_demod.py | 11 +++---- 2 files changed, 29 insertions(+), 27 deletions(-) diff --git a/src/demod/python/cqpsk.py b/src/demod/python/cqpsk.py index f9621b1..daf78d9 100644 --- a/src/demod/python/cqpsk.py +++ b/src/demod/python/cqpsk.py @@ -27,7 +27,8 @@ differential PI/4 CQPSK modulation and demodulation. """ -from gnuradio import gr, gru +from gnuradio import gr, gru, blocks, analog, filter, digital +from gnuradio.filter import firdes from math import pi, sqrt #import psk import cmath @@ -110,14 +111,14 @@ class cqpsk_mod(gr.hier_block2): self.chunks2symbols = gr.chunks_to_symbols_bc(psk.constellation[arity]) # pulse shaping filter - self.rrc_taps = gr.firdes.root_raised_cosine( + self.rrc_taps = 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) + self.rrc_filter = filter.interp_fir_filter_ccf(self._samples_per_symbol, self.rrc_taps) if verbose: self._print_verbage() @@ -145,15 +146,15 @@ class cqpsk_mod(gr.hier_block2): def _setup_logging(self): print "Modulation logging turned on." self.connect(self.bytes2chunks, - gr.file_sink(gr.sizeof_char, "tx_bytes2chunks.dat")) + blocks.file_sink(gr.sizeof_char, "tx_bytes2chunks.dat")) self.connect(self.symbol_mapper, - gr.file_sink(gr.sizeof_char, "tx_graycoder.dat")) + blocks.file_sink(gr.sizeof_char, "tx_graycoder.dat")) self.connect(self.diffenc, - gr.file_sink(gr.sizeof_char, "tx_diffenc.dat")) + blocks.file_sink(gr.sizeof_char, "tx_diffenc.dat")) self.connect(self.chunks2symbols, - gr.file_sink(gr.sizeof_gr_complex, "tx_chunks2symbols.dat")) + blocks.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")) + blocks.file_sink(gr.sizeof_gr_complex, "tx_rrc_filter.dat")) def add_options(parser): """ @@ -238,19 +239,19 @@ class cqpsk_demod(gr.hier_block2): # 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.pre_scaler = blocks.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) + self.agc = analog.feedforward_agc_cc(16, 2.0) # RRC data filter ntaps = 11 * samples_per_symbol - self.rrc_taps = gr.firdes.root_raised_cosine( + self.rrc_taps = 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) + self.rrc_filter=filter.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} @@ -281,13 +282,13 @@ class cqpsk_demod(gr.hier_block2): self.receiver.set_beta(self._costas_beta) # Perform Differential decoding on the constellation - self.diffdec = gr.diff_phasor_cc() + self.diffdec = digital.diff_phasor_cc() # take angle of the difference (in radians) - self.to_float = gr.complex_to_arg() + self.to_float = blocks.complex_to_arg() # convert from radians such that signal is in -3/-1/+1/+3 - self.rescale = gr.multiply_const_ff( 1 / (pi / 4) ) + self.rescale = blocks.multiply_const_ff( 1 / (pi / 4) ) if verbose: self._print_verbage() @@ -322,19 +323,19 @@ class cqpsk_demod(gr.hier_block2): def _setup_logging(self): print "Modulation logging turned on." self.connect(self.pre_scaler, - gr.file_sink(gr.sizeof_gr_complex, "rx_prescaler.dat")) + blocks.file_sink(gr.sizeof_gr_complex, "rx_prescaler.dat")) self.connect(self.agc, - gr.file_sink(gr.sizeof_gr_complex, "rx_agc.dat")) + blocks.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")) + blocks.file_sink(gr.sizeof_gr_complex, "rx_rrc_filter.dat")) self.connect(self.receiver, - gr.file_sink(gr.sizeof_gr_complex, "rx_receiver.dat")) + blocks.file_sink(gr.sizeof_gr_complex, "rx_receiver.dat")) self.connect(self.diffdec, - gr.file_sink(gr.sizeof_gr_complex, "rx_diffdec.dat")) + blocks.file_sink(gr.sizeof_gr_complex, "rx_diffdec.dat")) self.connect(self.to_float, - gr.file_sink(gr.sizeof_float, "rx_to_float.dat")) + blocks.file_sink(gr.sizeof_float, "rx_to_float.dat")) self.connect(self.rescale, - gr.file_sink(gr.sizeof_float, "rx_rescale.dat")) + blocks.file_sink(gr.sizeof_float, "rx_rescale.dat")) def add_options(parser): """ diff --git a/src/demod/python/uhd-tetra_demod.py b/src/demod/python/uhd-tetra_demod.py index ac49fb7..6efa40b 100755 --- a/src/demod/python/uhd-tetra_demod.py +++ b/src/demod/python/uhd-tetra_demod.py @@ -2,8 +2,9 @@ import sys import math -from gnuradio import gr, gru, audio, eng_notation, blks2, optfir +from gnuradio import gr, gru, audio, eng_notation, filter, blocks from gnuradio import uhd +from gnuradio.filter import firdes from gnuradio.eng_option import eng_option from optparse import OptionParser @@ -63,9 +64,9 @@ class my_top_block(gr.top_block): sys.stderr.write('Failed to set center frequency\n') raise SystemExit, 1 - channel_taps = gr.firdes.low_pass(1.0, sample_rate, options.low_pass, options.low_pass * 0.1, gr.firdes.WIN_HANN) + channel_taps = firdes.low_pass(1.0, sample_rate, options.low_pass, options.low_pass * 0.1, firdes.WIN_HANN) - FILTER = gr.freq_xlating_fir_filter_ccf(1, channel_taps, options.calibration, sample_rate) + FILTER = filter.freq_xlating_fir_filter_ccf(1, channel_taps, options.calibration, sample_rate) sys.stderr.write("sample rate: %d\n" %(sample_rate)) @@ -78,11 +79,11 @@ class my_top_block(gr.top_block): log=options.log, verbose=options.verbose) - OUT = gr.file_sink(gr.sizeof_float, options.output_file) + OUT = blocks.file_sink(gr.sizeof_float, options.output_file) r = float(sample_rate) / float(new_sample_rate) - INTERPOLATOR = gr.fractional_interpolator_cc(0, r) + INTERPOLATOR = filter.fractional_interpolator_cc(0, r) self.connect(self._u, FILTER, INTERPOLATOR, DEMOD, OUT)