Package gnu.io.rfc2217
Class TelnetSerialPort
- java.lang.Object
-
- gnu.io.CommPort
-
- gnu.io.SerialPort
-
- gnu.io.rfc2217.TelnetSerialPort
-
public class TelnetSerialPort extends SerialPort
Implements the client side of the RFC 2217 serial-over-Telnet protocol as asSerialPort
. This class extends theSerialPort
class and functions in the same way, however, there are a couple of differences to be aware of:-
To "open" a serial port, create an instance of this class, configure it as required,
and then get the
TelnetClient
viagetTelnetClient()
and invokeTelnetClient.connect()
(or one of its variants). This will create the telnet connection to the access server. -
Once connected, if the underlying telnet connection is broken, an
IOException
will be thrown when attempting to access the serial port input or output streams. In addition, aDATA_AVAILABLE
event will be immediately generated.
- Receive threshold
- Receive timeout
- Receive framing byte
- Input buffer size
- Output buffer size
notifyOnOutputEmpty(boolean)
. Finally,sendBreak(int)
is supported but themillis
argument is ignored, as timing cannot be assured over a TCP connection. Access servers typically enforce a fixed break time.- See Also:
SerialPort
, RFC 2217
-
To "open" a serial port, create an instance of this class, configure it as required,
and then get the
-
-
Field Summary
-
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 Constructor Description TelnetSerialPort()
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addEventListener(SerialPortEventListener listener)
void
close()
protected org.apache.commons.net.telnet.TelnetClient
createTelnetClient()
Construct and configure theTelnetClient
to be used for this instance.void
disableReceiveFraming()
void
disableReceiveThreshold()
void
disableReceiveTimeout()
void
enableReceiveFraming(int framingByte)
void
enableReceiveThreshold(int threshold)
void
enableReceiveTimeout(int timeout)
int
getBaudBase()
int
getBaudRate()
boolean
getCallOutHangup()
int
getDataBits()
int
getDivisor()
byte
getEndOfInputChar()
int
getFlowControlMode()
int
getInputBufferSize()
java.io.InputStream
getInputStream()
boolean
getLowLatency()
java.lang.String
getName()
Get the descriptive name of this client (used for logging purposes).int
getOutputBufferSize()
java.io.OutputStream
getOutputStream()
int
getParity()
byte
getParityErrorChar()
int
getReceiveFramingByte()
int
getReceiveThreshold()
int
getReceiveTimeout()
java.lang.String
getSignature()
Get the signature sent to the remote server at connection time.int
getStopBits()
org.apache.commons.net.telnet.TelnetClient
getTelnetClient()
Get theTelnetClient
associated with this instance.java.lang.String
getUARTType()
boolean
isCD()
boolean
isCTS()
boolean
isDSR()
boolean
isDTR()
boolean
isReceiveFramingEnabled()
boolean
isReceiveThresholdEnabled()
boolean
isReceiveTimeoutEnabled()
boolean
isRI()
boolean
isRTS()
void
notifyOnBreakInterrupt(boolean value)
void
notifyOnCarrierDetect(boolean value)
void
notifyOnCTS(boolean value)
void
notifyOnDataAvailable(boolean value)
void
notifyOnDSR(boolean value)
void
notifyOnFramingError(boolean value)
void
notifyOnOutputEmpty(boolean value)
void
notifyOnOverrunError(boolean value)
void
notifyOnParityError(boolean value)
void
notifyOnRingIndicator(boolean value)
void
removeEventListener()
void
sendBreak(int millis)
boolean
setBaudBase(int arg0)
boolean
setCallOutHangup(boolean arg0)
boolean
setDivisor(int arg0)
void
setDTR(boolean value)
boolean
setEndOfInputChar(byte arg0)
void
setFlowControlMode(int flowControl)
void
setInputBufferSize(int size)
boolean
setLowLatency()
void
setName(java.lang.String name)
Set the descriptive name of this client (used for logging purposes).void
setOutputBufferSize(int size)
boolean
setParityErrorChar(byte arg0)
void
setRTS(boolean value)
void
setSerialPortParams(int baudRate, int dataBits, int stopBits, int parity)
void
setSignature(java.lang.String signature)
Set the signature sent to the remote server at connection time.boolean
setUARTType(java.lang.String arg0, boolean arg1)
-
-
-
Method Detail
-
getName
public java.lang.String getName()
Get the descriptive name of this client (used for logging purposes).
-
setName
public void setName(java.lang.String name)
Set the descriptive name of this client (used for logging purposes).
-
getSignature
public java.lang.String getSignature()
Get the signature sent to the remote server at connection time. By default, the signature is the name of this class.
-
setSignature
public void setSignature(java.lang.String signature)
Set the signature sent to the remote server at connection time.- Parameters:
signature
- signature string, ornull
(or empty string) to not send a signature
-
getTelnetClient
public org.apache.commons.net.telnet.TelnetClient getTelnetClient()
Get theTelnetClient
associated with this instance.
-
createTelnetClient
protected org.apache.commons.net.telnet.TelnetClient createTelnetClient()
Construct and configure theTelnetClient
to be used for this instance.
-
getInputStream
public java.io.InputStream getInputStream() throws java.io.IOException
- Specified by:
getInputStream
in classCommPort
- Throws:
java.io.IOException
-
getOutputStream
public java.io.OutputStream getOutputStream() throws java.io.IOException
- Specified by:
getOutputStream
in classCommPort
- Throws:
java.io.IOException
-
getBaudRate
public int getBaudRate()
- Specified by:
getBaudRate
in classSerialPort
-
getDataBits
public int getDataBits()
- Specified by:
getDataBits
in classSerialPort
-
getStopBits
public int getStopBits()
- Specified by:
getStopBits
in classSerialPort
-
getParity
public int getParity()
- Specified by:
getParity
in classSerialPort
-
sendBreak
public void sendBreak(int millis)
- Specified by:
sendBreak
in classSerialPort
-
setFlowControlMode
public void setFlowControlMode(int flowControl) throws UnsupportedCommOperationException
- Specified by:
setFlowControlMode
in classSerialPort
- Throws:
UnsupportedCommOperationException
-
getFlowControlMode
public int getFlowControlMode()
- Specified by:
getFlowControlMode
in classSerialPort
-
setSerialPortParams
public void setSerialPortParams(int baudRate, int dataBits, int stopBits, int parity) throws UnsupportedCommOperationException
- Specified by:
setSerialPortParams
in classSerialPort
- Throws:
UnsupportedCommOperationException
-
setDTR
public void setDTR(boolean value)
- Specified by:
setDTR
in classSerialPort
-
isDTR
public boolean isDTR()
- Specified by:
isDTR
in classSerialPort
-
setRTS
public void setRTS(boolean value)
- Specified by:
setRTS
in classSerialPort
-
isRTS
public boolean isRTS()
- Specified by:
isRTS
in classSerialPort
-
isCTS
public boolean isCTS()
- Specified by:
isCTS
in classSerialPort
-
isDSR
public boolean isDSR()
- Specified by:
isDSR
in classSerialPort
-
isRI
public boolean isRI()
- Specified by:
isRI
in classSerialPort
-
isCD
public boolean isCD()
- Specified by:
isCD
in classSerialPort
-
addEventListener
public void addEventListener(SerialPortEventListener listener) throws java.util.TooManyListenersException
- Specified by:
addEventListener
in classSerialPort
- Throws:
java.util.TooManyListenersException
-
removeEventListener
public void removeEventListener()
- Specified by:
removeEventListener
in classSerialPort
-
notifyOnDataAvailable
public void notifyOnDataAvailable(boolean value)
- Specified by:
notifyOnDataAvailable
in classSerialPort
-
notifyOnOutputEmpty
public void notifyOnOutputEmpty(boolean value)
- Specified by:
notifyOnOutputEmpty
in classSerialPort
-
notifyOnCTS
public void notifyOnCTS(boolean value)
- Specified by:
notifyOnCTS
in classSerialPort
-
notifyOnDSR
public void notifyOnDSR(boolean value)
- Specified by:
notifyOnDSR
in classSerialPort
-
notifyOnRingIndicator
public void notifyOnRingIndicator(boolean value)
- Specified by:
notifyOnRingIndicator
in classSerialPort
-
notifyOnCarrierDetect
public void notifyOnCarrierDetect(boolean value)
- Specified by:
notifyOnCarrierDetect
in classSerialPort
-
notifyOnOverrunError
public void notifyOnOverrunError(boolean value)
- Specified by:
notifyOnOverrunError
in classSerialPort
-
notifyOnParityError
public void notifyOnParityError(boolean value)
- Specified by:
notifyOnParityError
in classSerialPort
-
notifyOnFramingError
public void notifyOnFramingError(boolean value)
- Specified by:
notifyOnFramingError
in classSerialPort
-
notifyOnBreakInterrupt
public void notifyOnBreakInterrupt(boolean value)
- Specified by:
notifyOnBreakInterrupt
in classSerialPort
-
enableReceiveThreshold
public void enableReceiveThreshold(int threshold) throws UnsupportedCommOperationException
- Specified by:
enableReceiveThreshold
in classCommPort
- Throws:
UnsupportedCommOperationException
-
disableReceiveThreshold
public void disableReceiveThreshold()
- Specified by:
disableReceiveThreshold
in classCommPort
-
isReceiveThresholdEnabled
public boolean isReceiveThresholdEnabled()
- Specified by:
isReceiveThresholdEnabled
in classCommPort
-
getReceiveThreshold
public int getReceiveThreshold()
- Specified by:
getReceiveThreshold
in classCommPort
-
enableReceiveTimeout
public void enableReceiveTimeout(int timeout) throws UnsupportedCommOperationException
- Specified by:
enableReceiveTimeout
in classCommPort
- Throws:
UnsupportedCommOperationException
-
disableReceiveTimeout
public void disableReceiveTimeout()
- Specified by:
disableReceiveTimeout
in classCommPort
-
isReceiveTimeoutEnabled
public boolean isReceiveTimeoutEnabled()
- Specified by:
isReceiveTimeoutEnabled
in classCommPort
-
getReceiveTimeout
public int getReceiveTimeout()
- Specified by:
getReceiveTimeout
in classCommPort
-
enableReceiveFraming
public void enableReceiveFraming(int framingByte) throws UnsupportedCommOperationException
- Specified by:
enableReceiveFraming
in classCommPort
- Throws:
UnsupportedCommOperationException
-
disableReceiveFraming
public void disableReceiveFraming()
- Specified by:
disableReceiveFraming
in classCommPort
-
isReceiveFramingEnabled
public boolean isReceiveFramingEnabled()
- Specified by:
isReceiveFramingEnabled
in classCommPort
-
getReceiveFramingByte
public int getReceiveFramingByte()
- Specified by:
getReceiveFramingByte
in classCommPort
-
setInputBufferSize
public void setInputBufferSize(int size)
- Specified by:
setInputBufferSize
in classCommPort
-
getInputBufferSize
public int getInputBufferSize()
- Specified by:
getInputBufferSize
in classCommPort
-
setOutputBufferSize
public void setOutputBufferSize(int size)
- Specified by:
setOutputBufferSize
in classCommPort
-
getOutputBufferSize
public int getOutputBufferSize()
- Specified by:
getOutputBufferSize
in classCommPort
-
getBaudBase
public int getBaudBase() throws UnsupportedCommOperationException, java.io.IOException
- Specified by:
getBaudBase
in classSerialPort
- Throws:
UnsupportedCommOperationException
java.io.IOException
-
getCallOutHangup
public boolean getCallOutHangup() throws UnsupportedCommOperationException
- Specified by:
getCallOutHangup
in classSerialPort
- Throws:
UnsupportedCommOperationException
-
getDivisor
public int getDivisor() throws UnsupportedCommOperationException, java.io.IOException
- Specified by:
getDivisor
in classSerialPort
- Throws:
UnsupportedCommOperationException
java.io.IOException
-
getEndOfInputChar
public byte getEndOfInputChar() throws UnsupportedCommOperationException
- Specified by:
getEndOfInputChar
in classSerialPort
- Throws:
UnsupportedCommOperationException
-
getLowLatency
public boolean getLowLatency() throws UnsupportedCommOperationException
- Specified by:
getLowLatency
in classSerialPort
- Throws:
UnsupportedCommOperationException
-
getParityErrorChar
public byte getParityErrorChar() throws UnsupportedCommOperationException
- Specified by:
getParityErrorChar
in classSerialPort
- Throws:
UnsupportedCommOperationException
-
getUARTType
public java.lang.String getUARTType() throws UnsupportedCommOperationException
- Specified by:
getUARTType
in classSerialPort
- Throws:
UnsupportedCommOperationException
-
setBaudBase
public boolean setBaudBase(int arg0) throws UnsupportedCommOperationException, java.io.IOException
- Specified by:
setBaudBase
in classSerialPort
- Throws:
UnsupportedCommOperationException
java.io.IOException
-
setCallOutHangup
public boolean setCallOutHangup(boolean arg0) throws UnsupportedCommOperationException
- Specified by:
setCallOutHangup
in classSerialPort
- Throws:
UnsupportedCommOperationException
-
setDivisor
public boolean setDivisor(int arg0) throws UnsupportedCommOperationException, java.io.IOException
- Specified by:
setDivisor
in classSerialPort
- Throws:
UnsupportedCommOperationException
java.io.IOException
-
setEndOfInputChar
public boolean setEndOfInputChar(byte arg0) throws UnsupportedCommOperationException
- Specified by:
setEndOfInputChar
in classSerialPort
- Throws:
UnsupportedCommOperationException
-
setLowLatency
public boolean setLowLatency() throws UnsupportedCommOperationException
- Specified by:
setLowLatency
in classSerialPort
- Throws:
UnsupportedCommOperationException
-
setParityErrorChar
public boolean setParityErrorChar(byte arg0) throws UnsupportedCommOperationException
- Specified by:
setParityErrorChar
in classSerialPort
- Throws:
UnsupportedCommOperationException
-
setUARTType
public boolean setUARTType(java.lang.String arg0, boolean arg1) throws UnsupportedCommOperationException
- Specified by:
setUARTType
in classSerialPort
- Throws:
UnsupportedCommOperationException
-
-