Skip to content

Commit 6138930

Browse files
committed
Serial port can take a while to close (especially on latest MacOSX) take this fact in account.
1 parent ed15dc3 commit 6138930

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

app/src/processing/app/SerialMonitor.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,12 @@ public void actionPerformed(ActionEvent event) {
139139
Preferences.set("serial.debug_rate", rateString);
140140
closeSerialPort();
141141
try {
142+
Thread.sleep(100); // Wait for serial port to properly close
142143
openSerialPort();
143144
} catch (SerialException e) {
144145
System.err.println(e);
146+
} catch (InterruptedException e) {
147+
e.printStackTrace();
145148
}
146149
}});
147150

app/src/processing/app/debug/BasicUploader.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,14 @@ public boolean uploadUsingPreferences(String buildPath, String className,
141141
while (timeout > System.currentTimeMillis()) {
142142
List<String> portList = Serial.list();
143143
if (portList.contains(uploadPort)) {
144-
Serial.touchPort(uploadPort, 9600);
145-
break;
144+
try {
145+
Serial.touchPort(uploadPort, 9600);
146+
break;
147+
} catch (SerialException e) {
148+
// Port already in use
149+
}
146150
}
147-
Thread.sleep(100);
151+
Thread.sleep(250);
148152
}
149153
} else {
150154
Serial.touchPort(uploadPort, 9600);

0 commit comments

Comments
 (0)