@@ -287,11 +287,9 @@ private void dumpFile(File file, long size) throws Exception{
287287 long received = 0 ;
288288 int bufferSize ;
289289
290- boolean zlt_expected = isAligned (size );
291-
292- while (received < size ) {
290+ while (received +NXDT_FILE_CHUNK_SIZE < size ) {
293291 //readBuffer = readUsbFile();
294- readBuffer = readUsbFileDebug ();
292+ readBuffer = readUsbFileDebug (NXDT_FILE_CHUNK_SIZE );
295293 bos .write (readBuffer );
296294 if (isWindows10 )
297295 fd .sync ();
@@ -300,20 +298,20 @@ private void dumpFile(File file, long size) throws Exception{
300298
301299 logPrinter .updateProgress ((double )received / (double )size );
302300 }
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 ();
309306 } finally {
310307 logPrinter .updateProgress (1.0 );
311308 }
312309 }
313- /** Handle Zero-length terminator **/
310+ /* Handle Zero-length terminator
314311 private boolean isAligned(long size){
315312 return ((size & (endpointMaxPacketSize - 1)) == 0);
316313 }
314+ */
317315
318316 /** Sending any byte array to USB device **/
319317 private void writeUsb (byte [] message ) throws Exception {
@@ -397,8 +395,8 @@ private byte[] readUsbFile() throws Exception{
397395 throw new InterruptedException ();
398396 }
399397
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 );
402400 IntBuffer readBufTransferred = IntBuffer .allocate (1 );
403401 if (parent .isCancelled ())
404402 throw new InterruptedException ();
0 commit comments