summaryrefslogtreecommitdiff
path: root/decoders/can
diff options
context:
space:
mode:
authorGerhard Sittig <gerhard.sittig@gmx.net>2017-05-14 19:08:37 +0200
committerUwe Hermann <uwe@hermann-uwe.de>2017-05-26 15:49:49 +0200
commita0128522e5fb4ee50fe10450ad8255cd1729bde4 (patch)
tree78410af239ff7a406acc8a95fd14598652f1e181 /decoders/can
parent64d8711976c3e74a4a19beabd505438ce91ac86c (diff)
downloadlibsigrokdecode-a0128522e5fb4ee50fe10450ad8255cd1729bde4.tar.gz
libsigrokdecode-a0128522e5fb4ee50fe10450ad8255cd1729bde4.zip
can: Skip stuff bit inspection where not applicable
Bit stuffing does not apply to the last fields of a frame, specifically the CRC delimiter, the ACK, and the end-of-frame fields. Adjust the respective bit handling logic. This fixes bug #656.
Diffstat (limited to 'decoders/can')
-rw-r--r--decoders/can/pd.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/decoders/can/pd.py b/decoders/can/pd.py
index 46054cd..375069f 100644
--- a/decoders/can/pd.py
+++ b/decoders/can/pd.py
@@ -113,6 +113,9 @@ class Decoder(srd.Decoder):
def is_stuff_bit(self):
# CAN uses NRZ encoding and bit stuffing.
# After 5 identical bits, a stuff bit of opposite value is added.
+ # But not in the CRC delimiter, ACK, and end of frame fields.
+ if len(self.bits) > self.last_databit + 16:
+ return False
last_6_bits = self.rawbits[-6:]
if last_6_bits not in ([0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 0]):
return False