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:
@ -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());
|
||||
|
@ -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(
|
||||
_("Couldn’t 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) {
|
||||
|
Reference in New Issue
Block a user