LIBUSB20(3)

NAME
libusb20_dev_open - open a USB device to retrieve descriptors and initiate transfers

SYNOPSIS
libusb
#include <libusb20.h>
int
libusb20_dev_open(struct libusb20_device *pdev, uin16_t transfer_max);

DESCRIPTION
The libusb20_dev_open function opens a USB device to retrieve descriptors and initiate transfers. libusb20_dev_open accepts a pointer as pdev to a libusb20_device obtained from libusb20_be_device_foreach. A zero for transfer_max limits the device to only control transfers. Call libusb20_dev_close(3) to free resources taken by the open device handle.

RETURN VALUES
libusb20_dev_open returns one of the following to report success or failure:

LIBUSB20_SUCCESS,
    The operation succeeds.
LIBUSB20_ERROR_BUSY,
    The device is in use elsewhere.
LIBUSB20_ERROR_ACCESS,
    A permissions issue.
LIBUSB20_ERROR_NO_DEVICE,
    The device detached.
LIBUSB20_ERROR_NO_MEM
    The library couldn't allocate memory.

Errors not listed here may be found in libusb20(3) and <libusb20.h>.

EXAMPLES

        #include <libusb20.h>
        struct libusb20_backend *be = libusb20_be_alloc_default();
        struct libusb20_device *device = NULL;
        while ( (device = libusb20_be_device_foreach(be, device)) != NULL ) {
            if (libusb20_dev_open(device, 0) == LIBUSB20_SUCCESS) {
                /* do something */
                libusb20_dev_close(device);
            }
        }
        libusb20_be_free(be);

SEE ALSO
libusb20(3), libusb20_be_device_foreach(3), libusb20_dev_close(3)