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);
}
if(portName != null){
portHandle = serialInterface.openPort(portName);
portHandle = serialInterface.openPort(portName, true, false);
}
else {
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;
if(SerialNativeInterface.getOsType() == SerialNativeInterface.OS_LINUX){
SerialPort serialPort = new SerialPort(portName);
try {
serialPort.openPort();
serialPort.closePort();
}
catch (SerialPortException ex) {
if(!ex.getExceptionType().equals(SerialPortException.TYPE_PORT_BUSY)){
//try {
/*serialPort.openPort();
serialPort.closePort();*/
int portHandle = serialInterface.openPort(portName, false, true);
if(portHandle < 0 && portHandle != -1){
continue;
}
else if(portHandle != -1) {
serialInterface.closePort(portHandle);
}
//}
//catch (SerialPortException ex) {
// if(!ex.getExceptionType().equals(SerialPortException.TYPE_PORT_BUSY)){
// continue;
// }
//}
}
portsTree.add(portName);
}