One more rewrite timeouts

This commit is contained in:
Dmitry Isaenko 2020-05-13 01:34:21 +03:00
parent c76487617c
commit 9f801869db

View file

@ -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)+