libusb.3 (bd2228ab3ee0cde6831fe446d793fffda2f48503) libusb.3 (ca96e26a7165b6267b688a4fb8293c1c22c5771e)
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:

--- 12 unchanged lines hidden (view full) ---

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
25.\" SUCH DAMAGE.
26.\"
27.\" $FreeBSD$
28.\"
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:

--- 12 unchanged lines hidden (view full) ---

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
25.\" SUCH DAMAGE.
26.\"
27.\" $FreeBSD$
28.\"
29.Dd November 18, 2010
29.Dd August 16, 2011
30.Dt LIBUSB 3
31.Os
32.Sh NAME
33.Nm libusb
34.
35.Nd "USB access library"
36.
37.

--- 73 unchanged lines hidden (view full) ---

111.Fn libusb_get_bus_number "libusb_device *dev"
112Returns the number of the bus contained by the device
113.Fa dev.
114.
115.Pp
116.
117.Ft uint8_t
118.Fn libusb_get_device_address "libusb_device *dev"
30.Dt LIBUSB 3
31.Os
32.Sh NAME
33.Nm libusb
34.
35.Nd "USB access library"
36.
37.

--- 73 unchanged lines hidden (view full) ---

111.Fn libusb_get_bus_number "libusb_device *dev"
112Returns the number of the bus contained by the device
113.Fa dev.
114.
115.Pp
116.
117.Ft uint8_t
118.Fn libusb_get_device_address "libusb_device *dev"
119Return the device_address contained by the device
119Returns the device_address contained by the device
120.Fa dev.
121.
122.Pp
123.
120.Fa dev.
121.
122.Pp
123.
124.Ft enum libusb_speed
125.Fn libusb_get_device_speed "libusb_device *dev"
126Returns the wire speed at which the device is connected.
127See the LIBUSB_SPEED_XXX enums for more information.
128LIBUSB_SPEED_UNKNOWN is returned in case of unknown wire speed.
129.
130.Pp
131.
124.Ft int
125.Fn libusb_get_max_packet_size "libusb_device *dev" "unsigned char endpoint"
132.Ft int
133.Fn libusb_get_max_packet_size "libusb_device *dev" "unsigned char endpoint"
126Return the wMaxPacketSize value on success, LIBUSB_ERROR_NOT_FOUND if the
134Returns the wMaxPacketSize value on success, LIBUSB_ERROR_NOT_FOUND if the
127endpoint does not exist and LIBUSB_ERROR_OTHERS on other failure.
128.
129.Pp
130.
131.Ft libusb_device *
132.Fn libusb_ref_device "libusb_device *dev"
133Increment the reference counter of the device
134.Fa dev.

--- 4 unchanged lines hidden (view full) ---

139.Fn libusb_unref_device "libusb_device *dev"
140Decrement the reference counter of the device
141.Fa dev.
142.
143.Pp
144.
145.Ft int
146.Fn libusb_open "libusb_device *dev" "libusb_device_handle **devh"
135endpoint does not exist and LIBUSB_ERROR_OTHERS on other failure.
136.
137.Pp
138.
139.Ft libusb_device *
140.Fn libusb_ref_device "libusb_device *dev"
141Increment the reference counter of the device
142.Fa dev.

--- 4 unchanged lines hidden (view full) ---

147.Fn libusb_unref_device "libusb_device *dev"
148Decrement the reference counter of the device
149.Fa dev.
150.
151.Pp
152.
153.Ft int
154.Fn libusb_open "libusb_device *dev" "libusb_device_handle **devh"
147Open a device and obtain a device_handle. Return 0 on success,
155Open a device and obtain a device_handle. Returns 0 on success,
148LIBUSB_ERROR_NO_MEM on memory allocation problem, LIBUSB_ERROR_ACCESS
149on permission problem, LIBUSB_ERROR_NO_DEVICE if the device has been
150disconnected and a LIBUSB_ERROR code on error.
151.
152.Pp
153.
154.Ft libusb_device_handle *
155.Fn libusb_open_device_with_vid_pid "libusb_context *ctx" "uint16_t vid" "uint16_t pid"
156Convenience function to open a device with is
157.Fa vid
158and
159.Fa pid.
156LIBUSB_ERROR_NO_MEM on memory allocation problem, LIBUSB_ERROR_ACCESS
157on permission problem, LIBUSB_ERROR_NO_DEVICE if the device has been
158disconnected and a LIBUSB_ERROR code on error.
159.
160.Pp
161.
162.Ft libusb_device_handle *
163.Fn libusb_open_device_with_vid_pid "libusb_context *ctx" "uint16_t vid" "uint16_t pid"
164Convenience function to open a device with is
165.Fa vid
166and
167.Fa pid.
160Return NULL on error.
168Returns NULL on error.
161.
162.Pp
163.
164.Ft void
165.Fn libusb_close "libusb_device_handle *devh"
166Close a device handle.
167.
168.Pp
169.
170.Ft libusb_device *
169.
170.Pp
171.
172.Ft void
173.Fn libusb_close "libusb_device_handle *devh"
174Close a device handle.
175.
176.Pp
177.
178.Ft libusb_device *
171.Fn libusb_get_device(libusb_device_handle *devh)
172Get the device contained by devh. Return NULL on error.
179.Fn libusb_get_device "libusb_device_handle *devh"
180Get the device contained by devh.
181Returns NULL on error.
173.
174.Pp
175.
176.Ft int
177.Fn libusb_get_configuration "libusb_device_handle *devh" "int *config"
182.
183.Pp
184.
185.Ft int
186.Fn libusb_get_configuration "libusb_device_handle *devh" "int *config"
178Return the bConfiguration value of the current configuration. return 0
187Returns the bConfiguration value of the current configuration. Returns 0
179on success, LIBUSB_ERROR_NO_DEVICE if the device has been disconnected
180and a LIBUSB_ERROR code on error.
181.
182.Pp
183.
184.Ft int
185.Fn libusb_set_configuration "libusb_device_handle *devh" "int config"
186Set the active configuration
187.Fa config
188for the device contained by
189.Fa devh.
188on success, LIBUSB_ERROR_NO_DEVICE if the device has been disconnected
189and a LIBUSB_ERROR code on error.
190.
191.Pp
192.
193.Ft int
194.Fn libusb_set_configuration "libusb_device_handle *devh" "int config"
195Set the active configuration
196.Fa config
197for the device contained by
198.Fa devh.
190This function return 0 on success, LIBUSB_ERROR_NOT_FOUND if the requested
199This function returns 0 on success, LIBUSB_ERROR_NOT_FOUND if the requested
191configuration does not exist, LIBUSB_ERROR_BUSY if the interfaces are currently
192claimed, LIBUSB_ERROR_NO_DEVICE if the device has been disconnected and a
193LIBUSB_ERROR code on failure.
194.
195.Pp
196.
197.Ft int
198.Fn libusb_claim_interface "libusb_device_handle *devh" "int interface_number"
199Claim an interface in a given libusb_handle
200.Fa devh.
200configuration does not exist, LIBUSB_ERROR_BUSY if the interfaces are currently
201claimed, LIBUSB_ERROR_NO_DEVICE if the device has been disconnected and a
202LIBUSB_ERROR code on failure.
203.
204.Pp
205.
206.Ft int
207.Fn libusb_claim_interface "libusb_device_handle *devh" "int interface_number"
208Claim an interface in a given libusb_handle
209.Fa devh.
201This is a non-blocking function. It return 0 success, LIBUSB_ERROR_NOT_FOUND
210This is a non-blocking function. It returns 0 success, LIBUSB_ERROR_NOT_FOUND
202if the requested interface does not exist, LIBUSB_ERROR_BUSY if a program or
203driver has claimed the interface, LIBUSB_ERROR_NO_DEVICE if the device has
204been disconnected and a LIBUSB_ERROR code on failure.
205.
206.Pp
207.
208.Ft int
209.Fn libusb_release_interface "libusb_device_handle *devh" "int interface_number"

--- 36 unchanged lines hidden (view full) ---

246code on failure.
247.
248.Pp
249.
250.Ft int
251.Fn libusb_kernel_driver_active "libusb_device_handle *devh" "int interface"
252Determine if a driver is active on a interface. Returns 0 if no kernel driver
253is active, returns 1 if a kernel driver is active, returns LIBUSB_ERROR_NO_DEVICE
211if the requested interface does not exist, LIBUSB_ERROR_BUSY if a program or
212driver has claimed the interface, LIBUSB_ERROR_NO_DEVICE if the device has
213been disconnected and a LIBUSB_ERROR code on failure.
214.
215.Pp
216.
217.Ft int
218.Fn libusb_release_interface "libusb_device_handle *devh" "int interface_number"

--- 36 unchanged lines hidden (view full) ---

255code on failure.
256.
257.Pp
258.
259.Ft int
260.Fn libusb_kernel_driver_active "libusb_device_handle *devh" "int interface"
261Determine if a driver is active on a interface. Returns 0 if no kernel driver
262is active, returns 1 if a kernel driver is active, returns LIBUSB_ERROR_NO_DEVICE
254if the device has been disconnected and return a LIBUSB_ERROR code on failure.
263if the device has been disconnected and returns a LIBUSB_ERROR code on failure.
255.
256.Pp
257.
258.Ft int
259.Fn libusb_get_driver "libusb_device_handle *devh" "int interface" "char *name" "int namelen"
260or
261.Ft int
262.Fn libusb_get_driver_np "libusb_device_handle *devh" "int interface" "char *name" "int namelen"

--- 48 unchanged lines hidden (view full) ---

311This is a non-blocking function. Returns 0 on success and a LIBUSB_ERROR code on
312failure.
313.
314.Pp
315.Ft int
316.Fn libsub_get_active_config_descriptor "libusb_device *dev" "struct libusb_config_descriptor **config"
317Get the USB configuration descriptor for the active configuration. Returns 0 on
318success, returns LIBUSB_ERROR_NOT_FOUND if the device is in unconfigured state
264.
265.Pp
266.
267.Ft int
268.Fn libusb_get_driver "libusb_device_handle *devh" "int interface" "char *name" "int namelen"
269or
270.Ft int
271.Fn libusb_get_driver_np "libusb_device_handle *devh" "int interface" "char *name" "int namelen"

--- 48 unchanged lines hidden (view full) ---

320This is a non-blocking function. Returns 0 on success and a LIBUSB_ERROR code on
321failure.
322.
323.Pp
324.Ft int
325.Fn libsub_get_active_config_descriptor "libusb_device *dev" "struct libusb_config_descriptor **config"
326Get the USB configuration descriptor for the active configuration. Returns 0 on
327success, returns LIBUSB_ERROR_NOT_FOUND if the device is in unconfigured state
319and return another LIBUSB_ERROR code on error.
328and returns another LIBUSB_ERROR code on error.
320.
321.Pp
322.Ft int
323.Fn libusb_get_config_descriptor "libusb_device *dev" "uint8_t config_index" "libusb_config_descriptor **config"
324Get USB configuration descriptor based on its index
325.Fa idx.
326Returns 0 on success, LIBUSB_ERROR_NOT_FOUND if the configuration does not exist
327and returns another LIBUSB_ERROR code on error.

--- 9 unchanged lines hidden (view full) ---

337.Pp
338.Ft void
339.Fn libusb_free_config_descriptor "libusb_config_descriptor *config"
340Free a configuration descriptor.
341.
342.Pp
343.Ft int
344.Fn libusb_get_string_descriptor_ascii "libusb_device_handle *devh" "uint8_t desc_idx" "unsigned char *data" "int length"
329.
330.Pp
331.Ft int
332.Fn libusb_get_config_descriptor "libusb_device *dev" "uint8_t config_index" "libusb_config_descriptor **config"
333Get USB configuration descriptor based on its index
334.Fa idx.
335Returns 0 on success, LIBUSB_ERROR_NOT_FOUND if the configuration does not exist
336and returns another LIBUSB_ERROR code on error.

--- 9 unchanged lines hidden (view full) ---

346.Pp
347.Ft void
348.Fn libusb_free_config_descriptor "libusb_config_descriptor *config"
349Free a configuration descriptor.
350.
351.Pp
352.Ft int
353.Fn libusb_get_string_descriptor_ascii "libusb_device_handle *devh" "uint8_t desc_idx" "unsigned char *data" "int length"
345Retrieve a string descriptor in C style ascii. Returns a number of byte on success
346and a LIBUSB_ERROR code on failure.
354Retrieve a string descriptor in C style ascii.
355Returns a positive number of bytes in the resulting ASCII string on success and a LIBUSB_ERROR code on failure.
347.
348.Pp
349.
350.Sh USB ASYNCHRONOUS I/O
351.
352.Pp
353.Ft struct libusb_transfer *
354.Fn libusb_alloc_transfer "int iso_packets"
355Allocate a transfer with
356.Fa iso_packets
356.
357.Pp
358.
359.Sh USB ASYNCHRONOUS I/O
360.
361.Pp
362.Ft struct libusb_transfer *
363.Fn libusb_alloc_transfer "int iso_packets"
364Allocate a transfer with
365.Fa iso_packets
357numbers of isochronous packet descriptors. Returns NULL on error.
366numbers of isochronous packet descriptors.
367Returns NULL on error.
358.
359.Pp
360.Ft void
361.Fn libusb_free_transfer "struct libusb_transfer *tr"
362Free a transfer.
363.
364.Pp
365.Ft int
366.Fn libusb_submit_transfer "struct libusb_transfer *tr"
368.
369.Pp
370.Ft void
371.Fn libusb_free_transfer "struct libusb_transfer *tr"
372Free a transfer.
373.
374.Pp
375.Ft int
376.Fn libusb_submit_transfer "struct libusb_transfer *tr"
367This function will submit a transfer and returns immediately. Returns 0 on
368success, LIBUSB_ERROR_NO_DEVICE if the device has been disconnected and
377This function will submit a transfer and returns immediately.
378Returns 0 on success, LIBUSB_ERROR_NO_DEVICE if the device has been disconnected and
369LIBUSB_ERROR code on other failure.
370.
371.Pp
372.Ft int
373.Fn libusb_cancel_transfer "struct libusb_transfer *tr"
379LIBUSB_ERROR code on other failure.
380.
381.Pp
382.Ft int
383.Fn libusb_cancel_transfer "struct libusb_transfer *tr"
374This function asynchronously cancel a transfer. Returns 0 on success and
375LIBUSB_ERROR code on failure.
384This function asynchronously cancel a transfer.
385Returns 0 on success and LIBUSB_ERROR code on failure.
376.
377.Pp
378.Sh USB SYNCHRONOUS I/O
379.
380.Pp
381.Ft int
382.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"
386.
387.Pp
388.Sh USB SYNCHRONOUS I/O
389.
390.Pp
391.Ft int
392.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"
383Perform a USB control transfer. Returns the actual number of bytes
393Perform a USB control transfer.
394Returns the actual number of bytes
384transferred on success in the range from and including zero until and
385including
386.Fa wLength .
387On error a libusb error code is returned, for example
388LIBUSB_ERROR_TIMEOUT if the transfer timeout, LIBUSB_ERROR_PIPE if the
389control request was not supported, LIBUSB_ERROR_NO_DEVICE if the
390device has been disconnected or another LIBUSB_ERROR code on other failures.
391The libusb error codes are always negative.

--- 23 unchanged lines hidden (view full) ---

415LIBUSB_ERROR code on other failure.
416.
417.Pp
418.Sh USB EVENTS
419.
420.Pp
421.Ft int
422.Fn libusb_try_lock_events "libusb_context *ctx"
395transferred on success in the range from and including zero until and
396including
397.Fa wLength .
398On error a libusb error code is returned, for example
399LIBUSB_ERROR_TIMEOUT if the transfer timeout, LIBUSB_ERROR_PIPE if the
400control request was not supported, LIBUSB_ERROR_NO_DEVICE if the
401device has been disconnected or another LIBUSB_ERROR code on other failures.
402The libusb error codes are always negative.

--- 23 unchanged lines hidden (view full) ---

426LIBUSB_ERROR code on other failure.
427.
428.Pp
429.Sh USB EVENTS
430.
431.Pp
432.Ft int
433.Fn libusb_try_lock_events "libusb_context *ctx"
423Try to acquire the event handling lock. Returns 0 if the lock was obtained and 1
424if not.
434Try to acquire the event handling lock.
435Returns 0 if the lock was obtained and 1 if not.
425.
426.Pp
427.Ft void
428.Fn libusb_lock_events "libusb_context *ctx"
429Acquire the event handling lock. This function is blocking.
430.
431.Pp
432.Ft void

--- 127 unchanged lines hidden ---
436.
437.Pp
438.Ft void
439.Fn libusb_lock_events "libusb_context *ctx"
440Acquire the event handling lock. This function is blocking.
441.
442.Pp
443.Ft void

--- 127 unchanged lines hidden ---