aboutsummaryrefslogtreecommitdiffstats
path: root/tests/correlator
diff options
context:
space:
mode:
authorNao Pross <np@0hm.ch>2021-12-11 14:04:56 +0100
committerNao Pross <np@0hm.ch>2021-12-11 14:04:56 +0100
commita644467ee7d2facf68474d3d0ef4de8a30cb1c37 (patch)
treea142b15df4b41966f2d094f261f37642f7b78955 /tests/correlator
parentContinue vector stream and fix bug(?) in GR 3.9 (diff)
downloadFading-a644467ee7d2facf68474d3d0ef4de8a30cb1c37.tar.gz
Fading-a644467ee7d2facf68474d3d0ef4de8a30cb1c37.zip
Correctly decode symbols
Diffstat (limited to 'tests/correlator')
-rw-r--r--tests/correlator/correlator.grc180
-rwxr-xr-xtests/correlator/correlator.py143
-rw-r--r--tests/correlator/epy_block_0.py22
-rw-r--r--tests/correlator/epy_block_1.py6
4 files changed, 271 insertions, 80 deletions
diff --git a/tests/correlator/correlator.grc b/tests/correlator/correlator.grc
index 26de096..db82de1 100644
--- a/tests/correlator/correlator.grc
+++ b/tests/correlator/correlator.grc
@@ -1,7 +1,6 @@
options:
parameters:
author: Naoki Pross
- catch_exceptions: 'True'
category: '[GRC Hier Blocks]'
cmake_opt: ''
comment: ''
@@ -23,6 +22,7 @@ options:
sizing_mode: fixed
thread_safe_setters: ''
title: Correlator Test
+ window_size: ''
states:
bus_sink: false
bus_source: false
@@ -53,7 +53,6 @@ blocks:
comment: ''
const_points: '[-1-1j, -1+1j, 1+1j, 1-1j]'
dims: '1'
- normalization: digital.constellation.AMPLITUDE_NORMALIZATION
precision: '8'
rot_sym: '4'
soft_dec_lut: None
@@ -78,6 +77,18 @@ blocks:
coordinate: [496, 360.0]
rotation: 0
state: enabled
+- name: frame_len
+ id: variable
+ parameters:
+ comment: ''
+ value: len(testvec) + 4
+ states:
+ bus_sink: false
+ bus_source: false
+ bus_structure: null
+ coordinate: [304, 380.0]
+ rotation: 0
+ state: true
- name: nfilts
id: variable
parameters:
@@ -150,7 +161,7 @@ blocks:
bus_sink: false
bus_source: false
bus_structure: null
- coordinate: [48, 360.0]
+ coordinate: [48, 356.0]
rotation: 0
state: enabled
- name: timing_loop_bw
@@ -165,6 +176,26 @@ blocks:
coordinate: [224, 936.0]
rotation: 0
state: enabled
+- name: analog_random_source_x_0
+ id: analog_random_source_x
+ parameters:
+ affinity: ''
+ alias: ''
+ comment: ''
+ max: '255'
+ maxoutbuf: '0'
+ min: '0'
+ minoutbuf: '0'
+ num_samps: '1000'
+ repeat: 'True'
+ type: byte
+ states:
+ bus_sink: false
+ bus_source: false
+ bus_structure: null
+ coordinate: [48, 428.0]
+ rotation: 0
+ state: true
- name: blocks_complex_to_magphase_0_0
id: blocks_complex_to_magphase
parameters:
@@ -240,11 +271,11 @@ blocks:
parameters:
affinity: ''
alias: ''
- align_output: 'False'
+ align_output: 'True'
comment: ''
- endianness: gr.GR_LSB_FIRST
+ endianness: gr.GR_MSB_FIRST
k: '2'
- l: '4'
+ l: '8'
len_tag_key: '""'
maxoutbuf: '0'
minoutbuf: '0'
@@ -252,7 +283,7 @@ blocks:
bus_sink: false
bus_source: false
bus_structure: null
- coordinate: [656, 1252.0]
+ coordinate: [816, 1252.0]
rotation: 0
state: enabled
- name: blocks_socket_pdu_0
@@ -272,7 +303,7 @@ blocks:
bus_sink: false
bus_source: false
bus_structure: null
- coordinate: [680, 1420.0]
+ coordinate: [680, 1428.0]
rotation: 0
state: disabled
- name: blocks_stream_mux_0
@@ -281,10 +312,10 @@ blocks:
affinity: ''
alias: ''
comment: ''
- lengths: '[0, len(testvec)]'
+ lengths: '[0, len(testvec), 4]'
maxoutbuf: '0'
minoutbuf: '0'
- num_inputs: '2'
+ num_inputs: '3'
type: byte
vlen: '1'
states:
@@ -302,14 +333,14 @@ blocks:
comment: ''
maxoutbuf: '0'
minoutbuf: '0'
- num_items: len(testvec)
+ num_items: frame_len
type: byte
vlen: '1'
states:
bus_sink: false
bus_source: false
bus_structure: null
- coordinate: [1208, 1264.0]
+ coordinate: [1072, 1264.0]
rotation: 0
state: true
- name: blocks_tagged_stream_align_0
@@ -327,7 +358,7 @@ blocks:
bus_sink: false
bus_source: false
bus_structure: null
- coordinate: [912, 1260.0]
+ coordinate: [520, 1260.0]
rotation: 0
state: true
- name: blocks_tagged_stream_to_pdu_1
@@ -394,10 +425,10 @@ blocks:
block_tags: 'False'
comment: ''
epsilon: '1.0'
- freq_offset: '0.0005'
+ freq_offset: '0.002'
maxoutbuf: '0'
minoutbuf: '0'
- noise_voltage: '0.01'
+ noise_voltage: '0.1'
seed: '243'
taps: np.exp(1j * 30 / 180 * np.pi)
states:
@@ -455,7 +486,6 @@ blocks:
maxoutbuf: '0'
minoutbuf: '0'
samples_per_symbol: sps
- truncate: 'False'
verbose: 'False'
states:
bus_sink: false
@@ -592,7 +622,7 @@ blocks:
\ = lambda tag: pmt.to_python(tag.key) == \"corr_start\"\n start_tags\
\ = list(filter(is_start, \\\n self.get_tags_in_range(0, counter,\
\ counter + len(inp))))\n\n for tag in start_tags:\n self.add_item_tag(0,\
- \ tag.offset, \\\n pmt.intern(\"frame_start\"), pmt.from_long(10))\n\
+ \ tag.offset +1, \\\n pmt.intern(\"frame_start\"), pmt.from_long(8))\n\
\n print(f\"Writing {len(out)} samples\")\n return len(out)\n"
affinity: ''
alias: ''
@@ -615,7 +645,7 @@ blocks:
parameters:
_source_code: "import numpy as np\nfrom gnuradio import gr\n\n# remove print for\
\ now\n# print = lambda x: None\n\nnp.set_printoptions(formatter={'int':hex})\n\
- \nclass blk(gr.sync_block):\n def __init__(self, vlen=4):\n gr.sync_block.__init__(\n\
+ \nclass blk(gr.sync_block):\n def __init__(self, vlen=8):\n gr.sync_block.__init__(\n\
\ self,\n name='Printer',\n in_sig=[(np.byte,\
\ vlen)],\n out_sig=[]\n )\n\n def work(self, input_items,\
\ output_items):\n inp = np.array(input_items[0], dtype=np.uint8)\n \
@@ -625,13 +655,13 @@ blocks:
comment: ''
maxoutbuf: '0'
minoutbuf: '0'
- vlen: len(testvec)
+ vlen: frame_len
states:
- _io_cache: ('Printer', 'blk', [('vlen', '4')], [('0', 'byte', 4)], [], '', [])
+ _io_cache: ('Printer', 'blk', [('vlen', '8')], [('0', 'byte', 8)], [], '', [])
bus_sink: false
bus_source: false
bus_structure: null
- coordinate: [1432, 1260.0]
+ coordinate: [1296, 1260.0]
rotation: 0
state: enabled
- name: epy_block_2
@@ -683,7 +713,7 @@ blocks:
bus_sink: false
bus_source: false
bus_structure: null
- coordinate: [936, 1164.0]
+ coordinate: [1080, 1140.0]
rotation: 0
state: disabled
- name: fir_filter_xxx_1
@@ -919,6 +949,103 @@ blocks:
coordinate: [1416, 772.0]
rotation: 0
state: enabled
+- name: qtgui_time_sink_x_0
+ id: qtgui_time_sink_x
+ parameters:
+ affinity: ''
+ alias: ''
+ alpha1: '1.0'
+ alpha10: '1.0'
+ alpha2: '1.0'
+ alpha3: '1.0'
+ alpha4: '1.0'
+ alpha5: '1.0'
+ alpha6: '1.0'
+ alpha7: '1.0'
+ alpha8: '1.0'
+ alpha9: '1.0'
+ autoscale: 'False'
+ axislabels: 'True'
+ color1: blue
+ color10: dark blue
+ color2: red
+ color3: green
+ color4: black
+ color5: cyan
+ color6: magenta
+ color7: yellow
+ color8: dark red
+ color9: dark green
+ comment: ''
+ ctrlpanel: 'False'
+ entags: 'True'
+ grid: 'False'
+ gui_hint: ''
+ label1: Signal 1
+ label10: Signal 10
+ label2: Signal 2
+ label3: Signal 3
+ label4: Signal 4
+ label5: Signal 5
+ label6: Signal 6
+ label7: Signal 7
+ label8: Signal 8
+ label9: Signal 9
+ legend: 'True'
+ marker1: '-1'
+ marker10: '-1'
+ marker2: '-1'
+ marker3: '-1'
+ marker4: '-1'
+ marker5: '-1'
+ marker6: '-1'
+ marker7: '-1'
+ marker8: '-1'
+ marker9: '-1'
+ name: '""'
+ nconnections: '1'
+ size: '1024'
+ srate: samp_rate / sps
+ stemplot: 'False'
+ style1: '1'
+ style10: '1'
+ style2: '1'
+ style3: '1'
+ style4: '1'
+ style5: '1'
+ style6: '1'
+ style7: '1'
+ style8: '1'
+ style9: '1'
+ tr_chan: '0'
+ tr_delay: '0'
+ tr_level: '0.0'
+ tr_mode: qtgui.TRIG_MODE_FREE
+ tr_slope: qtgui.TRIG_SLOPE_POS
+ tr_tag: '""'
+ type: complex
+ update_time: '0.10'
+ width1: '1'
+ width10: '1'
+ width2: '1'
+ width3: '1'
+ width4: '1'
+ width5: '1'
+ width6: '1'
+ width7: '1'
+ width8: '1'
+ width9: '1'
+ ylabel: Amplitude
+ ymax: '1'
+ ymin: '-1'
+ yunit: '""'
+ states:
+ bus_sink: false
+ bus_source: false
+ bus_structure: null
+ coordinate: [1416, 572.0]
+ rotation: 0
+ state: true
- name: qtgui_time_sink_x_0_0
id: qtgui_time_sink_x
parameters:
@@ -1458,16 +1585,16 @@ blocks:
state: true
connections:
+- [analog_random_source_x_0, '0', blocks_stream_mux_0, '2']
- [blocks_complex_to_magphase_0_0, '0', qtgui_time_sink_x_0_0, '0']
- [blocks_complex_to_magphase_0_0, '1', blocks_multiply_const_vxx_0_0, '0']
- [blocks_complex_to_magphase_0_0, '1', blocks_null_sink_3, '0']
- [blocks_multiply_const_vxx_0_0, '0', qtgui_time_sink_x_2_0, '0']
- [blocks_null_source_0, '0', blocks_stream_mux_0, '0']
-- [blocks_repack_bits_bb_0, '0', blocks_tagged_stream_align_0, '0']
-- [blocks_repack_bits_bb_0, '0', epy_block_2, '0']
+- [blocks_repack_bits_bb_0, '0', blocks_stream_to_vector_0, '0']
- [blocks_stream_mux_0, '0', digital_constellation_modulator_0, '0']
- [blocks_stream_to_vector_0, '0', epy_block_1, '0']
-- [blocks_tagged_stream_align_0, '0', blocks_stream_to_vector_0, '0']
+- [blocks_tagged_stream_align_0, '0', blocks_repack_bits_bb_0, '0']
- [blocks_tagged_stream_to_pdu_1, pdus, blocks_socket_pdu_0, pdus]
- [blocks_throttle_0, '0', virtual_sink_0, '0']
- [blocks_vector_source_x_0, '0', blocks_stream_mux_0, '1']
@@ -1476,7 +1603,7 @@ connections:
- [digital_cma_equalizer_cc_0, '0', fir_filter_xxx_1, '0']
- [digital_cma_equalizer_cc_0, '0', qtgui_const_sink_x_0, '0']
- [digital_cma_equalizer_cc_0, '0', qtgui_time_sink_x_1_1, '0']
-- [digital_constellation_decoder_cb_0, '0', blocks_repack_bits_bb_0, '0']
+- [digital_constellation_decoder_cb_0, '0', blocks_tagged_stream_align_0, '0']
- [digital_constellation_modulator_0, '0', channels_channel_model_0, '0']
- [digital_constellation_modulator_0, '0', qtgui_time_sink_x_1_0, '0']
- [digital_corr_est_cc_0, '0', digital_costas_loop_cc_0, '0']
@@ -1486,6 +1613,7 @@ connections:
- [digital_costas_loop_cc_0, '0', qtgui_const_sink_x_0_0, '1']
- [digital_pfb_clock_sync_xxx_0, '0', digital_cma_equalizer_cc_0, '0']
- [epy_block_0, '0', qtgui_const_sink_x_0_0, '0']
+- [epy_block_0, '0', qtgui_time_sink_x_0, '0']
- [epy_block_0, '0', virtual_sink_3, '0']
- [fir_filter_xxx_1, '0', blocks_complex_to_magphase_0_0, '0']
- [virtual_source_0, '0', digital_pfb_clock_sync_xxx_0, '0']
diff --git a/tests/correlator/correlator.py b/tests/correlator/correlator.py
index a20d95c..f4760c5 100755
--- a/tests/correlator/correlator.py
+++ b/tests/correlator/correlator.py
@@ -7,7 +7,7 @@
# GNU Radio Python Flow Graph
# Title: Correlator Test
# Author: Naoki Pross
-# GNU Radio version: 3.9.2.0
+# GNU Radio version: 3.8.2.0
from distutils.version import StrictVersion
@@ -26,27 +26,25 @@ from gnuradio import qtgui
from gnuradio.filter import firdes
import sip
from gnuradio import blocks
+import numpy
from gnuradio import channels
from gnuradio import digital
from gnuradio import gr
-from gnuradio.fft import window
import sys
import signal
from argparse import ArgumentParser
from gnuradio.eng_arg import eng_float, intx
from gnuradio import eng_notation
-import correlator_epy_block_0 as epy_block_0 # embedded python block
-import correlator_epy_block_1 as epy_block_1 # embedded python block
+import epy_block_0
+import epy_block_1
import numpy as np
-
-
from gnuradio import qtgui
class correlator(gr.top_block, Qt.QWidget):
def __init__(self):
- gr.top_block.__init__(self, "Correlator Test", catch_exceptions=True)
+ gr.top_block.__init__(self, "Correlator Test")
Qt.QWidget.__init__(self)
self.setWindowTitle("Correlator Test")
qtgui.util.check_set_qss()
@@ -79,14 +77,15 @@ class correlator(gr.top_block, Qt.QWidget):
##################################################
# Variables
##################################################
+ self.testvec = testvec = [0x1f, 0x35] + [0x12, 0x48]
self.sps = sps = 4
self.nfilts = nfilts = 32
self.excess_bw = excess_bw = .35
self.timing_loop_bw = timing_loop_bw = 2 * np.pi / 100
- self.testvec = testvec = [0x1f, 0x35] + [0x12, 0x48]
self.samp_rate = samp_rate = int(1e6)
self.rrc_taps = rrc_taps = firdes.root_raised_cosine(nfilts, nfilts, 1.0/float(sps), excess_bw, 45*nfilts)
self.revconj_access_code_symbols = revconj_access_code_symbols = [(1.4142135623730951+1.4142135623730951j), (1.4142135623730951+1.4142135623730951j), (1.4142135623730951-1.4142135623730951j), (-1.4142135623730951+1.4142135623730951j), (1.4142135623730951-1.4142135623730951j), (1.4142135623730951-1.4142135623730951j), (1.4142135623730951+1.4142135623730951j), (-1.4142135623730951+1.4142135623730951j)]
+ self.frame_len = frame_len = len(testvec) + 4
self.const = const = digital.constellation_qpsk().base()
self.access_code_symbols = access_code_symbols = .5 * np.array([(-1.4142135623730951-1.4142135623730951j), (1.4142135623730951-1.4142135623730951j), (1.4142135623730951+1.4142135623730951j), (1.4142135623730951+1.4142135623730951j), (-1.4142135623730951-1.4142135623730951j), (1.4142135623730951+1.4142135623730951j), (1.4142135623730951-1.4142135623730951j), (1.4142135623730951-1.4142135623730951j)])
@@ -97,8 +96,7 @@ class correlator(gr.top_block, Qt.QWidget):
1024, #size
samp_rate, #samp_rate
"", #name
- 1, #number of inputs
- None # parent
+ 1 #number of inputs
)
self.qtgui_time_sink_x_1_0.set_update_time(0.10)
self.qtgui_time_sink_x_1_0.set_y_axis(-2, 2)
@@ -152,8 +150,7 @@ class correlator(gr.top_block, Qt.QWidget):
1024, #size
samp_rate / sps, #samp_rate
"", #name
- 1, #number of inputs
- None # parent
+ 1 #number of inputs
)
self.qtgui_time_sink_x_0_0_0.set_update_time(0.10)
self.qtgui_time_sink_x_0_0_0.set_y_axis(-2, 2)
@@ -198,13 +195,12 @@ class correlator(gr.top_block, Qt.QWidget):
self.qtgui_time_sink_x_0_0_0.set_line_alpha(i, alphas[i])
self._qtgui_time_sink_x_0_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0_0.pyqwidget(), Qt.QWidget)
- self.top_layout.addWidget(self._qtgui_time_sink_x_0_0_0_win)
+ self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_0_win)
self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f(
1024, #size
samp_rate / sps, #samp_rate
"", #name
- 1, #number of inputs
- None # parent
+ 1 #number of inputs
)
self.qtgui_time_sink_x_0_0.set_update_time(0.10)
self.qtgui_time_sink_x_0_0.set_y_axis(0, 20)
@@ -246,12 +242,61 @@ class correlator(gr.top_block, Qt.QWidget):
self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i])
self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget)
- self.top_layout.addWidget(self._qtgui_time_sink_x_0_0_win)
+ self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_win)
+ self.qtgui_time_sink_x_0 = qtgui.time_sink_c(
+ 1024, #size
+ samp_rate / sps, #samp_rate
+ "", #name
+ 1 #number of inputs
+ )
+ self.qtgui_time_sink_x_0.set_update_time(0.10)
+ self.qtgui_time_sink_x_0.set_y_axis(-1, 1)
+
+ self.qtgui_time_sink_x_0.set_y_label('Amplitude', "")
+
+ self.qtgui_time_sink_x_0.enable_tags(True)
+ self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "")
+ self.qtgui_time_sink_x_0.enable_autoscale(False)
+ self.qtgui_time_sink_x_0.enable_grid(False)
+ self.qtgui_time_sink_x_0.enable_axis_labels(True)
+ self.qtgui_time_sink_x_0.enable_control_panel(False)
+ self.qtgui_time_sink_x_0.enable_stem_plot(False)
+
+
+ labels = ['Signal 1', 'Signal 2', 'Signal 3', 'Signal 4', 'Signal 5',
+ 'Signal 6', 'Signal 7', 'Signal 8', 'Signal 9', 'Signal 10']
+ widths = [1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1]
+ colors = ['blue', 'red', 'green', 'black', 'cyan',
+ 'magenta', 'yellow', 'dark red', 'dark green', 'dark blue']
+ alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
+ 1.0, 1.0, 1.0, 1.0, 1.0]
+ styles = [1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1]
+ markers = [-1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1]
+
+
+ for i in range(2):
+ if len(labels[i]) == 0:
+ if (i % 2 == 0):
+ self.qtgui_time_sink_x_0.set_line_label(i, "Re{{Data {0}}}".format(i/2))
+ else:
+ self.qtgui_time_sink_x_0.set_line_label(i, "Im{{Data {0}}}".format(i/2))
+ else:
+ self.qtgui_time_sink_x_0.set_line_label(i, labels[i])
+ self.qtgui_time_sink_x_0.set_line_width(i, widths[i])
+ self.qtgui_time_sink_x_0.set_line_color(i, colors[i])
+ self.qtgui_time_sink_x_0.set_line_style(i, styles[i])
+ self.qtgui_time_sink_x_0.set_line_marker(i, markers[i])
+ self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i])
+
+ self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
+ self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win)
self.qtgui_const_sink_x_0_0 = qtgui.const_sink_c(
1024, #size
"Phase Locked Signal", #name
- 2, #number of inputs
- None # parent
+ 2 #number of inputs
)
self.qtgui_const_sink_x_0_0.set_update_time(0.10)
self.qtgui_const_sink_x_0_0.set_y_axis(-2, 2)
@@ -295,8 +340,7 @@ class correlator(gr.top_block, Qt.QWidget):
self.qtgui_const_sink_x_0 = qtgui.const_sink_c(
1024, #size
"Equalized Signal", #name
- 1, #number of inputs
- None # parent
+ 1 #number of inputs
)
self.qtgui_const_sink_x_0.set_update_time(0.10)
self.qtgui_const_sink_x_0.set_y_axis(-2, 2)
@@ -337,7 +381,7 @@ class correlator(gr.top_block, Qt.QWidget):
self.top_grid_layout.setRowStretch(r, 1)
for c in range(1, 2):
self.top_grid_layout.setColumnStretch(c, 1)
- self.epy_block_1 = epy_block_1.blk(vlen=len(testvec))
+ self.epy_block_1 = epy_block_1.blk(vlen=frame_len)
self.epy_block_0 = epy_block_0.blk()
self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(sps, timing_loop_bw, rrc_taps, nfilts, 16, 1.5, 1)
self.digital_costas_loop_cc_0 = digital.costas_loop_cc(2 * 3.141592653589793 / 100, 4, False)
@@ -349,13 +393,12 @@ class correlator(gr.top_block, Qt.QWidget):
pre_diff_code=True,
excess_bw=excess_bw,
verbose=False,
- log=False,
- truncate=False)
+ log=False)
self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(const)
self.digital_cma_equalizer_cc_0 = digital.cma_equalizer_cc(15, 1, .002, 1)
self.channels_channel_model_0 = channels.channel_model(
- noise_voltage=0.01,
- frequency_offset=0.0005,
+ noise_voltage=0.1,
+ frequency_offset=0.002,
epsilon=1.0,
taps=[np.exp(1j * 30 / 180 * np.pi)],
noise_seed=243,
@@ -363,31 +406,33 @@ class correlator(gr.top_block, Qt.QWidget):
self.blocks_vector_source_x_0 = blocks.vector_source_b(testvec * 10000, True, 1, [])
self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True)
self.blocks_tagged_stream_align_0 = blocks.tagged_stream_align(gr.sizeof_char*1, 'frame_start')
- self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_char*1, len(testvec))
- self.blocks_stream_mux_0 = blocks.stream_mux(gr.sizeof_char*1, [0, len(testvec)])
- self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(2, 4, "", False, gr.GR_LSB_FIRST)
+ self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_char*1, frame_len)
+ self.blocks_stream_mux_0 = blocks.stream_mux(gr.sizeof_char*1, [0, len(testvec), 4])
+ self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(2, 8, "", True, gr.GR_MSB_FIRST)
self.blocks_null_source_0 = blocks.null_source(gr.sizeof_char*1)
self.blocks_null_sink_3 = blocks.null_sink(gr.sizeof_float*1)
self.blocks_complex_to_magphase_0_0 = blocks.complex_to_magphase(1)
+ self.analog_random_source_x_0 = blocks.vector_source_b(list(map(int, numpy.random.randint(0, 255, 1000))), True)
##################################################
# Connections
##################################################
+ self.connect((self.analog_random_source_x_0, 0), (self.blocks_stream_mux_0, 2))
self.connect((self.blocks_complex_to_magphase_0_0, 1), (self.blocks_null_sink_3, 0))
self.connect((self.blocks_complex_to_magphase_0_0, 0), (self.qtgui_time_sink_x_0_0, 0))
self.connect((self.blocks_null_source_0, 0), (self.blocks_stream_mux_0, 0))
- self.connect((self.blocks_repack_bits_bb_0, 0), (self.blocks_tagged_stream_align_0, 0))
+ self.connect((self.blocks_repack_bits_bb_0, 0), (self.blocks_stream_to_vector_0, 0))
self.connect((self.blocks_stream_mux_0, 0), (self.digital_constellation_modulator_0, 0))
self.connect((self.blocks_stream_to_vector_0, 0), (self.epy_block_1, 0))
- self.connect((self.blocks_tagged_stream_align_0, 0), (self.blocks_stream_to_vector_0, 0))
+ self.connect((self.blocks_tagged_stream_align_0, 0), (self.blocks_repack_bits_bb_0, 0))
self.connect((self.blocks_throttle_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0))
self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_stream_mux_0, 1))
self.connect((self.channels_channel_model_0, 0), (self.blocks_throttle_0, 0))
self.connect((self.digital_cma_equalizer_cc_0, 0), (self.digital_corr_est_cc_0, 0))
self.connect((self.digital_cma_equalizer_cc_0, 0), (self.qtgui_const_sink_x_0, 0))
- self.connect((self.digital_constellation_decoder_cb_0, 0), (self.blocks_repack_bits_bb_0, 0))
+ self.connect((self.digital_constellation_decoder_cb_0, 0), (self.blocks_tagged_stream_align_0, 0))
self.connect((self.digital_constellation_modulator_0, 0), (self.channels_channel_model_0, 0))
self.connect((self.digital_constellation_modulator_0, 0), (self.qtgui_time_sink_x_1_0, 0))
self.connect((self.digital_corr_est_cc_0, 1), (self.blocks_complex_to_magphase_0_0, 0))
@@ -398,22 +443,29 @@ class correlator(gr.top_block, Qt.QWidget):
self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_cma_equalizer_cc_0, 0))
self.connect((self.epy_block_0, 0), (self.digital_constellation_decoder_cb_0, 0))
self.connect((self.epy_block_0, 0), (self.qtgui_const_sink_x_0_0, 0))
+ self.connect((self.epy_block_0, 0), (self.qtgui_time_sink_x_0, 0))
def closeEvent(self, event):
self.settings = Qt.QSettings("GNU Radio", "correlator")
self.settings.setValue("geometry", self.saveGeometry())
- self.stop()
- self.wait()
-
event.accept()
+ def get_testvec(self):
+ return self.testvec
+
+ def set_testvec(self, testvec):
+ self.testvec = testvec
+ self.set_frame_len(len(self.testvec) + 4)
+ self.blocks_vector_source_x_0.set_data(self.testvec * 10000, [])
+
def get_sps(self):
return self.sps
def set_sps(self, sps):
self.sps = sps
self.set_rrc_taps(firdes.root_raised_cosine(self.nfilts, self.nfilts, 1.0/float(self.sps), self.excess_bw, 45*self.nfilts))
+ self.qtgui_time_sink_x_0.set_samp_rate(self.samp_rate / self.sps)
self.qtgui_time_sink_x_0_0.set_samp_rate(self.samp_rate / self.sps)
self.qtgui_time_sink_x_0_0_0.set_samp_rate(self.samp_rate / self.sps)
@@ -438,19 +490,13 @@ class correlator(gr.top_block, Qt.QWidget):
self.timing_loop_bw = timing_loop_bw
self.digital_pfb_clock_sync_xxx_0.set_loop_bandwidth(self.timing_loop_bw)
- def get_testvec(self):
- return self.testvec
-
- def set_testvec(self, testvec):
- self.testvec = testvec
- self.blocks_vector_source_x_0.set_data(self.testvec * 10000, [])
-
def get_samp_rate(self):
return self.samp_rate
def set_samp_rate(self, samp_rate):
self.samp_rate = samp_rate
self.blocks_throttle_0.set_sample_rate(self.samp_rate)
+ self.qtgui_time_sink_x_0.set_samp_rate(self.samp_rate / self.sps)
self.qtgui_time_sink_x_0_0.set_samp_rate(self.samp_rate / self.sps)
self.qtgui_time_sink_x_0_0_0.set_samp_rate(self.samp_rate / self.sps)
self.qtgui_time_sink_x_1_0.set_samp_rate(self.samp_rate)
@@ -468,6 +514,12 @@ class correlator(gr.top_block, Qt.QWidget):
def set_revconj_access_code_symbols(self, revconj_access_code_symbols):
self.revconj_access_code_symbols = revconj_access_code_symbols
+ def get_frame_len(self):
+ return self.frame_len
+
+ def set_frame_len(self, frame_len):
+ self.frame_len = frame_len
+
def get_const(self):
return self.const
@@ -484,6 +536,7 @@ class correlator(gr.top_block, Qt.QWidget):
+
def main(top_block_cls=correlator, options=None):
if StrictVersion("4.5.0") <= StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"):
@@ -498,9 +551,6 @@ def main(top_block_cls=correlator, options=None):
tb.show()
def sig_handler(sig=None, frame=None):
- tb.stop()
- tb.wait()
-
Qt.QApplication.quit()
signal.signal(signal.SIGINT, sig_handler)
@@ -510,6 +560,11 @@ def main(top_block_cls=correlator, options=None):
timer.start(500)
timer.timeout.connect(lambda: None)
+ def quitting():
+ tb.stop()
+ tb.wait()
+
+ qapp.aboutToQuit.connect(quitting)
qapp.exec_()
if __name__ == '__main__':
diff --git a/tests/correlator/epy_block_0.py b/tests/correlator/epy_block_0.py
index a0b4cd9..85d02f0 100644
--- a/tests/correlator/epy_block_0.py
+++ b/tests/correlator/epy_block_0.py
@@ -28,6 +28,7 @@ class blk(gr.sync_block):
# of the previous block to correct the first values of the next block
self.last = None
self.lastfreq = 0
+
self.lastnback = 0
self.lastnsamples = 0
@@ -68,6 +69,7 @@ class blk(gr.sync_block):
def work(self, input_items, output_items):
counter = self.nitems_written(0)
+ print(f"Counter is at {counter} (nitems_written)")
# nicer aliases
inp = input_items[0]
@@ -75,7 +77,7 @@ class blk(gr.sync_block):
# read phase tags
is_phase = lambda tag: pmt.to_python(tag.key) == "phase_est"
- tags = list(filter(is_phase, self.get_tags_in_window(0, 0, len(inp))))
+ tags = list(filter(is_phase, self.get_tags_in_range(0, counter, counter + len(inp))))
if not tags:
print(f"There were no tags in {len(inp)} samples!")
@@ -105,10 +107,12 @@ class blk(gr.sync_block):
print(f"Processing {nfront} samples at the front of the buffer")
start = self.block_phase(self.last, tags[0])[-nfront:] \
if self.last and nfront else np.zeros(nfront)
+ # start = np.zeros(nfront)
# debugging
if nfront + self.lastnback != self.lastnsamples:
- print(f"Something went wrong: {self.lastnback + nfront} != self.lastnsamples")
+ print("Something went wrong: last back + front != chunk size,"\
+ f" {self.lastnback} + {nfront} != {self.lastnsamples}")
self.lastnback = nback
# compute correction
@@ -116,13 +120,19 @@ class blk(gr.sync_block):
length = len(correction)
# write outputs
- out[:length] = inp[:length] * correction
+ out[:] = inp * correction
# save last tag for next call
self.last = tags[-1]
- # add tags
- for tag in tags:
- self.add_item_tag(0, tag.offset, pmt.intern("frame_start"), pmt.PMT_T)
+ # corr_start phase tags
+ is_start = lambda tag: pmt.to_python(tag.key) == "corr_start"
+ start_tags = list(filter(is_start, \
+ self.get_tags_in_range(0, counter, counter + len(inp))))
+
+ for tag in start_tags:
+ self.add_item_tag(0, tag.offset +1, \
+ pmt.intern("frame_start"), pmt.from_long(8))
+ print(f"Writing {len(out)} samples")
return len(out)
diff --git a/tests/correlator/epy_block_1.py b/tests/correlator/epy_block_1.py
index 8ace6e4..2ee37fa 100644
--- a/tests/correlator/epy_block_1.py
+++ b/tests/correlator/epy_block_1.py
@@ -2,14 +2,12 @@ import numpy as np
from gnuradio import gr
# remove print for now
-print = lambda x: None
+# print = lambda x: None
np.set_printoptions(formatter={'int':hex})
class blk(gr.sync_block):
- def __init__(self, vlen=1):
- dt = np.byte if vlen == 1 else (np.byte, vlen)
-
+ def __init__(self, vlen=8):
gr.sync_block.__init__(
self,
name='Printer',