X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=decoders%2Fsrd_usb.py;h=842cf03d0cdc69ce3c9dc1517b0dea50c69e09fb;hb=677d597b072c0a1d2df81c5c193cd3678aef8d03;hp=4792eeb24ab06624f9716c0553fbd828362165dd;hpb=ea42f53ece1b82434ba6f5f43e23560b81c102bc;p=libsigrokdecode.git diff --git a/decoders/srd_usb.py b/decoders/srd_usb.py index 4792eeb..842cf03 100644 --- a/decoders/srd_usb.py +++ b/decoders/srd_usb.py @@ -40,15 +40,15 @@ # http://www.usb.org/developers/docs/ # -import sigrokdecode +import sigrokdecode as srd # States SE0, J, K, SE1 = 0, 1, 2, 3 syms = { - (False, False): SE0, - (True, False): J, - (False, True): K, - (True, True): SE1, + (0, 0): SE0, + (1, 0): J, + (0, 1): K, + (1, 1): SE1, } def bitstr_to_num(bitstr): @@ -99,7 +99,7 @@ def packet_decode(packet): return pid + ' ' + data -class Decoder(sigrokdecode.Decoder): +class Decoder(srd.Decoder): id = 'usb' name = 'USB' desc = 'Universal Serial Bus' @@ -118,13 +118,13 @@ class Decoder(sigrokdecode.Decoder): options = {} def __init__(self): - self.output_protocol = None - self.output_annotation = None + self.out_proto = None + self.out_ann = None def start(self, metadata): self.rate = metadata['samplerate'] - # self.output_protocol = self.output_new(2) - self.output_annotation = self.output_new(1) + # self.out_proto = self.add(srd.SRD_OUTPUT_PROTO, 'usb') + self.out_ann = self.add(srd.SRD_OUTPUT_ANN, 'usb') if self.rate < 48000000: raise Exception("Sample rate not sufficient for USB decoding") # Initialise decoder state. @@ -182,6 +182,6 @@ class Decoder(sigrokdecode.Decoder): self.sym = sym if out != []: - # self.put(0, 0, self.output_protocol, out_proto) - self.put(0, 0, self.output_annotation, out) + # self.put(0, 0, self.out_proto, out_proto) + self.put(0, 0, self.out_ann, out)