Skip to content

Commit 77ae860

Browse files
committed
DarkMatterCore/nxdumptool support
Hotfix within adding DarkMatterCore/nxdumptool support: fix 'Stop' button functionality Update NxdtUsbAbi1.java Rename method isInvalidCommand() -> isInvalidCommand() A bit more renames and debug things More refactoring Typos fixes He just told me that 'NXDT_COMMAND_HEADER_SIZE was added to reflect the UsbCommandHeader struct from my codebase. No received command should ever be smaller than this. NXDT_COMMAND_SIZE was renamed to NXDT_MAX_COMMAND_SIZE for this reason.' Some bug fixes With debug Few more fixes Copy-paste Windows10 workaround fix Add NXDT_FILE_PROPERTIES_MAX_NAME_LENGTH validation Fix NXDT_FILE_PROPERTIES_MAX_NAME_LENGTH validation If fileSize == 0 only one success reply sent Add debug rewrite timeouts One more rewrite timeouts
1 parent 6334100 commit 77ae860

18 files changed

+726
-143
lines changed

Outdated_README_KR.md

Lines changed: 0 additions & 135 deletions
This file was deleted.

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<name>NS-USBloader</name>
99

1010
<artifactId>ns-usbloader</artifactId>
11-
<version>2.2.1-SNAPSHOT</version>
11+
<version>3.0-SNAPSHOT</version>
1212

1313
<url>https://github.com/developersu/ns-usbloader/</url>
1414
<description>

src/main/java/nsusbloader/AppPreferences.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,4 +152,7 @@ public String getHostPort(){
152152
// RCM //
153153
public String getRecentRcm(int num){ return preferences.get(String.format("RCM_%02d", num), ""); }
154154
public void setRecentRcm(int num, String value){ preferences.put(String.format("RCM_%02d", num), value); }
155+
// NXDT //
156+
public String getNXDTSaveToLocation(){ return preferences.get("nxdt_saveto", System.getProperty("user.home")); }
157+
public void setNXDTSaveToLocation(String value){ preferences.put("nxdt_saveto", value); }
155158
}

src/main/java/nsusbloader/Controllers/NSLMainController.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ public class NSLMainController implements Initializable {
4848
private SplitMergeController SplitMergeTabController;
4949
@FXML
5050
private RcmController RcmTabController;
51+
@FXML
52+
private NxdtController NXDTabController;
5153

5254
@Override
5355
public void initialize(URL url, ResourceBundle rb) {
@@ -110,6 +112,8 @@ public SplitMergeController getSmCtrlr(){
110112
}
111113

112114
public RcmController getRcmCtrlr(){ return RcmTabController; }
115+
116+
public NxdtController getNXDTabController(){ return NXDTabController; }
113117
/**
114118
* Save preferences before exit
115119
* */
@@ -135,5 +139,6 @@ public void exit(){
135139

136140
SplitMergeTabController.updatePreferencesOnExit(); // NOTE: This shit above should be re-written to similar pattern
137141
RcmTabController.updatePreferencesOnExit();
142+
NXDTabController.updatePreferencesOnExit();
138143
}
139144
}
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
/*
2+
Copyright 2019-2020 Dmitry Isaenko
3+
4+
This file is part of NS-USBloader.
5+
6+
NS-USBloader is free software: you can redistribute it and/or modify
7+
it under the terms of the GNU General Public License as published by
8+
the Free Software Foundation, either version 3 of the License, or
9+
(at your option) any later version.
10+
11+
NS-USBloader is distributed in the hope that it will be useful,
12+
but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
GNU General Public License for more details.
15+
16+
You should have received a copy of the GNU General Public License
17+
along with NS-USBloader. If not, see <https://www.gnu.org/licenses/>.
18+
*/
19+
package nsusbloader.Controllers;
20+
21+
import javafx.concurrent.Task;
22+
import javafx.fxml.FXML;
23+
import javafx.fxml.Initializable;
24+
import javafx.scene.control.Button;
25+
import javafx.scene.control.Label;
26+
import javafx.scene.layout.Region;
27+
import javafx.stage.DirectoryChooser;
28+
import nsusbloader.AppPreferences;
29+
import nsusbloader.MediatorControl;
30+
import nsusbloader.NSLDataTypes.EModule;
31+
import nsusbloader.Utilities.NxdtTask;
32+
33+
import java.io.File;
34+
import java.net.URL;
35+
import java.util.ResourceBundle;
36+
37+
public class NxdtController implements Initializable {
38+
@FXML
39+
private Label saveToLocationLbl, statusLbl;
40+
41+
@FXML
42+
private Button injectPldBtn;
43+
44+
private ResourceBundle rb;
45+
46+
private Region btnDumpStopImage;
47+
48+
private Task<Boolean> NxdtTask;
49+
private Thread workThread;
50+
51+
@Override
52+
public void initialize(URL url, ResourceBundle resourceBundle) {
53+
this.rb = resourceBundle;
54+
55+
File saveToValidator = new File(AppPreferences.getInstance().getNXDTSaveToLocation());
56+
if (saveToValidator.exists())
57+
saveToLocationLbl.setText(saveToValidator.getAbsolutePath());
58+
else
59+
saveToLocationLbl.setText(System.getProperty("user.home"));
60+
61+
btnDumpStopImage = new Region();
62+
btnDumpStopImage.getStyleClass().add("regionDump");
63+
64+
injectPldBtn.getStyleClass().add("buttonUp");
65+
injectPldBtn.setGraphic(btnDumpStopImage);
66+
67+
injectPldBtn.setOnAction(event -> startDumpProcess());
68+
}
69+
70+
@FXML
71+
private void bntSelectSaveTo(){
72+
DirectoryChooser dc = new DirectoryChooser();
73+
dc.setTitle(rb.getString("tabSplMrg_Btn_SelectFolder"));
74+
dc.setInitialDirectory(new File(saveToLocationLbl.getText()));
75+
File saveToDir = dc.showDialog(saveToLocationLbl.getScene().getWindow());
76+
if (saveToDir != null)
77+
saveToLocationLbl.setText(saveToDir.getAbsolutePath());
78+
}
79+
/**
80+
* Start reading commands from NXDT button handler
81+
* */
82+
private void startDumpProcess(){
83+
if ((workThread == null || ! workThread.isAlive())){
84+
MediatorControl.getInstance().getContoller().logArea.clear();
85+
86+
NxdtTask = new NxdtTask(saveToLocationLbl.getText());
87+
NxdtTask.setOnSucceeded(event -> {
88+
if (NxdtTask.getValue())
89+
statusLbl.setText(rb.getString("done_txt"));
90+
else
91+
statusLbl.setText(rb.getString("failure_txt"));
92+
});
93+
94+
workThread = new Thread(NxdtTask);
95+
workThread.setDaemon(true);
96+
workThread.start();
97+
}
98+
}
99+
100+
/**
101+
* Interrupt thread NXDT button handler
102+
* */
103+
private void stopBtnAction(){
104+
if (workThread != null && workThread.isAlive()){
105+
NxdtTask.cancel(false);
106+
}
107+
}
108+
109+
public void notifyThreadStarted(boolean isActive, EModule type){
110+
if (! type.equals(EModule.NXDT)){
111+
injectPldBtn.setDisable(isActive);
112+
return;
113+
}
114+
115+
if (isActive) {
116+
btnDumpStopImage.getStyleClass().clear();
117+
btnDumpStopImage.getStyleClass().add("regionStop");
118+
119+
injectPldBtn.setOnAction(e-> stopBtnAction());
120+
injectPldBtn.setText(rb.getString("btn_Stop"));
121+
injectPldBtn.getStyleClass().remove("buttonUp");
122+
injectPldBtn.getStyleClass().add("buttonStop");
123+
return;
124+
}
125+
btnDumpStopImage.getStyleClass().clear();
126+
btnDumpStopImage.getStyleClass().add("regionDump");
127+
128+
injectPldBtn.setOnAction(e-> startDumpProcess());
129+
injectPldBtn.setText(rb.getString("tabNXDT_Btn_Start"));
130+
injectPldBtn.getStyleClass().remove("buttonStop");
131+
injectPldBtn.getStyleClass().add("buttonUp");
132+
}
133+
/**
134+
* Save application settings on exit
135+
* */
136+
public void updatePreferencesOnExit(){
137+
AppPreferences.getInstance().setNXDTSaveToLocation(saveToLocationLbl.getText());
138+
}
139+
}

src/main/java/nsusbloader/MediatorControl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public synchronized void setBgThreadActive(boolean isActive, EModule appModuleTy
4444
mainCtrler.getFrontCtrlr().notifyTransmThreadStarted(isActive, appModuleType);
4545
mainCtrler.getSmCtrlr().notifySmThreadStarted(isActive, appModuleType);
4646
mainCtrler.getRcmCtrlr().notifySmThreadStarted(isActive, appModuleType);
47+
mainCtrler.getNXDTabController().notifyThreadStarted(isActive, appModuleType);
4748
}
4849
public synchronized boolean getTransferActive() { return this.isTransferActive.get(); }
4950
}

src/main/java/nsusbloader/NSLDataTypes/EModule.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,6 @@
2121
public enum EModule {
2222
USB_NET_TRANSFERS,
2323
SPLIT_MERGE_TOOL,
24-
RCM
24+
RCM,
25+
NXDT
2526
}

src/main/java/nsusbloader/NSLMain.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,14 @@
2626
import javafx.stage.Stage;
2727
import nsusbloader.Controllers.NSLMainController;
2828

29+
import java.io.File;
30+
import java.nio.file.Paths;
2931
import java.util.Locale;
3032
import java.util.ResourceBundle;
3133

3234
public class NSLMain extends Application {
3335

34-
public static final String appVersion = "v2.2.1";
36+
public static final String appVersion = "v3.0";
3537

3638
@Override
3739
public void start(Stage primaryStage) throws Exception{

src/main/java/nsusbloader/RainbowHexDump.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,31 @@ public static void hexDumpUTF8(byte[] byteArray){
4141
System.out.println(">"+ANSI_RED+byteArray.length+ANSI_RESET);
4242
for (byte b: byteArray)
4343
System.out.print(String.format("%02x ", b));
44-
//System.out.println();
44+
System.out.println();
4545
System.out.print("\t\t\t"
4646
+ new String(byteArray, StandardCharsets.UTF_8)
4747
+ "\n");
4848
}
4949

50+
public static void hexDumpUTF8ForWin(byte[] byteArray){
51+
for (int i=0; i < byteArray.length; i++)
52+
System.out.print(String.format("%02d-", i%100));
53+
System.out.println(">"+byteArray.length);
54+
for (byte b: byteArray)
55+
System.out.print(String.format("%02x ", b));
56+
System.out.println();
57+
System.out.print(new String(byteArray, StandardCharsets.UTF_8)
58+
+ "\n");
59+
}
60+
5061
public static void hexDumpUTF16LE(byte[] byteArray){
5162
System.out.print(ANSI_BLUE);
5263
for (int i=0; i < byteArray.length; i++)
5364
System.out.print(String.format("%02d-", i%100));
5465
System.out.println(">"+ANSI_RED+byteArray.length+ANSI_RESET);
5566
for (byte b: byteArray)
5667
System.out.print(String.format("%02x ", b));
57-
System.out.print("\t\t\t"
58-
+ new String(byteArray, StandardCharsets.UTF_16LE)
68+
System.out.print(new String(byteArray, StandardCharsets.UTF_16LE)
5969
+ "\n");
6070
}
6171
}

0 commit comments

Comments
 (0)