Package jmri.jmrix.jserialcomm
Class JSerialPort
- java.lang.Object
-
- jmri.jmrix.jserialcomm.JSerialPort
-
- All Implemented Interfaces:
SerialPort
public class JSerialPort extends java.lang.Object implements 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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static JSerialPort
activatePort(java.lang.String systemPrefix, java.lang.String inputPortName, org.slf4j.Logger log, int stop_bits, SerialPort.Parity parity)
Open the port.void
addDataListener(SerialPortDataListener listener)
void
clearBreak()
void
clearDTR()
void
clearRTS()
void
closePort()
static java.util.Vector<java.lang.String>
getActualPortNames()
Provide the actual serial port names.int
getBaudRate()
boolean
getCTS()
boolean
getDCD()
java.lang.String
getDescriptivePortName()
boolean
getDSR()
boolean
getDTR()
int
getFlowControlSettings()
java.io.InputStream
getInputStream()
int
getNumDataBits()
int
getNumStopBits()
java.io.OutputStream
getOutputStream()
SerialPort.Parity
getParity()
boolean
getRI()
boolean
getRTS()
void
setBaudRate(int baudrate)
void
setBreak()
boolean
setComPortTimeouts(int newTimeoutMode, int newReadTimeout, int newWriteTimeout)
void
setDTR()
void
setFlowControl(AbstractSerialPortController.FlowControl flow)
Configure the flow control settings.void
setNumDataBits(int bits)
void
setNumStopBits(int bits)
void
setParity(SerialPort.Parity parity)
void
setRTS()
java.lang.String
toString()
-
-
-
Method Detail
-
addDataListener
public void addDataListener(SerialPortDataListener listener)
- Specified by:
addDataListener
in interfaceSerialPort
-
getInputStream
public java.io.InputStream getInputStream()
- Specified by:
getInputStream
in interfaceSerialPort
-
getOutputStream
public java.io.OutputStream getOutputStream()
- Specified by:
getOutputStream
in interfaceSerialPort
-
setRTS
public void setRTS()
- Specified by:
setRTS
in interfaceSerialPort
-
clearRTS
public void clearRTS()
- Specified by:
clearRTS
in interfaceSerialPort
-
setBaudRate
public void setBaudRate(int baudrate)
- Specified by:
setBaudRate
in interfaceSerialPort
-
getBaudRate
public int getBaudRate()
- Specified by:
getBaudRate
in interfaceSerialPort
-
setNumDataBits
public void setNumDataBits(int bits)
- Specified by:
setNumDataBits
in interfaceSerialPort
-
getNumDataBits
public final int getNumDataBits()
- Specified by:
getNumDataBits
in interfaceSerialPort
-
setNumStopBits
public void setNumStopBits(int bits)
- Specified by:
setNumStopBits
in interfaceSerialPort
-
getNumStopBits
public final int getNumStopBits()
- Specified by:
getNumStopBits
in interfaceSerialPort
-
setParity
public void setParity(SerialPort.Parity parity)
- Specified by:
setParity
in interfaceSerialPort
-
getParity
public SerialPort.Parity getParity()
- Specified by:
getParity
in interfaceSerialPort
-
setDTR
public void setDTR()
- Specified by:
setDTR
in interfaceSerialPort
-
clearDTR
public void clearDTR()
- Specified by:
clearDTR
in interfaceSerialPort
-
getDTR
public boolean getDTR()
- Specified by:
getDTR
in interfaceSerialPort
-
getRTS
public boolean getRTS()
- Specified by:
getRTS
in interfaceSerialPort
-
getDSR
public boolean getDSR()
- Specified by:
getDSR
in interfaceSerialPort
-
getCTS
public boolean getCTS()
- Specified by:
getCTS
in interfaceSerialPort
-
getDCD
public boolean getDCD()
- Specified by:
getDCD
in interfaceSerialPort
-
getRI
public boolean getRI()
- Specified by:
getRI
in interfaceSerialPort
-
setFlowControl
public final void setFlowControl(AbstractSerialPortController.FlowControl flow)
Configure the flow control settings. Keep this in synch with the FlowControl enum.- Specified by:
setFlowControl
in interfaceSerialPort
- Parameters:
flow
- set which kind of flow control to use
-
setBreak
public void setBreak()
- Specified by:
setBreak
in interfaceSerialPort
-
clearBreak
public void clearBreak()
- Specified by:
clearBreak
in interfaceSerialPort
-
getFlowControlSettings
public final int getFlowControlSettings()
- Specified by:
getFlowControlSettings
in interfaceSerialPort
-
setComPortTimeouts
public final boolean setComPortTimeouts(int newTimeoutMode, int newReadTimeout, int newWriteTimeout)
- Specified by:
setComPortTimeouts
in interfaceSerialPort
-
closePort
public void closePort()
- Specified by:
closePort
in interfaceSerialPort
-
getDescriptivePortName
public java.lang.String getDescriptivePortName()
- Specified by:
getDescriptivePortName
in interfaceSerialPort
-
toString
public java.lang.String toString()
- Specified by:
toString
in interfaceSerialPort
- Overrides:
toString
in classjava.lang.Object
-
activatePort
public static JSerialPort activatePort(java.lang.String systemPrefix, java.lang.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
public static java.util.Vector<java.lang.String> 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
-
-