public class Modbus extends Object
| Constructor and Description |
|---|
Modbus() |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the connection to the Modbus
|
org.lsst.ccs.drivers.ftdi.Ftdi |
getFtdi()
Gets the associated Ftdi object
|
void |
open(int index,
String serial)
Opens a connection to the Modbus
|
void |
open(String node,
int index,
String serial)
Opens a connection to the Modbus
|
byte[] |
readCoils(short dAddr,
short cNmbr,
short count)
Reads a set of coils
|
byte[] |
readDiscretes(short dAddr,
short iNmbr,
short count)
Reads a set of discrete inputs
|
short[] |
readInputs(short dAddr,
short rNmbr,
short count)
Reads a set of input registers
|
short[] |
readRegisters(short dAddr,
short rNmbr,
short count)
Reads a set of holding registers
|
byte[] |
send(short addr,
byte[] cmnd,
int timeout)
Sends a command to a device on the Modbus and returns its response
|
void |
writeCoil(short dAddr,
short cNmbr,
boolean value)
Writes a coil
|
void |
writeCoils(short dAddr,
short cNmbr,
short count,
byte[] value)
Writes a set of coils
|
void |
writeRegister(short dAddr,
short rNmbr,
short value)
Writes a holding register
|
void |
writeRegisters(short dAddr,
short rNmbr,
short[] value)
Writes a set of holding registers
|
public void open(int index,
String serial)
throws ModbusException
index - The zero-based index of the Modbus adapter within the
list of FTDI devices selected by the serial argumentserial - A string which, if non-null and non-empty, restricts
the list of available devices to those with a serial
number containing this stringModbusExceptionpublic void open(String node, int index, String serial) throws ModbusException
node - The name of the node from which the Modbus is being
served, or null for the local nodeindex - The zero-based index of the Modbus adapter within the
list of FTDI devices selected by the serial argumentserial - A string which, if non-null and non-empty, restricts
the list of available devices to those with a serial
number containing this stringModbusExceptionpublic void close()
throws ModbusException
ModbusExceptionpublic org.lsst.ccs.drivers.ftdi.Ftdi getFtdi()
public byte[] readCoils(short dAddr,
short cNmbr,
short count)
throws ModbusException
dAddr - The Modbus address of the devicecNmbr - The number (starting at 1) of the first coil to readcount - The number of coils to readModbusExceptionpublic byte[] readDiscretes(short dAddr,
short iNmbr,
short count)
throws ModbusException
dAddr - The Modbus address of the deviceiNmbr - The number (starting at 1) of the first input to readcount - The number of inputs to readModbusExceptionpublic short[] readRegisters(short dAddr,
short rNmbr,
short count)
throws ModbusException
dAddr - The Modbus address of the devicerNmbr - The number (starting at 1) of the first register to readcount - The number of registers to readModbusExceptionpublic short[] readInputs(short dAddr,
short rNmbr,
short count)
throws ModbusException
dAddr - The Modbus address of the devicerNmbr - The number (starting at 1) of the first register to readcount - The number of registers to readModbusExceptionpublic void writeRegister(short dAddr,
short rNmbr,
short value)
throws ModbusException
dAddr - The Modbus address of the devicerNmbr - The number (starting at 1) of the register to writevalue - The (16-bit) value to writeModbusExceptionpublic void writeCoil(short dAddr,
short cNmbr,
boolean value)
throws ModbusException
dAddr - The Modbus address of the devicecNmbr - The number (starting at 1) of the coil to writevalue - The value (false = off, true = on) to writeModbusExceptionpublic void writeRegisters(short dAddr,
short rNmbr,
short[] value)
throws ModbusException
dAddr - The Modbus address of the devicerNmbr - The number (starting at 1) of the first register to
writevalue - The array of register values to writeModbusExceptionpublic void writeCoils(short dAddr,
short cNmbr,
short count,
byte[] value)
throws ModbusException
dAddr - The Modbus address of the devicecNmbr - The number (starting at 1) of the first coil to writecount - The number of coil values to writevalue - The array of coil values to writeModbusExceptionpublic byte[] send(short addr,
byte[] cmnd,
int timeout)
throws ModbusException
addr - The destination Modbus addresscmnd - The command byte array to send.timeout - The timeout period (ms)ModbusExceptionCopyright © 2013 LSST. All Rights Reserved.