aboutsummaryrefslogtreecommitdiffstats
path: root/tests/correlator/epy_block_2.py
diff options
context:
space:
mode:
authorNao Pross <np@0hm.ch>2021-12-09 18:37:06 +0100
committerNao Pross <np@0hm.ch>2021-12-09 18:37:06 +0100
commite034f477e6eb6570d309f43a5d4ca2a400c5aac9 (patch)
tree123fcaaf78f160aee6ab6596cdaf90d5296ba388 /tests/correlator/epy_block_2.py
parentRemove unnecessary (out of date) FIXME (diff)
downloadFading-e034f477e6eb6570d309f43a5d4ca2a400c5aac9.tar.gz
Fading-e034f477e6eb6570d309f43a5d4ca2a400c5aac9.zip
Begin tag stream to vector stream
Diffstat (limited to '')
-rw-r--r--tests/correlator/epy_block_2.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/correlator/epy_block_2.py b/tests/correlator/epy_block_2.py
new file mode 100644
index 0000000..210be12
--- /dev/null
+++ b/tests/correlator/epy_block_2.py
@@ -0,0 +1,33 @@
+import pmt
+import numpy as np
+from gnuradio import gr
+
+
+class blk(gr.sync_block):
+
+ def __init__(self, tag="frame_start", vlen=1):
+ dt = np.byte if vlen == 1 else (np.byte, vlen)
+
+ gr.sync_block.__init__(
+ self,
+ name='Split at tag',
+ in_sig=[np.byte],
+ out_sig=[(np.byte, vlen)]
+ )
+
+ self.tag = tag
+ self.vlen = vlen
+
+ def work(self, input_items, output_items):
+ inp = input_items[0]
+
+ is_frame_start = lambda tag: pmt.to_python(tag.key) == self.tag
+ tags = filter(is_frame_start, self.get_tags_in_window(0, 0, len(inp)))
+
+ counter = self.nitems_written(0)
+ offsets = map(lambda t: t.offset - counter, tags)
+
+ print(list(offsets))
+
+ output_items[0][:] = inp
+ return len(output_items[0])