mirror of https://github.com/noisymime/Arduino.git
Tweaks to post-upload touch for Leonardo upload.
Added a delay to avoid exceptions when touching the serial port. Only printing the debug message in verbose mode.
This commit is contained in:
parent
5fa8cd4130
commit
e2b99206d8
|
@ -174,29 +174,33 @@ public class AvrdudeUploader extends Uploader {
|
|||
|
||||
boolean avrdudeResult = avrdude(commandDownloader);
|
||||
|
||||
// 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.
|
||||
// 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.
|
||||
if (true == avrdudeResult && boardPreferences.get("bootloader.path") != null && boardPreferences.get("bootloader.path").equals("caterina")) {
|
||||
try {
|
||||
Thread.sleep(500);
|
||||
} catch (InterruptedException ex) { }
|
||||
long timeout = System.currentTimeMillis() + 2000;
|
||||
while (timeout > System.currentTimeMillis()) {
|
||||
List<String> portList = Serial.list();
|
||||
uploadPort = Preferences.get("serial.port");
|
||||
if (portList.contains(uploadPort)) {
|
||||
// Remove the magic baud rate (1200bps) to avoid future unwanted board resets
|
||||
int serialRate = Preferences.getInteger("serial.debug_rate");
|
||||
System.out.println("Set baud rate to " + serialRate);
|
||||
Serial.touchPort(uploadPort, serialRate);
|
||||
break;
|
||||
}
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
} catch (InterruptedException ex) { }
|
||||
}
|
||||
try {
|
||||
Thread.sleep(500);
|
||||
} catch (InterruptedException ex) { }
|
||||
long timeout = System.currentTimeMillis() + 2000;
|
||||
while (timeout > System.currentTimeMillis()) {
|
||||
List<String> portList = Serial.list();
|
||||
uploadPort = Preferences.get("serial.port");
|
||||
if (portList.contains(uploadPort)) {
|
||||
try {
|
||||
Thread.sleep(100); // delay to avoid port in use and invalid parameters errors
|
||||
} catch (InterruptedException ex) { }
|
||||
// Remove the magic baud rate (1200bps) to avoid future unwanted board resets
|
||||
int serialRate = Preferences.getInteger("serial.debug_rate");
|
||||
if (verbose || Preferences.getBoolean("upload.verbose"))
|
||||
System.out.println("Setting baud rate to " + serialRate + " on " + uploadPort);
|
||||
Serial.touchPort(uploadPort, serialRate);
|
||||
break;
|
||||
}
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
} catch (InterruptedException ex) { }
|
||||
}
|
||||
}
|
||||
|
||||
return avrdudeResult;
|
||||
|
|
Loading…
Reference in New Issue