mirror of https://github.com/noisymime/Arduino.git
Merge branch 'master' of github.com:arduino/32U4 into LUFA_bootloader
This commit is contained in:
commit
7f76e96574
|
@ -102,17 +102,20 @@ public class Serial implements SerialPortEventListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean touchPort(String iname, int irate) throws SerialException {
|
public static boolean touchPort(String iname, int irate) throws SerialException {
|
||||||
SerialPort port;
|
|
||||||
boolean result = false;
|
|
||||||
try {
|
try {
|
||||||
Enumeration portList = CommPortIdentifier.getPortIdentifiers();
|
Enumeration portList = CommPortIdentifier.getPortIdentifiers();
|
||||||
while (portList.hasMoreElements()) {
|
while (portList.hasMoreElements()) {
|
||||||
CommPortIdentifier portId = (CommPortIdentifier) portList.nextElement();
|
CommPortIdentifier portId = (CommPortIdentifier) portList.nextElement();
|
||||||
if ((CommPortIdentifier.PORT_SERIAL == portId.getPortType()) && (portId.getName().equals(iname))) {
|
if ((CommPortIdentifier.PORT_SERIAL == portId.getPortType()) && (portId.getName().equals(iname))) {
|
||||||
port = (SerialPort) portId.open("tap", 2000);
|
final SerialPort port = (SerialPort) portId.open("tap", 2000);
|
||||||
port.setSerialPortParams(irate, 8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
|
port.setSerialPortParams(irate, 8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
|
||||||
|
// Sometime the port close takes a lot to complete, so we run it in a parallel thread
|
||||||
|
new Thread() {
|
||||||
|
public void run() {
|
||||||
port.close();
|
port.close();
|
||||||
result = true;
|
};
|
||||||
|
}.start();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (PortInUseException e) {
|
} catch (PortInUseException e) {
|
||||||
|
@ -124,7 +127,7 @@ public class Serial implements SerialPortEventListener {
|
||||||
I18n.format(_("Error touching serial port ''{0}''."), iname), e
|
I18n.format(_("Error touching serial port ''{0}''."), iname), e
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return result;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Serial(String iname, int irate,
|
public Serial(String iname, int irate,
|
||||||
|
|
|
@ -100,7 +100,7 @@ public class AvrdudeUploader extends Uploader {
|
||||||
|
|
||||||
// Wait for a port to appear on the list
|
// Wait for a port to appear on the list
|
||||||
int elapsed = 0;
|
int elapsed = 0;
|
||||||
while (elapsed < 20000) {
|
while (elapsed < 10000) {
|
||||||
List<String> now = Serial.list();
|
List<String> now = Serial.list();
|
||||||
List<String> diff = new ArrayList<String>(now);
|
List<String> diff = new ArrayList<String>(now);
|
||||||
diff.removeAll(before);
|
diff.removeAll(before);
|
||||||
|
@ -122,8 +122,8 @@ public class AvrdudeUploader extends Uploader {
|
||||||
|
|
||||||
// Keep track of port that disappears
|
// Keep track of port that disappears
|
||||||
before = now;
|
before = now;
|
||||||
Thread.sleep(500);
|
Thread.sleep(250);
|
||||||
elapsed += 500;
|
elapsed += 250;
|
||||||
|
|
||||||
// If after 5 seconds the selected port is active use that port
|
// If after 5 seconds the selected port is active use that port
|
||||||
if (elapsed == 5000 && now.contains(uploadPort)) {
|
if (elapsed == 5000 && now.contains(uploadPort)) {
|
||||||
|
|
Loading…
Reference in New Issue