XferData Fails when Large Amount of Data is Requested - KBA215067

Version: *A

 

Question:

When I use the XferData (or the BeginDataXfer) call, large amount of data is requested and the transfer can fail. Why does this happen and how do I 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 https://docs.microsoft.com/en-us/windows-hardware/drivers/usbcon/usb-bandwidth-allocation.

 

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, you can use the third parameter of XferData called packetMode (Boolean) 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);