aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--flowgraphs/qpsk_hw.grc12
-rwxr-xr-xflowgraphs/qpsk_hw.py4
-rw-r--r--flowgraphs/qpsk_sim.grc2
-rw-r--r--notebooks/BER .ipynb95
-rw-r--r--simulation/QAM/lena512color.tiffbin786572 -> 0 bytes
-rwxr-xr-xsimulation/QAM_Fading/qam_fading.py7
-rw-r--r--simulation/QAM_Fading/qam_fading_frequency_selectiv.grc207
-rw-r--r--src/gr-fadingui/grc/fadingui_ber.block.yml4
-rw-r--r--src/gr-fadingui/python/ber.py30
-rw-r--r--src/gr-fadingui/python/logger.py2
-rwxr-xr-xsrc/gui/gui.py15
-rw-r--r--src/gui/net.py25
12 files changed, 184 insertions, 219 deletions
diff --git a/flowgraphs/qpsk_hw.grc b/flowgraphs/qpsk_hw.grc
index 2ebc340..a0d6872 100644
--- a/flowgraphs/qpsk_hw.grc
+++ b/flowgraphs/qpsk_hw.grc
@@ -131,7 +131,7 @@ blocks:
id: variable
parameters:
comment: ''
- value: 1e6
+ value: 5e5
states:
bus_sink: false
bus_source: false
@@ -361,7 +361,7 @@ blocks:
minoutbuf: '0'
sps: '1'
symbols: access_code_symbols
- threshold: '0.85'
+ threshold: '0.7'
threshold_method: digital.THRESHOLD_ABSOLUTE
states:
bus_sink: false
@@ -386,7 +386,7 @@ blocks:
bus_sink: false
bus_source: false
bus_structure: null
- coordinate: [520, 1100.0]
+ coordinate: [520, 1084.0]
rotation: 0
state: enabled
- name: digital_pfb_clock_sync_xxx_0
@@ -424,7 +424,7 @@ blocks:
bus_sink: false
bus_source: false
bus_structure: null
- coordinate: [1184, 1300.0]
+ coordinate: [1184, 1292.0]
rotation: 0
state: true
- name: fadingui_datasource_0
@@ -1000,7 +1000,7 @@ blocks:
bus_sink: false
bus_source: false
bus_structure: null
- coordinate: [312, 692.0]
+ coordinate: [336, 684.0]
rotation: 0
state: true
- name: uhd_usrp_source_0
@@ -1450,7 +1450,7 @@ blocks:
bus_sink: false
bus_source: false
bus_structure: null
- coordinate: [56, 764.0]
+ coordinate: [80, 756.0]
rotation: 0
state: true
diff --git a/flowgraphs/qpsk_hw.py b/flowgraphs/qpsk_hw.py
index eb6bf70..9db06a3 100755
--- a/flowgraphs/qpsk_hw.py
+++ b/flowgraphs/qpsk_hw.py
@@ -81,7 +81,7 @@ class qpsk_hw(gr.top_block, Qt.QWidget):
self.sps = sps = 4
self.nfilts = nfilts = 32
self.excess_bw = excess_bw = 0.35
- self.samp_rate = samp_rate = 1e6
+ self.samp_rate = samp_rate = 5e5
self.rrc_taps = rrc_taps = firdes.root_raised_cosine(nfilts, nfilts, 1.0/float(sps), excess_bw, 45*nfilts)
self.qpsk_const = qpsk_const = digital.constellation_qpsk().base()
self.frame_len = frame_len = len(testvec) +4
@@ -210,7 +210,7 @@ class qpsk_hw(gr.top_block, Qt.QWidget):
self.fadingui_ber_0 = fadingui.ber(vgl=testvec + list(np.zeros(4)), vlen=frame_len)
self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(sps, 2 * np.pi / 100, rrc_taps, 32, 16, 1.5, 1)
self.digital_lms_dd_equalizer_cc_0 = digital.lms_dd_equalizer_cc(15, 3e-3, 1, qpsk_const)
- self.digital_corr_est_cc_0 = digital.corr_est_cc(access_code_symbols, 1, len(access_code_symbols) // 2, 0.85, digital.THRESHOLD_ABSOLUTE)
+ self.digital_corr_est_cc_0 = digital.corr_est_cc(access_code_symbols, 1, len(access_code_symbols) // 2, 0.7, digital.THRESHOLD_ABSOLUTE)
self.digital_constellation_modulator_0 = digital.generic_mod(
constellation=qpsk_const,
differential=False,
diff --git a/flowgraphs/qpsk_sim.grc b/flowgraphs/qpsk_sim.grc
index db8f2be..ea9518b 100644
--- a/flowgraphs/qpsk_sim.grc
+++ b/flowgraphs/qpsk_sim.grc
@@ -433,7 +433,7 @@ blocks:
bus_sink: false
bus_source: false
bus_structure: null
- coordinate: [600, 572.0]
+ coordinate: [592, 572.0]
rotation: 0
state: enabled
- name: digital_cma_equalizer_cc_0
diff --git a/notebooks/BER .ipynb b/notebooks/BER .ipynb
index 57675f1..fa70396 100644
--- a/notebooks/BER .ipynb
+++ b/notebooks/BER .ipynb
@@ -134,7 +134,7 @@
},
{
"cell_type": "code",
- "execution_count": 12,
+ "execution_count": 8,
"id": "fc4fef77",
"metadata": {},
"outputs": [
@@ -144,7 +144,7 @@
"20"
]
},
- "execution_count": 12,
+ "execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
@@ -156,7 +156,7 @@
},
{
"cell_type": "code",
- "execution_count": 13,
+ "execution_count": 9,
"id": "74ae964c",
"metadata": {},
"outputs": [
@@ -166,7 +166,7 @@
"array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0])"
]
},
- "execution_count": 13,
+ "execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
@@ -178,7 +178,7 @@
},
{
"cell_type": "code",
- "execution_count": 14,
+ "execution_count": 10,
"id": "5a1d95f1",
"metadata": {},
"outputs": [
@@ -205,9 +205,92 @@
]
},
{
+ "cell_type": "markdown",
+ "id": "6e96c7bf",
+ "metadata": {},
+ "source": [
+ "# Test meister Wert \n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 24,
+ "id": "90d18368",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Length: 10\n",
+ "Inp_vector:[31, 53, 18, 227, 155, 238, 132, 35, 65, 243]\n",
+ "BER 6 in Paket 31\n",
+ "BER 6 in Paket 53\n",
+ "BER 4 in Paket 18\n",
+ "BER 2 in Paket 227\n",
+ "BER 4 in Paket 155\n",
+ "BER 12 in Paket 238\n",
+ "BER 10 in Paket 132\n",
+ "BER 0 in Paket 35\n",
+ "BER 6 in Paket 65\n",
+ "BER 2 in Paket 243\n"
+ ]
+ }
+ ],
+ "source": [
+ "inp = ([31, 53,0x12, 0xe3, 0x9b, 0xee, 0x84, 0x23, 0x41, 0xf3])\n",
+ "#inp[1] = ([31, 53,0x12, 0xe5, 0x9b, 0xee, 0x84, 0x23, 0x41, 0xf3])\n",
+ "#inp[2] = ([31, 53,0x13, 0xe3, 0x9b, 0xee, 0x84, 0x23, 0x41, 0xf3])\n",
+ "\n",
+ "vgl = ([31, 53] + [0x12, 0xe3, 0x9b, 0xee, 0x84, 0x23, 0x41, 0xf3])\n",
+ "\n",
+ "\n",
+ "print(f\"Length: {len(inp)}\")\n",
+ "print(f\"Inp_vector:{inp}\")\n",
+ " \n",
+ "for i in inp:\n",
+ " i = np.array(i, dtype=np.uint8)\n",
+ " v = np.array(vgl, dtype=np.uint8) ^ i\n",
+ " ber = sum(np.unpackbits(v))\n",
+ "\n",
+ " trueber = ber - 32\n",
+ " if trueber < 0:\n",
+ " trueber = 0\n",
+ " print(f\"BER {trueber} in Paket {i}\")\n",
+ "\n",
+ " #print(f\"max BER {np.max(trueber)} in Paket {i}\")\n",
+ " \n",
+ " #self.send(self.encode(trueber))"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "72ca6e60",
+ "metadata": {},
+ "outputs": [],
+ "source": []
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "3a891089",
+ "metadata": {},
+ "outputs": [],
+ "source": []
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "6489bfcc",
+ "metadata": {},
+ "outputs": [],
+ "source": []
+ },
+ {
"cell_type": "code",
"execution_count": null,
- "id": "038ceffa",
+ "id": "fda1e417",
"metadata": {},
"outputs": [],
"source": []
diff --git a/simulation/QAM/lena512color.tiff b/simulation/QAM/lena512color.tiff
deleted file mode 100644
index ffe5c83..0000000
--- a/simulation/QAM/lena512color.tiff
+++ /dev/null
Binary files differ
diff --git a/simulation/QAM_Fading/qam_fading.py b/simulation/QAM_Fading/qam_fading.py
index 56a3847..cc1bd08 100755
--- a/simulation/QAM_Fading/qam_fading.py
+++ b/simulation/QAM_Fading/qam_fading.py
@@ -76,7 +76,7 @@ class qam_fading(gr.top_block, Qt.QWidget):
##################################################
# Variables
##################################################
- self.sps = sps = 2
+ self.sps = sps = 4
self.nfilts = nfilts = 32
self.excess_bw = excess_bw = 350e-3
self.timing_loop_bw = timing_loop_bw = 2 * 3.141592653589793 / 100
@@ -91,8 +91,7 @@ class qam_fading(gr.top_block, Qt.QWidget):
self.eq_ntaps = eq_ntaps = 15
self.eq_mod = eq_mod = 1
self.eq_gain = eq_gain = .01
- self.const = const = digital.constellation_calcdist([-1-1j, -1+1j, 1+1j, 1-1j], [0, 1, 3, 2],
- 4, 1).base()
+ self.const = const = digital.constellation_qpsk().base()
self.chn_taps = chn_taps = [1.0 + 0.0j, ]
##################################################
@@ -467,7 +466,7 @@ class qam_fading(gr.top_block, Qt.QWidget):
self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(const)
self.digital_cma_equalizer_cc_0_0 = digital.cma_equalizer_cc(eq_ntaps, eq_mod, eq_gain, 2)
self.digital_cma_equalizer_cc_0 = digital.cma_equalizer_cc(eq_ntaps, eq_mod, eq_gain, 2)
- self.channels_selective_fading_model_0 = channels.selective_fading_model( 8, ((2*fc*1e9)/(3*10e8))/samp_rate, False, 4, 0, (0,1.8), (1,0.12), 8 )
+ self.channels_selective_fading_model_0 = channels.selective_fading_model( 8, ((2*fc*1e9)/(3*10e8))/samp_rate, False, 4, 21, (0,1.8), (1,0.12), 8 )
self.channels_channel_model_0 = channels.channel_model(
noise_voltage=noise_volt,
frequency_offset=freq_offset,
diff --git a/simulation/QAM_Fading/qam_fading_frequency_selectiv.grc b/simulation/QAM_Fading/qam_fading_frequency_selectiv.grc
index 02948d2..109a74d 100644
--- a/simulation/QAM_Fading/qam_fading_frequency_selectiv.grc
+++ b/simulation/QAM_Fading/qam_fading_frequency_selectiv.grc
@@ -54,7 +54,7 @@ blocks:
rot_sym: '4'
soft_dec_lut: None
sym_map: '[0, 1, 3, 2]'
- type: calcdist
+ type: qpsk
states:
bus_sink: false
bus_source: false
@@ -127,11 +127,11 @@ blocks:
label: fc
min_len: '200'
orient: Qt.Horizontal
- rangeType: int
+ rangeType: float
start: '0'
step: '1'
- stop: '1000000000'
- value: '1'
+ stop: '10'
+ value: '2.4'
widget: counter_slider
states:
bus_sink: false
@@ -243,7 +243,7 @@ blocks:
id: variable
parameters:
comment: ''
- value: '2'
+ value: '4'
states:
bus_sink: false
bus_source: false
@@ -411,28 +411,9 @@ blocks:
bus_sink: false
bus_source: false
bus_structure: null
- coordinate: [464, 324.0]
+ coordinate: [480, 356.0]
rotation: 0
state: enabled
-- name: blocks_throttle_0_0
- id: blocks_throttle
- parameters:
- affinity: ''
- alias: ''
- comment: ''
- ignoretag: 'True'
- maxoutbuf: '0'
- minoutbuf: '0'
- samples_per_second: samp_rate
- type: byte
- vlen: '1'
- states:
- bus_sink: false
- bus_source: false
- bus_structure: null
- coordinate: [240, 204.0]
- rotation: 0
- state: bypassed
- name: blocks_unpack_k_bits_bb_0
id: blocks_unpack_k_bits_bb
parameters:
@@ -522,20 +503,20 @@ blocks:
coordinate: [648, 316.0]
rotation: 0
state: enabled
-- name: channels_selective_fading_model2_0
+- name: channels_selective_fading_model2_1
id: channels_selective_fading_model2
parameters:
- K: '5.1'
+ K: '4.0'
LOS: 'False'
N: '8'
affinity: ''
alias: ''
comment: ''
- delay_maxdev: (0.5,0.7)
- delay_std: (1e-4,1e-4)
- delays: (0,2e-5/samp_rate)
- fDTs: ((4*fc)/(3*10e8))/samp_rate
- mags: (1,0.12)
+ delay_maxdev: (0.5,0.7,0.9)
+ delay_std: (1e-4,1e-4,1e-4)
+ delays: (1.0,1.9,2.7)
+ fDTs: 0.2/samp_rate
+ mags: (1,0.95,0.8)
maxoutbuf: '0'
minoutbuf: '0'
ntaps: '8'
@@ -544,7 +525,7 @@ blocks:
bus_sink: false
bus_source: false
bus_structure: null
- coordinate: [904, 292.0]
+ coordinate: [888, 276.0]
rotation: 0
state: disabled
- name: channels_selective_fading_model_0
@@ -556,18 +537,18 @@ blocks:
affinity: ''
alias: ''
comment: ''
- delays: (0,2e-5/samp_rate)
- fDTs: ((4*fc)/(3*10e8))/samp_rate
+ delays: (0,1.8)
+ fDTs: ((2*fc*1e9)/(3*10e8))/samp_rate
mags: (1,0.12)
maxoutbuf: '0'
minoutbuf: '0'
ntaps: '8'
- seed: '0'
+ seed: '21'
states:
bus_sink: false
bus_source: false
bus_structure: null
- coordinate: [968, 468.0]
+ coordinate: [976, 404.0]
rotation: 0
state: enabled
- name: channels_selective_fading_model_2
@@ -684,26 +665,6 @@ blocks:
coordinate: [240, 332.0]
rotation: 0
state: enabled
-- name: digital_constellation_receiver_cb_0
- id: digital_constellation_receiver_cb
- parameters:
- affinity: ''
- alias: ''
- comment: ''
- constellation: const
- fmax: '1'
- fmin: '1.5'
- loop_bw: timing_loop_bw
- maxoutbuf: '0'
- minoutbuf: '0'
- showports: 'False'
- states:
- bus_sink: false
- bus_source: false
- bus_structure: null
- coordinate: [1376, -64.0]
- rotation: 0
- state: disabled
- name: digital_costas_loop_cc_0
id: digital_costas_loop_cc
parameters:
@@ -850,25 +811,6 @@ blocks:
coordinate: [1088, 868.0]
rotation: 0
state: true
-- name: fir_filter_xxx_0
- id: fir_filter_xxx
- parameters:
- affinity: ''
- alias: ''
- comment: ''
- decim: '1'
- maxoutbuf: '0'
- minoutbuf: '0'
- samp_delay: '0'
- taps: rrc_taps
- type: ccc
- states:
- bus_sink: false
- bus_source: false
- bus_structure: null
- coordinate: [488, 212.0]
- rotation: 0
- state: bypassed
- name: import_0
id: import
parameters:
@@ -1318,98 +1260,6 @@ blocks:
coordinate: [2188.0, 0]
rotation: 90
state: enabled
-- name: qtgui_const_sink_x_3
- id: qtgui_const_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: '"red"'
- color2: '"red"'
- color3: '"red"'
- color4: '"red"'
- color5: '"red"'
- color6: '"red"'
- color7: '"red"'
- color8: '"red"'
- color9: '"red"'
- comment: ''
- grid: 'False'
- gui_hint: ''
- label1: ''
- label10: ''
- label2: ''
- label3: ''
- label4: ''
- label5: ''
- label6: ''
- label7: ''
- label8: ''
- label9: ''
- legend: 'True'
- marker1: '0'
- marker10: '0'
- marker2: '0'
- marker3: '0'
- marker4: '0'
- marker5: '0'
- marker6: '0'
- marker7: '0'
- marker8: '0'
- marker9: '0'
- name: '""'
- nconnections: '1'
- size: '1024'
- style1: '0'
- style10: '0'
- style2: '0'
- style3: '0'
- style4: '0'
- style5: '0'
- style6: '0'
- style7: '0'
- style8: '0'
- style9: '0'
- tr_chan: '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'
- xmax: '2'
- xmin: '-2'
- ymax: '2'
- ymin: '-2'
- states:
- bus_sink: false
- bus_source: false
- bus_structure: null
- coordinate: [344, 660.0]
- rotation: 0
- state: true
- name: qtgui_freq_sink_x_0
id: qtgui_freq_sink_x
parameters:
@@ -1669,30 +1519,28 @@ blocks:
state: true
connections:
-- [analog_random_source_x_0, '0', blocks_throttle_0_0, '0']
- [analog_random_source_x_0, '0', blocks_unpack_k_bits_bb_0_0, '0']
+- [analog_random_source_x_0, '0', digital_constellation_modulator_0, '0']
- [blocks_char_to_float_0, '0', qtgui_freq_sink_x_2_1, '0']
- [blocks_char_to_float_0, '0', qtgui_time_sink_x_0, '0']
- [blocks_char_to_float_0_0, '0', blocks_delay_0, '0']
- [blocks_char_to_float_0_1, '0', qtgui_freq_sink_x_2_1, '1']
- [blocks_char_to_float_0_1, '0', qtgui_time_sink_x_0, '2']
- [blocks_delay_0, '0', qtgui_time_sink_x_0, '1']
-- [blocks_throttle_0, '0', fir_filter_xxx_0, '0']
-- [blocks_throttle_0_0, '0', digital_constellation_modulator_0, '0']
+- [blocks_throttle_0, '0', channels_channel_model_0, '0']
- [blocks_unpack_k_bits_bb_0, '0', blocks_char_to_float_0, '0']
- [blocks_unpack_k_bits_bb_0_0, '0', blocks_char_to_float_0_0, '0']
- [blocks_unpack_k_bits_bb_0_1, '0', blocks_char_to_float_0_1, '0']
- [blocks_vector_source_x_0, '0', digital_constellation_modulator_0, '0']
-- [channels_channel_model_0, '0', channels_selective_fading_model2_0, '0']
+- [channels_channel_model_0, '0', channels_selective_fading_model2_1, '0']
- [channels_channel_model_0, '0', channels_selective_fading_model_0, '0']
- [channels_channel_model_0, '0', channels_selective_fading_model_2, '0']
- [channels_channel_model_0, '0', digital_pfb_clock_sync_xxx_0_0, '0']
- [channels_channel_model_0, '0', qtgui_const_sink_x_0, '1']
- [channels_channel_model_0, '0', qtgui_freq_sink_x_0, '1']
-- [channels_selective_fading_model2_0, '0', digital_pfb_clock_sync_xxx_0, '0']
-- [channels_selective_fading_model2_0, '0', qtgui_const_sink_x_0, '0']
-- [channels_selective_fading_model2_0, '0', qtgui_freq_sink_x_0, '0']
-- [channels_selective_fading_model_0, '0', digital_constellation_receiver_cb_0, '0']
+- [channels_selective_fading_model2_1, '0', digital_pfb_clock_sync_xxx_0, '0']
+- [channels_selective_fading_model2_1, '0', qtgui_const_sink_x_0, '0']
+- [channels_selective_fading_model2_1, '0', qtgui_freq_sink_x_0, '0']
- [channels_selective_fading_model_0, '0', digital_pfb_clock_sync_xxx_0, '0']
- [channels_selective_fading_model_0, '0', qtgui_const_sink_x_0, '0']
- [channels_selective_fading_model_0, '0', qtgui_freq_sink_x_0, '0']
@@ -1706,12 +1554,6 @@ connections:
- [digital_constellation_decoder_cb_0, '0', digital_diff_decoder_bb_0, '0']
- [digital_constellation_decoder_cb_0_0, '0', digital_diff_decoder_bb_0_0, '0']
- [digital_constellation_modulator_0, '0', blocks_throttle_0, '0']
-- [digital_constellation_modulator_0, '0', qtgui_const_sink_x_3, '0']
-- [digital_constellation_receiver_cb_0, '0', digital_diff_decoder_bb_0, '0']
-- [digital_constellation_receiver_cb_0, '4', digital_cma_equalizer_cc_0, '0']
-- [digital_constellation_receiver_cb_0, '4', qtgui_const_sink_x_0_0, '0']
-- [digital_constellation_receiver_cb_0, '4', qtgui_const_sink_x_1, '0']
-- [digital_constellation_receiver_cb_0, '4', qtgui_const_sink_x_2, '0']
- [digital_costas_loop_cc_0, '0', digital_constellation_decoder_cb_0, '0']
- [digital_costas_loop_cc_0, '0', qtgui_const_sink_x_2, '0']
- [digital_costas_loop_cc_0_0, '0', digital_constellation_decoder_cb_0_0, '0']
@@ -1724,7 +1566,6 @@ connections:
- [digital_pfb_clock_sync_xxx_0, '0', qtgui_const_sink_x_0_0, '0']
- [digital_pfb_clock_sync_xxx_0_0, '0', digital_cma_equalizer_cc_0_0, '0']
- [digital_pfb_clock_sync_xxx_0_0, '0', qtgui_const_sink_x_0_0, '1']
-- [fir_filter_xxx_0, '0', channels_channel_model_0, '0']
metadata:
file_format: 1
diff --git a/src/gr-fadingui/grc/fadingui_ber.block.yml b/src/gr-fadingui/grc/fadingui_ber.block.yml
index 477f9ff..b0ec75c 100644
--- a/src/gr-fadingui/grc/fadingui_ber.block.yml
+++ b/src/gr-fadingui/grc/fadingui_ber.block.yml
@@ -5,7 +5,7 @@ category: '[fadingui]'
templates:
imports: import fadingui
make: fadingui.ber(vgl=${vgl}, vlen=${vlen},address=${address})
-
+
# Make one 'parameters' list entry for every parameter you want settable from the GUI.
# Keys include:
# * id (makes the value accessible as \$keyname, e.g. in the make entry)
@@ -21,7 +21,7 @@ parameters:
- id: address
label: Address
dtype: string
- default: "udp://localhost:31415"
+ default: "udp://localhost:31420"
# Make one 'inputs' list entry per input and one 'outputs' list entry per output.
diff --git a/src/gr-fadingui/python/ber.py b/src/gr-fadingui/python/ber.py
index 205dcd4..664780f 100644
--- a/src/gr-fadingui/python/ber.py
+++ b/src/gr-fadingui/python/ber.py
@@ -23,6 +23,7 @@ import socket
from urllib.parse import urlparse
import numpy as np
+from numpy_ringbuffer import RingBuffer
from gnuradio import gr
from fadingui.logger import get_logger
@@ -42,6 +43,9 @@ class ber(gr.sync_block):
self.vgl=vgl
self.vlen=vlen
+ self.ber_samples = RingBuffer(capacity=100, dtype=int)
+ self.ber_samples.extend(np.zeros(self.ber_samples.maxlen))
+
# Create a socket and parse remote machine url
self.socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
self.url = urlparse(address)
@@ -65,14 +69,21 @@ class ber(gr.sync_block):
# FIXME: this could be (very) slow, is there a faster way with numpy?
# Maybe numpy.array2string
return bytes(str(data) + "\n", "ascii")
-
+
+ def ber_stats(self):
+ ber_max = np.max(self.ber_samples)
+ ber_min = np.min(self.ber_samples)
+ ber_avg = np.sum(self.ber_samples) / self.ber_samples.maxlen
+
+ return ber_max, ber_min, ber_avg
+
def work(self, input_items, output_items):
inp = input_items[0]
log.debug(f"Length: {len(inp)}")
- log.debug(f"Inp_vector:{inp}")
-
+ # log.debug(f"Inp_vector:{inp}")
+
for i in inp:
i = np.array(i, dtype=np.uint8)
v = np.array(self.vgl, dtype=np.uint8) ^ i
@@ -81,11 +92,16 @@ class ber(gr.sync_block):
trueber = ber - 32
if trueber < 0:
trueber = 0
- log.debug(f"BER {trueber} in Paket {i}")
-
- self.send(self.encode(trueber))
+ # log.debug(f"BER {trueber} in Paket {i}")
- return len(inp)
+ self.ber_samples.appendleft(trueber)
+
+
+ ber_max, ber_min, ber_avg = self.ber_stats()
+ log.debug(f"Statistics: {ber_max}, {ber_min}, {ber_avg}")
+ self.send(self.encode([trueber, ber_max, ber_avg]))
+
+ return len(inp)
#return len(input_items[0])
diff --git a/src/gr-fadingui/python/logger.py b/src/gr-fadingui/python/logger.py
index a101b9e..a189aeb 100644
--- a/src/gr-fadingui/python/logger.py
+++ b/src/gr-fadingui/python/logger.py
@@ -10,5 +10,5 @@ def get_logger(module):
log.addHandler(stdout_handler)
stdout_handler.setFormatter(formatter)
- log.setLevel(logging.WARNING)
+ log.setLevel(logging.DEBUG)
return log
diff --git a/src/gui/gui.py b/src/gui/gui.py
index b298fd8..7e2357b 100755
--- a/src/gui/gui.py
+++ b/src/gui/gui.py
@@ -249,12 +249,18 @@ with window(label="Bit Error Rate ", width=300, height=150, pos=(200,875)) as be
add_theme_color(mvThemeCol_Text,(0,0,0)) #Schwarz
add_theme_style(mvStyleVar_FrameRounding, 5)
- add_button(label="BER", height=60, width=150,pos=(75,60))
- bind_item_theme(last_item(),"button_ber")
+ add_button(label="BER", height=60, width=-1, tag="ber_value")
+ bind_item_theme(last_item(), "button_ber")
# bind_item_theme(ber_window, "ber_window")
# bind_item_font(ber_window, test)
+def set_ber(values):
+ ber_curr, ber_max, ber_avg = values
+ configure_item("ber_value", label=f"Current: {ber_curr}, Max: {ber_max}, Avg: {ber_avg}")
+
+ber_value = net.network_value(url="udp://localhost:31420", dtype=float, refresh_func=set_ber)
+
#================================================
# Picture Window
@@ -278,8 +284,9 @@ set_primary_window("primary_window", True)
# Main loop
while is_dearpygui_running():
- for plt in network_plots:
- plt.refresh_series(plt.series_tag)
+ for plt, tag in network_plots.items():
+ plt.refresh_series(tag)
+ ber_value.refresh()
render_dearpygui_frame()
diff --git a/src/gui/net.py b/src/gui/net.py
index 1ddb1d0..820bc84 100644
--- a/src/gui/net.py
+++ b/src/gui/net.py
@@ -13,10 +13,12 @@ class udpsource:
"""
Creates an UDP listening socket
"""
- def __init__(self, url, dtype, timeout=0.05):
+ def __init__(self, url, dtype, timeout=0.05, blocksize=1024):
+ self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
self.url = urlparse(url)
self.dtype = dtype
self.timeout = timeout
+ self.blocksize = blocksize
if self.url.scheme == "udp":
self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
@@ -50,8 +52,7 @@ class udpsource:
return None
# read from socket
- blocksize = 1024
- string = ready[0].recv(nblocks * blocksize).decode("ascii")
+ string = ready[0].recv(nblocks * self.blocksize).decode("ascii")
# decode string, remove empty values
chunks = filter(None, re.split(r"\[(.+?)\]", string))
@@ -72,6 +73,24 @@ class udpsource:
return values
+class network_value(udpsource):
+ def __init__(self, url, dtype, refresh_func):
+ udpsource.__init__(self, url, dtype, blocksize=16)
+
+ self._refresh = refresh_func
+ self.value = None
+
+ self.bind()
+
+ def read(self):
+ return udpsource.read(self, 1)
+
+ def refresh(self):
+ self.value = self.read()
+ if self.value:
+ self._refresh(self.value)
+
+
class network_plot(udpsource):
"""
Wraps a udpsource while at the same time intefacing with DearPyGUI as a plot element.