]> sigrok.org Git - libsigrokdecode.git/blob - decoders/usb_request/__init__.py
66723dc20831960017a1d7de8c00de43b4a4ddbc
[libsigrokdecode.git] / decoders / usb_request / __init__.py
1 ##
2 ## This file is part of the libsigrokdecode project.
3 ##
4 ## Copyright (C) 2015 Stefan BrĂ¼ns <stefan.bruens@rwth-aachen.de>
5 ##
6 ## This program is free software; you can redistribute it and/or modify
7 ## it under the terms of the GNU General Public License as published by
8 ## the Free Software Foundation; either version 2 of the License, or
9 ## (at your option) any later version.
10 ##
11 ## This program is distributed in the hope that it will be useful,
12 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 ## GNU General Public License for more details.
15 ##
16 ## You should have received a copy of the GNU General Public License
17 ## along with this program; if not, see <http://www.gnu.org/licenses/>.
18 ##
19
20 '''
21 This decoder stacks on top of the 'usb_packet' PD and decodes the USB
22 (low-speed and full-speed) transactions.
23
24 Transactions and requests are tracked per device address and endpoint.
25
26 Tracking of CONTROL requests is quite accurate, as these always start with
27 a SETUP token and are completed by an IN or OUT transaction, the status
28 packet. All transactions during the DATA stage are combined.
29
30 For BULK and INTERRUPT requests, each transaction starts with an IN or OUT
31 request, and is considered completed after the first transaction containing
32 data has been ACKed. Normally a request is only completed after a short or
33 zero length packet, but this would require knowledge about the max packet
34 size of an endpoint.
35
36 All INTERRUPT requests are treated as BULK requests, as on the link layer
37 both are identical.
38
39 The PCAP binary output contains 'SUBMIT' and 'COMPLETE' records. For
40 CONTROL request, the SUBMIT contains the SETUP request, the data is
41 either contained in the SUBMIT (Host-to-Device) or the COMPLETE
42 (Device-to-Host) record.
43
44 Details:
45 https://en.wikipedia.org/wiki/USB
46 http://www.usb.org/developers/docs/
47 '''
48
49 from .pd import Decoder