openusb_open_device,openusb_close_device

OpenUSB Developers Guide
Prev |  | Next

# `openusb_open_device,openusb_close_device`

## Name

`openusb_open_device,openusb_close_device` -- Open/Close a device

## Synopsis

``int32_t openusb_open_device`(openusb_handle_t handle , openusb_devid_t devid , uint32_t flags , openusb_dev_handle_t *dev);`

``int32_t openusb_close_device`(openusb_dev_handle_t dev);`

## Parameters

`handle` - Libusb handle.

`devid` - Device's devid.

`flags` - Initialization flag.

`dev` - Device handle

## Description

`openusb_open_device` prepares a device and sets up internal data structures for use by openusb. `openusb_close_device` returns the opened device to its original state.

Application must call `openusb_open_device()` to open a device before it can do any USB transfers on that device. The open `flags` can be:

               USB_INIT_DEFAULT		default behavior

               USB_INIT_FAIL_FAST		fail if not immediately available

               USB_INIT_REVERSIBLE	try platform dependent things that are
                                        guaranteed to be reversed on close

               USB_INIT_NON_REVERSIBLE	try advanced platform dependent things that may
                                        not be guaranteed to be reversible on close

Upon successful open of a device, the device handle is returned in `dev`. All device associated operations will use this handle.

`openusb_close_device()` will destroy some internal data structures associated with the device handle `dev`.

## Return Value

OPENUSB_SUCCESS - Success.

OPENUSB_NO_RESOURCES - Memory allocation failure.

OPENUSB_UNKNOWN_DEVICE - Can't find the device specified by `devid`.

OPENUSB_SYS_FUNC_FAILURE - System function fails.

OPENUSB_INVALID_HANDLE - Libusb `handle` is invalid.

OPENUSB_PLATFORM_FAILURE - Unspecified kernel/driver failure.

OPENUSB_IO_* - USB host controller errors

## See Also

`openusb_init, openusb_fini`

Prev | Home | Next
`openusb_get_device_data,openusb_free_device_data` | Up | `openusb_get_devid`