Sophie

Sophie

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

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: Device handling and enumeration</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>Device handling and enumeration</h1>
<p>The functionality documented below is designed to help with the following operations:</p>
<ul>
<li>Enumerating the USB devices currently attached to the system</li>
<li>Choosing a device to operate from your software</li>
<li>Opening and closing the chosen device. </li>
</ul>
 
<a href="#_details">More...</a></p>
<table border="0" cellpadding="0" cellspacing="0">
<tr><td colspan="2"><h2>Typedefs</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">typedef struct <a class="el" href="group__dev.html#ga77eedd00d01eb7569b880e861a971c2b">libusb_device</a>&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__dev.html#ga77eedd00d01eb7569b880e861a971c2b">libusb_device</a></td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Structure representing a USB device detected on the system.  <a href="#ga77eedd00d01eb7569b880e861a971c2b"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">typedef struct <a class="el" href="group__dev.html#ga7df95821d20d27b5597f1d783749d6a4">libusb_device_handle</a>&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__dev.html#ga7df95821d20d27b5597f1d783749d6a4">libusb_device_handle</a></td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Structure representing a handle on a USB device.  <a href="#ga7df95821d20d27b5597f1d783749d6a4"></a><br/></td></tr>
<tr><td colspan="2"><h2>Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">ssize_t&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__dev.html#gac0fe4b65914c5ed036e6cbec61cb0b97">libusb_get_device_list</a> (<a class="el" href="group__lib.html#ga4ec088aa7b79c4a9599e39bf36a72833">libusb_context</a> *ctx, <a class="el" href="group__dev.html#ga77eedd00d01eb7569b880e861a971c2b">libusb_device</a> ***list)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Returns a list of USB devices currently attached to the system.  <a href="#gac0fe4b65914c5ed036e6cbec61cb0b97"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__dev.html#gad3b8561d064bb3e1b8851ddeed3cd7d6">libusb_free_device_list</a> (<a class="el" href="group__dev.html#ga77eedd00d01eb7569b880e861a971c2b">libusb_device</a> **list, int unref_devices)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Frees a list of devices previously discovered using <a class="el" href="group__dev.html#gac0fe4b65914c5ed036e6cbec61cb0b97" title="Returns a list of USB devices currently attached to the system.">libusb_get_device_list()</a>.  <a href="#gad3b8561d064bb3e1b8851ddeed3cd7d6"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">uint8_t&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__dev.html#gaf2718609d50c8ded2704e4051b3d2925">libusb_get_bus_number</a> (<a class="el" href="group__dev.html#ga77eedd00d01eb7569b880e861a971c2b">libusb_device</a> *dev)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Get the number of the bus that a device is connected to.  <a href="#gaf2718609d50c8ded2704e4051b3d2925"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">uint8_t&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__dev.html#gab6d4e39ac483ebaeb108f2954715305d">libusb_get_device_address</a> (<a class="el" href="group__dev.html#ga77eedd00d01eb7569b880e861a971c2b">libusb_device</a> *dev)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Get the address of the device on the bus it is connected to.  <a href="#gab6d4e39ac483ebaeb108f2954715305d"></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__dev.html#gac81968047e262409e78f3fe24321b604">libusb_get_max_packet_size</a> (<a class="el" href="group__dev.html#ga77eedd00d01eb7569b880e861a971c2b">libusb_device</a> *dev, unsigned char endpoint)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Convenience function to retrieve the wMaxPacketSize value for a particular endpoint in the active device configuration.  <a href="#gac81968047e262409e78f3fe24321b604"></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__dev.html#gaec10b71c7209760db55ee0f8768bb4f0">libusb_get_max_iso_packet_size</a> (<a class="el" href="group__dev.html#ga77eedd00d01eb7569b880e861a971c2b">libusb_device</a> *dev, unsigned char endpoint)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Calculate the maximum packet size which a specific endpoint is capable is sending or receiving in the duration of 1 microframe.  <a href="#gaec10b71c7209760db55ee0f8768bb4f0"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__dev.html#ga77eedd00d01eb7569b880e861a971c2b">libusb_device</a> *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__dev.html#gaabaa4193adcabba1789cc1165ac41a03">libusb_ref_device</a> (<a class="el" href="group__dev.html#ga77eedd00d01eb7569b880e861a971c2b">libusb_device</a> *dev)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Increment the reference count of a device.  <a href="#gaabaa4193adcabba1789cc1165ac41a03"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__dev.html#ga3cc62e6a191b7a9f213e62b81ec30f4d">libusb_unref_device</a> (<a class="el" href="group__dev.html#ga77eedd00d01eb7569b880e861a971c2b">libusb_device</a> *dev)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Decrement the reference count of a device.  <a href="#ga3cc62e6a191b7a9f213e62b81ec30f4d"></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__dev.html#ga8163100afdf933fabed0db7fa81c89d1">libusb_open</a> (<a class="el" href="group__dev.html#ga77eedd00d01eb7569b880e861a971c2b">libusb_device</a> *dev, <a class="el" href="group__dev.html#ga7df95821d20d27b5597f1d783749d6a4">libusb_device_handle</a> **handle)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Open a device and obtain a device handle.  <a href="#ga8163100afdf933fabed0db7fa81c89d1"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__dev.html#ga7df95821d20d27b5597f1d783749d6a4">libusb_device_handle</a> *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__dev.html#ga11ba48adb896b1492bbd3d0bf7e0f665">libusb_open_device_with_vid_pid</a> (<a class="el" href="group__lib.html#ga4ec088aa7b79c4a9599e39bf36a72833">libusb_context</a> *ctx, uint16_t vendor_id, uint16_t product_id)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Convenience function for finding a device with a particular <code>idVendor</code>/<code>idProduct</code> combination.  <a href="#ga11ba48adb896b1492bbd3d0bf7e0f665"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__dev.html#ga779bc4f1316bdb0ac383bddbd538620e">libusb_close</a> (<a class="el" href="group__dev.html#ga7df95821d20d27b5597f1d783749d6a4">libusb_device_handle</a> *dev_handle)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Close a device handle.  <a href="#ga779bc4f1316bdb0ac383bddbd538620e"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__dev.html#ga77eedd00d01eb7569b880e861a971c2b">libusb_device</a> *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__dev.html#gafe70b8a797893d4d16985980acec956a">libusb_get_device</a> (<a class="el" href="group__dev.html#ga7df95821d20d27b5597f1d783749d6a4">libusb_device_handle</a> *dev_handle)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Get the underlying device for a handle.  <a href="#gafe70b8a797893d4d16985980acec956a"></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__dev.html#ga6fdf904b6d53279da278b3556e51273c">libusb_get_configuration</a> (<a class="el" href="group__dev.html#ga7df95821d20d27b5597f1d783749d6a4">libusb_device_handle</a> *dev, int *config)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Determine the bConfigurationValue of the currently active configuration.  <a href="#ga6fdf904b6d53279da278b3556e51273c"></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__dev.html#ga186593ecae576dad6cd9679f45a2aa43">libusb_set_configuration</a> (<a class="el" href="group__dev.html#ga7df95821d20d27b5597f1d783749d6a4">libusb_device_handle</a> *dev, int configuration)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Set the active configuration for a device.  <a href="#ga186593ecae576dad6cd9679f45a2aa43"></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__dev.html#ga32fabedf5f13fdecf1cb33acdb19b57a">libusb_claim_interface</a> (<a class="el" href="group__dev.html#ga7df95821d20d27b5597f1d783749d6a4">libusb_device_handle</a> *dev, int interface_number)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Claim an interface on a given device handle.  <a href="#ga32fabedf5f13fdecf1cb33acdb19b57a"></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__dev.html#gaf0d053dd23420c4daec89c06da04abe4">libusb_release_interface</a> (<a class="el" href="group__dev.html#ga7df95821d20d27b5597f1d783749d6a4">libusb_device_handle</a> *dev, int interface_number)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Release an interface previously claimed with <a class="el" href="group__dev.html#ga32fabedf5f13fdecf1cb33acdb19b57a" title="Claim an interface on a given device handle.">libusb_claim_interface()</a>.  <a href="#gaf0d053dd23420c4daec89c06da04abe4"></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__dev.html#ga3047fea29830a56524388fd423068b53">libusb_set_interface_alt_setting</a> (<a class="el" href="group__dev.html#ga7df95821d20d27b5597f1d783749d6a4">libusb_device_handle</a> *dev, int interface_number, int alternate_setting)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Activate an alternate setting for an interface.  <a href="#ga3047fea29830a56524388fd423068b53"></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__dev.html#ga5b321176ce7f18cfec369dd3ab7d431e">libusb_clear_halt</a> (<a class="el" href="group__dev.html#ga7df95821d20d27b5597f1d783749d6a4">libusb_device_handle</a> *dev, unsigned char endpoint)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Clear the halt/stall condition for an endpoint.  <a href="#ga5b321176ce7f18cfec369dd3ab7d431e"></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__dev.html#ga7321bd8dc28e9a20b411bf18e6d0e9aa">libusb_reset_device</a> (<a class="el" href="group__dev.html#ga7df95821d20d27b5597f1d783749d6a4">libusb_device_handle</a> *dev)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Perform a USB port reset to reinitialize a device.  <a href="#ga7321bd8dc28e9a20b411bf18e6d0e9aa"></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__dev.html#ga76e047ca95da2b32d0e7455da1804a49">libusb_kernel_driver_active</a> (<a class="el" href="group__dev.html#ga7df95821d20d27b5597f1d783749d6a4">libusb_device_handle</a> *dev, int interface)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Determine if a kernel driver is active on an interface.  <a href="#ga76e047ca95da2b32d0e7455da1804a49"></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__dev.html#ga0bc7a17090debf6d2b2711c505ad9725">libusb_detach_kernel_driver</a> (<a class="el" href="group__dev.html#ga7df95821d20d27b5597f1d783749d6a4">libusb_device_handle</a> *dev, int interface)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Detach a kernel driver from an interface.  <a href="#ga0bc7a17090debf6d2b2711c505ad9725"></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__dev.html#ga9de769d3aeb45a07f5559c8a0597cbcc">libusb_attach_kernel_driver</a> (<a class="el" href="group__dev.html#ga7df95821d20d27b5597f1d783749d6a4">libusb_device_handle</a> *dev, int interface)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Re-attach an interface's kernel driver, which was previously detached using <a class="el" href="group__dev.html#ga0bc7a17090debf6d2b2711c505ad9725" title="Detach a kernel driver from an interface.">libusb_detach_kernel_driver()</a>.  <a href="#ga9de769d3aeb45a07f5559c8a0597cbcc"></a><br/></td></tr>
</table>
<hr/><a name="_details"></a><h2>Detailed Description</h2>
<p>The functionality documented below is designed to help with the following operations:</p>
<ul>
<li>Enumerating the USB devices currently attached to the system</li>
<li>Choosing a device to operate from your software</li>
<li>Opening and closing the chosen device. </li>
</ul>
<h2><a class="anchor" id="nutshell">
In a nutshell...</a></h2>
<p>The description below really makes things sound more complicated than they actually are. The following sequence of function calls will be suitable for almost all scenarios and does not require you to have such a deep understanding of the resource management issues: </p>
<div class="fragment"><pre class="fragment"><span class="comment">// discover devices</span>
<a class="code" href="group__dev.html#ga77eedd00d01eb7569b880e861a971c2b" title="Structure representing a USB device detected on the system.">libusb_device</a> **list;
<a class="code" href="group__dev.html#ga77eedd00d01eb7569b880e861a971c2b" title="Structure representing a USB device detected on the system.">libusb_device</a> *found = NULL;
ssize_t cnt = <a class="code" href="group__dev.html#gac0fe4b65914c5ed036e6cbec61cb0b97" title="Returns a list of USB devices currently attached to the system.">libusb_get_device_list</a>(NULL, &amp;list);
ssize_t i = 0;
<span class="keywordtype">int</span> err = 0;
<span class="keywordflow">if</span> (cnt &lt; 0)
    error();

<span class="keywordflow">for</span> (i = 0; i &lt; cnt; i++) {
    <a class="code" href="group__dev.html#ga77eedd00d01eb7569b880e861a971c2b" title="Structure representing a USB device detected on the system.">libusb_device</a> *device = list[i];
    <span class="keywordflow">if</span> (is_interesting(device)) {
        found = device;
        <span class="keywordflow">break</span>;
    }
}

<span class="keywordflow">if</span> (found) {
    <a class="code" href="group__dev.html#ga7df95821d20d27b5597f1d783749d6a4" title="Structure representing a handle on a USB device.">libusb_device_handle</a> *handle;

    err = <a class="code" href="group__dev.html#ga8163100afdf933fabed0db7fa81c89d1" title="Open a device and obtain a device handle.">libusb_open</a>(found, &amp;handle);
    <span class="keywordflow">if</span> (err)
        error();
    <span class="comment">// etc</span>
}

<a class="code" href="group__dev.html#gad3b8561d064bb3e1b8851ddeed3cd7d6" title="Frees a list of devices previously discovered using libusb_get_device_list().">libusb_free_device_list</a>(list, 1);
</pre></div><p>The two important points:</p>
<ul>
<li>You asked <a class="el" href="group__dev.html#gad3b8561d064bb3e1b8851ddeed3cd7d6" title="Frees a list of devices previously discovered using libusb_get_device_list().">libusb_free_device_list()</a> to unreference the devices (2nd parameter)</li>
<li>You opened the device before freeing the list and unreferencing the devices</li>
</ul>
<p>If you ended up with a handle, you can now proceed to perform I/O on the device.</p>
<h2><a class="anchor" id="devshandles">
Devices and device handles</a></h2>
<p>libusb has a concept of a USB device, represented by the <a class="el" href="group__dev.html#ga77eedd00d01eb7569b880e861a971c2b">libusb_device</a> opaque type. A device represents a USB device that is currently or was previously connected to the system. Using a reference to a device, you can determine certain information about the device (e.g. you can read the descriptor data).</p>
<p>The <a class="el" href="group__dev.html#gac0fe4b65914c5ed036e6cbec61cb0b97" title="Returns a list of USB devices currently attached to the system.">libusb_get_device_list()</a> function can be used to obtain a list of devices currently connected to the system. This is known as device discovery.</p>
<p>Just because you have a reference to a device does not mean it is necessarily usable. The device may have been unplugged, you may not have permission to operate such device, or another program or driver may be using the device.</p>
<p>When you've found a device that you'd like to operate, you must ask libusb to open the device using the <a class="el" href="group__dev.html#ga8163100afdf933fabed0db7fa81c89d1" title="Open a device and obtain a device handle.">libusb_open()</a> function. Assuming success, libusb then returns you a <em>device handle</em> (a <a class="el" href="group__dev.html#ga7df95821d20d27b5597f1d783749d6a4">libusb_device_handle</a> pointer). All "real" I/O operations then operate on the handle rather than the original device pointer.</p>
<h2><a class="anchor" id="devref">
Device discovery and reference counting</a></h2>
<p>Device discovery (i.e. calling <a class="el" href="group__dev.html#gac0fe4b65914c5ed036e6cbec61cb0b97" title="Returns a list of USB devices currently attached to the system.">libusb_get_device_list()</a>) returns a freshly-allocated list of devices. The list itself must be freed when you are done with it. libusb also needs to know when it is OK to free the contents of the list - the devices themselves.</p>
<p>To handle these issues, libusb provides you with two separate items:</p>
<ul>
<li>A function to free the list itself</li>
<li>A reference counting system for the devices inside</li>
</ul>
<p>New devices presented by the <a class="el" href="group__dev.html#gac0fe4b65914c5ed036e6cbec61cb0b97" title="Returns a list of USB devices currently attached to the system.">libusb_get_device_list()</a> function all have a reference count of 1. You can increase and decrease reference count using <a class="el" href="group__dev.html#gaabaa4193adcabba1789cc1165ac41a03" title="Increment the reference count of a device.">libusb_ref_device()</a> and <a class="el" href="group__dev.html#ga3cc62e6a191b7a9f213e62b81ec30f4d" title="Decrement the reference count of a device.">libusb_unref_device()</a>. A device is destroyed when its reference count reaches 0.</p>
<p>With the above information in mind, the process of opening a device can be viewed as follows:</p>
<ol type="1">
<li>Discover devices using <a class="el" href="group__dev.html#gac0fe4b65914c5ed036e6cbec61cb0b97" title="Returns a list of USB devices currently attached to the system.">libusb_get_device_list()</a>.</li>
<li>Choose the device that you want to operate, and call <a class="el" href="group__dev.html#ga8163100afdf933fabed0db7fa81c89d1" title="Open a device and obtain a device handle.">libusb_open()</a>.</li>
<li>Unref all devices in the discovered device list.</li>
<li>Free the discovered device list.</li>
</ol>
<p>The order is important - you must not unreference the device before attempting to open it, because unreferencing it may destroy the device.</p>
<p>For convenience, the <a class="el" href="group__dev.html#gad3b8561d064bb3e1b8851ddeed3cd7d6" title="Frees a list of devices previously discovered using libusb_get_device_list().">libusb_free_device_list()</a> function includes a parameter to optionally unreference all the devices in the list before freeing the list itself. This combines steps 3 and 4 above.</p>
<p>As an implementation detail, <a class="el" href="group__dev.html#ga8163100afdf933fabed0db7fa81c89d1" title="Open a device and obtain a device handle.">libusb_open()</a> actually adds a reference to the device in question. This is because the device remains available through the handle via <a class="el" href="group__dev.html#gafe70b8a797893d4d16985980acec956a" title="Get the underlying device for a handle.">libusb_get_device()</a>. The reference is deleted during <a class="el" href="group__dev.html#ga779bc4f1316bdb0ac383bddbd538620e" title="Close a device handle.">libusb_close()</a>. </p>
<hr/><h2>Typedef Documentation</h2>
<a class="anchor" id="ga77eedd00d01eb7569b880e861a971c2b"></a><!-- doxytag: member="libusb.h::libusb_device" ref="ga77eedd00d01eb7569b880e861a971c2b" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">typedef struct <a class="el" href="group__dev.html#ga77eedd00d01eb7569b880e861a971c2b">libusb_device</a> <a class="el" href="group__dev.html#ga77eedd00d01eb7569b880e861a971c2b">libusb_device</a></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Structure representing a USB device detected on the system. </p>
<p>This is an opaque type for which you are only ever provided with a pointer, usually originating from <a class="el" href="group__dev.html#gac0fe4b65914c5ed036e6cbec61cb0b97" title="Returns a list of USB devices currently attached to the system.">libusb_get_device_list()</a>.</p>
<p>Certain operations can be performed on a device, but in order to do any I/O you will have to first obtain a device handle using <a class="el" href="group__dev.html#ga8163100afdf933fabed0db7fa81c89d1" title="Open a device and obtain a device handle.">libusb_open()</a>.</p>
<p>Devices are reference counted with libusb_device_ref() and libusb_device_unref(), and are freed when the reference count reaches 0. New devices presented by <a class="el" href="group__dev.html#gac0fe4b65914c5ed036e6cbec61cb0b97" title="Returns a list of USB devices currently attached to the system.">libusb_get_device_list()</a> have a reference count of 1, and <a class="el" href="group__dev.html#gad3b8561d064bb3e1b8851ddeed3cd7d6" title="Frees a list of devices previously discovered using libusb_get_device_list().">libusb_free_device_list()</a> can optionally decrease the reference count on all devices in the list. <a class="el" href="group__dev.html#ga8163100afdf933fabed0db7fa81c89d1" title="Open a device and obtain a device handle.">libusb_open()</a> adds another reference which is later destroyed by <a class="el" href="group__dev.html#ga779bc4f1316bdb0ac383bddbd538620e" title="Close a device handle.">libusb_close()</a>. </p>

</div>
</div>
<a class="anchor" id="ga7df95821d20d27b5597f1d783749d6a4"></a><!-- doxytag: member="libusb.h::libusb_device_handle" ref="ga7df95821d20d27b5597f1d783749d6a4" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">typedef struct <a class="el" href="group__dev.html#ga7df95821d20d27b5597f1d783749d6a4">libusb_device_handle</a> <a class="el" href="group__dev.html#ga7df95821d20d27b5597f1d783749d6a4">libusb_device_handle</a></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Structure representing a handle on a USB device. </p>
<p>This is an opaque type for which you are only ever provided with a pointer, usually originating from <a class="el" href="group__dev.html#ga8163100afdf933fabed0db7fa81c89d1" title="Open a device and obtain a device handle.">libusb_open()</a>.</p>
<p>A device handle is used to perform I/O and other operations. When finished with a device handle, you should call <a class="el" href="group__dev.html#ga779bc4f1316bdb0ac383bddbd538620e" title="Close a device handle.">libusb_close()</a>. </p>

</div>
</div>
<hr/><h2>Function Documentation</h2>
<a class="anchor" id="gac0fe4b65914c5ed036e6cbec61cb0b97"></a><!-- doxytag: member="core.c::libusb_get_device_list" ref="gac0fe4b65914c5ed036e6cbec61cb0b97" args="(libusb_context *ctx, libusb_device ***list)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">ssize_t libusb_get_device_list </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__lib.html#ga4ec088aa7b79c4a9599e39bf36a72833">libusb_context</a> *&nbsp;</td>
          <td class="paramname"> <em>ctx</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__dev.html#ga77eedd00d01eb7569b880e861a971c2b">libusb_device</a> ***&nbsp;</td>
          <td class="paramname"> <em>list</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Returns a list of USB devices currently attached to the system. </p>
<p>This is your entry point into finding a USB device to operate.</p>
<p>You are expected to unreference all the devices when you are done with them, and then free the list with <a class="el" href="group__dev.html#gad3b8561d064bb3e1b8851ddeed3cd7d6" title="Frees a list of devices previously discovered using libusb_get_device_list().">libusb_free_device_list()</a>. Note that <a class="el" href="group__dev.html#gad3b8561d064bb3e1b8851ddeed3cd7d6" title="Frees a list of devices previously discovered using libusb_get_device_list().">libusb_free_device_list()</a> can unref all the devices for you. Be careful not to unreference a device you are about to open until after you have opened it.</p>
<p>This return value of this function indicates the number of devices in the resultant list. The list is actually one element larger, as it is NULL-terminated.</p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>ctx</em>&nbsp;</td><td>the context to operate on, or NULL for the default context </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>list</em>&nbsp;</td><td>output location for a list of devices. Must be later freed with <a class="el" href="group__dev.html#gad3b8561d064bb3e1b8851ddeed3cd7d6" title="Frees a list of devices previously discovered using libusb_get_device_list().">libusb_free_device_list()</a>. </td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>the number of devices in the outputted list, or LIBUSB_ERROR_NO_MEM on memory allocation failure. </dd></dl>

</div>
</div>
<a class="anchor" id="gad3b8561d064bb3e1b8851ddeed3cd7d6"></a><!-- doxytag: member="core.c::libusb_free_device_list" ref="gad3b8561d064bb3e1b8851ddeed3cd7d6" args="(libusb_device **list, int unref_devices)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void libusb_free_device_list </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__dev.html#ga77eedd00d01eb7569b880e861a971c2b">libusb_device</a> **&nbsp;</td>
          <td class="paramname"> <em>list</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&nbsp;</td>
          <td class="paramname"> <em>unref_devices</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Frees a list of devices previously discovered using <a class="el" href="group__dev.html#gac0fe4b65914c5ed036e6cbec61cb0b97" title="Returns a list of USB devices currently attached to the system.">libusb_get_device_list()</a>. </p>
<p>If the unref_devices parameter is set, the reference count of each device in the list is decremented by 1. </p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>list</em>&nbsp;</td><td>the list to free </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>unref_devices</em>&nbsp;</td><td>whether to unref the devices in the list </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="gaf2718609d50c8ded2704e4051b3d2925"></a><!-- doxytag: member="core.c::libusb_get_bus_number" ref="gaf2718609d50c8ded2704e4051b3d2925" args="(libusb_device *dev)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">uint8_t libusb_get_bus_number </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__dev.html#ga77eedd00d01eb7569b880e861a971c2b">libusb_device</a> *&nbsp;</td>
          <td class="paramname"> <em>dev</em></td>
          <td>&nbsp;)&nbsp;</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Get the number of the bus that a device is connected to. </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</em>&nbsp;</td><td>a device </td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>the bus number </dd></dl>

</div>
</div>
<a class="anchor" id="gab6d4e39ac483ebaeb108f2954715305d"></a><!-- doxytag: member="core.c::libusb_get_device_address" ref="gab6d4e39ac483ebaeb108f2954715305d" args="(libusb_device *dev)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">uint8_t libusb_get_device_address </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__dev.html#ga77eedd00d01eb7569b880e861a971c2b">libusb_device</a> *&nbsp;</td>
          <td class="paramname"> <em>dev</em></td>
          <td>&nbsp;)&nbsp;</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Get the address of the device on the bus it is connected to. </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</em>&nbsp;</td><td>a device </td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>the device address </dd></dl>

</div>
</div>
<a class="anchor" id="gac81968047e262409e78f3fe24321b604"></a><!-- doxytag: member="core.c::libusb_get_max_packet_size" ref="gac81968047e262409e78f3fe24321b604" args="(libusb_device *dev, unsigned char endpoint)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int libusb_get_max_packet_size </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__dev.html#ga77eedd00d01eb7569b880e861a971c2b">libusb_device</a> *&nbsp;</td>
          <td class="paramname"> <em>dev</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">unsigned char&nbsp;</td>
          <td class="paramname"> <em>endpoint</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Convenience function to retrieve the wMaxPacketSize value for a particular endpoint in the active device configuration. </p>
<p>This function was originally intended to be of assistance when setting up isochronous transfers, but a design mistake resulted in this function instead. It simply returns the wMaxPacketSize value without considering its contents. If you're dealing with isochronous transfers, you probably want <a class="el" href="group__dev.html#gaec10b71c7209760db55ee0f8768bb4f0" title="Calculate the maximum packet size which a specific endpoint is capable is sending...">libusb_get_max_iso_packet_size()</a> instead.</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</em>&nbsp;</td><td>a device </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>endpoint</em>&nbsp;</td><td>address of the endpoint in question </td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>the wMaxPacketSize value </dd>
<dd>
LIBUSB_ERROR_NOT_FOUND if the endpoint does not exist </dd>
<dd>
LIBUSB_ERROR_OTHER on other failure </dd></dl>

</div>
</div>
<a class="anchor" id="gaec10b71c7209760db55ee0f8768bb4f0"></a><!-- doxytag: member="core.c::libusb_get_max_iso_packet_size" ref="gaec10b71c7209760db55ee0f8768bb4f0" args="(libusb_device *dev, unsigned char endpoint)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int libusb_get_max_iso_packet_size </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__dev.html#ga77eedd00d01eb7569b880e861a971c2b">libusb_device</a> *&nbsp;</td>
          <td class="paramname"> <em>dev</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">unsigned char&nbsp;</td>
          <td class="paramname"> <em>endpoint</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Calculate the maximum packet size which a specific endpoint is capable is sending or receiving in the duration of 1 microframe. </p>
<p>Only the active configution is examined. The calculation is based on the wMaxPacketSize field in the endpoint descriptor as described in section 9.6.6 in the USB 2.0 specifications.</p>
<p>If acting on an isochronous or interrupt endpoint, this function will multiply the value found in bits 0:10 by the number of transactions per microframe (determined by bits 11:12). Otherwise, this function just returns the numeric value found in bits 0:10.</p>
<p>This function is useful for setting up isochronous transfers, for example you might pass the return value from this function to <a class="el" href="group__asyncio.html#gacbdecd6f50093f0c1d0e72ee35ace274" title="Convenience function to set the length of all packets in an isochronous transfer...">libusb_set_iso_packet_lengths()</a> in order to set the length field of every isochronous packet in a transfer.</p>
<p>Since v1.0.3.</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</em>&nbsp;</td><td>a device </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>endpoint</em>&nbsp;</td><td>address of the endpoint in question </td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>the maximum packet size which can be sent/received on this endpoint </dd>
<dd>
LIBUSB_ERROR_NOT_FOUND if the endpoint does not exist </dd>
<dd>
LIBUSB_ERROR_OTHER on other failure </dd></dl>

</div>
</div>
<a class="anchor" id="gaabaa4193adcabba1789cc1165ac41a03"></a><!-- doxytag: member="core.c::libusb_ref_device" ref="gaabaa4193adcabba1789cc1165ac41a03" args="(libusb_device *dev)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__dev.html#ga77eedd00d01eb7569b880e861a971c2b">libusb_device</a>* libusb_ref_device </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__dev.html#ga77eedd00d01eb7569b880e861a971c2b">libusb_device</a> *&nbsp;</td>
          <td class="paramname"> <em>dev</em></td>
          <td>&nbsp;)&nbsp;</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Increment the reference count of a device. </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</em>&nbsp;</td><td>the device to reference </td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>the same device </dd></dl>

</div>
</div>
<a class="anchor" id="ga3cc62e6a191b7a9f213e62b81ec30f4d"></a><!-- doxytag: member="core.c::libusb_unref_device" ref="ga3cc62e6a191b7a9f213e62b81ec30f4d" args="(libusb_device *dev)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void libusb_unref_device </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__dev.html#ga77eedd00d01eb7569b880e861a971c2b">libusb_device</a> *&nbsp;</td>
          <td class="paramname"> <em>dev</em></td>
          <td>&nbsp;)&nbsp;</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Decrement the reference count of a device. </p>
<p>If the decrement operation causes the reference count to reach zero, the device shall be destroyed. </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</em>&nbsp;</td><td>the device to unreference </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="ga8163100afdf933fabed0db7fa81c89d1"></a><!-- doxytag: member="core.c::libusb_open" ref="ga8163100afdf933fabed0db7fa81c89d1" args="(libusb_device *dev, libusb_device_handle **handle)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int libusb_open </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__dev.html#ga77eedd00d01eb7569b880e861a971c2b">libusb_device</a> *&nbsp;</td>
          <td class="paramname"> <em>dev</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__dev.html#ga7df95821d20d27b5597f1d783749d6a4">libusb_device_handle</a> **&nbsp;</td>
          <td class="paramname"> <em>handle</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Open a device and obtain a device handle. </p>
<p>A handle allows you to perform I/O on the device in question.</p>
<p>Internally, this function adds a reference to the device and makes it available to you through <a class="el" href="group__dev.html#gafe70b8a797893d4d16985980acec956a" title="Get the underlying device for a handle.">libusb_get_device()</a>. This reference is removed during <a class="el" href="group__dev.html#ga779bc4f1316bdb0ac383bddbd538620e" title="Close a device handle.">libusb_close()</a>.</p>
<p>This is a non-blocking function; no requests are sent over the bus.</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</em>&nbsp;</td><td>the device to open </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>handle</em>&nbsp;</td><td>output location for the returned device handle pointer. Only populated when the return code is 0. </td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>0 on success </dd>
<dd>
LIBUSB_ERROR_NO_MEM on memory allocation failure </dd>
<dd>
LIBUSB_ERROR_ACCESS if the user has insufficient permissions </dd>
<dd>
LIBUSB_ERROR_NO_DEVICE if the device has been disconnected </dd>
<dd>
another LIBUSB_ERROR code on other failure </dd></dl>

</div>
</div>
<a class="anchor" id="ga11ba48adb896b1492bbd3d0bf7e0f665"></a><!-- doxytag: member="core.c::libusb_open_device_with_vid_pid" ref="ga11ba48adb896b1492bbd3d0bf7e0f665" args="(libusb_context *ctx, uint16_t vendor_id, uint16_t product_id)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__dev.html#ga7df95821d20d27b5597f1d783749d6a4">libusb_device_handle</a>* libusb_open_device_with_vid_pid </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__lib.html#ga4ec088aa7b79c4a9599e39bf36a72833">libusb_context</a> *&nbsp;</td>
          <td class="paramname"> <em>ctx</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint16_t&nbsp;</td>
          <td class="paramname"> <em>vendor_id</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint16_t&nbsp;</td>
          <td class="paramname"> <em>product_id</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Convenience function for finding a device with a particular <code>idVendor</code>/<code>idProduct</code> combination. </p>
<p>This function is intended for those scenarios where you are using libusb to knock up a quick test application - it allows you to avoid calling <a class="el" href="group__dev.html#gac0fe4b65914c5ed036e6cbec61cb0b97" title="Returns a list of USB devices currently attached to the system.">libusb_get_device_list()</a> and worrying about traversing/freeing the list.</p>
<p>This function has limitations and is hence not intended for use in real applications: if multiple devices have the same IDs it will only give you the first one, etc.</p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>ctx</em>&nbsp;</td><td>the context to operate on, or NULL for the default context </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>vendor_id</em>&nbsp;</td><td>the idVendor value to search for </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>product_id</em>&nbsp;</td><td>the idProduct value to search for </td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>a handle for the first found device, or NULL on error or if the device could not be found. </dd></dl>

</div>
</div>
<a class="anchor" id="ga779bc4f1316bdb0ac383bddbd538620e"></a><!-- doxytag: member="core.c::libusb_close" ref="ga779bc4f1316bdb0ac383bddbd538620e" args="(libusb_device_handle *dev_handle)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void libusb_close </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>
          <td>&nbsp;)&nbsp;</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Close a device handle. </p>
<p>Should be called on all open handles before your application exits.</p>
<p>Internally, this function destroys the reference that was added by <a class="el" href="group__dev.html#ga8163100afdf933fabed0db7fa81c89d1" title="Open a device and obtain a device handle.">libusb_open()</a> on the given device.</p>
<p>This is a non-blocking function; no requests are sent over the bus.</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>the handle to close </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="gafe70b8a797893d4d16985980acec956a"></a><!-- doxytag: member="core.c::libusb_get_device" ref="gafe70b8a797893d4d16985980acec956a" args="(libusb_device_handle *dev_handle)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__dev.html#ga77eedd00d01eb7569b880e861a971c2b">libusb_device</a>* libusb_get_device </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>
          <td>&nbsp;)&nbsp;</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Get the underlying device for a handle. </p>
<p>This function does not modify the reference count of the returned device, so do not feel compelled to unreference it when you are done. </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 device handle </td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>the underlying device </dd></dl>

</div>
</div>
<a class="anchor" id="ga6fdf904b6d53279da278b3556e51273c"></a><!-- doxytag: member="core.c::libusb_get_configuration" ref="ga6fdf904b6d53279da278b3556e51273c" args="(libusb_device_handle *dev, int *config)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int libusb_get_configuration </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</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int *&nbsp;</td>
          <td class="paramname"> <em>config</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Determine the bConfigurationValue of the currently active configuration. </p>
<p>You could formulate your own control request to obtain this information, but this function has the advantage that it may be able to retrieve the information from operating system caches (no I/O involved).</p>
<p>If the OS does not cache this information, then this function will block while a control transfer is submitted to retrieve the information.</p>
<p>This function will return a value of 0 in the <code>config</code> output parameter if the device is in unconfigured state.</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</em>&nbsp;</td><td>a device handle </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>config</em>&nbsp;</td><td>output location for the bConfigurationValue of the active configuration (only valid for return code 0) </td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>0 on success </dd>
<dd>
LIBUSB_ERROR_NO_DEVICE if the device has been disconnected </dd>
<dd>
another LIBUSB_ERROR code on other failure </dd></dl>

</div>
</div>
<a class="anchor" id="ga186593ecae576dad6cd9679f45a2aa43"></a><!-- doxytag: member="core.c::libusb_set_configuration" ref="ga186593ecae576dad6cd9679f45a2aa43" args="(libusb_device_handle *dev, int configuration)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int libusb_set_configuration </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</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&nbsp;</td>
          <td class="paramname"> <em>configuration</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Set the active configuration for a device. </p>
<p>The operating system may or may not have already set an active configuration on the device. It is up to your application to ensure the correct configuration is selected before you attempt to claim interfaces and perform other operations.</p>
<p>If you call this function on a device already configured with the selected configuration, then this function will act as a lightweight device reset: it will issue a SET_CONFIGURATION request using the current configuration, causing most USB-related device state to be reset (altsetting reset to zero, endpoint halts cleared, toggles reset).</p>
<p>You cannot change/reset configuration if your application has claimed interfaces - you should free them with <a class="el" href="group__dev.html#gaf0d053dd23420c4daec89c06da04abe4" title="Release an interface previously claimed with libusb_claim_interface().">libusb_release_interface()</a> first. You cannot change/reset configuration if other applications or drivers have claimed interfaces.</p>
<p>A configuration value of -1 will put the device in unconfigured state. The USB specifications state that a configuration value of 0 does this, however buggy devices exist which actually have a configuration 0.</p>
<p>You should always use this function rather than formulating your own SET_CONFIGURATION control request. This is because the underlying operating system needs to know when such changes happen.</p>
<p>This is a blocking function.</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</em>&nbsp;</td><td>a device handle </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>configuration</em>&nbsp;</td><td>the bConfigurationValue of the configuration you wish to activate, or -1 if you wish to put the device in unconfigured state </td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>0 on success </dd>
<dd>
LIBUSB_ERROR_NOT_FOUND if the requested configuration does not exist </dd>
<dd>
LIBUSB_ERROR_BUSY if interfaces are currently claimed </dd>
<dd>
LIBUSB_ERROR_NO_DEVICE if the device has been disconnected </dd>
<dd>
another LIBUSB_ERROR code on other failure </dd></dl>

</div>
</div>
<a class="anchor" id="ga32fabedf5f13fdecf1cb33acdb19b57a"></a><!-- doxytag: member="core.c::libusb_claim_interface" ref="ga32fabedf5f13fdecf1cb33acdb19b57a" args="(libusb_device_handle *dev, int interface_number)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int libusb_claim_interface </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</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&nbsp;</td>
          <td class="paramname"> <em>interface_number</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Claim an interface on a given device handle. </p>
<p>You must claim the interface you wish to use before you can perform I/O on any of its endpoints.</p>
<p>It is legal to attempt to claim an already-claimed interface, in which case libusb just returns 0 without doing anything.</p>
<p>Claiming of interfaces is a purely logical operation; it does not cause any requests to be sent over the bus. Interface claiming is used to instruct the underlying operating system that your application wishes to take ownership of the interface.</p>
<p>This is a non-blocking function.</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</em>&nbsp;</td><td>a device handle </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>interface_number</em>&nbsp;</td><td>the <code>bInterfaceNumber</code> of the interface you wish to claim </td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>0 on success </dd>
<dd>
LIBUSB_ERROR_NOT_FOUND if the requested interface does not exist </dd>
<dd>
LIBUSB_ERROR_BUSY if another program or driver has claimed the interface </dd>
<dd>
LIBUSB_ERROR_NO_DEVICE if the device has been disconnected </dd>
<dd>
a LIBUSB_ERROR code on other failure </dd></dl>

</div>
</div>
<a class="anchor" id="gaf0d053dd23420c4daec89c06da04abe4"></a><!-- doxytag: member="core.c::libusb_release_interface" ref="gaf0d053dd23420c4daec89c06da04abe4" args="(libusb_device_handle *dev, int interface_number)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int libusb_release_interface </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</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&nbsp;</td>
          <td class="paramname"> <em>interface_number</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Release an interface previously claimed with <a class="el" href="group__dev.html#ga32fabedf5f13fdecf1cb33acdb19b57a" title="Claim an interface on a given device handle.">libusb_claim_interface()</a>. </p>
<p>You should release all claimed interfaces before closing a device handle.</p>
<p>This is a blocking function. A SET_INTERFACE control request will be sent to the device, resetting interface state to the first alternate setting.</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</em>&nbsp;</td><td>a device handle </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>interface_number</em>&nbsp;</td><td>the <code>bInterfaceNumber</code> of the previously-claimed interface </td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>0 on success </dd>
<dd>
LIBUSB_ERROR_NOT_FOUND if the interface was not claimed </dd>
<dd>
LIBUSB_ERROR_NO_DEVICE if the device has been disconnected </dd>
<dd>
another LIBUSB_ERROR code on other failure </dd></dl>

</div>
</div>
<a class="anchor" id="ga3047fea29830a56524388fd423068b53"></a><!-- doxytag: member="core.c::libusb_set_interface_alt_setting" ref="ga3047fea29830a56524388fd423068b53" args="(libusb_device_handle *dev, int interface_number, int alternate_setting)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int libusb_set_interface_alt_setting </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</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&nbsp;</td>
          <td class="paramname"> <em>interface_number</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&nbsp;</td>
          <td class="paramname"> <em>alternate_setting</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Activate an alternate setting for an interface. </p>
<p>The interface must have been previously claimed with <a class="el" href="group__dev.html#ga32fabedf5f13fdecf1cb33acdb19b57a" title="Claim an interface on a given device handle.">libusb_claim_interface()</a>.</p>
<p>You should always use this function rather than formulating your own SET_INTERFACE control request. This is because the underlying operating system needs to know when such changes happen.</p>
<p>This is a blocking function.</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</em>&nbsp;</td><td>a device handle </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>interface_number</em>&nbsp;</td><td>the <code>bInterfaceNumber</code> of the previously-claimed interface </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>alternate_setting</em>&nbsp;</td><td>the <code>bAlternateSetting</code> of the alternate setting to activate </td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>0 on success </dd>
<dd>
LIBUSB_ERROR_NOT_FOUND if the interface was not claimed, or the requested alternate setting does not exist </dd>
<dd>
LIBUSB_ERROR_NO_DEVICE if the device has been disconnected </dd>
<dd>
another LIBUSB_ERROR code on other failure </dd></dl>

</div>
</div>
<a class="anchor" id="ga5b321176ce7f18cfec369dd3ab7d431e"></a><!-- doxytag: member="core.c::libusb_clear_halt" ref="ga5b321176ce7f18cfec369dd3ab7d431e" args="(libusb_device_handle *dev, unsigned char endpoint)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int libusb_clear_halt </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</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">unsigned char&nbsp;</td>
          <td class="paramname"> <em>endpoint</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Clear the halt/stall condition for an endpoint. </p>
<p>Endpoints with halt status are unable to receive or transmit data until the halt condition is stalled.</p>
<p>You should cancel all pending transfers before attempting to clear the halt condition.</p>
<p>This is a blocking function.</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</em>&nbsp;</td><td>a device handle </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>endpoint</em>&nbsp;</td><td>the endpoint to clear halt status </td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>0 on success </dd>
<dd>
LIBUSB_ERROR_NOT_FOUND if the endpoint does not exist </dd>
<dd>
LIBUSB_ERROR_NO_DEVICE if the device has been disconnected </dd>
<dd>
another LIBUSB_ERROR code on other failure </dd></dl>

</div>
</div>
<a class="anchor" id="ga7321bd8dc28e9a20b411bf18e6d0e9aa"></a><!-- doxytag: member="core.c::libusb_reset_device" ref="ga7321bd8dc28e9a20b411bf18e6d0e9aa" args="(libusb_device_handle *dev)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int libusb_reset_device </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</em></td>
          <td>&nbsp;)&nbsp;</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Perform a USB port reset to reinitialize a device. </p>
<p>The system will attempt to restore the previous configuration and alternate settings after the reset has completed.</p>
<p>If the reset fails, the descriptors change, or the previous state cannot be restored, the device will appear to be disconnected and reconnected. This means that the device handle is no longer valid (you should close it) and rediscover the device. A return code of LIBUSB_ERROR_NOT_FOUND indicates when this is the case.</p>
<p>This is a blocking function which usually incurs a noticeable delay.</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</em>&nbsp;</td><td>a handle of the device to reset </td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>0 on success </dd>
<dd>
LIBUSB_ERROR_NOT_FOUND if re-enumeration is required, or if the device has been disconnected </dd>
<dd>
another LIBUSB_ERROR code on other failure </dd></dl>

</div>
</div>
<a class="anchor" id="ga76e047ca95da2b32d0e7455da1804a49"></a><!-- doxytag: member="core.c::libusb_kernel_driver_active" ref="ga76e047ca95da2b32d0e7455da1804a49" args="(libusb_device_handle *dev, int interface)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int libusb_kernel_driver_active </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</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&nbsp;</td>
          <td class="paramname"> <em>interface</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Determine if a kernel driver is active on an interface. </p>
<p>If a kernel driver is active, you cannot claim the interface, and libusb will be unable to perform 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</em>&nbsp;</td><td>a device handle </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>interface</em>&nbsp;</td><td>the interface to check </td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>0 if no kernel driver is active </dd>
<dd>
1 if a kernel driver is active </dd>
<dd>
LIBUSB_ERROR_NO_DEVICE if the device has been disconnected </dd>
<dd>
another LIBUSB_ERROR code on other failure </dd></dl>
<dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="group__dev.html#ga0bc7a17090debf6d2b2711c505ad9725" title="Detach a kernel driver from an interface.">libusb_detach_kernel_driver()</a> </dd></dl>

</div>
</div>
<a class="anchor" id="ga0bc7a17090debf6d2b2711c505ad9725"></a><!-- doxytag: member="core.c::libusb_detach_kernel_driver" ref="ga0bc7a17090debf6d2b2711c505ad9725" args="(libusb_device_handle *dev, int interface)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int libusb_detach_kernel_driver </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</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&nbsp;</td>
          <td class="paramname"> <em>interface</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Detach a kernel driver from an interface. </p>
<p>If successful, you will then be able to claim the interface and perform 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</em>&nbsp;</td><td>a device handle </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>interface</em>&nbsp;</td><td>the interface to detach the driver from </td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>0 on success </dd>
<dd>
LIBUSB_ERROR_NOT_FOUND if no kernel driver was active </dd>
<dd>
LIBUSB_ERROR_INVALID_PARAM if the interface does not exist </dd>
<dd>
LIBUSB_ERROR_NO_DEVICE if the device has been disconnected </dd>
<dd>
another LIBUSB_ERROR code on other failure </dd></dl>
<dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="group__dev.html#ga76e047ca95da2b32d0e7455da1804a49" title="Determine if a kernel driver is active on an interface.">libusb_kernel_driver_active()</a> </dd></dl>

</div>
</div>
<a class="anchor" id="ga9de769d3aeb45a07f5559c8a0597cbcc"></a><!-- doxytag: member="core.c::libusb_attach_kernel_driver" ref="ga9de769d3aeb45a07f5559c8a0597cbcc" args="(libusb_device_handle *dev, int interface)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int libusb_attach_kernel_driver </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</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&nbsp;</td>
          <td class="paramname"> <em>interface</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Re-attach an interface's kernel driver, which was previously detached using <a class="el" href="group__dev.html#ga0bc7a17090debf6d2b2711c505ad9725" title="Detach a kernel driver from an interface.">libusb_detach_kernel_driver()</a>. </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</em>&nbsp;</td><td>a device handle </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>interface</em>&nbsp;</td><td>the interface to attach the driver from </td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>0 on success </dd>
<dd>
LIBUSB_ERROR_NOT_FOUND if no kernel driver was active </dd>
<dd>
LIBUSB_ERROR_INVALID_PARAM if the interface does not exist </dd>
<dd>
LIBUSB_ERROR_NO_DEVICE if the device has been disconnected </dd>
<dd>
LIBUSB_ERROR_BUSY if the driver cannot be attached because the interface is claimed by a program or driver </dd>
<dd>
another LIBUSB_ERROR code on other failure </dd></dl>
<dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="group__dev.html#ga76e047ca95da2b32d0e7455da1804a49" title="Determine if a kernel driver is active on an interface.">libusb_kernel_driver_active()</a> </dd></dl>

</div>
</div>
</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>