]> sigrok.org Git - libsigrokdecode.git/blobdiff - decoders/modbus/pd.py
All PDs: Consistently use singular/plural for annotation classes/rows.
[libsigrokdecode.git] / decoders / modbus / pd.py
index d5cb811ef1794c226851fb3c6d8bde16c52568f3..83ffbb27277090cb477abc3f1c28512291cd04fb 100644 (file)
@@ -841,14 +841,14 @@ class Decoder(srd.Decoder):
     annotation_rows = (
         ('sc', 'Server->client', (0, 1, 2, 3, 4, 5, 6)),
         ('cs', 'Client->server', (7, 8, 9, 10, 11, 12, 13)),
-        ('error-indicator', 'Errors in frame', (14,)),
+        ('error-indicators', 'Errors in frame', (14,)),
     )
     options = (
         {'id': 'scchannel', 'desc': 'Server -> client channel',
             'default': rxtx_channels[0], 'values': rxtx_channels},
         {'id': 'cschannel', 'desc': 'Client -> server channel',
             'default': rxtx_channels[1], 'values': rxtx_channels},
-        {'id': 'framegap', 'desc': 'Inter-frame bit gap', 'default': '28'},
+        {'id': 'framegap', 'desc': 'Inter-frame bit gap', 'default': 28},
     )
 
     def __init__(self):
@@ -912,7 +912,7 @@ class Decoder(srd.Decoder):
         # somewhere between seems fine.
         # A character is 11 bits long, so (3.5 + 1.5)/2 * 11 ~= 28
         # TODO: Display error for too short or too long.
-        if (ss - ADU.last_read) <= self.bitlength * int(self.options['framegap']):
+        if (ss - ADU.last_read) <= self.bitlength * self.options['framegap']:
             ADU.add_data(ss, es, data)
         else:
             # It's been too long since the last part of the ADU!
@@ -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']: