Commit 4e7b7f6f1802df2cd78c84bb93ff64acf51ca075

Con Kolivas 2013-11-10T17:49:49

Send a zero length packet at the end of every usb transfer on windows in case libusb internally has batched them into one maxpacket sized.

diff --git a/usbutils.c b/usbutils.c
index 3b62545..c36aeac 100644
--- a/usbutils.c
+++ b/usbutils.c
@@ -2442,7 +2442,7 @@ usb_bulk_transfer(struct libusb_device_handle *dev_handle, int intinfo,
 
 	if (length > usb_epinfo->wMaxPacketSize)
 		length = usb_epinfo->wMaxPacketSize;
-	else if (length == usb_epinfo->wMaxPacketSize)
+	else
 		eot = true;
 
 	/* Avoid any async transfers during shutdown to allow the polling
@@ -2456,7 +2456,9 @@ usb_bulk_transfer(struct libusb_device_handle *dev_handle, int intinfo,
 		memcpy(buf, data, length);
 		/* If this is the last packet in a transfer and is the length
 		 * of the wMaxPacketSize then we need to send a zero length
-		 * packet to let the device know it's the end of the message.*/
+		 * packet to let the device know it's the end of the message.
+		 * Since libusb may batch transfers together, we send a zlp at
+		 * the end of every transfer on windows just in case. */
 		if (eot)
 			zlp = true;
 #ifndef WIN32