📄 usbs-testing.html
字号:
</P
></DD
><DT
><TT
CLASS="VARNAME"
>control()</TT
></DT
><DD
><P
> This array holds information about the control endpoint. It contains
two fields, <TT
CLASS="LITERAL"
>min_size</TT
> and
<TT
CLASS="LITERAL"
>max_size</TT
>. Note that there is no variable
<TT
CLASS="VARNAME"
>control_endpoints</TT
> because a USB target always
supports a single control endpoint <TT
CLASS="LITERAL"
>0</TT
>. Similarly
the <TT
CLASS="VARNAME"
>control</TT
> array does not use an endpoint number
as the first index because that would be redundant.
</P
></DD
><DT
><TT
CLASS="VARNAME"
>isochronous_in_endpoints</TT
> and
<TT
CLASS="VARNAME"
>isochronous_in()</TT
></DT
><DD
><P
> These variables provide the same information as
<TT
CLASS="VARNAME"
>bulk_in_endpoints</TT
> and <TT
CLASS="VARNAME"
>bulk_in</TT
>,
but for endpoints that support isochronous IN transfers.
</P
></DD
><DT
><TT
CLASS="VARNAME"
>isochronous_out_endpoints</TT
> and
<TT
CLASS="VARNAME"
>isochronous_out()</TT
></DT
><DD
><P
> These variables provide the same information as
<TT
CLASS="VARNAME"
>bulk_out_endpoints</TT
> and <TT
CLASS="VARNAME"
>bulk_out</TT
>,
but for endpoints that support isochronous OUT transfers.
</P
></DD
><DT
><TT
CLASS="VARNAME"
>interrupt_in_endpoints</TT
> and
<TT
CLASS="VARNAME"
>interrupt_in()</TT
></DT
><DD
><P
> These variables provide the same information as
<TT
CLASS="VARNAME"
>bulk_in_endpoints</TT
> and <TT
CLASS="VARNAME"
>bulk_in</TT
>,
but for endpoints that support interrupt IN transfers.
</P
></DD
><DT
><TT
CLASS="VARNAME"
>interrupt_out_endpoints</TT
> and
<TT
CLASS="VARNAME"
>interrupt_out()</TT
></DT
><DD
><P
> These variables provide the same information as
<TT
CLASS="VARNAME"
>bulk_out_endpoints</TT
> and <TT
CLASS="VARNAME"
>bulk_out</TT
>,
but for endpoints that support interrupt OUT transfers.
</P
></DD
></DL
></DIV
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN17142"
></A
><H2
>Testing Bulk Transfers</H2
><P
>The main function for initiating a bulk test is
<TT
CLASS="FUNCTION"
>usbtest::bulktest</TT
>. This takes three compulsory
arguments, and can be given a number of additional arguments to
control the exact behaviour. The compulsory arguments are:</P
><P
></P
><DIV
CLASS="VARIABLELIST"
><DL
><DT
>endpoint</DT
><DD
><P
> This specifies the endpoint to use. It should correspond to
one of the entries in
<TT
CLASS="VARNAME"
>usbtest::bulk_in_endpoints</TT
> or
<TT
CLASS="VARNAME"
>usbtest::bulk_out_endpoints</TT
>, depending on the
transfer direction.
</P
></DD
><DT
>direction</DT
><DD
><P
> This should be either <TT
CLASS="LITERAL"
>in</TT
> or <TT
CLASS="LITERAL"
>out</TT
>.
</P
></DD
><DT
>number of transfers</DT
><DD
><P
> This specifies the number of transfers that should take place. The
testing software does not currently support the concept of performing
transfers for a given period of time because synchronising this on
both the host and a wide range of targets is difficult. However it
is relatively easy to work out the approximate time a number of bulk
transfers should take place, based on a typical bandwidth of
1MB/second and assuming say a 1ms overhead per transfer.
Alternatively a test script could perform a small initial run to
determine what performance can actually be expected from a given
target, and then use this information to run a much longer test.
</P
></DD
></DL
></DIV
><P
>Additional arguments can be used to control the exact transfer. For
example a <TT
CLASS="PARAMETER"
><I
>txdelay+</I
></TT
> argument can be used to
slowly increase the delay between transfers. All such arguments involve
a value which can be passed either as part of the argument itself,
for example <TT
CLASS="LITERAL"
>txdelay+=5</TT
>, or as a subsequent
argument, <TT
CLASS="LITERAL"
>txdelay+ 5</TT
>. The possible arguments fall
into a number of categories: data, I/O mechanism, transmit size,
receive size, transmit delay, and receive delay.</P
><DIV
CLASS="REFSECT2"
><A
NAME="AEN17167"
></A
><H3
>Data</H3
><P
>An obvious parameter to control is the actual data that gets sent.
This can be controlled by the argument <TT
CLASS="PARAMETER"
><I
>data</I
></TT
>
which can take one of five values: <TT
CLASS="LITERAL"
>none</TT
>,
<TT
CLASS="LITERAL"
>bytefill</TT
>, <TT
CLASS="LITERAL"
>intfill</TT
>,
<TT
CLASS="LITERAL"
>byteseq</TT
> and <TT
CLASS="LITERAL"
>wordseq</TT
>. The default
value is <TT
CLASS="LITERAL"
>none</TT
>.</P
><P
></P
><DIV
CLASS="VARIABLELIST"
><DL
><DT
><TT
CLASS="LITERAL"
>none</TT
></DT
><DD
><P
> The transmit code will not attempt to fill the buffer in any way,
and the receive code will not check it. The actual data that gets
transferred will be whatever happened to be in the buffer before
the transfer started.
</P
></DD
><DT
><TT
CLASS="LITERAL"
>bytefill</TT
></DT
><DD
><P
> The entire buffer will be filled with a single byte, as per
<TT
CLASS="FUNCTION"
>memset</TT
>.
</P
></DD
><DT
><TT
CLASS="LITERAL"
>intfill</TT
></DT
><DD
><P
> The buffer will be treated as an array of 32-bit integers, and will
be filled with the same integer repeated the appropriate number of
times. If the buffer size is not a multiple of four bytes then
the last few bytes will be set to 0.
</P
></DD
><DT
><TT
CLASS="LITERAL"
>byteseq</TT
></DT
><DD
><P
> The buffer will be filled with a sequence of bytes, generated by
a linear congruential generator. If the first byte in the buffer is
filled with the value <TT
CLASS="LITERAL"
>x</TT
>, the next byte will be
<TT
CLASS="LITERAL"
>(m*x)+i</TT
>. For example a sequence of slowly
incrementing bytes can be achieved by setting both the multiplier
and the increment to 1. Alternatively a pseudo-random number
sequence can be achieved using values 1103515245 and 12345, as
per the standard C library <TT
CLASS="FUNCTION"
>rand</TT
> function.
For convenience these two constants are available as Tcl
variables <TT
CLASS="VARNAME"
>usbtest::MULTIPLIER</TT
> and
<TT
CLASS="VARNAME"
>usbtest::INCREMENT</TT
>.
</P
></DD
><DT
><TT
CLASS="LITERAL"
>wordseq</TT
></DT
><DD
><P
> This acts like <TT
CLASS="LITERAL"
>byteseq</TT
>, except that the buffer is
treated as an array of 32-bit integers rather than as an array of
bytes. If the buffer is not a multiple of four bytes then the last
few bytes will be filled with zeroes.
</P
></DD
></DL
></DIV
><P
>The above requires three additional parameters
<TT
CLASS="PARAMETER"
><I
>data1</I
></TT
>, <TT
CLASS="PARAMETER"
><I
>data*</I
></TT
> and
<TT
CLASS="PARAMETER"
><I
>data+</I
></TT
>. <TT
CLASS="PARAMETER"
><I
>data1</I
></TT
> specifies
the value to be used for byte or word fills, or the first number when
calculating a sequence. The default value is <TT
CLASS="LITERAL"
>0</TT
>.
<TT
CLASS="PARAMETER"
><I
>data*</I
></TT
> and <TT
CLASS="PARAMETER"
><I
>data+</I
></TT
> specify
the multiplier and increment for a sequence, and have default values
of <TT
CLASS="LITERAL"
>1</TT
> and <TT
CLASS="LITERAL"
>0</TT
> respectively. For
example, to perform a bulk transfer of a pseudo-random sequence of
integers starting with 42 the following code could be used:</P
><TABLE
BORDER="5"
BGCOLOR="#E0E0F0"
WIDTH="70%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>bulktest 2 IN 1000 data=wordseq data1=42 \
data* $usbtest::MULTIPLIER data+ $usbtest::INCREMENT</PRE
></TD
></TR
></TABLE
><P
>The above parameters define what data gets transferred for the first
transfer, but a test can involve multiple transfers. The data format
will be the same for all transfers, but it is possible to adjust the
current value, the multiplier, and the increment between each
transfer. This is achieved with parameters <TT
CLASS="PARAMETER"
><I
>data1*</I
></TT
>,
<TT
CLASS="PARAMETER"
><I
>data1+</I
></TT
>, <TT
CLASS="PARAMETER"
><I
>data**</I
></TT
>,
<TT
CLASS="PARAMETER"
><I
>data*+</I
></TT
>, <TT
CLASS="PARAMETER"
><I
>data+*</I
></TT
>, and
<TT
CLASS="PARAMETER"
><I
>data++</I
></TT
>, with default values of 1 for each
multiplier and 0 for each increment. For example, if the multiplier
for the first transfer is set to <TT
CLASS="LITERAL"
>2</TT
> using
<TT
CLASS="PARAMETER"
><I
>data*</I
></TT
>, and arguments
<TT
CLASS="LITERAL"
>data** 2</TT
> and <TT
CLASS="LITERAL"
>data*+ -1</TT
> are also
supplied, then the multiplier for subsequent transfers will be
<TT
CLASS="LITERAL"
>3</TT
>, <TT
CLASS="LITERAL"
>5</TT
>, <TT
CLASS="LITERAL"
>9</TT
>,
….</P
><DIV
CLASS="NOTE"
><BLOCKQUOTE
CLASS="NOTE"
><P
><B
>Note: </B
>Currently it is not possible for a test script to send specific data,
for example a specific sequence of bytes captured by a protocol analyser
that caused a problem. If the transfer was from host to target then
the target would have to know the exact sequence of bytes to expect,
which means transferring data over the USB bus when that data is known
to have caused problems in the past. Similarly for target to host
transfers the target would have to know what bytes to send. A possible
future extension of the USB testing support would allow for bounce
operations, where a given message is first sent to the target and then
sent back to the host, with only the host checking that the data was
returned correctly.</P
></BLOCKQUOTE
></DIV
></DIV
><DIV
CLASS="REFSECT2"
><A
NAME="AEN17237"
></A
><H3
>I/O Mechanism</H3
><P
>On the target side USB transfers can happen using either low-level
USB calls such as <TT
CLASS="FUNCTION"
>usbs_start_rx_buffer</TT
>, or by
higher-level calls which go through the device table. By default the
target-side code will use the low-level calls. If it is desired to
test the higher-level calls instead, for example because those are
what the application uses, then that can be achieved with an
argument <TT
CLASS="PARAMETER"
><I
>mechanism=devtab</I
></TT
>.</P
></DIV
><DIV
CLASS="REFSECT2"
><A
NAME="AEN17242"
></A
><H3
>Transmit Size</H3
><P
>The next set of arguments can be used to control the size of the
transmitted buffer: <TT
CLASS="PARAMETER"
><I
>txsize1</I
></TT
>,
<TT
CLASS="PARAMETER"
><I
>txsize>=</I
></TT
>, <TT
CLASS="PARAMETER"
><I
>txsize<=</I
></TT
>
<TT
CLASS="PARAMETER"
><I
>txsize*</I
></TT
>, <TT
CLASS="PARAMETER"
><I
>txsize/</I
></TT
>,
and <TT
CLASS="PARAMETER"
><I
>txsize+</I
></TT
>.</P
><P
><TT
CLASS="PARAMETER"
><I
>txsize1</I
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -