diff options
-rw-r--r-- | lib/libusb/Makefile | 1 | ||||
-rw-r--r-- | lib/libusb/libusb.3 | 8 | ||||
-rw-r--r-- | lib/libusb/libusb.h | 1 | ||||
-rw-r--r-- | lib/libusb/libusb10_desc.c | 19 |
4 files changed, 28 insertions, 1 deletions
diff --git a/lib/libusb/Makefile b/lib/libusb/Makefile index 75efe2e..7a9bd1b 100644 --- a/lib/libusb/Makefile +++ b/lib/libusb/Makefile @@ -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 diff --git a/lib/libusb/libusb.3 b/lib/libusb/libusb.3 index 6b1defd..1ab0a8b 100644 --- a/lib/libusb/libusb.3 +++ b/lib/libusb/libusb.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 diff --git a/lib/libusb/libusb.h b/lib/libusb/libusb.h index d8a22b5..1675f46 100644 --- a/lib/libusb/libusb.h +++ b/lib/libusb/libusb.h @@ -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); diff --git a/lib/libusb/libusb10_desc.c b/lib/libusb/libusb10_desc.c index 8e39bab..11e201f 100644 --- a/lib/libusb/libusb10_desc.c +++ b/lib/libusb/libusb10_desc.c @@ -294,6 +294,25 @@ libusb_free_config_descriptor(struct libusb_config_descriptor *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) { |