modbus: Ignore unknown/unsupported types.
authorUwe Hermann <uwe@hermann-uwe.de>
Fri, 29 Nov 2019 18:47:35 +0000 (19:47 +0100)
committerUwe Hermann <uwe@hermann-uwe.de>
Fri, 29 Nov 2019 19:10:06 +0000 (20:10 +0100)
Without this, e.g. the recently added 'IDLE' ptype of the UART decoder
would cause issues.

decoders/modbus/pd.py

index cc4272168c28f4a60d633c1554f4340cb1d9071c..1d012e4560170aa05b3cebfc47defa2f3a9d3b8f 100644 (file)
@@ -929,6 +929,10 @@ class Decoder(srd.Decoder):
     def decode(self, ss, es, data):
         ptype, rxtx, pdata = data
 
+        # Ignore unknown/unsupported ptypes.
+        if ptype not in ('STARTBIT', 'DATA', 'STOPBIT'):
+            return
+
         # Decide what ADU(s) we need this packet to go to.
         # Note that it's possible to go to both ADUs.
         if rxtx_channels[rxtx] == self.options['scchannel']: