X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=decoders%2Fusb_request%2Fpd.py;h=2835bf9036142314adff4d167173b0997b799124;hb=2b46b01c72c06683b3130647affe92c425d573b5;hp=76e015b93d52fcb9a32d040f0cbb184096b5d5fc;hpb=fc9d619c520c2b47b52ff71e30260ed9333f33f2;p=libsigrokdecode.git diff --git a/decoders/usb_request/pd.py b/decoders/usb_request/pd.py index 76e015b..2835bf9 100644 --- a/decoders/usb_request/pd.py +++ b/decoders/usb_request/pd.py @@ -120,6 +120,7 @@ class Decoder(srd.Decoder): license = 'gplv2+' inputs = ['usb_packet'] outputs = ['usb_request'] + tags = ['PC'] annotations = ( ('request-setup-read', 'Setup: Device-to-host'), ('request-setup-write', 'Setup: Host-to-device'), @@ -136,6 +137,9 @@ class Decoder(srd.Decoder): ) def __init__(self): + self.reset() + + def reset(self): self.samplerate = None self.request = {} self.request_id = 0 @@ -168,7 +172,8 @@ class Decoder(srd.Decoder): def metadata(self, key, value): if key == srd.SRD_CONF_SAMPLERATE: self.samplerate = value - self.secs_per_sample = float(1) / float(self.samplerate) + if self.samplerate: + self.secs_per_sample = float(1) / float(self.samplerate) def start(self): self.out_binary = self.register(srd.OUTPUT_BINARY) @@ -196,18 +201,17 @@ class Decoder(srd.Decoder): request = self.request[(addr,ep)] if request_end: + request['es'] = self.es_transaction request['handshake'] = self.handshake # BULK or INTERRUPT transfer if request['type'] in (None, 'BULK IN') and self.transaction_type == 'IN': request['type'] = 'BULK IN' request['data'] += self.transaction_data - request['es'] = self.es_transaction self.handle_request(request_started, request_end) elif request['type'] in (None, 'BULK OUT') and self.transaction_type == 'OUT': request['type'] = 'BULK OUT' request['data'] += self.transaction_data - request['es'] = self.es_transaction self.handle_request(request_started, request_end) # CONTROL, SETUP stage @@ -233,11 +237,9 @@ class Decoder(srd.Decoder): # CONTROL, STATUS stage elif request['type'] == 'SETUP IN' and self.transaction_type == 'OUT': - request['es'] = self.es_transaction self.handle_request(0, request_end) elif request['type'] == 'SETUP OUT' and self.transaction_type == 'IN': - request['es'] = self.es_transaction self.handle_request(0, request_end) else: