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