What is jSerialComm?
-jSerialComm is a Java library designed to provide a platform-independent way to access standard serial ports without requiring external libraries, native code, or any other tools. It is meant as an alternative to RxTx and the (deprecated) Java Communications API, with increased ease-of-use and an enhanced support for timeouts.
+jSerialComm is a Java library designed to provide a platform-independent way to access standard serial ports without requiring external libraries, native code, or any other tools. It is meant as an alternative to RxTx and the (deprecated) Java Communications API, with increased ease-of-use, an enhanced support for timeouts, and the ability to open multiple ports simultaneously.
Some of the features of this library include:
@@ -73,13 +73,13 @@How can use this library in my own project?
-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:
SerialPort.getCommPorts()
- This will return an array of SerialPort objects through which you can iterate. See the Javadoc Library Reference for a complete overview of this library and its methods. Alternately, if you already know the port descriptor of the port you wish to use (e.g., "/dev/ttyS0" or "COM3"), you can create a SerialPort object using the following static method:
+This will return an array of SerialPort objects through which you can iterate. See the Javadoc Library Reference for a complete overview of this library and its methods. Alternately, if you already know the port descriptor of the port you wish to use (e.g., "/dev/ttyS0" or "COM3"), or if you are using this library with pseudo-terminals (e.g., "/dev/pts/14"), you can create a SerialPort object using the following static method:
SerialPort.getCommPort(String portDescriptor)
@@ -102,25 +102,25 @@
<dependency>
<groupId>com.fazecast</groupId>
<artifactId>jSerialComm</artifactId>
<version>1.3.3</version>
</dependency>
+ <dependency>
<groupId>com.fazecast</groupId>
<artifactId>jSerialComm</artifactId>
<version>1.3.4</version>
</dependency>
<dependency org="com.fazecast" name="jSerialComm" rev="1.3.3"/>
+ <dependency org="com.fazecast" name="jSerialComm" rev="1.3.4"/>
@Grapes(
@Grab(group='com.fazecast', module='jSerialComm', version='1.3.3')
)
+ @Grapes(
@Grab(group='com.fazecast', module='jSerialComm', version='1.3.4')
)
'com.fazecast:jSerialComm:1.3.3'
+ 'com.fazecast:jSerialComm:1.3.4'
'com.fazecast:jSerialComm:jar:1.3.3'
+ 'com.fazecast:jSerialComm:jar:1.3.4'
libraryDependencies += "com.fazecast" % "jSerialComm" % "1.3.3"
+ libraryDependencies += "com.fazecast" % "jSerialComm" % "1.3.4"
[com.fazecast/jSerialComm "1.3.3"]
+ [com.fazecast/jSerialComm "1.3.4"]
- -
SerialPort
- -SerialPortDataListener - -SerialPortEvent - -SerialPortPacketListener - - |
-
All Classes
+ + + diff --git a/javadoc/allclasses-noframe.html b/javadoc/allclasses-noframe.html index 067f8ee..f2ee4a9 100644 --- a/javadoc/allclasses-noframe.html +++ b/javadoc/allclasses-noframe.html @@ -1,37 +1,22 @@ - - - - -- -
SerialPort
- -SerialPortDataListener - -SerialPortEvent - -SerialPortPacketListener - - |
-
All Classes
+ + + diff --git a/javadoc/com/fazecast/jSerialComm/SerialPort.html b/javadoc/com/fazecast/jSerialComm/SerialPort.html index 6b93558..24a2e39 100644 --- a/javadoc/com/fazecast/jSerialComm/SerialPort.html +++ b/javadoc/com/fazecast/jSerialComm/SerialPort.html @@ -1,1026 +1,982 @@ - - - - -- - + catch(err) { + } +//--> +var methods = {"i0":10,"i1":10,"i2":10,"i3":10,"i4":9,"i5":9,"i6":10,"i7":10,"i8":10,"i9":10,"i10":10,"i11":10,"i12":10,"i13":10,"i14":10,"i15":10,"i16":10,"i17":10,"i18":10,"i19":10,"i20":10,"i21":10,"i22":10,"i23":10,"i24":10,"i25":10,"i26":10}; +var tabs = {65535:["t0","All Methods"],1:["t1","Static Methods"],2:["t2","Instance Methods"],8:["t4","Concrete Methods"]}; +var altColor = "altColor"; +var rowColor = "rowColor"; +var tableTab = "tableTab"; +var activeTableTab = "activeTableTab"; + + - - -
-
-
|
-- - | -|||||||
- PREV CLASS - NEXT CLASS | -- FRAMES - NO FRAMES - - - - - | -|||||||
- SUMMARY: NESTED | FIELD | CONSTR | METHOD | --DETAIL: FIELD | CONSTR | METHOD | -
-
-
-com.fazecast.jSerialComm
-
-Class SerialPort
--java.lang.Object - com.fazecast.jSerialComm.SerialPort --
-
-
-
public final class SerialPort
- extends Object
-This class provides native access to serial ports and devices without requiring external libraries or tools. -
- -
-
-
-
- See Also:
InputStream
, -OutputStream
- -
+
Class SerialPort
+-
+
- java.lang.Object +
-
+
-
+
- com.fazecast.jSerialComm.SerialPort +
+
-
+
-
+
+
+public final class SerialPort +extends Object
+This class provides native access to serial ports and devices without requiring external libraries or tools.+-
+
- See Also: +
InputStream
, +OutputStream
+
+
-
+
-
-
-
-
-
- +- --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
- -
--
+
-
+
+
+
Field Summary
++
+Fields ++ +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
+
-
- -- --Method Summary -- -- -boolean
-addDataListener(SerialPortDataListener listener)
- -
- Adds aSerialPortDataListener
to the serial port interface.- -- -int
-bytesAvailable()
- -
- Returns the number of bytes available without blocking ifreadBytes(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 aSerialPort
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 anInputStream
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 anOutputStream
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 areadBytes(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 awriteBytes(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 associatedSerialPortDataListener
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
- +
-
+
-
+
+
+
Method Summary
++
+ +All Methods Static Methods Instance Methods Concrete Methods ++ +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(long, 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.+
+
+ -
+
+
+
-
+
-
-
-
-
-
- -- --Field Detail --NO_PARITY
--public static final int NO_PARITY
--
-
- See Also:
- Constant Field Values
-
-
- --ODD_PARITY
--public static final int ODD_PARITY
--
-
- See Also:
- Constant Field Values
-
-
- --EVEN_PARITY
--public static final int EVEN_PARITY
--
-
- See Also:
- Constant Field Values
-
-
- --MARK_PARITY
--public static final int MARK_PARITY
--
-
- See Also:
- Constant Field Values
-
-
- --SPACE_PARITY
--public static final int SPACE_PARITY
--
-
- See Also:
- Constant Field Values
-
-
- --ONE_STOP_BIT
--public static final int ONE_STOP_BIT
--
-
- See Also:
- Constant Field Values
-
-
- --ONE_POINT_FIVE_STOP_BITS
--public static final int ONE_POINT_FIVE_STOP_BITS
--
-
- See Also:
- Constant Field Values
-
-
- --TWO_STOP_BITS
--public static final int TWO_STOP_BITS
--
-
- See Also:
- Constant Field Values
-
-
- --FLOW_CONTROL_DISABLED
--public static final int FLOW_CONTROL_DISABLED
--
-
- See Also:
- Constant Field Values
-
-
- --FLOW_CONTROL_RTS_ENABLED
--public static final int FLOW_CONTROL_RTS_ENABLED
--
-
- See Also:
- Constant Field Values
-
-
- --FLOW_CONTROL_CTS_ENABLED
--public static final int FLOW_CONTROL_CTS_ENABLED
--
-
- See Also:
- Constant Field Values
-
-
- --FLOW_CONTROL_DSR_ENABLED
--public static final int FLOW_CONTROL_DSR_ENABLED
--
-
- See Also:
- Constant Field Values
-
-
- --FLOW_CONTROL_DTR_ENABLED
--public static final int FLOW_CONTROL_DTR_ENABLED
--
-
- See Also:
- Constant Field Values
-
-
- --FLOW_CONTROL_XONXOFF_IN_ENABLED
--public static final int FLOW_CONTROL_XONXOFF_IN_ENABLED
--
-
- See Also:
- Constant Field Values
-
-
- --FLOW_CONTROL_XONXOFF_OUT_ENABLED
--public static final int FLOW_CONTROL_XONXOFF_OUT_ENABLED
--
-
- See Also:
- Constant Field Values
-
-
- --TIMEOUT_NONBLOCKING
--public static final int TIMEOUT_NONBLOCKING
--
-
- See Also:
- Constant Field Values
-
-
- --TIMEOUT_READ_SEMI_BLOCKING
--public static final int TIMEOUT_READ_SEMI_BLOCKING
--
-
- See Also:
- Constant Field Values
-
-
- --TIMEOUT_WRITE_SEMI_BLOCKING
--public static final int TIMEOUT_WRITE_SEMI_BLOCKING
--
-
- See Also:
- Constant Field Values
-
-
- --TIMEOUT_READ_BLOCKING
--public static final int TIMEOUT_READ_BLOCKING
--
-
- See Also:
- Constant Field Values
-
-
- --TIMEOUT_WRITE_BLOCKING
--public static final int TIMEOUT_WRITE_BLOCKING
--
-
- See Also:
- Constant Field Values
-
-
- --TIMEOUT_SCANNER
--public static final int TIMEOUT_SCANNER
--
-
- See Also:
- Constant Field Values
-
-
- --LISTENING_EVENT_DATA_AVAILABLE
--public static final int LISTENING_EVENT_DATA_AVAILABLE
--
-
- See Also:
- Constant Field Values
-
-
- --LISTENING_EVENT_DATA_RECEIVED
--public static final int LISTENING_EVENT_DATA_RECEIVED
--
-
- See Also:
- Constant Field Values
-
-
- --LISTENING_EVENT_DATA_WRITTEN
--public static final int LISTENING_EVENT_DATA_WRITTEN
--
-
- See Also:
- Constant Field Values
-
-
-
+
-
+
+
+
Field Detail
+ + + +-
+
-
+
NO_PARITY
+public static final int NO_PARITY
+-
+
- See Also: +
- Constant Field Values +
+
-
+
-
+
ODD_PARITY
+public static final int ODD_PARITY
+-
+
- See Also: +
- Constant Field Values +
+
-
+
-
+
EVEN_PARITY
+public static final int EVEN_PARITY
+-
+
- See Also: +
- Constant Field Values +
+
-
+
-
+
MARK_PARITY
+public static final int MARK_PARITY
+-
+
- See Also: +
- Constant Field Values +
+
-
+
-
+
SPACE_PARITY
+public static final int SPACE_PARITY
+-
+
- See Also: +
- Constant Field Values +
+
-
+
-
+
ONE_STOP_BIT
+public static final int ONE_STOP_BIT
+-
+
- See Also: +
- Constant Field Values +
+
-
+
-
+
ONE_POINT_FIVE_STOP_BITS
+public static final int ONE_POINT_FIVE_STOP_BITS
+-
+
- See Also: +
- Constant Field Values +
+
-
+
-
+
TWO_STOP_BITS
+public static final int TWO_STOP_BITS
+-
+
- See Also: +
- Constant Field Values +
+
-
+
-
+
FLOW_CONTROL_DISABLED
+public static final int FLOW_CONTROL_DISABLED
+-
+
- See Also: +
- Constant Field Values +
+
-
+
-
+
FLOW_CONTROL_RTS_ENABLED
+public static final int FLOW_CONTROL_RTS_ENABLED
+-
+
- See Also: +
- Constant Field Values +
+
-
+
-
+
FLOW_CONTROL_CTS_ENABLED
+public static final int FLOW_CONTROL_CTS_ENABLED
+-
+
- See Also: +
- Constant Field Values +
+
-
+
-
+
FLOW_CONTROL_DSR_ENABLED
+public static final int FLOW_CONTROL_DSR_ENABLED
+-
+
- See Also: +
- Constant Field Values +
+
-
+
-
+
FLOW_CONTROL_DTR_ENABLED
+public static final int FLOW_CONTROL_DTR_ENABLED
+-
+
- See Also: +
- Constant Field Values +
+
-
+
-
+
FLOW_CONTROL_XONXOFF_IN_ENABLED
+public static final int FLOW_CONTROL_XONXOFF_IN_ENABLED
+-
+
- See Also: +
- Constant Field Values +
+
-
+
-
+
FLOW_CONTROL_XONXOFF_OUT_ENABLED
+public static final int FLOW_CONTROL_XONXOFF_OUT_ENABLED
+-
+
- See Also: +
- Constant Field Values +
+
-
+
-
+
TIMEOUT_NONBLOCKING
+public static final int TIMEOUT_NONBLOCKING
+-
+
- See Also: +
- Constant Field Values +
+
-
+
-
+
TIMEOUT_READ_SEMI_BLOCKING
+public static final int TIMEOUT_READ_SEMI_BLOCKING
+-
+
- See Also: +
- Constant Field Values +
+
-
+
-
+
TIMEOUT_WRITE_SEMI_BLOCKING
+public static final int TIMEOUT_WRITE_SEMI_BLOCKING
+-
+
- See Also: +
- Constant Field Values +
+
-
+
-
+
TIMEOUT_READ_BLOCKING
+public static final int TIMEOUT_READ_BLOCKING
+-
+
- See Also: +
- Constant Field Values +
+
-
+
-
+
TIMEOUT_WRITE_BLOCKING
+public static final int TIMEOUT_WRITE_BLOCKING
+-
+
- See Also: +
- Constant Field Values +
+
-
+
-
+
TIMEOUT_SCANNER
+public static final int TIMEOUT_SCANNER
+-
+
- See Also: +
- Constant Field Values +
+
-
+
-
+
LISTENING_EVENT_DATA_AVAILABLE
+public static final int LISTENING_EVENT_DATA_AVAILABLE
+-
+
- See Also: +
- Constant Field Values +
+
-
+
-
+
LISTENING_EVENT_DATA_RECEIVED
+public static final int LISTENING_EVENT_DATA_RECEIVED
+-
+
- See Also: +
- Constant Field Values +
+
-
+
-
+
LISTENING_EVENT_DATA_WRITTEN
+public static final int LISTENING_EVENT_DATA_WRITTEN
+-
+
- See Also: +
- Constant Field Values +
+
+ -
+
-
- -- --Method Detail --getCommPorts
--public static SerialPort[] getCommPorts()
--
-
- Returns a list of all available serial ports on this machine.
+
-
+
-
+
+
+
Method Detail
+ + + +-
+
-
+
getCommPorts
+public static SerialPort[] getCommPorts()
+Returns a list of all available serial ports on this machine.+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 theopenPort()
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. -
-
- --
-
-
- Returns:
- An array of
SerialPort
objects.
- --getCommPort
--public static SerialPort getCommPort(String portDescriptor)
--
-
- Allocates a
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.
-
+
- Returns: +
- An array of
SerialPort
objects.
+
+
-
+
-
+
getCommPort
+public static SerialPort getCommPort(String portDescriptor)
+Allocates a+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[*]". --
- --
-
- Parameters:
portDescriptor
- The desired serial port to use with this library. -- Returns:
- A SerialPort object.
- --openPort
--public final boolean openPort()
--
-
- Opens this serial port for reading and writing. + On Linux machines, the descriptor will look similar to "/dev/tty[*]".
-
+
- Parameters: +
portDescriptor
- The desired serial port to use with this library.
+- Returns: +
- A SerialPort object. +
+
-
+
-
+
openPort
+public final boolean openPort()
+Opens this serial port for reading and writing.+- All serial port parameters or timeouts can be changed at any time after the port has been opened. -
-
- --
-
-
- Returns:
- Whether the port was successfully opened.
- --closePort
--public final boolean closePort()
--
-
- Closes this serial port.
-
-
--
-
-
- Returns:
- Whether the port was successfully closed.
- --bytesAvailable
--public final int bytesAvailable()
--
-
- Returns the number of bytes available without blocking if
readBytes(byte[], long)
were to be called immediately - after this method returns. --
--
-
-
- Returns:
- The number of bytes currently available to be read, or -1 if the port is not open.
- --readBytes
--public final int readBytes(byte[] buffer, - long bytesToRead)
--
-
- Reads up to bytesToRead raw data bytes from the serial port and stores them in the buffer. + All serial port parameters or timeouts can be changed at any time after the port has been opened.
-
+
- Returns: +
- Whether the port was successfully opened. +
+
-
+
-
+
closePort
+public final boolean closePort()
+Closes this serial port.+-
+
- Returns: +
- Whether the port was successfully closed. +
+
-
+
-
+
bytesAvailable
+public final int bytesAvailable()
+Returns the number of bytes available without blocking if+readBytes(long, byte[], long)
were to be called immediately + after this method returns.-
+
- Returns: +
- The number of bytes currently available to be read, or -1 if the port is not open. +
+
-
+
-
+
readBytes
+public final int readBytes(byte[] buffer, + long bytesToRead)
+Reads up to bytesToRead raw data bytes from the serial port and stores them in the buffer.+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. -
-
- --
-
- Parameters:
buffer
- The buffer into which the raw data is read.bytesToRead
- The number of bytes to read from the serial port. -- Returns:
- The number of bytes successfully read, or -1 if there was an error reading from the port.
- --writeBytes
--public final int writeBytes(byte[] buffer, - long bytesToWrite)
--
-
- Writes up to bytesToWrite raw data bytes from the buffer parameter to the serial port. + whichever comes first, regardless of the availability of more data.
-
+
- Parameters: +
buffer
- The buffer into which the raw data is read.
+bytesToRead
- The number of bytes to read from the serial port.
+- Returns: +
- The number of bytes successfully read, or -1 if there was an error reading from the port. +
+
-
+
-
+
writeBytes
+public final int writeBytes(byte[] buffer, + long bytesToWrite)
+Writes up to bytesToWrite raw data bytes from the buffer parameter to the serial port.+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. -
-
- --
-
- Parameters:
buffer
- The buffer containing the raw data to write to the serial port.bytesToWrite
- The number of bytes to write to the serial port. -- Returns:
- The number of bytes successfully written, or -1 if there was an error writing to the port.
- --addDataListener
--public final boolean addDataListener(SerialPortDataListener listener)
--
-
- Adds a
SerialPortDataListener
to the serial port interface. + whichever comes first, regardless of the availability of more data.
-
+
- Parameters: +
buffer
- The buffer containing the raw data to write to the serial port.
+bytesToWrite
- The number of bytes to write to the serial port.
+- Returns: +
- The number of bytes successfully written, or -1 if there was an error writing to the port. +
+
-
+
-
+
addDataListener
+public final boolean addDataListener(SerialPortDataListener listener)
+Adds a+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 theInputStream
/OutputStream
interface.- The parameter passed into this method must be an implementation of either the
SerialPortDataListener
or theSerialPortPacketListener
. - TheSerialPortPacketListener
interface must be used if you plan to use event-based reading of full data packets over the serial port. - Otherwise, the simplerSerialPortDataListener
may be used. + The parameter passed into this method must be an implementation of either theSerialPortDataListener
or theSerialPortPacketListener
. + TheSerialPortPacketListener
interface must be used if you plan to use event-based reading of full data packets over the serial port. + Otherwise, the simplerSerialPortDataListener
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
andSerialPortPacketListener
for more information. --
- --
-
- Parameters:
listener
- ASerialPortDataListener
orSerialPortPacketListener
implementation to be used for event-based serial port communications. -- Returns:
- Whether the listener was successfully registered with the serial port.
- See Also:
SerialPortDataListener
, -SerialPortPacketListener
- --removeDataListener
--public final void removeDataListener()
--
-
- Removes the associated
SerialPortDataListener
from the serial port interface. --
--
-
- --getInputStream
--public final InputStream getInputStream()
--
-
- Returns an
InputStream
object associated with this serial port. + Refer toSerialPortDataListener
andSerialPortPacketListener
for more information.
-
+
- Parameters: +
listener
- ASerialPortDataListener
orSerialPortPacketListener
implementation to be used for event-based serial port communications.
+- Returns: +
- Whether the listener was successfully registered with the serial port. +
- See Also: +
SerialPortDataListener
, +SerialPortPacketListener
+
+
-
+
-
+
removeDataListener
+public final void removeDataListener()
+Removes the associated+SerialPortDataListener
from the serial port interface.
+
-
+
-
+
getInputStream
+public final InputStream getInputStream()
+Returns an+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. --
- --
-
-
- Returns:
- An
InputStream
object associated with this serial port. - See Also:
InputStream
- --getOutputStream
--public final OutputStream getOutputStream()
--
-
- Returns an
OutputStream
object associated with this serial port. + Make sure to call theInputStream.close()
method when you are done using this stream.
-
+
- Returns: +
- An
InputStream
object associated with this serial port.
+ - See Also: +
InputStream
+
+
-
+
-
+
getOutputStream
+public final OutputStream getOutputStream()
+Returns an+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. --
- --
-
-
- Returns:
- An
OutputStream
object associated with this serial port. - See Also:
OutputStream
- --setComPortParameters
--public final void setComPortParameters(int newBaudRate, + Make sure to call the
OutputStream.close()
method when you are done using this stream.-
+
- Returns: +
- An
OutputStream
object associated with this serial port.
+ - See Also: +
OutputStream
+
+
-
+
-
+
setComPortParameters
+public final void setComPortParameters(int newBaudRate, int newDataBits, int newStopBits, - int newParity)
--
-
- Sets all serial port parameters at one time.
+ int newParity)
+Sets all serial port parameters at one time.+
Allows the user to set all port parameters with a single function call.
@@ -1028,401 +984,434 @@ public final void setComPortParameters(int newBaudRate, specifies how many data bits to use per word. The default is 8, but any values from 5 to 8 are acceptable.
The default number of stop bits is 1, but 2 bits can also be used or even 1.5 on Windows machines. Please use the built-in - constants for this parameter (
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
, andSPACE_PARITY
. --
- --
-
- Parameters:
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.- See Also:
ONE_STOP_BIT
, -ONE_POINT_FIVE_STOP_BITS
, -TWO_STOP_BITS
, -NO_PARITY
, -EVEN_PARITY
, -ODD_PARITY
, -MARK_PARITY
, -SPACE_PARITY
- --setComPortTimeouts
--public final void setComPortTimeouts(int newTimeoutMode, + Acceptable values are
NO_PARITY
,EVEN_PARITY
,ODD_PARITY
,MARK_PARITY
, andSPACE_PARITY
.-
+
- Parameters: +
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.
+- See Also: +
ONE_STOP_BIT
, +ONE_POINT_FIVE_STOP_BITS
, +TWO_STOP_BITS
, +NO_PARITY
, +EVEN_PARITY
, +ODD_PARITY
, +MARK_PARITY
, +SPACE_PARITY
+
+ - Sets all serial port parameters at one time.
+ int newParity)
+
-
+
-
+
setComPortTimeouts
+public final void setComPortTimeouts(int newTimeoutMode, int newReadTimeout, - int newWriteTimeout)
--
-
- Sets the serial port read and write timeout parameters.
+ int newWriteTimeout)
+Sets the serial port read and write timeout parameters.+
- 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 correspondingreadBytes(byte[],long)
orwriteBytes(byte[],long)
call + TheTIMEOUT_NONBLOCKING
mode specifies that the correspondingreadBytes(byte[],long)
orwriteBytes(byte[],long)
call will return immediately with any available data.- The
TIMEOUT_READ_SEMI_BLOCKING
orTIMEOUT_WRITE_SEMI_BLOCKING
modes specify that the corresponding calls will block until either + TheTIMEOUT_READ_SEMI_BLOCKING
orTIMEOUT_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
orTIMEOUT_WRITE_BLOCKING
modes specify that the corresponding call will block until either + TheTIMEOUT_READ_BLOCKING
orTIMEOUT_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 JavaScanner
class for reading from the serial port. In this mode, + TheTIMEOUT_SCANNER
mode is intended for use with the JavaScanner
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). --
- --
-
- Parameters:
newTimeoutMode
- The new timeout mode as specified above.newReadTimeout
- The number of milliseconds of inactivity to tolerate before returning from areadBytes(byte[],long)
call.newWriteTimeout
- The number of milliseconds of inactivity to tolerate before returning from awriteBytes(byte[],long)
call.
- --setBaudRate
--public final void setBaudRate(int newBaudRate)
--
-
- Sets the desired baud rate for this serial port.
+ 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).
-
+
- Parameters: +
newTimeoutMode
- The new timeout mode as specified above.
+newReadTimeout
- The number of milliseconds of inactivity to tolerate before returning from areadBytes(byte[],long)
call.
+newWriteTimeout
- The number of milliseconds of inactivity to tolerate before returning from awriteBytes(byte[],long)
call.
+
+ - Sets the serial port read and write timeout parameters.
+ int newWriteTimeout)
+
-
+
-
+
setBaudRate
+public final void setBaudRate(int newBaudRate)
+Sets the desired baud rate for this serial port.+- The default baud rate is 9600 baud. -
-
- --
-
- Parameters:
newBaudRate
- The desired baud rate for this serial port.
- --setNumDataBits
--public final void setNumDataBits(int newDataBits)
--
-
- Sets the desired number of data bits per word. + The default baud rate is 9600 baud.
-
+
- Parameters: +
newBaudRate
- The desired baud rate for this serial port.
+
+
-
+
-
+
setNumDataBits
+public final void setNumDataBits(int newDataBits)
+Sets the desired number of data bits per word.+- The default number of data bits per word is 8. -
-
- --
-
- Parameters:
newDataBits
- The desired number of data bits per word.
- --setNumStopBits
--public final void setNumStopBits(int newStopBits)
--
-
- Sets the desired number of stop bits per word. + The default number of data bits per word is 8.
-
+
- Parameters: +
newDataBits
- The desired number of data bits per word.
+
+
-
+
-
+
setNumStopBits
+public final void setNumStopBits(int newStopBits)
+Sets the desired number of stop bits per word.+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. --
- --
-
- Parameters:
newStopBits
- The desired number of stop bits per word.- See Also:
ONE_STOP_BIT
, -ONE_POINT_FIVE_STOP_BITS
, -TWO_STOP_BITS
- --setFlowControl
--public final void setFlowControl(int newFlowControlSettings)
--
-
- Specifies what kind of flow control to enable for this serial port.
+ Note that
ONE_POINT_FIVE_STOP_BITS
stop bits may not be available on non-Windows systems.
-
+
- Parameters: +
newStopBits
- The desired number of stop bits per word.
+- See Also: +
ONE_STOP_BIT
, +ONE_POINT_FIVE_STOP_BITS
, +TWO_STOP_BITS
+
+
-
+
-
+
setFlowControl
+public final void setFlowControl(int newFlowControlSettings)
+Specifies what kind of flow control to enable for this serial port.+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. -
-
- --
-
- Parameters:
newFlowControlSettings
- The desired type of flow control to enable for this serial port.- See Also:
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
- --setParity
--public final void setParity(int newParity)
--
-
- Sets the desired parity error-detection scheme to be used. + and RTS/CTS will most likely result in an unusable serial port.
-
+
- Parameters: +
newFlowControlSettings
- The desired type of flow control to enable for this serial port.
+- See Also: +
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
+
+
-
+
-
+
setParity
+public final void setParity(int newParity)
+Sets the desired parity error-detection scheme to be used.+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
, andSPACE_PARITY
. --
- --
-
- Parameters:
newParity
- The desired parity scheme to be used.- See Also:
NO_PARITY
, -EVEN_PARITY
, -ODD_PARITY
, -MARK_PARITY
, -SPACE_PARITY
- --getDescriptivePortName
--public final String getDescriptivePortName()
--
-
- Gets a descriptive string representing this serial port or the device connected to it.
+ Acceptable values are
NO_PARITY
,EVEN_PARITY
,ODD_PARITY
,MARK_PARITY
, andSPACE_PARITY
.
-
+
- Parameters: +
newParity
- The desired parity scheme to be used.
+- See Also: +
NO_PARITY
, +EVEN_PARITY
, +ODD_PARITY
, +MARK_PARITY
, +SPACE_PARITY
+
+
-
+
-
+
getDescriptivePortName
+public final String getDescriptivePortName()
+Gets a descriptive string representing this serial port or the device connected to it.+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. -
-
- --
-
-
- Returns:
- A descriptive string representing this serial port.
- --getSystemPortName
--public final String getSystemPortName()
--
-
- Gets the operating system-defined device name corresponding to this serial port.
-
-
--
-
-
- Returns:
- The system-defined device name of this serial port.
- --getBaudRate
--public final int getBaudRate()
--
-
- Gets the current baud rate of the serial port.
-
-
--
-
-
- Returns:
- The current baud rate of the serial port.
- --getNumDataBits
--public final int getNumDataBits()
--
-
- Gets the current number of data bits per word.
-
-
--
-
-
- Returns:
- The current number of data bits per word.
- --getNumStopBits
--public final int getNumStopBits()
--
-
- Gets the current number of stop bits per word. + device it describes.
-
+
- Returns: +
- A descriptive string representing this serial port. +
+
-
+
-
+
getSystemPortName
+public final String getSystemPortName()
+Gets the operating system-defined device name corresponding to this serial port.+-
+
- Returns: +
- The system-defined device name of this serial port. +
+
-
+
-
+
getBaudRate
+public final int getBaudRate()
+Gets the current baud rate of the serial port.+-
+
- Returns: +
- The current baud rate of the serial port. +
+
-
+
-
+
getNumDataBits
+public final int getNumDataBits()
+Gets the current number of data bits per word.+-
+
- Returns: +
- The current number of data bits per word. +
+
-
+
-
+
getNumStopBits
+public final int getNumStopBits()
+Gets the current number of stop bits per word.+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
). --
- --
-
-
- Returns:
- The current number of stop bits per word.
- See Also:
ONE_STOP_BIT
, -ONE_POINT_FIVE_STOP_BITS
, -TWO_STOP_BITS
- --getParity
--public final int getParity()
--
-
- Gets the current parity error-checking scheme.
+ (
ONE_STOP_BIT
,ONE_POINT_FIVE_STOP_BITS
,TWO_STOP_BITS
).
-
+
- Returns: +
- The current number of stop bits per word. +
- See Also: +
ONE_STOP_BIT
, +ONE_POINT_FIVE_STOP_BITS
, +TWO_STOP_BITS
+
+
-
+
-
+
getParity
+public final int getParity()
+Gets the current parity error-checking scheme.+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
, andSPACE_PARITY
). --
- --
-
-
- Returns:
- The current parity scheme.
- See Also:
NO_PARITY
, -EVEN_PARITY
, -ODD_PARITY
, -MARK_PARITY
, -SPACE_PARITY
- --getReadTimeout
--public final int getReadTimeout()
--
-
- Gets the number of milliseconds of inactivity to tolerate before returning from a
readBytes(byte[],long)
call. + (NO_PARITY
,EVEN_PARITY
,ODD_PARITY
,MARK_PARITY
, andSPACE_PARITY
).
-
+
- Returns: +
- The current parity scheme. +
- See Also: +
NO_PARITY
, +EVEN_PARITY
, +ODD_PARITY
, +MARK_PARITY
, +SPACE_PARITY
+
+
-
+
-
+
getReadTimeout
+public final int getReadTimeout()
+Gets the number of milliseconds of inactivity to tolerate before returning from a+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 areadBytes(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. --
- --
-
-
- Returns:
- The number of milliseconds of inactivity to tolerate before returning from a
readBytes(byte[],long)
call.
- --getWriteTimeout
--public final int getWriteTimeout()
--
-
- Gets the number of milliseconds of inactivity to tolerate before returning from a
writeBytes(byte[],long)
call. + Any value other than 0 indicates the number of milliseconds of inactivity that will be tolerated before thereadBytes(byte[],long)
+ call will return.
-
+
- Returns: +
- The number of milliseconds of inactivity to tolerate before returning from a
readBytes(byte[],long)
call.
+
+
-
+
-
+
getWriteTimeout
+public final int getWriteTimeout()
+Gets the number of milliseconds of inactivity to tolerate before returning from a+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 awriteBytes(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. --
- --
-
-
- Returns:
- The number of milliseconds of inactivity to tolerate before returning from a
writeBytes(byte[],long)
call.
- --getFlowControlSettings
--public final int getFlowControlSettings()
--
-
- Returns the flow control settings enabled on this 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.
-
+
- Returns: +
- The number of milliseconds of inactivity to tolerate before returning from a
writeBytes(byte[],long)
call.
+
+
-
+
-
+
getFlowControlSettings
+public final int getFlowControlSettings()
+Returns the flow control settings enabled on this serial port.+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
--
- + None:-
-
-
- Returns:
- The flow control settings enabled on this serial port.
- See Also:
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
+ 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
-
+
- Returns: +
- The flow control settings enabled on this serial port. +
- See Also: +
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
+
+
+ -
+
-
+
+
+
+
- - - - -
-
-
|
-- - | -|||||||
- PREV CLASS - NEXT CLASS | -- FRAMES - NO FRAMES - - - - - | -|||||||
- SUMMARY: NESTED | FIELD | CONSTR | METHOD | --DETAIL: FIELD | CONSTR | METHOD | -
- - - +