Class LocalSerialPortBuffered
java.lang.Object
org.harctoolbox.harchardware.comm.LocalSerialPort
org.harctoolbox.harchardware.comm.LocalSerialPortBuffered
- All Implemented Interfaces:
Closeable,AutoCloseable,ICommandLineDevice,IHarcHardware
-
Nested Class Summary
Nested classes/interfaces inherited from class org.harctoolbox.harchardware.comm.LocalSerialPort
LocalSerialPort.FlowControl, LocalSerialPort.Parity, LocalSerialPort.StopBits -
Field Summary
Fields inherited from class org.harctoolbox.harchardware.comm.LocalSerialPort
DEFAULT, DEFAULT_BAUD, DEFAULT_DATABITS, DEFAULT_FLOWCONTROL, DEFAULT_PARITY, DEFAULT_PORT, DEFAULT_STOPBITS, DEFAULT_TIMEOUT, inStream, outStream, verbose -
Constructor Summary
ConstructorsConstructorDescriptionLocalSerialPortBuffered(Integer portNumber) LocalSerialPortBuffered(String portName) LocalSerialPortBuffered(String portName, boolean verbose) LocalSerialPortBuffered(String portName, boolean verbose, Integer timeout) LocalSerialPortBuffered(String portName, boolean verbose, Integer timeout, Integer baud) LocalSerialPortBuffered(String portName, boolean verbose, Integer timeout, Integer baud, Integer dataLength, LocalSerialPort.StopBits stopBits, LocalSerialPort.Parity parity, LocalSerialPort.FlowControl flowControl) -
Method Summary
Modifier and TypeMethodDescriptionstatic voidvoidopen()Opens the device.Reads a line of text.readString(boolean wait) Reads a line of text.booleanready()Tells whether this stream is ready to be read.voidsendByte(byte b) voidsendBytes(byte[] data) voidsendBytes(byte[] data, int offset, int length) voidsendString(String cmd) Sends a command (a String) to the instance.Methods inherited from class org.harctoolbox.harchardware.comm.LocalSerialPort
canonicalizePortName, canonicalizePortName, close, dropDTR, flush, flushInput, getPortName, getSerialPortName, getSerialPortNames, getSoftwareVersion, getVersion, isValid, mkStopBits, setDebug, setDTR, setLibraryDir, setTimeout, setVerboseMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.harctoolbox.harchardware.ICommandLineDevice
flushInputMethods inherited from interface org.harctoolbox.harchardware.IHarcHardware
getVersion, isValid, setDebug, setTimeout, setVerbose
-
Constructor Details
-
LocalSerialPortBuffered
public LocalSerialPortBuffered(String portName, boolean verbose, Integer timeout, Integer baud, Integer dataLength, LocalSerialPort.StopBits stopBits, LocalSerialPort.Parity parity, LocalSerialPort.FlowControl flowControl) throws IOException - Throws:
IOException
-
LocalSerialPortBuffered
public LocalSerialPortBuffered(String portName, boolean verbose, Integer timeout, Integer baud) throws IOException - Throws:
IOException
-
LocalSerialPortBuffered
public LocalSerialPortBuffered(String portName, boolean verbose, Integer timeout) throws IOException - Throws:
IOException
-
LocalSerialPortBuffered
- Throws:
IOException
-
LocalSerialPortBuffered
- Throws:
IOException
-
LocalSerialPortBuffered
- Throws:
NonExistingPortExceptionIOException
-
-
Method Details
-
main
-
open
Description copied from class:LocalSerialPortOpens the device.- Specified by:
openin interfaceIHarcHardware- Overrides:
openin classLocalSerialPort- Throws:
NonExistingPortExceptionHarcHardwareException- Bundles RXTX exceptions together.IOException
-
sendString
Description copied from interface:ICommandLineDeviceSends a command (a String) to the instance.- Specified by:
sendStringin interfaceICommandLineDevice- Parameters:
cmd- Command string to be sent.- Throws:
IOException
-
sendBytes
- Throws:
IOException
-
sendBytes
- Throws:
IOException
-
sendByte
- Throws:
IOException
-
readString
Description copied from interface:ICommandLineDeviceReads a line of text. A line is considered to be terminated by any one of a line feed ('\n'), a carriage return ('\r'), or a carriage return followed immediately by a linefeed.- Specified by:
readStringin interfaceICommandLineDevice- Returns:
- A String containing the contents of the line, not including any line-termination characters, or null if no input available.
- Throws:
IOException
-
readString
Description copied from interface:ICommandLineDeviceReads a line of text. A line is considered to be terminated by any one of a line feed ('\n'), a carriage return ('\r'), or a carriage return followed immediately by a linefeed.- Specified by:
readStringin interfaceICommandLineDevice- Parameters:
wait- if true, wait until something arrives, otherwise return null if nothing there.- Returns:
- A String containing the contents of the line, not including any line-termination characters, or null if no input available.
- Throws:
IOException
-
ready
Description copied from interface:ICommandLineDeviceTells whether this stream is ready to be read. A buffered character stream is ready if the buffer is not empty, or if the underlying character stream is ready.- Specified by:
readyin interfaceICommandLineDevice- Returns:
- True if the next read() is guaranteed not to block for input, false otherwise. Note that returning false does not guarantee that the next read will block.
- Throws:
IOException- If an I/O error occurs
-