Changeset View
Changeset View
Standalone View
Standalone View
lib/libusb/libusb.3
Show All 20 Lines | |||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||||
.\" SUCH DAMAGE. | .\" SUCH DAMAGE. | ||||
.\" | .\" | ||||
.\" $FreeBSD$ | .\" $FreeBSD$ | ||||
.\" | .\" | ||||
.Dd June 23, 2016 | .Dd October 11, 2018 | ||||
.Dt LIBUSB 3 | .Dt LIBUSB 3 | ||||
.Os | .Os | ||||
.Sh NAME | .Sh NAME | ||||
.Nm libusb | .Nm libusb | ||||
.Nd "USB access library" | .Nd "USB access library" | ||||
.Sh LIBRARY | .Sh LIBRARY | ||||
USB access library | USB access library | ||||
.Pq libusb, -lusb | .Pq libusb, -lusb | ||||
▲ Show 20 Lines • Show All 287 Lines • ▼ Show 20 Lines | |||||
Returns 0 on | Returns 0 on | ||||
success, LIBUSB_ERROR_NOT_FOUND if the device is in | success, LIBUSB_ERROR_NOT_FOUND if the device is in | ||||
an unconfigured state | an unconfigured state | ||||
and a LIBUSB_ERROR code on error. | and a LIBUSB_ERROR code on error. | ||||
.Pp | .Pp | ||||
.Ft int | .Ft int | ||||
.Fn libusb_get_config_descriptor "libusb_device *dev" "uint8_t config_index" "libusb_config_descriptor **config" | .Fn libusb_get_config_descriptor "libusb_device *dev" "uint8_t config_index" "libusb_config_descriptor **config" | ||||
Get a USB configuration descriptor based on its index | Get a USB configuration descriptor based on its index | ||||
.Fa idx. | .Fa idx . | ||||
Returns 0 on success, LIBUSB_ERROR_NOT_FOUND if the configuration does not exist | Returns 0 on success, LIBUSB_ERROR_NOT_FOUND if the configuration does not exist | ||||
and a LIBUSB_ERROR code on error. | and a LIBUSB_ERROR code on error. | ||||
.Pp | .Pp | ||||
.Ft int | .Ft int | ||||
.Fn libusb_get_config_descriptor_by_value "libusb_device *dev" "uint8 bConfigurationValue" "libusb_config_descriptor **config" | .Fn libusb_get_config_descriptor_by_value "libusb_device *dev" "uint8 bConfigurationValue" "libusb_config_descriptor **config" | ||||
Get a USB configuration descriptor with a specific bConfigurationValue. | Get a USB configuration descriptor with a specific bConfigurationValue. | ||||
This is | This is | ||||
a non-blocking function which does not send a request through the device. | a non-blocking function which does not send a request through the device. | ||||
▲ Show 20 Lines • Show All 234 Lines • ▼ Show 20 Lines | |||||
Returns 1 if there is a thread handling events and 0 if there | Returns 1 if there is a thread handling events and 0 if there | ||||
are no threads currently handling events. | are no threads currently handling events. | ||||
.Pp | .Pp | ||||
.Ft void | .Ft void | ||||
.Fn libusb_lock_event_waiters "libusb_context *ctx" | .Fn libusb_lock_event_waiters "libusb_context *ctx" | ||||
Acquire the event_waiters lock. | Acquire the event_waiters lock. | ||||
This lock is designed to be obtained in the | This lock is designed to be obtained in the | ||||
situation where you want to be aware when events are completed, but some other | situation where you want to be aware when events are completed, but some other | ||||
thread is event handling so calling libusb_handle_events() is not allowed. | thread is event handling so calling | ||||
.Fn libusb_handle_events | |||||
is not allowed. | |||||
.Pp | .Pp | ||||
.Ft void | .Ft void | ||||
.Fn libusb_unlock_event_waiters "libusb_context *ctx" | .Fn libusb_unlock_event_waiters "libusb_context *ctx" | ||||
Release the event_waiters lock. | Release the event_waiters lock. | ||||
.Pp | .Pp | ||||
.Ft int | .Ft int | ||||
.Fn libusb_wait_for_event "libusb_context *ctx" "struct timeval *tv" | .Fn libusb_wait_for_event "libusb_context *ctx" "struct timeval *tv" | ||||
Wait for another thread to signal completion of an event. | Wait for another thread to signal completion of an event. | ||||
Must be called | Must be called | ||||
with the event waiters lock held, see libusb_lock_event_waiters(). | with the event waiters lock held, see | ||||
.Fn libusb_lock_event_waiters . | |||||
This will | This will | ||||
block until the timeout expires or a transfer completes or a thread releases | block until the timeout expires or a transfer completes or a thread releases | ||||
the event handling lock through libusb_unlock_events(). | the event handling lock through | ||||
.Fn libusb_unlock_events . | |||||
Returns 0 after a | Returns 0 after a | ||||
transfer completes or another thread stops event handling, and 1 if the | transfer completes or another thread stops event handling, and 1 if the | ||||
timeout expired. | timeout expired. | ||||
.Pp | .Pp | ||||
.Ft int | .Ft int | ||||
.Fn libusb_handle_events_timeout_completed "libusb_context *ctx" "struct timeval *tv" "int *completed" | .Fn libusb_handle_events_timeout_completed "libusb_context *ctx" "struct timeval *tv" "int *completed" | ||||
Handle any pending events by checking if timeouts have expired and by | Handle any pending events by checking if timeouts have expired and by | ||||
checking the set of file descriptors for activity. | checking the set of file descriptors for activity. | ||||
▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | |||||
.Ft void | .Ft void | ||||
.Fn libusb_set_pollfd_notifiers "libusb_context *ctx" "libusb_pollfd_added_cb added_cb" "libusb_pollfd_removed_cb remove_cb" "void *user_data" | .Fn libusb_set_pollfd_notifiers "libusb_context *ctx" "libusb_pollfd_added_cb added_cb" "libusb_pollfd_removed_cb remove_cb" "void *user_data" | ||||
Register notification functions for file descriptor additions/removals. | Register notification functions for file descriptor additions/removals. | ||||
These functions will be invoked for every new or removed file descriptor | These functions will be invoked for every new or removed file descriptor | ||||
that libusb uses as an event source. | that libusb uses as an event source. | ||||
.Pp | .Pp | ||||
.Ft const struct libusb_pollfd ** | .Ft const struct libusb_pollfd ** | ||||
.Fn libusb_get_pollfds "libusb_context *ctx" | .Fn libusb_get_pollfds "libusb_context *ctx" | ||||
Retrive a list of file descriptors that should be polled by your main loop as | Retrieve a list of file descriptors that should be polled by your main loop as | ||||
libusb event sources. | libusb event sources. | ||||
Returns a NULL-terminated list on success or NULL on failure. | Returns a NULL-terminated list on success or NULL on failure. | ||||
.Pp | .Pp | ||||
.Ft int | .Ft int | ||||
.Fn libusb_hotplug_register_callback "libusb_context *ctx" "libusb_hotplug_event events" "libusb_hotplug_flag flags" "int vendor_id" "int product_id" "int dev_class" "libusb_hotplug_callback_fn cb_fn" "void *user_data" "libusb_hotplug_callback_handle *handle" | .Fn libusb_hotplug_register_callback "libusb_context *ctx" "libusb_hotplug_event events" "libusb_hotplug_flag flags" "int vendor_id" "int product_id" "int dev_class" "libusb_hotplug_callback_fn cb_fn" "void *user_data" "libusb_hotplug_callback_handle *handle" | ||||
This function registers a hotplug filter. | This function registers a hotplug filter. | ||||
The | The | ||||
.Fa events | .Fa events | ||||
▲ Show 20 Lines • Show All 68 Lines • ▼ Show 20 Lines | |||||
.Fn usb_get_driver_np | .Fn usb_get_driver_np | ||||
.Fn usb_detach_kernel_driver_np | .Fn usb_detach_kernel_driver_np | ||||
.Sh SEE ALSO | .Sh SEE ALSO | ||||
.Xr libusb20 3 , | .Xr libusb20 3 , | ||||
.Xr usb 4 , | .Xr usb 4 , | ||||
.Xr usbconfig 8 , | .Xr usbconfig 8 , | ||||
.Xr usbdump 8 | .Xr usbdump 8 | ||||
.Pp | .Pp | ||||
.Pa http://libusb.sourceforge.net/ | .Lk https://libusb.info/ | ||||
.Sh HISTORY | .Sh HISTORY | ||||
.Nm | .Nm | ||||
support first appeared in | support first appeared in | ||||
.Fx 8.0 . | .Fx 8.0 . |