aboutsummaryrefslogtreecommitdiff
path: root/lib/vusb/examples/usbtool/Readme.txt
diff options
context:
space:
mode:
Diffstat (limited to 'lib/vusb/examples/usbtool/Readme.txt')
-rw-r--r--lib/vusb/examples/usbtool/Readme.txt209
1 files changed, 209 insertions, 0 deletions
diff --git a/lib/vusb/examples/usbtool/Readme.txt b/lib/vusb/examples/usbtool/Readme.txt
new file mode 100644
index 000000000..33f527cc4
--- /dev/null
+++ b/lib/vusb/examples/usbtool/Readme.txt
@@ -0,0 +1,209 @@
1This is the Readme file for usbtool, a general purpose command line utility
2which can send USB requests to arbitrary devices. Usbtool is based on libusb.
3
4
5WHAT IS USBTOOL GOOD FOR?
6=========================
7When you implement a communication protocol like USB, you must usually write
8two programs: one on each end of the communication. For USB, this means that
9you must write a firmware for the device and driver software for the host.
10
11Usbtool can save you the work of writing the host software, at least during
12firmware development and testing. Usbtool can send control-in and -out
13requests to arbitrary devices and send and receive data on interrupt- and
14bulk-endpoints.
15
16Usbtool is not only a useful developer tool, it's also an example for using
17libusb for communication with the device.
18
19
20SYNOPSIS
21========
22 usbtool [options] <command>
23
24
25COMMANDS
26========
27 list
28 This command prints a list of devices found on all available USB busses.
29 Options -v, -V, -p and -P can be used to filter the list.
30
31 control in|out <type> <recipient> <request> <value> <index>
32 Sends a control-in or control-out request to the device. The request
33 parameters are:
34 type ........ Type of request, can be "standard", "class", "vendor" or
35 "reserved". The type determines which software module in
36 the device is responsible for answering the request:
37 Standard requests are answered by the driver, class
38 requests by the class implementation (e.g. HID, CDC) and
39 vendor requests by custom code.
40 recipient ... Recipient of the request in the device. Can be "device",
41 "interface", "endpoint" or "other". For standard and
42 class requests, the specification defines a recipient for
43 each request. For vendor requests, choose whatever your
44 code expects.
45 request ..... 8 bit numeric value identifying the request.
46 value ....... 16 bit numeric value passed to the device.
47 index ....... another 16 bit numeric value passed to the device.
48 Use options -v, -V, -p and -P to single out a particular device. Use
49 options -d or -D to to send data in an OUT request. Use options -n, -O
50 and -b to determine what to do with data received in an IN request.
51
52 interrupt in|out
53 Sends or receives data on an interrupt-out resp. -in endpoint.
54 Use options -v, -V, -p and -P to single out a particular device. Use
55 options -d or -D to to send data to an OUT endpoint. Use options -n, -O
56 and -b to determine what to do with data received from an IN endpoint.
57 Use option -e to set the endpoint number, -c to choose a configuration
58 -i to claim a particular interface.
59
60 bulk in|out
61 Same as "interrupt in" and "interrupt out", but for bulk endpoints.
62
63
64OPTIONS
65=======
66Most options have already been mentioned at the commands which use them.
67here is a complete list:
68
69 -h or -?
70 Prints a short help.
71
72 -v <vendor-id>
73 Numeric vendor ID, can be "*" to allow any VID. Take only devices with
74 matching vendor ID into account.
75
76 -p <product-id>
77 Numeric product ID, can be "*" to allow any PID. Take only devices with
78 matching product ID into account.
79
80 -V <vendor-name-pattern>
81 Shell style matching pattern for vendor name. Take only devices into
82 account which have a vendor name that matches this pattern.
83
84 -P <product-name-pattern>
85 Shell style matching pattern for product name. Take only devices into
86 account which have a product name that matches this pattern.
87
88 -S <serial-pattern>
89 Shell style matching pattern for serial number. Take only devices into
90 account which have a serial number that matches this pattern.
91
92 -d <databytes>
93 Data bytes to send to the device, comma separated list of numeric values.
94 E.g.: "1,2,3,4,5".
95
96 -D <file>
97 Binary data sent to the device should be taken from this file.
98
99 -O <file>
100 Write received data bytes to the given file. Format is either hex or
101 binary, depending on the -b flag. By default, received data is printed
102 to standard output.
103
104 -b
105 Request binary output format for files and standard output. Default is
106 a hexadecimal listing.
107
108 -n <count>
109 Numeric value: Maximum number of bytes to receive. This value is passed
110 directly to the libusb API functions.
111
112 -e <endpoint>
113 Numeric value: Endpoint number for interrupt and bulk commands.
114
115 -t <timeout>
116 Numeric value: Timeout in milliseconds for the request. This value is
117 passed directly to the libusb API functions.
118
119 -c <configuration>
120 Numeric value: Interrupt and bulk endpoints can usually only be used if
121 a configuration and an interface has been chosen. Use -c and -i to
122 specify configuration and interface values.
123
124 -i <interface>
125 Numeric value: Interrupt and bulk endpoints can usually only be used if
126 a configuration and an interface has been chosen. Use -c and -i to
127 specify configuration and interface values.
128
129 -w
130 Usbtool may be too verbose with warnings for some applications. Use this
131 option to suppress USB warnings.
132
133
134NUMERIC VALUES
135==============
136All numeric values can be given in hexadecimal, decimal or octal. Hex values
137are identified by their 0x or 0X prefix, octal values by a leading "0" (the
138digit zero) and decimal values because they start with a non-zero digit. An
139optional sign character is allowed. The special value "*" is translated to
140zero and stands for "any value" in some contexts.
141
142
143SHELL STYLE MATCHING PATTERNS
144=============================
145Some options take shell style matching patterns as an argument. This refers
146to Unix shells and their file wildcard operations:
147 + "*" (asterisk character) matches any number (0 to infinite) of any
148 characters.
149 + "?" matches exactly one arbitrary character.
150 + A list of characters in square brackets (e.g. "[abc]") matches any of the
151 characters in the list. If a dash ("-") is in the list, it must be the
152 first or the last character. If a caret ("^") is in the list, it must
153 not be the first character. A closing square bracket ("]") must be the
154 first character in the list. A range of characters can be specified in
155 the way "[a-z]". This matches all characters with numeric representation
156 (usually ASCII) starting with "a" and ending with "z". The entire
157 construct matches only one character.
158 + A list of characters in square brackets starting with a caret ("^"), e.g.
159 ("[^abc]") matches any character NOT in the list. The other rules are as
160 above.
161 + "\" (backslash) followed by any character matches that following
162 character. This can be used to escape "*", "?", "[" and "\".
163
164
165BUILDING USBTOOL
166================
167Usbtool uses libusb on Unix and libusb-win32 on Windows. These libraries can
168be obtained from http://libusb.sourceforge.net/ and
169http://libusb-win32.sourceforge.net/ respectively. On Unix, a simple "make"
170should compile the sources (although you may have to edit Makefile to
171include or remove additional libraries). On Windows, we recommend that you
172use MinGW and MSYS. See the top level Readme file for details. Edit
173Makefile.windows according to your library installation paths and build with
174"make -f Makefile.windows".
175
176
177EXAMPLES
178========
179To list all devices connected to your computer, do
180
181 usbtool -w list
182
183To check whether our selection options single out the desired device, use eg.
184
185 usbtool -w -P LEDControl list
186
187This command shows all LEDControl devices connected or prints nothing if
188none is found. LEDControl is the device from the "custom-class" example.
189
190You can also send commands to the LEDControl device using usbtool. From
191the file requests.h in custom-class/firmware, we know that the set-status
192request has numeric value 1 and the get-status request is 2. See this file
193for details of the protocol used. We can therefore query the status with
194
195 usbtool -w -P LEDControl control in vendor device 2 0 0
196
197This command prints 0x00 if the LED is off or 0x01 if it is on. To turn the
198LED on, use
199
200 usbtool -w -P LEDControl control out vendor device 1 1 0
201
202and to turn it off, use
203
204 usbtool -w -P LEDControl control out vendor device 1 0 0
205
206
207----------------------------------------------------------------------------
208(c) 2008 by OBJECTIVE DEVELOPMENT Software GmbH.
209http://www.obdev.at/