diff --git a/src/cpp/_nix_based/jssc.cpp b/src/cpp/_nix_based/jssc.cpp index 151e0b9..fd6ae27 100644 --- a/src/cpp/_nix_based/jssc.cpp +++ b/src/cpp/_nix_based/jssc.cpp @@ -1,5 +1,5 @@ /* jSSC (Java Simple Serial Connector) - serial port communication library. - * © Alexey Sokolov (scream3r), 2010-2011. + * © Alexey Sokolov (scream3r), 2010-2013. * * This file is part of jSSC. * @@ -51,30 +51,28 @@ * Port opening * In 2.2.0 added useTIOCEXCL and invokedByPortList */ -JNIEXPORT jint JNICALL Java_jssc_SerialNativeInterface_openPort(JNIEnv *env, jobject object, jstring portName, jboolean useTIOCEXCL, jboolean invokedByPortList){ +JNIEXPORT jint JNICALL Java_jssc_SerialNativeInterface_openPort(JNIEnv *env, jobject object, jstring portName, jboolean useTIOCEXCL){ const char* port = env->GetStringUTFChars(portName, JNI_FALSE); jint hComm; hComm = open(port, O_RDWR | O_NOCTTY | O_NDELAY); if(hComm != -1){ - //since 2.2.0 -> + //since 2.2.0 -> (check termios structure for separating real serial devices from others) termios *settings = new termios(); if(tcgetattr(hComm, settings) == 0){ - //<- since 2.2.0 #if defined TIOCEXCL && !defined __SunOS - if(useTIOCEXCL == JNI_TRUE){//since 2.2.0 - ioctl(hComm, TIOCEXCL);//since 0.9 + if(useTIOCEXCL == JNI_TRUE){ + ioctl(hComm, TIOCEXCL); } #endif - if(invokedByPortList == JNI_FALSE){//since 2.2.0 (should not change any flags while using port list, because port can be opened by another application) - int flags = fcntl(hComm, F_GETFL, 0); - flags &= ~O_NDELAY; - fcntl(hComm, F_SETFL, flags); - } + int flags = fcntl(hComm, F_GETFL, 0); + flags &= ~O_NDELAY; + fcntl(hComm, F_SETFL, flags); } else { hComm = -2; } delete settings; + //<- since 2.2.0 } else {//since 0.9 -> if(errno == EBUSY){//Port busy diff --git a/src/cpp/jssc_SerialNativeInterface.h b/src/cpp/jssc_SerialNativeInterface.h index 4bb81cc..b4e555b 100644 --- a/src/cpp/jssc_SerialNativeInterface.h +++ b/src/cpp/jssc_SerialNativeInterface.h @@ -42,10 +42,10 @@ extern "C" { /* * Class: jssc_SerialNativeInterface * Method: openPort - * Signature: (Ljava/lang/String;ZZ)I + * Signature: (Ljava/lang/String;Z)I */ JNIEXPORT jint JNICALL Java_jssc_SerialNativeInterface_openPort - (JNIEnv *, jobject, jstring, jboolean, jboolean); + (JNIEnv *, jobject, jstring, jboolean); /* * Class: jssc_SerialNativeInterface diff --git a/src/java/jssc/SerialNativeInterface.java b/src/java/jssc/SerialNativeInterface.java index 51b37f8..0e78f35 100644 --- a/src/java/jssc/SerialNativeInterface.java +++ b/src/java/jssc/SerialNativeInterface.java @@ -259,13 +259,10 @@ public class SerialNativeInterface { * * @param portName name of port for opening * @param useTIOCEXCL enable/disable using of TIOCEXCL. Take effect only on *nix based systems. - * Ignored if invokedByPortList == true, and always igored on Windows - * @param invokedByPortList if true - open port only for checking handle, not for working. - * Take effect only on *nix based systems. If invokedByPortList == true value of useTIOCEXCL will be ignored * * @return handle of opened port or -1 if opening of the port was unsuccessful */ - public native int openPort(String portName, boolean useTIOCEXCL, boolean invokedByPortList); + public native int openPort(String portName, boolean useTIOCEXCL); /** * Setting the parameters of opened port diff --git a/src/java/jssc/SerialPort.java b/src/java/jssc/SerialPort.java index 54a1330..e9e6d34 100644 --- a/src/java/jssc/SerialPort.java +++ b/src/java/jssc/SerialPort.java @@ -146,7 +146,7 @@ public class SerialPort { throw new SerialPortException(portName, "openPort()", SerialPortException.TYPE_PORT_ALREADY_OPENED); } if(portName != null){ - portHandle = serialInterface.openPort(portName, true, false); + portHandle = serialInterface.openPort(portName, true); } else { throw new SerialPortException(portName, "openPort()", SerialPortException.TYPE_NULL_NOT_PERMITTED);//since 2.1.0 -> NULL port name fix