diff --git a/binaries/jSerialComm-1.3.2-test.jar b/binaries/jSerialComm-1.3.3-test.jar
similarity index 91%
rename from binaries/jSerialComm-1.3.2-test.jar
rename to binaries/jSerialComm-1.3.3-test.jar
index 2d489a4..dbbb0c8 100644
Binary files a/binaries/jSerialComm-1.3.2-test.jar and b/binaries/jSerialComm-1.3.3-test.jar differ
diff --git a/binaries/jSerialComm-1.3.2.jar b/binaries/jSerialComm-1.3.3.jar
similarity index 93%
rename from binaries/jSerialComm-1.3.2.jar
rename to binaries/jSerialComm-1.3.3.jar
index b0d90fd..62cf2e7 100644
Binary files a/binaries/jSerialComm-1.3.2.jar and b/binaries/jSerialComm-1.3.3.jar differ
diff --git a/images/Thumbs.db b/images/Thumbs.db
new file mode 100644
index 0000000..e7204b1
Binary files /dev/null and b/images/Thumbs.db differ
diff --git a/index.html b/index.html
index 678bbfa..e697d85 100644
--- a/index.html
+++ b/index.html
@@ -29,7 +29,7 @@
One of the most convenient features of this library is that it allows you to simply include the JAR file in your custom project, and it will automatically select and load the correct native library for your platform and architecture. As such, you can make use of this library by simply copying the jSerialComm.jar file into your project directory and linking to it as you would any other JAR file.
+One of the most convenient features of this library is that it allows you to simply include the JAR file in your custom project, and it will automatically select and load the correct native library for your platform and architecture. As such, you can make use of this library by simply copying the jSerialComm.jar file into your project directory and linking to it as you would any other JAR file.
To access the contents of the library in your project, make sure to import com.fazecast.jSerialComm.*
into your java files. You can then generate a list of all available serial ports on your system (real or virtual), by calling the following static method:
<dependency>
<groupId>com.fazecast</groupId>
<artifactId>jSerialComm</artifactId>
<version>1.3.2</version>
</dependency>
+ <dependency>
<groupId>com.fazecast</groupId>
<artifactId>jSerialComm</artifactId>
<version>1.3.3</version>
</dependency>
<dependency org="com.fazecast" name="jSerialComm" rev="1.3.2"/>
+ <dependency org="com.fazecast" name="jSerialComm" rev="1.3.3"/>
@Grapes(
@Grab(group='com.fazecast', module='jSerialComm', version='1.3.2')
)
+ @Grapes(
@Grab(group='com.fazecast', module='jSerialComm', version='1.3.3')
)
'com.fazecast:jSerialComm:1.3.2'
+ 'com.fazecast:jSerialComm:1.3.3'
'com.fazecast:jSerialComm:jar:1.3.2'
+ 'com.fazecast:jSerialComm:jar:1.3.3'
libraryDependencies += "com.fazecast" % "jSerialComm" % "1.3.2"
+ libraryDependencies += "com.fazecast" % "jSerialComm" % "1.3.3"
[com.fazecast/jSerialComm "1.3.2"]
+ [com.fazecast/jSerialComm "1.3.3"]
SerialPort
+ +SerialPortDataListener + +SerialPortEvent + +SerialPortPacketListener + + |
+
SerialPort
+ +SerialPortDataListener + +SerialPortEvent + +SerialPortPacketListener + + |
+
public final class SerialPort -extends Object-
InputStream
,
-OutputStream
+java.lang.Object + com.fazecast.jSerialComm.SerialPort ++
public final class SerialPort
+This class provides native access to serial ports and devices without requiring external libraries or tools. +
+ +
+
InputStream
,
+OutputStream
-
Modifier and Type | -Field and Description | -
---|---|
static int |
-EVEN_PARITY |
-
static int |
-FLOW_CONTROL_CTS_ENABLED |
-
static int |
-FLOW_CONTROL_DISABLED |
-
static int |
-FLOW_CONTROL_DSR_ENABLED |
-
static int |
-FLOW_CONTROL_DTR_ENABLED |
-
static int |
-FLOW_CONTROL_RTS_ENABLED |
-
static int |
-FLOW_CONTROL_XONXOFF_IN_ENABLED |
-
static int |
-FLOW_CONTROL_XONXOFF_OUT_ENABLED |
-
static int |
-LISTENING_EVENT_DATA_AVAILABLE |
-
static int |
-LISTENING_EVENT_DATA_RECEIVED |
-
static int |
-LISTENING_EVENT_DATA_WRITTEN |
-
static int |
-MARK_PARITY |
-
static int |
-NO_PARITY |
-
static int |
-ODD_PARITY |
-
static int |
-ONE_POINT_FIVE_STOP_BITS |
-
static int |
-ONE_STOP_BIT |
-
static int |
-SPACE_PARITY |
-
static int |
-TIMEOUT_NONBLOCKING |
-
static int |
-TIMEOUT_READ_BLOCKING |
-
static int |
-TIMEOUT_READ_SEMI_BLOCKING |
-
static int |
-TIMEOUT_SCANNER |
-
static int |
-TIMEOUT_WRITE_BLOCKING |
-
static int |
-TIMEOUT_WRITE_SEMI_BLOCKING |
-
static int |
-TWO_STOP_BITS |
-
+Field Summary | +|
---|---|
+static int |
+EVEN_PARITY
+
++ |
+
+static int |
+FLOW_CONTROL_CTS_ENABLED
+
++ |
+
+static int |
+FLOW_CONTROL_DISABLED
+
++ |
+
+static int |
+FLOW_CONTROL_DSR_ENABLED
+
++ |
+
+static int |
+FLOW_CONTROL_DTR_ENABLED
+
++ |
+
+static int |
+FLOW_CONTROL_RTS_ENABLED
+
++ |
+
+static int |
+FLOW_CONTROL_XONXOFF_IN_ENABLED
+
++ |
+
+static int |
+FLOW_CONTROL_XONXOFF_OUT_ENABLED
+
++ |
+
+static int |
+LISTENING_EVENT_DATA_AVAILABLE
+
++ |
+
+static int |
+LISTENING_EVENT_DATA_RECEIVED
+
++ |
+
+static int |
+LISTENING_EVENT_DATA_WRITTEN
+
++ |
+
+static int |
+MARK_PARITY
+
++ |
+
+static int |
+NO_PARITY
+
++ |
+
+static int |
+ODD_PARITY
+
++ |
+
+static int |
+ONE_POINT_FIVE_STOP_BITS
+
++ |
+
+static int |
+ONE_STOP_BIT
+
++ |
+
+static int |
+SPACE_PARITY
+
++ |
+
+static int |
+TIMEOUT_NONBLOCKING
+
++ |
+
+static int |
+TIMEOUT_READ_BLOCKING
+
++ |
+
+static int |
+TIMEOUT_READ_SEMI_BLOCKING
+
++ |
+
+static int |
+TIMEOUT_SCANNER
+
++ |
+
+static int |
+TIMEOUT_WRITE_BLOCKING
+
++ |
+
+static int |
+TIMEOUT_WRITE_SEMI_BLOCKING
+
++ |
+
+static int |
+TWO_STOP_BITS
+
++ |
+
Modifier and Type | -Method and Description | -
---|---|
boolean |
-addDataListener(SerialPortDataListener listener)
-Adds a
-SerialPortDataListener to the serial port interface. |
-
int |
-bytesAvailable()
-Returns the number of bytes available without blocking if
-readBytes(byte[], long) were to be called immediately
- after this method returns. |
-
boolean |
-closePort()
-Closes this serial port.
- |
-
int |
-getBaudRate()
-Gets the current baud rate of the serial port.
- |
-
static SerialPort |
-getCommPort(String portDescriptor)
-Allocates a
-SerialPort object corresponding to the user-specified port descriptor. |
-
static SerialPort[] |
-getCommPorts()
-Returns a list of all available serial ports on this machine.
- |
-
String |
-getDescriptivePortName()
-Gets a descriptive string representing this serial port or the device connected to it.
- |
-
int |
-getFlowControlSettings()
-Returns the flow control settings enabled on this serial port.
- |
-
InputStream |
-getInputStream()
-Returns an
-InputStream object associated with this serial port. |
-
int |
-getNumDataBits()
-Gets the current number of data bits per word.
- |
-
int |
-getNumStopBits()
-Gets the current number of stop bits per word.
- |
-
OutputStream |
-getOutputStream()
-Returns an
-OutputStream object associated with this serial port. |
-
int |
-getParity()
-Gets the current parity error-checking scheme.
- |
-
int |
-getReadTimeout()
-Gets the number of milliseconds of inactivity to tolerate before returning from a
-readBytes(byte[],long) call. |
-
String |
-getSystemPortName()
-Gets the operating system-defined device name corresponding to this serial port.
- |
-
int |
-getWriteTimeout()
-Gets the number of milliseconds of inactivity to tolerate before returning from a
-writeBytes(byte[],long) call. |
-
boolean |
-openPort()
-Opens this serial port for reading and writing.
- |
-
int |
-readBytes(byte[] buffer,
- long bytesToRead)
-Reads up to bytesToRead raw data bytes from the serial port and stores them in the buffer.
- |
-
void |
-removeDataListener()
-Removes the associated
-SerialPortDataListener from the serial port interface. |
-
void |
-setBaudRate(int newBaudRate)
-Sets the desired baud rate for this serial port.
- |
-
void |
-setComPortParameters(int newBaudRate,
- int newDataBits,
- int newStopBits,
- int newParity)
-Sets all serial port parameters at one time.
- |
-
void |
-setComPortTimeouts(int newTimeoutMode,
- int newReadTimeout,
- int newWriteTimeout)
-Sets the serial port read and write timeout parameters.
- |
-
void |
-setFlowControl(int newFlowControlSettings)
-Specifies what kind of flow control to enable for this serial port.
- |
-
void |
-setNumDataBits(int newDataBits)
-Sets the desired number of data bits per word.
- |
-
void |
-setNumStopBits(int newStopBits)
-Sets the desired number of stop bits per word.
- |
-
void |
-setParity(int newParity)
-Sets the desired parity error-detection scheme to be used.
- |
-
int |
-writeBytes(byte[] buffer,
- long bytesToWrite)
-Writes up to bytesToWrite raw data bytes from the buffer parameter to the serial port.
- |
-
+Method Summary | +|
---|---|
+ boolean |
+addDataListener(SerialPortDataListener listener)
+
++ Adds a SerialPortDataListener to the serial port interface. |
+
+ int |
+bytesAvailable()
+
++ Returns the number of bytes available without blocking if readBytes(byte[], long) were to be called immediately
+ after this method returns. |
+
+ boolean |
+closePort()
+
++ Closes this serial port. |
+
+ int |
+getBaudRate()
+
++ Gets the current baud rate of the serial port. |
+
+static SerialPort |
+getCommPort(String portDescriptor)
+
++ Allocates a SerialPort object corresponding to the user-specified port descriptor. |
+
+static SerialPort[] |
+getCommPorts()
+
++ Returns a list of all available serial ports on this machine. |
+
+ String |
+getDescriptivePortName()
+
++ Gets a descriptive string representing this serial port or the device connected to it. |
+
+ int |
+getFlowControlSettings()
+
++ Returns the flow control settings enabled on this serial port. |
+
+ InputStream |
+getInputStream()
+
++ Returns an InputStream object associated with this serial port. |
+
+ int |
+getNumDataBits()
+
++ Gets the current number of data bits per word. |
+
+ int |
+getNumStopBits()
+
++ Gets the current number of stop bits per word. |
+
+ OutputStream |
+getOutputStream()
+
++ Returns an OutputStream object associated with this serial port. |
+
+ int |
+getParity()
+
++ Gets the current parity error-checking scheme. |
+
+ int |
+getReadTimeout()
+
++ Gets the number of milliseconds of inactivity to tolerate before returning from a readBytes(byte[],long) call. |
+
+ String |
+getSystemPortName()
+
++ Gets the operating system-defined device name corresponding to this serial port. |
+
+ int |
+getWriteTimeout()
+
++ Gets the number of milliseconds of inactivity to tolerate before returning from a writeBytes(byte[],long) call. |
+
+ boolean |
+openPort()
+
++ Opens this serial port for reading and writing. |
+
+ int |
+readBytes(byte[] buffer,
+ long bytesToRead)
+
++ Reads up to bytesToRead raw data bytes from the serial port and stores them in the buffer. |
+
+ void |
+removeDataListener()
+
++ Removes the associated SerialPortDataListener from the serial port interface. |
+
+ void |
+setBaudRate(int newBaudRate)
+
++ Sets the desired baud rate for this serial port. |
+
+ void |
+setComPortParameters(int newBaudRate,
+ int newDataBits,
+ int newStopBits,
+ int newParity)
+
++ Sets all serial port parameters at one time. |
+
+ void |
+setComPortTimeouts(int newTimeoutMode,
+ int newReadTimeout,
+ int newWriteTimeout)
+
++ Sets the serial port read and write timeout parameters. |
+
+ void |
+setFlowControl(int newFlowControlSettings)
+
++ Specifies what kind of flow control to enable for this serial port. |
+
+ void |
+setNumDataBits(int newDataBits)
+
++ Sets the desired number of data bits per word. |
+
+ void |
+setNumStopBits(int newStopBits)
+
++ Sets the desired number of stop bits per word. |
+
+ void |
+setParity(int newParity)
+
++ Sets the desired parity error-detection scheme to be used. |
+
+ int |
+writeBytes(byte[] buffer,
+ long bytesToWrite)
+
++ Writes up to bytesToWrite raw data bytes from the buffer parameter to the serial port. |
+
Methods inherited from class java.lang.Object | +
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
+
+ -
public static final int NO_PARITY-
public static final int ODD_PARITY-
public static final int EVEN_PARITY-
public static final int MARK_PARITY-
public static final int SPACE_PARITY-
public static final int ONE_STOP_BIT-
public static final int ONE_POINT_FIVE_STOP_BITS-
public static final int TWO_STOP_BITS-
public static final int FLOW_CONTROL_DISABLED-
public static final int FLOW_CONTROL_RTS_ENABLED-
public static final int FLOW_CONTROL_CTS_ENABLED-
public static final int FLOW_CONTROL_DSR_ENABLED-
public static final int FLOW_CONTROL_DTR_ENABLED-
public static final int FLOW_CONTROL_XONXOFF_IN_ENABLED-
public static final int FLOW_CONTROL_XONXOFF_OUT_ENABLED-
public static final int TIMEOUT_NONBLOCKING-
public static final int TIMEOUT_READ_SEMI_BLOCKING-
public static final int TIMEOUT_WRITE_SEMI_BLOCKING-
public static final int TIMEOUT_READ_BLOCKING-
public static final int TIMEOUT_WRITE_BLOCKING-
public static final int TIMEOUT_SCANNER-
public static final int LISTENING_EVENT_DATA_AVAILABLE-
public static final int LISTENING_EVENT_DATA_RECEIVED-
public static final int LISTENING_EVENT_DATA_WRITTEN-
+Field Detail | +
---|
+public static final int NO_PARITY+
+public static final int ODD_PARITY+
+public static final int EVEN_PARITY+
+public static final int MARK_PARITY+
+public static final int SPACE_PARITY+
+public static final int ONE_STOP_BIT+
+public static final int ONE_POINT_FIVE_STOP_BITS+
+public static final int TWO_STOP_BITS+
+public static final int FLOW_CONTROL_DISABLED+
+public static final int FLOW_CONTROL_RTS_ENABLED+
+public static final int FLOW_CONTROL_CTS_ENABLED+
+public static final int FLOW_CONTROL_DSR_ENABLED+
+public static final int FLOW_CONTROL_DTR_ENABLED+
+public static final int FLOW_CONTROL_XONXOFF_IN_ENABLED+
+public static final int FLOW_CONTROL_XONXOFF_OUT_ENABLED+
+public static final int TIMEOUT_NONBLOCKING+
+public static final int TIMEOUT_READ_SEMI_BLOCKING+
+public static final int TIMEOUT_WRITE_SEMI_BLOCKING+
+public static final int TIMEOUT_READ_BLOCKING+
+public static final int TIMEOUT_WRITE_BLOCKING+
+public static final int TIMEOUT_SCANNER+
+public static final int LISTENING_EVENT_DATA_AVAILABLE+
+public static final int LISTENING_EVENT_DATA_RECEIVED+
+public static final int LISTENING_EVENT_DATA_WRITTEN+
public static SerialPort[] getCommPorts()-
+Method Detail | +
---|
+public static SerialPort[] getCommPorts()+
The serial ports can be accessed by iterating through each of the SerialPort objects in this array.
- Note that the openPort()
method must be called before any attempts to read from or write to the port. Likewise, closePort()
should be called when you are finished accessing the port.
+ Note that the openPort()
method must be called before any attempts to read from or write to the port. Likewise, closePort()
should be called when you are finished accessing the port.
- All serial port parameters or timeouts can be changed at any time after the port has been opened.
SerialPort
objects.public static SerialPort getCommPort(String portDescriptor)-
SerialPort
object corresponding to the user-specified port descriptor.
+ All serial port parameters or timeouts can be changed at any time after the port has been opened.
++
SerialPort
objects.+public static SerialPort getCommPort(String portDescriptor)+
SerialPort
object corresponding to the user-specified port descriptor.
On Windows machines, this descriptor should be in the form of "COM[*]".
- On Linux machines, the descriptor will look similar to "/dev/tty[*]".
portDescriptor
- The desired serial port to use with this library.public final boolean openPort()-
+
portDescriptor
- The desired serial port to use with this library.
++public final boolean openPort()+
- All serial port parameters or timeouts can be changed at any time after the port has been opened.
public final boolean closePort()-
public final int bytesAvailable()-
readBytes(byte[], long)
were to be called immediately
- after this method returns.public final int readBytes(byte[] buffer, - long bytesToRead)-
+
+public final boolean closePort()+
+
+public final int bytesAvailable()+
readBytes(byte[], long)
were to be called immediately
+ after this method returns.
++
+public final int readBytes(byte[] buffer, + long bytesToRead)+
The length of the byte buffer must be greater than or equal to the value passed in for bytesToRead
If no timeouts were specified or the read timeout was set to 0, this call will block until bytesToRead bytes of data have been successfully read from the serial port. Otherwise, this method will return after bytesToRead bytes of data have been read or the number of milliseconds specified by the read timeout have elapsed, - whichever comes first, regardless of the availability of more data.
buffer
- The buffer into which the raw data is read.bytesToRead
- The number of bytes to read from the serial port.public final int writeBytes(byte[] buffer, - long bytesToWrite)-
+
buffer
- The buffer into which the raw data is read.bytesToRead
- The number of bytes to read from the serial port.
++public final int writeBytes(byte[] buffer, + long bytesToWrite)+
The length of the byte buffer must be greater than or equal to the value passed in for bytesToWrite
If no timeouts were specified or the write timeout was set to 0, this call will block until bytesToWrite bytes of data have been successfully written the serial port. Otherwise, this method will return after bytesToWrite bytes of data have been written or the number of milliseconds specified by the write timeout have elapsed, - whichever comes first, regardless of the availability of more data.
buffer
- The buffer containing the raw data to write to the serial port.bytesToWrite
- The number of bytes to write to the serial port.public final boolean addDataListener(SerialPortDataListener listener)-
SerialPortDataListener
to the serial port interface.
+ whichever comes first, regardless of the availability of more data.
++
buffer
- The buffer containing the raw data to write to the serial port.bytesToWrite
- The number of bytes to write to the serial port.
++public final boolean addDataListener(SerialPortDataListener listener)+
SerialPortDataListener
to the serial port interface.
- Calling this function enables event-based serial port callbacks to be used instead of, or in addition to, direct serial port read/write calls or the InputStream
/OutputStream
interface.
+ Calling this function enables event-based serial port callbacks to be used instead of, or in addition to, direct serial port read/write calls or the InputStream
/OutputStream
interface.
- The parameter passed into this method must be an implementation of either the SerialPortDataListener
or the SerialPortPacketListener
.
- The SerialPortPacketListener
interface must be used if you plan to use event-based reading of full data packets over the serial port.
- Otherwise, the simpler SerialPortDataListener
may be used.
+ The parameter passed into this method must be an implementation of either the SerialPortDataListener
or the SerialPortPacketListener
.
+ The SerialPortPacketListener
interface must be used if you plan to use event-based reading of full data packets over the serial port.
+ Otherwise, the simpler SerialPortDataListener
may be used.
Only one listener can be registered at a time; however, that listener can be used to detect multiple types of serial port events.
- Refer to SerialPortDataListener
and SerialPortPacketListener
for more information.
listener
- A SerialPortDataListener
or SerialPortPacketListener
implementation to be used for event-based serial port communications.SerialPortDataListener
,
-SerialPortPacketListener
public final void removeDataListener()-
SerialPortDataListener
from the serial port interface.public final InputStream getInputStream()-
InputStream
object associated with this serial port.
+ Refer to SerialPortDataListener
and SerialPortPacketListener
for more information.
++
listener
- A SerialPortDataListener
or SerialPortPacketListener
implementation to be used for event-based serial port communications.
+SerialPortDataListener
,
+SerialPortPacketListener
+public final void removeDataListener()+
SerialPortDataListener
from the serial port interface.
++
+public final InputStream getInputStream()+
InputStream
object associated with this serial port.
Allows for easier read access of the underlying data stream and abstracts away many low-level read details.
- Make sure to call the InputStream.close()
method when you are done using this stream.
InputStream
object associated with this serial port.InputStream
public final OutputStream getOutputStream()-
OutputStream
object associated with this serial port.
+ Make sure to call the InputStream.close()
method when you are done using this stream.
++
InputStream
object associated with this serial port.InputStream
+public final OutputStream getOutputStream()+
OutputStream
object associated with this serial port.
Allows for easier write access to the underlying data stream and abstracts away many low-level writing details.
- Make sure to call the OutputStream.close()
method when you are done using this stream.
OutputStream
object associated with this serial port.OutputStream
public final void setComPortParameters(int newBaudRate, + Make sure to call theOutputStream.close()
method when you are done using this stream. ++
OutputStream
object associated with this serial port.OutputStream
+public final void setComPortParameters(int newBaudRate, int newDataBits, int newStopBits, - int newParity)-
Allows the user to set all port parameters with a single function call.
@@ -984,434 +1028,401 @@ extends ONE_STOP_BIT
, ONE_POINT_FIVE_STOP_BITS
, TWO_STOP_BITS
).
+ constants for this parameter (ONE_STOP_BIT
, ONE_POINT_FIVE_STOP_BITS
, TWO_STOP_BITS
).
The parity parameter specifies how error detection is carried out. Again, the built-in constants should be used.
- Acceptable values are NO_PARITY
, EVEN_PARITY
, ODD_PARITY
, MARK_PARITY
, and SPACE_PARITY
.
newBaudRate
- The desired baud rate for this serial port.newDataBits
- The number of data bits to use per word.newStopBits
- The number of stop bits to use.newParity
- The type of parity error-checking desired.ONE_STOP_BIT
,
-ONE_POINT_FIVE_STOP_BITS
,
-TWO_STOP_BITS
,
-NO_PARITY
,
-EVEN_PARITY
,
-ODD_PARITY
,
-MARK_PARITY
,
-SPACE_PARITY
public final void setComPortTimeouts(int newTimeoutMode, + Acceptable values areNO_PARITY
,EVEN_PARITY
,ODD_PARITY
,MARK_PARITY
, andSPACE_PARITY
. ++
newBaudRate
- The desired baud rate for this serial port.newDataBits
- The number of data bits to use per word.newStopBits
- The number of stop bits to use.newParity
- The type of parity error-checking desired.ONE_STOP_BIT
,
+ONE_POINT_FIVE_STOP_BITS
,
+TWO_STOP_BITS
,
+NO_PARITY
,
+EVEN_PARITY
,
+ODD_PARITY
,
+MARK_PARITY
,
+SPACE_PARITY
+public final void setComPortTimeouts(int newTimeoutMode, int newReadTimeout, - int newWriteTimeout)-
- The built-in timeout mode constants should be used (TIMEOUT_NONBLOCKING
, TIMEOUT_READ_SEMI_BLOCKING
,
- TIMEOUT_WRITE_SEMI_BLOCKING
, TIMEOUT_READ_BLOCKING
, TIMEOUT_WRITE_BLOCKING
, TIMEOUT_SCANNER
) to specify how
+ The built-in timeout mode constants should be used (TIMEOUT_NONBLOCKING
, TIMEOUT_READ_SEMI_BLOCKING
,
+ TIMEOUT_WRITE_SEMI_BLOCKING
, TIMEOUT_READ_BLOCKING
, TIMEOUT_WRITE_BLOCKING
, TIMEOUT_SCANNER
) to specify how
timeouts are to be handled.
Valid modes are:
- Non-blocking: TIMEOUT_NONBLOCKING
- Read Semi-blocking: TIMEOUT_READ_SEMI_BLOCKING
- Read/Write Semi-blocking: TIMEOUT_READ_SEMI_BLOCKING
| TIMEOUT_WRITE_SEMI_BLOCKING
- Read Semi-Blocking/Write Full-blocking: TIMEOUT_READ_SEMI_BLOCKING
| TIMEOUT_WRITE_BLOCKING
- Read Full-blocking: TIMEOUT_READ_BLOCKING
- Read Full-blocking/Write Semi-blocking: TIMEOUT_READ_BLOCKING
| TIMEOUT_WRITE_SEMI_BLOCKING
- Read/Write Full-blocking: TIMEOUT_READ_BLOCKING
| TIMEOUT_WRITE_BLOCKING
- Scanner: TIMEOUT_SCANNER
+ Non-blocking: TIMEOUT_NONBLOCKING
+ Read Semi-blocking: TIMEOUT_READ_SEMI_BLOCKING
+ Read/Write Semi-blocking: TIMEOUT_READ_SEMI_BLOCKING
| TIMEOUT_WRITE_SEMI_BLOCKING
+ Read Semi-Blocking/Write Full-blocking: TIMEOUT_READ_SEMI_BLOCKING
| TIMEOUT_WRITE_BLOCKING
+ Read Full-blocking: TIMEOUT_READ_BLOCKING
+ Read Full-blocking/Write Semi-blocking: TIMEOUT_READ_BLOCKING
| TIMEOUT_WRITE_SEMI_BLOCKING
+ Read/Write Full-blocking: TIMEOUT_READ_BLOCKING
| TIMEOUT_WRITE_BLOCKING
+ Scanner: TIMEOUT_SCANNER
- The TIMEOUT_NONBLOCKING
mode specifies that the corresponding readBytes(byte[],long)
or writeBytes(byte[],long)
call
+ The TIMEOUT_NONBLOCKING
mode specifies that the corresponding readBytes(byte[],long)
or writeBytes(byte[],long)
call
will return immediately with any available data.
- The TIMEOUT_READ_SEMI_BLOCKING
or TIMEOUT_WRITE_SEMI_BLOCKING
modes specify that the corresponding calls will block until either
+ The TIMEOUT_READ_SEMI_BLOCKING
or TIMEOUT_WRITE_SEMI_BLOCKING
modes specify that the corresponding calls will block until either
newReadTimeout or newWriteTimeout milliseconds of inactivity have elapsed or at least 1 byte of data can be written or read.
- The TIMEOUT_READ_BLOCKING
or TIMEOUT_WRITE_BLOCKING
modes specify that the corresponding call will block until either
+ The TIMEOUT_READ_BLOCKING
or TIMEOUT_WRITE_BLOCKING
modes specify that the corresponding call will block until either
newReadTimeout or newWriteTimeout milliseconds have elapsed since the start of the call or the total number of requested bytes can be written or
returned.
- The TIMEOUT_SCANNER
mode is intended for use with the Java Scanner
class for reading from the serial port. In this mode,
+ The TIMEOUT_SCANNER
mode is intended for use with the Java Scanner
class for reading from the serial port. In this mode,
manually specified timeouts are ignored to ensure compatibility with the Java specification.
- A value of 0 for either newReadTimeout or newWriteTimeout indicates that a readBytes(byte[],long)
or
- writeBytes(byte[],long)
call should block forever until it can return successfully (based upon the current timeout mode specified).
newTimeoutMode
- The new timeout mode as specified above.newReadTimeout
- The number of milliseconds of inactivity to tolerate before returning from a readBytes(byte[],long)
call.newWriteTimeout
- The number of milliseconds of inactivity to tolerate before returning from a writeBytes(byte[],long)
call.public final void setBaudRate(int newBaudRate)-
readBytes(byte[],long)
or
+ writeBytes(byte[],long)
call should block forever until it can return successfully (based upon the current timeout mode specified).
++
newTimeoutMode
- The new timeout mode as specified above.newReadTimeout
- The number of milliseconds of inactivity to tolerate before returning from a readBytes(byte[],long)
call.newWriteTimeout
- The number of milliseconds of inactivity to tolerate before returning from a writeBytes(byte[],long)
call.+public final void setBaudRate(int newBaudRate)+
- The default baud rate is 9600 baud.
newBaudRate
- The desired baud rate for this serial port.public final void setNumDataBits(int newDataBits)-
+
newBaudRate
- The desired baud rate for this serial port.+public final void setNumDataBits(int newDataBits)+
- The default number of data bits per word is 8.
newDataBits
- The desired number of data bits per word.public final void setNumStopBits(int newStopBits)-
+
newDataBits
- The desired number of data bits per word.+public final void setNumStopBits(int newStopBits)+
The default number of stop bits per word is 2. Built-in stop-bit constants should be used
- in this method (ONE_STOP_BIT
, ONE_POINT_FIVE_STOP_BITS
, TWO_STOP_BITS
).
+ in this method (ONE_STOP_BIT
, ONE_POINT_FIVE_STOP_BITS
, TWO_STOP_BITS
).
- Note that ONE_POINT_FIVE_STOP_BITS
stop bits may not be available on non-Windows systems.
newStopBits
- The desired number of stop bits per word.ONE_STOP_BIT
,
-ONE_POINT_FIVE_STOP_BITS
,
-TWO_STOP_BITS
public final void setFlowControl(int newFlowControlSettings)-
ONE_POINT_FIVE_STOP_BITS
stop bits may not be available on non-Windows systems.
++
newStopBits
- The desired number of stop bits per word.ONE_STOP_BIT
,
+ONE_POINT_FIVE_STOP_BITS
,
+TWO_STOP_BITS
+public final void setFlowControl(int newFlowControlSettings)+
By default, no flow control is enabled. Built-in flow control constants should be used
- in this method (FLOW_CONTROL_RTS_ENABLED
, FLOW_CONTROL_CTS_ENABLED
, FLOW_CONTROL_DTR_ENABLED
,
- FLOW_CONTROL_DSR_ENABLED
, FLOW_CONTROL_XONXOFF_IN_ENABLED
, FLOW_CONTROL_XONXOFF_OUT_ENABLED
), and can be OR'ed together.
+ in this method (FLOW_CONTROL_RTS_ENABLED
, FLOW_CONTROL_CTS_ENABLED
, FLOW_CONTROL_DTR_ENABLED
,
+ FLOW_CONTROL_DSR_ENABLED
, FLOW_CONTROL_XONXOFF_IN_ENABLED
, FLOW_CONTROL_XONXOFF_OUT_ENABLED
), and can be OR'ed together.
Valid flow control configurations are:
- None: FLOW_CONTROL_DISABLED
- CTS: FLOW_CONTROL_CTS_ENABLED
- RTS/CTS: FLOW_CONTROL_RTS_ENABLED
| FLOW_CONTROL_CTS_ENABLED
- DSR: FLOW_CONTROL_DSR_ENABLED
- DTR/DSR: FLOW_CONTROL_DTR_ENABLED
| FLOW_CONTROL_DSR_ENABLED
- XOn/XOff: FLOW_CONTROL_XONXOFF_IN_ENABLED
| FLOW_CONTROL_XONXOFF_OUT_ENABLED
+ None: FLOW_CONTROL_DISABLED
+ CTS: FLOW_CONTROL_CTS_ENABLED
+ RTS/CTS: FLOW_CONTROL_RTS_ENABLED
| FLOW_CONTROL_CTS_ENABLED
+ DSR: FLOW_CONTROL_DSR_ENABLED
+ DTR/DSR: FLOW_CONTROL_DTR_ENABLED
| FLOW_CONTROL_DSR_ENABLED
+ XOn/XOff: FLOW_CONTROL_XONXOFF_IN_ENABLED
| FLOW_CONTROL_XONXOFF_OUT_ENABLED
Note that only one valid flow control configuration can be used at any time. For example, attempting to use both XOn/XOff - and RTS/CTS will most likely result in an unusable serial port.
newFlowControlSettings
- The desired type of flow control to enable for this serial port.FLOW_CONTROL_DISABLED
,
-FLOW_CONTROL_RTS_ENABLED
,
-FLOW_CONTROL_CTS_ENABLED
,
-FLOW_CONTROL_DTR_ENABLED
,
-FLOW_CONTROL_DSR_ENABLED
,
-FLOW_CONTROL_XONXOFF_IN_ENABLED
,
-FLOW_CONTROL_XONXOFF_OUT_ENABLED
public final void setParity(int newParity)-
+
newFlowControlSettings
- The desired type of flow control to enable for this serial port.FLOW_CONTROL_DISABLED
,
+FLOW_CONTROL_RTS_ENABLED
,
+FLOW_CONTROL_CTS_ENABLED
,
+FLOW_CONTROL_DTR_ENABLED
,
+FLOW_CONTROL_DSR_ENABLED
,
+FLOW_CONTROL_XONXOFF_IN_ENABLED
,
+FLOW_CONTROL_XONXOFF_OUT_ENABLED
+public final void setParity(int newParity)+
The parity parameter specifies how error detection is carried out. The built-in parity constants should be used.
- Acceptable values are NO_PARITY
, EVEN_PARITY
, ODD_PARITY
, MARK_PARITY
, and SPACE_PARITY
.
newParity
- The desired parity scheme to be used.NO_PARITY
,
-EVEN_PARITY
,
-ODD_PARITY
,
-MARK_PARITY
,
-SPACE_PARITY
public final String getDescriptivePortName()-
NO_PARITY
, EVEN_PARITY
, ODD_PARITY
, MARK_PARITY
, and SPACE_PARITY
.
++
newParity
- The desired parity scheme to be used.NO_PARITY
,
+EVEN_PARITY
,
+ODD_PARITY
,
+MARK_PARITY
,
+SPACE_PARITY
+public final String getDescriptivePortName()+
This description is generated by the operating system and may or may not be a good representation of the actual port or - device it describes.
public final String getSystemPortName()-
public final int getBaudRate()-
public final int getNumDataBits()-
public final int getNumStopBits()-
+
+public final String getSystemPortName()+
+
+public final int getBaudRate()+
+
+public final int getNumDataBits()+
+
+public final int getNumStopBits()+
The return value should not be interpreted as an integer, but rather compared with the built-in stop bit constants
- (ONE_STOP_BIT
, ONE_POINT_FIVE_STOP_BITS
, TWO_STOP_BITS
).
ONE_STOP_BIT
,
-ONE_POINT_FIVE_STOP_BITS
,
-TWO_STOP_BITS
public final int getParity()-
ONE_STOP_BIT
, ONE_POINT_FIVE_STOP_BITS
, TWO_STOP_BITS
).
++
ONE_STOP_BIT
,
+ONE_POINT_FIVE_STOP_BITS
,
+TWO_STOP_BITS
+public final int getParity()+
The return value should not be interpreted as an integer, but rather compared with the built-in parity constants
- (NO_PARITY
, EVEN_PARITY
, ODD_PARITY
, MARK_PARITY
, and SPACE_PARITY
).
NO_PARITY
,
-EVEN_PARITY
,
-ODD_PARITY
,
-MARK_PARITY
,
-SPACE_PARITY
public final int getReadTimeout()-
readBytes(byte[],long)
call.
+ (NO_PARITY
, EVEN_PARITY
, ODD_PARITY
, MARK_PARITY
, and SPACE_PARITY
).
++
NO_PARITY
,
+EVEN_PARITY
,
+ODD_PARITY
,
+MARK_PARITY
,
+SPACE_PARITY
+public final int getReadTimeout()+
readBytes(byte[],long)
call.
- A value of 0 indicates that a readBytes(byte[],long)
call will block forever until it has successfully read
+ A value of 0 indicates that a readBytes(byte[],long)
call will block forever until it has successfully read
the indicated number of bytes from the serial port.
- Any value other than 0 indicates the number of milliseconds of inactivity that will be tolerated before the readBytes(byte[],long)
- call will return.
readBytes(byte[],long)
call.public final int getWriteTimeout()-
writeBytes(byte[],long)
call.
+ Any value other than 0 indicates the number of milliseconds of inactivity that will be tolerated before the readBytes(byte[],long)
+ call will return.
++
readBytes(byte[],long)
call.+public final int getWriteTimeout()+
writeBytes(byte[],long)
call.
- A value of 0 indicates that a writeBytes(byte[],long)
call will block forever until it has successfully written
+ A value of 0 indicates that a writeBytes(byte[],long)
call will block forever until it has successfully written
the indicated number of bytes to the serial port.
- Any value other than 0 indicates the number of milliseconds of inactivity that will be tolerated before the writeBytes(byte[],long)
- call will return.
writeBytes(byte[],long)
call.public final int getFlowControlSettings()-
writeBytes(byte[],long)
+ call will return.
++
writeBytes(byte[],long)
call.+public final int getFlowControlSettings()+
The integer result should be masked with the built-in flow control constants to test if the desired setting is enabled. Valid flow control configurations are:
- None: FLOW_CONTROL_DISABLED
- CTS: FLOW_CONTROL_CTS_ENABLED
- RTS/CTS: FLOW_CONTROL_RTS_ENABLED
| FLOW_CONTROL_CTS_ENABLED
- DSR: FLOW_CONTROL_DSR_ENABLED
- DTR/DSR: FLOW_CONTROL_DTR_ENABLED
| FLOW_CONTROL_DSR_ENABLED
- XOn/XOff: FLOW_CONTROL_XONXOFF_IN_ENABLED
| FLOW_CONTROL_XONXOFF_OUT_ENABLED
FLOW_CONTROL_DISABLED
,
-FLOW_CONTROL_RTS_ENABLED
,
-FLOW_CONTROL_CTS_ENABLED
,
-FLOW_CONTROL_DTR_ENABLED
,
-FLOW_CONTROL_DSR_ENABLED
,
-FLOW_CONTROL_XONXOFF_IN_ENABLED
,
-FLOW_CONTROL_XONXOFF_OUT_ENABLED
FLOW_CONTROL_DISABLED
FLOW_CONTROL_CTS_ENABLED
FLOW_CONTROL_RTS_ENABLED
| FLOW_CONTROL_CTS_ENABLED
FLOW_CONTROL_DSR_ENABLED
FLOW_CONTROL_DTR_ENABLED
| FLOW_CONTROL_DSR_ENABLED
FLOW_CONTROL_XONXOFF_IN_ENABLED
| FLOW_CONTROL_XONXOFF_OUT_ENABLED
++
FLOW_CONTROL_DISABLED
,
+FLOW_CONTROL_RTS_ENABLED
,
+FLOW_CONTROL_CTS_ENABLED
,
+FLOW_CONTROL_DTR_ENABLED
,
+FLOW_CONTROL_DSR_ENABLED
,
+FLOW_CONTROL_XONXOFF_IN_ENABLED
,
+FLOW_CONTROL_XONXOFF_OUT_ENABLED