Use one of functions described in Descriptors section to retrieve needed descriptor. This functions issue GetDescriptor USB request. For more infromation about standard USB descriptors refer to 9.6 section of USB 1.1 specification.
Use UsbGetDescriptor function to get descriptor of user-specified type and request recipinent. In some cases when descriptor is class (vendor) -specific use UsbClassRequestIn (UsbVendorRequestIn) to retrieve it.
Functions UsbGetConfigDescriptor and UsbGetInterfaceDescriptor which retrieve descriptors of variable length allocate memory buffer to hold result. So after descriptor is no more needed call respective UsbFreeXXXXXDescriptor function to free allocated memory.
Note: For more information regarding reading descriptors refer to "Descriptors" example.
The following is an example of how to get a configuration descriptor:
// open first RapidUSB device
USB_HANDLE hUsb = OpenRapidUsb(0);
PUSB_CONFIGURATION_DESCRIPTOR pConfDesc;
UsbGetConfigDescriptor(hUsb, 0, pConfDesc);
if (pConfDesc != NULL)
{
// configuration retrieved successfully
// work with descriptor
// ....................
// Free descriptor when it is not needed
UsbFreeConfigDescriptor(pConfDesc);
}
else
{
// Error! Check if hUsb is valid
}
CloseRapidUsb(hUsb);
|