Skip to content

Commit

Permalink
NXDT-related updates
Browse files Browse the repository at this point in the history
  • Loading branch information
developersu committed Sep 1, 2020
1 parent ba4afa0 commit adabfbe
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
* [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)

#### Thanks for the great work done by our translators!

* French by [Stephane Meden (JackFromNice)](https://github.com/JackFromNice)
* Italian by [unbranched](https://github.com/unbranched)
Expand Down
24 changes: 11 additions & 13 deletions src/main/java/nsusbloader/Utilities/nxdumptool/NxdtUsbAbi1.java
Original file line number Diff line number Diff line change
Expand Up @@ -287,11 +287,9 @@ private void dumpFile(File file, long size) throws Exception{
long received = 0;
int bufferSize;

boolean zlt_expected = isAligned(size);

while (received < size) {
while (received+NXDT_FILE_CHUNK_SIZE < size) {
//readBuffer = readUsbFile();
readBuffer = readUsbFileDebug();
readBuffer = readUsbFileDebug(NXDT_FILE_CHUNK_SIZE);
bos.write(readBuffer);
if (isWindows10)
fd.sync();
Expand All @@ -300,20 +298,20 @@ private void dumpFile(File file, long size) throws Exception{

logPrinter.updateProgress((double)received / (double)size);
}

if (zlt_expected) {
logPrinter.print("Finishing with ZLT packet request", EMsgType.INFO);
//readUsbFile();
readUsbFileDebug();
}
int lastChunkSize = (int)(size - received) + 1;
readBuffer = readUsbFileDebug(lastChunkSize);
bos.write(readBuffer);
if (isWindows10)
fd.sync();
} finally {
logPrinter.updateProgress(1.0);
}
}
/** Handle Zero-length terminator **/
/* Handle Zero-length terminator
private boolean isAligned(long size){
return ((size & (endpointMaxPacketSize - 1)) == 0);
}
*/

/** Sending any byte array to USB device **/
private void writeUsb(byte[] message) throws Exception{
Expand Down Expand Up @@ -397,8 +395,8 @@ private byte[] readUsbFile() throws Exception{
throw new InterruptedException();
}

private byte[] readUsbFileDebug() throws Exception {
ByteBuffer readBuffer = ByteBuffer.allocateDirect(NXDT_FILE_CHUNK_SIZE);
private byte[] readUsbFileDebug(int chunkSize) throws Exception {
ByteBuffer readBuffer = ByteBuffer.allocateDirect(chunkSize);
IntBuffer readBufTransferred = IntBuffer.allocate(1);
if (parent.isCancelled())
throw new InterruptedException();
Expand Down

0 comments on commit adabfbe

Please sign in to comment.