NXDT-related updates

This commit is contained in:
Dmitry Isaenko 2020-09-02 00:28:38 +03:00
parent ba4afa0046
commit adabfbe860
2 changed files with 13 additions and 15 deletions

View file

@ -32,11 +32,11 @@ Sometimes I add new posts about this project [on my home page](https://developer
* Information, ideas and data from ['fusee-launcher'](https://github.com/reswitched/fusee-launcher) application * Information, ideas and data from ['fusee-launcher'](https://github.com/reswitched/fusee-launcher) application
* [Apache Commons CLI](https://commons.apache.org/proper/commons-cli/) * [Apache Commons CLI](https://commons.apache.org/proper/commons-cli/)
#### List of awesome contributors! ### List of awesome code contributors, translators and other great people!
* [Pablo Curiel (DarkMatterCore)](https://github.com/DarkMatterCore)
* [wolfposd](https://github.com/wolfposd) * [wolfposd](https://github.com/wolfposd)
#### Thanks for the great work done by our translators!
* French by [Stephane Meden (JackFromNice)](https://github.com/JackFromNice) * French by [Stephane Meden (JackFromNice)](https://github.com/JackFromNice)
* Italian by [unbranched](https://github.com/unbranched) * Italian by [unbranched](https://github.com/unbranched)

View file

@ -287,11 +287,9 @@ class NxdtUsbAbi1 {
long received = 0; long received = 0;
int bufferSize; int bufferSize;
boolean zlt_expected = isAligned(size); while (received+NXDT_FILE_CHUNK_SIZE < size) {
while (received < size) {
//readBuffer = readUsbFile(); //readBuffer = readUsbFile();
readBuffer = readUsbFileDebug(); readBuffer = readUsbFileDebug(NXDT_FILE_CHUNK_SIZE);
bos.write(readBuffer); bos.write(readBuffer);
if (isWindows10) if (isWindows10)
fd.sync(); fd.sync();
@ -300,20 +298,20 @@ class NxdtUsbAbi1 {
logPrinter.updateProgress((double)received / (double)size); logPrinter.updateProgress((double)received / (double)size);
} }
int lastChunkSize = (int)(size - received) + 1;
if (zlt_expected) { readBuffer = readUsbFileDebug(lastChunkSize);
logPrinter.print("Finishing with ZLT packet request", EMsgType.INFO); bos.write(readBuffer);
//readUsbFile(); if (isWindows10)
readUsbFileDebug(); fd.sync();
}
} finally { } finally {
logPrinter.updateProgress(1.0); logPrinter.updateProgress(1.0);
} }
} }
/** Handle Zero-length terminator **/ /* Handle Zero-length terminator
private boolean isAligned(long size){ private boolean isAligned(long size){
return ((size & (endpointMaxPacketSize - 1)) == 0); return ((size & (endpointMaxPacketSize - 1)) == 0);
} }
*/
/** Sending any byte array to USB device **/ /** Sending any byte array to USB device **/
private void writeUsb(byte[] message) throws Exception{ private void writeUsb(byte[] message) throws Exception{
@ -397,8 +395,8 @@ class NxdtUsbAbi1 {
throw new InterruptedException(); throw new InterruptedException();
} }
private byte[] readUsbFileDebug() throws Exception { private byte[] readUsbFileDebug(int chunkSize) throws Exception {
ByteBuffer readBuffer = ByteBuffer.allocateDirect(NXDT_FILE_CHUNK_SIZE); ByteBuffer readBuffer = ByteBuffer.allocateDirect(chunkSize);
IntBuffer readBufTransferred = IntBuffer.allocate(1); IntBuffer readBufTransferred = IntBuffer.allocate(1);
if (parent.isCancelled()) if (parent.isCancelled())
throw new InterruptedException(); throw new InterruptedException();