]> sigrok.org Git - libsigrokdecode.git/blobdiff - decoders/onewire_network/pd.py
All PDs: Bump api_version to 2.
[libsigrokdecode.git] / decoders / onewire_network / pd.py
index 813c595cd2412d0819024252f7572d3647af6462..23402a63ebae8dc86147b0f9a458cfebc8439478 100644 (file)
@@ -18,8 +18,6 @@
 ## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
 ##
 
-# 1-Wire protocol decoder (network layer)
-
 import sigrokdecode as srd
 
 # Dictionary of ROM commands and their names, next state.
@@ -35,7 +33,7 @@ command = {
 }
 
 class Decoder(srd.Decoder):
-    api_version = 1
+    api_version = 2
     id = 'onewire_network'
     name = '1-Wire network layer'
     longname = '1-Wire serial communication bus (network layer)'
@@ -43,12 +41,9 @@ class Decoder(srd.Decoder):
     license = 'gplv2+'
     inputs = ['onewire_link']
     outputs = ['onewire_network']
-    probes = []
-    optional_probes = []
-    options = {}
-    annotations = [
-        ['Text', 'Human-readable text'],
-    ]
+    annotations = (
+        ('text', 'Human-readable text'),
+    )
 
     def __init__(self, **kwargs):
         self.beg = 0
@@ -61,12 +56,9 @@ class Decoder(srd.Decoder):
         self.data = 0x0
         self.rom = 0x0000000000000000
 
-    def start(self, metadata):
-        self.out_proto = self.add(srd.OUTPUT_PROTO, 'onewire_network')
-        self.out_ann = self.add(srd.OUTPUT_ANN, 'onewire_network')
-
-    def report(self):
-        pass
+    def start(self):
+        self.out_python = self.register(srd.OUTPUT_PYTHON)
+        self.out_ann = self.register(srd.OUTPUT_ANN)
 
     def putx(self, data):
         # Helper function for most annotations.
@@ -74,7 +66,7 @@ class Decoder(srd.Decoder):
 
     def puty(self, data):
         # Helper function for most protocol packets.
-        self.put(self.beg, self.end, self.out_proto, data)
+        self.put(self.beg, self.end, self.out_python, data)
 
     def decode(self, ss, es, data):
         code, val = data
@@ -85,7 +77,7 @@ class Decoder(srd.Decoder):
             self.bit_cnt = 0
             self.put(ss, es, self.out_ann,
                      [0, ['Reset/presence: %s' % ('true' if val else 'false')]])
-            self.put(ss, es, self.out_proto, ['RESET/PRESENCE', val])
+            self.put(ss, es, self.out_python, ['RESET/PRESENCE', val])
             self.state = 'COMMAND'
             return