summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Thiele <stephan.thiele@mailbox.org>2019-11-10 17:11:34 +0100
committerUwe Hermann <uwe@hermann-uwe.de>2019-11-29 20:10:10 +0100
commitd871cc2d11dba2a57b747a940beace0d9456c166 (patch)
tree73fa6f9a3ad602b5fc8f9b453ff1d70d3717815a
parent7714a23058fcf1fbffa1208fb02f854947f0617f (diff)
downloadlibsigrokdecode-d871cc2d11dba2a57b747a940beace0d9456c166.tar.gz
libsigrokdecode-d871cc2d11dba2a57b747a940beace0d9456c166.zip
lin: calculate checksum on two consecutive UART idle frames
-rw-r--r--decoders/lin/pd.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/decoders/lin/pd.py b/decoders/lin/pd.py
index 216d416..426cbf0 100644
--- a/decoders/lin/pd.py
+++ b/decoders/lin/pd.py
@@ -41,6 +41,7 @@ class LinFsm:
def reset(self):
self.state = LinFsm.State.WaitForBreak
+ self.uart_idle_count = 0
def __init__(self):
a = dict()
@@ -53,6 +54,7 @@ class LinFsm:
self.allowed_state = a
self.state = None
+ self.uart_idle_count = 0
self.reset()
class Decoder(srd.Decoder):
@@ -113,6 +115,15 @@ class Decoder(srd.Decoder):
return True
+ def handle_uart_idle(self):
+ if self.fsm.state not in (LinFsm.State.WaitForBreak, LinFsm.State.Error):
+ self.fsm.uart_idle_count += 1
+
+ if self.fsm.uart_idle_count == 2:
+ self.fsm.transit(LinFsm.State.Checksum)
+ self.handle_checksum()
+ self.fsm.reset()
+
def handle_wait_for_break(self, value):
self.wipe_break_null_byte(value)
@@ -217,6 +228,8 @@ class Decoder(srd.Decoder):
self.ss_block, self.es_block = ss, es
# Ignore all UART packets except the actual data packets or BREAK.
+ if ptype == 'IDLE':
+ self.handle_uart_idle()
if ptype == 'BREAK':
self.handle_break(pdata)
if ptype != 'DATA':