One more rewrite timeouts
This commit is contained in:
parent
c76487617c
commit
9f801869db
1 changed files with 3 additions and 15 deletions
|
@ -52,8 +52,6 @@ class NxdtUsbAbi1 {
|
||||||
private static final int CMD_SEND_FILE_PROPERTIES = 1;
|
private static final int CMD_SEND_FILE_PROPERTIES = 1;
|
||||||
private static final int CMD_ENDSESSION = 3;
|
private static final int CMD_ENDSESSION = 3;
|
||||||
|
|
||||||
private boolean nxdtCanDie;
|
|
||||||
|
|
||||||
// Standard set of possible replies
|
// Standard set of possible replies
|
||||||
private static final byte[] USBSTATUS_SUCCESS = { 0x4e, 0x58, 0x44, 0x54,
|
private static final byte[] USBSTATUS_SUCCESS = { 0x4e, 0x58, 0x44, 0x54,
|
||||||
0x00, 0x00, 0x00, 0x00,
|
0x00, 0x00, 0x00, 0x00,
|
||||||
|
@ -110,8 +108,6 @@ class NxdtUsbAbi1 {
|
||||||
while (true){
|
while (true){
|
||||||
directive = readUsbDirective();
|
directive = readUsbDirective();
|
||||||
|
|
||||||
//RainbowHexDump.hexDumpUTF8(directive);
|
|
||||||
|
|
||||||
if (isInvalidDirective(directive))
|
if (isInvalidDirective(directive))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -120,7 +116,6 @@ class NxdtUsbAbi1 {
|
||||||
switch (command){
|
switch (command){
|
||||||
case CMD_HANDSHAKE:
|
case CMD_HANDSHAKE:
|
||||||
performHandshake(directive);
|
performHandshake(directive);
|
||||||
nxdtCanDie = true;
|
|
||||||
break;
|
break;
|
||||||
case CMD_SEND_FILE_PROPERTIES:
|
case CMD_SEND_FILE_PROPERTIES:
|
||||||
handleSendFileProperties(directive);
|
handleSendFileProperties(directive);
|
||||||
|
@ -210,7 +205,8 @@ class NxdtUsbAbi1 {
|
||||||
// Check if enough space
|
// Check if enough space
|
||||||
if (fileToDump.getParentFile().getFreeSpace() <= fileSize){
|
if (fileToDump.getParentFile().getFreeSpace() <= fileSize){
|
||||||
writeUsb(USBSTATUS_HOSTIOERROR);
|
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;
|
return;
|
||||||
}
|
}
|
||||||
// Check if FS is NOT read-only
|
// 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.
|
// We can limit it to 32 bytes, but there is a non-zero chance to got OVERFLOW from libusb.
|
||||||
IntBuffer readBufTransferred = IntBuffer.allocate(1);
|
IntBuffer readBufTransferred = IntBuffer.allocate(1);
|
||||||
int result;
|
int result;
|
||||||
int countDown = 0;
|
|
||||||
while (! task.isCancelled()) {
|
while (! task.isCancelled()) {
|
||||||
result = LibUsb.bulkTransfer(handlerNS, (byte) 0x81, readBuffer, readBufTransferred, 1000); // last one is TIMEOUT. 0 stands for unlimited. Endpoint IN = 0x81
|
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);
|
readBuffer.get(receivedBytes);
|
||||||
return receivedBytes;
|
return receivedBytes;
|
||||||
case LibUsb.ERROR_TIMEOUT:
|
case LibUsb.ERROR_TIMEOUT:
|
||||||
if (nxdtCanDie){
|
break;
|
||||||
if (countDown < 5) {
|
|
||||||
countDown++;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
throw new Exception("Data transfer issue [read command]" +
|
throw new Exception("Data transfer issue [read command]" +
|
||||||
"\n Returned: " + UsbErrorCodes.getErrCode(result)+
|
"\n Returned: " + UsbErrorCodes.getErrCode(result)+
|
||||||
|
|
Loading…
Reference in a new issue