⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 usbs-testing.html

📁 有关ecos2。0介绍了实时嵌入式的结构以及线程调度的实现和内存的管理等
💻 HTML
📖 第 1 页 / 共 4 页
字号:
symbolic link from <TTCLASS="FILENAME">usbhost</TT> to this executablewill be created, so users can just run <BCLASS="COMMAND">usbhost</B> toaccess the most recently-installed version.</P></LI><LI><P><SPANCLASS="APPLICATION">usbchmod</SPAN> will be installed in<TTCLASS="FILENAME">/usr/local/libexec/ecos/io_usb_slave_&lt;version&gt;</TT>.This program should only be run by <SPANCLASS="APPLICATION">usbhost</SPAN>,not invoked directly, so it is not placed in the <TTCLASS="FILENAME">bin</TT> directory. Again the presence of the package version in the directoryname allows multiple releases of the package to co-exist.</P></LI><LI><P>A Tcl script <TTCLASS="FILENAME">usbhost.tcl</TT> will get installed inthe same directory as <SPANCLASS="APPLICATION">usbchmod</SPAN>. This Tclscript is loaded automatically by the<SPANCLASS="APPLICATION">usbhost</SPAN> executable. </P></LI><LI><P>A number of additional Tcl scripts, for example<TTCLASS="FILENAME">list.tcl</TT> will get installed alongside<TTCLASS="FILENAME">usbhost.tcl</TT>. These correspond to various testcases provided as standard. If a given test case is specified on thecommand line and cannot be found relative to the current directorythen <SPANCLASS="APPLICATION">usbhost</SPAN> will search the installdirectory for these test cases.</P><DIVCLASS="NOTE"><BLOCKQUOTECLASS="NOTE"><P><B>Note: </B>Strictly speaking installing the <TTCLASS="FILENAME">usbhost.tcl</TT> andother Tcl scripts below the <TTCLASS="FILENAME">libexec</TT>directory deviates from standard practice: they arearchitecture-independent data files so should be installed belowthe <TTCLASS="FILENAME">share</TT> subdirectory. Inpractice the files are sufficiently small that there is no point insharing them, and keeping them below <TTCLASS="FILENAME">libexec</TT>simplifies the host-side software somewhat.</P></BLOCKQUOTE></DIV></LI></OL><P>The <BCLASS="COMMAND">usbhost</B> should be run only when there is asuitable target attached to the USB bus and running the<SPANCLASS="APPLICATION">usbtarget</SPAN> program. It will search<TTCLASS="FILENAME">/proc/bus/usb/devices</TT> for an entry correspondingto this program, invoke <SPANCLASS="APPLICATION">usbchmod</SPAN> ifnecessary to change the access rights, and then interact with<SPANCLASS="APPLICATION">usbtarget</SPAN> over the USB bus.<BCLASS="COMMAND">usbhost</B> should be invoked as follows:</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="SCREEN">$ usbhost [-v|--version] [-h|--help] [-V|--verbose] &lt;test&gt; [&lt;test parameters&gt;]</PRE></TD></TR></TABLE><P></P><OLTYPE="1"><LI><P>The <TTCLASS="PARAMETER"><I>-v</I></TT> or <TTCLASS="PARAMETER"><I>--version</I></TT>option will display version information for<SPANCLASS="APPLICATION">usbhost</SPAN> including the version of the USBslave package that was used to build the executable.</P></LI><LI><P>The <TTCLASS="PARAMETER"><I>-h</I></TT> or <TTCLASS="PARAMETER"><I>--help</I></TT> optionwill display usage information.</P></LI><LI><P>The <TTCLASS="PARAMETER"><I>-V</I></TT> or <TTCLASS="PARAMETER"><I>--verbose</I></TT>option can be used to obtain more information at run-time, for examplesome output for every USB transfer. This option can be repeatedmultiple times to increase the amount of output.</P></LI><LI><P>The first argument that does not begin with a hyphen specifies a testthat should be run, in the form of a Tcl script. For example anargument of <TTCLASS="PARAMETER"><I>list.tcl</I></TT> will cause<SPANCLASS="APPLICATION">usbhost</SPAN> to look for a script with thatname, adding a <TTCLASS="FILENAME">.tcl</TT> suffix if necessarary, andrun that script. <SPANCLASS="APPLICATION">usbhost</SPAN> will look in thecurrent directory first, then in the install tree for standard testscripts provided by the USB slave package.</P></LI><LI><P>Some test scripts may want their own parameters, for example aduration in seconds. These can be passed on the command line afterthe name of the test, for example<BCLASS="COMMAND">usbhost&nbsp;mytest&nbsp;60</B>. </P></LI></OL></DIV><DIVCLASS="REFSECT1"><ANAME="AEN17020"></A><H2>Writing a Test</H2><P>Each test is defined by a Tcl script, running inside an interpreterprovided by <SPANCLASS="APPLICATION">usbhost</SPAN>. In addition to thenormal Tcl functionality this interpreter provides a number ofvariables and functions related to USB testing. For example there is avariable <TTCLASS="VARNAME">bulk_in_endpoints</TT> that lists all theendpoints on the target that can perform bulk IN operations, and arelated array <TTCLASS="VARNAME">bulk_in</TT> which contains informationsuch as the minimum and maximum packets sizes. There is a function<TTCLASS="FUNCTION">bulktest</TT> which can be used to perform bulk testson a particular endpoint. A simple test script aimed at specifichardware could ignore the information variables since it would knowexactly what USB hardware is available on the target, whereas ageneral-purpose script would use the information to adapt to thehardware capabilities.</P><P>To avoid namespace pollution all USB-related Tcl variables andfunctions live in the <TTCLASS="VARNAME">usbtest::</TT> namespace.Therefore accessing requires either explicitly including thenamespace any references, for example<TTCLASS="LITERAL">$usbtest::bulk_in_endpoints</TT>, or by using Tcl's<TTCLASS="FUNCTION">namespace import</TT> facility.</P><P>A very simple test script might look like this:</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">usbtest::bulktest 1 out 4000usbtest::bulktest 2 in  4000if { [usbtest::start 60] } {    puts "Test successful"} else    puts "Test failed"    foreach result $usbtest::results {        puts $result    }}</PRE></TD></TR></TABLE><P>This would perform a test run involving 4000 bulk transfers from thehost to the target's endpoint 1, and concurrently 4000 bulk transfersfrom endpoint 2. Default settings for packet sizes, contents, anddelays would be used. The actual test would not start running until<TTCLASS="FILENAME">usbtest</TT> is invoked, and it is expected that thetest would complete within 60 seconds. If any failures occur then theyare reported.</P></DIV><DIVCLASS="REFSECT1"><ANAME="AEN17035"></A><H2>Available Hardware</H2><P>Each target-side USB device driver provides information about theactual capabilities of the hardware, for example which endpoints areavailable. Strictly speaking it provides information about what isactually supported by the device driver, which may be a subset of whatthe hardware is capable of. For example, the hardware may supportisochronous transfers on a particular endpoint but if there is nosoftware support for this in the driver then this endpoint will not belisted. When <SPANCLASS="APPLICATION">usbhost</SPAN> first contacts the<SPANCLASS="APPLICATION">usbtarget</SPAN> program running on the targetplatform, it obtains this information and makes it available to testscripts via Tcl variables:</P><P></P><DIVCLASS="VARIABLELIST"><DL><DT><TTCLASS="VARNAME">bulk_in_endpoints</TT></DT><DD><P>    This is a simple list of the endpoints which can support bulk IN    transfers. For example if the target-side hardware supports    these transfers on endpoints 3 and 5 then the value would be    <TTCLASS="LITERAL">&quot;3 5&quot;</TT> Typical test scripts would    iterate over the list using something like:  </P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">  if { 0 != [llength $usbtest::bulk_in_endpoints] } {      puts"Bulk IN endpoints: $usbtest::bulk_in_endpoints"      foreach endpoint $usbtest:bulk_in_endpoints {          &#8230;      }  }  </PRE></TD></TR></TABLE></DD><DT><TTCLASS="VARNAME">bulk_in()</TT></DT><DD><P>  This array holds additional information about each bulk IN endpoint.  The array is indexed by two fields, the endpoint number and one of  <TTCLASS="LITERAL">min_size</TT>, <TTCLASS="LITERAL">max_size</TT>,  <TTCLASS="LITERAL">max_in_padding</TT> and <TTCLASS="LITERAL">devtab</TT>:  </P><P></P><DIVCLASS="VARIABLELIST"><DL><DT><TTCLASS="LITERAL">min_size</TT></DT><DD><P>    This field specifies a lower bound on the size of bulk transfers,    and will typically will have a value of 1.    </P><DIVCLASS="NOTE"><BLOCKQUOTECLASS="NOTE"><P><B>Note: </B>    The typical minimum transfer size of a single byte is not strictly    speaking correct, since under some circumstances it can make sense    to have a transfer size of zero bytes. However current target-side    device drivers interpret a request to transfer zero bytes as a way    for higher-level code to determine whether or not an endpoint is    stalled, so it is not actually possible to perform zero-byte    transfers. This issue will be addressed at some future point.    </P></BLOCKQUOTE></DIV></DD><DT><TTCLASS="LITERAL">max_size</TT></DT><DD><P>    This field specifies an upper bound on the size of bulk transfers.    Some target-side drivers may be limited to transfers of say    0x0FFFF bytes because of hardware limitations. In practice the    transfer size is likely to be limited primarily to limit memory    consumption of the test code on the target hardware, and to ensure    that tests complete reasonably quickly. At the time of writing    transfers are limited to 4K.    </P></DD><DT><TTCLASS="LITERAL">max_in_padding</TT></DT><DD><P>    On some hardware it may be necessary for the target-side device    driver to send more data than is actually intended. For example    the SA11x0 USB hardware cannot perform bulk transfers that are    an exact multiple of 64 bytes, instead it must pad such    transfers with an extra byte and the host must be ready to    accept and discard this byte. The    <TTCLASS="LITERAL">max_in_padding</TT> field indicates the amount of    padding that is required. The low-level code inside    <SPANCLASS="APPLICATION">usbhost</SPAN> will use this field    automatically, and there is no need for test scripts to adjust    packet sizes for padding. The field is provided for    informational purposes only.    </P></DD><DT><TTCLASS="LITERAL">devtab</TT></DT><DD><P>    This is a string indicating whether or not the    target-side USB device driver supports access to this endpoint    via entries in the device table, in other words through    conventional calls like <TTCLASS="FUNCTION">open</TT> and    <TTCLASS="FUNCTION">write</TT>. Some device drivers may only    support low-level USB access because typically that is what gets    used by USB class-specific packages such as USB-ethernet.    An empty string indicates that no devtab entry is available,    otherwise it will be something like    <TTCLASS="LITERAL">&quot;/dev/usbs2w&quot;</TT>.     </P></DD></DL></DIV><P>  Typical test scripts would access this data using something like:  </P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">  foreach endpoint $usbtest:bulk_in_endpoints {      puts "Endpoint $endpoint: "      puts "    minimum transfer size $usbtest::bulk_in($endpoint,min_size)"      puts "    maximum transfer size $usbtest::bulk_in($endpoint,max_size)"      if { 0 == $usbtest::bulk_in($endpoint,max_in_padding) } {          puts "    no IN padding required"      } else {          puts "    $usbtest::bulk_in($endpoint,max_in_padding) bytes of IN padding required"      }      if { "" == $usbtest::bulk_in($endpoint,devtab) } {          puts "    no devtab entry provided"      } else {          puts "    corresponding devtab entry is $usbtest::bulk_in($endpoint,devtab)"      }  }  </PRE></TD></TR></TABLE></DD><DT><TTCLASS="VARNAME">bulk_out_endpoint</TT></DT><DD><P>    This is a simple list of the endpoints which can support bulk OUT    transfers. It is analogous to    <TTCLASS="VARNAME">bulk_in_endpoints</TT>.  </P></DD><DT><TTCLASS="VARNAME">bulk_out()</TT></DT><DD><P>  This array holds additional information about each bulk OUT  endpoint. It can be accessed in the same way as  <TTCLASS="VARNAME">bulk_in()</TT>, except that there is no  <TTCLASS="LITERAL">max_in_padding</TT> field because that field only  makes sense for IN transfers.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -