diff options
author | Stephan Thiele <stephan.thiele@mailbox.org> | 2019-02-22 19:50:03 +0100 |
---|---|---|
committer | Uwe Hermann <uwe@hermann-uwe.de> | 2019-09-13 15:19:33 +0200 |
commit | 0102e92b4979de776cdabf50fcff69d8c95f30ca (patch) | |
tree | 31eb5534f73390b0fea02ff3f1f0bf6b43963978 /decoders/can | |
parent | 741dba7858f41c555d01d041c8481bf9ef155e7d (diff) | |
download | libsigrokdecode-0102e92b4979de776cdabf50fcff69d8c95f30ca.tar.gz libsigrokdecode-0102e92b4979de776cdabf50fcff69d8c95f30ca.zip |
can: decode CAN-FD DLC
Diffstat (limited to 'decoders/can')
-rw-r--r-- | decoders/can/pd.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/decoders/can/pd.py b/decoders/can/pd.py index 2d346bb..2087742 100644 --- a/decoders/can/pd.py +++ b/decoders/can/pd.py @@ -69,6 +69,9 @@ class Decoder(srd.Decoder): def __init__(self): self.reset() + def dlc2len(self, dlc): + return [0, 1, 2, 3, 4, 5, 6, 7, 8, 12, 16, 20, 24, 32, 48, 64][dlc] + def reset(self): self.samplerate = None self.reset_variables() @@ -266,8 +269,8 @@ class Decoder(srd.Decoder): # Bits 15-18: Data length code (DLC), in number of bytes (0-8). elif bitnum == self.dlc_start + 3: self.dlc = int(''.join(str(d) for d in self.bits[self.dlc_start:self.dlc_start + 4]), 2) - self.putb([10, ['Data length code: %d' % self.dlc, - 'DLC: %d' % self.dlc, 'DLC']]) + self.putb([10, ['Data length code: %d (%d Bytes)' % (self.dlc, self.dlc2len(self.dlc)), + 'DLC: %d (%d B)' % (self.dlc, self.dlc2len(self.dlc)), 'DLC']]) self.last_databit = self.dlc_start + 3 + (self.dlc * 8) if self.dlc > 8: self.putb([16, ['Data length code (DLC) > 8 is not allowed']]) |