public class TcpSocketChannel extends Object implements IStringCommand, IBytesCommand
| Constructor and Description |
|---|
TcpSocketChannel(InetAddress inetAddress,
int portNumber,
int timeout,
boolean verbose,
TcpSocketPort.ConnectionMode connectionMode) |
TcpSocketChannel(String hostIp,
int portNumber,
int timeout,
boolean verbose,
TcpSocketPort.ConnectionMode connectionMode) |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
void |
close(boolean force) |
void |
connect() |
BufferedReader |
getBufferedIn() |
InputStream |
getIn() |
OutputStream |
getOut() |
String |
getVersion()
Returns the hardware version (not the version of the driver software).
|
boolean |
isValid()
Tries to identify instances that are not valid.
|
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 cmd) |
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 TcpSocketChannel(String hostIp, int portNumber, int timeout, boolean verbose, TcpSocketPort.ConnectionMode connectionMode) throws UnknownHostException
hostIp - portNumber - timeout - verbose - connectionMode - UnknownHostExceptionpublic TcpSocketChannel(InetAddress inetAddress, int portNumber, int timeout, boolean verbose, TcpSocketPort.ConnectionMode connectionMode)
inetAddress - portNumber - timeout - verbose - connectionMode - public void connect()
throws IOException
IOExceptionpublic void close(boolean force)
throws IOException
force - IOExceptionpublic OutputStream getOut()
public InputStream getIn()
public BufferedReader getBufferedIn()
public boolean isValid()
IHarcHardwareisValid in interface IHarcHardwarepublic void setTimeout(int timeout)
throws SocketException
IHarcHardwaresetTimeout in interface IHarcHardwaretimeout - Timeout in milliseconds.SocketExceptionpublic void setVerbosity(boolean verbose)
IHarcHardwaresetVerbosity in interface IHarcHardwareverbose - on or offpublic void setDebug(int debug)
IHarcHardwaresetDebug in interface IHarcHardwarepublic void sendString(String cmd) throws IOException
sendString in interface IStringCommandIOExceptionpublic String readString() throws IOException
IStringCommandreadString in interface IStringCommandIOExceptionpublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionpublic void sendBytes(byte[] cmd)
throws IOException
sendBytes in interface IBytesCommandIOExceptionpublic byte[] readBytes(int length)
throws IOException
readBytes in interface IBytesCommandIOExceptionpublic String getVersion()
IHarcHardwaregetVersion in interface IHarcHardwarepublic void open()
IHarcHardwareopen in interface IHarcHardwarepublic boolean ready()
throws IOException
IStringCommandready in interface IStringCommandIOException - If an I/O error occursCopyright © 2015. All rights reserved.