aboutsummaryrefslogtreecommitdiffstats
path: root/tests/sockets
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--tests/sockets/Socket_test.grc (renamed from tests/zmq/zmqtest.grc)92
-rwxr-xr-xtests/sockets/Test_Bit_Errorrate.py (renamed from tests/zmq/zmqtest.py)33
-rw-r--r--tests/sockets/send.py21
3 files changed, 95 insertions, 51 deletions
diff --git a/tests/zmq/zmqtest.grc b/tests/sockets/Socket_test.grc
index ad1729d..fbc3cdf 100644
--- a/tests/zmq/zmqtest.grc
+++ b/tests/sockets/Socket_test.grc
@@ -1,6 +1,6 @@
options:
parameters:
- author: Naoki Pross
+ author: 'Sara Halter '
category: '[GRC Hier Blocks]'
cmake_opt: ''
comment: ''
@@ -10,18 +10,18 @@ options:
gen_linking: dynamic
generate_options: no_gui
hier_block_src_path: '.:'
- id: zmqtest
+ id: Test_Bit_Errorrate
max_nouts: '0'
output_language: python
placement: (0,0)
qt_qss_theme: ''
- realtime_scheduling: '1'
+ realtime_scheduling: ''
run: 'True'
run_command: '{python} -u {filename}'
- run_options: prompt
+ run_options: run
sizing_mode: fixed
thread_safe_setters: ''
- title: ZMQ test
+ title: 'Bit Error Rate test '
window_size: ''
states:
bus_sink: false
@@ -41,72 +41,100 @@ blocks:
bus_sink: false
bus_source: false
bus_structure: null
- coordinate: [184, 12]
+ coordinate: [216, 20.0]
rotation: 0
state: enabled
-- name: blocks_throttle_0
- id: blocks_throttle
+- name: analog_noise_source_x_0
+ id: analog_noise_source_x
parameters:
affinity: ''
alias: ''
+ amp: '1'
comment: ''
- ignoretag: 'True'
maxoutbuf: '0'
minoutbuf: '0'
- samples_per_second: samp_rate
- type: complex
- vlen: '1'
+ noise_type: analog.GR_GAUSSIAN
+ seed: '0'
+ type: float
states:
bus_sink: false
bus_source: false
bus_structure: null
- coordinate: [440, 324.0]
+ coordinate: [32, 148.0]
rotation: 0
- state: true
-- name: zeromq_rep_sink_0
- id: zeromq_rep_sink
+ state: enabled
+- name: blocks_null_source_0
+ id: blocks_null_source
parameters:
- address: ''
affinity: ''
alias: ''
+ bus_structure_source: '[[0,],]'
comment: ''
- hwm: '-1'
- pass_tags: 'False'
- timeout: '100'
+ maxoutbuf: '0'
+ minoutbuf: '0'
+ num_outputs: '1'
type: complex
vlen: '1'
states:
bus_sink: false
bus_source: false
bus_structure: null
- coordinate: [664, 308.0]
+ coordinate: [64, 264.0]
rotation: 0
- state: true
-- name: zeromq_req_source_0
- id: zeromq_req_source
+ state: disabled
+- name: blocks_throttle_1
+ id: blocks_throttle
parameters:
- address: ''
affinity: ''
alias: ''
comment: ''
- hwm: '-1'
+ ignoretag: 'True'
maxoutbuf: '0'
minoutbuf: '0'
- pass_tags: 'False'
- timeout: '100'
- type: complex
+ samples_per_second: samp_rate
+ type: float
vlen: '1'
states:
bus_sink: false
bus_source: false
bus_structure: null
- coordinate: [216, 308.0]
+ 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:
-- [blocks_throttle_0, '0', zeromq_rep_sink_0, '0']
-- [zeromq_req_source_0, '0', blocks_throttle_0, '0']
+- [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/zmq/zmqtest.py b/tests/sockets/Test_Bit_Errorrate.py
index a046c13..6a989df 100755
--- a/tests/zmq/zmqtest.py
+++ b/tests/sockets/Test_Bit_Errorrate.py
@@ -5,10 +5,11 @@
# SPDX-License-Identifier: GPL-3.0
#
# GNU Radio Python Flow Graph
-# Title: ZMQ test
-# Author: Naoki Pross
+# 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
@@ -17,13 +18,14 @@ import signal
from argparse import ArgumentParser
from gnuradio.eng_arg import eng_float, intx
from gnuradio import eng_notation
-from gnuradio import zeromq
+import fadingui
+import numpy as np
-class zmqtest(gr.top_block):
+class Test_Bit_Errorrate(gr.top_block):
def __init__(self):
- gr.top_block.__init__(self, "ZMQ test")
+ gr.top_block.__init__(self, "Bit Error Rate test ")
##################################################
# Variables
@@ -33,17 +35,17 @@ class zmqtest(gr.top_block):
##################################################
# Blocks
##################################################
- self.zeromq_req_source_0 = zeromq.req_source(gr.sizeof_gr_complex, 1, '', 100, False, -1)
- self.zeromq_rep_sink_0 = zeromq.rep_sink(gr.sizeof_gr_complex, 1, '', 100, False, -1)
- self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True)
+ 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.blocks_throttle_0, 0), (self.zeromq_rep_sink_0, 0))
- self.connect((self.zeromq_req_source_0, 0), (self.blocks_throttle_0, 0))
+ 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):
@@ -51,15 +53,13 @@ class zmqtest(gr.top_block):
def set_samp_rate(self, samp_rate):
self.samp_rate = samp_rate
- self.blocks_throttle_0.set_sample_rate(self.samp_rate)
+ self.blocks_throttle_1.set_sample_rate(self.samp_rate)
-def main(top_block_cls=zmqtest, options=None):
- if gr.enable_realtime_scheduling() != gr.RT_OK:
- print("Error: failed to enable real-time scheduling.")
+def main(top_block_cls=Test_Bit_Errorrate, options=None):
tb = top_block_cls()
def sig_handler(sig=None, frame=None):
@@ -73,11 +73,6 @@ def main(top_block_cls=zmqtest, options=None):
tb.start()
- try:
- input('Press Enter to quit: ')
- except EOFError:
- pass
- tb.stop()
tb.wait()
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())