Class SerialPort
- java.lang.Object
-
- com.fazecast.jSerialComm.SerialPort
-
public 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
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
addDataListener(SerialPortDataListener listener)
Adds aSerialPortDataListener
to the serial port interface.static void
addShutdownHook(Thread hook)
Registers a shutdown hook that will run just before the application fully closes, due to either exiting normally or in response to a user interrupt such as Ctrl+C.void
allowElevatedPermissionsRequest()
Allows the library to request elevation of the current user's permissions for use in making certain system-specific changes regarding this serial port.int
bytesAvailable()
Returns the number of bytes available without blocking ifreadBytes(byte[], int)
were to be called immediately after this method returns.int
bytesAwaitingWrite()
Returns the number of bytes still waiting to be written in the device's output queue.boolean
clearBreak()
Clears the BREAK signal from the serial control line.boolean
clearDTR()
Clears the state of the DTR line to 0.boolean
clearRTS()
Clears the state of the RTS line to 0.boolean
closePort()
Closes this serial port.void
disableExclusiveLock()
Disables the library from obtaining an exclusive lock on the serial port.void
disablePortConfiguration()
Disables the library from calling any of the underlying device driver configuration methods.void
flushDataListener()
Flushes any already-received data from the registeredSerialPortDataListener
that has not yet triggered an event.boolean
flushIOBuffers()
Flushes the serial port's Rx/Tx device buffers.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.boolean
getCTS()
Returns whether the CTS line is currently asserted.boolean
getDCD()
Returns whether the DCD line is currently asserted.String
getDescriptivePortName()
Gets a descriptive string representing this serial port or the device connected to it.int
getDeviceReadBufferSize()
Returns the underlying receive buffer size used by the serial port device driver.int
getDeviceWriteBufferSize()
Returns the underlying transmit buffer size used by the serial port device driver.boolean
getDSR()
Returns whether the DSR line is currently asserted.boolean
getDTR()
Returns whether the DTR line is currently asserted.int
getFlowControlSettings()
Returns the flow control settings enabled on this serial port.InputStream
getInputStream()
Returns anInputStream
object associated with this serial port.InputStream
getInputStreamWithSuppressedTimeoutExceptions()
Returns anInputStream
object associated with this serial port, with read timeout exceptions completely suppressed.int
getLastErrorCode()
Returns the error number returned by the most recent native source code line that failed execution.int
getLastErrorLocation()
Returns the source code line location of the latest error encountered during execution of the native code for this 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.String
getPortDescription()
Gets a description of the port as reported by the device itself.String
getPortLocation()
Gets the physical location of the port as a String in the form "BUS-[HUB1.HUB2.etc]PORT_NUMBER".int
getProductID()
Gets the 16-bit Product Identification number for the serial port, assuming it is USB-based.int
getReadTimeout()
Gets the number of milliseconds of inactivity to tolerate before returning from areadBytes(byte[],int)
call.boolean
getRI()
Returns whether the RI line is currently asserted.boolean
getRTS()
Returns whether the RTS line is currently asserted.String
getSerialNumber()
Gets the Serial Number for the serial port, assuming it is USB-based.String
getSystemPortName()
Gets the operating system-defined device name corresponding to this serial port.String
getSystemPortPath()
Gets the operating system-defined device path corresponding to this serial port.int
getVendorID()
Gets the 16-bit Vendor Identification number for the serial port, assuming it is USB-based.static String
getVersion()
Returns the current version of the jSerialComm library.int
getWriteTimeout()
Gets the number of milliseconds of inactivity to tolerate before returning from awriteBytes(byte[],int)
call.boolean
isOpen()
Returns whether the port is currently open and available for communication.boolean
openPort()
Opens this serial port for reading and writing.boolean
openPort(int safetySleepTime)
Opens this serial port for reading and writing with an optional delay time.boolean
openPort(int safetySleepTime, int deviceSendQueueSize, int deviceReceiveQueueSize)
Opens this serial port for reading and writing with an optional delay time and user-specified device buffer size.int
readBytes(byte[] buffer, int bytesToRead)
Reads up to bytesToRead raw data bytes from the serial port and stores them in the buffer.int
readBytes(byte[] buffer, int bytesToRead, int offset)
Reads up to bytesToRead raw data bytes from the serial port and stores them in the buffer starting at the indicated offset.void
removeDataListener()
Removes the associatedSerialPortDataListener
from the serial port interface.static boolean
setAndroidContext(Object androidApp)
Registers an application context to be used by the library when running on an Android device.boolean
setBaudRate(int newBaudRate)
Sets the desired baud rate for this serial port.boolean
setBreak()
Sets the BREAK signal on the serial control line.boolean
setComPortParameters(int newBaudRate, int newDataBits, int newStopBits, int newParity)
Sets all serial port parameters at one time.boolean
setComPortParameters(int newBaudRate, int newDataBits, int newStopBits, int newParity, boolean useRS485Mode)
Sets all serial port parameters at one time.boolean
setComPortTimeouts(int newTimeoutMode, int newReadTimeout, int newWriteTimeout)
Sets the serial port read and write timeout parameters.boolean
setDTR()
Sets the state of the DTR line to 1.boolean
setFlowControl(int newFlowControlSettings)
Specifies what kind of flow control to enable for this serial port.boolean
setNumDataBits(int newDataBits)
Sets the desired number of data bits per word.boolean
setNumStopBits(int newStopBits)
Sets the desired number of stop bits per word.boolean
setParity(int newParity)
Sets the desired parity error-detection scheme to be used.boolean
setRs485ModeParameters(boolean useRS485Mode, boolean rs485RtsActiveHigh, boolean enableTermination, boolean rxDuringTx, int delayBeforeSendMicroseconds, int delayAfterSendMicroseconds)
Sets RS-485 mode and its parameters for the device.boolean
setRs485ModeParameters(boolean useRS485Mode, boolean rs485RtsActiveHigh, int delayBeforeSendMicroseconds, int delayAfterSendMicroseconds)
Sets RS-485 mode and its parameters for the device.boolean
setRTS()
Sets the state of the RTS line to 1.boolean
setXonXoffCharacters(byte xonStartCharacter, byte xoffStopCharacter)
Sets custom XON/XOFF flow control characters for the device.String
toString()
Returns the same output as callinggetPortDescription()
.int
writeBytes(byte[] buffer, int bytesToWrite)
Writes up to bytesToWrite raw data bytes from the buffer parameter to the serial port.int
writeBytes(byte[] buffer, int bytesToWrite, int offset)
Writes up to bytesToWrite raw data bytes from the buffer parameter to the serial port starting at the indicated offset.
-
-
-
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_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_TIMED_OUT
public static final int LISTENING_EVENT_TIMED_OUT
- 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
-
LISTENING_EVENT_BREAK_INTERRUPT
public static final int LISTENING_EVENT_BREAK_INTERRUPT
- See Also:
- Constant Field Values
-
LISTENING_EVENT_CARRIER_DETECT
public static final int LISTENING_EVENT_CARRIER_DETECT
- See Also:
- Constant Field Values
-
LISTENING_EVENT_CTS
public static final int LISTENING_EVENT_CTS
- See Also:
- Constant Field Values
-
LISTENING_EVENT_DSR
public static final int LISTENING_EVENT_DSR
- See Also:
- Constant Field Values
-
LISTENING_EVENT_RING_INDICATOR
public static final int LISTENING_EVENT_RING_INDICATOR
- See Also:
- Constant Field Values
-
LISTENING_EVENT_FRAMING_ERROR
public static final int LISTENING_EVENT_FRAMING_ERROR
- See Also:
- Constant Field Values
-
LISTENING_EVENT_FIRMWARE_OVERRUN_ERROR
public static final int LISTENING_EVENT_FIRMWARE_OVERRUN_ERROR
- See Also:
- Constant Field Values
-
LISTENING_EVENT_SOFTWARE_OVERRUN_ERROR
public static final int LISTENING_EVENT_SOFTWARE_OVERRUN_ERROR
- See Also:
- Constant Field Values
-
LISTENING_EVENT_PARITY_ERROR
public static final int LISTENING_EVENT_PARITY_ERROR
- See Also:
- Constant Field Values
-
LISTENING_EVENT_PORT_DISCONNECTED
public static final int LISTENING_EVENT_PORT_DISCONNECTED
- See Also:
- Constant Field Values
-
-
Method Detail
-
toString
public final String toString()
Returns the same output as callinggetPortDescription()
. This may be useful for display containers which call a Java Object's default toString() method.
-
getVersion
public static String getVersion()
Returns the current version of the jSerialComm library.- Returns:
- The current library version.
-
addShutdownHook
public static void addShutdownHook(Thread hook)
Registers a shutdown hook that will run just before the application fully closes, due to either exiting normally or in response to a user interrupt such as Ctrl+C.These hooks can be used to carry out any final serial port operations that should be executed to ensure graceful disconnection or device shutdown.
There is no need to add a shutdown hook just to close all open ports, as this is done automatically by the library; however, any special reads, writes, or port handling that should take place prior to closing of the ports should be handled in a shutdown hook registered with this method.
- Parameters:
hook
- AThread
object that will run just before the application shuts down.- See Also:
Runtime.addShutdownHook(Thread)
,Thread
-
setAndroidContext
public static boolean setAndroidContext(Object androidApp)
Registers an application context to be used by the library when running on an Android device.This method must be called prior to using any other library functionality when running on an Android device. Failure to do so will result in a runtime error. Calling this method on a non-Android device will have no effect.
The preferred way to use this method is by calling "SerialPort.setAndroidContext(getApplication())" from your Android application's "onCreate()" method.
- Parameters:
androidApp
- The android.app.Application object for the current application.
-
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 array will also include any serial ports that your application currently has open, even if the devices attached to those ports become disconnected. As such, it is important that you always call
closePort()
on a SerialPort object if it becomes disconnected, which is detectable by inspecting the return values from the various read calls or by registering aSerialPortDataListener
for theLISTENING_EVENT_PORT_DISCONNECTED
event.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 repeated calls to this function will re-enumerate all serial ports and will return a completely unique set of array objects. As such, you should store a reference to the serial port object(s) you are interested in in your own application code.
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) throws SerialPortInvalidPortException
Allocates aSerialPort
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[*]".
On Android machines, this method is unavailable and will return null.- Parameters:
portDescriptor
- The desired serial port to use with this library.- Returns:
- A
SerialPort
object. - Throws:
SerialPortInvalidPortException
- If aSerialPort
object cannot be created due to a logical or formatting error in the portDescriptor parameter.
-
openPort
public final boolean openPort(int safetySleepTime, int deviceSendQueueSize, int deviceReceiveQueueSize)
Opens this serial port for reading and writing with an optional delay time and user-specified device buffer size.All serial port parameters or timeouts can be changed at any time before or after the port has been opened.
Note that when trying to open a Serial-over-Bluetooth port, this method may fail if the underlying device driver takes too long to connect. In that case, retrying this method may allow it to eventually connect and succeed.
Note that calling this method on an already opened port will simply reconfigure the port parameters.
- Parameters:
safetySleepTime
- The number of milliseconds to sleep before opening the port in case of frequent closing/openings.deviceSendQueueSize
- The requested size in bytes of the internal device driver's output queue (no effect on OSX)deviceReceiveQueueSize
- The requested size in bytes of the internal device driver's input queue (no effect on Linux/OSX)- Returns:
- Whether the port was successfully opened with a valid configuration.
-
openPort
public final boolean openPort(int safetySleepTime)
Opens this serial port for reading and writing with an optional delay time.All serial port parameters or timeouts can be changed at any time before or after the port has been opened.
Note that when trying to open a Serial-over-Bluetooth port, this method may fail if the underlying device driver takes too long to connect. In that case, retrying this method may allow it to eventually connect and succeed.
Note that calling this method on an already opened port will simply reconfigure the port parameters.
- Parameters:
safetySleepTime
- The number of milliseconds to sleep before opening the port in case of frequent closing/openings.- Returns:
- Whether the port was successfully opened with a valid configuration.
-
openPort
public final boolean openPort()
Opens this serial port for reading and writing.This method is equivalent to calling
openPort(int, int, int)
with a safetySleepTime of 0.All serial port parameters or timeouts can be changed at any time before or after the port has been opened.
Note that when trying to open a Serial-over-Bluetooth port, this method may fail if the underlying device driver takes too long to connect. In that case, retrying this method may allow it to eventually connect and succeed.
Note that calling this method on an already opened port will simply reconfigure the port parameters.
- Returns:
- Whether the port was successfully opened with a valid configuration.
-
closePort
public final boolean closePort()
Closes this serial port.Note that calling this method on an already closed port will simply return a value of true.
- Returns:
- Whether the port was successfully closed.
-
isOpen
public final boolean isOpen()
Returns whether the port is currently open and available for communication.- Returns:
- Whether the port is opened.
-
disablePortConfiguration
public final void disablePortConfiguration()
Disables the library from calling any of the underlying device driver configuration methods.This function should never be called except in very specific cases involving USB-to-Serial converters with buggy device drivers. In that case, this function must be called before attempting to open the port.
-
disableExclusiveLock
public final void disableExclusiveLock()
Disables the library from obtaining an exclusive lock on the serial port.This function should never be called except on very specific systems which do not support obtaining exclusive locks on system resources.
-
allowElevatedPermissionsRequest
public final void allowElevatedPermissionsRequest()
Allows the library to request elevation of the current user's permissions for use in making certain system-specific changes regarding this serial port.Examples of such changes include reducing the default latency for FTDI-type devices using the Windows registry, or adding the current Linux user to the same OS group to which the serial port belongs so that they can access the port without having to make these changes manually.
On Windows, if elevated permissions are required, a User Access Control (UAC) dialog box will appear, requesting authorization to carry out the privileged operation. On a non-Windows system, elevated permissions will be requested as if you had used the 'sudo' command in a terminal. As such, this function should not be used if your application does not contain or use a console.
Care should be taken when choosing to use this function as it may cause a prompt to appear during runtime of your final application requesting permission to make these elevated changes which may detract from the user experience of your application. When possible, making any system changes related to serial port usage should be done manually before attempting to use such ports, but in some situations, this function may make it easier for your application to automatically apply these necessary changes.
-
getLastErrorLocation
public final int getLastErrorLocation()
Returns the source code line location of the latest error encountered during execution of the native code for this port.This function must be called as soon as an error is encountered, or it may return an incorrect source code line location.
- Returns:
- Source line of latest native code error.
-
getLastErrorCode
public final int getLastErrorCode()
Returns the error number returned by the most recent native source code line that failed execution.This function must be called as soon as an error is encountered, or it may return an incorrect or invalid error code.
- Returns:
- Error number of the latest native code error.
-
bytesAvailable
public final int bytesAvailable()
Returns the number of bytes available without blocking ifreadBytes(byte[], int)
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.
-
bytesAwaitingWrite
public final int bytesAwaitingWrite()
Returns the number of bytes still waiting to be written in the device's output queue.Note that this method is not required or guaranteed to be implemented by the underlying device driver. Use it carefully and test your application to ensure it is working as you expect.
- Returns:
- The number of bytes currently waiting to be written, or -1 if the port is not open.
-
readBytes
public final int readBytes(byte[] buffer, int 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
In blocking-read mode, 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.
-
readBytes
public final int readBytes(byte[] buffer, int bytesToRead, int offset)
Reads up to bytesToRead raw data bytes from the serial port and stores them in the buffer starting at the indicated offset.The length of the byte buffer minus the offset must be greater than or equal to the value passed in for bytesToRead
In blocking-read mode, 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.offset
- The read buffer index into which to begin storing data.- 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, int 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
In blocking-write mode, this call will block until bytesToWrite bytes of data have been successfully written to the serial port. Otherwise, this method will return after bytesToWrite bytes of data have been written to the device driver's internal data buffer, which, in most cases, should be almost instantaneous unless the data buffer is full.
- 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.
-
writeBytes
public final int writeBytes(byte[] buffer, int bytesToWrite, int offset)
Writes up to bytesToWrite raw data bytes from the buffer parameter to the serial port starting at the indicated offset.The length of the byte buffer minus the offset must be greater than or equal to the value passed in for bytesToWrite
In blocking-write mode, this call will block until bytesToWrite bytes of data have been successfully written to the serial port. Otherwise, this method will return after bytesToWrite bytes of data have been written to the device driver's internal data buffer, which, in most cases, should be almost instantaneous unless the data buffer is full.
- 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.offset
- The buffer index from which to begin writing to the serial port.- Returns:
- The number of bytes successfully written, or -1 if there was an error writing to the port.
-
getDeviceWriteBufferSize
public final int getDeviceWriteBufferSize()
Returns the underlying transmit buffer size used by the serial port device driver. The device or operating system may choose to misrepresent this value.Only Windows and Linux-based operating systems are potentially able to return a correct value for this method. On other operating systems, this value is undefined.
- Returns:
- The underlying device transmit buffer size.
-
getDeviceReadBufferSize
public final int getDeviceReadBufferSize()
Returns the underlying receive buffer size used by the serial port device driver. The device or operating system may choose to misrepresent this value.Only Windows and Linux-based operating systems are potentially able to return a correct value for this method. On other operating systems, this value is undefined.
- Returns:
- The underlying device receive buffer size.
-
setBreak
public final boolean setBreak()
Sets the BREAK signal on the serial control line.- Returns:
- true if successful, false if not.
-
clearBreak
public final boolean clearBreak()
Clears the BREAK signal from the serial control line.- Returns:
- true if successful, false if not.
-
setRTS
public final boolean setRTS()
Sets the state of the RTS line to 1.- Returns:
- true if successful, false if not.
-
clearRTS
public final boolean clearRTS()
Clears the state of the RTS line to 0.- Returns:
- true if successful, false if not.
-
setDTR
public final boolean setDTR()
Sets the state of the DTR line to 1.- Returns:
- true if successful, false if not.
-
clearDTR
public final boolean clearDTR()
Clears the state of the DTR line to 0.- Returns:
- true if successful, false if not.
-
getCTS
public final boolean getCTS()
Returns whether the CTS line is currently asserted.- Returns:
- Whether or not the CTS line is asserted.
-
getDSR
public final boolean getDSR()
Returns whether the DSR line is currently asserted.- Returns:
- Whether or not the DSR line is asserted.
-
getDCD
public final boolean getDCD()
Returns whether the DCD line is currently asserted.- Returns:
- Whether or not the DCD line is asserted.
-
getDTR
public final boolean getDTR()
Returns whether the DTR line is currently asserted.Note that polling this line's status is not supported on Windows, so results may be incorrect.
- Returns:
- Whether or not the DTR line is asserted.
-
getRTS
public final boolean getRTS()
Returns whether the RTS line is currently asserted.Note that polling this line's status is not supported on Windows, so results may be incorrect.
- Returns:
- Whether or not the RTS line is asserted.
-
getRI
public final boolean getRI()
Returns whether the RI line is currently asserted.- Returns:
- Whether or not the RI line is asserted.
-
addDataListener
public final boolean addDataListener(SerialPortDataListener listener)
Adds aSerialPortDataListener
to the serial port interface.Calling this function enables event-based serial port callbacks to be used instead of direct serial port read/write calls or the
InputStream
/OutputStream
interface.The parameter passed into this method must be an implementation of either
SerialPortDataListener
,SerialPortDataListenerWithExceptions
,SerialPortPacketListener
,SerialPortMessageListener
orSerialPortMessageListenerWithExceptions
. TheSerialPortMessageListener
orSerialPortMessageListenerWithExceptions
interface should be used if you plan to use event-based reading of delimited data messages over the serial port. TheSerialPortPacketListener
interface should be used if you plan to use event-based reading of full data packets over the serial port. Otherwise, the simplerSerialPortDataListener
orSerialPortDataListenerWithExceptions
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
,SerialPortDataListenerWithExceptions
,SerialPortPacketListener
,SerialPortMessageListener
, andSerialPortMessageListenerWithExceptions
for more information.- Parameters:
listener
- ASerialPortDataListener
,SerialPortDataListenerWithExceptions
,SerialPortPacketListener
,SerialPortMessageListener
, orSerialPortMessageListenerWithExceptions
implementation to be used for event-based serial port communications.- Returns:
- Whether the listener was successfully registered with the serial port.
- See Also:
SerialPortDataListener
,SerialPortDataListenerWithExceptions
,SerialPortPacketListener
,SerialPortMessageListener
,SerialPortMessageListenerWithExceptions
-
flushDataListener
public final void flushDataListener()
Flushes any already-received data from the registeredSerialPortDataListener
that has not yet triggered an event.
-
removeDataListener
public final void removeDataListener()
Removes the associatedSerialPortDataListener
from the serial port interface.
-
getInputStream
public final InputStream getInputStream()
Returns anInputStream
object associated with this serial port.Allows for easier read access of the underlying data stream and abstracts away many low-level read details.
Note that any time a method is marked as throwable for an
IOException
in the official JavaInputStream
documentation, you can catch this exception directly, or you can choose to catch either aSerialPortIOException
or aSerialPortTimeoutException
(or both) which may make it easier for your code to determine why the exception was thrown. In general, aSerialPortIOException
means that the port is having connectivity issues, while aSerialPortTimeoutException
indicates that a user timeout has been reached before valid data was able to be returned (as specified in thesetComPortTimeouts(int, int, int)
method).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
-
getInputStreamWithSuppressedTimeoutExceptions
public final InputStream getInputStreamWithSuppressedTimeoutExceptions()
Returns anInputStream
object associated with this serial port, with read timeout exceptions completely suppressed.Allows for easier read access of the underlying data stream and abstracts away many low-level read details.
Note that any time a method is marked as throwable for an
IOException
in the official JavaInputStream
documentation, you can catch this exception directly, or you can choose to catch either aSerialPortIOException
or aSerialPortTimeoutException
(or both) which may make it easier for your code to determine why the exception was thrown. In general, aSerialPortIOException
means that the port is having connectivity issues, while aSerialPortTimeoutException
indicates that a user timeout has been reached before valid data was able to be returned (as specified in thesetComPortTimeouts(int, int, int)
method). When anInputStream
is returned using this method, aSerialPortTimeoutException
will never be thrown.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 anOutputStream
object associated with this serial port.Allows for easier write access to the underlying data stream and abstracts away many low-level writing details.
Note that any time a method is marked as throwable for an
IOException
in the official JavaInputStream
documentation, you can catch this exception directly, or you can choose to catch either aSerialPortIOException
or aSerialPortTimeoutException
(or both) which may make it easier for your code to determine why the exception was thrown. In general, aSerialPortIOException
means that the port is having connectivity issues, while aSerialPortTimeoutException
indicates that a user timeout has been reached before valid data was able to be returned (as specified in thesetComPortTimeouts(int, int, int)
method).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
-
flushIOBuffers
public final boolean flushIOBuffers()
Flushes the serial port's Rx/Tx device buffers.If this function is called before the port is open, then the buffers will be flushed immediately after opening the port. If called on an already-open port, flushing of the buffers will happen immediately.
Note that flushing serial buffers will always work on real serial ports; however, many USB-to-serial converters do not accurately implement this functionality, so the flushing may not always work as expected, especially immediately after opening a new port.
- Returns:
- Whether the IO buffers were (or will be) successfully flushed.
-
setComPortParameters
public final boolean setComPortParameters(int newBaudRate, int newDataBits, int newStopBits, int newParity)
Sets all serial port parameters at one time.Allows the user to set all port parameters with a single function call.
The baud rate can be any arbitrary value specified by the user. The default value is 9600 baud. The data bits parameter 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
).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.- Returns:
- Whether the port configuration is valid or disallowed on this system (only meaningful after the port is already opened).
- See Also:
ONE_STOP_BIT
,ONE_POINT_FIVE_STOP_BITS
,TWO_STOP_BITS
,NO_PARITY
,EVEN_PARITY
,ODD_PARITY
,MARK_PARITY
,SPACE_PARITY
-
setComPortParameters
public final boolean setComPortParameters(int newBaudRate, int newDataBits, int newStopBits, int newParity, boolean useRS485Mode)
Sets all serial port parameters at one time.Allows the user to set all port parameters with a single function call.
The baud rate can be any arbitrary value specified by the user. The default value is 9600 baud. The data bits parameter 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
).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
.RS-485 mode can be used to enable transmit/receive mode signaling using the RTS pin. This mode should be set if you plan to use this library with an RS-485 device. Note that this mode requires support from the underlying device driver, so it may not work with all RS-485 devices.
- 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.useRS485Mode
- Whether to enable RS-485 mode.- Returns:
- Whether the port configuration is valid or disallowed on this system (only meaningful after the port is already opened).
- 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 boolean setComPortTimeouts(int newTimeoutMode, int newReadTimeout, int newWriteTimeout)
Sets the serial port read and write timeout parameters.Note that time-based write timeouts are only available on Windows systems. There is no functionality to set a write timeout on other operating systems.
The built-in timeout mode constants should be used (
TIMEOUT_NONBLOCKING
,TIMEOUT_READ_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
Write Blocking:TIMEOUT_WRITE_BLOCKING
Read Semi-blocking:TIMEOUT_READ_SEMI_BLOCKING
Read Full-blocking:TIMEOUT_READ_BLOCKING
Scanner:TIMEOUT_SCANNER
The
TIMEOUT_NONBLOCKING
mode specifies that correspondingreadBytes(byte[],int)
andwriteBytes(byte[],int)
calls will return immediately with any available data.The
TIMEOUT_WRITE_BLOCKING
mode specifies that a corresponding write call will block until all data bytes have been successfully written to the output serial device.The
TIMEOUT_READ_SEMI_BLOCKING
mode specifies that a corresponding read call will block until either newReadTimeout milliseconds of inactivity have elapsed or at least 1 byte of data can be read.The
TIMEOUT_READ_BLOCKING
mode specifies that a corresponding read call will block until either newReadTimeout milliseconds have elapsed since the start of the call or the total number of requested bytes can be returned.The
TIMEOUT_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[],int)
orwriteBytes(byte[],int)
call should block forever until it can return successfully (based upon the current timeout mode specified).In order to specify that both a blocking read and write mode should be used,
TIMEOUT_WRITE_BLOCKING
can be OR'd together with any of the read modes to pass to the first parameter.It is important to note that non-Windows operating systems only allow decisecond (1/10th of a second) granularity for serial port timeouts. As such, your millisecond timeout value will be rounded to the nearest decisecond under Linux or Mac OS. To ensure consistent performance across multiple platforms, it is advisable that you set your timeout values to be multiples of 100, although this is not strictly enforced.
Also note that if the serial port has an event-based data listener actively registered for the event type
LISTENING_EVENT_DATA_RECEIVED
, all serial port timeout settings are ignored.- Parameters:
newTimeoutMode
- The new timeout mode as specified above.newReadTimeout
- The number of milliseconds of inactivity to tolerate before returning from areadBytes(byte[],int)
call.newWriteTimeout
- The number of milliseconds of inactivity to tolerate before returning from awriteBytes(byte[],int)
call (effective only on Windows).- Returns:
- Whether the port configuration is valid or disallowed on this system (only meaningful after the port is already opened).
-
setBaudRate
public final boolean 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.- Returns:
- Whether the port configuration is valid or disallowed on this system (only meaningful after the port is already opened).
-
setNumDataBits
public final boolean 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.- Returns:
- Whether the port configuration is valid or disallowed on this system (only meaningful after the port is already opened).
-
setNumStopBits
public final boolean setNumStopBits(int newStopBits)
Sets the desired number of stop bits per word.The default number of stop bits per word is 1. Built-in stop-bit constants should be used 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.- Returns:
- Whether the port configuration is valid or disallowed on this system (only meaningful after the port is already opened).
- See Also:
ONE_STOP_BIT
,ONE_POINT_FIVE_STOP_BITS
,TWO_STOP_BITS
-
setFlowControl
public final boolean 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.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
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.
Also note that some flow control modes are only available on certain operating systems. Valid modes for each OS are:
Windows: CTS, RTS/CTS, DSR, DTR/DSR, Xon, Xoff, Xon/Xoff
Mac: RTS/CTS, Xon, Xoff, Xon/Xoff
Linux: RTS/CTS, Xon, Xoff, Xon/Xoff- Parameters:
newFlowControlSettings
- The desired type of flow control to enable for this serial port.- Returns:
- Whether the port configuration is valid or disallowed on this system (only meaningful after the port is already opened).
- 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 boolean 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.- Returns:
- Whether the port configuration is valid or disallowed on this system (only meaningful after the port is already opened).
- See Also:
NO_PARITY
,EVEN_PARITY
,ODD_PARITY
,MARK_PARITY
,SPACE_PARITY
-
setRs485ModeParameters
public final boolean setRs485ModeParameters(boolean useRS485Mode, boolean rs485RtsActiveHigh, int delayBeforeSendMicroseconds, int delayAfterSendMicroseconds)
Sets RS-485 mode and its parameters for the device. This is a wrapper aroundsetRs485ModeParameters(boolean, boolean, boolean, boolean, int, int)
for backward-compatibility which disables bus termination and receiving data while transmitting.- Parameters:
useRS485Mode
- Whether to enable RS-485 mode.rs485RtsActiveHigh
- Whether to set the RTS line to 1 when transmitting (effective only on Linux).delayBeforeSendMicroseconds
- The time to wait after enabling transmit mode before sending the first data bit (effective only on Linux).delayAfterSendMicroseconds
- The time to wait after sending the last data bit before disabling transmit mode (effective only on Linux).- Returns:
- Whether the port configuration is valid or disallowed on this system (only meaningful after the port is already opened).
- See Also:
setRs485ModeParameters(boolean, boolean, boolean, boolean, int, int)
-
setRs485ModeParameters
public final boolean setRs485ModeParameters(boolean useRS485Mode, boolean rs485RtsActiveHigh, boolean enableTermination, boolean rxDuringTx, int delayBeforeSendMicroseconds, int delayAfterSendMicroseconds)
Sets RS-485 mode and its parameters for the device.RS-485 mode can be used to enable transmit/receive mode signaling using the RTS pin. This mode should be set if you plan to use this library with an RS-485 device. Note that this mode requires support from the underlying device driver, so it may not work with all RS-485 devices. On the other hand there are devices that operate in RS-485 mode by default and do not require explicit configuration (like some USB to RS-485 adapters).
Please note that the parameters beyond useRS485Mode are only effective on Linux.
The RTS "active high" parameter specifies that the logical level of the RTS line will be set to 1 when transmitting and 0 when receiving.
The delay parameters specify how long to wait before or after transmission of data after enabling or before disabling transmission mode via the RTS pin.
- Parameters:
useRS485Mode
- Whether to enable RS-485 mode.rs485RtsActiveHigh
- Whether to set the RTS line to 1 when transmitting (effective only on Linux).enableTermination
- Whether to enable RS-485 bus termination on systems supporting this feature (effective only on Linux).rxDuringTx
- Whether to receive data while transmitting. This usually means that data sent will be read back (effective only on Linux).delayBeforeSendMicroseconds
- The time to wait after enabling transmit mode before sending the first data bit (effective only on Linux).delayAfterSendMicroseconds
- The time to wait after sending the last data bit before disabling transmit mode (effective only on Linux).- Returns:
- Whether the port configuration is valid or disallowed on this system (only meaningful after the port is already opened).
-
setXonXoffCharacters
public final boolean setXonXoffCharacters(byte xonStartCharacter, byte xoffStopCharacter)
Sets custom XON/XOFF flow control characters for the device.Custom characters should almost never be used, as most devices expect the XON/START character to be 17 and the XOFF/STOP character to be 13. If your device expects different flow control characters, they may be changed using this function.
- Parameters:
xonStartCharacter
- The decimal-based character to use as an XON signal.xoffStopCharacter
- The decimal-based character to use as an XOFF signal.- Returns:
- Whether the port configuration is valid or disallowed on this system (only meaningful after the port is already opened).
-
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 either unique or 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. The name will be unique, returning a different string for multiples of the same type of device connected to a single computer.- Returns:
- The system-defined device name of this serial port.
-
getSystemPortPath
public final String getSystemPortPath()
Gets the operating system-defined device path corresponding to this serial port. The path will be unique, returning a different string for multiples of the same type of device connected to a single computer.- Returns:
- The system-defined device path of this serial port.
-
getPortDescription
public final String getPortDescription()
Gets a description of the port as reported by the device itself.This will only be available for USB-connected devices that report a product description. Otherwise, it will return the same value as
getDescriptivePortName()
.- Returns:
- The port description as reported by the device itself.
-
getPortLocation
public final String getPortLocation()
Gets the physical location of the port as a String in the form "BUS-[HUB1.HUB2.etc]PORT_NUMBER"."[HUB1.HUB2...]" is an optional field that refers to the hierarchy of USB hub numbers that a device might be plugged into. For example, a USB-to-Serial Converter plugged into the third port of a USB hub which is plugged into another USB hub which is plugged into a USB bus on a PC might have the port location "1-1.1.3". A device plugged directly into a PC-based serial or USB port might have a port location of "1-2". A virtual (non-physical) serial port might return a value of "0-0" since this port has no physical location.
This method may be used to uniquely identify a device in the case where multiples of the same type of device are present on the same system. In this case, the operating system might assign each device to a different port number upon reboot; however, the port locations will remain the same as long as each device remains physically plugged into the same port.
Note, if you manually specified the port location using
getCommPort(java.lang.String)
, this method will always return "0-0".- Returns:
- The physical port location in the form "BUS-[HUB1.HUB2.etc]PORT_NUMBER".
-
getVendorID
public final int getVendorID()
Gets the 16-bit Vendor Identification number for the serial port, assuming it is USB-based.- Returns:
- The VID of this serial port, or -1 if it is not USB-based.
-
getProductID
public final int getProductID()
Gets the 16-bit Product Identification number for the serial port, assuming it is USB-based.- Returns:
- The PID of this serial port, or -1 if it is not USB-based.
-
getSerialNumber
public final String getSerialNumber()
Gets the Serial Number for the serial port, assuming it is USB-based.- Returns:
- The Serial Number of this serial port, or "Unknown" if it is not USB-based.
-
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.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 areadBytes(byte[],int)
call.A value of 0 in blocking-read mode indicates that a
readBytes(byte[],int)
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[],int)
call will return.- Returns:
- The number of milliseconds of inactivity to tolerate before returning from a
readBytes(byte[],int)
call.
-
getWriteTimeout
public final int getWriteTimeout()
Gets the number of milliseconds of inactivity to tolerate before returning from awriteBytes(byte[],int)
call.A value of 0 in blocking-write mode indicates that a
writeBytes(byte[],int)
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[],int)
call will return.Note that write timeouts are only available on Windows operating systems. This value is ignored on all other systems.
- Returns:
- The number of milliseconds of inactivity to tolerate before returning from a
writeBytes(byte[],int)
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
Note that some flow control modes are only available on certain operating systems. Valid modes for each OS are:
Windows: CTS, RTS/CTS, DSR, DTR/DSR, Xon, Xoff, Xon/Xoff
Mac: RTS/CTS, Xon, Xoff, Xon/Xoff
Linux: RTS/CTS, Xon, Xoff, Xon/Xoff- 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
-
-