XferData Fails when Large Amounts of Data Are Requested - KBA215067

Version: **

 

Question:

When I use the XferData (or the BeginDataXfer) call, large amounts of data are requested and the transfer can fail. Why is this and how to fix it? 

 

Answer:

XferData directly requests or sends the specified amount of data to the host controller driver. The host driver can queue only a certain maximum size depending on the transfer type (Bulk, Isoc, Interrupt, or Control), and the OS version. For details on the maximum transfer sizes, see the MSDN article at http://msdn.microsoft.com/en-us/library/ff538112.aspx.

To overcome this issue, you can split the large request into multiple requests of smaller sizes (with the size equal to the maximum transfer size allowed in the specified OS).

Alternatively, the third parameter of XferData called packetMode (Boolean) can be used to queue requests in multiples of wMaxPacketSize.

So, for example, for bulk endpoints in C#, this would be: 

bool isPacketMode = true;
bool transferResult = BulkEndpoint.XferData(ref xferBuffer, ref xferLength, isPacketMode);