Sophie

Sophie

distrib > Mandriva > 2010.1 > x86_64 > by-pkgid > f48b0484566fe5f15f1edab7e7e31247 > files > 26

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: libusb-1.0 API Reference</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 class="current"><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>libusb-1.0 API Reference </h1><h2><a class="anchor" id="intro">
Introduction</a></h2>
<p>libusb is an open source library that allows you to communicate with USB devices from userspace. For more info, see the <a href="http://libusb.sourceforge.net">libusb homepage</a>.</p>
<p>This documentation is aimed at application developers wishing to communicate with USB peripherals from their own software. After reviewing this documentation, feedback and questions can be sent to the <a href="http://sourceforge.net/mail/?group_id=1674">libusb-devel mailing list</a>.</p>
<p>This documentation assumes knowledge of how to operate USB devices from a software standpoint (descriptors, configurations, interfaces, endpoints, control/bulk/interrupt/isochronous transfers, etc). Full information can be found in the <a href="http://www.usb.org/developers/docs/">USB 2.0 Specification</a> which is available for free download. You can probably find less verbose introductions by searching the web.</p>
<h2><a class="anchor" id="features">
Library features</a></h2>
<ul>
<li>All transfer types supported (control/bulk/interrupt/isochronous)</li>
<li>2 transfer interfaces:<ol type="a">
<li>Synchronous (simple)</li>
<li>Asynchronous (more complicated, but more powerful)</li>
</ol>
</li>
<li>Thread safe (although the asynchronous interface means that you usually won't need to thread)</li>
<li>Lightweight with lean API</li>
<li>Compatible with libusb-0.1 through the libusb-compat-0.1 translation layer</li>
</ul>
<h2><a class="anchor" id="gettingstarted">
Getting Started</a></h2>
<p>To begin reading the API documentation, start with the Modules page which links to the different categories of libusb's functionality.</p>
<p>One decision you will have to make is whether to use the synchronous or the asynchronous data transfer interface. The <a class="el" href="io.html">Synchronous and asynchronous device I/O</a> documentation provides some insight into this topic.</p>
<p>Some example programs can be found in the libusb source distribution under the "examples" subdirectory. The libusb homepage includes a list of real-life project examples which use libusb.</p>
<h2><a class="anchor" id="errorhandling">
Error handling</a></h2>
<p>libusb functions typically return 0 on success or a negative error code on failure. These negative error codes relate to LIBUSB_ERROR constants which are listed on the <a class="el" href="group__misc.html">miscellaneous</a> documentation page.</p>
<h2><a class="anchor" id="msglog">
Debug message logging</a></h2>
<p>libusb does not log any messages by default. Your application is therefore free to close stdout/stderr and those descriptors may be reused without worry.</p>
<p>The <a class="el" href="group__lib.html#ga5f8376b7a863a5a8d5b8824feb8a427a" title="Set message verbosity.">libusb_set_debug()</a> function can be used to enable stdout/stderr logging of certain messages. Under standard configuration, libusb doesn't really log much at all, so you are advised to use this function to enable all error/warning/informational messages. It will help you debug problems with your software.</p>
<p>The logged messages are unstructured. There is no one-to-one correspondence between messages being logged and success or failure return codes from libusb functions. There is no format to the messages, so you should not try to capture or parse them. They are not and will not be localized. These messages are not suitable for being passed to your application user; instead, you should interpret the error codes returned from libusb functions and provide appropriate notification to the user. The messages are simply there to aid you as a programmer, and if you're confused because you're getting a strange error code from a libusb function, enabling message logging may give you a suitable explanation.</p>
<p>The LIBUSB_DEBUG environment variable can be used to enable message logging at run-time. This environment variable should be set to a number, which is interpreted the same as the <a class="el" href="group__lib.html#ga5f8376b7a863a5a8d5b8824feb8a427a" title="Set message verbosity.">libusb_set_debug()</a> parameter. When this environment variable is set, the message logging verbosity level is fixed and <a class="el" href="group__lib.html#ga5f8376b7a863a5a8d5b8824feb8a427a" title="Set message verbosity.">libusb_set_debug()</a> effectively does nothing.</p>
<p>libusb can be compiled without any logging functions, useful for embedded systems. In this case, <a class="el" href="group__lib.html#ga5f8376b7a863a5a8d5b8824feb8a427a" title="Set message verbosity.">libusb_set_debug()</a> and the LIBUSB_DEBUG environment variable have no effects.</p>
<p>libusb can also be compiled with verbose debugging messages. When the library is compiled in this way, all messages of all verbosities are always logged. <a class="el" href="group__lib.html#ga5f8376b7a863a5a8d5b8824feb8a427a" title="Set message verbosity.">libusb_set_debug()</a> and the LIBUSB_DEBUG environment variable have no effects.</p>
<h2><a class="anchor" id="remarks">
Other remarks</a></h2>
<p>libusb does have imperfections. The <a class="el" href="caveats.html">caveats</a> page attempts to document these. </p>
</div>
<hr class="footer"/><address style="text-align: right;"><small>Generated on Wed Apr 28 09:03:58 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>