Add ability to get library version programmatically with getVersion()
This commit is contained in:
parent
206d1721a9
commit
15a24d4cf6
|
@ -2,7 +2,7 @@
|
|||
* SerialPort.java
|
||||
*
|
||||
* Created on: Feb 25, 2012
|
||||
* Last Updated on: Mar 19, 2019
|
||||
* Last Updated on: Mar 22, 2019
|
||||
* Author: Will Hedgecock
|
||||
*
|
||||
* Copyright (C) 2012-2019 Fazecast, Inc.
|
||||
|
@ -39,19 +39,19 @@ import java.io.InputStreamReader;
|
|||
import java.io.OutputStream;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* This class provides native access to serial ports and devices without requiring external libraries or tools.
|
||||
*
|
||||
* @author Will Hedgecock <will.hedgecock@fazecast.com>
|
||||
* @version 2.5.0
|
||||
* @version 2.5.1
|
||||
* @see java.io.InputStream
|
||||
* @see java.io.OutputStream
|
||||
*/
|
||||
public final class SerialPort
|
||||
{
|
||||
// Static initializer loads correct native library for this machine
|
||||
private static final String versionString = "2.5.1";
|
||||
private static volatile boolean isAndroid = false;
|
||||
private static volatile boolean isUnixBased = false;
|
||||
private static volatile boolean isWindows = false;
|
||||
|
@ -265,7 +265,14 @@ public final class SerialPort
|
|||
* @return The port description as reported by the device itself.
|
||||
*/
|
||||
@Override
|
||||
public String toString() { return getPortDescription(); }
|
||||
public String toString() { return getPortDescription(); }
|
||||
|
||||
/**
|
||||
* Returns the current version of the jSerialComm library.
|
||||
*
|
||||
* @return The current library version.
|
||||
*/
|
||||
static public String getVersion() { return versionString; }
|
||||
|
||||
/**
|
||||
* Returns a list of all available serial ports on this machine.
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* SerialPortTest.java
|
||||
*
|
||||
* Created on: Feb 27, 2015
|
||||
* Last Updated on: Mar 19, 2019
|
||||
* Last Updated on: Mar 22, 2019
|
||||
* Author: Will Hedgecock
|
||||
*
|
||||
* Copyright (C) 2012-2019 Fazecast, Inc.
|
||||
|
@ -26,14 +26,13 @@
|
|||
package com.fazecast.jSerialComm;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
* This class provides a test case for the jSerialComm library.
|
||||
*
|
||||
* @author Will Hedgecock <will.hedgecock@gmail.com>
|
||||
* @version 2.5.0
|
||||
* @version 2.5.1
|
||||
* @see java.io.InputStream
|
||||
* @see java.io.OutputStream
|
||||
*/
|
||||
|
@ -84,6 +83,7 @@ public class SerialPortTest
|
|||
|
||||
static public void main(String[] args)
|
||||
{
|
||||
System.out.println("\nUsing Library Version v" + SerialPort.getVersion());
|
||||
SerialPort[] ports = SerialPort.getCommPorts();
|
||||
System.out.println("\nAvailable Ports:\n");
|
||||
for (int i = 0; i < ports.length; ++i)
|
||||
|
|
Loading…
Reference in New Issue