public class TcpSocketPort extends Object implements IStringCommand, 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 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() |
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.
|
boolean |
ready()
Tells whether this stream is ready to be read.
|
void |
sendBytes(byte[] cmd) |
void |
sendString(String str) |
void |
setDebug(int debug)
Sets a debug parameter.
|
void |
setTimeout(int timeout)
Set timeout in milliseconds.
|
void |
setVerbosity(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
UnknownHostException
public TcpSocketPort(String hostIp, int portNumber, boolean verbose, TcpSocketPort.ConnectionMode connectionMode) throws UnknownHostException
UnknownHostException
public void open() throws IOException
IHarcHardware
open
in interface IHarcHardware
IOException
public boolean ready() throws IOException
IStringCommand
ready
in interface IStringCommand
IOException
- If an I/O error occurspublic void sendBytes(byte[] cmd) throws IOException
sendBytes
in interface IBytesCommand
IOException
public byte[] readBytes(int length) throws IOException
readBytes
in interface IBytesCommand
IOException
public void close()
close
in interface Closeable
close
in interface AutoCloseable
public void sendString(String str) throws IOException
sendString
in interface IStringCommand
IOException
public String readString() throws IOException
IStringCommand
readString
in interface IStringCommand
IOException
public boolean isValid()
IHarcHardware
isValid
in interface IHarcHardware
public String getVersion()
IHarcHardware
getVersion
in interface IHarcHardware
public void setTimeout(int timeout)
IHarcHardware
setTimeout
in interface IHarcHardware
timeout
- Timeout in milliseconds.public void setVerbosity(boolean verbose)
IHarcHardware
setVerbosity
in interface IHarcHardware
verbose
- on or offpublic void setDebug(int debug)
IHarcHardware
setDebug
in interface IHarcHardware
public static void main(String[] args)
Copyright © 2015. All rights reserved.