X-Git-Url: https://sigrok.org/gitweb/?p=libsigrokdecode.git;a=blobdiff_plain;f=decoders%2Ftransitioncounter.py;h=46b5ac43f278d34f31c6cfccffcae49fffec52be;hp=f401b1520d48a8f87d1d769eefb6215c4f0c8b9b;hb=e9de9c90da6bd8c6a2314fb68f37cefc0a480926;hpb=3643fc3fe053bf531b4a7618d02c3d92c29f924b diff --git a/decoders/transitioncounter.py b/decoders/transitioncounter.py index f401b15..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,8 @@ 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 = '...' desc = 'Counts rising/falling edges in the signal.' @@ -55,7 +58,7 @@ class Decoder(): self.falling = [0] * self.channels def start(self, metadata): - self.unitsize = metadata["unitsize"] + self.unitsize = metadata['unitsize'] def report(self): pass @@ -65,7 +68,7 @@ class Decoder(): channel(s) of the signal.""" # We should accept a list of samples and iterate... - for sample in sampleiter(data["data"], self.unitsize): + for sample in sampleiter(data['data'], self.unitsize): # TODO: Eliminate the need for ord(). s = ord(sample.data) @@ -105,14 +108,5 @@ class Decoder(): outdata = [] for i in range(self.channels): outdata += [[self.transitions[i], self.rising[i], self.falling[i]]] - sigrok.put(outdata) - -# Use psyco (if available) as it results in huge performance improvements. -try: - import psyco - psyco.bind(decode) -except ImportError: - pass - -import sigrok + self.put(outdata)