diff options
author | Nao Pross <np@0hm.ch> | 2021-11-23 17:44:01 +0100 |
---|---|---|
committer | Nao Pross <np@0hm.ch> | 2021-11-23 17:44:01 +0100 |
commit | 9dca36d5de399fccf56cf4d845a884b56e4c2ffb (patch) | |
tree | 161c855760a7e9fc8d83dd926002ff190a60b31b /src | |
parent | Eignere Block FIR Filer (diff) | |
download | Fading-9dca36d5de399fccf56cf4d845a884b56e4c2ffb.tar.gz Fading-9dca36d5de399fccf56cf4d845a884b56e4c2ffb.zip |
Bugs in xor sync
Diffstat (limited to 'src')
-rw-r--r-- | src/gr-fadingui/python/qa_xor_frame_sync.py | 7 | ||||
-rw-r--r-- | src/gr-fadingui/python/xor_frame_sync.py | 44 |
2 files changed, 30 insertions, 21 deletions
diff --git a/src/gr-fadingui/python/qa_xor_frame_sync.py b/src/gr-fadingui/python/qa_xor_frame_sync.py index 280c694..e763d00 100644 --- a/src/gr-fadingui/python/qa_xor_frame_sync.py +++ b/src/gr-fadingui/python/qa_xor_frame_sync.py @@ -16,10 +16,11 @@ class test_xor_frame_sync(gr_unittest.TestCase): def test_001(self): """Test a byte aligned delay""" - pattern = np.array([0xbe, 0xef], dtype=np.uint8) + pattern = np.array([0xc0, 0xff, 0xee], dtype=np.uint8) testdata = np.packbits(np.concatenate([ - np.unpackbits(np.arange(0, 10, dtype=np.uint8)), - np.random.randint(0, 2, size = 8 * 5), np.unpackbits(pattern), + np.unpackbits(np.arange(0, 5, dtype=np.uint8)), + # np.random.randint(0, 2, size = 8 * 5), + np.unpackbits(pattern), np.random.randint(0, 2, size = 64) ])) diff --git a/src/gr-fadingui/python/xor_frame_sync.py b/src/gr-fadingui/python/xor_frame_sync.py index e52b493..312ad2a 100644 --- a/src/gr-fadingui/python/xor_frame_sync.py +++ b/src/gr-fadingui/python/xor_frame_sync.py @@ -80,9 +80,8 @@ class xor_frame_sync(gr.sync_block): - If the buffer is not synchronized, compute a binary cross correlation to find how much the stream should be delayed. """ + # array of samples, growing index = forward in time inp = input_items[0] - out = output_items[0] - inp_len = len(inp) if not self.synchronized: @@ -90,25 +89,32 @@ class xor_frame_sync(gr.sync_block): log.error("Input is bigger than delay buffer") # FIXME: Makes the QA hang for some reason - # raise NotImplemented + raise NotImplemented + # create space for new samples in the delay buffer + self.delaybuf.extendleft(np.zeros(inp_len)) + + # Add values and while processing for bytenr, value in enumerate(inp): # save value in the buffer + # FIXME: this is wrong, it should be in reverse order self.delaybuf.appendleft(value) # compute the cross correlation bitnr = self.xcorrelation(value) if bitnr is not None: # correlation was found - delay_bits = 8 * bytenr + bitnr + delay_bits = (bitnr - 7) + delay_bytes = 8 * (bytenr -1) + + log.debug(f"Synchronized with delay_bytes={delay_bytes} delay_bits={delay_bits}") # FIXME: add bit delay - self.delay = bytenr + self.delay = delay_bytes self.synchronized = True - log.debug(f"Synchronized with delay={self.delay} delay_bits={delay_bits}") # Not aligned to bytes - if bitnr != 7: + if delay_bits != 0: log.error("Not implemented: byte unaligned delay") self.synchronized = False self.delay = 0 @@ -116,15 +122,6 @@ class xor_frame_sync(gr.sync_block): # FIXME: Makes the QA hang for some reason # raise NotImplemented - # bigger than buffer - if bytenr > self.delaybuf.maxlen: - log.error("Too too long to synchronize, ran out of buffer memory") - self.synchronized = False - self.delay = 0 - - # FIXME: Makes the QA hang for some reason - # raise NotImplemented - # stop processing inputs break @@ -134,7 +131,18 @@ class xor_frame_sync(gr.sync_block): self.delaybuf.extendleft(inp) # return data with delay - out[:] = self.delaybuf[self.delay] + out = output_items[0] + # FIXME: this is also wrong + out[:] = self.delaybuf[:len(out)] + + + inptmp = np.array(inp[:12], dtype=np.uint8) + inphex = np.array(list(map(hex, inptmp))) + log.debug(f"inp={inptmp}") + log.debug(f"inp={inphex}") + + # outtmp = np.array(out[:12], dtype=np.uint8) + # log.debug(f"out={outtmp}") - return len(output_items[0]) + return len(out) |