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
UsbTransferAsync
Go to RapidDriver Main Page


Language

Description

C/C++
BOOL UsbTransferAsync(IN  USB_PIPE_HANDLE hPipe,
IN  OUT LPVOID pBuffer,  
IN  DWORD nNumberOfBytesToTransfer,  
IN  PTRANSFER_COMPLETION_ROUTINE pCompletionRoutine);  

Delphi
function UsbWriteAsync(hPipe                    : USB_PIPE_HANDLE;
                       const Buffer             : LPVOID;
                       nNumberOfBytesToTransfer : DWORD;
                       CompletionRoutine        : TTRANSFER_COMPLETION_ROUTINE) : BOOL; stdcall;

function UsbReadAsync(hPipe                     : USB_PIPE_HANDLE;
                      var Buffer;
                      nNumberOfBytesToTransfer  : DWORD;
                      CompletionRoutine         : TTRANSFER_COMPLETION_ROUTINE) : BOOL; stdcall;

VB
Function UsbTransferAsync (ByVal hPipe As Long, _
                           ByRef lpBuffer As Any, _
                           ByVal nNumberOfBytesToTransfer As Long, _
                           ByVal pCompletionRoutine As Long) As Boolean



Parameters
 
hPipe  
Pipe handle. This handle can be obtained with UsbPipeOpen.  
 
pBuffer  
Pointer to a resident buffer for the transfer. The contents of this buffer depend on pipe direction. If pipe direction is IN (from device to host) this buffer will contain data read from the device. Otherwise, this buffer contains user-supplied data for transfer to the device.  
 
nNumberOfBytesToTransfer  
Specifies the length, in bytes, of the buffer specified in lpBuffer.  
 
pCompletionRoutine  
Pointer to the completion routine to be called when the transfer operation is complete. For more information about transfer completion routine, see TRANSFER_COMPLETION_ROUTINE.  

Return Value
 
If function fails it return FALSE. To detect error call GetLastError function.  

Description
 
Use this function to transfer data to/from USB device pipe. Function performs transfer with bulk, interrupt and isochronous pipes. The UsbTransferAsync transfers data asynchronously. Function lets an application perform other processing during a transfer operation. When an operation completes pCompletionRoutine routine is called.