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 theSerialPortclass 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
TelnetClientviagetTelnetClient()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
IOExceptionwill be thrown when attempting to access the serial port input or output streams. In addition, aDATA_AVAILABLEevent 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 themillisargument 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 voidaddEventListener(SerialPortEventListener listener)voidclose()protected org.apache.commons.net.telnet.TelnetClientcreateTelnetClient()Construct and configure theTelnetClientto be used for this instance.voiddisableReceiveFraming()voiddisableReceiveThreshold()voiddisableReceiveTimeout()voidenableReceiveFraming(int framingByte)voidenableReceiveThreshold(int threshold)voidenableReceiveTimeout(int timeout)intgetBaudBase()intgetBaudRate()booleangetCallOutHangup()intgetDataBits()intgetDivisor()bytegetEndOfInputChar()intgetFlowControlMode()intgetInputBufferSize()java.io.InputStreamgetInputStream()booleangetLowLatency()java.lang.StringgetName()Get the descriptive name of this client (used for logging purposes).intgetOutputBufferSize()java.io.OutputStreamgetOutputStream()intgetParity()bytegetParityErrorChar()intgetReceiveFramingByte()intgetReceiveThreshold()intgetReceiveTimeout()java.lang.StringgetSignature()Get the signature sent to the remote server at connection time.intgetStopBits()org.apache.commons.net.telnet.TelnetClientgetTelnetClient()Get theTelnetClientassociated with this instance.java.lang.StringgetUARTType()booleanisCD()booleanisCTS()booleanisDSR()booleanisDTR()booleanisReceiveFramingEnabled()booleanisReceiveThresholdEnabled()booleanisReceiveTimeoutEnabled()booleanisRI()booleanisRTS()voidnotifyOnBreakInterrupt(boolean value)voidnotifyOnCarrierDetect(boolean value)voidnotifyOnCTS(boolean value)voidnotifyOnDataAvailable(boolean value)voidnotifyOnDSR(boolean value)voidnotifyOnFramingError(boolean value)voidnotifyOnOutputEmpty(boolean value)voidnotifyOnOverrunError(boolean value)voidnotifyOnParityError(boolean value)voidnotifyOnRingIndicator(boolean value)voidremoveEventListener()voidsendBreak(int millis)booleansetBaudBase(int arg0)booleansetCallOutHangup(boolean arg0)booleansetDivisor(int arg0)voidsetDTR(boolean value)booleansetEndOfInputChar(byte arg0)voidsetFlowControlMode(int flowControl)voidsetInputBufferSize(int size)booleansetLowLatency()voidsetName(java.lang.String name)Set the descriptive name of this client (used for logging purposes).voidsetOutputBufferSize(int size)booleansetParityErrorChar(byte arg0)voidsetRTS(boolean value)voidsetSerialPortParams(int baudRate, int dataBits, int stopBits, int parity)voidsetSignature(java.lang.String signature)Set the signature sent to the remote server at connection time.booleansetUARTType(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 theTelnetClientassociated with this instance.
-
createTelnetClient
protected org.apache.commons.net.telnet.TelnetClient createTelnetClient()
Construct and configure theTelnetClientto be used for this instance.
-
getInputStream
public java.io.InputStream getInputStream() throws java.io.IOException- Specified by:
getInputStreamin classCommPort- Throws:
java.io.IOException
-
getOutputStream
public java.io.OutputStream getOutputStream() throws java.io.IOException- Specified by:
getOutputStreamin classCommPort- Throws:
java.io.IOException
-
getBaudRate
public int getBaudRate()
- Specified by:
getBaudRatein classSerialPort
-
getDataBits
public int getDataBits()
- Specified by:
getDataBitsin classSerialPort
-
getStopBits
public int getStopBits()
- Specified by:
getStopBitsin classSerialPort
-
getParity
public int getParity()
- Specified by:
getParityin classSerialPort
-
sendBreak
public void sendBreak(int millis)
- Specified by:
sendBreakin classSerialPort
-
setFlowControlMode
public void setFlowControlMode(int flowControl) throws UnsupportedCommOperationException- Specified by:
setFlowControlModein classSerialPort- Throws:
UnsupportedCommOperationException
-
getFlowControlMode
public int getFlowControlMode()
- Specified by:
getFlowControlModein classSerialPort
-
setSerialPortParams
public void setSerialPortParams(int baudRate, int dataBits, int stopBits, int parity) throws UnsupportedCommOperationException- Specified by:
setSerialPortParamsin classSerialPort- Throws:
UnsupportedCommOperationException
-
setDTR
public void setDTR(boolean value)
- Specified by:
setDTRin classSerialPort
-
isDTR
public boolean isDTR()
- Specified by:
isDTRin classSerialPort
-
setRTS
public void setRTS(boolean value)
- Specified by:
setRTSin classSerialPort
-
isRTS
public boolean isRTS()
- Specified by:
isRTSin classSerialPort
-
isCTS
public boolean isCTS()
- Specified by:
isCTSin classSerialPort
-
isDSR
public boolean isDSR()
- Specified by:
isDSRin classSerialPort
-
isRI
public boolean isRI()
- Specified by:
isRIin classSerialPort
-
isCD
public boolean isCD()
- Specified by:
isCDin classSerialPort
-
addEventListener
public void addEventListener(SerialPortEventListener listener) throws java.util.TooManyListenersException
- Specified by:
addEventListenerin classSerialPort- Throws:
java.util.TooManyListenersException
-
removeEventListener
public void removeEventListener()
- Specified by:
removeEventListenerin classSerialPort
-
notifyOnDataAvailable
public void notifyOnDataAvailable(boolean value)
- Specified by:
notifyOnDataAvailablein classSerialPort
-
notifyOnOutputEmpty
public void notifyOnOutputEmpty(boolean value)
- Specified by:
notifyOnOutputEmptyin classSerialPort
-
notifyOnCTS
public void notifyOnCTS(boolean value)
- Specified by:
notifyOnCTSin classSerialPort
-
notifyOnDSR
public void notifyOnDSR(boolean value)
- Specified by:
notifyOnDSRin classSerialPort
-
notifyOnRingIndicator
public void notifyOnRingIndicator(boolean value)
- Specified by:
notifyOnRingIndicatorin classSerialPort
-
notifyOnCarrierDetect
public void notifyOnCarrierDetect(boolean value)
- Specified by:
notifyOnCarrierDetectin classSerialPort
-
notifyOnOverrunError
public void notifyOnOverrunError(boolean value)
- Specified by:
notifyOnOverrunErrorin classSerialPort
-
notifyOnParityError
public void notifyOnParityError(boolean value)
- Specified by:
notifyOnParityErrorin classSerialPort
-
notifyOnFramingError
public void notifyOnFramingError(boolean value)
- Specified by:
notifyOnFramingErrorin classSerialPort
-
notifyOnBreakInterrupt
public void notifyOnBreakInterrupt(boolean value)
- Specified by:
notifyOnBreakInterruptin classSerialPort
-
enableReceiveThreshold
public void enableReceiveThreshold(int threshold) throws UnsupportedCommOperationException- Specified by:
enableReceiveThresholdin classCommPort- Throws:
UnsupportedCommOperationException
-
disableReceiveThreshold
public void disableReceiveThreshold()
- Specified by:
disableReceiveThresholdin classCommPort
-
isReceiveThresholdEnabled
public boolean isReceiveThresholdEnabled()
- Specified by:
isReceiveThresholdEnabledin classCommPort
-
getReceiveThreshold
public int getReceiveThreshold()
- Specified by:
getReceiveThresholdin classCommPort
-
enableReceiveTimeout
public void enableReceiveTimeout(int timeout) throws UnsupportedCommOperationException- Specified by:
enableReceiveTimeoutin classCommPort- Throws:
UnsupportedCommOperationException
-
disableReceiveTimeout
public void disableReceiveTimeout()
- Specified by:
disableReceiveTimeoutin classCommPort
-
isReceiveTimeoutEnabled
public boolean isReceiveTimeoutEnabled()
- Specified by:
isReceiveTimeoutEnabledin classCommPort
-
getReceiveTimeout
public int getReceiveTimeout()
- Specified by:
getReceiveTimeoutin classCommPort
-
enableReceiveFraming
public void enableReceiveFraming(int framingByte) throws UnsupportedCommOperationException- Specified by:
enableReceiveFramingin classCommPort- Throws:
UnsupportedCommOperationException
-
disableReceiveFraming
public void disableReceiveFraming()
- Specified by:
disableReceiveFramingin classCommPort
-
isReceiveFramingEnabled
public boolean isReceiveFramingEnabled()
- Specified by:
isReceiveFramingEnabledin classCommPort
-
getReceiveFramingByte
public int getReceiveFramingByte()
- Specified by:
getReceiveFramingBytein classCommPort
-
setInputBufferSize
public void setInputBufferSize(int size)
- Specified by:
setInputBufferSizein classCommPort
-
getInputBufferSize
public int getInputBufferSize()
- Specified by:
getInputBufferSizein classCommPort
-
setOutputBufferSize
public void setOutputBufferSize(int size)
- Specified by:
setOutputBufferSizein classCommPort
-
getOutputBufferSize
public int getOutputBufferSize()
- Specified by:
getOutputBufferSizein classCommPort
-
getBaudBase
public int getBaudBase() throws UnsupportedCommOperationException, java.io.IOException- Specified by:
getBaudBasein classSerialPort- Throws:
UnsupportedCommOperationExceptionjava.io.IOException
-
getCallOutHangup
public boolean getCallOutHangup() throws UnsupportedCommOperationException- Specified by:
getCallOutHangupin classSerialPort- Throws:
UnsupportedCommOperationException
-
getDivisor
public int getDivisor() throws UnsupportedCommOperationException, java.io.IOException- Specified by:
getDivisorin classSerialPort- Throws:
UnsupportedCommOperationExceptionjava.io.IOException
-
getEndOfInputChar
public byte getEndOfInputChar() throws UnsupportedCommOperationException- Specified by:
getEndOfInputCharin classSerialPort- Throws:
UnsupportedCommOperationException
-
getLowLatency
public boolean getLowLatency() throws UnsupportedCommOperationException- Specified by:
getLowLatencyin classSerialPort- Throws:
UnsupportedCommOperationException
-
getParityErrorChar
public byte getParityErrorChar() throws UnsupportedCommOperationException- Specified by:
getParityErrorCharin classSerialPort- Throws:
UnsupportedCommOperationException
-
getUARTType
public java.lang.String getUARTType() throws UnsupportedCommOperationException- Specified by:
getUARTTypein classSerialPort- Throws:
UnsupportedCommOperationException
-
setBaudBase
public boolean setBaudBase(int arg0) throws UnsupportedCommOperationException, java.io.IOException- Specified by:
setBaudBasein classSerialPort- Throws:
UnsupportedCommOperationExceptionjava.io.IOException
-
setCallOutHangup
public boolean setCallOutHangup(boolean arg0) throws UnsupportedCommOperationException- Specified by:
setCallOutHangupin classSerialPort- Throws:
UnsupportedCommOperationException
-
setDivisor
public boolean setDivisor(int arg0) throws UnsupportedCommOperationException, java.io.IOException- Specified by:
setDivisorin classSerialPort- Throws:
UnsupportedCommOperationExceptionjava.io.IOException
-
setEndOfInputChar
public boolean setEndOfInputChar(byte arg0) throws UnsupportedCommOperationException- Specified by:
setEndOfInputCharin classSerialPort- Throws:
UnsupportedCommOperationException
-
setLowLatency
public boolean setLowLatency() throws UnsupportedCommOperationException- Specified by:
setLowLatencyin classSerialPort- Throws:
UnsupportedCommOperationException
-
setParityErrorChar
public boolean setParityErrorChar(byte arg0) throws UnsupportedCommOperationException- Specified by:
setParityErrorCharin classSerialPort- Throws:
UnsupportedCommOperationException
-
setUARTType
public boolean setUARTType(java.lang.String arg0, boolean arg1) throws UnsupportedCommOperationException- Specified by:
setUARTTypein classSerialPort- Throws:
UnsupportedCommOperationException
-
-