summaryrefslogtreecommitdiff
path: root/decoders
diff options
context:
space:
mode:
Diffstat (limited to 'decoders')
-rw-r--r--decoders/i2c.py1
-rw-r--r--decoders/nunchuk.py10
-rw-r--r--decoders/spi.py6
-rw-r--r--decoders/srd_usb.py12
-rw-r--r--decoders/transitioncounter.py10
5 files changed, 15 insertions, 24 deletions
diff --git a/decoders/i2c.py b/decoders/i2c.py
index 583c4d0..2b3b875 100644
--- a/decoders/i2c.py
+++ b/decoders/i2c.py
@@ -352,4 +352,3 @@ class Decoder(sigrok.Decoder):
if out != []:
self.put(out)
-
diff --git a/decoders/nunchuk.py b/decoders/nunchuk.py
index e53d0de..95ba3b6 100644
--- a/decoders/nunchuk.py
+++ b/decoders/nunchuk.py
@@ -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)
diff --git a/decoders/spi.py b/decoders/spi.py
index 9c0be9a..a363b5a 100644
--- a/decoders/spi.py
+++ b/decoders/spi.py
@@ -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)
-
diff --git a/decoders/srd_usb.py b/decoders/srd_usb.py
index 07fc732..b0fa4e5 100644
--- a/decoders/srd_usb.py
+++ b/decoders/srd_usb.py
@@ -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)
-
diff --git a/decoders/transitioncounter.py b/decoders/transitioncounter.py
index 3946d4b..46b5ac4 100644
--- a/decoders/transitioncounter.py
+++ b/decoders/transitioncounter.py
@@ -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)