summaryrefslogtreecommitdiff
path: root/decoders/pjon
diff options
context:
space:
mode:
authorGerhard Sittig <gerhard.sittig@gmx.net>2020-07-17 09:12:17 +0200
committerGerhard Sittig <gerhard.sittig@gmx.net>2020-07-17 17:13:39 +0200
commit303f43e74aee56f64318be7b0507d0f7a70c1897 (patch)
tree874f60e60bce32457ac9dfdc6204a7f7a6c9f0f6 /decoders/pjon
parent397ec00dae6800d733f0efbbf430a6f8c0bed000 (diff)
downloadlibsigrokdecode-303f43e74aee56f64318be7b0507d0f7a70c1897.tar.gz
libsigrokdecode-303f43e74aee56f64318be7b0507d0f7a70c1897.zip
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 <jcallano@gmail.com>
Diffstat (limited to 'decoders/pjon')
-rw-r--r--decoders/pjon/pd.py3
1 files changed, 2 insertions, 1 deletions
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)