Home    Prev Next    
Contents
Programming For USB Device
Overview
Programmers Guide
Scenario
Data transfer
Synchronous Transfer
Asynchronous Transfer
Reading Descriptors
USB Support Routines And Structures
Common Procedures
UsbEnumerateDevices
OpenRapidUsb
IsRapidUsbOpened
CloseRapidUsb
Descriptors
UsbGetDescriptor
UsbGetDeviceDescriptor
UsbGetStringDescriptor
UsbGetConfigDescriptor
UsbFreeConfigDescriptor
UsbGetInterfaceDescriptor
UsbFreeInterfaceDescriptor
UsbGetEndpointDescriptor
Configure Device
UsbGetDeviceInfo
UsbUnconfigureDevice
UsbSelectConfig
UsbGetConfig
UsbSelectInterface
UsbGetInterface
UsbResetDevice
UsbGetBandwidthInfo
UsbCyclePort
Features and Status
UsbSetFeature
UsbClearFeature
UsbGetStatus
Vendor/Class Requests
UsbVendorRequestIn
UsbVendorRequestOut
UsbClassRequestIn
UsbClassRequestOut
Pipes
IsRapidUsbPipeOpened
UsbPipeOpen
UsbPipeClose
UsbGetPipeCount
UsbPipeGetInfo
UsbPipeDirectionIn
UsbPipeGetType
UsbTransfer
UsbTransferAsync
TRANSFER_COMPLETION_ROUTINE
UsbCancelTransfer
UsbPipeReset
UsbPipeAbort
Other
UsbGetPortStatus
UsbGetCurrentFrameNumber
USB Structures and Types
RDUSB_DEVICE_INFORMATION
RDUSB_PIPE_INFORMATION
RDUSB_PIPE_TYPE
RDUSB_BANDWIDTH_INFORMATION
Reading Descriptors
Go to RapidDriver Main Page


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);