Added an isOpen() function call.

This commit is contained in:
hedgecrw85 2015-06-14 16:56:00 -05:00
parent 33df74c31f
commit 85e219a285
7 changed files with 30 additions and 15 deletions

14
INSTALL
View File

@ -123,31 +123,31 @@ Maven:
<dependency>
<groupId>com.fazecast</groupId>
<artifactId>jSerialComm</artifactId>
<version>1.3.4</version>
<version>1.3.5</version>
</dependency>
Ivy:
<dependency org="com.fazecast" name="jSerialComm" rev="1.3.4"/>
<dependency org="com.fazecast" name="jSerialComm" rev="1.3.5"/>
Grape:
@Grapes(
@Grab(group='com.fazecast', module='jSerialComm', version='1.3.4')
@Grab(group='com.fazecast', module='jSerialComm', version='1.3.5')
)
Gradle:
'com.fazecast:jSerialComm:1.3.4'
'com.fazecast:jSerialComm:1.3.5'
Buildr:
'com.fazecast:jSerialComm:jar:1.3.4'
'com.fazecast:jSerialComm:jar:1.3.5'
SBT:
libraryDependencies += "com.fazecast" % "jSerialComm" % "1.3.4"
libraryDependencies += "com.fazecast" % "jSerialComm" % "1.3.5"
Leiningen:
[com.fazecast/jSerialComm "1.3.4"]
[com.fazecast/jSerialComm "1.3.5"]

View File

@ -4,7 +4,7 @@ apply plugin: 'maven'
group = 'com.fazecast'
archivesBaseName = 'jSerialComm'
version = '1.3.4'
version = '1.3.5'
sourceCompatibility = 1.6
targetCompatibility = 1.6

View File

@ -38,7 +38,7 @@ import java.util.Date;
* This class provides native access to serial ports and devices without requiring external libraries or tools.
*
* @author Will Hedgecock &lt;will.hedgecock@fazecast.com&gt;
* @version 1.3.4
* @version 1.3.5
* @see java.io.InputStream
* @see java.io.OutputStream
*/
@ -257,12 +257,18 @@ public final class SerialPort
* Opens this serial port for reading and writing.
* <p>
* All serial port parameters or timeouts can be changed at any time after the port has been opened.
* <p>
* Note that calling this method on an already opened port will simply return a value of true.
*
* @return Whether the port was successfully opened.
*/
public final boolean openPort()
{
// If this is an Android application, we must explicitly allow serial port access to this library
// Return true if already opened
if (isOpened)
return true;
// If this is an Android root application, we must explicitly allow serial port access to this library
if (isAndroid)
{
try
@ -277,7 +283,7 @@ public final class SerialPort
}
try { Thread.sleep(500); } catch (Exception e) {}
if (!isOpened && (portHandle = openPortNative()) > 0)
if ((portHandle = openPortNative()) > 0)
{
inputStream = new SerialPortInputStream();
outputStream = new SerialPortOutputStream();
@ -289,6 +295,8 @@ public final class SerialPort
/**
* Closes this serial port.
* <p>
* Note that calling this method on an already closed port will simply return a value of true.
*
* @return Whether the port was successfully closed.
*/
@ -305,6 +313,13 @@ public final class SerialPort
return !isOpened;
}
/**
* Returns whether the port is currently open and available for communication.
*
* @return Whether the port is opened.
*/
public final boolean isOpen() { return isOpened; }
// Serial Port Setup Methods
private static native void initializeLibrary(); // Initializes the JNI code
private static native void uninitializeLibrary(); // Un-initializes the JNI code

View File

@ -31,7 +31,7 @@ import java.util.EventListener;
* This interface must be implemented to enable simple event-based serial port I/O.
*
* @author Will Hedgecock &lt;will.hedgecock@fazecast.com&gt;
* @version 1.3.4
* @version 1.3.5
* @see java.util.EventListener
*/
public interface SerialPortDataListener extends EventListener

View File

@ -31,7 +31,7 @@ import java.util.EventObject;
* This class describes an asynchronous serial port event.
*
* @author Will Hedgecock &lt;will.hedgecock@fazecast.com&gt;
* @version 1.3.4
* @version 1.3.5
* @see java.util.EventObject
*/
public final class SerialPortEvent extends EventObject

View File

@ -31,7 +31,7 @@ package com.fazecast.jSerialComm;
* <i>Note</i>: Using this interface will negate any serial port read timeout settings since they make no sense in an asynchronous context.
*
* @author Will Hedgecock &lt;will.hedgecock@fazecast.com&gt;
* @version 1.3.4
* @version 1.3.5
* @see com.fazecast.jSerialComm.SerialPortDataListener
* @see java.util.EventListener
*/

View File

@ -32,7 +32,7 @@ import java.util.Scanner;
* This class provides a test case for the jSerialComm library.
*
* @author Will Hedgecock &lt;will.hedgecock@gmail.com&gt;
* @version 1.3.4
* @version 1.3.5
* @see java.io.InputStream
* @see java.io.OutputStream
*/