From 9f801869db08c7994b24ead0fad13b27b431494b Mon Sep 17 00:00:00 2001 From: Dmitry Isaenko Date: Wed, 13 May 2020 01:34:21 +0300 Subject: [PATCH] One more rewrite timeouts --- .../nsusbloader/Utilities/NxdtUsbAbi1.java | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/src/main/java/nsusbloader/Utilities/NxdtUsbAbi1.java b/src/main/java/nsusbloader/Utilities/NxdtUsbAbi1.java index c8f9105..0f1b6b0 100644 --- a/src/main/java/nsusbloader/Utilities/NxdtUsbAbi1.java +++ b/src/main/java/nsusbloader/Utilities/NxdtUsbAbi1.java @@ -52,8 +52,6 @@ class NxdtUsbAbi1 { private static final int CMD_SEND_FILE_PROPERTIES = 1; private static final int CMD_ENDSESSION = 3; - private boolean nxdtCanDie; - // Standard set of possible replies private static final byte[] USBSTATUS_SUCCESS = { 0x4e, 0x58, 0x44, 0x54, 0x00, 0x00, 0x00, 0x00, @@ -110,8 +108,6 @@ class NxdtUsbAbi1 { while (true){ directive = readUsbDirective(); - //RainbowHexDump.hexDumpUTF8(directive); - if (isInvalidDirective(directive)) continue; @@ -120,7 +116,6 @@ class NxdtUsbAbi1 { switch (command){ case CMD_HANDSHAKE: performHandshake(directive); - nxdtCanDie = true; break; case CMD_SEND_FILE_PROPERTIES: handleSendFileProperties(directive); @@ -210,7 +205,8 @@ class NxdtUsbAbi1 { // Check if enough space if (fileToDump.getParentFile().getFreeSpace() <= fileSize){ writeUsb(USBSTATUS_HOSTIOERROR); - logPrinter.print("Not enough space on selected volume. Need: "+fileSize+" while available: "+fileToDump.getParentFile().getFreeSpace(), EMsgType.FAIL); + logPrinter.print("Not enough space on selected volume. Need: "+fileSize+ + " while available: "+fileToDump.getParentFile().getFreeSpace(), EMsgType.FAIL); return; } // Check if FS is NOT read-only @@ -343,7 +339,6 @@ class NxdtUsbAbi1 { // We can limit it to 32 bytes, but there is a non-zero chance to got OVERFLOW from libusb. IntBuffer readBufTransferred = IntBuffer.allocate(1); int result; - int countDown = 0; while (! task.isCancelled()) { result = LibUsb.bulkTransfer(handlerNS, (byte) 0x81, readBuffer, readBufTransferred, 1000); // last one is TIMEOUT. 0 stands for unlimited. Endpoint IN = 0x81 @@ -354,14 +349,7 @@ class NxdtUsbAbi1 { readBuffer.get(receivedBytes); return receivedBytes; case LibUsb.ERROR_TIMEOUT: - if (nxdtCanDie){ - if (countDown < 5) { - countDown++; - break; - } - } - else - break; + break; default: throw new Exception("Data transfer issue [read command]" + "\n Returned: " + UsbErrorCodes.getErrCode(result)+