Removed port opening only for Linux in "getUnixBasedPortNames()" method of SerialPortList class, now port opening will be used on all _unix_based systems, because it can help to get real serial devices

This commit is contained in:
scream3r 2013-04-22 11:30:55 +04:00
parent 9544ad46cd
commit 3363195bef
1 changed files with 6 additions and 8 deletions

View File

@ -330,14 +330,12 @@ public class SerialPortList {
String fileName = file.getName();
if(!file.isDirectory() && !file.isFile() && pattern.matcher(fileName).find()){
String portName = searchPath + fileName;
if(SerialNativeInterface.getOsType() == SerialNativeInterface.OS_LINUX){
int portHandle = serialInterface.openPort(portName, false);//Open port without TIOCEXCL
if(portHandle < 0 && portHandle != SerialNativeInterface.ERR_PORT_BUSY){//If port handle == -1 it's mean that it's busy
continue;
}
else if(portHandle != -1) {
serialInterface.closePort(portHandle);
}
int portHandle = serialInterface.openPort(portName, false);//Open port without TIOCEXCL
if(portHandle < 0 && portHandle != SerialNativeInterface.ERR_PORT_BUSY){
continue;
}
else if(portHandle != SerialNativeInterface.ERR_PORT_BUSY) {
serialInterface.closePort(portHandle);
}
portsTree.add(portName);
}