Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port to GNURadio 3.7 #1

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 36 additions & 56 deletions src/demod/python/cqpsk.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,8 @@
differential PI/4 CQPSK modulation and demodulation.
"""

from gnuradio import gr, gru
from math import pi, sqrt
#import psk
import cmath
from pprint import pprint

_def_has_gr_digital = False

# address gnuradio 3.5.x changes
try:
from gnuradio import modulation_utils
except ImportError:
from gnuradio import digital
_def_has_gr_digital = True
from gnuradio import analog, blocks, digital, filter, gr
from math import pi

# default values (used in __init__ and add_options)
_def_samples_per_symbol = 10
Expand Down Expand Up @@ -98,26 +86,26 @@ def __init__(self,

# turn bytes into k-bit vectors
self.bytes2chunks = \
gr.packed_to_unpacked_bb(self.bits_per_symbol(), gr.GR_MSB_FIRST)
blocks.packed_to_unpacked_bb(self.bits_per_symbol(), gr.GR_MSB_FIRST)

# 0 +45 1 [+1]
# 1 +135 3 [+3]
# 2 -45 7 [-1]
# 3 -135 5 [-3]
self.pi4map = [1, 3, 7, 5]
self.symbol_mapper = gr.map_bb(self.pi4map)
self.diffenc = gr.diff_encoder_bb(arity)
self.chunks2symbols = gr.chunks_to_symbols_bc(psk.constellation[arity])
self.symbol_mapper = digital.map_bb(self.pi4map)
self.diffenc = digital.diff_encoder_bb(arity)
self.chunks2symbols = digital.chunks_to_symbols_bc(psk.constellation[arity])

# pulse shaping filter
self.rrc_taps = gr.firdes.root_raised_cosine(
self.rrc_taps = filter.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()
Expand Down Expand Up @@ -145,15 +133,15 @@ def _print_verbage(self):
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):
"""
Expand Down Expand Up @@ -238,19 +226,19 @@ def __init__(self,

# 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 = filter.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}
Expand All @@ -262,32 +250,24 @@ def __init__(self,
fmin = -0.025
fmax = 0.025

if not _def_has_gr_digital:
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)
else:
self.receiver=digital.mpsk_receiver_cc(arity, pi/4.0,
2*pi/150,
fmin, fmax,
self._mm_mu, self._mm_gain_mu,
self._mm_omega, self._mm_gain_omega,
self._mm_omega_relative_limit)

self.receiver.set_alpha(self._costas_alpha)
self.receiver.set_beta(self._costas_beta)
self.receiver=digital.mpsk_receiver_cc(arity, pi/4.0,
2*pi/150,
fmin, fmax,
self._mm_mu, self._mm_gain_mu,
self._mm_omega, self._mm_gain_omega,
self._mm_omega_relative_limit)

self.receiver.set_alpha(self._costas_alpha)
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()
Expand Down Expand Up @@ -322,19 +302,19 @@ def _print_verbage(self):
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):
"""
Expand Down
13 changes: 6 additions & 7 deletions src/demod/python/fcdp-tetra_demod.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

import sys
import math
from gnuradio import gr, gru, audio, eng_notation, blks2, optfir
from gnuradio import audio
from gnuradio import blocks, filter, gr, audio
from gnuradio.eng_option import eng_option
from optparse import OptionParser

Expand All @@ -22,7 +21,7 @@ def __init__(self, options):

self.asrc = audio.source(sample_rate, options.audio_device, True)

self.f2c = gr.float_to_complex(1)
self.f2c = blocks.float_to_complex(1)

self.connect((self.asrc, 1), (self.f2c, 1))
self.connect((self.asrc, 0), (self.f2c, 0))
Expand All @@ -33,9 +32,9 @@ def __init__(self, options):
ntaps = 11 * sps
new_sample_rate = symbol_rate * sps

channel_taps = gr.firdes.low_pass(1.0, sample_rate, options.low_pass, options.low_pass * 0.1, gr.firdes.WIN_HANN)
channel_taps = filter.firdes.low_pass(1.0, sample_rate, options.low_pass, options.low_pass * 0.1, filter.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))

Expand All @@ -48,11 +47,11 @@ def __init__(self, options):
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_resampler_cc(0, r)

self.connect(self.f2c, FILTER, INTERPOLATOR, DEMOD, OUT)

Expand Down
13 changes: 6 additions & 7 deletions src/demod/python/fcdp-tetra_demod_fft.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

import sys
import math
from gnuradio import gr, gru, audio, eng_notation, blks2, optfir
from gnuradio import audio
from gnuradio import blocks, filter, gr, gru, audio
from gnuradio.eng_option import eng_option
from gnuradio.wxgui import stdgui2, fftsink2
from optparse import OptionParser
Expand All @@ -28,7 +27,7 @@ def __init__(self, frame, panel, vbox, argv):

self.asrc = audio.source(sample_rate, options.audio_device, True)

self.f2c = gr.float_to_complex(1)
self.f2c = blocks.float_to_complex(1)

self.connect((self.asrc, 1), (self.f2c, 1))
self.connect((self.asrc, 0), (self.f2c, 0))
Expand All @@ -39,9 +38,9 @@ def __init__(self, frame, panel, vbox, argv):
ntaps = 11 * sps
new_sample_rate = symbol_rate * sps

channel_taps = gr.firdes.low_pass(1.0, sample_rate, options.low_pass, options.low_pass * 0.1, gr.firdes.WIN_HANN)
channel_taps = filter.firdes.low_pass(1.0, sample_rate, options.low_pass, options.low_pass * 0.1, filter.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))

Expand All @@ -54,11 +53,11 @@ def __init__(self, frame, panel, vbox, argv):
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_resampler_cc(0, r)

self.connect(self.f2c, FILTER, INTERPOLATOR, DEMOD, OUT)

Expand Down
16 changes: 8 additions & 8 deletions src/demod/python/osmosdr-tetra_demod_fft.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import sys
import math
from gnuradio import gr, gru, eng_notation, blks2, optfir
from gnuradio import blocks, filter, gr, wxgui
from gnuradio.eng_option import eng_option
from gnuradio.wxgui import fftsink2
from gnuradio.wxgui import scopesink2
Expand All @@ -39,7 +39,7 @@ def __init__(self):
self.ifreq = options.frequency
self.rfgain = options.gain

self.src = osmosdr.source_c(options.args)
self.src = osmosdr.source(options.args)
self.src.set_center_freq(self.ifreq)
self.src.set_sample_rate(int(options.sample_rate))
#sq5bpf: dodalem ppm
Expand Down Expand Up @@ -71,8 +71,8 @@ def __init__(self):

self.offset = 0

taps = gr.firdes.low_pass(1.0, sample_rate, options.low_pass, options.low_pass * 0.2, gr.firdes.WIN_HANN)
self.tuner = gr.freq_xlating_fir_filter_ccf(first_decim, taps, self.offset, sample_rate)
taps = filter.firdes.low_pass(1.0, sample_rate, options.low_pass, options.low_pass * 0.2, filter.firdes.WIN_HANN)
self.tuner = filter.freq_xlating_fir_filter_ccf(first_decim, taps, self.offset, sample_rate)

self.demod = cqpsk.cqpsk_demod(
samples_per_symbol = sps,
Expand All @@ -84,17 +84,17 @@ def __init__(self):
log=options.log,
verbose=options.verbose)

self.output = gr.file_sink(gr.sizeof_float, options.output_file)
self.output = blocks.file_sink(gr.sizeof_float, options.output_file)

rerate = float(sample_rate / float(first_decim)) / float(out_sample_rate)
sys.stderr.write("resampling factor: %f\n" % rerate)

if rerate.is_integer():
sys.stderr.write("using pfb decimator\n")
self.resamp = blks2.pfb_decimator_ccf(int(rerate))
self.resamp = filter.pfb_decimator_ccf(int(rerate))
else:
sys.stderr.write("using pfb resampler\n")
self.resamp = blks2.pfb_arb_resampler_ccf(1 / rerate)
self.resamp = filter.pfb_arb_resampler_ccf(1 / rerate)

self.connect(self.src, self.tuner, self.resamp, self.demod, self.output)

Expand Down Expand Up @@ -227,7 +227,7 @@ def fftsink2_callback2(x, y):
ac_couple=False,
xy_mode=False,
num_inputs=1,
trig_mode=gr.gr_TRIG_MODE_AUTO,
trig_mode=wxgui.TRIG_MODE_AUTO,
y_axis_label="Counts",
)
self.Main.GetPage(2).Add(self.scope3.win)
Expand Down
6 changes: 3 additions & 3 deletions src/demod/python/simdemod2.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

import sys
import math
from gnuradio import gr, gru, eng_notation, blks2, optfir
from gnuradio import blocks, gr
from gnuradio.eng_option import eng_option
from optparse import OptionParser
import osmosdr
Expand All @@ -30,7 +30,7 @@ def __init__(self):

options = get_options()
self.input_file=options.input_file
self.gr_file_source_0 = gr.file_source(gr.sizeof_gr_complex*1, self.input_file, True)
self.gr_file_source_0 = blocks.file_source(gr.sizeof_gr_complex*1, self.input_file, True)

symbol_rate = 18000
sps = 2 # output rate will be 36,000
Expand All @@ -48,7 +48,7 @@ def __init__(self):
log=options.log,
verbose=options.verbose)

self.output = gr.file_sink(gr.sizeof_float, options.output_file)
self.output = blocks.file_sink(gr.sizeof_float, options.output_file)

self.connect(self.gr_file_source_0, self.demod, self.output)

Expand Down
12 changes: 6 additions & 6 deletions src/demod/python/tetra-demod.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import sys
import math
from gnuradio import gr, gru, audio, eng_notation, blks2, optfir
from gnuradio import blocks, filter, gr
from gnuradio.eng_option import eng_option
from optparse import OptionParser

Expand Down Expand Up @@ -36,13 +36,13 @@ def __init__(self):
ntaps = 11 * sps
new_sample_rate = symbol_rate * sps

channel_taps = gr.firdes.low_pass(1.0, sample_rate, options.low_pass, options.low_pass * 0.1, gr.firdes.WIN_HANN)
channel_taps = filter.firdes.low_pass(1.0, sample_rate, options.low_pass, options.low_pass * 0.1, filter.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))

IN = gr.file_source(gr.sizeof_gr_complex, options.input_file)
IN = blocks.file_source(gr.sizeof_gr_complex, options.input_file)

DEMOD = cqpsk.cqpsk_demod( samples_per_symbol = sps,
excess_bw=0.35,
Expand All @@ -54,11 +54,11 @@ def __init__(self):
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_resampler_cc(0, r)

self.connect(IN, FILTER, INTERPOLATOR, DEMOD, OUT)

Expand Down
Loading