Skip to content

Commit ed15dc3

Browse files
committed
Remove 1200 automagic baud rate every time the IDE use the serial port touch
1 parent c97e362 commit ed15dc3

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

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

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -126,24 +126,28 @@ public boolean uploadUsingPreferences(String buildPath, String className,
126126
throw new RunnerException(e);
127127
}
128128

129-
// For Leonardo wait until the bootloader serial port disconnects and the
130-
// sketch serial port reconnects (or timeout after a few seconds if the
131-
// sketch port never comes back). Doing this saves users from accidentally
132-
// opening Serial Monitor on the soon-to-be-orphaned bootloader port.
129+
// Remove the magic baud rate (1200bps) to avoid
130+
// future unwanted board resets
133131
try {
134-
if (uploadResult && waitForUploadPort) {
135-
Thread.sleep(500);
136-
long timeout = System.currentTimeMillis() + 2000;
137-
while (timeout > System.currentTimeMillis()) {
138-
List<String> portList = Serial.list();
139-
String uploadPort = Preferences.get("serial.port");
140-
if (portList.contains(Preferences.get("serial.port"))) {
141-
// Remove the magic baud rate (1200bps) to avoid
142-
// future unwanted board resets
143-
Serial.touchPort(uploadPort, 9600);
144-
break;
132+
if (uploadResult && doTouch) {
133+
String uploadPort = Preferences.get("serial.port");
134+
if (waitForUploadPort) {
135+
// For Due/Leonardo wait until the bootloader serial port disconnects and the
136+
// sketch serial port reconnects (or timeout after a few seconds if the
137+
// sketch port never comes back). Doing this saves users from accidentally
138+
// opening Serial Monitor on the soon-to-be-orphaned bootloader port.
139+
Thread.sleep(500);
140+
long timeout = System.currentTimeMillis() + 2000;
141+
while (timeout > System.currentTimeMillis()) {
142+
List<String> portList = Serial.list();
143+
if (portList.contains(uploadPort)) {
144+
Serial.touchPort(uploadPort, 9600);
145+
break;
146+
}
147+
Thread.sleep(100);
145148
}
146-
Thread.sleep(100);
149+
} else {
150+
Serial.touchPort(uploadPort, 9600);
147151
}
148152
}
149153
} catch (InterruptedException ex) {

0 commit comments

Comments
 (0)