Fixed "openPort()" invocations in considering of last changes
This commit is contained in:
parent
273e132321
commit
6d542e09a1
|
@ -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
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue