diff options
Diffstat (limited to '')
-rw-r--r-- | src/gr-fadingui/grc/CMakeLists.txt | 3 | ||||
-rw-r--r-- | src/gr-fadingui/grc/fadingui_xor_frame_sync.block.yml | 45 | ||||
-rw-r--r-- | src/gr-fadingui/python/CMakeLists.txt | 3 | ||||
-rw-r--r-- | src/gr-fadingui/python/__init__.py | 1 | ||||
-rw-r--r-- | src/gr-fadingui/python/datasource.py | 27 | ||||
-rw-r--r-- | src/gr-fadingui/python/dearpygui_sink.py | 16 | ||||
-rw-r--r-- | src/gr-fadingui/python/xor_frame_sync.py | 27 |
7 files changed, 85 insertions, 37 deletions
diff --git a/src/gr-fadingui/grc/CMakeLists.txt b/src/gr-fadingui/grc/CMakeLists.txt index 98713e8..1fe2b9c 100644 --- a/src/gr-fadingui/grc/CMakeLists.txt +++ b/src/gr-fadingui/grc/CMakeLists.txt @@ -19,5 +19,6 @@ # Boston, MA 02110-1301, USA. install(FILES fadingui_datasource.block.yml - fadingui_dearpygui_sink.block.yml DESTINATION share/gnuradio/grc/blocks + fadingui_dearpygui_sink.block.yml + fadingui_xor_frame_sync.block.yml DESTINATION share/gnuradio/grc/blocks ) diff --git a/src/gr-fadingui/grc/fadingui_xor_frame_sync.block.yml b/src/gr-fadingui/grc/fadingui_xor_frame_sync.block.yml new file mode 100644 index 0000000..92be2a8 --- /dev/null +++ b/src/gr-fadingui/grc/fadingui_xor_frame_sync.block.yml @@ -0,0 +1,45 @@ +id: fadingui_xor_frame_sync +label: xor_frame_sync +category: '[fadingui]' + +templates: + imports: import fadingui + make: fadingui.xor_frame_sync() + +# 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) +# * label (label shown in the GUI) +# * dtype (e.g. int, float, complex, byte, short, xxx_vector, ...) +parameters: +- id: ... + label: ... + dtype: ... +- id: ... + label: ... + dtype: ... + +# Make one 'inputs' list entry per input and one 'outputs' list entry per output. +# Keys include: +# * label (an identifier for the GUI) +# * domain (optional - stream or message. Default is stream) +# * dtype (e.g. int, float, complex, byte, short, xxx_vector, ...) +# * vlen (optional - data stream vector length. Default is 1) +# * optional (optional - set to 1 for optional inputs. Default is 0) +inputs: +- label: ... + domain: ... + dtype: ... + vlen: ... + optional: ... + +outputs: +- label: ... + domain: ... + dtype: ... + vlen: ... + optional: ... + +# 'file_format' specifies the version of the GRC yml format used in the file +# and should usually not be changed. +file_format: 1 diff --git a/src/gr-fadingui/python/CMakeLists.txt b/src/gr-fadingui/python/CMakeLists.txt index 27b5f4b..4845bd9 100644 --- a/src/gr-fadingui/python/CMakeLists.txt +++ b/src/gr-fadingui/python/CMakeLists.txt @@ -33,7 +33,8 @@ GR_PYTHON_INSTALL( FILES __init__.py datasource.py - dearpygui_sink.py DESTINATION ${GR_PYTHON_DIR}/fadingui + dearpygui_sink.py + xor_frame_sync.py DESTINATION ${GR_PYTHON_DIR}/fadingui ) ######################################################################## diff --git a/src/gr-fadingui/python/__init__.py b/src/gr-fadingui/python/__init__.py index d551a71..f62e3cf 100644 --- a/src/gr-fadingui/python/__init__.py +++ b/src/gr-fadingui/python/__init__.py @@ -34,5 +34,6 @@ except ImportError: # import any pure python here from .datasource import datasource from .dearpygui_sink import dearpygui_sink +from .xor_frame_sync import xor_frame_sync # diff --git a/src/gr-fadingui/python/datasource.py b/src/gr-fadingui/python/datasource.py index 1914d33..764b4d5 100644 --- a/src/gr-fadingui/python/datasource.py +++ b/src/gr-fadingui/python/datasource.py @@ -1,23 +1,7 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- # -# Copyright 2021 Naoki Pross, Sara Halter. -# -# This is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# This software is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this software; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# +# Copyright 2021 Naoki Pross. import io @@ -60,23 +44,27 @@ class datasource(gr.sync_block): self.fdata = np.fromfile(fname, np.byte) self.fsize = len(self.fdata) - # TODO: remove debugging statements + # TODO: remove debugging statements or create logger print(f"datasource: loaded file size={self.fsize}, head:") print(self.fdata[:10]) def make_header(self, data_size): # TODO: check that data_size is not too big pilot = 0x1248 + + # TODO: implement hamming code for header header = f"p{pilot:04x}s{data_size:04x}d".encode("ascii") + arr = np.frombuffer(header, dtype=np.dtype("byte")) return arr def work(self, input_items, output_items): out = output_items[0] - print(self.fpos) if self.fpos + self.vec_len > self.fsize: # FIXME: repair broken code below + # TODO: create logger + print(f"WARNING: the last {self.fsize - self.fpos} bytes were not sent!") self.fpos = 0 return 0; @@ -92,6 +80,7 @@ class datasource(gr.sync_block): self.fpos = 0 return rest + # cache header if not saved if self.header_cache == None: self.header = self.make_header(self.vec_len) diff --git a/src/gr-fadingui/python/dearpygui_sink.py b/src/gr-fadingui/python/dearpygui_sink.py index bca780d..6153611 100644 --- a/src/gr-fadingui/python/dearpygui_sink.py +++ b/src/gr-fadingui/python/dearpygui_sink.py @@ -2,22 +2,6 @@ # -*- coding: utf-8 -*- # # Copyright 2021 Naoki Pross. -# -# This is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# This software is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this software; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# import socket from urllib.parse import urlparse diff --git a/src/gr-fadingui/python/xor_frame_sync.py b/src/gr-fadingui/python/xor_frame_sync.py new file mode 100644 index 0000000..9d9064f --- /dev/null +++ b/src/gr-fadingui/python/xor_frame_sync.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# +# Copyright 2021 Naoki Pross. + + +import numpy +from gnuradio import gr + +class xor_frame_sync(gr.sync_block): + """ + docstring for block xor_frame_sync + """ + def __init__(self, sync_pattern): + gr.sync_block.__init__(self, + name="xor_frame_sync", + in_sig=[np.byte], + out_sig=[np.byte]) + + def work(self, input_items, output_items): + inp = input_items[0] + out = output_items[0] + + out[:] = inp + + return len(output_items[0]) + |