|
|
 |
Data and Control Functions for all Protocols
Detailed Description
This protocol stack implements the most commonly used Modbus® data functions as well as some control functions. The functions to perform PLC program download and other device specific functions are outside the scope of this package.
All functions of conformance Class 0 and Class 1 have been implemented. In addition the most frequent used functions of conformance Class 2 have been implemented.
The following table lists the available FieldTalk Master Protocol Pack functions:
| Function Code | Current Terminology | Classic Terminology |
| Conformance Class 0 |
| 3 (03 hex) | Read Multiple Registers | Read Holding Registers |
| 16 (10 hex) | Write Multiple Registers | Preset Multiple Registers |
| Conformance Class 1 |
| 1 (01 hex) | Read Coils | Read Coil Status |
| 2 (02 hex) | Read Inputs Discretes | Read Input Status |
| 4 (04 hex) | Read Input Registers | Read Input Registers |
| 5 (05 hex) | Write Coil | Force Single Coil |
| 6 (06 hex) | Write Single Register | Preset Single Register |
| 7 (07 hex) | Read Exception Status | Read Exception Status |
| Conformance Class 2 |
| 15 (0F hex) | Force Multiple Coils | Force Multiple Coils |
| 22 (16 hex) | Mask Write Register | Mask Write Register |
| 23 (17 hex) | Read/Write Registers | Read/Write Registers |
| Vendor Specific |
| 100 (64 hex) | Read Log History | |
| n/a | Send/Receive ADAM 5000/6000 ASCII command | |
- Remarks:
- When passing register numbers and discrete numbers to FieldTalk functions you have to use the the Modbus register and discrete numbering scheme. See Register and Discrete Numbering Scheme. (Internally the functions will deduct 1 from the start register value before transmitting the value to the slave device.)
Most slave devices are limiting the amount of registers to be exchanged with the ASCII protocol to be 62 registers or 496 discretes. The limitation is based on the fact that the buffer must not exceed 256 bytes.
All master data and control functions are designed thread-safe. All methods of a particular MbusMaster... object can only be accessed by one thread at the same time. In addition, access to the register array objects is synchronized to allow concurrent access. This enables one thread to update a register array while a second thread is sending the data to a Modbus slave. In this case the update thread must also synchronize his access to the register array by embedding the access into a synchronized(regArr) clause.
Using multiple instances of a MbusMaster... class enables concurrent protocol transfer on different communication channels (e.g. multiple TCP/IP sessions in separate threads or multiple COM ports in separate threads).
|
Compounds |
| class | MbusMasterFunctions |
| | This base class implements the Modbus® master functions. More...
|
Class 0 Modbus Functions |
| synchronized void | com::focus_sw::fieldtalk::MbusMasterFunctions.writeMultipleRegisters (int slaveAddr, int startRef, short[] regArr) throws IOException, BusProtocolException |
| | Modbus function 16 (10 hex), Preset Multiple Registers/Write Multiple Registers.
|
| synchronized void | com::focus_sw::fieldtalk::MbusMasterFunctions.writeMultipleRegisters (int slaveAddr, int startRef, int[] int32Arr) throws IOException, BusProtocolException |
| | Modbus function 16 (10 hex) for 32-bit int data types, Preset Multiple Registers/Write Multiple Registers with int data.
|
| synchronized void | com::focus_sw::fieldtalk::MbusMasterFunctions.writeMultipleRegisters (int slaveAddr, int startRef, float[] float32Arr) throws IOException, BusProtocolException |
| | Modbus function 16 (10 hex) for 32-bit float data types, Preset Multiple Registers/Write Multiple Registers with float data.
|
| synchronized void | com::focus_sw::fieldtalk::MbusMasterFunctions.readMultipleRegisters (int slaveAddr, int startRef, short[] regArr) throws IOException, BusProtocolException |
| | Modbus function 3 (03 hex), Read Holding Registers/Read Multiple Registers.
|
| synchronized void | com::focus_sw::fieldtalk::MbusMasterFunctions.readMultipleRegisters (int slaveAddr, int startRef, int[] int32Arr) throws IOException, BusProtocolException |
| | Modbus function 3 (03 hex) for 32-bit int data types, Read Holding Registers/Read Multiple Registers as int data.
|
| synchronized void | com::focus_sw::fieldtalk::MbusMasterFunctions.readMultipleRegisters (int slaveAddr, int startRef, float[] float32Arr) throws IOException, BusProtocolException |
| | Modbus function 3 (03 hex) for 32-bit float data types, Read Holding Registers/Read Multiple Registers as float data.
|
Class 1 Modbus Functions |
| synchronized void | com::focus_sw::fieldtalk::MbusMasterFunctions.readCoils (int slaveAddr, int startRef, boolean[] bitArr) throws IOException, BusProtocolException |
| | Modbus function 1 (01 hex), Read Coil Status/Read Coils.
|
| synchronized void | com::focus_sw::fieldtalk::MbusMasterFunctions.readInputDiscretes (int slaveAddr, int startRef, boolean[] bitArr) throws IOException, BusProtocolException |
| | Modbus function 2 (02 hex), Read Inputs Status/Read Input Discretes.
|
| synchronized void | com::focus_sw::fieldtalk::MbusMasterFunctions.readInputRegisters (int slaveAddr, int startRef, short[] regArr) throws IOException, BusProtocolException |
| | Modbus function 4 (04 hex), Read Input Registers.
|
| synchronized void | com::focus_sw::fieldtalk::MbusMasterFunctions.readInputRegisters (int slaveAddr, int startRef, int[] int32Arr) throws IOException, BusProtocolException |
| | Modbus function 4 (04 hex) for 32-bit int data types, Read Input Registers as int data.
|
| synchronized void | com::focus_sw::fieldtalk::MbusMasterFunctions.readInputRegisters (int slaveAddr, int startRef, float[] float32Arr) throws IOException, BusProtocolException |
| | Modbus function 4 (04 hex) for 32-bit float data types, Read Input Registers as float data.
|
| synchronized void | com::focus_sw::fieldtalk::MbusMasterFunctions.writeCoil (int slaveAddr, int bitAddr, boolean bitVal) throws IOException, BusProtocolException |
| | Modbus function 5 (05 hex), Force Single Coil/Write Coil.
|
| synchronized void | com::focus_sw::fieldtalk::MbusMasterFunctions.writeSingleRegister (int slaveAddr, int regAddr, short regVal) throws IOException, BusProtocolException |
| | Modbus function 6 (06 hex), Preset Single Register/Write Single Register.
|
| synchronized byte | com::focus_sw::fieldtalk::MbusMasterFunctions.readExceptionStatus (int slaveAddr) throws IOException, BusProtocolException |
| | Modbus function 7 (07 hex), Read Exception Status.
|
Class 2 Modbus Functions |
| synchronized void | com::focus_sw::fieldtalk::MbusMasterFunctions.forceMultipleCoils (int slaveAddr, int startRef, boolean[] bitArr) throws IOException, BusProtocolException |
| | Modbus function 15 (0F hex), Force Multiple Coils.
|
| synchronized void | com::focus_sw::fieldtalk::MbusMasterFunctions.maskWriteRegister (int slaveAddr, int regAddr, short andMask, short orMask) throws IOException, BusProtocolException |
| | Modbus function 22 (16 hex), Mask Write Register.
|
| synchronized void | com::focus_sw::fieldtalk::MbusMasterFunctions.readWriteRegisters (int slaveAddr, int readRef, short[] readArr, int writeRef, short[] writeArr) throws IOException, BusProtocolException |
| | Modbus function 23 (17 hex), Read/Write Registers.
|
Protocol Configuration |
| synchronized void | com::focus_sw::fieldtalk::MbusMasterFunctions.setTimeout (int timeOut) |
| | Configures time-out.
|
| int | com::focus_sw::fieldtalk::MbusMasterFunctions.getTimeout () |
| | Returns the operation time-out value.
|
| synchronized void | com::focus_sw::fieldtalk::MbusMasterFunctions.setPollDelay (int pollDelay) |
| | Configures poll delay.
|
| int | com::focus_sw::fieldtalk::MbusMasterFunctions.getPollDelay () |
| | Returns the poll delay time.
|
| synchronized void | com::focus_sw::fieldtalk::MbusMasterFunctions.setRetryCnt (int retryCnt) |
| | Configures the automatic retry setting.
|
| int | com::focus_sw::fieldtalk::MbusMasterFunctions.getRetryCnt () |
| | Returns the automatic retry count.
|
Transmission Statistic Functions |
| synchronized long | com::focus_sw::fieldtalk::MbusMasterFunctions.getTotalCounter () |
| | Returns how often a transmit/receive cycle has been executed.
|
|
synchronized void | com::focus_sw::fieldtalk::MbusMasterFunctions.resetTotalCounter () |
| | Resets total transmit/receive cycle counter.
|
| synchronized long | com::focus_sw::fieldtalk::MbusMasterFunctions.getSuccessCounter () |
| | Returns how often a transmit/receive cycle was successful.
|
|
synchronized void | com::focus_sw::fieldtalk::MbusMasterFunctions.resetSuccessCounter () |
| | Resets successful transmit/receive counter.
|
Slave Configuration |
| void | com::focus_sw::fieldtalk::MbusMasterFunctions.configureStandard32BitMode () |
| | Configures all slaves for Standard 32-bit Mode.
|
| synchronized void | com::focus_sw::fieldtalk::MbusMasterFunctions.configureStandard32BitMode (int slaveAddr) |
| | Configures a slave for Standard 32-bit Register Mode.
|
| void | com::focus_sw::fieldtalk::MbusMasterFunctions.configureSingleReg32BitMode () |
| | Configures all slaves for Single Register 32-bit Mode.
|
| synchronized void | com::focus_sw::fieldtalk::MbusMasterFunctions.configureSingleReg32BitMode (int slaveAddr) |
| | Configures all slaves for Single Register 32-bit Mode.
|
| void | com::focus_sw::fieldtalk::MbusMasterFunctions.configureCountFromOne () |
| | Configures the reference counting scheme to start with one for all slaves.
|
| synchronized void | com::focus_sw::fieldtalk::MbusMasterFunctions.configureCountFromOne (int slaveAddr) |
| | Configures a slave's reference counting scheme to start with one.
|
| void | com::focus_sw::fieldtalk::MbusMasterFunctions.configureCountFromZero () |
| | Configures the reference counting scheme to start with zero for all slaves.
|
| synchronized void | com::focus_sw::fieldtalk::MbusMasterFunctions.configureCountFromZero (int slaveAddr) |
| | Configures a slave's reference counting scheme to start with zero.
|
| void | com::focus_sw::fieldtalk::MbusMasterFunctions.configureLittleEndianInts () |
| | Disables word swapping for int data type functions for all slaves.
|
| synchronized void | com::focus_sw::fieldtalk::MbusMasterFunctions.configureLittleEndianInts (int slaveAddr) |
| | Disables word swapping for int data type functions on a per slave basis.
|
| void | com::focus_sw::fieldtalk::MbusMasterFunctions.configureBigEndianInts () |
| | Configures int data type functions to do a word swap for all slaves.
|
| synchronized void | com::focus_sw::fieldtalk::MbusMasterFunctions.configureBigEndianInts (int slaveAddr) |
| | Enables int data type functions to do a word swap on a per slave basis.
|
| void | com::focus_sw::fieldtalk::MbusMasterFunctions.configureLittleEndianFloats () |
| | Disables float data type functions to do a word swap for all slaves.
|
| synchronized void | com::focus_sw::fieldtalk::MbusMasterFunctions.configureLittleEndianFloats (int slaveAddr) |
| | Disables float data type functions to do a word swap on a per slave basis.
|
| void | com::focus_sw::fieldtalk::MbusMasterFunctions.configureSwappedFloats () |
| | Configures float data type functions to do a word swap for all slaves.
|
| synchronized void | com::focus_sw::fieldtalk::MbusMasterFunctions.configureSwappedFloats (int slaveAddr) |
| | Enables float data type functions to do a word swap on a per slave basis.
|
Function Documentation
| synchronized void writeMultipleRegisters |
( |
int |
slaveAddr, |
|
|
int |
startRef, |
|
|
short[] |
regArr |
|
) |
throws IOException, BusProtocolException [inherited] |
|
|
|
Modbus function 16 (10 hex), Preset Multiple Registers/Write Multiple Registers.
Writes values into a sequence of output registers (holding registers, 4:00000 table).
- Parameters:
-
| slaveAddr | Modbus address of slave device or unit identifier (Range: 0 - 247) |
| startRef | Start reference (Range depends on configuration setting) |
| regArr | Buffer with the data to be sent. The length of the array determines how many registers are sent (Range: 1-100). |
- Exceptions:
-
| IllegalStateException | Port or connection is closed |
| IOException | An I/O error occured |
| IllegalArgumentException | A parameter is out of range |
| BusProtocolException | A protocol failure occured. See descendants of BusProtocolException for a more detailed failure list. |
- Note:
- Broadcast supported for serial protocols
|
| synchronized void readCoils |
( |
int |
slaveAddr, |
|
|
int |
startRef, |
|
|
boolean[] |
bitArr |
|
) |
throws IOException, BusProtocolException [inherited] |
|
|
|
Modbus function 1 (01 hex), Read Coil Status/Read Coils.
Reads the contents of the discrete outputs (coils, 0:00000 table).
- Parameters:
-
| slaveAddr | Modbus address of slave device or unit identifier (Range: 1 - 247) |
| startRef | Start reference (Range: depends on configuration setting) |
| bitArr | Buffer which will contain the data read |
- Exceptions:
-
| IOException | An I/O error occured |
| IllegalArgumentException | A parameter is out of range |
| BusProtocolException | A protocol failure occured. See descendants of BusProtocolException for a more detailed failure list. |
- Note:
- No broadcast supported
|
| synchronized void forceMultipleCoils |
( |
int |
slaveAddr, |
|
|
int |
startRef, |
|
|
boolean[] |
bitArr |
|
) |
throws IOException, BusProtocolException [inherited] |
|
|
|
Modbus function 15 (0F hex), Force Multiple Coils.
Writes binary values into a sequence of discrete outputs (coils, 0:00000 table).
- Parameters:
-
| slaveAddr | Modbus address of slave device or unit identifier (Range: 1 - 247) |
| startRef | Start reference (Range: depends on configuration setting) |
| bitArr | Buffer which contains the data to be sent |
- Exceptions:
-
| IllegalStateException | Port or connection is closed |
| IOException | An I/O error occured |
| BusProtocolException | A protocol failure occured. See descendants of BusProtocolException for a more detailed failure list. |
- Note:
- Broadcast supported for serial protocols
|
| synchronized void setTimeout |
( |
int |
timeOut |
) |
[inherited] |
|
|
|
Configures time-out.
This function sets the time-out to the specified value. A value of 0 disables the time-out, which causes all subsequent calls to data and control functions to block. - Note:
- A port or connection must be closed in order to configure it.
- Parameters:
-
| timeOut | Timeout value in ms (Range: 0 - 100000), 0 disables time-out |
- Exceptions:
-
| IllegalStateException | Port is open |
| IllegalArgumentException | Parameter is out of range |
|
| synchronized long getTotalCounter |
( |
|
) |
[inherited] |
|
|
|
Returns how often a transmit/receive cycle has been executed.
- Returns:
- Counter value
|
| void configureStandard32BitMode |
( |
|
) |
[inherited] |
|
|
|
Configures all slaves for Standard 32-bit Mode.
In Standard 32-bit Register Mode a 32-bit value is transmitted as two consecutive 16-bit Modbus registers.
- Remarks:
- This is the default mode
|
| synchronized void writeMultipleRegisters |
( |
int |
slaveAddr, |
|
|
int |
startRef, |
|
|
int[] |
int32Arr |
|
) |
throws IOException, BusProtocolException [inherited] |
|
|
|
Modbus function 16 (10 hex) for 32-bit int data types, Preset Multiple Registers/Write Multiple Registers with int data.
Writes int values into a pairs of output registers (holding registers, 4:00000 table). - Remarks:
- Depending on the 32-bit Mode setting, an int will be transferred as two consecutive 16-bit registers (Standard) or as one 32-bit register (Daniel/Enron).
- Parameters:
-
| slaveAddr | Modbus address of slave device or unit identifier (Range: 0 - 247) |
| startRef | Start reference (Range: depends on configuration setting) |
| int32Arr | Buffer with the data to be sent. The length of the array determines how many registers are sent (Range: 1-50). |
- Exceptions:
-
| IOException | An I/O error occured |
| IllegalArgumentException | A parameter is out of range |
| BusProtocolException | A protocol failure occured. See descendants of BusProtocolException for a more detailed failure list. |
- Note:
- Broadcast supported for serial protocols
|
| synchronized void writeMultipleRegisters |
( |
int |
slaveAddr, |
|
|
int |
startRef, |
|
|
float[] |
float32Arr |
|
) |
throws IOException, BusProtocolException [inherited] |
|
|
|
Modbus function 16 (10 hex) for 32-bit float data types, Preset Multiple Registers/Write Multiple Registers with float data.
Writes float values into a pairs of output registers (holding registers, 4:00000 table). - Remarks:
- Depending on the 32-bit Mode setting, an int will be transferred as two consecutive 16-bit registers (Standard) or as one 32-bit register (Daniel/Enron).
- Parameters:
-
| slaveAddr | Modbus address of slave device or unit identifier (Range: 0 - 247) |
| startRef | Start reference (Range: depends on configuration setting) |
| float32Arr | Buffer with the data to be sent. The length of the array determines how many registers are sent (Range: 1-50). |
- Exceptions:
-
| IOException | An I/O error occured |
| IllegalArgumentException | A parameter is out of range |
| BusProtocolException | A protocol failure occured. See descendants of BusProtocolException for a more detailed failure list. |
- Note:
- Broadcast supported for serial protocols
|
| synchronized void readMultipleRegisters |
( |
int |
slaveAddr, |
|
|
int |
startRef, |
|
|
short[] |
regArr |
|
) |
throws IOException, BusProtocolException [inherited] |
|
|
|
Modbus function 3 (03 hex), Read Holding Registers/Read Multiple Registers.
Reads the contents of the output registers (holding registers, 4:00000 table).
- Parameters:
-
| slaveAddr | Modbus address of slave device or unit identifier (Range: 1 - 247) |
| startRef | Start reference (Range: depends on configuration setting) |
| regArr | Buffer which will be filled with the data read. The length of the array determines how many registers are read (Range: 1-125). |
- Exceptions:
-
| IOException | An I/O error occured |
| IllegalArgumentException | A parameter is out of range |
| BusProtocolException | A protocol failure occured. See descendants of BusProtocolException for a more detailed failure list. |
- Note:
- No broadcast supported
|
| synchronized void readMultipleRegisters |
( |
int |
slaveAddr, |
|
|
int |
startRef, |
|
|
int[] |
int32Arr |
|
) |
throws IOException, BusProtocolException [inherited] |
|
|
|
Modbus function 3 (03 hex) for 32-bit int data types, Read Holding Registers/Read Multiple Registers as int data.
Reads the contents of pairs of two consecutive output registers (holding registers, 4:00000 table) into float values.
- Remarks:
- Depending on the 32-bit Mode setting, an int will be transferred as two consecutive 16-bit registers (Standard) or as one 32-bit register (Daniel/Enron).
- Parameters:
-
| slaveAddr | Modbus address of slave device or unit identifier (Range: 1 - 247) |
| startRef | Start reference (Range: depends on configuration setting) |
| int32Arr | Buffer which will be filled with the data read. The length of the array determines how many registers are read (Range: 1-62). |
- Exceptions:
-
| IOException | An I/O error occured |
| IllegalArgumentException | A parameter is out of range |
| BusProtocolException | A protocol failure occured. See descendants of BusProtocolException for a more detailed failure list. |
- Note:
- No broadcast supported
|
| synchronized void readMultipleRegisters |
( |
int |
slaveAddr, |
|
|
int |
startRef, |
|
|
float[] |
float32Arr |
|
) |
throws IOException, BusProtocolException [inherited] |
|
|
|
Modbus function 3 (03 hex) for 32-bit float data types, Read Holding Registers/Read Multiple Registers as float data.
Reads the contents of pairs of two consecutive output registers (holding registers, 4:00000 table) into float values.
- Remarks:
- Depending on the 32-bit Mode setting, an int will be transferred as two consecutive 16-bit registers (Standard) or as one 32-bit register (Daniel/Enron).
- Parameters:
-
| slaveAddr | Modbus address of slave device or unit identifier (Range: 1 - 247) |
| startRef | Start reference (Range: depends on configuration setting) |
| float32Arr | Buffer which will be filled with the data read. The length of the array determines how many registers are read (Range: 1-62). |
- Exceptions:
-
| IOException | An I/O error occured |
| IllegalArgumentException | A parameter is out of range |
| BusProtocolException | A protocol failure occured. See descendants of BusProtocolException for a more detailed failure list. |
- Note:
- No broadcast supported
|
| synchronized void readInputDiscretes |
( |
int |
slaveAddr, |
|
|
int |
startRef, |
|
|
boolean[] |
bitArr |
|
) |
throws IOException, BusProtocolException [inherited] |
|
|
|
Modbus function 2 (02 hex), Read Inputs Status/Read Input Discretes.
Reads the contents of the discrete inputs (coils, 1:00000 table).
- Parameters:
-
| slaveAddr | Modbus address of slave device or unit identifier (Range: 1 - 247) |
| startRef | Start reference (Range: depends on configuration setting) |
| bitArr | Buffer which will contain the data read |
- Exceptions:
-
| IOException | An I/O error occured |
| IllegalArgumentException | A parameter is out of range |
| BusProtocolException | A protocol failure occured. See descendants of BusProtocolException for a more detailed failure list. |
- Note:
- No broadcast supported
|
| synchronized void readInputRegisters |
( |
int |
slaveAddr, |
|
|
int |
startRef, |
|
|
short[] |
regArr |
|
) |
throws IOException, BusProtocolException [inherited] |
|
|
|
Modbus function 4 (04 hex), Read Input Registers.
Read the contents of the input registers (3:00000 table).
- Parameters:
-
| slaveAddr | Modbus address of slave device or unit identifier (Range: 1 - 247) |
| startRef | Start reference (Range: depends on configuration setting) |
| regArr | Buffer which will be filled with the data read. The length of the array determines how many registers are read (Range: 1-125). |
- Exceptions:
-
| IOException | An I/O error occured |
| IllegalArgumentException | A parameter is out of range |
| BusProtocolException | A protocol failure occured. See descendants of BusProtocolException for a more detailed failure list. |
- Note:
- No broadcast supported
|
| synchronized void readInputRegisters |
( |
int |
slaveAddr, |
|
|
int |
startRef, |
|
|
int[] |
int32Arr |
|
) |
throws IOException, BusProtocolException [inherited] |
|
|
|
Modbus function 4 (04 hex) for 32-bit int data types, Read Input Registers as int data.
Reads the contents of pairs of two consecutive input registers (3:00000 table) into float values.
- Remarks:
- Depending on the 32-bit Mode setting, an int will be transferred as two consecutive 16-bit registers (Standard) or as one 32-bit register (Daniel/Enron).
- Parameters:
-
| slaveAddr | Modbus address of slave device or unit identifier (Range: 1 - 247) |
| startRef | Start reference (Range: depends on configuration setting) |
| int32Arr | Buffer which will be filled with the data read. The length of the array determines how many registers are read (Range: 1-62). |
- Exceptions:
-
| IOException | An I/O error occured |
| IllegalArgumentException | A parameter is out of range |
| BusProtocolException | A protocol failure occured. See descendants of BusProtocolException for a more detailed failure list. |
- Note:
- No broadcast supported
|
| synchronized void readInputRegisters |
( |
int |
slaveAddr, |
|
|
int |
startRef, |
|
|
float[] |
float32Arr |
|
) |
throws IOException, BusProtocolException [inherited] |
|
|
|
Modbus function 4 (04 hex) for 32-bit float data types, Read Input Registers as float data.
Reads the contents of pairs of two consecutive input registers (3:00000 table) into float values.
- Remarks:
- Depending on the 32-bit Mode setting, an int will be transferred as two consecutive 16-bit registers (Standard) or as one 32-bit register (Daniel/Enron).
- Parameters:
-
| slaveAddr | Modbus address of slave device or unit identifier (Range: 1 - 247) |
| startRef | Start reference (Range: depends on configuration setting) |
| float32Arr | Buffer which will be filled with the data read. The length of the array determines how many registers are read (Range: 1-62). |
- Exceptions:
-
| IOException | An I/O error occured |
| IllegalArgumentException | A parameter is out of range |
| BusProtocolException | A protocol failure occured. See descendants of BusProtocolException for a more detailed failure list. |
- Note:
- No broadcast supported
|
| synchronized void writeCoil |
( |
int |
slaveAddr, |
|
|
int |
bitAddr, |
|
|
boolean |
bitVal |
|
) |
throws IOException, BusProtocolException [inherited] |
|
|
|
Modbus function 5 (05 hex), Force Single Coil/Write Coil.
Sets a single discrete output variable (coil, 0:00000 table) to either ON or OFF.
- Parameters:
-
| slaveAddr | Modbus address of slave device or unit identifier (Range: 0 - 247) |
| bitAddr | Coil address (Range: depends on configuration setting) |
| bitVal | true sets, false clears discrete output variable |
- Exceptions:
-
| IllegalStateException | Port or connection is closed |
| IOException | An I/O error occured |
| IllegalArgumentException | A parameter is out of range |
| BusProtocolException | A protocol failure occured. See descendants of BusProtocolException for a more detailed failure list. |
- Note:
- Broadcast supported for serial protocols
|
| synchronized void writeSingleRegister |
( |
int |
slaveAddr, |
|
|
int |
regAddr, |
|
|
short |
regVal |
|
) |
throws IOException, BusProtocolException [inherited] |
|
|
|
Modbus function 6 (06 hex), Preset Single Register/Write Single Register.
Writes a value into a single output register (holding register, 4:00000 reference).
- Parameters:
-
| slaveAddr | Modbus address of slave device or unit identifier (Range: 0 - 247) |
| regAddr | Register address (Range: depends on configuration setting) |
| regVal | Data to be sent |
- Exceptions:
-
| IllegalStateException | Port or connection is closed |
| IOException | An I/O error occured |
| IllegalArgumentException | A parameter is out of range |
| BusProtocolException | A protocol failure occured. See descendants of BusProtocolException for a more detailed failure list. |
- Note:
- Broadcast supported for serial protocols
|
| synchronized byte readExceptionStatus |
( |
int |
slaveAddr |
) |
throws IOException, BusProtocolException [inherited] |
|
|
|
Modbus function 7 (07 hex), Read Exception Status.
Reads the eight exception status coils within the slave device.
- Parameters:
-
| slaveAddr | Modbus address of slave device or unit identifier (Range: 1 - 247) |
- Exceptions:
-
| IllegalStateException | Port or connection is closed |
| IOException | An I/O error occured |
| IllegalArgumentException | A parameter is out of range |
| BusProtocolException | A protocol failure occured. See descendants of BusProtocolException for a more detailed failure list. |
- Note:
- No broadcast supported
|
| synchronized void maskWriteRegister |
( |
int |
slaveAddr, |
|
|
int |
regAddr, |
|
|
short |
andMask, |
|
|
short |
orMask |
|
) |
throws IOException, BusProtocolException [inherited] |
|
|
|
Modbus function 22 (16 hex), Mask Write Register.
Masks bits according to an AND & an OR mask into a single output register (holding register, 4:00000 reference). Masking is done as follows: result = (currentVal AND andMask) OR (orMask AND andMask)
- Parameters:
-
| slaveAddr | Modbus address of slave device or unit identifier (Range: 1 - 247) |
| regAddr | Register address (Range: depends on configuration setting) |
| andMask | Mask to be applied as a logic AND to the register |
| orMask | Mask to be applied as a logic OR to the register |
- Exceptions:
-
| IllegalStateException | Port or connection is closed |
| IOException | An I/O error occured |
| IllegalArgumentException | A parameter is out of range |
| BusProtocolException | A protocol failure occured. See descendants of BusProtocolException for a more detailed failure list. |
- Note:
- No broadcast supported
|
| synchronized void readWriteRegisters |
( |
int |
slaveAddr, |
|
|
int |
readRef, |
|
|
short[] |
readArr, |
|
|
int |
writeRef, |
|
|
short[] |
writeArr |
|
) |
throws IOException, BusProtocolException [inherited] |
|
|
|
Modbus function 23 (17 hex), Read/Write Registers.
Combines reading and writing of the output registers in one transaction (holding registers, 4:00000 table).
- Parameters:
-
| slaveAddr | Modbus address of slave device or unit identifier (Range: 1 - 247) |
| readRef | Start reference for reading (Range: depends on configuration setting) |
| readArr | Buffer which will contain the data read. The length of the array determines how many registers are read (Range: 1-125). |
| writeRef | Start reference for writing (Range: depends on configuration setting) |
| writeArr | Buffer with data to be sent. The length of the array determines how many registers are sent (Range: 1-100). |
- Exceptions:
-
| IllegalStateException | Port or connection is closed |
| IOException | An I/O error occured |
| IllegalArgumentException | A parameter is out of range |
| BusProtocolException | A protocol failure occured. See descendants of BusProtocolException for a more detailed failure list. |
- Note:
- No broadcast supported
|
| int getTimeout |
( |
|
) |
[inherited] |
|
|
|
Returns the operation time-out value.
- Returns:
- Timeout value in ms
|
| synchronized void setPollDelay |
( |
int |
pollDelay |
) |
[inherited] |
|
|
|
Configures poll delay.
This function sets the delay time which applies between two consecutive Modbus read/write. A value of 0 disables the poll delay. - Note:
- A port or connection must be closed in order to configure it.
- Parameters:
-
| pollDelay | Delay time in ms (Range: 0 - 100000), 0 disables poll delay |
- Exceptions:
-
| IllegalStateException | Port is open |
| IllegalArgumentException | Parameter is out of range |
|
| int getPollDelay |
( |
|
) |
[inherited] |
|
|
|
Returns the poll delay time.
- Returns:
- Delay time in ms, 0 if poll delay is switched off
|
| synchronized void setRetryCnt |
( |
int |
retryCnt |
) |
[inherited] |
|
|
|
Configures the automatic retry setting.
A value of 0 disables any automatic retries. - Note:
- A port or connection must be closed in order to configure it.
- Parameters:
-
| retryCnt | Retry count (Range: 0 - 10), 0 disables retries |
- Exceptions:
-
| IllegalStateException | Port is open |
| IllegalArgumentException | Parameter is out of range |
|
| int getRetryCnt |
( |
|
) |
[inherited] |
|
|
|
Returns the automatic retry count.
- Returns:
- Retry count
|
| synchronized long getSuccessCounter |
( |
|
) |
[inherited] |
|
|
|
Returns how often a transmit/receive cycle was successful.
- Returns:
- Counter value
|
| synchronized void configureStandard32BitMode |
( |
int |
slaveAddr |
) |
[inherited] |
|
|
|
Configures a slave for Standard 32-bit Register Mode.
In Standard 32-bit Register Mode a 32-bit value is transmitted as two consecutive 16-bit Modbus registers.
- Parameters:
-
| slaveAddr | Modbus address of slave device or unit identifier (Range: 1 - 247). A value of zero configures the behaviour for broadcasting. |
- Remarks:
- This is the default mode
|
| void configureSingleReg32BitMode |
( |
|
) |
[inherited] |
|
|
|
Configures all slaves for Single Register 32-bit Mode.
Some Modbus flavours like the Daniel/Enron protocol represent a 32-bit value using one 32-bit Modbus register instead of two 16-bit registers. |
| synchronized void configureSingleReg32BitMode |
( |
int |
slaveAddr |
) |
[inherited] |
|
|
|
Configures all slaves for Single Register 32-bit Mode.
Some Modbus flavours like the Daniel/Enron protocol represent a 32-bit value using one 32-bit Modbus register instead of two 16-bit registers.
- Parameters:
-
| slaveAddr | Modbus address of slave device or unit identifier (Range: 1 - 247). A value of zero configures the behaviour for broadcasting. |
|
| void configureCountFromOne |
( |
|
) |
[inherited] |
|
|
|
Configures the reference counting scheme to start with one for all slaves.
This renders the reference range to be 1 to 0x10000 and register #0 is an illegal register.
- Remarks:
- This is the default mode
|
| synchronized void configureCountFromOne |
( |
int |
slaveAddr |
) |
[inherited] |
|
|
|
Configures a slave's reference counting scheme to start with one.
This renders the reference range to be 1 to 0x10000 and register #0 is an illegal register.
- Parameters:
-
| slaveAddr | Modbus address of slave device or unit identifier (Range: 1 - 247). A value of zero configures the behaviour for broadcasting. |
- Remarks:
- This is the default mode
|
| void configureCountFromZero |
( |
|
) |
[inherited] |
|
|
|
Configures the reference counting scheme to start with zero for all slaves.
This renders the valid reference range to be 0 to 0xFFFF.
This renders the first register to be #0 for all slaves. |
| synchronized void configureCountFromZero |
( |
int |
slaveAddr |
) |
[inherited] |
|
|
|
Configures a slave's reference counting scheme to start with zero.
This renders the valid reference range to be 0 to 0xFFFF.
- Parameters:
-
| slaveAddr | Modbus address of slave device or unit identifier (Range: 1 - 247). A value of zero configures the behaviour for broadcasting. |
|
| void configureLittleEndianInts |
( |
|
) |
[inherited] |
|
|
|
Disables word swapping for int data type functions for all slaves.
Modbus is using little-endian word order for 32-bit values. This setting assumes that the slave also serves 32-bit data in in little little-endian word order.
- Remarks:
- This is the default mode
|
| synchronized void configureLittleEndianInts |
( |
int |
slaveAddr |
) |
[inherited] |
|
|
|
Disables word swapping for int data type functions on a per slave basis.
Modbus is using little-endian word order for 32-bit values. This setting assumes that the slave also serves 32-bit data in little little-endian word order.
- Remarks:
- This is the default mode
- Parameters:
-
| slaveAddr | Modbus address of slave device or unit identifier (Range: 1 - 247). A value of zero configures the behaviour for broadcasting. |
|
| void configureBigEndianInts |
( |
|
) |
[inherited] |
|
|
|
Configures int data type functions to do a word swap for all slaves.
Modbus is using little-endian word order for 32-bit values. The data transfer functions operating upon 32-bit int data types can be configured to do a word swap which enables them to read 32-bit data correctly from a big-endian machine. |
| synchronized void configureBigEndianInts |
( |
int |
slaveAddr |
) |
[inherited] |
|
|
|
Enables int data type functions to do a word swap on a per slave basis.
Modbus is using little-endian word order for 32-bit values. The data transfer functions operating upon 32-bit int data types can be configured to do a word swap which enables them to read 32-bit data correctly from a big-endian machine.
- Parameters:
-
| slaveAddr | Modbus address of slave device or unit identifier (Range: 1 - 247). A value of zero configures the behaviour for broadcasting. |
|
| void configureLittleEndianFloats |
( |
|
) |
[inherited] |
|
|
|
Disables float data type functions to do a word swap for all slaves.
Modbus is using little-endian word order for 32-bit values. This setting assumes that the slaves also serves 32-bit floats in little little-endian word order which is the most common case.
- Remarks:
- This is the default mode
|
| synchronized void configureLittleEndianFloats |
( |
int |
slaveAddr |
) |
[inherited] |
|
|
|
Disables float data type functions to do a word swap on a per slave basis.
Modbus is using little-endian word order for 32-bit values. This setting assumes that the slave also serves 32-bit floats in little little-endian word order which is the most common case.
- Remarks:
- This is the default mode
- Parameters:
-
| slaveAddr | Modbus address of slave device or unit identifier (Range: 1 - 247). A value of zero configures the behaviour for broadcasting. |
|
| void configureSwappedFloats |
( |
|
) |
[inherited] |
|
|
|
Configures float data type functions to do a word swap for all slaves.
The data functions operating upon 32-bit float data types can be configured to do a word swap. - Note:
- Most platforms store floats in IEEE 754 little-endian order which does not need a word swap.
|
| synchronized void configureSwappedFloats |
( |
int |
slaveAddr |
) |
[inherited] |
|
|
|
Enables float data type functions to do a word swap on a per slave basis.
The data functions operating upon 32-bit float data types can be configured to do a word swap. - Note:
- Most platforms store floats in IEEE 754 little-endian order which does not need a word swap.
- Parameters:
-
| slaveAddr | Modbus address of slave device or unit identifier (Range: 1 - 247). A value of zero configures the behaviour for broadcasting. |
|
|
 |