From: Stefan BrĂ¼ns Date: Sat, 22 Jul 2017 17:54:59 +0000 (+0200) Subject: usb_request: Handle CONTROL transfer protocol stalls X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=fc9d619c520c2b47b52ff71e30260ed9333f33f2;p=libsigrokdecode.git 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. --- 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):