diff options
author | Stefan Brüns <stefan.bruens@rwth-aachen.de> | 2015-11-29 23:56:53 +0100 |
---|---|---|
committer | Stefan Brüns <stefan.bruens@rwth-aachen.de> | 2015-11-30 00:03:01 +0100 |
commit | 72b2a50cc23388ba3568fc96deda79a7e39cbfc5 (patch) | |
tree | ce33fc8f33cf92bfb9e6f0a2e370f1b89bc69b42 /decoders/usb_request/pd.py | |
parent | 519092e31aa4f2288dd82d43719d5a88d4e465b9 (diff) | |
download | libsigrokdecode-72b2a50cc23388ba3568fc96deda79a7e39cbfc5.tar.gz libsigrokdecode-72b2a50cc23388ba3568fc96deda79a7e39cbfc5.zip |
usb_request: Handle transmission timeouts
If a device or host did not receive a handshake 18 bit times after the
EOP, there was a transmission error and the host may repeat the
transmission
Diffstat (limited to 'decoders/usb_request/pd.py')
-rw-r--r-- | decoders/usb_request/pd.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/decoders/usb_request/pd.py b/decoders/usb_request/pd.py index 060929b..4227856 100644 --- a/decoders/usb_request/pd.py +++ b/decoders/usb_request/pd.py @@ -178,7 +178,7 @@ class Decoder(srd.Decoder): def handle_transfer(self): request_started = 0 - request_end = self.handshake in ('ACK', 'STALL') + request_end = self.handshake in ('ACK', 'STALL', 'timeout') ep = self.transaction_ep addr = self.transaction_addr if not (addr, ep) in self.request: @@ -306,6 +306,16 @@ class Decoder(srd.Decoder): if pcategory == 'TOKEN': if pname == 'SOF': return + if self.transaction_state == 'TOKEN RECEIVED': + transaction_timeout = self.transaction_es + # token length is 35 bits, timeout is 16..18 bit times (USB 2.0 7.1.19.1) + transaction_timeout += int((self.transaction_es - self.transaction_ss) / 2) + if (ss > transaction_timeout): + self.transaction_es = transaction_timeout + self.handshake = 'timeout' + self.handle_transfer() + self.transaction_state = 'IDLE' + if self.transaction_state != 'IDLE': self.putr(ss, es, [4, ['ERR: received %s token in state %s' % (pname, self.transaction_state)]]) @@ -314,6 +324,7 @@ class Decoder(srd.Decoder): sync, pid, addr, ep, crc5 = pinfo self.transaction_data = [] self.transaction_ss = ss + self.transaction_es = es self.transaction_state = 'TOKEN RECEIVED' self.transaction_ep = ep self.transaction_addr = addr |