]> sigrok.org Git - libsigrokdecode.git/blobdiff - decoders/spi.py
srd: decoders: Metadata consistency fixes/updates.
[libsigrokdecode.git] / decoders / spi.py
index 2c7445f9f427354444743095a6b1741625413572..e6a59bf6cbdda9e49482ddc0d3667f8fea2e3d00 100644 (file)
 ## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
 ##
 
-import sigrokdecode
+import sigrokdecode as srd
 
-class Decoder(sigrokdecode.Decoder):
+class Decoder(srd.Decoder):
     id = 'spi'
     name = 'SPI'
-    desc = '...desc...'
     longname = 'Serial Peripheral Interface (SPI) bus'
+    desc = '...desc...'
     longdesc = '...longdesc...'
     author = 'Gareth McMullin'
     email = 'gareth@blacksphere.co.nz'
@@ -36,18 +36,17 @@ class Decoder(sigrokdecode.Decoder):
         {'id': 'sck', 'name': 'CLK', 'desc': 'SPI clock line'},
     ]
     options = {}
+    annotations = []
 
     def __init__(self):
         self.oldsck = 1
         self.rxcount = 0
         self.rxdata = 0
         self.bytesreceived = 0
-        self.output_protocol = None
-        self.output_annotation = None
 
     def start(self, metadata):
-        # self.output_protocol = self.output_new(2)
-        self.output_annotation = self.output_new(1)
+        # self.out_proto = self.add(srd.OUTPUT_PROTO, 'spi')
+        self.out_ann = self.add(srd.OUTPUT_ANN, 'spi')
 
     def report(self):
         return 'SPI: %d bytes received' % self.bytesreceived
@@ -81,8 +80,8 @@ class Decoder(sigrokdecode.Decoder):
                 'display':('%02X' % self.rxdata),
                 'type':'spi',
             }
-            # self.put(0, 0, self.output_protocol, out_proto)
-            self.put(0, 0, self.output_annotation, outdata)
+            # self.put(0, 0, self.out_proto, out_proto)
+            self.put(0, 0, self.out_ann, outdata)
             # Reset decoder state
             self.rxdata = 0
             self.rxcount = 0