public class Ascii extends Object implements org.lsst.ccs.drivers.commons.DriverConstants
| Modifier and Type | Class and Description |
|---|---|
static class |
Ascii.DataBits
Data characteristics - number of data bits
|
static class |
Ascii.FlowCtrl
Data characteristics - flow control
|
static class |
Ascii.Option
Constructor options
|
static class |
Ascii.Parity
Data characteristics - parity
|
static class |
Ascii.StopBits
Data characteristics - number of stop bits
|
static class |
Ascii.Terminator
Command or response terminators
|
| Constructor and Description |
|---|
Ascii()
Constructor.
|
Ascii(Ascii.Option option)
Deprecated.
|
| 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.
|
int |
getTimeout()
Gets the read timeout.
|
boolean |
isOpen()
Tests whether the device connection is open.
|
static int |
makeDataCharacteristics(Ascii.DataBits dataBits,
Ascii.StopBits stopBits,
Ascii.Parity parity,
Ascii.FlowCtrl flowCtrl)
Generates the serial data characteristics parameter.
|
void |
open(org.lsst.ccs.drivers.commons.DriverConstants.ConnType type,
String ident)
Opens a connection to the device with default parameters.
|
void |
open(org.lsst.ccs.drivers.commons.DriverConstants.ConnType type,
String ident,
int parm)
Opens a connection to the device with default data characteristics.
|
void |
open(org.lsst.ccs.drivers.commons.DriverConstants.ConnType type,
String ident,
int parm1,
int parm2)
Opens a connection to the device.
|
void |
openFtdi(String serialNo)
Opens a connection to an FTDI device with default parameters.
|
void |
openFtdi(String serialNo,
int baudRate)
Opens a connection to an FTDI device with default data characteristics.
|
void |
openFtdi(String serialNo,
int baudRate,
int dataChar)
Opens a connection to an FTDI device.
|
void |
openNet(String host)
Opens a connection to a network device with default port.
|
void |
openNet(String host,
int port)
Opens a connection to a network device.
|
void |
openSerial(String devcName)
Opens a connection to a serial device with default parameters.
|
void |
openSerial(String devcName,
int baudRate)
Opens a connection to a serial device with default data characteristic.
|
void |
openSerial(String devcName,
int baudRate,
int dataChar)
Opens a connection to a serial device.
|
String |
read()
Reads a terminated 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 |
setCommandTerm(Ascii.Terminator term)
Sets the command terminator.
|
void |
setDefaultParm(int parm1)
Set the default parameter.
|
void |
setMultidrop()
Set multidrop connection.
|
void |
setOptions(Ascii.Option option)
Sets the options.
|
void |
setResponseTerm(Ascii.Terminator term)
Sets the response terminator.
|
void |
setTerminator(Ascii.Terminator term)
Sets both the command & response terminators.
|
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 Ascii()
@Deprecated public Ascii(Ascii.Option option)
option - Various optionspublic void setOptions(Ascii.Option option)
option - Various optionspublic void setDefaultParm(int parm1)
parm1 - Default parm1 valuepublic void setMultidrop()
public 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 open(org.lsst.ccs.drivers.commons.DriverConstants.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;
serial number for FTDI device;
device name for serialparm1 - The first device parameter, or 0 for default:
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 controlorg.lsst.ccs.drivers.commons.DriverExceptionpublic void open(org.lsst.ccs.drivers.commons.DriverConstants.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;
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 void open(org.lsst.ccs.drivers.commons.DriverConstants.ConnType type,
String ident)
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;
serial number for FTDI device;
device name for serialorg.lsst.ccs.drivers.commons.DriverExceptionpublic void openNet(String host, int port) throws org.lsst.ccs.drivers.commons.DriverException
host - The host name or IP addressport - The port numberorg.lsst.ccs.drivers.commons.DriverExceptionpublic void openNet(String host) throws org.lsst.ccs.drivers.commons.DriverException
host - The host name or IP addressorg.lsst.ccs.drivers.commons.DriverExceptionpublic void openSerial(String devcName, int baudRate, int dataChar) throws org.lsst.ccs.drivers.commons.DriverException
devcName - The device namebaudRate - The baud ratedataChar - The encoded data characteristics:
0 sets 8-bit, no parity, 1 stop bit, no flow ctrlorg.lsst.ccs.drivers.commons.DriverExceptionpublic void openSerial(String devcName, int baudRate) throws org.lsst.ccs.drivers.commons.DriverException
devcName - The device namebaudRate - The baud rateorg.lsst.ccs.drivers.commons.DriverExceptionpublic void openSerial(String devcName) throws org.lsst.ccs.drivers.commons.DriverException
devcName - The device nameorg.lsst.ccs.drivers.commons.DriverExceptionpublic void openFtdi(String serialNo, int baudRate, int dataChar) throws org.lsst.ccs.drivers.commons.DriverException
serialNo - The USB serial numberbaudRate - The baud ratedataChar - The encoded data characteristics:
0 sets 8-bit, no parity, 1 stop bit, no flow ctrlorg.lsst.ccs.drivers.commons.DriverExceptionpublic void openFtdi(String serialNo, int baudRate) throws org.lsst.ccs.drivers.commons.DriverException
serialNo - The USB serial numberbaudRate - The baud rateorg.lsst.ccs.drivers.commons.DriverExceptionpublic void openFtdi(String serialNo) throws org.lsst.ccs.drivers.commons.DriverException
serialNo - The USB serial numberorg.lsst.ccs.drivers.commons.DriverExceptionpublic void close()
throws org.lsst.ccs.drivers.commons.DriverException
org.lsst.ccs.drivers.commons.DriverExceptionpublic boolean closeSilent()
public boolean isOpen()
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 setResponseTerm(Ascii.Terminator term)
term - The expected terminator for a response (CR, LF or CRLF)public void setCommandTerm(Ascii.Terminator term)
term - The terminator to be appended to each command (CR, LF or CRLF)public void setTerminator(Ascii.Terminator term)
term - The terminator to be usedpublic 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.DriverExceptionpublic int getTimeout()
Copyright © 2018 LSST. All rights reserved.