diff options
Diffstat (limited to '')
-rw-r--r-- | flowgraphs/qpsk_sim.grc | 3 | ||||
-rwxr-xr-x | flowgraphs/qpsk_sim.py | 2 | ||||
-rw-r--r-- | src/gr-fadingui/grc/fadingui_ber.block.yml | 7 | ||||
-rw-r--r-- | src/gr-fadingui/python/ber.py | 41 |
4 files changed, 46 insertions, 7 deletions
diff --git a/flowgraphs/qpsk_sim.grc b/flowgraphs/qpsk_sim.grc index a6afefa..b2ad25e 100644 --- a/flowgraphs/qpsk_sim.grc +++ b/flowgraphs/qpsk_sim.grc @@ -471,6 +471,7 @@ blocks: - name: fadingui_ber_0 id: fadingui_ber parameters: + address: udp://localhost:31415 affinity: '' alias: '' comment: '' @@ -480,7 +481,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 diff --git a/flowgraphs/qpsk_sim.py b/flowgraphs/qpsk_sim.py index 12a4894..52129ad 100755 --- a/flowgraphs/qpsk_sim.py +++ b/flowgraphs/qpsk_sim.py @@ -179,7 +179,7 @@ class qpsk_sim(gr.top_block, Qt.QWidget): self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_win) self.fadingui_phasecorrection_0 = fadingui.phasecorrection(frame_len) self.fadingui_multipath_fading_0 = fadingui.multipath_fading(amplitudes=[0.12], delays=[1.8], los =True) - self.fadingui_ber_0 = fadingui.ber(vgl=testvec + list(np.zeros(4)), vlen=frame_len) + self.fadingui_ber_0 = fadingui.ber(vgl=testvec + list(np.zeros(4)), vlen=frame_len,address='udp://localhost:31415') 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_corr_est_cc_0 = digital.corr_est_cc(access_code_symbols, 1, len(access_code_symbols) // 2, 0.9, digital.THRESHOLD_ABSOLUTE) self.digital_constellation_modulator_0 = digital.generic_mod( diff --git a/src/gr-fadingui/grc/fadingui_ber.block.yml b/src/gr-fadingui/grc/fadingui_ber.block.yml index 3070311..477f9ff 100644 --- a/src/gr-fadingui/grc/fadingui_ber.block.yml +++ b/src/gr-fadingui/grc/fadingui_ber.block.yml @@ -4,7 +4,7 @@ category: '[fadingui]' templates: imports: import fadingui - make: fadingui.ber(vgl=${vgl}, vlen=${vlen}) + 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: @@ -18,6 +18,11 @@ parameters: - id: vlen label: Vec Length dtype: int +- id: address + label: Address + dtype: string + default: "udp://localhost:31415" + # Make one 'inputs' list entry per input and one 'outputs' list entry per output. # Keys include: diff --git a/src/gr-fadingui/python/ber.py b/src/gr-fadingui/python/ber.py index 5b71f35..205dcd4 100644 --- a/src/gr-fadingui/python/ber.py +++ b/src/gr-fadingui/python/ber.py @@ -19,6 +19,8 @@ # Boston, MA 02110-1301, USA. # +import socket +from urllib.parse import urlparse import numpy as np from gnuradio import gr @@ -32,7 +34,7 @@ class ber(gr.sync_block): """ docstring for block ber """ - def __init__(self, vgl, vlen): + def __init__(self, vgl, vlen, address): gr.sync_block.__init__(self, name="ber", in_sig=[np.dtype(str(vlen) + "b")], @@ -40,9 +42,34 @@ class ber(gr.sync_block): self.vgl=vgl self.vlen=vlen + # Create a socket and parse remote machine url + self.socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) + self.url = urlparse(address) + self.srv = (self.url.hostname, self.url.port) + + + def send(self, data): + """ + Send the data to self.srv + + @param data Data as python bytes + @return Number of bytes that were actually sent + """ + assert type(data) == bytes + return self.socket.sendto(data, self.srv) + + def encode(self, data): + """ + Encode the data into a dead simple format + """ + # FIXME: this could be (very) slow, is there a faster way with numpy? + # Maybe numpy.array2string + return bytes(str(data) + "\n", "ascii") + + def work(self, input_items, output_items): - inp = input_items[0] + log.debug(f"Length: {len(inp)}") log.debug(f"Inp_vector:{inp}") @@ -52,7 +79,13 @@ class ber(gr.sync_block): ber = sum(np.unpackbits(v)) trueber = ber - 32 - log.debug(f"BER {trueber if trueber > 0 else 0} in Paket {i}") + if trueber < 0: + trueber = 0 + log.debug(f"BER {trueber} in Paket {i}") + + self.send(self.encode(trueber)) + + return len(inp) - return len(input_items[0]) + #return len(input_items[0]) |