summaryrefslogtreecommitdiff
path: root/decoders/usb_request
diff options
context:
space:
mode:
authorStefan Brüns <stefan.bruens@rwth-aachen.de>2019-06-17 19:51:29 +0200
committerStefan Brüns <stefan.bruens@rwth-aachen.de>2019-06-17 19:51:29 +0200
commit7c4029417cbdd12fdbfbd2a94107e215c1eaa605 (patch)
treec127f00bce1ce593ec731b6b36472d835cbff687 /decoders/usb_request
parentff73d589b60677cf405d8e6af8810c849595fd7a (diff)
downloadlibsigrokdecode-7c4029417cbdd12fdbfbd2a94107e215c1eaa605.tar.gz
libsigrokdecode-7c4029417cbdd12fdbfbd2a94107e215c1eaa605.zip
usb_request: Fix some decoding errors
Append OUT data only if it has been ACKed. OUT transfers (BULK OUT or CONTROL transfer DATA stage) are typically NACKed to create backpressure. Always keep IN and OUT transfers separate. On the physical layer, the endpoint number only uses 4 bits, and IN and OUT use separate tokens. In case the transfer is an IN transfer, set the high bit as used in the endpoint descriptors (i.e. 0x81 is IN enpoint 1, 0x01 is OUT endpoint 1).
Diffstat (limited to 'decoders/usb_request')
-rw-r--r--decoders/usb_request/pd.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/decoders/usb_request/pd.py b/decoders/usb_request/pd.py
index 49b0b35..25ee4c5 100644
--- a/decoders/usb_request/pd.py
+++ b/decoders/usb_request/pd.py
@@ -211,7 +211,8 @@ class Decoder(srd.Decoder):
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
+ if self.handshake == 'ACK':
+ request['data'] += self.transaction_data
self.handle_request(request_started, request_end)
# CONTROL, SETUP stage
@@ -231,7 +232,8 @@ class Decoder(srd.Decoder):
request['data'] += self.transaction_data
elif request['type'] == 'SETUP OUT' and self.transaction_type == 'OUT':
- request['data'] += self.transaction_data
+ if self.handshake == 'ACK':
+ request['data'] += self.transaction_data
if request['wLength'] == len(request['data']):
self.handle_request(1, 0)
@@ -339,6 +341,8 @@ class Decoder(srd.Decoder):
self.es_transaction = es
self.transaction_state = 'TOKEN RECEIVED'
self.transaction_ep = ep
+ if ep > 0 and pname == 'IN':
+ self.transaction_ep = ep + 0x80
self.transaction_addr = addr
self.transaction_type = pname # IN OUT SETUP