public class Ascii extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
Ascii.ConnType
Connection type
|
static class |
Ascii.DataBits
Data characteristics - number of data bits
|
static class |
Ascii.FlowCtrl
Data characteristics - flow control
|
static class |
Ascii.Option
Connection type
|
static class |
Ascii.Parity
Data characteristics - parity
|
static class |
Ascii.StopBits
Data characteristics - number of stop bits
|
| Modifier and Type | Field and Description |
|---|---|
static int |
CONN_TYPE_FTDI
Connection type - serial via FTDI chip
|
static int |
CONN_TYPE_NETWORK
Connection type - network
|
static int |
CONN_TYPE_SERIAL
Connection type - serial via serial port
|
| Constructor and Description |
|---|
Ascii()
Constructor.
|
Ascii(Ascii.Option option)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the device connection.
|
boolean |
closeSilent()
Closes the device connection silently.
|
void |
flush()
Flushes any unread data.
|
static int |
makeDataCharacteristics(Ascii.DataBits dataBits,
Ascii.StopBits stopBits,
Ascii.Parity parity,
Ascii.FlowCtrl flowCtrl)
Generates the serial data characteristics parameter.
|
void |
open(Ascii.ConnType type,
String ident,
int parm)
Opens a connection to the device.
|
void |
open(Ascii.ConnType type,
String ident,
int parm1,
int parm2)
Opens a connection to the device.
|
void |
open(int type,
String ident,
int parm)
Deprecated.
|
void |
open(int type,
String ident,
int parm1,
int parm2)
Deprecated.
|
String |
read()
Reads a response.
|
String |
read(String command)
Reads a response after writing a command.
|
int |
readBytes(byte[] buff,
int offset)
Reads available response data as bytes.
|
int |
readBytes(byte[] buff,
int offset,
int leng)
Reads available response data as bytes.
|
void |
setTerminator(String term)
Sets the command terminator.
|
void |
setTimeout(double time)
Sets the read timeout.
|
void |
setTimeout(int time)
Sets the read timeout.
|
void |
write(String command)
Writes a command.
|
void |
writeBytes(byte[] command)
Writes a command as bytes.
|
void |
writeBytes(byte[] command,
int offset,
int leng)
Writes a command as bytes.
|
public static final int CONN_TYPE_NETWORK
public static final int CONN_TYPE_FTDI
public static final int CONN_TYPE_SERIAL
public Ascii()
public Ascii(Ascii.Option option)
option - Disallowed connections optionpublic void open(Ascii.ConnType type, String ident, int parm1, int parm2) throws org.lsst.ccs.drivers.commons.DriverException
type - The enumerated type of connection to makeident - The device identifier:
host name or IP address for network;
[node:]serial number for FTDI device;
device name for serialparm1 - The first device parameter:
port number for network;
baud rate for FTDI or serialparm2 - The second device parameter:
unused for network;
encoded data characteristics for FTDI or serial:
0 sets 8-bit, no parity, 1 stop bit, no flow ctrlorg.lsst.ccs.drivers.commons.DriverExceptionpublic void open(Ascii.ConnType type, String ident, int parm) throws org.lsst.ccs.drivers.commons.DriverException
type - The enumerated type of connection to makeident - The device identifier:
host name or IP address for network;
[node:]serial number for FTDI device;
device name for serialparm - The device parameter:
port number for network;
baud rate for FTDI or serialorg.lsst.ccs.drivers.commons.DriverException@Deprecated public final void open(int type, String ident, int parm1, int parm2) throws org.lsst.ccs.drivers.commons.DriverException
type - The type of connection to makeident - The device identifier:
host name or IP address for network;
[node:]serial number for FTDI device;
device name for serialparm1 - The first device parameter:
port number for network;
baud rate for FTDI or serialparm2 - The second device parameter:
unused for network;
encoded data characteristics for FTDI or serial:
0 sets 8-bit, no parity, 1 stop bit, no flow ctrlorg.lsst.ccs.drivers.commons.DriverException@Deprecated public void open(int type, String ident, int parm) throws org.lsst.ccs.drivers.commons.DriverException
type - The type of connection to makeident - The device identifier:
host name or IP address for network;
[node:]serial number for FTDI device;
device name for serialparm - The device parameter:
port number for network;
baud rate for FTDI or serialorg.lsst.ccs.drivers.commons.DriverExceptionpublic static int makeDataCharacteristics(Ascii.DataBits dataBits, Ascii.StopBits stopBits, Ascii.Parity parity, Ascii.FlowCtrl flowCtrl)
dataBits - The enumerated number of data bitsstopBits - The enumerated number of stop bitsparity - The enumerated parityflowCtrl - The enumerated flow controlpublic void close()
throws org.lsst.ccs.drivers.commons.DriverException
org.lsst.ccs.drivers.commons.DriverExceptionpublic boolean closeSilent()
public void write(String command) throws org.lsst.ccs.drivers.commons.DriverException
command - The command to write, excluding terminatororg.lsst.ccs.drivers.commons.DriverExceptionpublic String read() throws org.lsst.ccs.drivers.commons.DriverException
org.lsst.ccs.drivers.commons.DriverExceptionorg.lsst.ccs.drivers.commons.DriverTimeoutExceptionpublic String read(String command) throws org.lsst.ccs.drivers.commons.DriverException
command - The command to write, excluding terminatororg.lsst.ccs.drivers.commons.DriverExceptionorg.lsst.ccs.drivers.commons.DriverTimeoutExceptionpublic void writeBytes(byte[] command)
throws org.lsst.ccs.drivers.commons.DriverException
command - The command to write, including any terminatororg.lsst.ccs.drivers.commons.DriverExceptionpublic void writeBytes(byte[] command,
int offset,
int leng)
throws org.lsst.ccs.drivers.commons.DriverException
command - The command to write, including any terminatoroffset - The offset to the first byte to writeleng - The number of bytes to writeorg.lsst.ccs.drivers.commons.DriverExceptionpublic int readBytes(byte[] buff,
int offset)
throws org.lsst.ccs.drivers.commons.DriverException
buff - The buffer to receive the response dataoffset - The offset to the first available byte in the bufferorg.lsst.ccs.drivers.commons.DriverExceptionorg.lsst.ccs.drivers.commons.DriverTimeoutExceptionpublic int readBytes(byte[] buff,
int offset,
int leng)
throws org.lsst.ccs.drivers.commons.DriverException
buff - The buffer to receive the response dataoffset - The offset to the first available byte in the bufferleng - The maximum number of bytes to readorg.lsst.ccs.drivers.commons.DriverExceptionorg.lsst.ccs.drivers.commons.DriverTimeoutExceptionpublic void flush()
throws org.lsst.ccs.drivers.commons.DriverException
org.lsst.ccs.drivers.commons.DriverExceptionpublic void setTerminator(String term)
term - The terminator to be appended to each sent commandpublic void setTimeout(double time)
throws org.lsst.ccs.drivers.commons.DriverException
time - The read timeout (sec). 0 means no timeout.org.lsst.ccs.drivers.commons.DriverExceptionpublic void setTimeout(int time)
throws org.lsst.ccs.drivers.commons.DriverException
time - The read timeout (msec). 0 means no timeout.org.lsst.ccs.drivers.commons.DriverExceptionCopyright © 2015 LSST. All rights reserved.