From: Stephan Thiele Date: Fri, 22 Feb 2019 18:50:03 +0000 (+0100) Subject: can: decode CAN-FD DLC X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=0102e92b4979de776cdabf50fcff69d8c95f30ca;p=libsigrokdecode.git can: decode CAN-FD DLC --- 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']])