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
ConstructorDescriptionLocalSerialPortBuffered
(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 void
void
open()
Opens the device.Reads a line of text.readString
(boolean wait) Reads a line of text.boolean
ready()
Tells whether this stream is ready to be read.void
sendByte
(byte b) void
sendBytes
(byte[] data) void
sendBytes
(byte[] data, int offset, int length) void
sendString
(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, setVerbose
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.harctoolbox.harchardware.ICommandLineDevice
flushInput
Methods 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:
NonExistingPortException
IOException
-
-
Method Details
-
main
-
open
Description copied from class:LocalSerialPort
Opens the device.- Specified by:
open
in interfaceIHarcHardware
- Overrides:
open
in classLocalSerialPort
- Throws:
NonExistingPortException
HarcHardwareException
- Bundles RXTX exceptions together.IOException
-
sendString
Description copied from interface:ICommandLineDevice
Sends a command (a String) to the instance.- Specified by:
sendString
in interfaceICommandLineDevice
- Parameters:
cmd
- Command string to be sent.- Throws:
IOException
-
sendBytes
- Throws:
IOException
-
sendBytes
- Throws:
IOException
-
sendByte
- Throws:
IOException
-
readString
Description copied from interface:ICommandLineDevice
Reads 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:
readString
in 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:ICommandLineDevice
Reads 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:
readString
in 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:ICommandLineDevice
Tells 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:
ready
in 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
-