Fix Zero Lenght Packet problem on USB (Thanks to Phil)
This commit is contained in:
parent
7e2ddedfc1
commit
868919107a
2 changed files with 8 additions and 0 deletions
|
@ -65,10 +65,12 @@ get_end_points (struct usb_device *dev, usb_spec_t * pus)
|
||||||
// Test if we dealing with a bulk IN endpoint
|
// Test if we dealing with a bulk IN endpoint
|
||||||
if ((uiEndPoint & USB_ENDPOINT_DIR_MASK) == USB_ENDPOINT_IN) {
|
if ((uiEndPoint & USB_ENDPOINT_DIR_MASK) == USB_ENDPOINT_IN) {
|
||||||
pus->uiEndPointIn = uiEndPoint;
|
pus->uiEndPointIn = uiEndPoint;
|
||||||
|
pus->wMaxPacketSize = puid->endpoint[uiIndex].wMaxPacketSize;
|
||||||
}
|
}
|
||||||
// Test if we dealing with a bulk OUT endpoint
|
// Test if we dealing with a bulk OUT endpoint
|
||||||
if ((uiEndPoint & USB_ENDPOINT_DIR_MASK) == USB_ENDPOINT_OUT) {
|
if ((uiEndPoint & USB_ENDPOINT_DIR_MASK) == USB_ENDPOINT_OUT) {
|
||||||
pus->uiEndPointOut = uiEndPoint;
|
pus->uiEndPointOut = uiEndPoint;
|
||||||
|
pus->wMaxPacketSize = puid->endpoint[uiIndex].wMaxPacketSize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -258,6 +260,11 @@ pn53x_usb_transceive (nfc_device_t * pnd, const byte_t * pbtTx, const size_t szT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ret = usb_bulk_write (pus->pudh, pus->uiEndPointOut, (char *) abtTx, szTxLen + 7, USB_TIMEOUT);
|
ret = usb_bulk_write (pus->pudh, pus->uiEndPointOut, (char *) abtTx, szTxLen + 7, USB_TIMEOUT);
|
||||||
|
// XXX This little hack is a well know problem of libusb, see http://www.libusb.org/ticket/6 for more details
|
||||||
|
if ((ret % pus->wMaxPacketSize) == 0) {
|
||||||
|
usb_bulk_write (pus->pudh, pus->uiEndPointOut, "\0", 0, USB_TIMEOUT);
|
||||||
|
}
|
||||||
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
DBG ("usb_bulk_write failed with error %d", ret);
|
DBG ("usb_bulk_write failed with error %d", ret);
|
||||||
pnd->iLastError = DEIO;
|
pnd->iLastError = DEIO;
|
||||||
|
|
|
@ -27,6 +27,7 @@ typedef struct {
|
||||||
usb_dev_handle *pudh;
|
usb_dev_handle *pudh;
|
||||||
uint32_t uiEndPointIn;
|
uint32_t uiEndPointIn;
|
||||||
uint32_t uiEndPointOut;
|
uint32_t uiEndPointOut;
|
||||||
|
uint32_t wMaxPacketSize;
|
||||||
} usb_spec_t;
|
} usb_spec_t;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
Loading…
Add table
Reference in a new issue