14eaae44dSAndrew Thompson.\" 24eaae44dSAndrew Thompson.\" Copyright (c) 2008 Hans Petter Selasky 34eaae44dSAndrew Thompson.\" 44eaae44dSAndrew Thompson.\" All rights reserved. 54eaae44dSAndrew Thompson.\" 64eaae44dSAndrew Thompson.\" Redistribution and use in source and binary forms, with or without 74eaae44dSAndrew Thompson.\" modification, are permitted provided that the following conditions 84eaae44dSAndrew Thompson.\" are met: 94eaae44dSAndrew Thompson.\" 1. Redistributions of source code must retain the above copyright 104eaae44dSAndrew Thompson.\" notice, this list of conditions and the following disclaimer. 114eaae44dSAndrew Thompson.\" 2. Redistributions in binary form must reproduce the above copyright 124eaae44dSAndrew Thompson.\" notice, this list of conditions and the following disclaimer in the 134eaae44dSAndrew Thompson.\" documentation and/or other materials provided with the distribution. 144eaae44dSAndrew Thompson.\" 154eaae44dSAndrew Thompson.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 164eaae44dSAndrew Thompson.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 174eaae44dSAndrew Thompson.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 184eaae44dSAndrew Thompson.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 194eaae44dSAndrew Thompson.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 204eaae44dSAndrew Thompson.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 214eaae44dSAndrew Thompson.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 224eaae44dSAndrew Thompson.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 234eaae44dSAndrew Thompson.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 244eaae44dSAndrew Thompson.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 254eaae44dSAndrew Thompson.\" SUCH DAMAGE. 264eaae44dSAndrew Thompson.\" 274eaae44dSAndrew Thompson.\" $FreeBSD$ 284eaae44dSAndrew Thompson.\" 294eaae44dSAndrew Thompson.Dd Feb 14, 2009 304eaae44dSAndrew Thompson.Dt LIBUSB 3 314eaae44dSAndrew Thompson.Os 324eaae44dSAndrew Thompson.Sh NAME 334eaae44dSAndrew Thompson.Nm libusb 344eaae44dSAndrew Thompson. 354eaae44dSAndrew Thompson.Nd "USB access library" 364eaae44dSAndrew Thompson. 374eaae44dSAndrew Thompson. 384eaae44dSAndrew Thompson.Sh LIBRARY 394eaae44dSAndrew Thompson. 404eaae44dSAndrew Thompson. 414eaae44dSAndrew ThompsonUSB access library (libusb -lusb) 424eaae44dSAndrew Thompson. 434eaae44dSAndrew Thompson. 444eaae44dSAndrew Thompson. 454eaae44dSAndrew Thompson.Sh SYNOPSIS 464eaae44dSAndrew Thompson. 474eaae44dSAndrew Thompson. 484eaae44dSAndrew Thompson.In libusb20.h 494eaae44dSAndrew Thompson. 504eaae44dSAndrew Thompson. 514eaae44dSAndrew Thompson.Sh DESCRIPTION 524eaae44dSAndrew Thompson. 534eaae44dSAndrew ThompsonThe 544eaae44dSAndrew Thompson.Nm 554eaae44dSAndrew Thompsonlibrary implements functions to be able to easily access and control 564eaae44dSAndrew ThompsonUSB through the USB file system interface. 574eaae44dSAndrew Thompson. 584eaae44dSAndrew Thompson. 594eaae44dSAndrew Thompson.Sh USB TRANSFER OPERATIONS 604eaae44dSAndrew Thompson. 614eaae44dSAndrew Thompson.Pp 624eaae44dSAndrew Thompson. 634eaae44dSAndrew Thompson.Fn libusb20_tr_close pxfer 644eaae44dSAndrew ThompsonThis function will release all kernel resources associated with an USB 654eaae44dSAndrew Thompson.Fa pxfer . 664eaae44dSAndrew Thompson. 674eaae44dSAndrew ThompsonThis function returns zero upon success. 684eaae44dSAndrew Thompson. 694eaae44dSAndrew ThompsonNon-zero return values indicate a LIBUSB20_ERROR value. 704eaae44dSAndrew Thompson. 714eaae44dSAndrew Thompson.Pp 724eaae44dSAndrew Thompson. 734eaae44dSAndrew Thompson.Fn libusb20_tr_open pxfer max_buf_size max_frame_count ep_no 744eaae44dSAndrew ThompsonThis function will allocate kernel resources like 754eaae44dSAndrew Thompson.Fa max_buf_size 764eaae44dSAndrew Thompsonand 774eaae44dSAndrew Thompson.Fa max_frame_count 784eaae44dSAndrew Thompsonassociated with an USB 794eaae44dSAndrew Thompson.Fa pxfer 804eaae44dSAndrew Thompsonand bind the transfer to the specified 814eaae44dSAndrew Thompson.Fa ep_no . 824eaae44dSAndrew Thompson. 834eaae44dSAndrew ThompsonThis function returns zero upon success. 844eaae44dSAndrew Thompson. 854eaae44dSAndrew ThompsonNon-zero return values indicate a LIBUSB20_ERROR value. 864eaae44dSAndrew Thompson. 874eaae44dSAndrew Thompson.Pp 884eaae44dSAndrew Thompson. 894eaae44dSAndrew Thompson.Fn libusb20_tr_get_pointer pdev tr_index 904eaae44dSAndrew ThompsonThis function will return a pointer to the allocated USB transfer according to the 914eaae44dSAndrew Thompson.Fa pdev 924eaae44dSAndrew Thompsonand 934eaae44dSAndrew Thompson.Fa tr_index 944eaae44dSAndrew Thompsonarguments. 954eaae44dSAndrew Thompson. 964eaae44dSAndrew ThompsonThis function returns NULL in case of failure. 974eaae44dSAndrew Thompson. 984eaae44dSAndrew Thompson.Pp 994eaae44dSAndrew Thompson. 1004eaae44dSAndrew Thompson.Fn libusb20_tr_get_time_complete pxfer 1014eaae44dSAndrew ThompsonThis function will return the completion time of an USB transfer in 1024eaae44dSAndrew Thompsonmillisecond units. This function is most useful for isochronous USB 1034eaae44dSAndrew Thompsontransfers when doing echo cancelling. 1044eaae44dSAndrew Thompson. 1054eaae44dSAndrew Thompson.Pp 1064eaae44dSAndrew Thompson. 1074eaae44dSAndrew Thompson.Fn libusb20_tr_get_actual_frames pxfer 1084eaae44dSAndrew ThompsonThis function will return the actual number of USB frames after an USB 1094eaae44dSAndrew Thompsontransfer completed. A value of zero means that no data was transferred. 1104eaae44dSAndrew Thompson. 1114eaae44dSAndrew Thompson.Pp 1124eaae44dSAndrew Thompson. 1134eaae44dSAndrew Thompson.Fn libusb20_tr_get_actual_length pxfer 1144eaae44dSAndrew ThompsonThis function will return the sum of the actual length for all 1154eaae44dSAndrew Thompsontransferred USB frames for the given USB transfer. 1164eaae44dSAndrew Thompson. 1174eaae44dSAndrew Thompson.Pp 1184eaae44dSAndrew Thompson. 1194eaae44dSAndrew Thompson.Fn libusb20_tr_get_max_frames pxfer 1204eaae44dSAndrew ThompsonThis function will return the maximum number of USB frames that were 1214eaae44dSAndrew Thompsonallocated when an USB transfer was setup for the given USB transfer. 1224eaae44dSAndrew Thompson. 1234eaae44dSAndrew Thompson.Pp 1244eaae44dSAndrew Thompson. 1254eaae44dSAndrew Thompson.Fn libusb20_tr_get_max_packet_length pxfer 1264eaae44dSAndrew ThompsonThis function will return the maximum packet length in bytes 1274eaae44dSAndrew Thompsonassociated with the given USB transfer. 1284eaae44dSAndrew Thompson. 1294eaae44dSAndrew ThompsonThe packet length can be used round up buffer sizes so that short USB 1304eaae44dSAndrew Thompsonpackets are avoided for proxy buffers. 1314eaae44dSAndrew Thompson. 1324eaae44dSAndrew Thompson. 1334eaae44dSAndrew Thompson.Pp 1344eaae44dSAndrew Thompson. 1354eaae44dSAndrew Thompson.Fn libusb20_tr_get_max_total_length pxfer 1364eaae44dSAndrew ThompsonThis function will return the maximum value for the length sum of all 1374eaae44dSAndrew ThompsonUSB frames associated with an USB transfer. 1384eaae44dSAndrew Thompson. 1394eaae44dSAndrew Thompson.Pp 1404eaae44dSAndrew Thompson. 1414eaae44dSAndrew Thompson.Fn libusb20_tr_get_status pxfer 1424eaae44dSAndrew ThompsonThis function will return the status of an USB transfer. 1434eaae44dSAndrew Thompson. 1444eaae44dSAndrew ThompsonStatus values are defined by a set of LIBUSB20_TRANSFER_XXX enums. 1454eaae44dSAndrew Thompson. 1464eaae44dSAndrew Thompson.Pp 1474eaae44dSAndrew Thompson. 1484eaae44dSAndrew Thompson.Fn libusb20_tr_pending pxfer 1494eaae44dSAndrew ThompsonThis function will return non-zero if the given USB transfer is 1504eaae44dSAndrew Thompsonpending for completion. 1514eaae44dSAndrew Thompson. 1524eaae44dSAndrew ThompsonElse this function returns zero. 1534eaae44dSAndrew Thompson. 1544eaae44dSAndrew Thompson.Pp 1554eaae44dSAndrew Thompson. 1564eaae44dSAndrew Thompson.Fn libusb20_tr_callback_wrapper pxfer 1574eaae44dSAndrew ThompsonThis is an internal function used to wrap asynchronous USB callbacks. 1584eaae44dSAndrew Thompson. 1594eaae44dSAndrew Thompson.Pp 1604eaae44dSAndrew Thompson. 1614eaae44dSAndrew Thompson.Fn libusb20_tr_clear_stall_sync pxfer 1624eaae44dSAndrew ThompsonThis is an internal function used to synchronously clear the stall on 1634eaae44dSAndrew Thompsonthe given USB transfer. 1644eaae44dSAndrew Thompson. 1654eaae44dSAndrew ThompsonPlease see the USB specification for more information on stall 1664eaae44dSAndrew Thompsonclearing. 1674eaae44dSAndrew Thompson. 1684eaae44dSAndrew ThompsonIf the given USB transfer is pending when this function is called, the 1694eaae44dSAndrew ThompsonUSB transfer will complete with an error after that this function has 1704eaae44dSAndrew Thompsonbeen called. 1714eaae44dSAndrew Thompson. 1724eaae44dSAndrew Thompson.Pp 1734eaae44dSAndrew Thompson. 1744eaae44dSAndrew Thompson.Fn libusb20_tr_drain pxfer 1754eaae44dSAndrew ThompsonThis function will stop the given USB transfer and will not return 1764eaae44dSAndrew Thompsonuntil the USB transfer has been stopped in hardware. 1774eaae44dSAndrew Thompson. 1784eaae44dSAndrew Thompson.Pp 1794eaae44dSAndrew Thompson. 1804eaae44dSAndrew Thompson.Fn libusb20_tr_set_buffer pxfer pbuf fr_index 1814eaae44dSAndrew ThompsonThis function is used to set the 1824eaae44dSAndrew Thompson.Fa buffer 1834eaae44dSAndrew Thompsonpointer for the given USB transfer and 1844eaae44dSAndrew Thompson.Fa fr_index . 1854eaae44dSAndrew Thompson. 1864eaae44dSAndrew ThompsonTypically the frame index is zero. 1874eaae44dSAndrew Thompson. 1884eaae44dSAndrew Thompson. 1894eaae44dSAndrew Thompson.Pp 1904eaae44dSAndrew Thompson. 1914eaae44dSAndrew Thompson.Fn libusb20_tr_set_callback pxfer pcallback 1924eaae44dSAndrew ThompsonThis function is used to set the USB callback for asynchronous USB 1934eaae44dSAndrew Thompsontransfers. 1944eaae44dSAndrew Thompson. 1954eaae44dSAndrew ThompsonThe callback type is defined by libusb20_tr_callback_t. 1964eaae44dSAndrew Thompson. 1974eaae44dSAndrew Thompson.Pp 1984eaae44dSAndrew Thompson. 1994eaae44dSAndrew Thompson.Fn libusb20_tr_set_flags pxfer flags 2004eaae44dSAndrew ThompsonThis function is used to set various USB flags for the given USB transfer. 2014eaae44dSAndrew Thompson.Bl -tag 2024eaae44dSAndrew Thompson.It LIBUSB20_TRANSFER_SINGLE_SHORT_NOT_OK 2034eaae44dSAndrew ThompsonReport a short frame as error. 2044eaae44dSAndrew Thompson.It LIBUSB20_TRANSFER_MULTI_SHORT_NOT_OK 2054eaae44dSAndrew ThompsonMultiple short frames are not allowed. 2064eaae44dSAndrew Thompson.It LIBUSB20_TRANSFER_FORCE_SHORT 2074eaae44dSAndrew ThompsonAll transmitted frames are short terminated. 2084eaae44dSAndrew Thompson.It LIBUSB20_TRANSFER_DO_CLEAR_STALL 2094eaae44dSAndrew ThompsonWill do a clear-stall before starting the transfer. 2104eaae44dSAndrew Thompson.El 2114eaae44dSAndrew Thompson. 2124eaae44dSAndrew Thompson.Pp 2134eaae44dSAndrew Thompson. 2144eaae44dSAndrew Thompson.Fn libusb20_tr_set_length pxfer length fr_index 2154eaae44dSAndrew ThompsonThis function sets the length of a given USB transfer and frame index. 2164eaae44dSAndrew Thompson. 2174eaae44dSAndrew Thompson.Pp 2184eaae44dSAndrew Thompson. 2194eaae44dSAndrew Thompson.Fn libusb20_tr_set_priv_sc0 pxfer psc0 2204eaae44dSAndrew ThompsonThis function sets private driver pointer number zero. 2214eaae44dSAndrew Thompson. 2224eaae44dSAndrew Thompson.Pp 2234eaae44dSAndrew Thompson. 2244eaae44dSAndrew Thompson.Fn libusb20_tr_set_priv_sc1 pxfer psc1 2254eaae44dSAndrew ThompsonThis function sets private driver pointer number one. 2264eaae44dSAndrew Thompson. 2274eaae44dSAndrew Thompson.Pp 2284eaae44dSAndrew Thompson. 2294eaae44dSAndrew Thompson.Fn libusb20_tr_set_timeout pxfer timeout 2304eaae44dSAndrew ThompsonThis function sets the timeout for the given USB transfer. 2314eaae44dSAndrew Thompson. 2324eaae44dSAndrew ThompsonA timeout value of zero means no timeout. 2334eaae44dSAndrew Thompson. 2344eaae44dSAndrew ThompsonThe timeout is given in milliseconds. 2354eaae44dSAndrew Thompson. 2364eaae44dSAndrew Thompson.Pp 2374eaae44dSAndrew Thompson. 2384eaae44dSAndrew Thompson.Fn libusb20_tr_set_total_frames pxfer nframes 2394eaae44dSAndrew ThompsonThis function sets the total number of frames that should be executed when the USB transfer is submitted. 2404eaae44dSAndrew Thompson. 2414eaae44dSAndrew ThompsonThe total number of USB frames must be less than the maximum number of USB frames associated with the given USB transfer. 2424eaae44dSAndrew Thompson. 2434eaae44dSAndrew Thompson.Pp 2444eaae44dSAndrew Thompson. 2454eaae44dSAndrew Thompson.Fn libusb20_tr_setup_bulk pxfer pbuf length timeout 2464eaae44dSAndrew ThompsonThis function is a helper function for setting up a single frame USB BULK transfer. 2474eaae44dSAndrew Thompson. 2484eaae44dSAndrew Thompson.Pp 2494eaae44dSAndrew Thompson. 2504eaae44dSAndrew Thompson.Fn libusb20_tr_setup_control pxfer psetup pbuf timeout 2514eaae44dSAndrew ThompsonThis function is a helper function for setting up a single or dual 2524eaae44dSAndrew Thompsonframe USB CONTROL transfer depending on the control transfer length. 2534eaae44dSAndrew Thompson. 2544eaae44dSAndrew Thompson.Pp 2554eaae44dSAndrew Thompson. 2564eaae44dSAndrew Thompson.Fn libusb20_tr_setup_intr pxfer pbuf length timeout 2574eaae44dSAndrew ThompsonThis function is a helper function for setting up a single frame USB INTERRUPT transfer. 2584eaae44dSAndrew Thompson. 2594eaae44dSAndrew Thompson.Pp 2604eaae44dSAndrew Thompson. 2614eaae44dSAndrew Thompson.Fn libusb20_tr_setup_isoc pxfer pbuf length fr_index 2624eaae44dSAndrew ThompsonThis function is a helper function for setting up a multi frame USB ISOCHRONOUS transfer. 2634eaae44dSAndrew Thompson. 2644eaae44dSAndrew Thompson.Pp 2654eaae44dSAndrew Thompson. 2664eaae44dSAndrew Thompson.Fn libusb20_tr_start pxfer 2674eaae44dSAndrew ThompsonThis function will get the USB transfer started, if not already 2684eaae44dSAndrew Thompsonstarted. 2694eaae44dSAndrew Thompson. 2704eaae44dSAndrew ThompsonThis function will not get the transfer queued in hardware. 2714eaae44dSAndrew Thompson. 2724eaae44dSAndrew ThompsonThis function is non-blocking. 2734eaae44dSAndrew Thompson. 2744eaae44dSAndrew Thompson.Pp 2754eaae44dSAndrew Thompson. 2764eaae44dSAndrew Thompson.Fn libusb20_tr_stop pxfer 2774eaae44dSAndrew ThompsonThis function will get the USB transfer stopped, if not already stopped. 2784eaae44dSAndrew Thompson. 2794eaae44dSAndrew ThompsonThis function is non-blocking, which means that the actual stop can 2804eaae44dSAndrew Thompsonhappen after the return of this function. 2814eaae44dSAndrew Thompson. 2824eaae44dSAndrew Thompson.Pp 2834eaae44dSAndrew Thompson. 2844eaae44dSAndrew Thompson.Fn libusb20_tr_submit pxfer 2854eaae44dSAndrew ThompsonThis function will get the USB transfer queued in hardware. 2864eaae44dSAndrew Thompson. 2874eaae44dSAndrew Thompson. 2884eaae44dSAndrew Thompson.Pp 2894eaae44dSAndrew Thompson. 2904eaae44dSAndrew Thompson.Fn libusb20_tr_get_priv_sc0 pxfer 2914eaae44dSAndrew ThompsonThis function returns private driver pointer number zero associated 2924eaae44dSAndrew Thompsonwith an USB transfer. 2934eaae44dSAndrew Thompson. 2944eaae44dSAndrew Thompson. 2954eaae44dSAndrew Thompson.Pp 2964eaae44dSAndrew Thompson. 2974eaae44dSAndrew Thompson.Fn libusb20_tr_get_priv_sc1 pxfer 2984eaae44dSAndrew ThompsonThis function returns private driver pointer number one associated 2994eaae44dSAndrew Thompsonwith an USB transfer. 3004eaae44dSAndrew Thompson. 3014eaae44dSAndrew Thompson. 3024eaae44dSAndrew Thompson.Sh USB DEVICE OPERATIONS 3034eaae44dSAndrew Thompson. 3044eaae44dSAndrew Thompson.Pp 3054eaae44dSAndrew Thompson. 3064eaae44dSAndrew Thompson.Fn libusb20_dev_get_backend_name pdev 3074eaae44dSAndrew ThompsonThis function returns a zero terminated string describing the backend used. 3084eaae44dSAndrew Thompson. 3094eaae44dSAndrew Thompson.Pp 3104eaae44dSAndrew Thompson. 3114eaae44dSAndrew Thompson.Fn libusb20_dev_get_info pdev pinfo 3124eaae44dSAndrew ThompsonThis function retrives the BSD specific usb2_device_info structure into the memory location given by 3134eaae44dSAndrew Thompson.Fa pinfo . 3144eaae44dSAndrew ThompsonThe USB device given by 3154eaae44dSAndrew Thompson.Fa pdev 3164eaae44dSAndrew Thompsonmust be opened before this function will succeed. 3174eaae44dSAndrew ThompsonThis function returns zero on success else a LIBUSB20_ERROR value is returned. 3184eaae44dSAndrew Thompson. 3194eaae44dSAndrew Thompson.Pp 3204eaae44dSAndrew Thompson. 3214eaae44dSAndrew Thompson.Fn libusb20_dev_get_iface_desc pdev iface_index pbuf len 3224eaae44dSAndrew ThompsonThis function retrieves the kernel interface description for the given USB 3234eaae44dSAndrew Thompson.Fa iface_index . 3244eaae44dSAndrew ThompsonThe format of the USB interface description is: "drivername<unit>: <description>" 3254eaae44dSAndrew ThompsonThe description string is always zero terminated. 3264eaae44dSAndrew ThompsonA zero length string is written in case no driver is attached to the given interface. 3274eaae44dSAndrew ThompsonThe USB device given by 3284eaae44dSAndrew Thompson.Fa pdev 3294eaae44dSAndrew Thompsonmust be opened before this function will succeed. 3304eaae44dSAndrew ThompsonThis function returns zero on success else a LIBUSB20_ERROR value is returned. 3314eaae44dSAndrew Thompson. 3324eaae44dSAndrew Thompson.Pp 3334eaae44dSAndrew Thompson. 3344eaae44dSAndrew Thompson.Fn libusb20_dev_get_desc pdev 3354eaae44dSAndrew ThompsonThis function returns a zero terminated string describing the given USB device. 3364eaae44dSAndrew ThompsonThe format of the string is: "drivername<unit>: <description>" 3374eaae44dSAndrew Thompson. 3384eaae44dSAndrew Thompson.Pp 3394eaae44dSAndrew Thompson. 3404eaae44dSAndrew Thompson.Fn libusb20_dev_claim_interface pdev iface_index 3414eaae44dSAndrew ThompsonThis function will try to claim the given USB interface given by 3424eaae44dSAndrew Thompson.Fa iface_index . 3434eaae44dSAndrew ThompsonThis function returns zero on success else a LIBUSB20_ERROR value is 3444eaae44dSAndrew Thompsonreturned. 3454eaae44dSAndrew Thompson. 3464eaae44dSAndrew Thompson.Pp 3474eaae44dSAndrew Thompson. 3484eaae44dSAndrew Thompson.Fn libusb20_dev_close pdev 3494eaae44dSAndrew ThompsonThis function will close the given USB device. 3504eaae44dSAndrew Thompson. 3514eaae44dSAndrew ThompsonThis function returns zero on success else a LIBUSB20_ERROR value is 3524eaae44dSAndrew Thompsonreturned. 3534eaae44dSAndrew Thompson. 3544eaae44dSAndrew Thompson.Pp 3554eaae44dSAndrew Thompson. 3564eaae44dSAndrew Thompson.Fn libusb20_dev_detach_kernel_driver pdev iface_index 3574eaae44dSAndrew ThompsonThis function will try to detach the kernel driver for the USB interface given by 3584eaae44dSAndrew Thompson.Fa iface_index . 3594eaae44dSAndrew Thompson. 3604eaae44dSAndrew ThompsonThis function returns zero on success else a LIBUSB20_ERROR value is 3614eaae44dSAndrew Thompsonreturned. 3624eaae44dSAndrew Thompson. 3634eaae44dSAndrew Thompson.Pp 3644eaae44dSAndrew Thompson. 3654eaae44dSAndrew Thompson.Fn libusb20_dev_set_config_index pdev config_index 3664eaae44dSAndrew ThompsonThis function will try to set the configuration index on an USB 3674eaae44dSAndrew Thompsondevice. 3684eaae44dSAndrew Thompson. 3694eaae44dSAndrew ThompsonThe first configuration index is zero. 3704eaae44dSAndrew Thompson. 3714eaae44dSAndrew ThompsonThe un-configure index is 255. 3724eaae44dSAndrew Thompson. 3734eaae44dSAndrew ThompsonThis function returns zero on success else a LIBUSB20_ERROR value is returned. 3744eaae44dSAndrew Thompson. 3754eaae44dSAndrew Thompson.Pp 3764eaae44dSAndrew Thompson. 3774eaae44dSAndrew Thompson.Fn libusb20_dev_get_debug pdev 3784eaae44dSAndrew ThompsonThis function returns the debug level of an USB device. 3794eaae44dSAndrew Thompson. 3804eaae44dSAndrew Thompson.Pp 3814eaae44dSAndrew Thompson. 3824eaae44dSAndrew Thompson.Fn libusb20_dev_get_fd pdev 3834eaae44dSAndrew ThompsonThis function returns the file descriptor of the given USB device. 3844eaae44dSAndrew Thompson. 3854eaae44dSAndrew ThompsonA negative value is returned when no file descriptor is present. 3864eaae44dSAndrew Thompson. 3874eaae44dSAndrew ThompsonThe file descriptor can be used for polling purposes. 3884eaae44dSAndrew Thompson. 3894eaae44dSAndrew Thompson.Pp 3904eaae44dSAndrew Thompson. 3914eaae44dSAndrew Thompson.Fn libusb20_dev_kernel_driver_active pdev iface_index 3924eaae44dSAndrew ThompsonThis function returns a non-zero value if a kernel driver is active on 3934eaae44dSAndrew Thompsonthe given USB interface. 3944eaae44dSAndrew Thompson. 3954eaae44dSAndrew ThompsonElse zero is returned. 3964eaae44dSAndrew Thompson. 3974eaae44dSAndrew Thompson.Pp 3984eaae44dSAndrew Thompson. 3994eaae44dSAndrew Thompson.Fn libusb20_dev_open pdev transfer_max 4004eaae44dSAndrew ThompsonThis function opens an USB device so that setting up USB transfers 4014eaae44dSAndrew Thompsonbecomes possible. 4024eaae44dSAndrew Thompson. 4034eaae44dSAndrew ThompsonThe number of USB transfers can be zero which means only control 4044eaae44dSAndrew Thompsontransfers are allowed. 4054eaae44dSAndrew Thompson. 4064eaae44dSAndrew ThompsonThis function returns zero on success else a LIBUSB20_ERROR value is 4074eaae44dSAndrew Thompsonreturned. 4084eaae44dSAndrew Thompson. 4094eaae44dSAndrew ThompsonA return value of LIBUSB20_ERROR_BUSY means that the device is already 4104eaae44dSAndrew Thompsonopened. 4114eaae44dSAndrew Thompson. 4124eaae44dSAndrew Thompson.Pp 4134eaae44dSAndrew Thompson. 4144eaae44dSAndrew Thompson.Fn libusb20_dev_process pdev 4154eaae44dSAndrew ThompsonThis function is called to sync kernel USB transfers with userland USB 4164eaae44dSAndrew Thompsontransfers. 4174eaae44dSAndrew Thompson. 4184eaae44dSAndrew ThompsonThis function returns zero on success else a LIBUSB20_ERROR value is 4194eaae44dSAndrew Thompsonreturned typically indicating that the given USB device has been 4204eaae44dSAndrew Thompsondetached. 4214eaae44dSAndrew Thompson. 4224eaae44dSAndrew Thompson.Pp 4234eaae44dSAndrew Thompson. 4244eaae44dSAndrew Thompson.Fn libusb20_dev_release_interface pdev iface_index 4254eaae44dSAndrew ThompsonThis function will try to release a claimed USB interface for the specified USB device. 4264eaae44dSAndrew Thompson. 4274eaae44dSAndrew ThompsonThis function returns zero on success else a LIBUSB20_ERROR value is 4284eaae44dSAndrew Thompsonreturned. 4294eaae44dSAndrew Thompson. 4304eaae44dSAndrew Thompson.Pp 4314eaae44dSAndrew Thompson. 4324eaae44dSAndrew Thompson.Fn libusb20_dev_request_sync pdev psetup pdata pactlen timeout flags 4334eaae44dSAndrew ThompsonThis function will perform a synchronous control request on the given 4344eaae44dSAndrew ThompsonUSB device. 4354eaae44dSAndrew Thompson. 4364eaae44dSAndrew ThompsonBefore this call will succeed the USB device must be opened. 4374eaae44dSAndrew Thompson. 4384eaae44dSAndrew Thompson.Fa setup 4394eaae44dSAndrew Thompsonis a pointer to a decoded and host endian SETUP packet. 4404eaae44dSAndrew Thompson.Fa data 4414eaae44dSAndrew Thompsonis a pointer to a data transfer buffer associated with the control transaction. This argument can be NULL. 4424eaae44dSAndrew Thompson.Fa pactlen 4434eaae44dSAndrew Thompsonis a pointer to a variable that will hold the actual transfer length after the control transaction is complete. 4444eaae44dSAndrew Thompson.Fa timeout 4454eaae44dSAndrew Thompsonis the transaction timeout given in milliseconds. 4464eaae44dSAndrew ThompsonA timeout of zero means no timeout. 4474eaae44dSAndrew Thompson.Fa flags 4484eaae44dSAndrew Thompsonis used to specify transaction flags, for example LIBUSB20_TRANSFER_SINGLE_SHORT_NOT_OK. 4494eaae44dSAndrew Thompson. 4504eaae44dSAndrew ThompsonThis function returns zero on success else a LIBUSB20_ERROR value is 4514eaae44dSAndrew Thompsonreturned. 4524eaae44dSAndrew Thompson. 4534eaae44dSAndrew Thompson.Pp 4544eaae44dSAndrew Thompson. 4554eaae44dSAndrew Thompson.Fn libusb20_dev_req_string_sync pdev index lang_id pbuf len 4564eaae44dSAndrew ThompsonThis function will synchronously request an USB string by language ID 4574eaae44dSAndrew Thompsonand string index into the given buffer limited by a maximum length. 4584eaae44dSAndrew Thompson. 4594eaae44dSAndrew ThompsonThis function returns zero on success else a LIBUSB20_ERROR value is 4604eaae44dSAndrew Thompsonreturned. 4614eaae44dSAndrew Thompson. 4624eaae44dSAndrew Thompson.Pp 4634eaae44dSAndrew Thompson. 4644eaae44dSAndrew Thompson.Fn libusb20_dev_req_string_simple_sync pdev index pbuf len 4654eaae44dSAndrew ThompsonThis function will synchronously request an USB string using the 4664eaae44dSAndrew Thompsondefault language ID and convert the string into ASCII before storing 4674eaae44dSAndrew Thompsonthe string into the given buffer limited by a maximum length which 4684eaae44dSAndrew Thompsonincludes the terminating zero. 4694eaae44dSAndrew Thompson. 4704eaae44dSAndrew ThompsonThis function returns zero on success else a LIBUSB20_ERROR value is 4714eaae44dSAndrew Thompsonreturned. 4724eaae44dSAndrew Thompson. 4734eaae44dSAndrew Thompson. 4744eaae44dSAndrew Thompson.Pp 4754eaae44dSAndrew Thompson. 4764eaae44dSAndrew Thompson.Fn libusb20_dev_reset pdev 4774eaae44dSAndrew ThompsonThis function will try to BUS reset the given USB device and restore 4784eaae44dSAndrew Thompsonthe last set USB configuration. 4794eaae44dSAndrew Thompson. 4804eaae44dSAndrew ThompsonThis function returns zero on success else a LIBUSB20_ERROR value is 4814eaae44dSAndrew Thompsonreturned. 4824eaae44dSAndrew Thompson. 4834eaae44dSAndrew Thompson.Pp 4844eaae44dSAndrew Thompson. 4854eaae44dSAndrew Thompson.Fn libusb20_dev_set_power_mode pdev power_mode 4864eaae44dSAndrew ThompsonThis function sets the power mode of the USB device. 4874eaae44dSAndrew Thompson. 4884eaae44dSAndrew ThompsonValid power modes: 4894eaae44dSAndrew Thompson.Bl -tag 4904eaae44dSAndrew Thompson.It LIBUSB20_POWER_OFF 4914eaae44dSAndrew Thompson.It LIBUSB20_POWER_ON 4924eaae44dSAndrew Thompson.It LIBUSB20_POWER_SAVE 4934eaae44dSAndrew Thompson.It LIBUSB20_POWER_SUSPEND 4944eaae44dSAndrew Thompson.It LIBUSB20_POWER_RESUME 4954eaae44dSAndrew Thompson.El 4964eaae44dSAndrew Thompson. 4974eaae44dSAndrew ThompsonThis function returns zero on success else a LIBUSB20_ERROR value is 4984eaae44dSAndrew Thompsonreturned. 4994eaae44dSAndrew Thompson. 5004eaae44dSAndrew Thompson.Pp 5014eaae44dSAndrew Thompson. 5024eaae44dSAndrew Thompson.Fn libusb20_dev_get_power_mode pdev 5034eaae44dSAndrew ThompsonThis function returns the currently selected power mode for the given 5044eaae44dSAndrew ThompsonUSB device. 5054eaae44dSAndrew Thompson. 5064eaae44dSAndrew Thompson.Pp 5074eaae44dSAndrew Thompson. 5084eaae44dSAndrew Thompson.Fn libusb20_dev_set_alt_index pdev iface_index alt_index 5094eaae44dSAndrew ThompsonThis function will try to set the given alternate index for the given 5104eaae44dSAndrew ThompsonUSB interface index. 5114eaae44dSAndrew Thompson. 5124eaae44dSAndrew ThompsonThis function returns zero on success else a LIBUSB20_ERROR value is 5134eaae44dSAndrew Thompsonreturned. 5144eaae44dSAndrew Thompson. 5154eaae44dSAndrew Thompson.Pp 5164eaae44dSAndrew Thompson. 5174eaae44dSAndrew Thompson.Fn libusb20_dev_get_device_desc pdev 5184eaae44dSAndrew ThompsonThis function returns a pointer to the decoded and host endian version 5194eaae44dSAndrew Thompsonof the device descriptor. 5204eaae44dSAndrew Thompson. 5214eaae44dSAndrew ThompsonThe USB device need not be opened when calling this function. 5224eaae44dSAndrew Thompson. 5234eaae44dSAndrew Thompson.Pp 5244eaae44dSAndrew Thompson. 5254eaae44dSAndrew Thompson.Fn libusb20_dev_alloc_config pdev config_index 5264eaae44dSAndrew ThompsonThis function will read out and decode the USB config descriptor for 5274eaae44dSAndrew Thompsonthe given USB device and config index. This function returns a pointer 5284eaae44dSAndrew Thompsonto the decoded configuration which must eventually be passed to 5294eaae44dSAndrew Thompsonfree(). NULL is returned in case of failure. 5304eaae44dSAndrew Thompson. 5314eaae44dSAndrew Thompson.Pp 5324eaae44dSAndrew Thompson. 5334eaae44dSAndrew Thompson.Fn libusb20_dev_alloc void 5344eaae44dSAndrew ThompsonThis is an internal function to allocate a new USB device. 5354eaae44dSAndrew Thompson. 5364eaae44dSAndrew Thompson.Pp 5374eaae44dSAndrew Thompson. 5384eaae44dSAndrew Thompson.Fn libusb20_dev_get_address pdev 5394eaae44dSAndrew ThompsonThis function returns the internal and not necessarily the real 5404eaae44dSAndrew Thompsonhardware address of the given USB device. 5414eaae44dSAndrew Thompson. 5424eaae44dSAndrew Thompson.Pp 5434eaae44dSAndrew Thompson. 5444eaae44dSAndrew Thompson.Fn libusb20_dev_get_bus_number pdev 5454eaae44dSAndrew ThompsonThis function return the internal bus number which the given USB 5464eaae44dSAndrew Thompsondevice belongs to. 5474eaae44dSAndrew Thompson. 5484eaae44dSAndrew Thompson.Pp 5494eaae44dSAndrew Thompson. 5504eaae44dSAndrew Thompson.Fn libusb20_dev_get_mode pdev 5514eaae44dSAndrew ThompsonThis function returns the current operation mode of the USB entity. 5524eaae44dSAndrew Thompson. 5534eaae44dSAndrew ThompsonValid return values are: 5544eaae44dSAndrew Thompson.Bl -tag 5554eaae44dSAndrew Thompson.It LIBUSB20_MODE_HOST 5564eaae44dSAndrew Thompson.It LIBUSB20_MODE_DEVICE 5574eaae44dSAndrew Thompson.El 5584eaae44dSAndrew Thompson. 5594eaae44dSAndrew Thompson.Pp 5604eaae44dSAndrew Thompson. 5614eaae44dSAndrew Thompson.Fn libusb20_dev_get_speed pdev 5624eaae44dSAndrew ThompsonThis function returns the current speed of the given USB device. 5634eaae44dSAndrew Thompson. 5644eaae44dSAndrew Thompson.Bl -tag 5654eaae44dSAndrew Thompson.It LIBUSB20_SPEED_UNKNOWN 5664eaae44dSAndrew Thompson.It LIBUSB20_SPEED_LOW 5674eaae44dSAndrew Thompson.It LIBUSB20_SPEED_FULL 5684eaae44dSAndrew Thompson.It LIBUSB20_SPEED_HIGH 5694eaae44dSAndrew Thompson.It LIBUSB20_SPEED_VARIABLE 5704eaae44dSAndrew Thompson.It LIBUSB20_SPEED_SUPER 5714eaae44dSAndrew Thompson.El 5724eaae44dSAndrew Thompson. 5734eaae44dSAndrew Thompson.Pp 5744eaae44dSAndrew Thompson. 5754eaae44dSAndrew Thompson.Fn libusb20_dev_get_config_index pdev 5764eaae44dSAndrew ThompsonThis function returns the currently select config index for the given 5774eaae44dSAndrew ThompsonUSB device. 5784eaae44dSAndrew Thompson. 5794eaae44dSAndrew Thompson.Pp 5804eaae44dSAndrew Thompson. 5814eaae44dSAndrew Thompson.Fn libusb20_dev_free pdev 5824eaae44dSAndrew ThompsonThis function will free the given USB device and all associated USB 5834eaae44dSAndrew Thompsontransfers. 5844eaae44dSAndrew Thompson. 5854eaae44dSAndrew Thompson.Pp 5864eaae44dSAndrew Thompson. 5874eaae44dSAndrew Thompson.Fn libusb20_dev_set_debug pdev debug_level 5884eaae44dSAndrew ThompsonThis function will set the debug level for the given USB device. 5894eaae44dSAndrew Thompson. 5904eaae44dSAndrew Thompson.Pp 5914eaae44dSAndrew Thompson. 5924eaae44dSAndrew Thompson.Fn libusb20_dev_wait_process pdev timeout 5934eaae44dSAndrew ThompsonThis function will wait until a pending USB transfer has completed on 5944eaae44dSAndrew Thompsonthe given USB device. 5954eaae44dSAndrew Thompson. 5964eaae44dSAndrew ThompsonA timeout value can be specified which is passed on to the 5974eaae44dSAndrew Thompson.Xr 2 poll 5984eaae44dSAndrew Thompsonfunction. 5994eaae44dSAndrew Thompson. 6004eaae44dSAndrew Thompson.Sh USB BACKEND OPERATIONS 6014eaae44dSAndrew Thompson. 6024eaae44dSAndrew Thompson.Fn libusb20_be_get_template pbackend ptemp 6034eaae44dSAndrew ThompsonThis function will return the currently selected global USB device 6044eaae44dSAndrew Thompsonside mode template into the integer pointer 6054eaae44dSAndrew Thompson.Fa ptemp . 6064eaae44dSAndrew ThompsonThis function returns zero on success else a LIBUSB20_ERROR value is 6074eaae44dSAndrew Thompsonreturned. 6084eaae44dSAndrew Thompson. 6094eaae44dSAndrew Thompson.Pp 6104eaae44dSAndrew Thompson. 6114eaae44dSAndrew Thompson.Fn libusb20_be_set_template pbackend temp 6124eaae44dSAndrew ThompsonThis function will set the global USB device side mode template to 6134eaae44dSAndrew Thompson.Fa temp . 6144eaae44dSAndrew ThompsonThe new template is not activated until after the next USB 6154eaae44dSAndrew Thompsonenumeration. 6164eaae44dSAndrew ThompsonThe template number decides how the USB device will present itself to 6174eaae44dSAndrew Thompsonthe USB Host, like Mass Storage Device, USB Ethernet Device. Also see 6184eaae44dSAndrew Thompsonthe 6194eaae44dSAndrew Thompson.Xr usb2_template 4 6204eaae44dSAndrew Thompsonmodule. 6214eaae44dSAndrew ThompsonThis function returns zero on success else a LIBUSB20_ERROR value is 6224eaae44dSAndrew Thompsonreturned. 6234eaae44dSAndrew Thompson. 6244eaae44dSAndrew Thompson.Pp 6254eaae44dSAndrew Thompson. 6264eaae44dSAndrew Thompson.Fn libusb20_be_get_dev_quirk pbackend index pquirk 6274eaae44dSAndrew ThompsonThis function will return the device quirk according to 6284eaae44dSAndrew Thompson.Fa index 6294eaae44dSAndrew Thompsoninto the libusb20_quirk structure pointed to by 6304eaae44dSAndrew Thompson.Fa pq . 6314eaae44dSAndrew ThompsonThis function returns zero on success else a LIBUSB20_ERROR value is 6324eaae44dSAndrew Thompsonreturned. 6334eaae44dSAndrew Thompson. 6344eaae44dSAndrew ThompsonIf the given quirk does not exist LIBUSB20_ERROR_NOT_FOUND is 6354eaae44dSAndrew Thompsonreturned. 6364eaae44dSAndrew Thompson. 6374eaae44dSAndrew Thompson.Pp 6384eaae44dSAndrew Thompson. 6394eaae44dSAndrew Thompson.Fn libusb20_be_get_quirk_name pbackend index pquirk 6404eaae44dSAndrew ThompsonThis function will return the quirk name according to 6414eaae44dSAndrew Thompson.Fa index 6424eaae44dSAndrew Thompsoninto the libusb20_quirk structure pointed to by 6434eaae44dSAndrew Thompson.Fa pq . 6444eaae44dSAndrew ThompsonThis function returns zero on success else a LIBUSB20_ERROR value is 6454eaae44dSAndrew Thompsonreturned. 6464eaae44dSAndrew Thompson. 6474eaae44dSAndrew ThompsonIf the given quirk does not exist LIBUSB20_ERROR_NOT_FOUND is 6484eaae44dSAndrew Thompsonreturned. 6494eaae44dSAndrew Thompson. 6504eaae44dSAndrew Thompson.Pp 6514eaae44dSAndrew Thompson. 6524eaae44dSAndrew Thompson.Fn libusb20_be_add_dev_quirk pbackend pquirk 6534eaae44dSAndrew ThompsonThis function will add the libusb20_quirk structure pointed to by the 6544eaae44dSAndrew Thompson.Fa pq 6554eaae44dSAndrew Thompsonargument into the device quirk list. 6564eaae44dSAndrew Thompson. 6574eaae44dSAndrew ThompsonThis function returns zero on success else a LIBUSB20_ERROR value is 6584eaae44dSAndrew Thompsonreturned. 6594eaae44dSAndrew Thompson. 6604eaae44dSAndrew ThompsonIf the given quirk cannot be added LIBUSB20_ERROR_NO_MEM is 6614eaae44dSAndrew Thompsonreturned. 6624eaae44dSAndrew Thompson. 6634eaae44dSAndrew Thompson.Pp 6644eaae44dSAndrew Thompson. 6654eaae44dSAndrew Thompson.Fn libusb20_be_remove_dev_quirk pbackend pquirk 6664eaae44dSAndrew ThompsonThis function will remove the quirk matching the libusb20_quirk structure pointed to by the 6674eaae44dSAndrew Thompson.Fa pq 6684eaae44dSAndrew Thompsonargument from the device quirk list. 6694eaae44dSAndrew Thompson. 6704eaae44dSAndrew ThompsonThis function returns zero on success else a LIBUSB20_ERROR value is 6714eaae44dSAndrew Thompsonreturned. 6724eaae44dSAndrew Thompson. 6734eaae44dSAndrew ThompsonIf the given quirk does not exist LIBUSB20_ERROR_NOT_FOUND is 6744eaae44dSAndrew Thompsonreturned. 6754eaae44dSAndrew Thompson. 6764eaae44dSAndrew Thompson.Fn libusb20_be_alloc_linux void 6774eaae44dSAndrew ThompsonThese functions are used to allocate a specific USB backend or the 6784eaae44dSAndrew Thompsonoperating system default USB backend. Allocating a backend is a way to 6794eaae44dSAndrew Thompsonscan for currently present USB devices. 6804eaae44dSAndrew Thompson. 6814eaae44dSAndrew Thompson.Pp 6824eaae44dSAndrew Thompson. 6834eaae44dSAndrew Thompson.Fn libusb20_be_device_foreach pbackend pdev 6844eaae44dSAndrew ThompsonThis function is used to iterate USB devices present in a USB backend. 6854eaae44dSAndrew Thompson. 6864eaae44dSAndrew ThompsonThe starting value of 6874eaae44dSAndrew Thompson.Fa pdev 6884eaae44dSAndrew Thompsonis NULL. 6894eaae44dSAndrew Thompson. 6904eaae44dSAndrew ThompsonThis function returns the next USB device in the list. 6914eaae44dSAndrew Thompson. 6924eaae44dSAndrew ThompsonIf NULL is returned the end of the USB device list has been reached. 6934eaae44dSAndrew Thompson. 6944eaae44dSAndrew Thompson.Pp 6954eaae44dSAndrew Thompson. 6964eaae44dSAndrew Thompson.Fn libusb20_be_dequeue_device pbackend pdev 6974eaae44dSAndrew ThompsonThis function will dequeue the given USB device pointer from the 6984eaae44dSAndrew Thompsonbackend USB device list. 6994eaae44dSAndrew Thompson. 7004eaae44dSAndrew ThompsonDequeued USB devices will not be freed when the backend is freed. 7014eaae44dSAndrew Thompson. 7024eaae44dSAndrew Thompson.Pp 7034eaae44dSAndrew Thompson. 7044eaae44dSAndrew Thompson.Fn libusb20_be_enqueue_device pbackend pdev 7054eaae44dSAndrew ThompsonThis function will enqueue the given USB device pointer in the backend USB device list. 7064eaae44dSAndrew Thompson. 7074eaae44dSAndrew ThompsonEnqueued USB devices will get freed when the backend is freed. 7084eaae44dSAndrew Thompson. 7094eaae44dSAndrew Thompson.Pp 7104eaae44dSAndrew Thompson. 7114eaae44dSAndrew Thompson.Fn libusb20_be_free pbackend 7124eaae44dSAndrew ThompsonThis function will free the given backend and all USB devices in its device list. 7134eaae44dSAndrew Thompson. 7144eaae44dSAndrew Thompson. 7154eaae44dSAndrew Thompson.Sh USB DESCRIPTOR PARSING 7164eaae44dSAndrew Thompson. 7174eaae44dSAndrew Thompson.Fn libusb20_me_get_1 pie offset 7184eaae44dSAndrew ThompsonThis function will return a byte at the given byte offset of a message 7194eaae44dSAndrew Thompsonentity. 7204eaae44dSAndrew Thompson. 7214eaae44dSAndrew ThompsonThis function is safe against invalid offsets. 7224eaae44dSAndrew Thompson. 7234eaae44dSAndrew Thompson.Pp 7244eaae44dSAndrew Thompson. 7254eaae44dSAndrew Thompson.Fn libusb20_me_get_2 pie offset 7264eaae44dSAndrew ThompsonThis function will return a little endian 16-bit value at the given byte offset of a message 7274eaae44dSAndrew Thompsonentity. 7284eaae44dSAndrew Thompson. 7294eaae44dSAndrew ThompsonThis function is safe against invalid offsets. 7304eaae44dSAndrew Thompson. 7314eaae44dSAndrew Thompson.Pp 7324eaae44dSAndrew Thompson. 7334eaae44dSAndrew Thompson.Fn libusb20_me_encode pbuf len pdecoded 7344eaae44dSAndrew ThompsonThis function will encode a so-called *DECODED structure into binary 7354eaae44dSAndrew Thompsonformat. 7364eaae44dSAndrew Thompson. 7374eaae44dSAndrew ThompsonThe total encoded length that will fit in the given buffer is 7384eaae44dSAndrew Thompsonreturned. 7394eaae44dSAndrew Thompson. 7404eaae44dSAndrew ThompsonIf the buffer pointer is NULL no data will be written to the buffer 7414eaae44dSAndrew Thompsonlocation. 7424eaae44dSAndrew Thompson. 7434eaae44dSAndrew Thompson.Pp 7444eaae44dSAndrew Thompson. 7454eaae44dSAndrew Thompson.Fn libusb20_me_decode pbuf len pdecoded 7464eaae44dSAndrew ThompsonThis function will decode a binary structure into a so-called *DECODED 7474eaae44dSAndrew Thompsonstructure. 7484eaae44dSAndrew Thompson. 7494eaae44dSAndrew ThompsonThe total decoded length is returned. 7504eaae44dSAndrew Thompson. 7514eaae44dSAndrew ThompsonThe buffer pointer cannot be NULL. 7524eaae44dSAndrew Thompson. 7534eaae44dSAndrew Thompson. 7544eaae44dSAndrew Thompson.Sh LIBUSB VERSION 0.1 COMPATIBILITY 7554eaae44dSAndrew Thompson. 7564eaae44dSAndrew Thompson.Fn usb_open 7574eaae44dSAndrew Thompson.Fn usb_close 7584eaae44dSAndrew Thompson.Fn usb_get_string 7594eaae44dSAndrew Thompson.Fn usb_get_string_simple 7604eaae44dSAndrew Thompson.Fn usb_get_descriptor_by_endpoint 7614eaae44dSAndrew Thompson.Fn usb_get_descriptor 7624eaae44dSAndrew Thompson.Fn usb_parse_descriptor 7634eaae44dSAndrew Thompson.Fn usb_parse_configuration 7644eaae44dSAndrew Thompson.Fn usb_destroy_configuration 7654eaae44dSAndrew Thompson.Fn usb_fetch_and_parse_descriptors 7664eaae44dSAndrew Thompson.Fn usb_bulk_write 7674eaae44dSAndrew Thompson.Fn usb_bulk_read 7684eaae44dSAndrew Thompson.Fn usb_interrupt_write 7694eaae44dSAndrew Thompson.Fn usb_interrupt_read 7704eaae44dSAndrew Thompson.Fn usb_control_msg 7714eaae44dSAndrew Thompson.Fn usb_set_configuration 7724eaae44dSAndrew Thompson.Fn usb_claim_interface 7734eaae44dSAndrew Thompson.Fn usb_release_interface 7744eaae44dSAndrew Thompson.Fn usb_set_altinterface 7754eaae44dSAndrew Thompson.Fn usb_resetep 7764eaae44dSAndrew Thompson.Fn usb_clear_halt 7774eaae44dSAndrew Thompson.Fn usb_reset 7784eaae44dSAndrew Thompson.Fn usb_strerror 7794eaae44dSAndrew Thompson.Fn usb_init 7804eaae44dSAndrew Thompson.Fn usb_set_debug 7814eaae44dSAndrew Thompson.Fn usb_find_busses 7824eaae44dSAndrew Thompson.Fn usb_find_devices 7834eaae44dSAndrew Thompson.Fn usb_device 7844eaae44dSAndrew Thompson.Fn usb_get_busses 7854eaae44dSAndrew ThompsonThese functions are compliant with LibUSB version 0.1.12. 7864eaae44dSAndrew Thompson. 7874eaae44dSAndrew Thompson.Sh FILES 7884eaae44dSAndrew Thompson. 7894eaae44dSAndrew Thompson. 7904eaae44dSAndrew Thompson/dev/usb 7914eaae44dSAndrew Thompson.Sh SEE ALSO 7924eaae44dSAndrew Thompson.Xr usb2_core 4 , 7934eaae44dSAndrew Thompson.Xr usbconfig 8 7944eaae44dSAndrew Thompson. 7954eaae44dSAndrew Thompson. 7964eaae44dSAndrew Thompson.Sh HISTORY 7974eaae44dSAndrew Thompson. 7984eaae44dSAndrew Thompson. 7994eaae44dSAndrew ThompsonSome parts of the 8004eaae44dSAndrew Thompson.Nm 8014eaae44dSAndrew ThompsonAPI derives from the libusb project at sourceforge. 802