diff --git a/app/src/main/java/org/cgutman/usbip/service/UsbIpService.java b/app/src/main/java/org/cgutman/usbip/service/UsbIpService.java index 99f4b71..f7530b6 100644 --- a/app/src/main/java/org/cgutman/usbip/service/UsbIpService.java +++ b/app/src/main/java/org/cgutman/usbip/service/UsbIpService.java @@ -558,10 +558,11 @@ public void submitUrbRequest(Socket s, UsbIpSubmitUrb msg) { context.activeMessages.add(msg); int res; - + boolean isDeviceToHost = (requestType & 0x80) != 0; + do { res = XferUtils.doControlTransfer(devConn, requestType, request, value, index, - (requestType & 0x80) != 0 ? reply.inData : msg.outData, length, 1000); + isDeviceToHost ? reply.inData : msg.outData, length, 1000); if (context.requestPool.isShutdown()) { // Bail if the queue is being torn down @@ -578,7 +579,7 @@ public void submitUrbRequest(Socket s, UsbIpSubmitUrb msg) { reply.status = res; } else { - reply.actualLength = res; + reply.actualLength = isDeviceToHost ? res : 0; reply.status = ProtoDefs.ST_OK; } diff --git a/app/src/main/java/org/cgutman/usbip/usb/XferUtils.java b/app/src/main/java/org/cgutman/usbip/usb/XferUtils.java index 8e88b4e..801c11c 100644 --- a/app/src/main/java/org/cgutman/usbip/usb/XferUtils.java +++ b/app/src/main/java/org/cgutman/usbip/usb/XferUtils.java @@ -52,9 +52,10 @@ public static int doBulkTransfer(UsbDeviceConnection devConn, UsbEndpoint endpoi bytesTransferred += res; - if (res < endpoint.getMaxPacketSize()) { + if (res != endpoint.getMaxPacketSize()) { // A packet less than the maximum size for this endpoint // indicates the transfer has ended + // For some devices (yubikey) the res is greater than max packet size break; } }