1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-22 08:22:04 +03:00

Auto restart after upload (linux only for now). Auto reset/erase when uploading a new sketch.

This commit is contained in:
Cristian Maglie
2012-08-14 10:05:02 +02:00
parent e2c98640c9
commit df19935d31
5 changed files with 62 additions and 34 deletions

View File

@ -105,9 +105,10 @@ public class Serial implements SerialPortEventListener {
SerialPort port;
boolean result = false;
try {
Enumeration portList = CommPortIdentifier.getPortIdentifiers();
@SuppressWarnings("unchecked")
Enumeration<CommPortIdentifier> portList = CommPortIdentifier.getPortIdentifiers();
while (portList.hasMoreElements()) {
CommPortIdentifier portId = (CommPortIdentifier) portList.nextElement();
CommPortIdentifier portId = portList.nextElement();
if ((CommPortIdentifier.PORT_SERIAL == portId.getPortType()) && (portId.getName().equals(iname))) {
port = (SerialPort) portId.open("tap", 2000);
port.setSerialPortParams(irate, 8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
@ -148,10 +149,10 @@ public class Serial implements SerialPortEventListener {
try {
port = null;
Enumeration portList = CommPortIdentifier.getPortIdentifiers();
@SuppressWarnings("unchecked")
Enumeration<CommPortIdentifier> portList = CommPortIdentifier.getPortIdentifiers();
while (portList.hasMoreElements()) {
CommPortIdentifier portId =
(CommPortIdentifier) portList.nextElement();
CommPortIdentifier portId = portList.nextElement();
if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) {
//System.out.println("found " + portId.getName());

View File

@ -67,7 +67,7 @@ public class BasicUploader extends Uploader {
boolean doTouch = use1200bpsTouch != null && use1200bpsTouch.equals("true");
if (doTouch) {
String uploadPort = prefs.get("serial.port");
String caterinaUploadPort = null;
String newUploadPort = null;
try {
// Toggle 1200 bps on selected serial port to force board reset.
List<String> before = Serial.list();
@ -104,10 +104,10 @@ public class BasicUploader extends Uploader {
System.out.println("}");
}
if (diff.size() > 0) {
caterinaUploadPort = diff.get(0);
newUploadPort = diff.get(0);
if (verbose || Preferences.getBoolean("upload.verbose"))
System.out.println("Found Leonardo upload port: " +
caterinaUploadPort);
System.out.println("Found upload port: " +
newUploadPort);
break;
}
@ -125,16 +125,16 @@ public class BasicUploader extends Uploader {
if (verbose || Preferences.getBoolean("upload.verbose"))
System.out
.println("Uploading using selected port: " + uploadPort);
caterinaUploadPort = uploadPort;
newUploadPort = uploadPort;
break;
}
}
if (caterinaUploadPort == null)
if (newUploadPort == null)
// Something happened while detecting port
throw new RunnerException(
_("Couldnt find a Leonardo on the selected port. Check that you have the correct port selected. If it is correct, try pressing the board's reset button after initiating the upload."));
uploadPort = caterinaUploadPort;
uploadPort = newUploadPort;
} catch (SerialException e) {
throw new RunnerException(e.getMessage());
} catch (InterruptedException e) {