From: Gerhard Sittig Date: Fri, 17 Jul 2020 07:12:17 +0000 (+0200) Subject: pjon: unbreak CRC32 check, adjust data length X-Git-Url: http://sigrok.org/gitweb/?a=commitdiff_plain;h=303f43e74aee56f64318be7b0507d0f7a70c1897;p=libsigrokdecode.git pjon: unbreak CRC32 check, adjust data length The previous implementation unconditionally assumed a CRC width of one byte when it calculated the checksum for received frame data. Do reflect on the CRC8/CRC32 choice instead. This patch is based on a fix that was Submitted-By: Julio Aguirre --- diff --git a/decoders/pjon/pd.py b/decoders/pjon/pd.py index 0c75f89..f9634e1 100644 --- a/decoders/pjon/pd.py +++ b/decoders/pjon/pd.py @@ -381,12 +381,13 @@ class Decoder(srd.Decoder): # across meta and end checksums in a frame's fields. caption = 'META' if is_meta else 'END' crc_len = 8 if is_meta else 32 if self.cfg_crc32 else 8 + crc_bytes = crc_len // 8 crc_fmt = '{:08x}' if crc_len == 32 else '{:02x}' have_text = crc_fmt.format(have) # Check received against expected checksum. Emit warnings. warn_texts = [] - data = self.frame_bytes[:-1] + data = self.frame_bytes[:-crc_bytes] want = calc_crc32(data) if crc_len == 32 else calc_crc8(data) if want != have: want_text = crc_fmt.format(want)