Add missing LibUSB 1.0 API function: libusb_get_string_descriptor().
Reported by: Xiaofan Chen
This commit is contained in:
parent
51a65f35df
commit
78ed0e49ff
@ -74,6 +74,7 @@ MLINKS += libusb.3 libusb_get_active_config_descriptor.3
|
||||
MLINKS += libusb.3 libusb_get_config_descriptor.3
|
||||
MLINKS += libusb.3 libusb_get_config_descriptor_by_value.3
|
||||
MLINKS += libusb.3 libusb_free_config_descriptor.3
|
||||
MLINKS += libusb.3 libusb_get_string_descriptor.3
|
||||
MLINKS += libusb.3 libusb_get_string_descriptor_ascii.3
|
||||
MLINKS += libusb.3 libusb_parse_ss_endpoint_comp.3
|
||||
MLINKS += libusb.3 libusb_free_ss_endpoint_comp.3
|
||||
|
@ -26,7 +26,7 @@
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd April 12, 2012
|
||||
.Dd May 7, 2012
|
||||
.Dt LIBUSB 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -314,6 +314,12 @@ LIBUSB_ERROR code on failure.
|
||||
Free a configuration descriptor.
|
||||
.Pp
|
||||
.Ft int
|
||||
.Fn libusb_get_string_descriptor "libusb_device_handle *devh" "uint8_t desc_idx" "uint16_t langid" "unsigned char *data" "int length"
|
||||
Retrieve a string descriptor in raw format.
|
||||
Returns the number of bytes actually transferred on success
|
||||
or a negative LIBUSB_ERROR code on failure.
|
||||
.Pp
|
||||
.Ft int
|
||||
.Fn libusb_get_string_descriptor_ascii "libusb_device_handle *devh" "uint8_t desc_idx" "unsigned char *data" "int length"
|
||||
Retrieve a string descriptor in C style ASCII.
|
||||
Returns the positive number of bytes in the resulting ASCII string
|
||||
|
@ -398,6 +398,7 @@ int libusb_get_active_config_descriptor(libusb_device * dev, struct libusb_confi
|
||||
int libusb_get_config_descriptor(libusb_device * dev, uint8_t config_index, struct libusb_config_descriptor **config);
|
||||
int libusb_get_config_descriptor_by_value(libusb_device * dev, uint8_t bConfigurationValue, struct libusb_config_descriptor **config);
|
||||
void libusb_free_config_descriptor(struct libusb_config_descriptor *config);
|
||||
int libusb_get_string_descriptor(libusb_device_handle * devh, uint8_t desc_index, uint16_t langid, unsigned char *data, int length);
|
||||
int libusb_get_string_descriptor_ascii(libusb_device_handle * devh, uint8_t desc_index, uint8_t *data, int length);
|
||||
int libusb_get_descriptor(libusb_device_handle * devh, uint8_t desc_type, uint8_t desc_index, uint8_t *data, int length);
|
||||
int libusb_parse_ss_endpoint_comp(const void *buf, int len, struct libusb_ss_endpoint_companion_descriptor **ep_comp);
|
||||
|
@ -293,6 +293,25 @@ libusb_free_config_descriptor(struct libusb_config_descriptor *config)
|
||||
free(config);
|
||||
}
|
||||
|
||||
int
|
||||
libusb_get_string_descriptor(libusb_device_handle *pdev,
|
||||
uint8_t desc_index, uint16_t langid, unsigned char *data,
|
||||
int length)
|
||||
{
|
||||
if (pdev == NULL || data == NULL || length < 1)
|
||||
return (LIBUSB_ERROR_INVALID_PARAM);
|
||||
|
||||
if (length > 65535)
|
||||
length = 65535;
|
||||
|
||||
/* put some default data into the destination buffer */
|
||||
data[0] = 0;
|
||||
|
||||
return (libusb_control_transfer(pdev, LIBUSB_ENDPOINT_IN,
|
||||
LIBUSB_REQUEST_GET_DESCRIPTOR, (LIBUSB_DT_STRING << 8) | desc_index,
|
||||
langid, data, length, 1000));
|
||||
}
|
||||
|
||||
int
|
||||
libusb_get_string_descriptor_ascii(libusb_device_handle *pdev,
|
||||
uint8_t desc_index, unsigned char *data, int length)
|
||||
|
Loading…
Reference in New Issue
Block a user