]> sigrok.org Git - libsigrokdecode.git/blobdiff - decoders/i2cdemux/pd.py
All PDs: Only import the 'Decoder' object.
[libsigrokdecode.git] / decoders / i2cdemux / pd.py
index 23c42532240490be6c48a2df0ec7f53f5c344bad..68b75a0d66fc70c9854cd3ece0520eaac279c075 100644 (file)
@@ -21,7 +21,7 @@
 import sigrokdecode as srd
 
 class Decoder(srd.Decoder):
-    api_version = 1
+    api_version = 2
     id = 'i2cdemux'
     name = 'I²C demux'
     longname = 'I²C demultiplexer'
@@ -29,10 +29,6 @@ class Decoder(srd.Decoder):
     license = 'gplv2+'
     inputs = ['i2c']
     outputs = [] # TODO: Only known at run-time.
-    probes = []
-    optional_probes = []
-    options = {}
-    annotations = []
 
     def __init__(self, **kwargs):
         self.packets = [] # Local cache of I²C packets
@@ -41,7 +37,7 @@ class Decoder(srd.Decoder):
         self.streamcount = 0 # Number of created output streams
 
     def start(self):
-        self.out_proto = []
+        self.out_python = []
 
     # 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
@@ -63,8 +59,8 @@ class Decoder(srd.Decoder):
 
             # We're never seen this slave, add a new stream.
             self.slaves.append(databyte)
-            self.out_proto.append(self.register(srd.OUTPUT_PYTHON,
-                                  proto_id='i2c-%s' % hex(databyte)))
+            self.out_python.append(self.register(srd.OUTPUT_PYTHON,
+                                   proto_id='i2c-%s' % hex(databyte)))
             self.stream = self.streamcount
             self.streamcount += 1
         elif cmd == 'STOP':
@@ -73,10 +69,9 @@ class Decoder(srd.Decoder):
 
             # Send the whole chunk of I²C packets to the correct stream.
             for p in self.packets:
-                self.put(p[0], p[1], self.out_proto[self.stream], p[2])
+                self.put(p[0], p[1], self.out_python[self.stream], p[2])
 
             self.packets = []
             self.stream = -1
         else:
             pass # Do nothing, only add the I²C packet to our cache.
-