mirror of
https://github.com/arduino/Arduino.git
synced 2025-01-17 06:52:18 +01:00
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 {
|
||||
SerialPort port;
|
||||
boolean result = false;
|
||||
try {
|
||||
Enumeration portList = CommPortIdentifier.getPortIdentifiers();
|
||||
while (portList.hasMoreElements()) {
|
||||
CommPortIdentifier portId = (CommPortIdentifier) portList.nextElement();
|
||||
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.close();
|
||||
result = true;
|
||||
// Sometime the port close takes a lot to complete, so we run it in a parallel thread
|
||||
new Thread() {
|
||||
public void run() {
|
||||
port.close();
|
||||
};
|
||||
}.start();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} catch (PortInUseException e) {
|
||||
@ -124,7 +127,7 @@ public class Serial implements SerialPortEventListener {
|
||||
I18n.format(_("Error touching serial port ''{0}''."), iname), e
|
||||
);
|
||||
}
|
||||
return result;
|
||||
return false;
|
||||
}
|
||||
|
||||
public Serial(String iname, int irate,
|
||||
|
@ -100,7 +100,7 @@ public class AvrdudeUploader extends Uploader {
|
||||
|
||||
// Wait for a port to appear on the list
|
||||
int elapsed = 0;
|
||||
while (elapsed < 20000) {
|
||||
while (elapsed < 10000) {
|
||||
List<String> now = Serial.list();
|
||||
List<String> diff = new ArrayList<String>(now);
|
||||
diff.removeAll(before);
|
||||
@ -122,8 +122,8 @@ public class AvrdudeUploader extends Uploader {
|
||||
|
||||
// Keep track of port that disappears
|
||||
before = now;
|
||||
Thread.sleep(500);
|
||||
elapsed += 500;
|
||||
Thread.sleep(250);
|
||||
elapsed += 250;
|
||||
|
||||
// If after 5 seconds the selected port is active use that port
|
||||
if (elapsed == 5000 && now.contains(uploadPort)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user