From fe0b0794fa4ea15960075de1e9ea2b27bc363406 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Thu, 14 Nov 2019 17:09:29 +0100 Subject: TransitionHarnes: fix barcode transfer --- lib/harness.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/harness.py b/lib/harness.py index cd9a477..f08f8d2 100644 --- a/lib/harness.py +++ b/lib/harness.py @@ -144,7 +144,9 @@ class TransitionHarness: def _pass_transition_call(self, transition_id): if self.gpio_mode == 'bar': barcode_bits = Code128('T{}'.format(transition_id), charset='B').modules - barcode_bytes = [int("".join(map(str, reversed(barcode_bits[i:i+8]))), 2) for i in range(0, len(barcode_bits), 8)] + if len(barcode_bits) % 8 != 0: + barcode_bits.extend([1] * (8 - (len(barcode_bits) % 8))) + barcode_bytes = [255 - int("".join(map(str, reversed(barcode_bits[i:i+8]))), 2) for i in range(0, len(barcode_bits), 8)] inline_array = "".join(map(lambda s: '\\x{:02x}'.format(s), barcode_bytes)) return 'ptalog.startTransition("{}", {});\n'.format(inline_array, len(barcode_bytes)) else: -- cgit v1.2.3