Sophie

Sophie

distrib > Mandriva > 2010.1 > x86_64 > media > main-release > by-pkgid > f48b0484566fe5f15f1edab7e7e31247 > files > 25

lib64usb1.0-devel-1.0.7-3mdv2010.1.x86_64.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>libusb: Synchronous device I/O</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.6.3 -->
<script type="text/javascript">
<!--
function changeDisplayState (e){
  var num=this.id.replace(/[^[0-9]/g,'');
  var button=this.firstChild;
  var sectionDiv=document.getElementById('dynsection'+num);
  if (sectionDiv.style.display=='none'||sectionDiv.style.display==''){
    sectionDiv.style.display='block';
    button.src='open.gif';
  }else{
    sectionDiv.style.display='none';
    button.src='closed.gif';
  }
}
function initDynSections(){
  var divs=document.getElementsByTagName('div');
  var sectionCounter=1;
  for(var i=0;i<divs.length-1;i++){
    if(divs[i].className=='dynheader'&&divs[i+1].className=='dynsection'){
      var header=divs[i];
      var section=divs[i+1];
      var button=header.firstChild;
      if (button!='IMG'){
        divs[i].insertBefore(document.createTextNode(' '),divs[i].firstChild);
        button=document.createElement('img');
        divs[i].insertBefore(button,divs[i].firstChild);
      }
      header.style.cursor='pointer';
      header.onclick=changeDisplayState;
      header.id='dynheader'+sectionCounter;
      button.src='closed.gif';
      section.id='dynsection'+sectionCounter;
      section.style.display='none';
      section.style.marginLeft='14px';
      sectionCounter++;
    }
  }
}
window.onload = initDynSections;
-->
</script>
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
      <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="annotated.html"><span>Data&nbsp;Structures</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
</div>
<div class="contents">
<h1>Synchronous device I/O</h1>
<p>This page documents libusb's synchronous (blocking) API for USB device I/O.  
<a href="#_details">More...</a></p>
<table border="0" cellpadding="0" cellspacing="0">
<tr><td colspan="2"><h2>Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__syncio.html#gadb11f7a761bd12fc77a07f4568d56f38">libusb_control_transfer</a> (<a class="el" href="group__dev.html#ga7df95821d20d27b5597f1d783749d6a4">libusb_device_handle</a> *dev_handle, uint8_t bmRequestType, uint8_t bRequest, uint16_t wValue, uint16_t wIndex, unsigned char *data, uint16_t wLength, unsigned int timeout)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Perform a USB control transfer.  <a href="#gadb11f7a761bd12fc77a07f4568d56f38"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__syncio.html#gab8ae853ab492c22d707241dc26c8a805">libusb_bulk_transfer</a> (struct <a class="el" href="group__dev.html#ga7df95821d20d27b5597f1d783749d6a4">libusb_device_handle</a> *dev_handle, unsigned char endpoint, unsigned char *data, int length, int *transferred, unsigned int timeout)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Perform a USB bulk transfer.  <a href="#gab8ae853ab492c22d707241dc26c8a805"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__syncio.html#gac412bda21b7ecf57e4c76877d78e6486">libusb_interrupt_transfer</a> (struct <a class="el" href="group__dev.html#ga7df95821d20d27b5597f1d783749d6a4">libusb_device_handle</a> *dev_handle, unsigned char endpoint, unsigned char *data, int length, int *transferred, unsigned int timeout)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Perform a USB interrupt transfer.  <a href="#gac412bda21b7ecf57e4c76877d78e6486"></a><br/></td></tr>
</table>
<hr/><a name="_details"></a><h2>Detailed Description</h2>
<p>This page documents libusb's synchronous (blocking) API for USB device I/O. </p>
<p>This interface is easy to use but has some limitations. More advanced users may wish to consider using the <a class="el" href="group__asyncio.html">asynchronous I/O API</a> instead. </p>
<hr/><h2>Function Documentation</h2>
<a class="anchor" id="gadb11f7a761bd12fc77a07f4568d56f38"></a><!-- doxytag: member="sync.c::libusb_control_transfer" ref="gadb11f7a761bd12fc77a07f4568d56f38" args="(libusb_device_handle *dev_handle, uint8_t bmRequestType, uint8_t bRequest, uint16_t wValue, uint16_t wIndex, unsigned char *data, uint16_t wLength, unsigned int timeout)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int libusb_control_transfer </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__dev.html#ga7df95821d20d27b5597f1d783749d6a4">libusb_device_handle</a> *&nbsp;</td>
          <td class="paramname"> <em>dev_handle</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t&nbsp;</td>
          <td class="paramname"> <em>bmRequestType</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t&nbsp;</td>
          <td class="paramname"> <em>bRequest</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint16_t&nbsp;</td>
          <td class="paramname"> <em>wValue</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint16_t&nbsp;</td>
          <td class="paramname"> <em>wIndex</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">unsigned char *&nbsp;</td>
          <td class="paramname"> <em>data</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint16_t&nbsp;</td>
          <td class="paramname"> <em>wLength</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">unsigned int&nbsp;</td>
          <td class="paramname"> <em>timeout</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Perform a USB control transfer. </p>
<p>The direction of the transfer is inferred from the bmRequestType field of the setup packet.</p>
<p>The wValue, wIndex and wLength fields values should be given in host-endian byte order.</p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>dev_handle</em>&nbsp;</td><td>a handle for the device to communicate with </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>bmRequestType</em>&nbsp;</td><td>the request type field for the setup packet </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>bRequest</em>&nbsp;</td><td>the request field for the setup packet </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>wValue</em>&nbsp;</td><td>the value field for the setup packet </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>wIndex</em>&nbsp;</td><td>the index field for the setup packet </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>data</em>&nbsp;</td><td>a suitably-sized data buffer for either input or output (depending on direction bits within bmRequestType) </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>wLength</em>&nbsp;</td><td>the length field for the setup packet. The data buffer should be at least this size. </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>timeout</em>&nbsp;</td><td>timeout (in millseconds) that this function should wait before giving up due to no response being received. For an unlimited timeout, use value 0. </td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>on success, the number of bytes actually transferred </dd>
<dd>
LIBUSB_ERROR_TIMEOUT if the transfer timed out </dd>
<dd>
LIBUSB_ERROR_PIPE if the control request was not supported by the device </dd>
<dd>
LIBUSB_ERROR_NO_DEVICE if the device has been disconnected </dd>
<dd>
another LIBUSB_ERROR code on other failures </dd></dl>

</div>
</div>
<a class="anchor" id="gab8ae853ab492c22d707241dc26c8a805"></a><!-- doxytag: member="sync.c::libusb_bulk_transfer" ref="gab8ae853ab492c22d707241dc26c8a805" args="(struct libusb_device_handle *dev_handle, unsigned char endpoint, unsigned char *data, int length, int *transferred, unsigned int timeout)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int libusb_bulk_transfer </td>
          <td>(</td>
          <td class="paramtype">struct <a class="el" href="group__dev.html#ga7df95821d20d27b5597f1d783749d6a4">libusb_device_handle</a> *&nbsp;</td>
          <td class="paramname"> <em>dev_handle</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">unsigned char&nbsp;</td>
          <td class="paramname"> <em>endpoint</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">unsigned char *&nbsp;</td>
          <td class="paramname"> <em>data</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&nbsp;</td>
          <td class="paramname"> <em>length</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int *&nbsp;</td>
          <td class="paramname"> <em>transferred</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">unsigned int&nbsp;</td>
          <td class="paramname"> <em>timeout</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Perform a USB bulk transfer. </p>
<p>The direction of the transfer is inferred from the direction bits of the endpoint address.</p>
<p>For bulk reads, the <code>length</code> field indicates the maximum length of data you are expecting to receive. If less data arrives than expected, this function will return that data, so be sure to check the <code>transferred</code> output parameter.</p>
<p>You should also check the <code>transferred</code> parameter for bulk writes. Not all of the data may have been written.</p>
<p>Also check <code>transferred</code> when dealing with a timeout error code. libusb may have to split your transfer into a number of chunks to satisfy underlying O/S requirements, meaning that the timeout may expire after the first few chunks have completed. libusb is careful not to lose any data that may have been transferred; do not assume that timeout conditions indicate a complete lack of I/O.</p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>dev_handle</em>&nbsp;</td><td>a handle for the device to communicate with </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>endpoint</em>&nbsp;</td><td>the address of a valid endpoint to communicate with </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>data</em>&nbsp;</td><td>a suitably-sized data buffer for either input or output (depending on endpoint) </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>length</em>&nbsp;</td><td>for bulk writes, the number of bytes from data to be sent. for bulk reads, the maximum number of bytes to receive into the data buffer. </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>transferred</em>&nbsp;</td><td>output location for the number of bytes actually transferred. </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>timeout</em>&nbsp;</td><td>timeout (in millseconds) that this function should wait before giving up due to no response being received. For an unlimited timeout, use value 0.</td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>0 on success (and populates <code>transferred</code>) </dd>
<dd>
LIBUSB_ERROR_TIMEOUT if the transfer timed out (and populates <code>transferred</code>) </dd>
<dd>
LIBUSB_ERROR_PIPE if the endpoint halted </dd>
<dd>
LIBUSB_ERROR_OVERFLOW if the device offered more data, see <a class="el" href="packetoverflow.html">Packets and overflows</a> </dd>
<dd>
LIBUSB_ERROR_NO_DEVICE if the device has been disconnected </dd>
<dd>
another LIBUSB_ERROR code on other failures </dd></dl>

</div>
</div>
<a class="anchor" id="gac412bda21b7ecf57e4c76877d78e6486"></a><!-- doxytag: member="sync.c::libusb_interrupt_transfer" ref="gac412bda21b7ecf57e4c76877d78e6486" args="(struct libusb_device_handle *dev_handle, unsigned char endpoint, unsigned char *data, int length, int *transferred, unsigned int timeout)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int libusb_interrupt_transfer </td>
          <td>(</td>
          <td class="paramtype">struct <a class="el" href="group__dev.html#ga7df95821d20d27b5597f1d783749d6a4">libusb_device_handle</a> *&nbsp;</td>
          <td class="paramname"> <em>dev_handle</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">unsigned char&nbsp;</td>
          <td class="paramname"> <em>endpoint</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">unsigned char *&nbsp;</td>
          <td class="paramname"> <em>data</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&nbsp;</td>
          <td class="paramname"> <em>length</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int *&nbsp;</td>
          <td class="paramname"> <em>transferred</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">unsigned int&nbsp;</td>
          <td class="paramname"> <em>timeout</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Perform a USB interrupt transfer. </p>
<p>The direction of the transfer is inferred from the direction bits of the endpoint address.</p>
<p>For interrupt reads, the <code>length</code> field indicates the maximum length of data you are expecting to receive. If less data arrives than expected, this function will return that data, so be sure to check the <code>transferred</code> output parameter.</p>
<p>You should also check the <code>transferred</code> parameter for interrupt writes. Not all of the data may have been written.</p>
<p>Also check <code>transferred</code> when dealing with a timeout error code. libusb may have to split your transfer into a number of chunks to satisfy underlying O/S requirements, meaning that the timeout may expire after the first few chunks have completed. libusb is careful not to lose any data that may have been transferred; do not assume that timeout conditions indicate a complete lack of I/O.</p>
<p>The default endpoint bInterval value is used as the polling interval.</p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>dev_handle</em>&nbsp;</td><td>a handle for the device to communicate with </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>endpoint</em>&nbsp;</td><td>the address of a valid endpoint to communicate with </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>data</em>&nbsp;</td><td>a suitably-sized data buffer for either input or output (depending on endpoint) </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>length</em>&nbsp;</td><td>for bulk writes, the number of bytes from data to be sent. for bulk reads, the maximum number of bytes to receive into the data buffer. </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>transferred</em>&nbsp;</td><td>output location for the number of bytes actually transferred. </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>timeout</em>&nbsp;</td><td>timeout (in millseconds) that this function should wait before giving up due to no response being received. For an unlimited timeout, use value 0.</td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>0 on success (and populates <code>transferred</code>) </dd>
<dd>
LIBUSB_ERROR_TIMEOUT if the transfer timed out </dd>
<dd>
LIBUSB_ERROR_PIPE if the endpoint halted </dd>
<dd>
LIBUSB_ERROR_OVERFLOW if the device offered more data, see <a class="el" href="packetoverflow.html">Packets and overflows</a> </dd>
<dd>
LIBUSB_ERROR_NO_DEVICE if the device has been disconnected </dd>
<dd>
another LIBUSB_ERROR code on other error </dd></dl>

</div>
</div>
</div>
<hr class="footer"/><address style="text-align: right;"><small>Generated on Wed Apr 28 09:03:59 2010 for libusb by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.3 </small></address>
</body>
</html>