FieldTalk Modbus Master C++ Library
Library version 2.13.2
|
Base class which implements Modbus data and control functions. More...
Classes | |
struct | FileSubRequest |
File subrequest structure. More... | |
Public Member Functions | |
virtual | ~MbusMasterFunctions () |
Destructor. More... | |
virtual int | isOpen ()=0 |
virtual void | closeProtocol ()=0 |
Closes an open protocol including any associated communication resources (com ports or sockets). | |
Protected Member Functions | |
MbusMasterFunctions () | |
Constructs a MbusMasterFunctions object and initialises its data. More... | |
Bit Access | |
int | readCoils (int slaveAddr, int startRef, int bitArr[], int refCnt) |
Modbus function 1, Read Coil Status/Read Coils. More... | |
int | readInputDiscretes (int slaveAddr, int startRef, int bitArr[], int refCnt) |
Modbus function 2, Read Inputs Status/Read Input Discretes. More... | |
int | writeCoil (int slaveAddr, int bitAddr, int bitVal) |
Modbus function 5, Force Single Coil/Write Coil. More... | |
int | forceMultipleCoils (int slaveAddr, int startRef, const int bitArr[], int refCnt) |
Modbus function 15 (0F Hex), Force Multiple Coils. More... | |
16-bit Access | |
Table 4:00000 (Holding Registers) and Table 3:00000 (Input Registers) | |
int | readMultipleRegisters (int slaveAddr, int startRef, short regArr[], int refCnt) |
Modbus function 3, Read Holding Registers/Read Multiple Registers. More... | |
int | readInputRegisters (int slaveAddr, int startRef, short regArr[], int refCnt) |
Modbus function 4, Read Input Registers. More... | |
int | writeSingleRegister (int slaveAddr, int regAddr, short regVal) |
Modbus function 6, Preset Single Register/Write Single Register. More... | |
int | writeMultipleRegisters (int slaveAddr, int startRef, const short regArr[], int refCnt) |
Modbus function 16 (10 Hex), Preset Multiple Registers/Write Multiple Registers. More... | |
int | maskWriteRegister (int slaveAddr, int regAddr, short andMask, short orMask) |
Modbus function 22 (16 Hex), Mask Write Register. More... | |
int | readWriteRegisters (int slaveAddr, int readRef, short readArr[], int readCnt, int writeRef, const short writeArr[], int writeCnt) |
Modbus function 23 (17 Hex), Read/Write Registers. More... | |
32-bit Access | |
Table 4:00000 (Holding Registers) and Table 3:00000 (Input Registers) | |
int | readMultipleLongInts (int slaveAddr, int startRef, int int32Arr[], int refCnt) |
Modbus function 3 for 32-bit long int data types, Read Holding Registers/Read Multiple Registers as long int data. More... | |
int | readInputLongInts (int slaveAddr, int startRef, int int32Arr[], int refCnt) |
Modbus function 4 for 32-bit long int data types, Read Input Registers as long int data. More... | |
int | writeMultipleLongInts (int slaveAddr, int startRef, const int 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. More... | |
int | readMultipleFloats (int slaveAddr, int startRef, float float32Arr[], int refCnt) |
Modbus function 3 for 32-bit float data types, Read Holding Registers/Read Multiple Registers as float data. More... | |
int | readInputFloats (int slaveAddr, int startRef, float float32Arr[], int refCnt) |
Modbus function 4 for 32-bit float data types, Read Input Registers as float data. More... | |
int | 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. More... | |
int | readMultipleMod10000 (int slaveAddr, int startRef, int int32Arr[], int refCnt) |
Modbus function 3 for 32-bit modulo-10000 long int data types, Read Holding Registers/Read Multiple Registers as modulo-10000 long int data. More... | |
int | readInputMod10000 (int slaveAddr, int startRef, int int32Arr[], int refCnt) |
Modbus function 4 for 32-bit modulo-10000 long int data types, Read Input Registers as modulo-10000 long int data. More... | |
int | writeMultipleMod10000 (int slaveAddr, int startRef, const int 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. More... | |
64-bit Access | |
Table 4:00000 (Holding Registers) and Table 3:00000 (Input Registers) | |
int | readHoldingRegistersI64 (int slaveAddr, int startRef, int64_t int64Arr[], int refCnt) |
Modbus function 3 for 64-bit integer data, Read Holding Registers as int64_t type. More... | |
int | readInputRegistersI64 (int slaveAddr, int startRef, int64_t int64Arr[], int refCnt) |
Modbus function 4 for 64-bit integer data, Read Holding Registers as int64_t type. More... | |
int | writeMultipleRegistersI64 (int slaveAddr, int startRef, const int64_t int64Arr[], int refCnt) |
Modbus function 16 (10 Hex) for 64-bit integer data, Write Multiple Registers as int64_t type. More... | |
int | readHoldingRegistersF64 (int slaveAddr, int startRef, double double64Arr[], int refCnt) |
Modbus function 3 for 64-bit floating point data, Read Input Registers as double type. More... | |
int | readInputRegistersF64 (int slaveAddr, int startRef, double double64Arr[], int refCnt) |
Modbus function 4 for 64-bit floating point data, Read Input Registers as double type. More... | |
int | writeMultipleRegistersF64 (int slaveAddr, int startRef, const double double64Arr[], int refCnt) |
Modbus function 16 (10 Hex) for 64-bit floating point data, Write Multiple Registers as double type. More... | |
File Record Access | |
int | readFileRecord (int slaveAddr, int refType, int fileNo, int recordNo, short recordArr[], int recordCnt) |
Modbus function 20, Read File Record. More... | |
int | readFileRecord (int slaveAddr, FileSubRequest subReqArr[], int subReqCnt) |
Modbus function 20, Read File Record. More... | |
int | writeFileRecord (int slaveAddr, int refType, int fileNo, int recordNo, const short recordArr[], int recordCnt) |
Modbus function 21, Write File Record. More... | |
int | writeFileRecord (int slaveAddr, const FileSubRequest subReqArr[], int subReqCnt) |
Modbus function 21, Write File Record. More... | |
Diagnostics | |
int | readExceptionStatus (int slaveAddr, unsigned char *statusBytePtr) |
Modbus function 7, Read Exception Status. More... | |
int | returnQueryData (int slaveAddr, const unsigned char queryArr[], unsigned char echoArr[], int len) |
Modbus function code 8, sub-function 00, Return Query Data. More... | |
int | restartCommunicationsOption (int slaveAddr, int clearEventLog) |
Modbus function code 8, sub-function 01, Restart Communications Option. More... | |
int | readDeviceIdentification (int slaveAddr, int accessType, int objId, DeviceIdObjectList *objListPtr) |
Modbus function 43 (hex 2B) subfunction 14 (hex 0E), Read Device Identification. More... | |
Custom Function Codes | |
int | customFunction (int slaveAddr, int functionCode, void *requestData, size_t requestLen, void *responseData, size_t *responseLenPtr) |
User Defined Function CodeThis method can be used to implement User Defined Function Codes. More... | |
Protocol Configuration | |
int | setTimeout (int timeOut) |
Configures time-out. More... | |
int | getTimeout () |
Returns the time-out value. More... | |
int | setPollDelay (int pollDelay) |
Configures poll delay. More... | |
int | getPollDelay () |
Returns the poll delay time. More... | |
int | setRetryCnt (int retryCnt) |
Configures the automatic retry setting. More... | |
int | getRetryCnt () |
Returns the automatic retry count. More... | |
Transmission Statistic Functions | |
long | getTotalCounter () |
Returns how often a message transfer has been executed. More... | |
void | resetTotalCounter () |
Resets total message transfer counter. | |
long | getSuccessCounter () |
Returns how often a message transfer was successful. More... | |
void | resetSuccessCounter () |
Resets successful message transfer counter. | |
Slave Configuration | |
void | configureBigEndianInts () |
Configures 32-bit int data type functions to do a word swap. More... | |
void | configureLittleEndianInts () |
Configures 32-bit int data type functions not to do a word swap. More... | |
void | configureIeeeFloats () |
Configures float data type functions not to do a word swap. More... | |
void | configureSwappedFloats () |
Configures float data type functions to do a word swap. More... | |
void | configureStandard32BitMode () |
Configures all slaves for Standard 32-bit Mode. More... | |
void | configureEnron32BitMode () |
Configures all slaves for Daniel/ENRON 32-bit Mode. More... | |
void | configureCountFromOne () |
Configures the reference counting scheme to start with one for all slaves. More... | |
void | configureCountFromZero () |
Configures the reference counting scheme to start with zero for all slaves. More... | |
int | configureBigEndianInts (int slaveAddr) |
Enables int data type functions to do a word swap on a per slave basis. More... | |
int | configureLittleEndianInts (int slaveAddr) |
Disables word swapping for int data type functions on a per slave basis. More... | |
int | configureIeeeFloats (int slaveAddr) |
Disables float data type functions to do a word swap on a per slave basis. More... | |
int | configureSwappedFloats (int slaveAddr) |
Enables float data type functions to do a word swap on a per slave basis. More... | |
int | configureStandard32BitMode (int slaveAddr) |
Configures a slave for Standard 32-bit Register Mode. More... | |
int | configureEnron32BitMode (int slaveAddr) |
Configures all slaves for Daniel/ENRON 32-bit Mode. More... | |
int | configureCountFromOne (int slaveAddr) |
Configures a slave's reference counting scheme to start with one. More... | |
int | configureCountFromZero (int slaveAddr) |
Configures a slave's reference counting scheme to start with zero. More... | |
Utility Functions | |
static const TCHAR * | getPackageVersion () |
Returns the library version number. More... | |
Base class which implements Modbus data and control functions.
The functions provided by this base class apply to all protocol flavours via inheritance. For a more detailed description see section Data and Control Functions for all Modbus Protocol Flavours.
|
protected |
Constructs a MbusMasterFunctions object and initialises its data.
It also detects the endianess of the machine it's running on and configures byte swapping if necessary.
|
virtual |
Destructor.
Does clean-up and closes an open protocol including any associated communication resources (serial ports or sockets).
int readCoils | ( | int | slaveAddr, |
int | startRef, | ||
int | bitArr[], | ||
int | refCnt | ||
) |
Modbus function 1, Read Coil Status/Read Coils.
Reads the contents of the discrete outputs (coils, 0:00000 table).
slaveAddr | Modbus address of slave device or unit identifier (Range: 1 - 255) |
startRef | Start reference (Range: 1 - 65536) |
bitArr | Buffer which will contain the data read |
refCnt | Number of coils to be read (Range: 1-2000) |
int readInputDiscretes | ( | int | slaveAddr, |
int | startRef, | ||
int | bitArr[], | ||
int | refCnt | ||
) |
Modbus function 2, Read Inputs Status/Read Input Discretes.
Reads the contents of the discrete inputs (input status, 1:00000 table).
slaveAddr | Modbus address of slave device or unit identifier (Range: 1 - 255) |
startRef | Start reference (Range: 1 - 65536) |
bitArr | Buffer which will contain the data read |
refCnt | Number of coils to be read (Range: 1-2000) |
int writeCoil | ( | int | slaveAddr, |
int | bitAddr, | ||
int | bitVal | ||
) |
Modbus function 5, Force Single Coil/Write Coil.
Sets a single discrete output variable (coil, 0:00000 table) to either ON or OFF.
slaveAddr | Modbus address of slave device or unit identifier (Range: 0 - 255) |
bitAddr | Coil address (Range: 1 - 65536) |
bitVal | true sets, false clears discrete output variable |
References FTALK_ILLEGAL_ARGUMENT_ERROR, FTALK_INVALID_REPLY_ERROR, and FTALK_SUCCESS.
int forceMultipleCoils | ( | int | slaveAddr, |
int | startRef, | ||
const int | bitArr[], | ||
int | refCnt | ||
) |
Modbus function 15 (0F Hex), Force Multiple Coils.
Writes binary values into a sequence of discrete outputs (coils, 0:00000 table).
slaveAddr | Modbus address of slave device or unit identifier (Range: 0 - 255) |
startRef | Start reference (Range: 1 - 65536) |
bitArr | Buffer which contains the data to be sent |
refCnt | Number of coils to be written (Range: 1-1968) |
References FTALK_ILLEGAL_ARGUMENT_ERROR, FTALK_INVALID_REPLY_ERROR, and FTALK_SUCCESS.
int readMultipleRegisters | ( | int | slaveAddr, |
int | startRef, | ||
short | regArr[], | ||
int | refCnt | ||
) |
Modbus function 3, Read Holding Registers/Read Multiple Registers.
Reads the contents of the output registers (holding registers, 4:00000 table).
slaveAddr | Modbus address of slave device or unit identifier (Range: 1 - 255) |
startRef | Start register (Range: 1 - 65536) |
regArr | Buffer which will be filled with the data read |
refCnt | Number of registers to be read (Range: 1-125) |
int readInputRegisters | ( | int | slaveAddr, |
int | startRef, | ||
short | regArr[], | ||
int | refCnt | ||
) |
Modbus function 4, Read Input Registers.
Read the contents of the input registers (3:00000 table).
slaveAddr | Modbus address of slave device or unit identifier (Range: 1 - 255) |
startRef | Start register (Range: 1 - 65536) |
regArr | Buffer which will be filled with the data read. |
refCnt | Number of registers to be read (Range: 1-125) |
int writeSingleRegister | ( | int | slaveAddr, |
int | regAddr, | ||
short | regVal | ||
) |
Modbus function 6, Preset Single Register/Write Single Register.
Writes a value into a single output register (holding register, 4:00000 reference).
slaveAddr | Modbus address of slave device or unit identifier (Range: 0 - 255) |
regAddr | Register address (Range: 1 - 65536) |
regVal | Data to be sent |
References FTALK_ILLEGAL_ARGUMENT_ERROR, FTALK_INVALID_REPLY_ERROR, and FTALK_SUCCESS.
int writeMultipleRegisters | ( | int | slaveAddr, |
int | startRef, | ||
const short | regArr[], | ||
int | refCnt | ||
) |
Modbus function 16 (10 Hex), Preset Multiple Registers/Write Multiple Registers.
Writes values into a sequence of output registers (holding registers, 4:00000 table).
slaveAddr | Modbus address of slave device or unit identifier (Range: 0 - 255) |
startRef | Start register (Range: 1 - 65536) |
regArr | Buffer with the data to be sent. |
refCnt | Number of registers to be written (Range: 1-123) |
int maskWriteRegister | ( | int | slaveAddr, |
int | regAddr, | ||
short | andMask, | ||
short | orMask | ||
) |
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 (NOT andMask))
slaveAddr | Modbus address of slave device or unit identifier (Range: 1 - 255 for serial, 0 - 255 for TCP) |
regAddr | Register address (Range: 1 - 65536) |
andMask | Mask to be applied as a logic AND to the register |
orMask | Mask to be applied as a logic OR to the register |
References FTALK_ILLEGAL_ARGUMENT_ERROR, FTALK_INVALID_REPLY_ERROR, and FTALK_SUCCESS.
int readWriteRegisters | ( | int | slaveAddr, |
int | readRef, | ||
short | readArr[], | ||
int | readCnt, | ||
int | writeRef, | ||
const short | writeArr[], | ||
int | writeCnt | ||
) |
Modbus function 23 (17 Hex), Read/Write Registers.
Combines reading and writing of the output registers in one transaction (holding registers, 4:00000 table).
slaveAddr | Modbus address of slave device or unit identifier (Range: 1 - 255 for serial, 0 - 255 for TCP) |
readRef | Start register for reading (Range: 1 - 65536) |
readArr | Buffer which will contain the data read |
readCnt | Number of registers to be read (Range: 1-125) |
writeRef | Start register for writing (Range: 1 - 65536) |
writeArr | Buffer with data to be sent |
writeCnt | Number of registers to be written (Range: 1-121) |
References FTALK_ILLEGAL_ARGUMENT_ERROR, FTALK_INVALID_REPLY_ERROR, and FTALK_SUCCESS.
int readMultipleLongInts | ( | int | slaveAddr, |
int | startRef, | ||
int | int32Arr[], | ||
int | refCnt | ||
) |
Modbus function 3 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.
slaveAddr | Modbus address of slave device or unit identifier (Range: 1 - 255) |
startRef | Start reference (Range: 1 - 65536) |
int32Arr | Buffer which will be filled with the data read |
refCnt | Number of values to be read (Range: 1-62) |
int readInputLongInts | ( | int | slaveAddr, |
int | startRef, | ||
int | int32Arr[], | ||
int | refCnt | ||
) |
Modbus function 4 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.
slaveAddr | Modbus address of slave device or unit identifier (Range: 1 - 255) |
startRef | Start reference (Range: 1 - 65536) |
int32Arr | Buffer which will be filled with the data read |
refCnt | Number of values to be read (Range: 1-62) |
int writeMultipleLongInts | ( | int | slaveAddr, |
int | startRef, | ||
const int | 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.
Writes long int values into pairs of output registers (holding registers, 4:00000 table).
slaveAddr | Modbus address of slave device or unit identifier (Range: 0 - 255) |
startRef | Start reference (Range: 1 - 65536) |
int32Arr | Buffer with the data to be sent |
refCnt | Number of values to be sent (Range: 1-61) |
References FTALK_ILLEGAL_ARGUMENT_ERROR.
int readMultipleFloats | ( | int | slaveAddr, |
int | startRef, | ||
float | float32Arr[], | ||
int | refCnt | ||
) |
Modbus function 3 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.
slaveAddr | Modbus address of slave device or unit identifier (Range: 1 - 255) |
startRef | Start reference (Range: 1 - 65536) |
float32Arr | Buffer which will be filled with the data read |
refCnt | Number of values to be read (Range: 1-62) |
int readInputFloats | ( | int | slaveAddr, |
int | startRef, | ||
float | float32Arr[], | ||
int | refCnt | ||
) |
Modbus function 4 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.
slaveAddr | Modbus address of slave device or unit identifier (Range: 1 - 255) |
startRef | Start reference (Range: 1 - 65536) |
float32Arr | Buffer which will be filled with the data read |
refCnt | Number of values to be read (Range: 1-62) |
int 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.
Writes float values into pairs of output registers (holding registers, 4:00000 table).
slaveAddr | Modbus address of slave device or unit identifier (Range: 0 - 255) |
startRef | Start reference (Range: 1 - 65536) |
float32Arr | Buffer with the data to be sent |
refCnt | Number of values to be sent (Range: 1-61) |
References FTALK_ILLEGAL_ARGUMENT_ERROR.
int readMultipleMod10000 | ( | int | slaveAddr, |
int | startRef, | ||
int | int32Arr[], | ||
int | refCnt | ||
) |
Modbus function 3 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.
slaveAddr | Modbus address of slave device or unit identifier (Range: 1 - 255) |
startRef | Start reference (Range: 1 - 65536) |
int32Arr | Buffer which will be filled with the data read |
refCnt | Number of M10K integers to be read (Range: 1-62) |
int readInputMod10000 | ( | int | slaveAddr, |
int | startRef, | ||
int | int32Arr[], | ||
int | refCnt | ||
) |
Modbus function 4 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.
slaveAddr | Modbus address of slave device or unit identifier (Range: 1 - 255) |
startRef | Start reference (Range: 1 - 65536) |
int32Arr | Buffer which will be filled with the data read |
refCnt | Number of M10K integers to be read (Range: 1-62) |
int writeMultipleMod10000 | ( | int | slaveAddr, |
int | startRef, | ||
const int | 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.
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.
slaveAddr | Modbus address of slave device or unit identifier (Range: 0 - 255) |
startRef | Start reference (Range: 1 - 65536) |
int32Arr | Buffer with the data to be sent |
refCnt | Number of values values to be sent (Range: 1-61) |
References FTALK_ILLEGAL_ARGUMENT_ERROR.
int readHoldingRegistersI64 | ( | int | slaveAddr, |
int | startRef, | ||
int64_t | int64Arr[], | ||
int | refCnt | ||
) |
Modbus function 3 for 64-bit integer data, Read Holding Registers as int64_t type.
Reads the contents of quartets of consecutive holding registers (4:00000 table) into 64-bit integer values.
slaveAddr | Modbus address of slave device or unit identifier (Range: 1 - 255) |
startRef | Start reference (Range: 1 - 65536) |
int64Arr | Buffer which will be filled with the data read |
refCnt | Number of values to be read (Range: 1-31) |
int readInputRegistersI64 | ( | int | slaveAddr, |
int | startRef, | ||
int64_t | int64Arr[], | ||
int | refCnt | ||
) |
Modbus function 4 for 64-bit integer data, Read Holding Registers as int64_t type.
Reads the contents of quartets of consecutive input registers (3:00000 table) into 64-bit integer values.
slaveAddr | Modbus address of slave device or unit identifier (Range: 1 - 255) |
startRef | Start reference (Range: 1 - 65536) |
int64Arr | Buffer which will be filled with the data read |
refCnt | Number of values to be read (Range: 1-31) |
int writeMultipleRegistersI64 | ( | int | slaveAddr, |
int | startRef, | ||
const int64_t | int64Arr[], | ||
int | refCnt | ||
) |
Modbus function 16 (10 Hex) for 64-bit integer data, Write Multiple Registers as int64_t type.
Writes for 64-bit integer values into quartets of holding registers (4:00000 table).
slaveAddr | Modbus address of slave device or unit identifier (Range: 0 - 255) |
startRef | Start reference (Range: 1 - 65536) |
int64Arr | Buffer with the data to be sent |
refCnt | Number of values to be sent (Range: 1-30) |
References FTALK_ILLEGAL_ARGUMENT_ERROR.
int readHoldingRegistersF64 | ( | int | slaveAddr, |
int | startRef, | ||
double | double64Arr[], | ||
int | refCnt | ||
) |
Modbus function 3 for 64-bit floating point data, Read Input Registers as double type.
Reads the contents of quartets of consecutive input registers (4:00000 table) into 64-bit floating point values.
slaveAddr | Modbus address of slave device or unit identifier (Range: 1 - 255) |
startRef | Start reference (Range: 1 - 65536) |
double64Arr | Buffer which will be filled with the data read |
refCnt | Number of values to be read (Range: 1-31) |
int readInputRegistersF64 | ( | int | slaveAddr, |
int | startRef, | ||
double | double64Arr[], | ||
int | refCnt | ||
) |
Modbus function 4 for 64-bit floating point data, Read Input Registers as double type.
Reads the contents of quartets of consecutive input registers (3:00000 table) into 64-bit floating point values.
slaveAddr | Modbus address of slave device or unit identifier (Range: 1 - 255) |
startRef | Start reference (Range: 1 - 65536) |
double64Arr | Buffer which will be filled with the data read |
refCnt | Number of values to be read (Range: 1-31) |
int writeMultipleRegistersF64 | ( | int | slaveAddr, |
int | startRef, | ||
const double | double64Arr[], | ||
int | refCnt | ||
) |
Modbus function 16 (10 Hex) for 64-bit floating point data, Write Multiple Registers as double type.
Writes for 64-bit floating point values into quartets of holding registers (4:00000 table).
slaveAddr | Modbus address of slave device or unit identifier (Range: 0 - 255) |
startRef | Start reference (Range: 1 - 65536) |
double64Arr | Buffer with the data to be sent |
refCnt | Number of values to be sent (Range: 1-30) |
References FTALK_ILLEGAL_ARGUMENT_ERROR.
int readFileRecord | ( | int | slaveAddr, |
int | refType, | ||
int | fileNo, | ||
int | recordNo, | ||
short | recordArr[], | ||
int | recordCnt | ||
) |
Modbus function 20, Read File Record.
Performs a file record read for a single subrequest.
slaveAddr | Modbus address of slave device or unit identifier (Range: 1 - 255) |
refType | Reference type (Must be specified as 6). |
fileNo | File number (Range 1-65535). 3 is the input registers file, 4 is the holding registers file. |
recordNo | Record Number (Range: 0 - 65535). The first record to read from, 0-based numbering. |
recordArr | Buffer which will be filled with the data read |
recordCnt | Number of records to read (Range 1-125) |
int readFileRecord | ( | int | slaveAddr, |
FileSubRequest | subReqArr[], | ||
int | subReqCnt | ||
) |
Modbus function 20, Read File Record.
Performs a file record read for a list of subrequests.
slaveAddr | Modbus address of slave device or unit identifier (Range: 1 - 255) |
subReqArr | Array with list of subrequests |
subReqCnt | Number of subrequests to read (Range 1-35) |
References FTALK_ILLEGAL_ARGUMENT_ERROR, FTALK_INVALID_REPLY_ERROR, FTALK_SUCCESS, and MbusMasterFunctions::FileSubRequest::recordCnt.
int writeFileRecord | ( | int | slaveAddr, |
int | refType, | ||
int | fileNo, | ||
int | recordNo, | ||
const short | recordArr[], | ||
int | recordCnt | ||
) |
Modbus function 21, Write File Record.
Performs a file record write for a single subrequest.
slaveAddr | Modbus address of slave device or unit identifier (Range: 1 - 255) |
refType | Reference type (Must be specified as 6). |
fileNo | File number (Range 1-65535). 3 is the input registers file, 4 is the holding registers file. |
recordNo | Record Number (Range: 0 - 65535). The first record to write to, 0-based numbering. |
recordArr | Buffer with the data to be sent. |
recordCnt | Number of records to write (Range 1-122) |
int writeFileRecord | ( | int | slaveAddr, |
const FileSubRequest | subReqArr[], | ||
int | subReqCnt | ||
) |
Modbus function 21, Write File Record.
Performs a file record write for a list of subrequests.
slaveAddr | Modbus address of slave device or unit identifier (Range: 1 - 255) |
subReqArr | Array with list of subrequests |
subReqCnt | Number of subrequests to write (Range 1-27) |
References FTALK_ILLEGAL_ARGUMENT_ERROR, FTALK_INVALID_REPLY_ERROR, FTALK_SUCCESS, and MbusMasterFunctions::FileSubRequest::recordCnt.
int readExceptionStatus | ( | int | slaveAddr, |
unsigned char * | statusBytePtr | ||
) |
Modbus function 7, Read Exception Status.
Reads the eight exception status coils within the slave device.
slaveAddr | Modbus address of slave device or unit identifier (Range: 1 - 255 for serial, 0 - 255 for TCP) |
statusBytePtr | Slave status byte. The meaning of this status byte is slave specific and varies from device to device. |
References FTALK_ILLEGAL_ARGUMENT_ERROR, and FTALK_SUCCESS.
int returnQueryData | ( | int | slaveAddr, |
const unsigned char | queryArr[], | ||
unsigned char | echoArr[], | ||
int | len | ||
) |
Modbus function code 8, sub-function 00, Return Query Data.
slaveAddr | Modbus address of slave device or unit identifier (Range: 1 - 255 for serial, 0 - 255 for TCP) |
queryArr | Buffer with data to be sent |
echoArr | Buffer which will contain the data read |
len | Number of bytes send sent and read back |
References FTALK_ILLEGAL_ARGUMENT_ERROR, FTALK_INVALID_REPLY_ERROR, and FTALK_SUCCESS.
int restartCommunicationsOption | ( | int | slaveAddr, |
int | clearEventLog | ||
) |
Modbus function code 8, sub-function 01, Restart Communications Option.
slaveAddr | Modbus address of slave device or unit identifier (Range: 1 - 255 for serial, 0 - 255 for TCP) |
clearEventLog | Flag when set to one clears in addition the slave's communication even log. |
References FTALK_ILLEGAL_ARGUMENT_ERROR.
int readDeviceIdentification | ( | int | slaveAddr, |
int | accessType, | ||
int | objId, | ||
DeviceIdObjectList * | objListPtr | ||
) |
Modbus function 43 (hex 2B) subfunction 14 (hex 0E), Read Device Identification.
This function allows a master to retrieve various objects with meta information about a slave device. The data type of the objects returned is a 0-terminated ASCII string.
Object Id | Object Name / Description |
0x00 | VendorName |
0x01 | ProductCode |
0x02 | MajorMinorRevision |
0x03 | VendorUrl |
0x04 | ProductName |
0x05 | ModelName |
0x06 | UserApplicationName |
0x07 - 0x7F | Reserved |
0x80 - 0xFF | Vendor specific private objects |
slaveAddr | Modbus address of slave device or unit identifier (Range: 1 - 255 for serial, 0 - 255 for TCP) |
accessType | Category type (1=only mandatory basic objects, 2=all regular objects, 3=include vendor specfic objects, 4=single object) |
objId | An object ID from above table |
objListPtr | A pointer to a object list container which will receive the retrieved objects. |
Example retrieving all Device ID strings of basic device identification level (level 1):
References FTALK_ILLEGAL_ARGUMENT_ERROR, FTALK_INVALID_FRAME_ERROR, FTALK_INVALID_REPLY_ERROR, and FTALK_SUCCESS.
int setTimeout | ( | int | msTime | ) |
Configures time-out.
This function sets the operation or socket time-out to the specified value.
msTime | Timeout value in ms (Range: 1 - 100000) |
FTALK_SUCCESS | Success |
FTALK_ILLEGAL_ARGUMENT_ERROR | Argument out of range |
FTALK_ILLEGAL_STATE_ERROR | Protocol is already open |
References FTALK_ILLEGAL_ARGUMENT_ERROR, FTALK_ILLEGAL_STATE_ERROR, FTALK_SUCCESS, and isOpen().
|
inline |
Returns the time-out value.
int setPollDelay | ( | int | msTime | ) |
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.
msTime | Delay time in ms (Range: 0 - 100000), 0 disables poll delay |
FTALK_SUCCESS | Success |
FTALK_ILLEGAL_ARGUMENT_ERROR | Argument out of range |
FTALK_ILLEGAL_STATE_ERROR | Protocol is already open |
References FTALK_ILLEGAL_ARGUMENT_ERROR, FTALK_ILLEGAL_STATE_ERROR, FTALK_SUCCESS, and isOpen().
|
inline |
Returns the poll delay time.
int setRetryCnt | ( | int | retries | ) |
Configures the automatic retry setting.
A value of 0 disables any automatic retries.
retries | Retry count (Range: 0 - 10), 0 disables retries |
FTALK_SUCCESS | Success |
FTALK_ILLEGAL_ARGUMENT_ERROR | Argument out of range |
FTALK_ILLEGAL_STATE_ERROR | Protocol is already open |
References FTALK_ILLEGAL_ARGUMENT_ERROR, FTALK_ILLEGAL_STATE_ERROR, FTALK_SUCCESS, and isOpen().
|
inline |
Returns the automatic retry count.
|
inline |
Returns how often a message transfer has been executed.
|
inline |
Returns how often a message transfer was successful.
void configureBigEndianInts | ( | ) |
Configures 32-bit 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.
void configureLittleEndianInts | ( | ) |
Configures 32-bit int data type functions not to do a word swap.
This is the default.
void configureIeeeFloats | ( | ) |
Configures float data type functions not to do a word swap.
This is the default.
void configureSwappedFloats | ( | ) |
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.
void configureStandard32BitMode | ( | ) |
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.
void configureEnron32BitMode | ( | ) |
Configures all slaves for Daniel/ENRON 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.
void configureCountFromOne | ( | ) |
Configures the reference counting scheme to start with one for all slaves.
This renders the reference range to be 1 to 65536 (0x10000) and register #0 is an illegal register.
void configureCountFromZero | ( | ) |
Configures the reference counting scheme to start with zero for all slaves.
This renders the valid reference range to be 0 to 65535 (0xFFFF).
This renders the first register to be #0 for all slaves.
int configureBigEndianInts | ( | int | slaveAddr | ) |
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.
slaveAddr | Modbus address of slave device or unit identifier (Range: 1 - 255). A value of zero configures the behaviour for broadcasting. |
References FTALK_ILLEGAL_ARGUMENT_ERROR, and FTALK_SUCCESS.
int configureLittleEndianInts | ( | int | slaveAddr | ) |
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.
slaveAddr | Modbus address of slave device or unit identifier (Range: 1 - 255). A value of zero configures the behaviour for broadcasting. |
References FTALK_ILLEGAL_ARGUMENT_ERROR, and FTALK_SUCCESS.
int configureIeeeFloats | ( | int | slaveAddr | ) |
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.
slaveAddr | Modbus address of slave device or unit identifier (Range: 1 - 255). A value of zero configures the behaviour for broadcasting. |
References FTALK_ILLEGAL_ARGUMENT_ERROR, and FTALK_SUCCESS.
int configureSwappedFloats | ( | int | slaveAddr | ) |
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.
slaveAddr | Modbus address of slave device or unit identifier (Range: 1 - 255). A value of zero configures the behaviour for broadcasting. |
References FTALK_ILLEGAL_ARGUMENT_ERROR, and FTALK_SUCCESS.
int configureStandard32BitMode | ( | int | slaveAddr | ) |
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.
slaveAddr | Modbus address of slave device or unit identifier (Range: 1 - 255). A value of zero configures the behaviour for broadcasting. |
FTALK_SUCCESS | Success |
FTALK_ILLEGAL_ARGUMENT_ERROR | Argument out of range |
References configureIeeeFloats(), configureLittleEndianInts(), FTALK_ILLEGAL_ARGUMENT_ERROR, and FTALK_SUCCESS.
int configureEnron32BitMode | ( | int | slaveAddr | ) |
Configures all slaves for Daniel/ENRON 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.
slaveAddr | Modbus address of slave device or unit identifier (Range: 1 - 255). A value of zero configures the behaviour for broadcasting. |
FTALK_SUCCESS | Success |
FTALK_ILLEGAL_ARGUMENT_ERROR | Argument out of range |
References configureBigEndianInts(), configureSwappedFloats(), FTALK_ILLEGAL_ARGUMENT_ERROR, and FTALK_SUCCESS.
int configureCountFromOne | ( | int | slaveAddr | ) |
Configures a slave's reference counting scheme to start with one.
This renders the reference range to be 1 to 65536 (0x10000) and register #0 is an illegal register.
slaveAddr | Modbus address of slave device or unit identifier (Range: 1 - 255). A value of zero configures the behaviour for broadcasting. |
References FTALK_ILLEGAL_ARGUMENT_ERROR, and FTALK_SUCCESS.
int configureCountFromZero | ( | int | slaveAddr | ) |
Configures a slave's reference counting scheme to start with zero.
This is also known as PDU addressing.
This renders the valid reference range to be 0 to 65535 (0xFFFF).
slaveAddr | Modbus address of slave device or unit identifier (Range: 1 - 255). A value of zero configures the behaviour for broadcasting. |
References FTALK_ILLEGAL_ARGUMENT_ERROR, and FTALK_SUCCESS.
|
pure virtual |
This simply returns the state of an internal flag whether openProtocol() has been called or not.
true | = open |
false | = closed |
Implemented in MbusSerialClientBase, and MbusIpClientBase.
|
static |
Returns the library version number.