Skip to content

Commit 8139e85

Browse files
author
Federico Fissore
committed
On some OSs, some boards may take time before reappearing. Better wait for them 5 reasonable seconds
1 parent c138628 commit 8139e85

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Diff for: app/src/processing/app/Editor.java

+12
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@
7070
@SuppressWarnings("serial")
7171
public class Editor extends JFrame implements RunnerListener {
7272

73+
public static final int MAX_TIME_AWAITING_FOR_RESUMING_SERIAL_MONITOR = 5000;
74+
7375
private final Platform platform;
7476
private JMenu recentSketchesMenu;
7577

@@ -2411,6 +2413,16 @@ private void resumeOrCloseSerialMonitor() {
24112413
// Return the serial monitor window to its initial state
24122414
if (serialMonitor != null) {
24132415
BoardPort boardPort = BaseNoGui.getDiscoveryManager().find(PreferencesData.get("serial.port"));
2416+
long sleptFor = 0;
2417+
while (boardPort == null && sleptFor < MAX_TIME_AWAITING_FOR_RESUMING_SERIAL_MONITOR) {
2418+
try {
2419+
Thread.sleep(100);
2420+
sleptFor += 100;
2421+
boardPort = BaseNoGui.getDiscoveryManager().find(PreferencesData.get("serial.port"));
2422+
} catch (InterruptedException e) {
2423+
// noop
2424+
}
2425+
}
24142426
try {
24152427
if (boardPort == null) {
24162428
serialMonitor.close();

0 commit comments

Comments
 (0)