libusb20_dev_open(3)

libusb20_dev_open3

Open a usb device to retrieve descriptors and initiate transfers

Usage

library “libusb”

#include <libusb20.h>

int

libusb20_dev_open(struct libusb20_device *pdev, uin16_t transfer_max);

Overview

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(NULL);
    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);

Releases

36 releases since FreeBSD 8.3-RELEASE; the text changed 27 times.

  1. 8.3
  2. 8.4
  3. 9.0
  4. 9.1
  5. 9.2
  6. 9.3
  7. 10.0
  8. 10.1
  9. 10.2
  10. 10.3
  11. 10.4
  12. 11.0
  13. 11.1
  14. 11.2
  15. 11.3
  16. 11.4
  17. 12.0
  18. 12.1
  19. 12.2
  20. 12.3
  21. 12.4
  22. 13.0–13.2
  23. 13.3–14.3
  24. 14.4
  25. 14.5
  26. 15.0
  27. 15.1
  28. 16.0

From base 16.0-CURRENT-20261027-61c70dc16a79 in FreeBSD 16.0-CURRENT (2026-10-27). Parsed by carta from the page's mdoc source.