#define USBHostGetStringDescriptor( deviceAddress, stringNumber, LangID, stringDescriptor, stringLength, clientDriverID ) \ USBHostIssueDeviceRequest( deviceAddress, USB_SETUP_DEVICE_TO_HOST | USB_SETUP_TYPE_STANDARD | USB_SETUP_RECIPIENT_DEVICE, \ USB_REQUEST_GET_DESCRIPTOR, (USB_DESCRIPTOR_STRING << 8) | stringNumber, \ LangID, stringLength, stringDescriptor, USB_DEVICE_REQUEST_GET, clientDriverID )
This routine initiates a request to obtains the requested string descriptor. If the request cannot be started, the routine returns an error. Otherwise, the request is started, and the requested string descriptor is stored in the designated location.
Example Usage:
USBHostGetStringDescriptor( deviceAddress, stringDescriptorNum, LangID, stringDescriptorBuffer, sizeof(stringDescriptorBuffer), 0xFF ); while(1) { if(USBHostTransferIsComplete( deviceAddress , 0, &errorCode, &byteCount)) { if(errorCode) { //There was an error reading the string, bail out of loop } else { //String is located in specified buffer, do something with it. //The length of the string is both in the byteCount variable // as well as the first byte of the string itself } break; } USBTasks(); }
None
Parameters |
Description |
deviceAddress |
Address of the device |
stringNumber |
Index of the desired string descriptor |
LangID |
The Language ID of the string to read (should be 0 if trying to read the language ID list *stringDescriptor - Pointer to where to store the string. |
stringLength |
Maximum length of the returned string. |
clientDriverID |
Client driver to return the completion event to. |
Return Values |
Description |
USB_SUCCESS |
The request was started successfully. |
USB_UNKNOWN_DEVICE |
Device not found |
USB_INVALID_STATE |
We must be in a normal running state. |
USB_ENDPOINT_BUSY |
The endpoint is currently processing a request. |
The returned string descriptor will be in the exact format as obtained from the device. The length of the entire descriptor will be in the first byte, and the descriptor type will be in the second. The string itself is represented in UNICODE. Refer to the USB 2.0 Specification for more information about the format of string descriptors.
MLA - USB Library Help Version : 2.16
![]() |