public class TcpSocketPort extends Object implements ICommandLineDevice, IBytesCommand, IHarcHardware
| Modifier and Type | Class and Description |
|---|---|
static class |
TcpSocketPort.ConnectionMode |
| Modifier and Type | Field and Description |
|---|---|
static int |
defaultTimeout |
| Constructor and Description |
|---|
TcpSocketPort(String ipName,
int portNumber) |
TcpSocketPort(String hostIp,
int portNumber,
boolean verbose,
TcpSocketPort.ConnectionMode connectionMode) |
TcpSocketPort(String hostIp,
int portNumber,
int timeout,
boolean verbose,
TcpSocketPort.ConnectionMode connectionMode) |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
void |
flushInput() |
String |
getVersion()
Returns the hardware version (not the version of the driver software).
|
boolean |
isValid()
Tries to identify instances that are not valid.
|
static void |
main(String[] args) |
void |
open()
Opens the device with previously set parameters.
|
byte[] |
readBytes(int length) |
String |
readString()
Reads a line of text.
|
String |
readString(boolean wait)
Reads a line of text.
|
boolean |
ready()
Tells whether this stream is ready to be read.
|
void |
sendBytes(byte[] cmd) |
void |
sendString(String str)
Sends a command (a String) to the instance.
|
void |
setDebug(int debug)
Sets a debug parameter.
|
void |
setTimeout(int timeout)
Set timeout in milliseconds.
|
void |
setVerbose(boolean verbose)
Sets a verbosity flag, causing commands to be executed verbosely.
|
public static final int defaultTimeout
public TcpSocketPort(String hostIp, int portNumber, int timeout, boolean verbose, TcpSocketPort.ConnectionMode connectionMode) throws UnknownHostException
UnknownHostExceptionpublic TcpSocketPort(String hostIp, int portNumber, boolean verbose, TcpSocketPort.ConnectionMode connectionMode) throws UnknownHostException
UnknownHostExceptionpublic TcpSocketPort(String ipName, int portNumber) throws UnknownHostException
UnknownHostExceptionpublic static void main(String[] args)
public void open()
throws IOException
IHarcHardwareopen in interface IHarcHardwareIOExceptionpublic boolean ready()
throws IOException
ICommandLineDeviceready in interface ICommandLineDeviceIOException - If an I/O error occurspublic void flushInput()
throws IOException
flushInput in interface ICommandLineDeviceIOExceptionpublic void sendBytes(byte[] cmd)
throws IOException
sendBytes in interface IBytesCommandIOExceptionpublic byte[] readBytes(int length)
throws IOException
readBytes in interface IBytesCommandIOExceptionpublic void close()
close in interface Closeableclose in interface AutoCloseablepublic void sendString(String str) throws IOException
ICommandLineDevicesendString in interface ICommandLineDevicestr - Command string to be sent.IOExceptionpublic String readString() throws IOException
ICommandLineDevicereadString in interface ICommandLineDeviceIOExceptionpublic String readString(boolean wait) throws IOException
ICommandLineDevicereadString in interface ICommandLineDevicewait - if true, wait until something arrives, otherwise return null if nothing there.IOExceptionpublic boolean isValid()
IHarcHardwareisValid in interface IHarcHardwarepublic String getVersion()
IHarcHardwaregetVersion in interface IHarcHardwarepublic void setTimeout(int timeout)
IHarcHardwaresetTimeout in interface IHarcHardwaretimeout - Timeout in milliseconds.public void setVerbose(boolean verbose)
IHarcHardwaresetVerbose in interface IHarcHardwareverbose - on or offpublic void setDebug(int debug)
IHarcHardwaresetDebug in interface IHarcHardwareCopyright © 2020. All rights reserved.