]> sigrok.org Git - libsigrokdecode.git/blobdiff - decoders/i2cfilter/i2cfilter.py
srd: Initial MEMSIC MXC6225XU protocol decoder.
[libsigrokdecode.git] / decoders / i2cfilter / i2cfilter.py
index 4b88befbcfa147ec9ed838daa8ac1190073d0a24..6b3d1134326f067c6af2d4367519195988cfb5de 100644 (file)
@@ -17,8 +17,9 @@
 ## along with this program; if not, see <http://www.gnu.org/licenses/>.
 ##
 
-import sigrokdecode as srd
+# Generic I2C filtering protocol decoder
 
+import sigrokdecode as srd
 
 class Decoder(srd.Decoder):
     api_version = 1
@@ -40,11 +41,14 @@ class Decoder(srd.Decoder):
     def start(self, metadata):
         self.out_proto = self.add(srd.OUTPUT_PROTO, 'i2cdata')
         if self.options['direction'] not in ('', 'read', 'write'):
-            raise Exception("Invalid direction: expected 'read' or 'write'")
+            raise Exception('Invalid direction: expected "read" or "write"')
+
+    def report(self):
+        pass
 
     def decode(self, ss, es, data):
         try:
-            cmd, data, ack_bit = data
+            cmd, data = data
         except Exception as e:
             raise Exception('Malformed I2C input: %s' % str(e)) from e
 
@@ -56,6 +60,9 @@ class Decoder(srd.Decoder):
         if cmd == 'STOP':
             self.state = None
             return
+        if cmd in ('ACK', 'NACK'):
+            # Don't care, we just want data.
+            return
 
         if self.state == 'start':
             # Start of a transfer, see if we want this one.
@@ -73,4 +80,3 @@ class Decoder(srd.Decoder):
         else:
             raise Exception('Invalid state: %s' % self.state)
 
-