]> sigrok.org Git - libsigrokdecode.git/commitdiff
srd: Update decoders to changed API.
authorUwe Hermann <redacted>
Sun, 4 Dec 2011 19:59:56 +0000 (20:59 +0100)
committerUwe Hermann <redacted>
Sun, 4 Dec 2011 19:59:56 +0000 (20:59 +0100)
decoders/i2c.py
decoders/nunchuk.py
decoders/spi.py
decoders/srd_usb.py
decoders/transitioncounter.py

index 583c4d0d07a0953e6216c8c0c449a3d41ba03891..2b3b8756f7ad8fe4cee12f0c154aebc55e064694 100644 (file)
@@ -352,4 +352,3 @@ class Decoder(sigrok.Decoder):
         if out != []:
             self.put(out)
 
-
index e53d0de15683665bb38ebd1d6748e1aeefceae2e..95ba3b63f9bf739368f558c3604a32d5fd67092d 100644 (file)
@@ -30,6 +30,8 @@
 # https://www.sparkfun.com/products/9281
 #
 
+import sigrok
+
 # FIXME: This is just some example input for testing purposes...
 example_packets = [
     # START condition.
@@ -64,7 +66,7 @@ def sampleiter(data, unitsize):
     for i in range(0, len(data), unitsize):
         yield(Sample(data[i:i+unitsize]))
 
-class Decoder():
+class Decoder(sigrok.Decoder):
     id = 'nunchuk'
     name = 'Nunchuk'
     longname = 'Nintendo Wii Nunchuk decoder'
@@ -180,9 +182,5 @@ class Decoder():
                 self.state = self.INITIALIZED
                 self.databytecount = 0
 
-        sigrok.put(out)
-
-import sigrok
-
-sigrok.register(Decoder)
+        self.put(out)
 
index 9c0be9a88bde146da5fe1a9bc9b782e5de1c361a..a363b5afba3c0f53838229435876d83c0450d2e2 100644 (file)
@@ -31,7 +31,7 @@ def sampleiter(data, unitsize):
     for i in range(0, len(data), unitsize):
         yield(Sample(data[i:i+unitsize]))
 
-class Decoder():
+class Decoder(sigrok.Decoder):
     id = 'spi'
     name = 'SPI'
     desc = '...desc...'
@@ -89,12 +89,10 @@ class Decoder():
                 'display':('%02X' % self.rxdata),
                 'type':'spi',
             }
-            sigrok.put(outdata)
+            self.put(outdata)
             # Reset decoder state
             self.rxdata = 0
             self.rxcount = 0
             # Keep stats for summary
             self.bytesreceived += 1
 
-sigrok.register(Decoder)
-
index 07fc732a04531cb6ce3a9bbfd7a0adc1165a12f4..b0fa4e51cea29aff173707fc75a33ca283299b67 100644 (file)
@@ -110,7 +110,7 @@ def packet_decode(packet):
 
     return pid + ' ' + data
 
-class Decoder():
+class Decoder(sigrok.Decoder):
     id = 'usb'
     name = 'USB'
     desc = 'Universal Serial Bus'
@@ -164,11 +164,11 @@ class Decoder():
             if self.sym == SE0:
                 if bitcount == 1:
                     # End-Of-Packet (EOP)
-                    sigrok.put({"type":"usb", "data":self.packet,
-                                "display":packet_decode(self.packet)})
+                    self.put({"type":"usb", "data":self.packet,
+                              "display":packet_decode(self.packet)})
                 else:
                     # Longer than EOP, assume reset.
-                    sigrok.put({"type":"usb", "display":"RESET"})
+                    self.put({"type":"usb", "display":"RESET"})
                 self.scount = 0
                 self.sym = sym
                 self.packet = ''
@@ -180,10 +180,8 @@ class Decoder():
             if bitcount < 6 and sym != SE0:
                 self.packet += '0'
             elif bitcount > 6:
-                sigrok.put({"type":"usb", "display":"BIT STUFF ERROR"})
+                self.put({"type":"usb", "display":"BIT STUFF ERROR"})
 
             self.scount = 0
             self.sym = sym
 
-sigrok.register(Decoder)
-
index 3946d4b3bf607bf75d6c90eca3a9fd718dc3dc6e..46b5ac43f278d34f31c6cfccffcae49fffec52be 100644 (file)
@@ -18,6 +18,8 @@
 ## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
 ##
 
+import sigrok
+
 class Sample():
     def __init__(self, data):
         self.data = data
@@ -29,7 +31,7 @@ def sampleiter(data, unitsize):
     for i in range(0, len(data), unitsize):
         yield(Sample(data[i:i+unitsize]))
 
-class Decoder():
+class Decoder(sigrok.Decoder):
     id = 'transitioncounter'
     name = 'Transition counter'
     longname = '...'
@@ -106,9 +108,5 @@ class Decoder():
         outdata = []
         for i in range(self.channels):
             outdata += [[self.transitions[i], self.rising[i], self.falling[i]]]
-        sigrok.put(outdata)
-
-import sigrok
-
-sigrok.register(Decoder)
+        self.put(outdata)