Package jmri.jmrix.jserialcomm
Class JSerialPort
java.lang.Object
jmri.jmrix.jserialcomm.JSerialPort
- All Implemented Interfaces:
SerialPort
Implementation of serial port using jSerialComm.
-
Nested Class Summary
Nested classes/interfaces inherited from interface jmri.jmrix.SerialPort
SerialPort.Parity -
Field Summary
Fields inherited from interface jmri.jmrix.SerialPort
LISTENING_EVENT_DATA_AVAILABLE, NO_PARITY, ONE_STOP_BIT -
Method Summary
Modifier and TypeMethodDescriptionstatic JSerialPortactivatePort(String systemPrefix, String inputPortName, org.slf4j.Logger log, int stop_bits, SerialPort.Parity parity) Open the port.voidaddDataListener(SerialPortDataListener listener) voidvoidclearDTR()voidclearRTS()voidProvide the actual serial port names.intbooleangetCTS()booleangetDCD()booleangetDSR()booleangetDTR()final intfinal intfinal intbooleangetRI()booleangetRTS()voidsetBaudRate(int baudrate) voidsetBreak()final booleansetComPortTimeouts(int newTimeoutMode, int newReadTimeout, int newWriteTimeout) voidsetDTR()final voidConfigure the flow control settings.voidsetNumDataBits(int bits) voidsetNumStopBits(int bits) voidsetParity(SerialPort.Parity parity) voidsetRTS()toString()
-
Method Details
-
addDataListener
- Specified by:
addDataListenerin interfaceSerialPort
-
getInputStream
- Specified by:
getInputStreamin interfaceSerialPort
-
getOutputStream
- Specified by:
getOutputStreamin interfaceSerialPort
-
setRTS
- Specified by:
setRTSin interfaceSerialPort
-
clearRTS
- Specified by:
clearRTSin interfaceSerialPort
-
setBaudRate
- Specified by:
setBaudRatein interfaceSerialPort
-
getBaudRate
- Specified by:
getBaudRatein interfaceSerialPort
-
setNumDataBits
- Specified by:
setNumDataBitsin interfaceSerialPort
-
getNumDataBits
- Specified by:
getNumDataBitsin interfaceSerialPort
-
setNumStopBits
- Specified by:
setNumStopBitsin interfaceSerialPort
-
getNumStopBits
- Specified by:
getNumStopBitsin interfaceSerialPort
-
setParity
- Specified by:
setParityin interfaceSerialPort
-
getParity
- Specified by:
getParityin interfaceSerialPort
-
setDTR
- Specified by:
setDTRin interfaceSerialPort
-
clearDTR
- Specified by:
clearDTRin interfaceSerialPort
-
getDTR
- Specified by:
getDTRin interfaceSerialPort
-
getRTS
- Specified by:
getRTSin interfaceSerialPort
-
getDSR
- Specified by:
getDSRin interfaceSerialPort
-
getCTS
- Specified by:
getCTSin interfaceSerialPort
-
getDCD
- Specified by:
getDCDin interfaceSerialPort
-
getRI
- Specified by:
getRIin interfaceSerialPort
-
setFlowControl
Configure the flow control settings. Keep this in synch with the FlowControl enum.- Specified by:
setFlowControlin interfaceSerialPort- Parameters:
flow- set which kind of flow control to use
-
setBreak
- Specified by:
setBreakin interfaceSerialPort
-
clearBreak
- Specified by:
clearBreakin interfaceSerialPort
-
getFlowControlSettings
- Specified by:
getFlowControlSettingsin interfaceSerialPort
-
setComPortTimeouts
public final boolean setComPortTimeouts(int newTimeoutMode, int newReadTimeout, int newWriteTimeout) - Specified by:
setComPortTimeoutsin interfaceSerialPort
-
closePort
- Specified by:
closePortin interfaceSerialPort
-
getDescriptivePortName
- Specified by:
getDescriptivePortNamein interfaceSerialPort
-
toString
- Specified by:
toStringin interfaceSerialPort- Overrides:
toStringin classObject
-
activatePort
public static JSerialPort activatePort(String systemPrefix, String inputPortName, org.slf4j.Logger log, int stop_bits, SerialPort.Parity parity) Open the port.- Parameters:
systemPrefix- the system prefixinputPortName- local system name for the desired portlog- Logger to use for errors, passed so that errors are logged from low-level class'stop_bits- The number of stop bits, either 1 or 2parity- one of the defined parity contants- Returns:
- the serial port object for later use
-
getActualPortNames
Provide the actual serial port names. As a public static method, this can be accessed outside the jmri.jmrix package to get the list of names for e.g. context reports.- Returns:
- the port names in the form they can later be used to open the port
-