public final class RXTXPort extends SerialPort
SerialPort
Modifier and Type | Field and Description |
---|---|
protected static boolean |
debug |
protected static boolean |
debug_events |
protected static boolean |
debug_read |
protected static boolean |
debug_read_results |
protected static boolean |
debug_verbose |
protected static boolean |
debug_write |
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 and Description |
---|
RXTXPort(String name)
Open the named port
|
Modifier and Type | Method and Description |
---|---|
void |
addEventListener(SerialPortEventListener lsnr) |
boolean |
checkMonitorThread() |
boolean |
clearCommInput()
Extension to CommAPI
returns boolean true on success
|
void |
close() |
void |
disableReceiveFraming() |
void |
disableReceiveThreshold() |
void |
disableReceiveTimeout() |
void |
enableReceiveFraming(int f)
Receive framing control
|
void |
enableReceiveThreshold(int thresh) |
void |
enableReceiveTimeout(int time) |
protected void |
finalize()
Finalize the port
|
int |
getBaudBase()
Extension to CommAPI
|
int |
getBaudRate() |
boolean |
getCallOutHangup()
Extension to CommAPI
returns boolean true on success
|
int |
getDataBits() |
int |
getDivisor()
Extension to CommAPI
|
byte |
getEndOfInputChar()
Extension to CommAPI
This is an extension to CommAPI.
|
int |
getFlowControlMode() |
int |
getInputBufferSize() |
InputStream |
getInputStream()
get the InputStream
|
boolean |
getLowLatency()
Extension to CommAPI
returns boolean true on success
|
int |
getOutputBufferSize() |
OutputStream |
getOutputStream()
get the OutputStream
|
int |
getParity() |
byte |
getParityErrorChar()
Extension to CommAPI
This is an extension to CommAPI.
|
int |
getReceiveFramingByte() |
int |
getReceiveThreshold() |
int |
getReceiveTimeout() |
int |
getStopBits() |
String |
getUARTType()
Extension to CommAPI
This is an extension to CommAPI.
|
boolean |
isCD() |
boolean |
isCTS() |
boolean |
isDSR() |
boolean |
isDTR() |
boolean |
isReceiveFramingEnabled() |
boolean |
isReceiveThresholdEnabled() |
boolean |
isReceiveTimeoutEnabled() |
boolean |
isRI() |
boolean |
isRTS() |
protected int |
nativeavailable()
RXTXPort read methods
|
protected boolean |
nativeDrain(boolean i) |
int |
NativegetReceiveTimeout() |
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 |
removeEventListener()
Remove the serial port event listener
|
void |
sendBreak(int duration)
Write to the port
|
boolean |
sendEvent(int event,
boolean state) |
boolean |
setBaudBase(int BaudBase)
Extension to CommAPI.
|
boolean |
setCallOutHangup(boolean NoHup)
Extension to CommAPI
returns boolean true on success
|
boolean |
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 |
setLowLatency()
Extension to CommAPI
returns boolean true on success
|
void |
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 Kaffe
|
void |
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 |
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.
|
protected void |
writeArray(byte[] b,
int off,
int len,
boolean i) |
protected void |
writeByte(int b,
boolean i) |
protected static final boolean debug
protected static final boolean debug_read
protected static final boolean debug_read_results
protected static final boolean debug_write
protected static final boolean debug_events
protected static final boolean debug_verbose
public RXTXPort(String name) throws PortInUseException
name
- the name of the device to openPortInUseException
SerialPort
public OutputStream getOutputStream()
getOutputStream
in class CommPort
public InputStream getInputStream()
getInputStream
in class CommPort
InputStream
public void setSerialPortParams(int b, int d, int s, int p) throws UnsupportedCommOperationException
setSerialPortParams
in class SerialPort
UnsupportedCommOperationException
public int getBaudRate()
getBaudRate
in class SerialPort
public int getDataBits()
getDataBits
in class SerialPort
public int getStopBits()
getStopBits
in class SerialPort
public int getParity()
getParity
in class SerialPort
public void setFlowControlMode(int flowcontrol)
setFlowControlMode
in class SerialPort
flowcontrol
- FLOWCONTROL_NONE is defaultSerialPort.FLOWCONTROL_NONE
public int getFlowControlMode()
getFlowControlMode
in class SerialPort
public void enableReceiveFraming(int f) throws UnsupportedCommOperationException
enableReceiveFraming
in class CommPort
f
- frammingUnsupportedCommOperationException
public void disableReceiveFraming()
disableReceiveFraming
in class CommPort
public boolean isReceiveFramingEnabled()
isReceiveFramingEnabled
in class CommPort
public int getReceiveFramingByte()
getReceiveFramingByte
in class CommPort
public int NativegetReceiveTimeout()
public void disableReceiveTimeout()
disableReceiveTimeout
in class CommPort
public void enableReceiveTimeout(int time)
enableReceiveTimeout
in class CommPort
time
- public boolean isReceiveTimeoutEnabled()
isReceiveTimeoutEnabled
in class CommPort
public int getReceiveTimeout()
getReceiveTimeout
in class CommPort
public void enableReceiveThreshold(int thresh)
enableReceiveThreshold
in class CommPort
thresh
- thresholdpublic void disableReceiveThreshold()
disableReceiveThreshold
in class CommPort
public int getReceiveThreshold()
getReceiveThreshold
in class CommPort
public boolean isReceiveThresholdEnabled()
isReceiveThresholdEnabled
in class CommPort
public void setInputBufferSize(int size)
setInputBufferSize
in class CommPort
size
- public int getInputBufferSize()
getInputBufferSize
in class CommPort
public void setOutputBufferSize(int size)
setOutputBufferSize
in class CommPort
size
- public int getOutputBufferSize()
getOutputBufferSize
in class CommPort
public boolean isDTR()
isDTR
in class SerialPort
public void setDTR(boolean state)
setDTR
in class SerialPort
state
- public void setRTS(boolean state)
setRTS
in class SerialPort
state
- public boolean isCTS()
isCTS
in class SerialPort
public boolean isDSR()
isDSR
in class SerialPort
public boolean isCD()
isCD
in class SerialPort
public boolean isRI()
isRI
in class SerialPort
public boolean isRTS()
isRTS
in class SerialPort
public void sendBreak(int duration)
sendBreak
in class SerialPort
duration
- protected void writeByte(int b, boolean i) throws IOException
IOException
protected void writeArray(byte[] b, int off, int len, boolean i) throws IOException
IOException
protected boolean nativeDrain(boolean i) throws IOException
IOException
protected int nativeavailable() throws IOException
IOException
protected int readByte() throws IOException
IOException
protected int readArray(byte[] b, int off, int len) throws IOException
IOException
protected int readTerminatedArray(byte[] b, int off, int len, byte[] t) throws IOException
IOException
public boolean checkMonitorThread()
public boolean sendEvent(int event, boolean state)
event
- state
- public void addEventListener(SerialPortEventListener lsnr) throws TooManyListenersException
addEventListener
in class SerialPort
TooManyListenersException
public void removeEventListener()
removeEventListener
in class SerialPort
protected void waitForTheNativeCodeSilly()
public void notifyOnDataAvailable(boolean enable)
notifyOnDataAvailable
in class SerialPort
public void notifyOnOutputEmpty(boolean enable)
notifyOnOutputEmpty
in class SerialPort
enable
- public void notifyOnCTS(boolean enable)
notifyOnCTS
in class SerialPort
enable
- public void notifyOnDSR(boolean enable)
notifyOnDSR
in class SerialPort
enable
- public void notifyOnRingIndicator(boolean enable)
notifyOnRingIndicator
in class SerialPort
enable
- public void notifyOnCarrierDetect(boolean enable)
notifyOnCarrierDetect
in class SerialPort
enable
- public void notifyOnOverrunError(boolean enable)
notifyOnOverrunError
in class SerialPort
enable
- public void notifyOnParityError(boolean enable)
notifyOnParityError
in class SerialPort
enable
- public void notifyOnFramingError(boolean enable)
notifyOnFramingError
in class SerialPort
enable
- public void notifyOnBreakInterrupt(boolean enable)
notifyOnBreakInterrupt
in class SerialPort
enable
- public void setRcvFifoTrigger(int trigger)
public static int staticGetBaudRate(String port) throws UnsupportedCommOperationException
port
- the name of the port thats been preopenedUnsupportedCommOperationException
- This will not behave as expected with custom speedspublic static int staticGetDataBits(String port) throws UnsupportedCommOperationException
port
- the name of the port thats been preopenedUnsupportedCommOperationException
public static int staticGetParity(String port) throws UnsupportedCommOperationException
port
- the name of the port thats been preopenedUnsupportedCommOperationException
public static int staticGetStopBits(String port) throws UnsupportedCommOperationException
port
- the name of the port thats been preopenedUnsupportedCommOperationException
public static void staticSetSerialPortParams(String f, int b, int d, int s, int p) throws UnsupportedCommOperationException
f
- filenameb
- baudrated
- databitss
- stopbitsp
- parityUnsupportedCommOperationException
UnsupportedCommOperationException
public static boolean staticSetDSR(String port, boolean flag) throws UnsupportedCommOperationException
UnsupportedCommOperationException
public static boolean staticSetDTR(String port, boolean flag) throws UnsupportedCommOperationException
UnsupportedCommOperationException
public static boolean staticSetRTS(String port, boolean flag) throws UnsupportedCommOperationException
UnsupportedCommOperationException
public static boolean staticIsRTS(String port) throws UnsupportedCommOperationException
port
- UnsupportedCommOperationException
public static boolean staticIsCD(String port) throws UnsupportedCommOperationException
port
- UnsupportedCommOperationException
public static boolean staticIsCTS(String port) throws UnsupportedCommOperationException
port
- UnsupportedCommOperationException
public static boolean staticIsDSR(String port) throws UnsupportedCommOperationException
port
- UnsupportedCommOperationException
public static boolean staticIsDTR(String port) throws UnsupportedCommOperationException
port
- UnsupportedCommOperationException
public static boolean staticIsRI(String port) throws UnsupportedCommOperationException
port
- UnsupportedCommOperationException
public byte getParityErrorChar() throws UnsupportedCommOperationException
getParityErrorChar
in class SerialPort
UnsupportedCommOperationException
- Anyone know how to do this in Unix?public boolean setParityErrorChar(byte b) throws UnsupportedCommOperationException
setParityErrorChar
in class SerialPort
b
- Parity Error CharacterUnsupportedCommOperationException
- Anyone know how to do this in Unix?public byte getEndOfInputChar() throws UnsupportedCommOperationException
getEndOfInputChar
in class SerialPort
UnsupportedCommOperationException
- Anyone know how to do this in Unix?public boolean setEndOfInputChar(byte b) throws UnsupportedCommOperationException
setEndOfInputChar
in class SerialPort
b
- End Of Input CharacterUnsupportedCommOperationException
public boolean setUARTType(String type, boolean test) throws UnsupportedCommOperationException
setUARTType
in class SerialPort
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.UnsupportedCommOperationException
public String getUARTType() throws UnsupportedCommOperationException
getUARTType
in class SerialPort
UnsupportedCommOperationException
public boolean setBaudBase(int BaudBase) throws UnsupportedCommOperationException, IOException
setBaudBase
in class SerialPort
BaudBase
- The clock frequency divided by 16. Default
BaudBase is 115200.UnsupportedCommOperationException
IOException
public int getBaudBase() throws UnsupportedCommOperationException, IOException
getBaudBase
in class SerialPort
UnsupportedCommOperationException
IOException
public boolean setDivisor(int Divisor) throws UnsupportedCommOperationException, IOException
setDivisor
in class SerialPort
Divisor
- UnsupportedCommOperationException
IOException
public int getDivisor() throws UnsupportedCommOperationException, IOException
getDivisor
in class SerialPort
UnsupportedCommOperationException
IOException
public boolean setLowLatency() throws UnsupportedCommOperationException
setLowLatency
in class SerialPort
UnsupportedCommOperationException
public boolean getLowLatency() throws UnsupportedCommOperationException
getLowLatency
in class SerialPort
UnsupportedCommOperationException
public boolean setCallOutHangup(boolean NoHup) throws UnsupportedCommOperationException
setCallOutHangup
in class SerialPort
UnsupportedCommOperationException
public boolean getCallOutHangup() throws UnsupportedCommOperationException
getCallOutHangup
in class SerialPort
UnsupportedCommOperationException
public boolean clearCommInput() throws UnsupportedCommOperationException
Copyright © 2016. All rights reserved.