Package org.harctoolbox.harchardware
Interface ICommandLineDevice
- All Superinterfaces:
AutoCloseable
,Closeable
,IHarcHardware
- All Known Implementing Classes:
BufferedExecutor
,GirsClient
,GlobalCache.SerialPort
,LocalSerialPortBuffered
,TcpSocketChannel
,TcpSocketPort
,UdpSocketPort
,UrlPort
This interface specifies a device that can be sent commands, and that can be queried for responses.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
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
sendString
(String cmd) Sends a command (a String) to the instance.Methods inherited from interface org.harctoolbox.harchardware.IHarcHardware
getVersion, isValid, open, setDebug, setTimeout, setVerbose
-
Method Details
-
sendString
Sends a command (a String) to the instance.- Parameters:
cmd
- Command string to be sent.- Throws:
IOException
HarcHardwareException
-
readString
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.- Returns:
- A String containing the contents of the line, not including any line-termination characters, or null if no input available.
- Throws:
IOException
-
readString
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.- 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
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.- 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
-
flushInput
- Throws:
IOException
-