Writing a test, Available hardware – Comtrol eCos User Manual
Page 720
Testing
3. The
-V
or
--verbose
option can be used to obtain more information at run-time, for example some output
for every USB transfer. This option can be repeated multiple times to increase the amount of output.
4. The first argument that does not begin with a hyphen specifies a test that should be run, in the form of a Tcl
script. For example an argument of
list.tcl
will cause usbhost to look for a script with that name, adding a
.tcl
suffix if necessarary, and run that script. usbhost will look in the current directory first, then in the install
tree for standard test scripts provided by the USB slave package.
5. Some test scripts may want their own parameters, for example a duration in seconds. These can be passed on
the command line after the name of the test, for example usbhost mytest 60.
Writing a Test
Each test is defined by a Tcl script, running inside an interpreter provided by usbhost. In addition to the normal Tcl
functionality this interpreter provides a number of variables and functions related to USB testing. For example there
is a variable
bulk_in_endpoints
that lists all the endpoints on the target that can perform bulk IN operations,
and a related array
bulk_in
which contains information such as the minimum and maximum packets sizes. There
is a function
bulktest
which can be used to perform bulk tests on a particular endpoint. A simple test script
aimed at specific hardware could ignore the information variables since it would know exactly what USB hardware
is available on the target, whereas a general-purpose script would use the information to adapt to the hardware
capabilities.
To avoid namespace pollution all USB-related Tcl variables and functions live in the
usbtest::
namespace.
Therefore accessing requires either explicitly including the namespace any references, for example
$usbtest::bulk_in_endpoints
, or by using Tcl’s
namespace import
facility.
A very simple test script might look like this:
usbtest::bulktest 1 out 4000
usbtest::bulktest 2 in
4000
if { [usbtest::start 60] } {
puts "Test successful"
} else
puts "Test failed"
foreach result $usbtest::results {
puts $result
}
}
This would perform a test run involving 4000 bulk transfers from the host to the target’s endpoint 1, and concur-
rently 4000 bulk transfers from endpoint 2. Default settings for packet sizes, contents, and delays would be used.
The actual test would not start running until
usbtest
is invoked, and it is expected that the test would complete
within 60 seconds. If any failures occur then they are reported.
Available Hardware
Each target-side USB device driver provides information about the actual capabilities of the hardware, for example
which endpoints are available. Strictly speaking it provides information about what is actually supported by the
device driver, which may be a subset of what the hardware is capable of. For example, the hardware may support
isochronous transfers on a particular endpoint but if there is no software support for this in the driver then this
616