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

📄 functions.sgml

📁 This libusb version 0.1.12. libusb is a library which allows userspace application access to USB de
💻 SGML
📖 第 1 页 / 共 2 页
字号:
  <title>Functions</title>  <reference id="ref.core">    <title>Core</title>    <partintro>      <!-- FIXME: Check spelling of "comprise" -->      <para>These functions comprise the core of libusb. They are used by all applications that utilize libusb.</para>    </partintro>    <refentry id="function.usbinit">      <refnamediv>        <refname>usb_init</refname>        <refpurpose>Initialize libusb</refpurpose>      </refnamediv>      <refsect1>        <title>Description</title>        <funcsynopsis>          <funcprototype>            <funcdef>void <function>usb_init</function></funcdef>            <void>          </funcprototype>        </funcsynopsis>        <para>Just like the name implies, <function>usb_init</function> sets up some internal structures. <function>usb_init</function> <emphasis>must</emphasis> be called before any other libusb functions.</para>      </refsect1>    </refentry>    <refentry id="function.usbfindbusses">      <refnamediv>        <refname>usb_find_busses</refname>        <refpurpose>Finds all USB busses on system</refpurpose>      </refnamediv>      <refsect1>        <title>Description</title>        <funcsynopsis>          <funcprototype>            <funcdef>int <function>usb_find_busses</function></funcdef>            <void>          </funcprototype>        </funcsynopsis>        <para><function>usb_find_busses</function> will find all of the busses on the system. Returns the number of changes since previous call to this function (total of new busses and busses removed).</para>      </refsect1>    </refentry>    <refentry id="function.usbfinddevices">      <refnamediv>        <refname>usb_find_devices</refname>        <refpurpose>Find all devices on all USB devices</refpurpose>      </refnamediv>      <refsect1>        <title>Description</title>        <funcsynopsis>          <funcprototype>            <funcdef>int <function>usb_find_devices</function></funcdef>            <void>          </funcprototype>        </funcsynopsis>        <para><function>usb_find_devices</function> will find all of the devices on each bus. This should be called after <xref linkend="function.usbfindbusses">. Returns the number of changes since the previous call to this function (total of new device and devices removed).</para>      </refsect1>    </refentry>    <refentry id="function.usbgetbusses">      <refnamediv>        <refname>usb_get_busses</refname>        <refpurpose>Return the list of USB busses found</refpurpose>      </refnamediv>      <refsect1>        <title>Description</title>        <funcsynopsis>          <funcprototype>            <funcdef>struct usb_bus *<function>usb_get_busses</function></funcdef>            <void>          </funcprototype>        </funcsynopsis>        <para><function>usb_get_busses</function> simply returns the value of the global variable <varname>usb_busses</varname>. This was implemented for those languages that support C calling convention and can use shared libraries, but don't support C global variables (like Delphi).</para>      </refsect1>    </refentry>  </reference>  <reference id="ref.deviceops">    <title>Device operations</title>    <partintro>      <para>This group of functions deal with the device. It allows you to open and close the device as well standard USB operations like setting the configuration, alternate settings, clearing halts and resetting the device. It also provides OS level operations such as claiming and releasing interfaces.</para>    </partintro>    <refentry id="function.usbopen">      <refnamediv>        <refname>usb_open</refname>        <refpurpose>Opens a USB device</refpurpose>      </refnamediv>      <refsect1>        <title>Description</title>        <funcsynopsis>          <funcprototype>            <funcdef>usb_dev_handle *<function>usb_open</function></funcdef>            <paramdef>struct *usb_device <parameter>dev</parameter></paramdef>          </funcprototype>        </funcsynopsis>        <para><function>usb_open</function> is to be used to open up a device for use. <function>usb_open</function> must be called before attempting to perform any operations to the device. Returns a handle used in future communication with the device.</para>      </refsect1>    </refentry>    <refentry id="function.usbclose">      <refnamediv>        <refname>usb_close</refname>        <refpurpose>Closes a USB device</refpurpose>      </refnamediv>      <refsect1>        <title>Description</title>        <funcsynopsis>          <funcprototype>            <funcdef>int <function>usb_close</function></funcdef>            <paramdef>usb_dev_handle *<parameter>dev</parameter></paramdef>          </funcprototype>        </funcsynopsis>        <para><function>usb_close</function> closes a device opened with <xref linkend="function.usbopen">. No further operations may be performed on the handle after <function>usb_close</function> is called. Returns 0 on success or &lt; 0 on error.</para>      </refsect1>    </refentry>    <refentry id="function.usbsetconfiguration">      <refnamediv>        <refname>usb_set_configuration</refname>        <refpurpose>Sets the active configuration of a device</refpurpose>      </refnamediv>      <refsect1>        <title>Description</title>        <funcsynopsis>          <funcprototype>            <funcdef>int <function>usb_set_configuration</function></funcdef>            <paramdef>usb_dev_handle *<parameter>dev</parameter></paramdef>            <paramdef>int <parameter>configuration</parameter></paramdef>          </funcprototype>        </funcsynopsis>        <para><function>usb_set_configuration</function> sets the active configuration of a device. The <varname>configuration</varname> parameter is the value as specified in the descriptor field bConfigurationValue. Returns 0 on success or &lt; 0 on error.</para>      </refsect1>    </refentry>    <refentry id="function.usbsetaltinterface">      <refnamediv>        <refname>usb_set_altinterface</refname>        <refpurpose>Sets the active alternate setting of the current interface</refpurpose>      </refnamediv>      <refsect1>        <title>Description</title>        <funcsynopsis>          <funcprototype>            <funcdef>int <function>usb_set_altinterface</function></funcdef>            <paramdef>usb_dev_handle *<parameter>dev</parameter></paramdef>            <paramdef>int <parameter>alternate</parameter></paramdef>          </funcprototype>        </funcsynopsis>        <para><function>usb_set_altinterface</function> sets the active alternate setting of the current interface. The <varname>alternate</varname> parameter is the value as specified in the descriptor field bAlternateSetting. Returns 0 on success or &lt; 0 on error.</para>      </refsect1>    </refentry>    <refentry id="function.usbresetep">      <refnamediv>        <refname>usb_resetep</refname>        <refpurpose>Resets state for an endpoint</refpurpose>      </refnamediv>      <refsect1>        <title>Description</title>        <funcsynopsis>          <funcprototype>            <funcdef>int <function>usb_resetep</function></funcdef>            <paramdef>usb_dev_handle *<parameter>dev</parameter></paramdef>            <paramdef>unsigned int <parameter>ep</parameter></paramdef>          </funcprototype>        </funcsynopsis>        <para><function>usb_resetep</function> resets all state (like toggles) for the specified endpoint. The <varname>ep</varname> parameter is the value specified in the descriptor field bEndpointAddress. Returns 0 on success or &lt; 0 on error.</para>        <note>          <title>Deprecated</title>          <para><function>usb_resetep</function> is deprecated. You probably want to use <xref linkend="function.usbclearhalt">.</para>        </note>      </refsect1>    </refentry>    <refentry id="function.usbclearhalt">      <refnamediv>        <refname>usb_clear_halt</refname>        <refpurpose>Clears any halt status on an endpoint</refpurpose>      </refnamediv>      <refsect1>        <title>Description</title>        <funcsynopsis>          <funcprototype>            <funcdef>int <function>usb_clear_halt</function></funcdef>            <paramdef>usb_dev_handle *<parameter>dev</parameter></paramdef>            <paramdef>unsigned int <parameter>ep</parameter></paramdef>          </funcprototype>        </funcsynopsis>        <para><function>usb_clear_halt</function> clears any halt status on the specified endpoint. The <varname>ep</varname> parameter is the value specified in the descriptor field bEndpointAddress. Returns 0 on success or &lt; 0 on error.</para>      </refsect1>    </refentry>    <refentry id="function.usbreset">      <refnamediv>        <refname>usb_reset</refname>        <refpurpose>Resets a device</refpurpose>      </refnamediv>      <refsect1>        <title>Description</title>        <funcsynopsis>          <funcprototype>            <funcdef>int <function>usb_reset</function></funcdef>            <paramdef>usb_dev_handle *<parameter>dev</parameter></paramdef>          </funcprototype>        </funcsynopsis>        <para><function>usb_reset</function> resets the specified device by sending a RESET down the port it is connected to. Returns 0 on success or &lt; 0 on error.</para>        <note>          <title>Causes re-enumeration</title>          <para>After calling <function>usb_reset</function>, the device will need to re-enumerate and thusly, requires you to find the new device and open a new handle. The handle used to call <function>usb_reset</function> will no longer work.</para>        </note>      </refsect1>    </refentry>    <refentry id="function.usbclaiminterface">      <refnamediv>        <refname>usb_claim_interface</refname>        <refpurpose>Claim an interface of a device</refpurpose>      </refnamediv>      <refsect1>        <title>Description</title>        <funcsynopsis>          <funcprototype>            <funcdef>int <function>usb_claim_interface</function></funcdef>            <paramdef>usb_dev_handle *<parameter>dev</parameter></paramdef>            <paramdef>int <parameter>interface</parameter></paramdef>          </funcprototype>        </funcsynopsis>        <para><function>usb_claim_interface</function> claims the interface with the Operating System. The interface parameter is the value as specified in the descriptor field bInterfaceNumber. Returns 0 on success or &lt; 0 on error.</para>        <important>          <title>Must be called!</title>          <para><function>usb_claim_interface</function> <emphasis>must</emphasis> be called before you perform any operations related to this interface (like <xref linkend="function.usbsetaltinterface">, <xref linkend="function.usbbulkwrite">, etc).</para>        </important>        <table>          <title>Return Codes</title>          <tgroup cols="2">            <thead>              <row>                <entry>code</entry>                <entry>description</entry>              </row>            </thead>            <tbody>              <row>                <entry>-EBUSY</entry>                <entry>Interface is not available to be claimed</entry>              </row>              <row>                <entry>-ENOMEM</entry>                <entry>Insufficient memory</entry>              </row>            </tbody>          </tgroup>        </table>      </refsect1>    </refentry>    <refentry id="function.usbreleaseinterface">      <refnamediv>        <refname>usb_release_interface</refname>        <refpurpose>Releases a previously claimed interface</refpurpose>      </refnamediv>      <refsect1>        <title>Description</title>        <funcsynopsis>          <funcprototype>            <funcdef>int <function>usb_release_interface</function></funcdef>            <paramdef>usb_dev_handle *<parameter>dev</parameter></paramdef>            <paramdef>int <parameter>interface</parameter></paramdef>

⌨️ 快捷键说明

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