diff options
Diffstat (limited to 'tests/sockets')
-rw-r--r-- | tests/sockets/Socket_test.grc | 140 | ||||
-rwxr-xr-x | tests/sockets/Test_Bit_Errorrate.py | 80 | ||||
-rw-r--r-- | tests/sockets/send.py | 21 |
3 files changed, 241 insertions, 0 deletions
diff --git a/tests/sockets/Socket_test.grc b/tests/sockets/Socket_test.grc new file mode 100644 index 0000000..fbc3cdf --- /dev/null +++ b/tests/sockets/Socket_test.grc @@ -0,0 +1,140 @@ +options: + parameters: + author: 'Sara Halter ' + category: '[GRC Hier Blocks]' + cmake_opt: '' + comment: '' + copyright: '' + description: '' + gen_cmake: 'On' + gen_linking: dynamic + generate_options: no_gui + hier_block_src_path: '.:' + id: Test_Bit_Errorrate + max_nouts: '0' + output_language: python + placement: (0,0) + qt_qss_theme: '' + realtime_scheduling: '' + run: 'True' + run_command: '{python} -u {filename}' + run_options: run + sizing_mode: fixed + thread_safe_setters: '' + title: 'Bit Error Rate test ' + window_size: '' + states: + bus_sink: false + bus_source: false + bus_structure: null + coordinate: [8, 8] + rotation: 0 + state: enabled + +blocks: +- name: samp_rate + id: variable + parameters: + comment: '' + value: '32000' + states: + bus_sink: false + bus_source: false + bus_structure: null + coordinate: [216, 20.0] + rotation: 0 + state: enabled +- name: analog_noise_source_x_0 + id: analog_noise_source_x + parameters: + affinity: '' + alias: '' + amp: '1' + comment: '' + maxoutbuf: '0' + minoutbuf: '0' + noise_type: analog.GR_GAUSSIAN + seed: '0' + type: float + states: + bus_sink: false + bus_source: false + bus_structure: null + coordinate: [32, 148.0] + rotation: 0 + state: enabled +- name: blocks_null_source_0 + id: blocks_null_source + parameters: + affinity: '' + alias: '' + bus_structure_source: '[[0,],]' + comment: '' + maxoutbuf: '0' + minoutbuf: '0' + num_outputs: '1' + type: complex + vlen: '1' + states: + bus_sink: false + bus_source: false + bus_structure: null + coordinate: [64, 264.0] + rotation: 0 + state: disabled +- name: blocks_throttle_1 + id: blocks_throttle + parameters: + affinity: '' + alias: '' + comment: '' + ignoretag: 'True' + maxoutbuf: '0' + minoutbuf: '0' + samples_per_second: samp_rate + type: float + vlen: '1' + states: + bus_sink: false + bus_source: false + bus_structure: null + coordinate: [280, 164.0] + rotation: 0 + state: true +- name: fadingui_netsink_0 + id: fadingui_netsink + parameters: + address: udp://localhost:31415 + affinity: '' + alias: '' + comment: '' + type: float + veclen: '1' + states: + bus_sink: false + bus_source: false + bus_structure: null + coordinate: [504, 164.0] + rotation: 0 + state: true +- name: import_0 + id: import + parameters: + alias: '' + comment: '' + imports: import numpy as np + states: + bus_sink: false + bus_source: false + bus_structure: null + coordinate: [328, 20.0] + rotation: 0 + state: true + +connections: +- [analog_noise_source_x_0, '0', blocks_throttle_1, '0'] +- [blocks_null_source_0, '0', blocks_throttle_1, '0'] +- [blocks_throttle_1, '0', fadingui_netsink_0, '0'] + +metadata: + file_format: 1 diff --git a/tests/sockets/Test_Bit_Errorrate.py b/tests/sockets/Test_Bit_Errorrate.py new file mode 100755 index 0000000..6a989df --- /dev/null +++ b/tests/sockets/Test_Bit_Errorrate.py @@ -0,0 +1,80 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +# +# SPDX-License-Identifier: GPL-3.0 +# +# GNU Radio Python Flow Graph +# Title: Bit Error Rate test +# Author: Sara Halter +# GNU Radio version: 3.8.2.0 + +from gnuradio import analog +from gnuradio import blocks +from gnuradio import gr +from gnuradio.filter import firdes +import sys +import signal +from argparse import ArgumentParser +from gnuradio.eng_arg import eng_float, intx +from gnuradio import eng_notation +import fadingui +import numpy as np + + +class Test_Bit_Errorrate(gr.top_block): + + def __init__(self): + gr.top_block.__init__(self, "Bit Error Rate test ") + + ################################################## + # Variables + ################################################## + self.samp_rate = samp_rate = 32000 + + ################################################## + # Blocks + ################################################## + self.fadingui_netsink_0 = fadingui.netsink(address='udp://localhost:31415', dtype="float", vlen=1) + self.blocks_throttle_1 = blocks.throttle(gr.sizeof_float*1, samp_rate,True) + self.analog_noise_source_x_0 = analog.noise_source_f(analog.GR_GAUSSIAN, 1, 0) + + + + ################################################## + # Connections + ################################################## + self.connect((self.analog_noise_source_x_0, 0), (self.blocks_throttle_1, 0)) + self.connect((self.blocks_throttle_1, 0), (self.fadingui_netsink_0, 0)) + + + def get_samp_rate(self): + return self.samp_rate + + def set_samp_rate(self, samp_rate): + self.samp_rate = samp_rate + self.blocks_throttle_1.set_sample_rate(self.samp_rate) + + + + + +def main(top_block_cls=Test_Bit_Errorrate, options=None): + tb = top_block_cls() + + def sig_handler(sig=None, frame=None): + tb.stop() + tb.wait() + + sys.exit(0) + + signal.signal(signal.SIGINT, sig_handler) + signal.signal(signal.SIGTERM, sig_handler) + + tb.start() + + tb.wait() + + +if __name__ == '__main__': + main() diff --git a/tests/sockets/send.py b/tests/sockets/send.py new file mode 100644 index 0000000..87faf5d --- /dev/null +++ b/tests/sockets/send.py @@ -0,0 +1,21 @@ +import socket +from urllib.parse import urlparse + +import numpy as np + +remote = "upd://localhost:31415" +url = urlparse(remote) + +print(url.hostname) +print(url.port) + +sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) +sock.connect((url.hostname, url.port)) + +# sent some text +sock.send(bytes("hello", "ascii")) + +arr = np.arange(0, 10) +print(arr) + +sock.send(arr.tobytes()) |