openusb_get_raw_desc, openusb_free_raw_desc, openusb_parse_device_desc, openusb_parse_config_desc, openusb_parse_interface_desc, openusb_parse_endpoint_desc

OpenUSB Developers Guide
Prev |  | Next

# `openusb_get_raw_desc, openusb_free_raw_desc, openusb_parse_device_desc, openusb_parse_config_desc, openusb_parse_interface_desc, openusb_parse_endpoint_desc`

## Name

`openusb_get_raw_desc, openusb_free_raw_desc, openusb_parse_device_desc, openusb_parse_config_desc, openusb_parse_interface_desc, openusb_parse_endpoint_desc` -- Get/Free raw device descriptors; Get cooked Device, Configuration, Interface, Endpoint descriptors

## Synopsis

``int32_t openusb_get_raw_desc`(openusb_handle_t handle, openusb_devid_t devid, uint8_t type, uint8_t descidx, uint16_t langid, uint8_t **buffer, uint16_t *buflen);`

``int32_t openusb_parse_device_desc`(openusb_handle_t handle, openusb_devid_t devid, uint8_t *buffer, uint16_t buflen, usb_device_desc_t *devdesc);`

``int32_t openusb_parse_config_desc`(openusb_handle_t handle, openusb_devid_t devid, uint8_t *buffer, uint16_t buflen, uint8_t cfgidx, usb_config_desc_t *cfgdesc);`

``int32_t openusb_parse_interface_desc`(openusb_handle_t handle, openusb_devid_t devid, uint8_t *buffer, uint16_t buflen, uint8_t cfgidx, uint8_t ifcidx, uint8_t alt, usb_interface_desc_t *ifcdesc);`

``int32_t openusb_parse_endpoint_desc`(openusb_handle_t handle, openusb_devid_t devid, uint8_t *buffer, uint16_t buflen, uint8_t cfgidx, uint8_t ifcidx, uint8_t alt, uint8_t eptidx, usb_endpoint_desc_t *eptdesc);`

``void openusb_free_raw_desc`(uint8_t *buffer);`

## Parameters

`handle` Libusb handle.

`devid` Device's devid.

`type` Descriptor type.

`descidx` Index for config/string descriptor, zero for others

`langid` Language ID for string descriptor, zero for others

`buffer` Data buffer of raw descriptors data.

`buflen` Length of raw descriptors.

`devdesc` Pointer to device descriptor.

`cfgidx` Configuration descriptor index.

`cfgdesc` Pointer to configuration descriptor.

`ifcidx` Interface index.

`alt` Alternate setting number.

`ifcdesc` Pointer to interface descriptor.

`eptidx` Endpoint index.

`eptdesc` Pointer to endpoint descriptor.

## Description

`openusb_get_raw_desc()` will return raw descriptors of `type, descidx and langid` which an application specifies on calling this function. The raw descriptor is returned in `buffer` and length of it is in `buflen`.

Application should call `openusb_free_raw_desc()` to free descriptor memory if it has called `openusb_get_raw_desc()`.

`openusb_parse_device_desc()` returns the cooked device descriptors of the specified `devid`.

`openusb_parse_config_desc()` returns the cooked configuration descriptor of specified `devid` and `cfgidx`.

`openusb_parse_interface_desc()` returns the cooked interface descriptor of number alt alternate setting of interface `ifcidx` in configuration `cfgidx`.

`openusb_parse_endpoint_desc()` returns an endpoint's descriptor of which is in alternate setting `alt` of interface `ifcidx` in configuration `cfgidx`.

For `openusb_parse_device_desc(), openusb_parse_config_desc(), openusb_parse_interface_desc() and openusb_parse_endpoint_desc()`, application can use the raw descriptor buffer got through `openusb_get_raw_desc()`. If application pass a NULL buffer pointer, these four openusb functions will call `openusb_get_raw_desc()` internally and return the cooked descriptors.

## Return Values

OPENUSB_SUCCESS Success.

OPENUSB_UNKNOWN_DEVICE Can't find the device specified by devid.

OPENUSB_INVALID_HANDLE Invalid openusb handle.

OPENUSB_NO_RESOURCES Memory allocation failure.

OPENUSB_PARSE_ERROR Fail to parse descriptors.

OPENUSB_PLATFORM_FAILURE Kernel/driver failure.

OPENUSB_BADARG Invalid arguments. devdesc, cfgdesc, ifcdesc or eptdesc is NULL. buflen is invalid if buffer is not NULL.

## See Also

Prev | Home | Next
Device Descriptor Parsers | Up | `openusb_parse_data`