Package gnu.io
Class RXTXPort
java.lang.Object
gnu.io.CommPort
gnu.io.SerialPort
gnu.io.RXTXPort
An extension of gnu.io.SerialPort
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final boolean
protected static final boolean
protected static final boolean
protected static final boolean
protected static final boolean
protected static final boolean
Fields inherited from class gnu.io.SerialPort
DATABITS_5, DATABITS_6, DATABITS_7, DATABITS_8, FLOWCONTROL_NONE, FLOWCONTROL_RTSCTS_IN, FLOWCONTROL_RTSCTS_OUT, FLOWCONTROL_XONXOFF_IN, FLOWCONTROL_XONXOFF_OUT, PARITY_EVEN, PARITY_MARK, PARITY_NONE, PARITY_ODD, PARITY_SPACE, STOPBITS_1, STOPBITS_1_5, STOPBITS_2
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
boolean
boolean
Extension to CommAPI returns boolean true on successvoid
close()
void
void
void
void
enableReceiveFraming
(int f) Receive framing controlvoid
enableReceiveThreshold
(int thresh) void
enableReceiveTimeout
(int time) protected void
finalize()
Finalize the portint
Extension to CommAPIint
boolean
Extension to CommAPI returns boolean true on successint
int
Extension to CommAPIbyte
Extension to CommAPI This is an extension to CommAPI.int
int
get the InputStreamboolean
Extension to CommAPI returns boolean true on successint
get the OutputStreamint
byte
Extension to CommAPI This is an extension to CommAPI.int
int
int
int
Extension to CommAPI This is an extension to CommAPI.boolean
isCD()
boolean
isCTS()
boolean
isDSR()
boolean
isDTR()
boolean
boolean
boolean
boolean
isRI()
boolean
isRTS()
protected int
RXTXPort read methodsprotected boolean
nativeDrain
(boolean i) int
void
notifyOnBreakInterrupt
(boolean enable) void
notifyOnCarrierDetect
(boolean enable) void
notifyOnCTS
(boolean enable) void
notifyOnDataAvailable
(boolean enable) void
notifyOnDSR
(boolean enable) void
notifyOnFramingError
(boolean enable) void
notifyOnOutputEmpty
(boolean enable) void
notifyOnOverrunError
(boolean enable) void
notifyOnParityError
(boolean enable) void
notifyOnRingIndicator
(boolean enable) protected int
readArray
(byte[] b, int off, int len) protected int
readByte()
protected int
readTerminatedArray
(byte[] b, int off, int len, byte[] t) void
Remove the serial port event listenervoid
sendBreak
(int duration) Write to the portboolean
sendEvent
(int event, boolean state) boolean
setBaudBase
(int BaudBase) Extension to CommAPI.boolean
setCallOutHangup
(boolean NoHup) Extension to CommAPI returns boolean true on successboolean
setDivisor
(int Divisor) Extension to CommAPI.void
setDTR
(boolean state) boolean
setEndOfInputChar
(byte b) Extension to CommAPI This is an extension to CommAPI.void
setFlowControlMode
(int flowcontrol) void
setInputBufferSize
(int size) boolean
Extension to CommAPI returns boolean true on successvoid
setOutputBufferSize
(int size) boolean
setParityErrorChar
(byte b) Extension to CommAPI This is an extension to CommAPI.void
setRcvFifoTrigger
(int trigger) Deprecated.deprecated but used in Kaffevoid
setRTS
(boolean state) void
setSerialPortParams
(int b, int d, int s, int p) boolean
setUARTType
(String type, boolean test) Extension to CommAPI This is an extension to CommAPI.static int
staticGetBaudRate
(String port) Extension to CommAPI This is an extension to CommAPI.static int
staticGetDataBits
(String port) Extension to CommAPI This is an extension to CommAPI.static int
staticGetParity
(String port) Extension to CommAPI This is an extension to CommAPI.static int
staticGetStopBits
(String port) Extension to CommAPI This is an extension to CommAPI.static boolean
staticIsCD
(String port) Extension to CommAPI This is an extension to CommAPI.static boolean
staticIsCTS
(String port) Extension to CommAPI This is an extension to CommAPI.static boolean
staticIsDSR
(String port) Extension to CommAPI This is an extension to CommAPI.static boolean
staticIsDTR
(String port) Extension to CommAPI This is an extension to CommAPI.static boolean
staticIsRI
(String port) Extension to CommAPI This is an extension to CommAPI.static boolean
staticIsRTS
(String port) Extension to CommAPI This is an extension to CommAPI.static boolean
staticSetDSR
(String port, boolean flag) Extension to CommAPI This is an extension to CommAPI.static boolean
staticSetDTR
(String port, boolean flag) Extension to CommAPI This is an extension to CommAPI.static boolean
staticSetRTS
(String port, boolean flag) Extension to CommAPI This is an extension to CommAPI.static void
staticSetSerialPortParams
(String f, int b, int d, int s, int p) Extension to CommAPI This is an extension to CommAPI.protected void
Give the native code a chance to start listening to the hardware or should we say give the native code control of the issue.protected void
writeArray
(byte[] b, int off, int len, boolean i) protected void
writeByte
(int b, boolean i)
-
Field Details
-
debug
protected static final boolean debug- See Also:
-
debug_read
protected static final boolean debug_read- See Also:
-
debug_read_results
protected static final boolean debug_read_results- See Also:
-
debug_write
protected static final boolean debug_write- See Also:
-
debug_events
protected static final boolean debug_events- See Also:
-
debug_verbose
protected static final boolean debug_verbose- See Also:
-
-
Constructor Details
-
RXTXPort
Open the named port- Parameters:
name
- the name of the device to open- Throws:
PortInUseException
- See Also:
-
-
Method Details
-
getOutputStream
get the OutputStream- Specified by:
getOutputStream
in classCommPort
- Returns:
- OutputStream
-
getInputStream
get the InputStream- Specified by:
getInputStream
in classCommPort
- Returns:
- InputStream
- See Also:
-
setSerialPortParams
public void setSerialPortParams(int b, int d, int s, int p) throws UnsupportedCommOperationException - Specified by:
setSerialPortParams
in classSerialPort
- Throws:
UnsupportedCommOperationException
-
getBaudRate
public int getBaudRate()- Specified by:
getBaudRate
in classSerialPort
- Returns:
- int representing the baudrate This will not behave as expected with custom speeds
-
getDataBits
public int getDataBits()- Specified by:
getDataBits
in classSerialPort
- Returns:
- int representing the databits
-
getStopBits
public int getStopBits()- Specified by:
getStopBits
in classSerialPort
- Returns:
- int representing the stopbits
-
getParity
public int getParity()- Specified by:
getParity
in classSerialPort
- Returns:
- int representing the parity
-
setFlowControlMode
public void setFlowControlMode(int flowcontrol) - Specified by:
setFlowControlMode
in classSerialPort
- Parameters:
flowcontrol
- FLOWCONTROL_NONE is default- See Also:
-
getFlowControlMode
public int getFlowControlMode()- Specified by:
getFlowControlMode
in classSerialPort
- Returns:
- int representing the flowmode
-
enableReceiveFraming
Receive framing control- Specified by:
enableReceiveFraming
in classCommPort
- Parameters:
f
- framming- Throws:
UnsupportedCommOperationException
-
disableReceiveFraming
public void disableReceiveFraming()- Specified by:
disableReceiveFraming
in classCommPort
-
isReceiveFramingEnabled
public boolean isReceiveFramingEnabled()- Specified by:
isReceiveFramingEnabled
in classCommPort
- Returns:
- true if framing is enabled
-
getReceiveFramingByte
public int getReceiveFramingByte()- Specified by:
getReceiveFramingByte
in classCommPort
- Returns:
- int representing the framing byte
-
NativegetReceiveTimeout
public int NativegetReceiveTimeout()- Returns:
- int the timeout
-
disableReceiveTimeout
public void disableReceiveTimeout()- Specified by:
disableReceiveTimeout
in classCommPort
-
enableReceiveTimeout
public void enableReceiveTimeout(int time) - Specified by:
enableReceiveTimeout
in classCommPort
- Parameters:
time
-
-
isReceiveTimeoutEnabled
public boolean isReceiveTimeoutEnabled()- Specified by:
isReceiveTimeoutEnabled
in classCommPort
- Returns:
- boolean true if recieve timeout is enabled
-
getReceiveTimeout
public int getReceiveTimeout()- Specified by:
getReceiveTimeout
in classCommPort
- Returns:
- int the timeout
-
enableReceiveThreshold
public void enableReceiveThreshold(int thresh) - Specified by:
enableReceiveThreshold
in classCommPort
- Parameters:
thresh
- threshold
-
disableReceiveThreshold
public void disableReceiveThreshold()- Specified by:
disableReceiveThreshold
in classCommPort
-
getReceiveThreshold
public int getReceiveThreshold()- Specified by:
getReceiveThreshold
in classCommPort
- Returns:
- int the recieve threshold
-
isReceiveThresholdEnabled
public boolean isReceiveThresholdEnabled()- Specified by:
isReceiveThresholdEnabled
in classCommPort
- Returns:
- boolean true if receive threshold is enabled
-
setInputBufferSize
public void setInputBufferSize(int size) - Specified by:
setInputBufferSize
in classCommPort
- Parameters:
size
-
-
getInputBufferSize
public int getInputBufferSize()- Specified by:
getInputBufferSize
in classCommPort
-
setOutputBufferSize
public void setOutputBufferSize(int size) - Specified by:
setOutputBufferSize
in classCommPort
- Parameters:
size
-
-
getOutputBufferSize
public int getOutputBufferSize()- Specified by:
getOutputBufferSize
in classCommPort
- Returns:
- in the output buffer size
-
isDTR
public boolean isDTR()- Specified by:
isDTR
in classSerialPort
- Returns:
- true if DTR is set
-
setDTR
public void setDTR(boolean state) - Specified by:
setDTR
in classSerialPort
- Parameters:
state
-
-
setRTS
public void setRTS(boolean state) - Specified by:
setRTS
in classSerialPort
- Parameters:
state
-
-
isCTS
public boolean isCTS()- Specified by:
isCTS
in classSerialPort
- Returns:
- boolean true if CTS is set
-
isDSR
public boolean isDSR()- Specified by:
isDSR
in classSerialPort
- Returns:
- boolean true if DSR is set
-
isCD
public boolean isCD()- Specified by:
isCD
in classSerialPort
- Returns:
- boolean true if CD is set
-
isRI
public boolean isRI()- Specified by:
isRI
in classSerialPort
- Returns:
- boolean true if RI is set
-
isRTS
public boolean isRTS()- Specified by:
isRTS
in classSerialPort
- Returns:
- boolean true if RTS is set
-
sendBreak
public void sendBreak(int duration) Write to the port- Specified by:
sendBreak
in classSerialPort
- Parameters:
duration
-
-
writeByte
- Throws:
IOException
-
writeArray
- Throws:
IOException
-
nativeDrain
- Throws:
IOException
-
nativeavailable
RXTXPort read methods- Throws:
IOException
-
readByte
- Throws:
IOException
-
readArray
- Throws:
IOException
-
readTerminatedArray
- Throws:
IOException
-
checkMonitorThread
public boolean checkMonitorThread() -
sendEvent
public boolean sendEvent(int event, boolean state) - Parameters:
event
-state
-- Returns:
- boolean true if the port is closing
-
addEventListener
- Specified by:
addEventListener
in classSerialPort
- Throws:
TooManyListenersException
-
removeEventListener
public void removeEventListener()Remove the serial port event listener- Specified by:
removeEventListener
in classSerialPort
-
waitForTheNativeCodeSilly
protected void waitForTheNativeCodeSilly()Give the native code a chance to start listening to the hardware or should we say give the native code control of the issue. This is important for applications that flicker the Monitor thread while keeping the port open. In worst case test cases this loops once or twice every time. -
notifyOnDataAvailable
public void notifyOnDataAvailable(boolean enable) - Specified by:
notifyOnDataAvailable
in classSerialPort
-
notifyOnOutputEmpty
public void notifyOnOutputEmpty(boolean enable) - Specified by:
notifyOnOutputEmpty
in classSerialPort
- Parameters:
enable
-
-
notifyOnCTS
public void notifyOnCTS(boolean enable) - Specified by:
notifyOnCTS
in classSerialPort
- Parameters:
enable
-
-
notifyOnDSR
public void notifyOnDSR(boolean enable) - Specified by:
notifyOnDSR
in classSerialPort
- Parameters:
enable
-
-
notifyOnRingIndicator
public void notifyOnRingIndicator(boolean enable) - Specified by:
notifyOnRingIndicator
in classSerialPort
- Parameters:
enable
-
-
notifyOnCarrierDetect
public void notifyOnCarrierDetect(boolean enable) - Specified by:
notifyOnCarrierDetect
in classSerialPort
- Parameters:
enable
-
-
notifyOnOverrunError
public void notifyOnOverrunError(boolean enable) - Specified by:
notifyOnOverrunError
in classSerialPort
- Parameters:
enable
-
-
notifyOnParityError
public void notifyOnParityError(boolean enable) - Specified by:
notifyOnParityError
in classSerialPort
- Parameters:
enable
-
-
notifyOnFramingError
public void notifyOnFramingError(boolean enable) - Specified by:
notifyOnFramingError
in classSerialPort
- Parameters:
enable
-
-
notifyOnBreakInterrupt
public void notifyOnBreakInterrupt(boolean enable) - Specified by:
notifyOnBreakInterrupt
in classSerialPort
- Parameters:
enable
-
-
close
public void close() -
finalize
protected void finalize()Finalize the port -
setRcvFifoTrigger
public void setRcvFifoTrigger(int trigger) Deprecated.deprecated but used in KaffeA dummy method added so RXTX compiles on Kaffee -
staticGetBaudRate
Extension to CommAPI This is an extension to CommAPI. It may not be supported on all operating systems. This is only accurate up to 38600 baud currently.- Parameters:
port
- the name of the port thats been preopened- Returns:
- BaudRate on success
- Throws:
UnsupportedCommOperationException
-
staticGetDataBits
Extension to CommAPI This is an extension to CommAPI. It may not be supported on all operating systems.- Parameters:
port
- the name of the port thats been preopened- Returns:
- DataBits on success
- Throws:
UnsupportedCommOperationException
-
staticGetParity
Extension to CommAPI This is an extension to CommAPI. It may not be supported on all operating systems.- Parameters:
port
- the name of the port thats been preopened- Returns:
- Parity on success
- Throws:
UnsupportedCommOperationException
-
staticGetStopBits
Extension to CommAPI This is an extension to CommAPI. It may not be supported on all operating systems.- Parameters:
port
- the name of the port thats been preopened- Returns:
- StopBits on success
- Throws:
UnsupportedCommOperationException
-
staticSetSerialPortParams
public static void staticSetSerialPortParams(String f, int b, int d, int s, int p) throws UnsupportedCommOperationException Extension to CommAPI This is an extension to CommAPI. It may not be supported on all operating systems. Set the SerialPort parameters 1.5 stop bits requires 5 databits- Parameters:
f
- filenameb
- baudrated
- databitss
- stopbitsp
- parity- Throws:
UnsupportedCommOperationException
- See Also:
-
staticSetDSR
public static boolean staticSetDSR(String port, boolean flag) throws UnsupportedCommOperationException Extension to CommAPI This is an extension to CommAPI. It may not be supported on all operating systems. Open the port and set DSR. remove lockfile and do not close This is so some software can appear to set the DSR before 'opening' the port a second time later on.- Returns:
- true on success
- Throws:
UnsupportedCommOperationException
-
staticSetDTR
public static boolean staticSetDTR(String port, boolean flag) throws UnsupportedCommOperationException Extension to CommAPI This is an extension to CommAPI. It may not be supported on all operating systems. Open the port and set DTR. remove lockfile and do not close This is so some software can appear to set the DTR before 'opening' the port a second time later on.- Returns:
- true on success
- Throws:
UnsupportedCommOperationException
-
staticSetRTS
public static boolean staticSetRTS(String port, boolean flag) throws UnsupportedCommOperationException Extension to CommAPI This is an extension to CommAPI. It may not be supported on all operating systems. Open the port and set RTS. remove lockfile and do not close This is so some software can appear to set the RTS before 'opening' the port a second time later on.- Returns:
- none
- Throws:
UnsupportedCommOperationException
-
staticIsRTS
Extension to CommAPI This is an extension to CommAPI. It may not be supported on all operating systems. find the fd and return RTS without using a Java open() call- Parameters:
port
-- Returns:
- true if asserted
- Throws:
UnsupportedCommOperationException
-
staticIsCD
Extension to CommAPI This is an extension to CommAPI. It may not be supported on all operating systems. find the fd and return CD without using a Java open() call- Parameters:
port
-- Returns:
- true if asserted
- Throws:
UnsupportedCommOperationException
-
staticIsCTS
Extension to CommAPI This is an extension to CommAPI. It may not be supported on all operating systems. find the fd and return CTS without using a Java open() call- Parameters:
port
-- Returns:
- true if asserted
- Throws:
UnsupportedCommOperationException
-
staticIsDSR
Extension to CommAPI This is an extension to CommAPI. It may not be supported on all operating systems. find the fd and return DSR without using a Java open() call- Parameters:
port
-- Returns:
- true if asserted
- Throws:
UnsupportedCommOperationException
-
staticIsDTR
Extension to CommAPI This is an extension to CommAPI. It may not be supported on all operating systems. find the fd and return DTR without using a Java open() call- Parameters:
port
-- Returns:
- true if asserted
- Throws:
UnsupportedCommOperationException
-
staticIsRI
Extension to CommAPI This is an extension to CommAPI. It may not be supported on all operating systems. find the fd and return RI without using a Java open() call- Parameters:
port
-- Returns:
- true if asserted
- Throws:
UnsupportedCommOperationException
-
getParityErrorChar
Extension to CommAPI This is an extension to CommAPI. It may not be supported on all operating systems.- Specified by:
getParityErrorChar
in classSerialPort
- Returns:
- int the Parity Error Character
- Throws:
UnsupportedCommOperationException
-
setParityErrorChar
Extension to CommAPI This is an extension to CommAPI. It may not be supported on all operating systems.- Specified by:
setParityErrorChar
in classSerialPort
- Parameters:
b
- Parity Error Character- Returns:
- boolean true on success
- Throws:
UnsupportedCommOperationException
-
getEndOfInputChar
Extension to CommAPI This is an extension to CommAPI. It may not be supported on all operating systems.- Specified by:
getEndOfInputChar
in classSerialPort
- Returns:
- int the End of Input Character
- Throws:
UnsupportedCommOperationException
-
setEndOfInputChar
Extension to CommAPI This is an extension to CommAPI. It may not be supported on all operating systems.- Specified by:
setEndOfInputChar
in classSerialPort
- Parameters:
b
- End Of Input Character- Returns:
- boolean true on success
- Throws:
UnsupportedCommOperationException
-
setUARTType
Extension to CommAPI This is an extension to CommAPI. It may not be supported on all operating systems.- Specified by:
setUARTType
in classSerialPort
- Parameters:
type
- String representation of the UART type which mayb be "none", "8250", "16450", "16550", "16550A", "16650", "16550V2" or "16750".test
- boolean flag to determin if the UART should be tested.- Returns:
- boolean true on success
- Throws:
UnsupportedCommOperationException
-
getUARTType
Extension to CommAPI This is an extension to CommAPI. It may not be supported on all operating systems.- Specified by:
getUARTType
in classSerialPort
- Returns:
- type String representation of the UART type which mayb be "none", "8250", "16450", "16550", "16550A", "16650", "16550V2" or "16750".
- Throws:
UnsupportedCommOperationException
-
setBaudBase
Extension to CommAPI. Set Baud Base to 38600 on Linux and W32 before using.- Specified by:
setBaudBase
in classSerialPort
- Parameters:
BaudBase
- The clock frequency divided by 16. Default BaudBase is 115200.- Returns:
- true on success
- Throws:
UnsupportedCommOperationException
IOException
-
getBaudBase
Extension to CommAPI- Specified by:
getBaudBase
in classSerialPort
- Returns:
- BaudBase
- Throws:
UnsupportedCommOperationException
IOException
-
setDivisor
Extension to CommAPI. Set Baud Base to 38600 on Linux and W32 before using.- Specified by:
setDivisor
in classSerialPort
- Parameters:
Divisor
-- Throws:
UnsupportedCommOperationException
IOException
-
getDivisor
Extension to CommAPI- Specified by:
getDivisor
in classSerialPort
- Returns:
- Divisor;
- Throws:
UnsupportedCommOperationException
IOException
-
setLowLatency
Extension to CommAPI returns boolean true on success- Specified by:
setLowLatency
in classSerialPort
- Throws:
UnsupportedCommOperationException
-
getLowLatency
Extension to CommAPI returns boolean true on success- Specified by:
getLowLatency
in classSerialPort
- Throws:
UnsupportedCommOperationException
-
setCallOutHangup
Extension to CommAPI returns boolean true on success- Specified by:
setCallOutHangup
in classSerialPort
- Throws:
UnsupportedCommOperationException
-
getCallOutHangup
Extension to CommAPI returns boolean true on success- Specified by:
getCallOutHangup
in classSerialPort
- Throws:
UnsupportedCommOperationException
-
clearCommInput
Extension to CommAPI returns boolean true on success
-