1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-02-18 12:54:25 +01:00

Revert "Speed up on serial port touch"

This reverts commit a5404125f684bb0f837d61676c6212b74f2b111b.
This commit is contained in:
David A. Mellis 2012-03-04 19:29:07 -05:00
parent 18f08bc7d4
commit 4ab241ceb6

View File

@ -102,20 +102,17 @@ 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))) {
final SerialPort port = (SerialPort) portId.open("tap", 2000);
port = (SerialPort) portId.open("tap", 2000);
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();
};
}.start();
return true;
port.close();
result = true;
}
}
} catch (PortInUseException e) {
@ -127,7 +124,7 @@ public class Serial implements SerialPortEventListener {
I18n.format(_("Error touching serial port ''{0}''."), iname), e
);
}
return false;
return result;
}
public Serial(String iname, int irate,