From ed15dc3b5a3a3655525a161c885631d74396d1b5 Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Sat, 20 Oct 2012 17:21:46 +0200 Subject: [PATCH] Remove 1200 automagic baud rate every time the IDE use the serial port touch --- .../processing/app/debug/BasicUploader.java | 36 ++++++++++--------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/app/src/processing/app/debug/BasicUploader.java b/app/src/processing/app/debug/BasicUploader.java index e92ae60c2..f88a38104 100644 --- a/app/src/processing/app/debug/BasicUploader.java +++ b/app/src/processing/app/debug/BasicUploader.java @@ -126,24 +126,28 @@ public class BasicUploader extends Uploader { throw new RunnerException(e); } - // For Leonardo wait until the bootloader serial port disconnects and the - // sketch serial port reconnects (or timeout after a few seconds if the - // sketch port never comes back). Doing this saves users from accidentally - // opening Serial Monitor on the soon-to-be-orphaned bootloader port. + // Remove the magic baud rate (1200bps) to avoid + // future unwanted board resets try { - if (uploadResult && waitForUploadPort) { - Thread.sleep(500); - long timeout = System.currentTimeMillis() + 2000; - while (timeout > System.currentTimeMillis()) { - List portList = Serial.list(); - String uploadPort = Preferences.get("serial.port"); - if (portList.contains(Preferences.get("serial.port"))) { - // Remove the magic baud rate (1200bps) to avoid - // future unwanted board resets - Serial.touchPort(uploadPort, 9600); - break; + 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 port never comes back). Doing this saves users from accidentally + // opening Serial Monitor on the soon-to-be-orphaned bootloader port. + Thread.sleep(500); + long timeout = System.currentTimeMillis() + 2000; + while (timeout > System.currentTimeMillis()) { + List 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) {