diff options
author | Stefan Brüns <stefan.bruens@rwth-aachen.de> | 2017-07-22 19:54:59 +0200 |
---|---|---|
committer | Stefan Brüns <stefan.bruens@rwth-aachen.de> | 2017-07-22 19:54:59 +0200 |
commit | fc9d619c520c2b47b52ff71e30260ed9333f33f2 (patch) | |
tree | cd6904dc5c8ffb7f9f07f3ab8b23c638dab5a9df /decoders | |
parent | 2071c4d3d8503b8ae9ccd623cec1163ec6732a91 (diff) | |
download | libsigrokdecode-fc9d619c520c2b47b52ff71e30260ed9333f33f2.tar.gz libsigrokdecode-fc9d619c520c2b47b52ff71e30260ed9333f33f2.zip |
usb_request: Handle CONTROL transfer protocol stalls
According to the USB 2.0 spec, 8.5.3.4, a protocol stall condition lasts
until the next SETUP transfer. On reception of the SETUP, adjust the end
sample accordingly, and flush the previous CONTROL transfer.
Diffstat (limited to 'decoders')
-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 5d2d47d..76e015b 100644 --- a/decoders/usb_request/pd.py +++ b/decoders/usb_request/pd.py @@ -179,6 +179,14 @@ class Decoder(srd.Decoder): request_end = self.handshake in ('ACK', 'STALL', 'timeout') ep = self.transaction_ep addr = self.transaction_addr + + # Handle protocol STALLs, condition lasts until next SETUP transfer (8.5.3.4) + if self.transaction_type == 'SETUP' and (addr, ep) in self.request: + request = self.request[(addr,ep)] + if request['type'] in ('SETUP IN', 'SETUP OUT'): + request['es'] = self.ss_transaction + self.handle_request(0, 1) + if not (addr, ep) in self.request: self.request[(addr, ep)] = {'setup_data': [], 'data': [], 'type': None, 'ss': self.ss_transaction, 'es': None, @@ -187,6 +195,9 @@ class Decoder(srd.Decoder): request_started = 1 request = self.request[(addr,ep)] + if request_end: + request['handshake'] = self.handshake + # BULK or INTERRUPT transfer if request['type'] in (None, 'BULK IN') and self.transaction_type == 'IN': request['type'] = 'BULK IN' @@ -251,7 +262,7 @@ class Decoder(srd.Decoder): s += ' ][' for b in request['data']: s += ' %02X' % b - s += ' ] : %s' % self.handshake + s += ' ] : %s' % request['handshake'] return s def handle_request(self, request_start, request_end): |