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:
David A. Mellis 2012-09-09 18:32:16 -04:00
parent 5fa8cd4130
commit e2b99206d8
1 changed files with 27 additions and 23 deletions

View File

@ -187,9 +187,13 @@ public class AvrdudeUploader extends Uploader {
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");
System.out.println("Set baud rate to " + serialRate);
if (verbose || Preferences.getBoolean("upload.verbose"))
System.out.println("Setting baud rate to " + serialRate + " on " + uploadPort);
Serial.touchPort(uploadPort, serialRate);
break;
}