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,15 +330,13 @@ public class SerialPortList {
String fileName = file.getName(); String fileName = file.getName();
if(!file.isDirectory() && !file.isFile() && pattern.matcher(fileName).find()){ if(!file.isDirectory() && !file.isFile() && pattern.matcher(fileName).find()){
String portName = searchPath + fileName; String portName = searchPath + fileName;
if(SerialNativeInterface.getOsType() == SerialNativeInterface.OS_LINUX){
int portHandle = serialInterface.openPort(portName, false);//Open port without TIOCEXCL 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 if(portHandle < 0 && portHandle != SerialNativeInterface.ERR_PORT_BUSY){
continue; continue;
} }
else if(portHandle != -1) { else if(portHandle != SerialNativeInterface.ERR_PORT_BUSY) {
serialInterface.closePort(portHandle); serialInterface.closePort(portHandle);
} }
}
portsTree.add(portName); portsTree.add(portName);
} }
} }