FieldTalk Modbus® Master Protocol Library C++ Editions |
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. This rich function set enables a user to solve nearly every Modbus data transfer problem.
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 |
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.
Class 0 Modbus Functions | |
int | MbusMasterFunctions::writeMultipleRegisters (int slaveAddr, int startRef, const short regArr[], int refCnt) |
Modbus function 16 (10 hex), Preset Multiple Registers/Write Multiple Registers. | |
int | MbusMasterFunctions::writeMultipleLongInts (int slaveAddr, int startRef, const long int32Arr[], int refCnt) |
Modbus function 16 (10 hex) for 32-bit long int data types, Preset Multiple Registers/Write Multiple Registers with long int data. | |
int | MbusMasterFunctions::writeMultipleMod10000 (int slaveAddr, int startRef, const long int32Arr[], int refCnt) |
Modbus function 16 (10 hex) for 32-bit modulo-10000 long int data types, Preset Multiple Registers/Write Multiple Registers with modulo-10000 long int data. | |
int | MbusMasterFunctions::writeMultipleFloats (int slaveAddr, int startRef, const float float32Arr[], int refCnt) |
Modbus function 16 (10 hex) for 32-bit float data types, Preset Multiple Registers/Write Multiple Registers with float data. | |
int | MbusMasterFunctions::readMultipleRegisters (int slaveAddr, int startRef, short regArr[], int refCnt) |
Modbus function 3 (03 hex), Read Holding Registers/Read Multiple Registers. | |
int | MbusMasterFunctions::readMultipleLongInts (int slaveAddr, int startRef, long int32Arr[], int refCnt) |
Modbus function 3 (03 hex) for 32-bit long int data types, Read Holding Registers/Read Multiple Registers as long int data. | |
int | MbusMasterFunctions::readMultipleMod10000 (int slaveAddr, int startRef, long int32Arr[], int refCnt) |
Modbus function 3 (03 hex) for 32-bit modulo-10000 long int data types, Read Holding Registers/Read Multiple Registers as modulo-10000 long int data. | |
int | MbusMasterFunctions::readMultipleFloats (int slaveAddr, int startRef, float float32Arr[], int refCnt) |
Modbus function 3 (03 hex) for 32-bit float data types, Read Holding Registers/Read Multiple Registers as float data. | |
Class 1 Modbus Functions | |
int | MbusMasterFunctions::readCoils (int slaveAddr, int startRef, int bitArr[], int refCnt) |
Modbus function 1 (01 hex), Read Coil Status/Read Coils. | |
int | MbusMasterFunctions::readInputDiscretes (int slaveAddr, int startRef, int bitArr[], int refCnt) |
Modbus function 2 (02 hex), Read Inputs Status/Read Input Discretes. | |
int | MbusMasterFunctions::readInputRegisters (int slaveAddr, int startRef, short regArr[], int refCnt) |
Modbus function 4 (04 hex), Read Input Registers. | |
int | MbusMasterFunctions::readInputLongInts (int slaveAddr, int startRef, long int32Arr[], int refCnt) |
Modbus function 4 (04 hex) for 32-bit long int data types, Read Input Registers as long int data. | |
int | MbusMasterFunctions::readInputMod10000 (int slaveAddr, int startRef, long int32Arr[], int refCnt) |
Modbus function 4 (04 hex) for 32-bit modulo-10000 long int data types, Read Input Registers as modulo-10000 long int data. | |
int | MbusMasterFunctions::readInputFloats (int slaveAddr, int startRef, float float32Arr[], int refCnt) |
Modbus function 4 (04 hex) for 32-bit float data types, Read Input Registers as float data. | |
int | MbusMasterFunctions::writeCoil (int slaveAddr, int bitAddr, int bitVal) |
Modbus function 5 (05 hex), Force Single Coil/Write Coil. | |
int | MbusMasterFunctions::writeSingleRegister (int slaveAddr, int regAddr, short regVal) |
Modbus function 6 (06 hex), Preset Single Register/Write Single Register. | |
int | MbusMasterFunctions::readExceptionStatus (int slaveAddr, unsigned char *statusByte) |
Modbus function 7 (07 hex), Read Exception Status. | |
Class 2 Modbus Functions | |
int | MbusMasterFunctions::forceMultipleCoils (int slaveAddr, int startRef, const int bitArr[], int refCnt) |
Modbus function 15 (0F hex), Force Multiple Coils. | |
int | MbusMasterFunctions::maskWriteRegister (int slaveAddr, int regAddr, unsigned short andMask, unsigned short orMask) |
Modbus function 22 (16 hex), Mask Write Register. | |
int | MbusMasterFunctions::readWriteRegisters (int slaveAddr, int readRef, short readArr[], int readCnt, int writeRef, const short writeArr[], int writeCnt) |
Modbus function 23 (17 hex), Read/Write Registers. | |
Protocol Configuration | |
int | MbusMasterFunctions::setTimeout (int timeOut) |
Configures time-out. | |
int | MbusMasterFunctions::getTimeout () |
Returns the time-out value. | |
int | MbusMasterFunctions::setPollDelay (int pollDelay) |
Configures poll delay. | |
int | MbusMasterFunctions::getPollDelay () |
Returns the poll delay time. | |
int | MbusMasterFunctions::setRetryCnt (int retryCnt) |
Configures the automatic retry setting. | |
int | MbusMasterFunctions::getRetryCnt () |
Returns the automatic retry count. | |
Transmission Statistic Functions | |
unsigned long | MbusMasterFunctions::getTotalCounter () |
Returns how often a message transfer has been executed. | |
void | MbusMasterFunctions::resetTotalCounter () |
Resets total message transfer counter. | |
unsigned long | MbusMasterFunctions::getSuccessCounter () |
Returns how often a message transfer was successful. | |
void | MbusMasterFunctions::resetSuccessCounter () |
Resets successful message transfer counter. | |
Word Order Configuration | |
void | MbusMasterFunctions::configureBigEndianInts () |
Configures int data type functions to do a word swap. | |
void | MbusMasterFunctions::configureSwappedFloats () |
Configures float data type functions to do a word swap. | |
void | MbusMasterFunctions::configureLittleEndianInts () |
Configures int data type functions not to do a word swap. | |
void | MbusMasterFunctions::configureIeeeFloats () |
Configures float data type functions not to do a word swap. | |
Functions | |
char * | MbusMasterFunctions::getPackageVersion () |
Returns the package version number. |
|
Modbus function 16 (10 hex), Preset Multiple Registers/Write Multiple Registers. Writes values into a sequence of output registers (holding registers, 4:00000 table).
|
|
Modbus function 1 (01 hex), Read Coil Status/Read Coils. Reads the contents of the discrete outputs (coils, 0:00000 table).
|
|
Modbus function 15 (0F hex), Force Multiple Coils. Writes binary values into a sequence of discrete outputs (coils, 0:00000 table).
|
|
Configures time-out. This function sets the operation or socket time-out to the specified value.
|
|
Returns how often a message transfer has been executed.
|
|
Configures int data type functions to do a word swap. 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 slave. |
|
Returns the package version number.
|
|
Modbus function 16 (10 hex) for 32-bit long int data types, Preset Multiple Registers/Write Multiple Registers with long int data. Writes long int values into pairs of output registers (holding registers, 4:00000 table).
|
|
Modbus function 16 (10 hex) for 32-bit modulo-10000 long int data types, Preset Multiple Registers/Write Multiple Registers with modulo-10000 long int data. Writes long int values into pairs of output registers (holding registers, 4:00000 table) representing a modulo-10000 long int value and performs number format conversion.
|
|
Modbus function 16 (10 hex) for 32-bit float data types, Preset Multiple Registers/Write Multiple Registers with float data. Writes float values into pairs of output registers (holding registers, 4:00000 table).
|
|
Modbus function 3 (03 hex), Read Holding Registers/Read Multiple Registers. Reads the contents of the output registers (holding registers, 4:00000 table).
|
|
Modbus function 3 (03 hex) for 32-bit long int data types, Read Holding Registers/Read Multiple Registers as long int data. Reads the contents of pairs of consecutive output registers (holding registers, 4:00000 table) into 32-bit long int values.
|
|
Modbus function 3 (03 hex) for 32-bit modulo-10000 long int data types, Read Holding Registers/Read Multiple Registers as modulo-10000 long int data. Reads the contents of pairs of consecutive output registers (holding registers, 4:00000 table) representing a modulo-10000 long int value into 32-bit int values and performs number format conversion.
|
|
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 consecutive output registers (holding registers, 4:00000 table) into float values.
|
|
Modbus function 2 (02 hex), Read Inputs Status/Read Input Discretes. Reads the contents of the discrete inputs (input status, 1:00000 table).
|
|
Modbus function 4 (04 hex), Read Input Registers. Read the contents of the input registers (3:00000 table).
|
|
Modbus function 4 (04 hex) for 32-bit long int data types, Read Input Registers as long int data. Reads the contents of pairs of consecutive input registers (3:00000 table) into 32-bit long int values.
|
|
Modbus function 4 (04 hex) for 32-bit modulo-10000 long int data types, Read Input Registers as modulo-10000 long int data. Reads the contents of pairs of consecutive input registers (3:00000 table) representing a modulo-10000 long int value into 32-bit long int values and performs number format conversion.
|
|
Modbus function 4 (04 hex) for 32-bit float data types, Read Input Registers as float data. Reads the contents of pairs of consecutive input registers (3:00000 table) into float values.
|
|
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.
|
|
Modbus function 6 (06 hex), Preset Single Register/Write Single Register. Writes a value into a single output register (holding register, 4:00000 reference).
|
|
Modbus function 7 (07 hex), Read Exception Status. Reads the eight exception status coils within the slave device.
|
|
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)
|
|
Modbus function 23 (17 hex), Read/Write Registers. Combines reading and writing of the output registers in one transaction (holding registers, 4:00000 table).
|
|
Returns the time-out value.
|
|
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.
|
|
Returns the poll delay time.
|
|
Configures the automatic retry setting. A value of 0 disables any automatic retries.
|
|
Returns the automatic retry count.
|
|
Returns how often a message transfer was successful.
|
|
Configures float data type functions to do a word swap. The data functions operating upon 32-bit float data types can be configured to do a word swap.
|
|
Configures int data type functions not to do a word swap. This is the default. |
|
Configures float data type functions not to do a word swap. This is the default. |
Copyright © 2002-2004
FOCUS Software Engineering Pty Ltd, Australia.
All rights reserved.
Please see the Notices page for trademark notices. Last updated: 26 May 2004 |