@@ -287,11 +287,9 @@ private void dumpFile(File file, long size) throws Exception{
287
287
long received = 0 ;
288
288
int bufferSize ;
289
289
290
- boolean zlt_expected = isAligned (size );
291
-
292
- while (received < size ) {
290
+ while (received +NXDT_FILE_CHUNK_SIZE < size ) {
293
291
//readBuffer = readUsbFile();
294
- readBuffer = readUsbFileDebug ();
292
+ readBuffer = readUsbFileDebug (NXDT_FILE_CHUNK_SIZE );
295
293
bos .write (readBuffer );
296
294
if (isWindows10 )
297
295
fd .sync ();
@@ -300,20 +298,20 @@ private void dumpFile(File file, long size) throws Exception{
300
298
301
299
logPrinter .updateProgress ((double )received / (double )size );
302
300
}
303
-
304
- if (zlt_expected ) {
305
- logPrinter .print ("Finishing with ZLT packet request" , EMsgType .INFO );
306
- //readUsbFile();
307
- readUsbFileDebug ();
308
- }
301
+ int lastChunkSize = (int )(size - received ) + 1 ;
302
+ readBuffer = readUsbFileDebug (lastChunkSize );
303
+ bos .write (readBuffer );
304
+ if (isWindows10 )
305
+ fd .sync ();
309
306
} finally {
310
307
logPrinter .updateProgress (1.0 );
311
308
}
312
309
}
313
- /** Handle Zero-length terminator **/
310
+ /* Handle Zero-length terminator
314
311
private boolean isAligned(long size){
315
312
return ((size & (endpointMaxPacketSize - 1)) == 0);
316
313
}
314
+ */
317
315
318
316
/** Sending any byte array to USB device **/
319
317
private void writeUsb (byte [] message ) throws Exception {
@@ -397,8 +395,8 @@ private byte[] readUsbFile() throws Exception{
397
395
throw new InterruptedException ();
398
396
}
399
397
400
- private byte [] readUsbFileDebug () throws Exception {
401
- ByteBuffer readBuffer = ByteBuffer .allocateDirect (NXDT_FILE_CHUNK_SIZE );
398
+ private byte [] readUsbFileDebug (int chunkSize ) throws Exception {
399
+ ByteBuffer readBuffer = ByteBuffer .allocateDirect (chunkSize );
402
400
IntBuffer readBufTransferred = IntBuffer .allocate (1 );
403
401
if (parent .isCancelled ())
404
402
throw new InterruptedException ();
0 commit comments