From: Uwe Hermann Date: Sun, 4 Dec 2011 19:59:56 +0000 (+0100) Subject: srd: Update decoders to changed API. X-Git-Tag: libsigrokdecode-0.1.0~247 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=1c8ac5bf07e0ded582234c9ef50ba10f042bae52;p=libsigrokdecode.git srd: Update decoders to changed API. --- 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)