]> sigrok.org Git - libsigrokdecode.git/blobdiff - decoders/i2cfilter/pd.py
Add a CFP decoder.
[libsigrokdecode.git] / decoders / i2cfilter / pd.py
index 8be7828a0af5aeea7405eb7511e02dd47ea6512d..1dc7fd1ddfc3e73cb1a2b53f3d38fa091aec0922 100644 (file)
@@ -23,7 +23,7 @@
 import sigrokdecode as srd
 
 class Decoder(srd.Decoder):
-    api_version = 1
+    api_version = 3
     id = 'i2cfilter'
     name = 'I²C filter'
     longname = 'I²C filter'
@@ -38,8 +38,10 @@ class Decoder(srd.Decoder):
             'values': ('read', 'write', 'both')}
     )
 
-    def __init__(self, **kwargs):
-        self.state = None
+    def __init__(self):
+        self.reset()
+
+    def reset(self):
         self.curslave = -1
         self.curdirection = None
         self.packets = [] # Local cache of I²C packets
@@ -48,8 +50,6 @@ class Decoder(srd.Decoder):
         self.out_python = self.register(srd.OUTPUT_PYTHON, proto_id='i2c')
         if self.options['address'] not in range(0, 127 + 1):
             raise Exception('Invalid slave (must be 0..127).')
-        if self.options['direction'] not in ('both', 'read', 'write'):
-            raise Exception('Invalid direction (valid: read/write/both).')
 
     # Grab I²C packets into a local cache, until an I²C STOP condition
     # packet comes along. At some point before that STOP condition, there
@@ -90,4 +90,3 @@ class Decoder(srd.Decoder):
             self.packets = []
         else:
             pass # Do nothing, only add the I²C packet to our cache.
-