Skip to content

Commit e6c49c1

Browse files
committed
V2.0
Improved time-out handling
1 parent ec2311e commit e6c49c1

File tree

3 files changed

+36
-12
lines changed

3 files changed

+36
-12
lines changed

FirmwareUpdateUI/build.num

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#Build Number for ANT. Do not edit!
2-
#Wed Feb 23 16:54:04 CET 2022
3-
build.number=2
2+
#Mon Mar 14 14:23:59 CET 2022
3+
build.number=3

FirmwareUpdateUI/src/org/gd32/dmx/FirmwareInstallation.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,22 +58,22 @@ public class FirmwareInstallation extends JDialog {
5858
private JCheckBox chckbxReboot;
5959
private JTextField textVersion;
6060

61-
public FirmwareInstallation(Node node, FirmwareUpdateUI remoteConfig) throws Exception {
61+
public FirmwareInstallation(Node node, FirmwareUpdateUI firmwareUpdateUI) throws Exception {
6262
InitComponents();
6363
CreateEvents();
6464

6565
setTitle("Workflow Firmware Installation");
6666
textNodeInfo.setText(node.toString());
6767

68-
remoteConfig.sendUDP(node, "!tftp#1");
68+
firmwareUpdateUI.sendUDP(node, "!tftp#1");
6969

7070
try {
7171
Thread.sleep(500);
7272
} catch (InterruptedException e1) {
7373
e1.printStackTrace();
7474
}
7575

76-
final String tftpServer = remoteConfig.requestUDP(node, "?tftp#");
76+
final String tftpServer = firmwareUpdateUI.requestUDP(node, "?tftp#");
7777

7878
chckbxTFTPOn.setSelected(tftpServer.contains("On"));
7979

@@ -96,15 +96,15 @@ public void run() {
9696

9797
System.out.println("TFTP Client Closed with result " + frame.result());
9898

99-
remoteConfig.sendUDP(node, "!tftp#0");
99+
firmwareUpdateUI.sendUDP(node, "!tftp#0");
100100

101101
try {
102102
Thread.sleep(500);
103103
} catch (InterruptedException e1) {
104104
e1.printStackTrace();
105105
}
106106

107-
final String tftpServer = remoteConfig.requestUDP(node, "?tftp#");
107+
final String tftpServer = firmwareUpdateUI.requestUDP(node, "?tftp#");
108108

109109
chckbxTFTPOff.setSelected(!tftpServer.contains("On"));
110110

@@ -113,7 +113,7 @@ public void run() {
113113
} else {
114114
if (frame.result() > 0) {
115115
chckbxReboot.setSelected(true);
116-
remoteConfig.sendUDP(node, "?reboot##");
116+
firmwareUpdateUI.sendUDP(node, "?reboot##");
117117
String version;
118118
String progress = "";
119119

@@ -126,13 +126,13 @@ public void run() {
126126
} catch (InterruptedException e) {
127127
e.printStackTrace();
128128
}
129-
version = remoteConfig.requestUDP(node, "?version#");
129+
version = firmwareUpdateUI.requestUDP(node, "?version#");
130130
System.out.println("[" + version + "]");
131131
} while (version.contains("tftp") || (version.contains("ERROR")));
132132

133133
textVersion.setForeground(Color.BLUE);
134134
textVersion.setText(version.substring(version.indexOf("[")));
135-
remoteConfig.constructTree();
135+
firmwareUpdateUI.constructTree();
136136
}
137137
}
138138
}

FirmwareUpdateUI/src/org/gd32/dmx/FirmwareUpdateUI.java

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,19 @@ private void doSwitchToBootLoader(Node node) {
456456
if (isEnabled) {
457457
sendUDP(node, "?reboot##");
458458
try {
459-
Thread.sleep(2000);
459+
String version;
460+
Graphics g = getGraphics();
461+
do {
462+
textArea.append("|");
463+
update(g);
464+
Thread.sleep(1000);
465+
textArea.append("/");
466+
update(g);
467+
version = requestUDP(node, "?version#");
468+
textArea.append("-");
469+
update(g);
470+
} while (version.contains("ERROR"));
471+
textArea.setText("");
460472
constructTree();
461473
} catch (InterruptedException e) {
462474
e.printStackTrace();
@@ -471,7 +483,19 @@ private void doReboot(Node node) {
471483
try {
472484
sendUDP(node, "?reboot##");
473485
JOptionPane.showMessageDialog(null, "Reboot message has been sent.");
474-
Thread.sleep(2000);
486+
String version;
487+
Graphics g = getGraphics();
488+
do {
489+
textArea.append("|");
490+
update(g);
491+
Thread.sleep(1000);
492+
textArea.append("/");
493+
update(g);
494+
version = requestUDP(node, "?version#");
495+
textArea.append("-");
496+
update(g);
497+
} while (version.contains("ERROR"));
498+
textArea.setText("");
475499
constructTree();
476500
} catch (Exception e) {
477501
e.printStackTrace();

0 commit comments

Comments
 (0)