aboutsummaryrefslogtreecommitdiffstats
path: root/src/gr-fadingui/python
diff options
context:
space:
mode:
authorSARA <sara.halter@ost.ch>2021-11-17 19:41:49 +0100
committerSARA <sara.halter@ost.ch>2021-11-17 19:41:49 +0100
commit37a204861a1ea56f39e68c690d3a5c23d4a3c23e (patch)
tree59540172ad5cab98b41b784c3535a4593fd5de85 /src/gr-fadingui/python
parentFir filter delay python file (diff)
parentBegin working on frame syncronization (diff)
downloadFading-37a204861a1ea56f39e68c690d3a5c23d4a3c23e.tar.gz
Fading-37a204861a1ea56f39e68c690d3a5c23d4a3c23e.zip
Merge remote-tracking branch 'origin/master'
Diffstat (limited to '')
-rw-r--r--src/gr-fadingui/python/CMakeLists.txt3
-rw-r--r--src/gr-fadingui/python/__init__.py1
-rw-r--r--src/gr-fadingui/python/datasource.py27
-rw-r--r--src/gr-fadingui/python/dearpygui_sink.py16
-rw-r--r--src/gr-fadingui/python/xor_frame_sync.py27
5 files changed, 38 insertions, 36 deletions
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])
+