From e1fb147b5967b52d9f6d709526d7730506694a0c Mon Sep 17 00:00:00 2001 From: Kabir Marwah Date: Tue, 23 Aug 2022 10:12:26 -0700 Subject: [PATCH] Fix bug in BCHPlugin --- ait/dsn/bch/bch_plugin.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/ait/dsn/bch/bch_plugin.py b/ait/dsn/bch/bch_plugin.py index 472106b..037317c 100644 --- a/ait/dsn/bch/bch_plugin.py +++ b/ait/dsn/bch/bch_plugin.py @@ -30,10 +30,11 @@ def process(self, input_data, topic=None): # handle case where number of bytes is not evenly divisible by 7 # CCSDS standard states add alternating 0/1 fill bits starting with 0 - number_of_filler_bytes = 7 - remainder_bytes - filler_bytes = bytearray(b"\x55")*number_of_filler_bytes - last_chunk = input_data[-remainder_bytes:] + filler_bytes - last_chunk_with_bch = BCH.generateBCH(last_chunk) - output_bytes = output_bytes + last_chunk_with_bch + if remainder_bytes != 0: + number_of_filler_bytes = 7 - remainder_bytes + filler_bytes = bytearray(b"\x55")*number_of_filler_bytes + last_chunk = input_data[-remainder_bytes:] + filler_bytes + last_chunk_with_bch = BCH.generateBCH(last_chunk) + output_bytes = output_bytes + last_chunk_with_bch self.publish(output_bytes)