if out != []:
self.put(out)
-
# https://www.sparkfun.com/products/9281
#
+import sigrok
+
# FIXME: This is just some example input for testing purposes...
example_packets = [
# START condition.
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'
self.state = self.INITIALIZED
self.databytecount = 0
- sigrok.put(out)
-
-import sigrok
-
-sigrok.register(Decoder)
+ self.put(out)
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...'
'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)
-
return pid + ' ' + data
-class Decoder():
+class Decoder(sigrok.Decoder):
id = 'usb'
name = 'USB'
desc = 'Universal Serial Bus'
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 = ''
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)
-
## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
##
+import sigrok
+
class Sample():
def __init__(self, data):
self.data = data
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 = '...'
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)