1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-02-21 15:54:39 +01:00

Serial port can take a while to close (especially on latest MacOSX) take this fact in account.

This commit is contained in:
Cristian Maglie 2012-10-21 22:14:01 +02:00
parent ed15dc3b5a
commit 61389303bb
2 changed files with 10 additions and 3 deletions

View File

@ -139,9 +139,12 @@ public class SerialMonitor extends JFrame implements MessageConsumer {
Preferences.set("serial.debug_rate", rateString); Preferences.set("serial.debug_rate", rateString);
closeSerialPort(); closeSerialPort();
try { try {
Thread.sleep(100); // Wait for serial port to properly close
openSerialPort(); openSerialPort();
} catch (SerialException e) { } catch (SerialException e) {
System.err.println(e); System.err.println(e);
} catch (InterruptedException e) {
e.printStackTrace();
} }
}}); }});

View File

@ -141,10 +141,14 @@ public class BasicUploader extends Uploader {
while (timeout > System.currentTimeMillis()) { while (timeout > System.currentTimeMillis()) {
List<String> portList = Serial.list(); List<String> portList = Serial.list();
if (portList.contains(uploadPort)) { if (portList.contains(uploadPort)) {
Serial.touchPort(uploadPort, 9600); try {
break; Serial.touchPort(uploadPort, 9600);
break;
} catch (SerialException e) {
// Port already in use
}
} }
Thread.sleep(100); Thread.sleep(250);
} }
} else { } else {
Serial.touchPort(uploadPort, 9600); Serial.touchPort(uploadPort, 9600);