1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-22 08:22:04 +03:00

Remove 1200 automagic baud rate every time the IDE use the serial port touch

This commit is contained in:
Cristian Maglie
2012-10-20 17:21:46 +02:00
parent c97e3623a4
commit ed15dc3b5a

View File

@ -126,24 +126,28 @@ public class BasicUploader extends Uploader {
throw new RunnerException(e); throw new RunnerException(e);
} }
// For Leonardo wait until the bootloader serial port disconnects and the // Remove the magic baud rate (1200bps) to avoid
// sketch serial port reconnects (or timeout after a few seconds if the // future unwanted board resets
// sketch port never comes back). Doing this saves users from accidentally
// opening Serial Monitor on the soon-to-be-orphaned bootloader port.
try { try {
if (uploadResult && waitForUploadPort) { if (uploadResult && doTouch) {
Thread.sleep(500); String uploadPort = Preferences.get("serial.port");
long timeout = System.currentTimeMillis() + 2000; if (waitForUploadPort) {
while (timeout > System.currentTimeMillis()) { // For Due/Leonardo wait until the bootloader serial port disconnects and the
List<String> portList = Serial.list(); // sketch serial port reconnects (or timeout after a few seconds if the
String uploadPort = Preferences.get("serial.port"); // sketch port never comes back). Doing this saves users from accidentally
if (portList.contains(Preferences.get("serial.port"))) { // opening Serial Monitor on the soon-to-be-orphaned bootloader port.
// Remove the magic baud rate (1200bps) to avoid Thread.sleep(500);
// future unwanted board resets long timeout = System.currentTimeMillis() + 2000;
Serial.touchPort(uploadPort, 9600); while (timeout > System.currentTimeMillis()) {
break; List<String> portList = Serial.list();
if (portList.contains(uploadPort)) {
Serial.touchPort(uploadPort, 9600);
break;
}
Thread.sleep(100);
} }
Thread.sleep(100); } else {
Serial.touchPort(uploadPort, 9600);
} }
} }
} catch (InterruptedException ex) { } catch (InterruptedException ex) {