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
|
@ -138,7 +138,7 @@ public class AvrdudeUploader extends Uploader {
|
||||||
// come back, so use a longer time out before assuming that the selected
|
// come back, so use a longer time out before assuming that the selected
|
||||||
// port is the bootloader (not the sketch).
|
// port is the bootloader (not the sketch).
|
||||||
if (((!Base.isWindows() && elapsed >= 500) || elapsed >= 5000) && now.contains(uploadPort)) {
|
if (((!Base.isWindows() && elapsed >= 500) || elapsed >= 5000) && now.contains(uploadPort)) {
|
||||||
if (verbose || Preferences.getBoolean("upload.verbose"))
|
if (verbose || Preferences.getBoolean("upload.verbose"))
|
||||||
System.out.println("Uploading using selected port: " + uploadPort);
|
System.out.println("Uploading using selected port: " + uploadPort);
|
||||||
caterinaUploadPort = uploadPort;
|
caterinaUploadPort = uploadPort;
|
||||||
break;
|
break;
|
||||||
|
@ -174,29 +174,33 @@ public class AvrdudeUploader extends Uploader {
|
||||||
|
|
||||||
boolean avrdudeResult = avrdude(commandDownloader);
|
boolean avrdudeResult = avrdude(commandDownloader);
|
||||||
|
|
||||||
// For Leonardo wait until the bootloader serial port disconnects and the sketch serial
|
// 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).
|
// 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
|
// Doing this saves users from accidentally opening Serial Monitor on the soon-to-be-orphaned
|
||||||
// bootloader port.
|
// bootloader port.
|
||||||
if (true == avrdudeResult && boardPreferences.get("bootloader.path") != null && boardPreferences.get("bootloader.path").equals("caterina")) {
|
if (true == avrdudeResult && boardPreferences.get("bootloader.path") != null && boardPreferences.get("bootloader.path").equals("caterina")) {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(500);
|
Thread.sleep(500);
|
||||||
} catch (InterruptedException ex) { }
|
} catch (InterruptedException ex) { }
|
||||||
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();
|
||||||
uploadPort = Preferences.get("serial.port");
|
uploadPort = Preferences.get("serial.port");
|
||||||
if (portList.contains(uploadPort)) {
|
if (portList.contains(uploadPort)) {
|
||||||
// Remove the magic baud rate (1200bps) to avoid future unwanted board resets
|
try {
|
||||||
int serialRate = Preferences.getInteger("serial.debug_rate");
|
Thread.sleep(100); // delay to avoid port in use and invalid parameters errors
|
||||||
System.out.println("Set baud rate to " + serialRate);
|
} catch (InterruptedException ex) { }
|
||||||
Serial.touchPort(uploadPort, serialRate);
|
// Remove the magic baud rate (1200bps) to avoid future unwanted board resets
|
||||||
break;
|
int serialRate = Preferences.getInteger("serial.debug_rate");
|
||||||
}
|
if (verbose || Preferences.getBoolean("upload.verbose"))
|
||||||
try {
|
System.out.println("Setting baud rate to " + serialRate + " on " + uploadPort);
|
||||||
Thread.sleep(100);
|
Serial.touchPort(uploadPort, serialRate);
|
||||||
} catch (InterruptedException ex) { }
|
break;
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
|
Thread.sleep(100);
|
||||||
|
} catch (InterruptedException ex) { }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return avrdudeResult;
|
return avrdudeResult;
|
||||||
|
|
Loading…
Reference in New Issue