Browse Source

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.

Con Kolivas 12 years ago
parent
commit
4e7b7f6f18
1 changed files with 4 additions and 2 deletions
  1. 4 2
      usbutils.c

+ 4 - 2
usbutils.c

@@ -2442,7 +2442,7 @@ usb_bulk_transfer(struct libusb_device_handle *dev_handle, int intinfo,
 
 
 	if (length > usb_epinfo->wMaxPacketSize)
 	if (length > usb_epinfo->wMaxPacketSize)
 		length = usb_epinfo->wMaxPacketSize;
 		length = usb_epinfo->wMaxPacketSize;
-	else if (length == usb_epinfo->wMaxPacketSize)
+	else
 		eot = true;
 		eot = true;
 
 
 	/* Avoid any async transfers during shutdown to allow the polling
 	/* 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);
 		memcpy(buf, data, length);
 		/* If this is the last packet in a transfer and is the 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
 		 * 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)
 		if (eot)
 			zlp = true;
 			zlp = true;
 #ifndef WIN32
 #ifndef WIN32