2 .\" Copyright (c) 2008 Hans Petter Selasky
4 .\" All rights reserved.
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\" notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\" notice, this list of conditions and the following disclaimer in the
13 .\" documentation and/or other materials provided with the distribution.
15 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 .Nd "USB access library"
41 USB access library (libusb -lusb)
48 .Fn libusb20_tr_close "struct libusb20_transfer *xfer"
50 .Fn libusb20_tr_open "struct libusb20_transfer *xfer" "uint32_t max_buf_size" "uint32_t max_frame_count" "uint8_t ep_no"
51 .Ft struct libusb20_transfer*
52 .Fn libusb20_tr_get_pointer "struct libusb20_device *pdev" "uint16_t tr_index"
54 .Fn libusb20_tr_get_time_complete "struct libusb20_transfer *xfer"
56 .Fn libusb20_tr_get_actual_frames "struct libusb20_transfer *xfer"
58 .Fn libusb20_tr_get_actual_length "struct libusb20_transfer *xfer"
60 .Fn libusb20_tr_get_max_frames "struct libusb20_transfer *xfer"
62 .Fn libusb20_tr_get_max_packet_length "struct libusb20_transfer *xfer"
64 .Fn libusb20_tr_get_max_total_length "struct libusb20_transfer *xfer"
66 .Fn libusb20_tr_get_status "struct libusb20_transfer *xfer"
68 .Fn libusb20_tr_pending "struct libusb20_transfer *xfer"
70 .Fn libusb20_tr_callback_wrapper "struct libusb20_transfer *xfer"
72 .Fn libusb20_tr_clear_stall_sync "struct libusb20_transfer *xfer"
74 .Fn libusb20_tr_drain "struct libusb20_transfer *xfer"
76 .Fn libusb20_tr_set_buffer "struct libusb20_transfer *xfer" "void *buffer" "uint16_t fr_index"
78 .Fn libusb20_tr_set_callback "struct libusb20_transfer *xfer" "libusb20_tr_callback_t *cb"
80 .Fn libusb20_tr_set_flags "struct libusb20_transfer *xfer" "uint8_t flags"
82 .Fn libusb20_tr_get_length "struct libusb20_transfer *xfer" "uint16_t fr_index"
84 .Fn libusb20_tr_set_length "struct libusb20_transfer *xfer" "uint32_t length" "uint16_t fr_index"
86 .Fn libusb20_tr_set_priv_sc0 "struct libusb20_transfer *xfer" "void *sc0"
88 .Fn libusb20_tr_set_priv_sc1 "struct libusb20_transfer *xfer" "void *sc1"
90 .Fn libusb20_tr_set_timeout "struct libusb20_transfer *xfer" "uint32_t timeout"
92 .Fn libusb20_tr_set_total_frames "struct libusb20_transfer *xfer" "uint32_t nframes"
94 .Fn libusb20_tr_setup_bulk "struct libusb20_transfer *xfer" "void *pbuf" "uint32_t length" "uint32_t timeout"
96 .Fn libusb20_tr_setup_control "struct libusb20_transfer *xfer" "void *psetup" "void *pbuf" "uint32_t timeout"
98 .Fn libusb20_tr_setup_intr "struct libusb20_transfer *xfer" "void *pbuf" "uint32_t length" "uint32_t timeout"
100 .Fn libusb20_tr_setup_isoc "struct libusb20_transfer *xfer" "void *pbuf" "uint32_t length" "uint61_t fr_index"
102 .Fn libusb20_tr_bulk_intr_sync "struct libusb20_transfer *xfer" "void *pbuf" "uint32_t length" "uint32_t *pactlen" "uint32_t timeout"
104 .Fn libusb20_tr_start "struct libusb20_transfer *xfer"
106 .Fn libusb20_tr_stop "struct libusb20_transfer *xfer"
108 .Fn libusb20_tr_submit "struct libusb20_transfer *xfer"
110 .Fn libusb20_tr_get_priv_sc0 "struct libusb20_transfer *xfer"
112 .Fn libusb20_tr_get_priv_sc1 "struct libusb20_transfer *xfer"
114 .Fn libusb20_dev_get_backend_name "struct libusb20_device *"
116 .Fn libusb20_dev_get_info "struct libusb20_device *pdev" "struct usb_device_info *pinfo"
118 .Fn libusb20_dev_get_iface_desc "struct libusb20_device *pdev" "uint8_t iface_index" "char *buf" "uint8_t len"
120 .Fn libusb20_dev_get_desc "struct libusb20_device *pdev"
122 .Fn libusb20_dev_close "struct libusb20_device *pdev"
124 .Fn libusb20_dev_detach_kernel_driver "struct libusb20_device *pdev" "uint8_t iface_index"
126 .Fn libusb20_dev_set_config_index "struct libusb20_device *pdev" "uint8_t configIndex"
128 .Fn libusb20_dev_get_debug "struct libusb20_device *pdev"
130 .Fn libusb20_dev_get_fd "struct libusb20_device *pdev"
132 .Fn libusb20_dev_kernel_driver_active "struct libusb20_device *pdev" "uint8_t iface_index"
134 .Fn libusb20_dev_open "struct libusb20_device *pdev" "uint16_t transfer_max"
136 .Fn libusb20_dev_process "struct libusb20_device *pdev"
138 .Fn libusb20_dev_request_sync "struct libusb20_device *pdev" "struct LIBUSB20_CONTROL_SETUP_DECODED *setup" "void *data" "uint16_t *pactlen" "uint32_t timeout" "uint8_t flags"
140 .Fn libusb20_dev_req_string_sync "struct libusb20_device *pdev" "uint8_t index" "uint16_t langid" "void *ptr" "uint16_t len"
142 .Fn libusb20_dev_req_string_simple_sync "struct libusb20_device *pdev" "uint8_t index" "void *ptr" "uint16_t len"
144 .Fn libusb20_dev_reset "struct libusb20_device *pdev"
146 .Fn libusb20_dev_set_power_mode "struct libusb20_device *pdev" "uint8_t power_mode"
148 .Fn libusb20_dev_get_power_mode "struct libusb20_device *pdev"
150 .Fn libusb20_dev_set_alt_index "struct libusb20_device *pdev" "uint8_t iface_index" "uint8_t alt_index"
151 .Ft struct LIBUSB20_DEVICE_DESC_DECODED *
152 .Fn libusb20_dev_get_device_desc "struct libusb20_device *pdev"
153 .Ft struct libusb20_config *
154 .Fn libusb20_dev_alloc_config "struct libusb20_device *pdev" "uint8_t config_index"
155 .Ft struct libusb20_device *
156 .Fn libusb20_dev_alloc "void"
158 .Fn libusb20_dev_get_address "struct libusb20_device *pdev"
160 .Fn libusb20_dev_get_bus_number "struct libusb20_device *pdev"
162 .Fn libusb20_dev_get_mode "struct libusb20_device *pdev"
164 .Fn libusb20_dev_get_speed "struct libusb20_device *pdev"
166 .Fn libusb20_dev_get_config_index "struct libusb20_device *pdev"
168 .Fn libusb20_dev_free "struct libusb20_device *pdev"
170 .Fn libusb20_dev_set_debug "struct libusb20_device *pdev" "int debug"
172 .Fn libusb20_dev_wait_process "struct libusb20_device *pdev" "int timeout"
174 .Fn libusb20_be_get_template "struct libusb20_backend *pbe" "int *ptemp"
176 .Fn libusb20_be_set_template "struct libusb20_backend *pbe" "int temp"
178 .Fn libusb20_be_get_dev_quirk "struct libusb20_backend *pber", "uint16_t index" "struct libusb20_quirk *pq"
180 .Fn libusb20_be_get_quirk_name "struct libusb20_backend *pbe" "uint16_t index" "struct libusb20_quirk *pq"
182 .Fn libusb20_be_add_dev_quirk "struct libusb20_backend *pbe" "struct libusb20_quirk *pq"
184 .Fn libusb20_be_remove_dev_quirk "struct libusb20_backend *pbe" "struct libusb20_quirk *pq"
185 .Ft struct libusb20_backend *
186 .Fn libusb20_be_alloc_default "void"
187 .Ft struct libusb20_backend *
188 .Fn libusb20_be_alloc_freebsd "void"
189 .Ft struct libusb20_backend *
190 .Fn libusb20_be_alloc_linux "void"
191 .Ft struct libusb20_device *
192 .Fn libusb20_be_device_foreach "struct libusb20_backend *pbe" "struct libusb20_device *pdev"
194 .Fn libusb20_be_dequeue_device "struct libusb20_backend *pbe" "struct libusb20_device *pdev"
196 .Fn libusb20_be_enqueue_device "struct libusb20_backend *pbe" "struct libusb20_device *pdev"
198 .Fn libusb20_be_free "struct libusb20_backend *pbe"
200 .Fn libusb20_me_get_1 "const struct libusb20_me_struct *me" "uint16_t off"
202 .Fn libusb20_me_get_2 "const struct libusb20_me_struct *me" "uint16_t off"
204 .Fn libusb20_me_encode "void *pdata" "uint16_t len" "const void *pdecoded"
206 .Fn libusb20_me_decode "const void *pdata" "uint16_t len" "void *pdecoded"
207 .Ft "const uint8_t *"
208 .Fn libusb20_desc_foreach "const struct libusb20_me_struct *me" "const uint8_t *pdesc"
215 library implements functions to be able to easily access and control
216 USB through the USB file system interface.
219 interfaces are specific to the
221 usb stack and are not available on other operating systems, portable
222 applications should consider using
226 .Sh USB TRANSFER OPERATIONS
230 .Fn libusb20_tr_close
231 will release all kernel resources associated with an USB
234 This function returns zero upon success.
236 Non-zero return values indicate a LIBUSB20_ERROR value.
241 will allocate kernel buffer resources according to
245 associated with an USB
247 and bind the transfer to the specified
250 is the minimum buffer size which the data transport layer has to support.
255 library will use wMaxPacketSize to compute the buffer size.
256 This can be useful for isochronous transfers.
257 The actual buffer size can be greater than
260 .Fn libusb20_tr_get_max_total_length .
262 This function returns zero upon success.
264 Non-zero return values indicate a LIBUSB20_ERROR value.
268 .Fn libusb20_tr_get_pointer
269 will return a pointer to the allocated USB transfer according to the
275 This function returns NULL in case of failure.
279 .Fn libusb20_tr_get_time_complete
280 will return the completion time of an USB transfer in
281 millisecond units. This function is most useful for isochronous USB
282 transfers when doing echo cancelling.
286 .Fn libusb20_tr_get_actual_frames
287 will return the actual number of USB frames after an USB
288 transfer completed. A value of zero means that no data was transferred.
292 .Fn libusb20_tr_get_actual_length
293 will return the sum of the actual length for all
294 transferred USB frames for the given USB transfer.
298 .Fn libusb20_tr_get_max_frames
299 will return the maximum number of USB frames that were
300 allocated when an USB transfer was setup for the given USB transfer.
304 .Fn libusb20_tr_get_max_packet_length
305 will return the maximum packet length in bytes
306 associated with the given USB transfer.
308 The packet length can be used round up buffer sizes so that short USB
309 packets are avoided for proxy buffers.
314 .Fn libusb20_tr_get_max_total_length
315 function will return the maximum value for the data length sum of all USB
316 frames associated with an USB transfer.
317 In case of control transfers the value returned does not include the
318 length of the SETUP packet, 8 bytes, which is part of frame zero.
319 The returned value of this function is always aligned to the maximum
320 packet size, wMaxPacketSize, of the endpoint which the USB transfer is
325 .Fn libusb20_tr_get_status
326 will return the status of an USB transfer.
328 Status values are defined by a set of LIBUSB20_TRANSFER_XXX enums.
332 .Fn libusb20_tr_pending
333 will return non-zero if the given USB transfer is
334 pending for completion.
336 Else this function returns zero.
340 .Fn libusb20_tr_callback_wrapper
341 This is an internal function used to wrap asynchronous USB callbacks.
345 .Fn libusb20_tr_clear_stall_sync
346 This is an internal function used to synchronously clear the stall on
347 the given USB transfer.
349 Please see the USB specification for more information on stall
352 If the given USB transfer is pending when this function is called, the
353 USB transfer will complete with an error after that this function has
358 .Fn libusb20_tr_drain
359 will stop the given USB transfer and will not return
360 until the USB transfer has been stopped in hardware.
364 .Fn libusb20_tr_set_buffer
367 pointer for the given USB transfer and
370 Typically the frame index is zero.
375 .Fn libusb20_tr_set_callback
376 is used to set the USB callback for asynchronous USB
379 The callback type is defined by libusb20_tr_callback_t.
383 .Fn libusb20_tr_set_flags
384 is used to set various USB flags for the given USB transfer.
386 .It LIBUSB20_TRANSFER_SINGLE_SHORT_NOT_OK
387 Report a short frame as error.
388 .It LIBUSB20_TRANSFER_MULTI_SHORT_NOT_OK
389 Multiple short frames are not allowed.
390 .It LIBUSB20_TRANSFER_FORCE_SHORT
391 All transmitted frames are short terminated.
392 .It LIBUSB20_TRANSFER_DO_CLEAR_STALL
393 Will do a clear-stall before starting the transfer.
398 .Fn libusb20_tr_get_length
399 returns the length of the given USB frame by index.
400 After an USB transfer is complete the USB frame length will get updated to the actual transferred length.
404 .Fn libusb20_tr_set_length
405 sets the length of the given USB frame by index.
409 .Fn libusb20_tr_set_priv_sc0
410 sets private driver pointer number zero.
414 .Fn libusb20_tr_set_priv_sc1
415 sets private driver pointer number one.
419 .Fn libusb20_tr_set_timeout
420 sets the timeout for the given USB transfer.
422 A timeout value of zero means no timeout.
424 The timeout is given in milliseconds.
428 .Fn libusb20_tr_set_total_frames
429 sets the total number of frames that should be executed when the USB transfer is submitted.
431 The total number of USB frames must be less than the maximum number of USB frames associated with the given USB transfer.
435 .Fn libusb20_tr_setup_bulk
436 is a helper function for setting up a single frame USB BULK transfer.
440 .Fn libusb20_tr_setup_control
441 is a helper function for setting up a single or dual
442 frame USB CONTROL transfer depending on the control transfer length.
446 .Fn libusb20_tr_setup_intr
447 is a helper function for setting up a single frame USB INTERRUPT transfer.
451 .Fn libusb20_tr_setup_isoc
452 is a helper function for setting up a multi frame USB ISOCHRONOUS transfer.
456 .Fn libusb20_tr_bulk_intr_sync
457 will perform a synchronous BULK or INTERRUPT transfer having length given by the
459 argument and buffer pointer given by the
461 argument on the USB transfer given by the
467 argument is non-NULL the actual transfer length will be stored at the given pointer destination.
471 argument is non-zero the transfer will timeout after the given value in milliseconds.
473 This function does not change the transfer flags, like short packet not ok.
475 This function returns zero on success else a LIBUSB20_TRANSFER_XXX value is returned.
479 .Fn libusb20_tr_start
480 will get the USB transfer started, if not already
483 This function will not get the transfer queued in hardware.
485 This function is non-blocking.
490 will get the USB transfer stopped, if not already stopped.
492 This function is non-blocking, which means that the actual stop can
493 happen after the return of this function.
497 .Fn libusb20_tr_submit
498 will get the USB transfer queued in hardware.
503 .Fn libusb20_tr_get_priv_sc0
504 returns private driver pointer number zero associated
505 with an USB transfer.
510 .Fn libusb20_tr_get_priv_sc1
511 returns private driver pointer number one associated
512 with an USB transfer.
515 .Sh USB DEVICE OPERATIONS
519 .Fn libusb20_dev_get_backend_name
520 returns a zero terminated string describing the backend used.
524 .Fn libusb20_dev_get_info
525 retrives the BSD specific usb_device_info structure into the memory location given by
527 The USB device given by
529 must be opened before this function will succeed.
530 This function returns zero on success else a LIBUSB20_ERROR value is returned.
534 .Fn libusb20_dev_get_iface_desc
535 retrieves the kernel interface description for the given USB
537 The format of the USB interface description is: "drivername<unit>: <description>"
538 The description string is always zero terminated.
539 A zero length string is written in case no driver is attached to the given interface.
540 The USB device given by
542 must be opened before this function will succeed.
543 This function returns zero on success else a LIBUSB20_ERROR value is returned.
547 .Fn libusb20_dev_get_desc
548 returns a zero terminated string describing the given USB device.
549 The format of the string is: "drivername<unit>: <description>"
553 .Fn libusb20_dev_close
554 will close the given USB device.
556 This function returns zero on success else a LIBUSB20_ERROR value is
561 .Fn libusb20_dev_detach_kernel_driver
562 will try to detach the kernel driver for the USB interface given by
565 This function returns zero on success else a LIBUSB20_ERROR value is
570 .Fn libusb20_dev_set_config_index
571 will try to set the configuration index on an USB
574 The first configuration index is zero.
576 The un-configure index is 255.
578 This function returns zero on success else a LIBUSB20_ERROR value is returned.
582 .Fn libusb20_dev_get_debug
583 returns the debug level of an USB device.
587 .Fn libusb20_dev_get_fd
588 returns the file descriptor of the given USB device.
590 A negative value is returned when no file descriptor is present.
592 The file descriptor can be used for polling purposes.
596 .Fn libusb20_dev_kernel_driver_active
597 returns a non-zero value if a kernel driver is active on
598 the given USB interface.
600 Else zero is returned.
604 .Fn libusb20_dev_open
605 opens an USB device so that setting up USB transfers
608 The number of USB transfers can be zero which means only control
609 transfers are allowed.
611 This function returns zero on success else a LIBUSB20_ERROR value is
614 A return value of LIBUSB20_ERROR_BUSY means that the device is already
619 .Fn libusb20_dev_process
620 is called to sync kernel USB transfers with userland USB
623 This function returns zero on success else a LIBUSB20_ERROR value is
624 returned typically indicating that the given USB device has been
629 .Fn libusb20_dev_request_sync
630 will perform a synchronous control request on the given
633 Before this call will succeed the USB device must be opened.
636 is a pointer to a decoded and host endian SETUP packet.
638 is a pointer to a data transfer buffer associated with the control transaction. This argument can be NULL.
640 is a pointer to a variable that will hold the actual transfer length after the control transaction is complete.
642 is the transaction timeout given in milliseconds.
643 A timeout of zero means no timeout.
645 is used to specify transaction flags, for example LIBUSB20_TRANSFER_SINGLE_SHORT_NOT_OK.
647 This function returns zero on success else a LIBUSB20_ERROR value is
652 .Fn libusb20_dev_req_string_sync
653 will synchronously request an USB string by language ID
654 and string index into the given buffer limited by a maximum length.
656 This function returns zero on success else a LIBUSB20_ERROR value is
661 .Fn libusb20_dev_req_string_simple_sync
662 will synchronously request an USB string using the
663 default language ID and convert the string into ASCII before storing
664 the string into the given buffer limited by a maximum length which
665 includes the terminating zero.
667 This function returns zero on success else a LIBUSB20_ERROR value is
673 .Fn libusb20_dev_reset
674 will try to BUS reset the given USB device and restore
675 the last set USB configuration.
677 This function returns zero on success else a LIBUSB20_ERROR value is
682 .Fn libusb20_dev_set_power_mode
683 sets the power mode of the USB device.
687 .It LIBUSB20_POWER_OFF
688 .It LIBUSB20_POWER_ON
689 .It LIBUSB20_POWER_SAVE
690 .It LIBUSB20_POWER_SUSPEND
691 .It LIBUSB20_POWER_RESUME
694 This function returns zero on success else a LIBUSB20_ERROR value is
699 .Fn libusb20_dev_get_power_mode
700 returns the currently selected power mode for the given
705 .Fn libusb20_dev_set_alt_index
706 will try to set the given alternate index for the given
709 This function returns zero on success else a LIBUSB20_ERROR value is
714 .Fn libusb20_dev_get_device_desc
715 returns a pointer to the decoded and host endian version
716 of the device descriptor.
718 The USB device need not be opened when calling this function.
722 .Fn libusb20_dev_alloc_config
723 will read out and decode the USB config descriptor for
724 the given USB device and config index. This function returns a pointer
725 to the decoded configuration which must eventually be passed to
726 free(). NULL is returned in case of failure.
730 .Fn libusb20_dev_alloc
731 is an internal function to allocate a new USB device.
735 .Fn libusb20_dev_get_address
736 returns the internal and not necessarily the real
737 hardware address of the given USB device.
741 .Fn libusb20_dev_get_bus_number
742 returns the internal bus number which the given USB
747 .Fn libusb20_dev_get_mode
748 returns the current operation mode of the USB entity.
750 Valid return values are:
752 .It LIBUSB20_MODE_HOST
753 .It LIBUSB20_MODE_DEVICE
758 .Fn libusb20_dev_get_speed
759 returns the current speed of the given USB device.
762 .It LIBUSB20_SPEED_UNKNOWN
763 .It LIBUSB20_SPEED_LOW
764 .It LIBUSB20_SPEED_FULL
765 .It LIBUSB20_SPEED_HIGH
766 .It LIBUSB20_SPEED_VARIABLE
767 .It LIBUSB20_SPEED_SUPER
772 .Fn libusb20_dev_get_config_index
773 This function returns the currently select config index for the given
778 .Fn libusb20_dev_free
779 will free the given USB device and all associated USB
784 .Fn libusb20_dev_set_debug
785 will set the debug level for the given USB device.
789 .Fn libusb20_dev_wait_process
790 function will wait until a pending USB transfer has completed on
791 the given USB device.
793 A timeout value can be specified which is passed on to the
797 .Sh USB BACKEND OPERATIONS
799 .Fn libusb20_be_get_template
800 will return the currently selected global USB device
801 side mode template into the integer pointer
803 This function returns zero on success else a LIBUSB20_ERROR value is
808 .Fn libusb20_be_set_template
809 will set the global USB device side mode template to
811 The new template is not activated until after the next USB
813 The template number decides how the USB device will present itself to
814 the USB Host, like Mass Storage Device, USB Ethernet Device. Also see
818 This function returns zero on success else a LIBUSB20_ERROR value is
823 .Fn libusb20_be_get_dev_quirk
824 This function will return the device quirk according to
826 into the libusb20_quirk structure pointed to by
828 This function returns zero on success else a LIBUSB20_ERROR value is
831 If the given quirk does not exist LIBUSB20_ERROR_NOT_FOUND is
836 .Fn libusb20_be_get_quirk_name
837 will return the quirk name according to
839 into the libusb20_quirk structure pointed to by
841 This function returns zero on success else a LIBUSB20_ERROR value is
844 If the given quirk does not exist LIBUSB20_ERROR_NOT_FOUND is
849 .Fn libusb20_be_add_dev_quirk
850 will add the libusb20_quirk structure pointed to by the
852 argument into the device quirk list.
854 This function returns zero on success else a LIBUSB20_ERROR value is
857 If the given quirk cannot be added LIBUSB20_ERROR_NO_MEM is
862 .Fn libusb20_be_remove_dev_quirk
863 will remove the quirk matching the libusb20_quirk structure pointed to by the
865 argument from the device quirk list.
867 This function returns zero on success else a LIBUSB20_ERROR value is
870 If the given quirk does not exist LIBUSB20_ERROR_NOT_FOUND is
875 .Fn libusb20_be_alloc_default
876 .Fn libusb20_be_alloc_freebsd
877 .Fn libusb20_be_alloc_linux
878 These functions are used to allocate a specific USB backend or the
879 operating system default USB backend. Allocating a backend is a way to
880 scan for currently present USB devices.
884 .Fn libusb20_be_device_foreach
885 is used to iterate USB devices present in a USB backend.
887 The starting value of
891 This function returns the next USB device in the list.
893 If NULL is returned the end of the USB device list has been reached.
897 .Fn libusb20_be_dequeue_device
898 will dequeue the given USB device pointer from the
899 backend USB device list.
901 Dequeued USB devices will not be freed when the backend is freed.
905 .Fn libusb20_be_enqueue_device
906 This function will enqueue the given USB device pointer in the backend USB device list.
908 Enqueued USB devices will get freed when the backend is freed.
913 will free the given backend and all USB devices in its device list.
916 .Sh USB DESCRIPTOR PARSING
918 .Fn libusb20_me_get_1 pie offset
919 This function will return a byte at the given byte offset of a message
922 This function is safe against invalid offsets.
926 .Fn libusb20_me_get_2 pie offset
927 This function will return a little endian 16-bit value at the given byte offset of a message
930 This function is safe against invalid offsets.
934 .Fn libusb20_me_encode pbuf len pdecoded
935 This function will encode a so-called *DECODED structure into binary
938 The total encoded length that will fit in the given buffer is
941 If the buffer pointer is NULL no data will be written to the buffer
946 .Fn libusb20_me_decode pbuf len pdecoded
947 This function will decode a binary structure into a so-called *DECODED
950 The total decoded length is returned.
952 The buffer pointer cannot be NULL.
970 API derives from the libusb project at sourceforge.