diff options
author | Nao Pross <np@0hm.ch> | 2021-11-15 16:19:23 +0100 |
---|---|---|
committer | Nao Pross <np@0hm.ch> | 2021-11-15 16:19:23 +0100 |
commit | c5145aa6519e0787457253749ea76456a0fb0011 (patch) | |
tree | 8e066fed868aed2ef8c664cafc25c3adf5f5cd26 | |
parent | Create build and install script for debian (diff) | |
download | Fading-c5145aa6519e0787457253749ea76456a0fb0011.tar.gz Fading-c5145aa6519e0787457253749ea76456a0fb0011.zip |
Implement basic framer
Diffstat (limited to '')
-rw-r--r-- | src/gr-fadingui/python/datasource.py | 22 | ||||
-rw-r--r-- | src/shell.nix | 2 |
2 files changed, 20 insertions, 4 deletions
diff --git a/src/gr-fadingui/python/datasource.py b/src/gr-fadingui/python/datasource.py index ddce468..2a54ce3 100644 --- a/src/gr-fadingui/python/datasource.py +++ b/src/gr-fadingui/python/datasource.py @@ -19,6 +19,8 @@ # Boston, MA 02110-1301, USA. # +import io + import numpy as np from gnuradio import gr @@ -30,9 +32,10 @@ class datasource(gr.sync_block): gr.sync_block.__init__(self, name="datasource", in_sig=None, - out_sig=[np.dtype('256b')]) + out_sig=[np.dtype('{vec_len}b')]) # parameters + self.header_size = 11 self.vec_len = vec_len self.sock_addr = sock_addr self.file_list = file_list @@ -49,15 +52,28 @@ class datasource(gr.sync_block): self.fdata = np.fromfile(fname, np.byte) self.fsize = len(self.data) - # TODO: remove + # TODO: remove debugging statements print(f"datasource: loaded file size={self.fsize}, head:") print(self.fdata[:10]) + def make_frame(self, data_size): + # TODO: check that data_size is not too big + pilot = 0x1248 + header = f"p{pilot:04x}s{data_size:04x}d".encode("ascii") + arr = np.array(bytearray(header)) + + assert(len(arr) == self.header_size) + return arr + def work(self, input_items, output_items): out = output_items[0] if self.fpos + self.vec_len > self.fsize: - # TODO: implement padding with zeroes + rest = self.fsize - self.fpos + + out[:rest] = self.fdata[self.fpos:rest] + out[rest:] = 0 # TODO: replace with 01010101.. seq or scramble + self.fpos = 0 return 0 diff --git a/src/shell.nix b/src/shell.nix index b6351e8..666bab3 100644 --- a/src/shell.nix +++ b/src/shell.nix @@ -12,7 +12,7 @@ in mkShell { gnuradio python38Packages.setuptools # gnuradio block dev dependencies - cmake ninja pkg-config log4cpp mpir boost175 gmp volk + cmake ninja pkg-config log4cpp mpir boost175 gmp volk doxygen python38Packages.pybind11 ]) ++ (with pkgs.python38Packages; [ numpy |