Fixed "openPort()" invocations in considering of last changes

This commit is contained in:
scream3r 2013-04-17 17:26:26 +04:00
parent 273e132321
commit 6d542e09a1
2 changed files with 15 additions and 8 deletions

View File

@ -146,7 +146,7 @@ public class SerialPort {
throw new SerialPortException(portName, "openPort()", SerialPortException.TYPE_PORT_ALREADY_OPENED); throw new SerialPortException(portName, "openPort()", SerialPortException.TYPE_PORT_ALREADY_OPENED);
} }
if(portName != null){ if(portName != null){
portHandle = serialInterface.openPort(portName); portHandle = serialInterface.openPort(portName, true, false);
} }
else { else {
throw new SerialPortException(portName, "openPort()", SerialPortException.TYPE_NULL_NOT_PERMITTED);//since 2.1.0 -> NULL port name fix throw new SerialPortException(portName, "openPort()", SerialPortException.TYPE_NULL_NOT_PERMITTED);//since 2.1.0 -> NULL port name fix

View File

@ -191,15 +191,22 @@ public class SerialPortList {
String portName = PORTNAMES_PATH + fileName; String portName = PORTNAMES_PATH + fileName;
if(SerialNativeInterface.getOsType() == SerialNativeInterface.OS_LINUX){ if(SerialNativeInterface.getOsType() == SerialNativeInterface.OS_LINUX){
SerialPort serialPort = new SerialPort(portName); SerialPort serialPort = new SerialPort(portName);
try { //try {
serialPort.openPort(); /*serialPort.openPort();
serialPort.closePort(); serialPort.closePort();*/
} int portHandle = serialInterface.openPort(portName, false, true);
catch (SerialPortException ex) { if(portHandle < 0 && portHandle != -1){
if(!ex.getExceptionType().equals(SerialPortException.TYPE_PORT_BUSY)){
continue; continue;
} }
} else if(portHandle != -1) {
serialInterface.closePort(portHandle);
}
//}
//catch (SerialPortException ex) {
// if(!ex.getExceptionType().equals(SerialPortException.TYPE_PORT_BUSY)){
// continue;
// }
//}
} }
portsTree.add(portName); portsTree.add(portName);
} }