From e23a29229c6ae6c538082300c8cafc87fe7ca5d3 Mon Sep 17 00:00:00 2001 From: scream3r Date: Thu, 18 Apr 2013 10:25:52 +0400 Subject: [PATCH] Cleared "getUnixBasedPortNames()" method is SerialPortList class --- src/java/jssc/SerialPortList.java | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/src/java/jssc/SerialPortList.java b/src/java/jssc/SerialPortList.java index 9237f31..f446eca 100644 --- a/src/java/jssc/SerialPortList.java +++ b/src/java/jssc/SerialPortList.java @@ -190,23 +190,13 @@ public class SerialPortList { if(!file.isDirectory() && !file.isFile() && PORTNAMES_REGEXP.matcher(fileName).find()){ String portName = PORTNAMES_PATH + fileName; if(SerialNativeInterface.getOsType() == SerialNativeInterface.OS_LINUX){ - SerialPort serialPort = new SerialPort(portName); - //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; - // } - //} + int portHandle = serialInterface.openPort(portName, false);//Open port without TIOCEXCL + if(portHandle < 0 && portHandle != -1){//If port handle == -1 it's mean that it's busy + continue; + } + else if(portHandle != -1) { + serialInterface.closePort(portHandle); + } } portsTree.add(portName); }