libusb.3 (867099fa10ec5cb8a004ceac8d512a30912e3a04) | libusb.3 (d284271a53574ffb0eb7581528bcebfb1a997e66) |
---|---|
1.\" 2.\" Copyright (c) 2009 Sylvestre Gallon 3.\" 4.\" All rights reserved. 5.\" 6.\" Redistribution and use in source and binary forms, with or without 7.\" modification, are permitted provided that the following conditions 8.\" are met: --- 29 unchanged lines hidden (view full) --- 38.Sh SYNOPSIS 39.In libusb.h 40.Sh DESCRIPTION 41The 42.Nm 43library contains interfaces for directly managing a usb device. 44The current implementation supports v1.0 of the libusb API. 45.Sh LIBRARY INITIALISATION / DEINITIALISATION | 1.\" 2.\" Copyright (c) 2009 Sylvestre Gallon 3.\" 4.\" All rights reserved. 5.\" 6.\" Redistribution and use in source and binary forms, with or without 7.\" modification, are permitted provided that the following conditions 8.\" are met: --- 29 unchanged lines hidden (view full) --- 38.Sh SYNOPSIS 39.In libusb.h 40.Sh DESCRIPTION 41The 42.Nm 43library contains interfaces for directly managing a usb device. 44The current implementation supports v1.0 of the libusb API. 45.Sh LIBRARY INITIALISATION / DEINITIALISATION |
46.Pp | |
47.Ft int 48.Fn libusb_init libusb_context **ctx 49This function initialises libusb. 50It must be called at the beginning 51of the program, before other libusb routines are used. 52This function returns 0 on success or LIBUSB_ERROR on 53failure. 54.Pp --- 210 unchanged lines hidden (view full) --- 265.Fn libusb_attach_kernel_driver "libusb_device_handle *devh" "int interface" 266Re-attach an interface kernel driver that was previously detached. 267Returns 0 on success, 268LIBUSB_ERROR_INVALID_PARAM if the interface does not exist, 269LIBUSB_ERROR_NO_DEVICE 270if the device has been disconnected, LIBUSB_ERROR_BUSY if the driver cannot be 271attached because the interface is claimed by a program or driver and a 272LIBUSB_ERROR code on failure. | 46.Ft int 47.Fn libusb_init libusb_context **ctx 48This function initialises libusb. 49It must be called at the beginning 50of the program, before other libusb routines are used. 51This function returns 0 on success or LIBUSB_ERROR on 52failure. 53.Pp --- 210 unchanged lines hidden (view full) --- 264.Fn libusb_attach_kernel_driver "libusb_device_handle *devh" "int interface" 265Re-attach an interface kernel driver that was previously detached. 266Returns 0 on success, 267LIBUSB_ERROR_INVALID_PARAM if the interface does not exist, 268LIBUSB_ERROR_NO_DEVICE 269if the device has been disconnected, LIBUSB_ERROR_BUSY if the driver cannot be 270attached because the interface is claimed by a program or driver and a 271LIBUSB_ERROR code on failure. |
273.Pp | |
274.Sh USB DESCRIPTORS | 272.Sh USB DESCRIPTORS |
275.Pp | |
276.Ft int 277.Fn libusb_get_device_descriptor "libusb_device *dev" "libusb_device_descriptor *desc" 278Get the USB device descriptor for the device 279.Fa dev. 280This is a non-blocking function. 281Returns 0 on success and a LIBUSB_ERROR code on 282failure. 283.Pp --- 60 unchanged lines hidden (view full) --- 344.Fa bos. 345Returns zero on success and a LIBUSB_ERROR code on failure. 346On success the parsed BOS descriptor must be freed using the 347libusb_free_bos_descriptor function. 348.Pp 349.Ft void 350.Fn libusb_free_bos_descriptor "libusb_bos_descriptor *bos" 351This function is NULL safe and frees a parsed BOS descriptor. | 273.Ft int 274.Fn libusb_get_device_descriptor "libusb_device *dev" "libusb_device_descriptor *desc" 275Get the USB device descriptor for the device 276.Fa dev. 277This is a non-blocking function. 278Returns 0 on success and a LIBUSB_ERROR code on 279failure. 280.Pp --- 60 unchanged lines hidden (view full) --- 341.Fa bos. 342Returns zero on success and a LIBUSB_ERROR code on failure. 343On success the parsed BOS descriptor must be freed using the 344libusb_free_bos_descriptor function. 345.Pp 346.Ft void 347.Fn libusb_free_bos_descriptor "libusb_bos_descriptor *bos" 348This function is NULL safe and frees a parsed BOS descriptor. |
352.Pp | |
353.Sh USB ASYNCHRONOUS I/O | 349.Sh USB ASYNCHRONOUS I/O |
354.Pp | |
355.Ft struct libusb_transfer * 356.Fn libusb_alloc_transfer "int iso_packets" 357Allocate a transfer with the number of isochronous packet descriptors 358specified by 359.Fa iso_packets . 360Returns NULL on error. 361.Pp 362.Ft void --- 6 unchanged lines hidden (view full) --- 369Returns 0 on success, LIBUSB_ERROR_NO_DEVICE if 370the device has been disconnected and a 371LIBUSB_ERROR code on other failure. 372.Pp 373.Ft int 374.Fn libusb_cancel_transfer "struct libusb_transfer *tr" 375This function asynchronously cancels a transfer. 376Returns 0 on success and a LIBUSB_ERROR code on failure. | 350.Ft struct libusb_transfer * 351.Fn libusb_alloc_transfer "int iso_packets" 352Allocate a transfer with the number of isochronous packet descriptors 353specified by 354.Fa iso_packets . 355Returns NULL on error. 356.Pp 357.Ft void --- 6 unchanged lines hidden (view full) --- 364Returns 0 on success, LIBUSB_ERROR_NO_DEVICE if 365the device has been disconnected and a 366LIBUSB_ERROR code on other failure. 367.Pp 368.Ft int 369.Fn libusb_cancel_transfer "struct libusb_transfer *tr" 370This function asynchronously cancels a transfer. 371Returns 0 on success and a LIBUSB_ERROR code on failure. |
377.Pp | |
378.Sh USB SYNCHRONOUS I/O | 372.Sh USB SYNCHRONOUS I/O |
379.Pp | |
380.Ft int 381.Fn libusb_control_transfer "libusb_device_handle *devh" "uint8_t bmRequestType" "uint8_t bRequest" "uint16_t wValue" "uint16_t wIndex" "unsigned char *data" "uint16_t wLength" "unsigned int timeout" 382Perform a USB control transfer. 383Returns the actual number of bytes 384transferred on success, in the range from and including zero up to and 385including 386.Fa wLength . 387On error a LIBUSB_ERROR code is returned, for example --- 18 unchanged lines hidden (view full) --- 406Perform an USB Interrupt transfer. 407A timeout value of zero means no timeout. 408The timeout value is given in milliseconds. 409Returns 0 on success, LIBUSB_ERROR_TIMEOUT 410if the transfer timed out, LIBUSB_ERROR_PIPE if the control request was not 411supported, LIBUSB_ERROR_OVERFLOW if the device offered more data, 412LIBUSB_ERROR_NO_DEVICE if the device has been disconnected and 413a LIBUSB_ERROR code on other failure. | 373.Ft int 374.Fn libusb_control_transfer "libusb_device_handle *devh" "uint8_t bmRequestType" "uint8_t bRequest" "uint16_t wValue" "uint16_t wIndex" "unsigned char *data" "uint16_t wLength" "unsigned int timeout" 375Perform a USB control transfer. 376Returns the actual number of bytes 377transferred on success, in the range from and including zero up to and 378including 379.Fa wLength . 380On error a LIBUSB_ERROR code is returned, for example --- 18 unchanged lines hidden (view full) --- 399Perform an USB Interrupt transfer. 400A timeout value of zero means no timeout. 401The timeout value is given in milliseconds. 402Returns 0 on success, LIBUSB_ERROR_TIMEOUT 403if the transfer timed out, LIBUSB_ERROR_PIPE if the control request was not 404supported, LIBUSB_ERROR_OVERFLOW if the device offered more data, 405LIBUSB_ERROR_NO_DEVICE if the device has been disconnected and 406a LIBUSB_ERROR code on other failure. |
414.Pp | |
415.Sh USB EVENTS | 407.Sh USB EVENTS |
416.Pp | |
417.Ft int 418.Fn libusb_try_lock_events "libusb_context *ctx" 419Try to acquire the event handling lock. 420Returns 0 if the lock was obtained and 1 if not. 421.Pp 422.Ft void 423.Fn libusb_lock_events "libusb_context *ctx" 424Acquire the event handling lock. 425This function is blocking. 426.Pp 427.Ft void 428.Fn libusb_unlock_events "libusb_context *ctx" 429Release the event handling lock. 430This will wake up any thread blocked 431on | 408.Ft int 409.Fn libusb_try_lock_events "libusb_context *ctx" 410Try to acquire the event handling lock. 411Returns 0 if the lock was obtained and 1 if not. 412.Pp 413.Ft void 414.Fn libusb_lock_events "libusb_context *ctx" 415Acquire the event handling lock. 416This function is blocking. 417.Pp 418.Ft void 419.Fn libusb_unlock_events "libusb_context *ctx" 420Release the event handling lock. 421This will wake up any thread blocked 422on |
432.B libusb_wait_for_event() . | 423.Fn libusb_wait_for_event . |
433.Pp 434.Ft int 435.Fn libusb_event_handling_ok "libusb_context *ctx" 436Determine if it still OK for this thread to be doing event handling. 437Returns 1 438if event handling can start or continue. 439Returns 0 if this thread must give up 440the events lock. --- 60 unchanged lines hidden (view full) --- 501that libusb uses as an event source. 502.Pp 503.Ft const struct libusb_pollfd ** 504.Fn libusb_get_pollfds "libusb_context *ctx" 505Retrive a list of file descriptors that should be polled by your main loop as 506libusb event sources. 507Returns a NULL-terminated list on success or NULL on failure. 508.Sh LIBUSB VERSION 0.1 COMPATIBILITY | 424.Pp 425.Ft int 426.Fn libusb_event_handling_ok "libusb_context *ctx" 427Determine if it still OK for this thread to be doing event handling. 428Returns 1 429if event handling can start or continue. 430Returns 0 if this thread must give up 431the events lock. --- 60 unchanged lines hidden (view full) --- 492that libusb uses as an event source. 493.Pp 494.Ft const struct libusb_pollfd ** 495.Fn libusb_get_pollfds "libusb_context *ctx" 496Retrive a list of file descriptors that should be polled by your main loop as 497libusb event sources. 498Returns a NULL-terminated list on success or NULL on failure. 499.Sh LIBUSB VERSION 0.1 COMPATIBILITY |
509.Pp | |
510The library is also compliant with LibUSB version 0.1.12. 511.Pp 512.Fn usb_open 513.Fn usb_close 514.Fn usb_get_string 515.Fn usb_get_string_simple 516.Fn usb_get_descriptor_by_endpoint 517.Fn usb_get_descriptor --- 37 unchanged lines hidden --- | 500The library is also compliant with LibUSB version 0.1.12. 501.Pp 502.Fn usb_open 503.Fn usb_close 504.Fn usb_get_string 505.Fn usb_get_string_simple 506.Fn usb_get_descriptor_by_endpoint 507.Fn usb_get_descriptor --- 37 unchanged lines hidden --- |