• Libraries
  • Shop
  • Doc
  • Free Modbus
  • Support
  • Login
  • Introduction
  • Chapters
  • Modules
  • Classes
  • Class List
  • Class Members
Public Member Functions | Public Attributes

TMbusRtuMasterProtocol Class Reference
[Serial Protocols]

Modbus RTU Master Protocol class. More...

Inheritance diagram for TMbusRtuMasterProtocol:
TMbusSerialMasterProtocol TMbusMasterFunctions

List of all members.

Public Member Functions

 TMbusRtuMasterProtocol (TComponent aOwner)
 Constructs a TMbusRtuMasterProtocol object and initialises its data.
 openProtocol ()
 Opens a serial Modbus protocol and the associated serial port with the port parameters configured via properties.
 openUseExistingConnection (integer cnxnHandle)
 Opens a serial Modbus protocol using an existing and open handle.
 enableRs485Mode (integer rtsDelay)
 Enables RS485 mode.
boolean isOpen ()
 Returns whether the protocol is open or not.
 closeProtocol ()
 Closes an open protocol including any associated communication resources (COM ports or sockets).
string getPackageVersion ()
 Returns the package version number.

Public Attributes

string portName
 Serial port identifier property (eg 'COM1').
longint baudRate
 Baud rate property in bps (typically 1200 - 115200, maximum value depends on UART hardware).
integer dataBits
 Data bits property.
integer stopBits
 Stop bits property.
integer parity
 Parity property.

Bit Access

Table 0:00000 (Coils) and Table 1:00000 (Input Status)



 readCoils (integer slaveAddr, integer startRef, boolean[]bitArr)
 Modbus function 1 (01 hex), Read Coil Status/Read Coils.
 readInputDiscretes (integer slaveAddr, integer startRef, boolean[]bitArr)
 Modbus function 2 (02 hex), Read Inputs Status/Read Input Discretes.
 writeCoil (integer slaveAddr, integer bitAddr, boolean bitVal)
 Modbus function 5 (05 hex), Force Single Coil/Write Coil.
 forceMultipleCoils (integer slaveAddr, integer startRef, boolean[]bitArr)
 Modbus function 15 (0F hex), Force Multiple Coils.

16-bit Access

Table 4:00000 (Holding Registers) and Table 3:00000 (Input Registers)



 readMultipleRegisters (integer slaveAddr, integer startRef, word[]regArr)
 Modbus function 3 (03 hex), Read Holding Registers/Read Multiple Registers.
 readInputRegisters (integer slaveAddr, integer startRef, word[]regArr)
 Modbus function 4 (04 hex), Read Input Registers.
 writeSingleRegister (integer slaveAddr, integer regAddr, word regVal)
 Modbus function 6 (06 hex), Preset Single Register/Write Single Register.
 writeMultipleRegisters (integer slaveAddr, integer startRef, word[]regArr)
 Modbus function 16 (10 hex), Preset Multiple Registers/Write Multiple Registers.
 maskWriteRegister (integer slaveAddr, integer regAddr, word andMask, word orMask)
 Modbus function 22 (16 hex), Mask Write Register.
 readWriteRegisters (integer slaveAddr, integer readRef, word[]readArr, integer writeRef, word[]writeArr)
 Modbus function 23 (17 hex), Read/Write Registers.

32-bit Access

Table 4:00000 (Holding Registers) and Table 3:00000 (Input Registers)



 readMultipleLongInts (integer slaveAddr, integer startRef, integer[]int32Arr)
 Modbus function 3 (03 hex) for 32-bit long int data types, Read Holding Registers/Read Multiple Registers as long int data.
 readInputLongInts (integer slaveAddr, integer startRef, integer[]int32Arr)
 Modbus function 4 (04 hex) for 32-bit long int data types, Read Input Registers as long int data.
 writeMultipleLongInts (integer slaveAddr, integer startRef, integer[]int32Arr)
 Modbus function 16 (10 hex) for 32-bit long int data types, Preset Multiple Registers/Write Multiple Registers with long int data.
 readMultipleFloats (integer slaveAddr, integer startRef, single[]float32Arr)
 Modbus function 3 (03 hex) for 32-bit float data types, Read Holding Registers/Read Multiple Registers as float data.
 readInputFloats (integer slaveAddr, integer startRef, single[]float32Arr)
 Modbus function 4 (04 hex) for 32-bit float data types, Read Input Registers as float data.
 writeMultipleFloats (integer slaveAddr, integer startRef, single[]float32Arr)
 Modbus function 16 (10 hex) for 32-bit float data types, Preset Multiple Registers/Write Multiple Registers with float data.
 readMultipleMod10000 (integer slaveAddr, integer startRef, integer[]int32Arr)
 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.
 readInputMod10000 (integer slaveAddr, integer startRef, integer[]int32Arr)
 Modbus function 4 (04 hex) for 32-bit modulo-10000 long int data types, Read Input Registers as modulo-10000 long int data.
 writeMultipleMod10000 (integer slaveAddr, integer startRef, integer[]int32Arr)
 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.

Diagnostics



 readExceptionStatus (integer slaveAddr, byte &statusByte)
 Modbus function 7 (07 hex), Read Exception Status.
 returnQueryData (integer slaveAddr, byte[]queryArr, byte[]echoArr)
 Modbus function code 8, sub-function 00, Return Query Data.
 restartCommunicationsOption (integer slaveAddr, boolean clearEventLog)
 Modbus function code 8, sub-function 01, Restart Communications Option.

Custom Function Codes



 customFunction (integer slaveAddr, integer functionCode, byte[]requestArr, byte[]responseArr, integer &responseLen)
 User Defined Function CodeThis method can be used to implement User Defined Function Codes.

Protocol Configuration



 setTimeout (const integer timeOut)
 Configures time-out.
integer getTimeout ()
 Returns the time-out value.
 setPollDelay (const integer pollDelay)
 Configures poll delay.
integer getPollDelay ()
 Returns the poll delay time.
 setRetryCnt (const integer retryCnt)
 Configures the automatic retry setting.
integer getRetryCnt ()
 Returns the automatic retry count.
integer timeout
 Time-out port property.
integer pollDelay
 Poll delay property.
integer retryCnt
 Retry count property.

Transmission Statistic Functions



cardinal getTotalCounter ()
 Returns how often a message transfer has been executed.
 resetTotalCounter ()
 Resets total message transfer counter.
cardinal getSuccessCounter ()
 Returns how often a message transfer was successful.
 resetSuccessCounter ()
 Resets successful message transfer counter.

Slave Configuration



 configureBigEndianInts ()
 Configures int data type functions to do a word swap.
 configureBigEndianInts (integer slaveAddr)
 Enables int data type functions to do a word swap on a per slave basis.
 configureSwappedFloats ()
 Configures float data type functions to do a word swap.
 configureSwappedFloats (integer slaveAddr)
 Enables float data type functions to do a word swap on a per slave basis.
 configureLittleEndianInts ()
 Configures int data type functions not to do a word swap.
 configureLittleEndianInts (integer slaveAddr)
 Disables word swapping for int data type functions on a per slave basis.
 configureIeeeFloats ()
 Configures float data type functions not to do a word swap.
 configureIeeeFloats (integer slaveAddr)
 Disables float data type functions to do a word swap on a per slave basis.
 configureStandard32BitMode ()
 Configures all slaves for Standard 32-bit Mode.
 configureStandard32BitMode (integer slaveAddr)
 Configures a slave for Standard 32-bit Register Mode.
 configureEnron32BitMode ()
 Configures all slaves for Daniel/ENRON 32-bit Mode.
 configureEnron32BitMode (integer slaveAddr)
 Configures all slaves for Daniel/ENRON 32-bit Mode.
 configureCountFromOne ()
 Configures the reference counting scheme to start with one for all slaves.
 configureCountFromOne (integer slaveAddr)
 Configures a slave's reference counting scheme to start with one.
 configureCountFromZero ()
 Configures the reference counting scheme to start with zero for all slaves.
 configureCountFromZero (integer slaveAddr)
 Configures a slave's reference counting scheme to start with zero.

Detailed Description

Modbus RTU Master Protocol class.

This class realizes the Modbus RTU master protocol. It provides functions to open and to close serial port as well as data and control functions which can be used at any time after the protocol has been opened. The data and control functions are organized different conformance classes. For a more detailed description of the data and control functions see section Data and Control Functions for all Modbus Protocol Flavours.

It is possible to instantiate multiple instances of this class for establishing multiple connections on different serial ports (They should be executed in separate threads).

See also:
Data and Control Functions for all Modbus Protocol Flavours, Serial Protocols
TMbusMasterFunctions, TMbusSerialMasterProtocol, TMbusAsciiMasterProtocol, TMbusTcpMasterProtocol, TMbusRtuOverTcpMasterProtocol

Constructor & Destructor Documentation

TMbusRtuMasterProtocol ( TComponent  aOwner  ) 

Constructs a TMbusRtuMasterProtocol object and initialises its data.

Exceptions:
EOutOfResources Creation of class failed

Member Function Documentation

openProtocol (  )  [inherited]

Opens a serial Modbus protocol and the associated serial port with the port parameters configured via properties.

This function opens the serial port. After a port has been opened, data and control functions can be used.

Exceptions:
EInOutError An I/O error occurred
EOpenErr The serial port does not exist
EPortAlreadyOpen Port is already used by somedbody else
EPortNoAccess No permission to access serial
EIllegalArgumentError A parameter is invalid
openUseExistingConnection ( integer  cnxnHandle  )  [inherited]

Opens a serial Modbus protocol using an existing and open handle.

Useful for using the protocol over a modem link.

Parameters:
cnxnHandle Win32 API handle pointing to the existing and open connection.
Exceptions:
EIllegalArgumentError A parameter is invalid
enableRs485Mode ( integer  rtsDelay  )  [inherited]

Enables RS485 mode.

In RS485 mode the RTS signal can be used to enable and disable the transmitter of a RS232/RS485 converter. The RTS signal is asserted before sending data. It is cleared after the transmit buffer has been emptied and in addition the specified delay time has elapsed. The delay time is necessary because even the transmit buffer is already empty, the UART's FIFO will still contain unsent characters.

Warning:
The use of RTS controlled RS232/RS485 converters should be avoided if possible. It is difficult to determine the exact time when to switch off the transmitter with non real-time operating systems like Windows and Linux. If it is switched off to early characters might still sit in the FIFO or the transmit register of the UART and these characters will be lost. Hence the slave will not recognize the message. On the other hand if it is switched off too late then the slave's message is corrupted and the master will not recognize the message.
Remarks:
The delay value is indicative only and not guaranteed to be maintained. How precise it is followed depends on the operating system used, it's scheduling priority and it's system timer resolution.
Note:
A protocol must be closed in order to configure it.
Parameters:
rtsDelay Delay time in ms (Range: 0 - 100000) which applies after the transmit buffer is empty. 0 disables this mode.
Exceptions:
EIllegalStateError Protocol is already open
EIllegalArgumentError A parameter is out of range
readCoils ( integer  slaveAddr,
integer  startRef,
boolean[]  bitArr 
) [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 - 255)
startRef Start reference (Range: 1 - 65536)
bitArr Buffer which will contain the data read. The length of the array determines how many coils are read (Range: 1-2000).
Exceptions:
EIllegalStateError Port or connection is closed
EInOutError An I/O error occurred
EIllegalArgumentError A parameter is out of range
EBusProtocolException A protocol failure occurred. See descendants of EBusProtocolException for a more detailed failure list.
Note:
No broadcast supported
readInputDiscretes ( integer  slaveAddr,
integer  startRef,
boolean[]  bitArr 
) [inherited]

Modbus function 2 (02 hex), Read Inputs Status/Read Input Discretes.

Reads the contents of the discrete inputs (input status, 1:00000 table).

Parameters:
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. The length of the array determines how many inputs are read (Range: 1-2000).
Exceptions:
EIllegalStateError Port or connection is closed
EInOutError An I/O error occurred
EIllegalArgumentError A parameter is out of range
EBusProtocolException A protocol failure occurred. See descendants of EBusProtocolException for a more detailed failure list.
Note:
No broadcast supported
writeCoil ( integer  slaveAddr,
integer  bitAddr,
boolean  bitVal 
) [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 - 255)
bitAddr Coil address (Range: 1 - 65536)
bitVal true sets, false clears discrete output variable
Exceptions:
EIllegalStateError Port or connection is closed
EInOutError An I/O error occurred
EIllegalArgumentError A parameter is out of range
EBusProtocolException A protocol failure occurred. See descendants of EBusProtocolException for a more detailed failure list.
Note:
Broadcast supported for serial protocols
forceMultipleCoils ( integer  slaveAddr,
integer  startRef,
boolean[]  bitArr 
) [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 - 255)
startRef Start reference (Range: 1 - 65536)
bitArr Buffer which contains the data to be sent. The length of the array determines how many coils are written (Range: 1-1968).
Exceptions:
EIllegalStateError Port or connection is closed
EInOutError An I/O error occurred
EIllegalArgumentError A parameter is out of range
EBusProtocolException A protocol failure occurred. See descendants of EBusProtocolException for a more detailed failure list.
Note:
Broadcast supported for serial protocols
readMultipleRegisters ( integer  slaveAddr,
integer  startRef,
word[]  regArr 
) [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 - 255)
startRef Start register (Range: 1 - 65536)
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:
EIllegalStateError Port or connection is closed
EInOutError An I/O error occurred
EIllegalArgumentError A parameter is out of range
EBusProtocolException A protocol failure occurred. See descendants of EBusProtocolException for a more detailed failure list.
Note:
No broadcast supported
readInputRegisters ( integer  slaveAddr,
integer  startRef,
word[]  regArr 
) [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 - 255)
startRef Start register (Range: 1 - 65536)
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:
EIllegalStateError Port or connection is closed
EInOutError An I/O error occurred
EIllegalArgumentError A parameter is out of range
EBusProtocolException A protocol failure occurred. See descendants of EBusProtocolException for a more detailed failure list.
Note:
No broadcast supported
writeSingleRegister ( integer  slaveAddr,
integer  regAddr,
word  regVal 
) [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 - 255)
regAddr Register address (Range: 1 - 65536)
regVal Data to be sent
Exceptions:
EIllegalStateError Port or connection is closed
EInOutError An I/O error occurred
EIllegalArgumentError A parameter is out of range
EBusProtocolException A protocol failure occurred. See descendants of EBusProtocolException for a more detailed failure list.
Note:
Broadcast supported for serial protocols
writeMultipleRegisters ( integer  slaveAddr,
integer  startRef,
word[]  regArr 
) [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 - 255)
startRef Start register (Range: 1 - 65536)
regArr Buffer with the data to be sent.The length of the array determines how many registers are written (Range: 1-123).
Exceptions:
EIllegalStateError Port or connection is closed
EInOutError An I/O error occurred
EIllegalArgumentError A parameter is out of range
EBusProtocolException A protocol failure occurred. See descendants of EBusProtocolException for a more detailed failure list.
Note:
Broadcast supported for serial protocols
maskWriteRegister ( integer  slaveAddr,
integer  regAddr,
word  andMask,
word  orMask 
) [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 (NOT andMask))

Parameters:
slaveAddr Modbus address of slave device or unit identifier (Range: 1 - 255)
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
Note:
No broadcast supported
readWriteRegisters ( integer  slaveAddr,
integer  readRef,
word[]  readArr,
integer  writeRef,
word[]  writeArr 
) [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 - 255)
readRef Start registers for reading (Range: 1 - 65536)
readArr Buffer which will contain the data read. The length of the array determines how many registers are read (Range: 1-125).
writeRef Start registers for writing (Range: 1 - 65536)
writeArr Buffer with data to be sent. The length of the array determines how many registers are written (Range: 1-121).
Exceptions:
EIllegalStateError Port or connection is closed
EInOutError An I/O error occurred
EIllegalArgumentError A parameter is out of range
EBusProtocolException A protocol failure occurred. See descendants of EBusProtocolException for a more detailed failure list.
Note:
No broadcast supported
readMultipleLongInts ( integer  slaveAddr,
integer  startRef,
integer[]  int32Arr 
) [inherited]

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.

Remarks:
Modbus does not know about any other data type than discretes and 16-bit registers. Because a long int value is of 32-bit length, it will be transferred as two consecutive 16-bit registers. This means that the amount of registers transferred with this function is twice the amount of int values passed to this function.
Parameters:
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. The length of the array determines how many values are read (Range: 1-62).
Exceptions:
EIllegalStateError Port or connection is closed
EInOutError An I/O error occurred
EIllegalArgumentError A parameter is out of range
EBusProtocolException A protocol failure occurred. See descendants of EBusProtocolException for a more detailed failure list.
Note:
No broadcast supported
readInputLongInts ( integer  slaveAddr,
integer  startRef,
integer[]  int32Arr 
) [inherited]

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.

Remarks:
Modbus does not know about any other data type than discretes and 16-bit registers. Because a long int value is of 32-bit length, it will be transferred as two consecutive 16-bit registers. This means that the amount of registers transferred with this function is twice the amount of int values passed to this function.
Parameters:
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. The length of the array determines how many values are read (Range: 1-62).
Exceptions:
EIllegalStateError Port or connection is closed
EInOutError An I/O error occurred
EIllegalArgumentError A parameter is out of range
EBusProtocolException A protocol failure occurred. See descendants of EBusProtocolException for a more detailed failure list.
Note:
No broadcast supported
writeMultipleLongInts ( integer  slaveAddr,
integer  startRef,
integer[]  int32Arr 
) [inherited]

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).

Remarks:
Modbus does not know about any other data type than discretes and 16-bit registers. Because a long int value is of 32-bit length, it will be transferred as two consecutive 16-bit registers. This means that the amount of registers transferred with this function is twice the amount of int values passed to this function.
Parameters:
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. The length of the array determines how many values are read (Range: 1-61).
Exceptions:
EIllegalStateError Port or connection is closed
EInOutError An I/O error occurred
EIllegalArgumentError A parameter is out of range
EBusProtocolException A protocol failure occurred. See descendants of EBusProtocolException for a more detailed failure list.
Note:
Broadcast supported for serial protocols
readMultipleFloats ( integer  slaveAddr,
integer  startRef,
single[]  float32Arr 
) [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 consecutive output registers (holding registers, 4:00000 table) into float values.

Remarks:
Modbus does not know about any other data type than discretes and 16-bit registers. Because a float value is of 32-bit length, it will be transferred as two consecutive 16-bit registers. This means that the amount of registers transferred with this function is twice the amount of float values passed to this function.
Parameters:
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. The length of the array determines how many values are read (Range: 1-62).
Exceptions:
EIllegalStateError Port or connection is closed
EInOutError An I/O error occurred
EIllegalArgumentError A parameter is out of range
EBusProtocolException A protocol failure occurred. See descendants of EBusProtocolException for a more detailed failure list.
Note:
No broadcast supported
readInputFloats ( integer  slaveAddr,
integer  startRef,
single[]  float32Arr 
) [inherited]

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.

Remarks:
Modbus does not know about any other data type than discretes and 16-bit registers. Because a float value is of 32-bit length, it will be transferred as two consecutive 16-bit registers. This means that the amount of registers transferred with this function is twice the amount of float values passed to this function.
Parameters:
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. The length of the array determines how many values are read (Range: 1-62).
Exceptions:
EIllegalStateError Port or connection is closed
EInOutError An I/O error occurred
EIllegalArgumentError A parameter is out of range
EBusProtocolException A protocol failure occurred. See descendants of EBusProtocolException for a more detailed failure list.
Note:
No broadcast supported
writeMultipleFloats ( integer  slaveAddr,
integer  startRef,
single[]  float32Arr 
) [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 pairs of output registers (holding registers, 4:00000 table).

Remarks:
Modbus does not know about any other data type than discretes and 16-bit registers. Because a float value is of 32-bit length, it will be transferred as two consecutive 16-bit registers. This means that the amount of registers transferred with this function is twice the amount of float values passed to this function.
Parameters:
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. The length of the array determines how many values are written (Range: 1-61).
Exceptions:
EIllegalStateError Port or connection is closed
EInOutError An I/O error occurred
EIllegalArgumentError A parameter is out of range
EBusProtocolException A protocol failure occurred. See descendants of EBusProtocolException for a more detailed failure list.
Note:
Broadcast supported for serial protocols
readMultipleMod10000 ( integer  slaveAddr,
integer  startRef,
integer[]  int32Arr 
) [inherited]

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.

Remarks:
Modbus does not know about any other data type than discretes and 16-bit registers. Because a modulo-10000 value is of 32-bit length, it will be transferred as two consecutive 16-bit registers. This means that the amount of registers transferred with this function is twice the amount of int values passed to this function.
Parameters:
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. The length of the array determines how many values are read (Range: 1-62).
Exceptions:
EIllegalStateError Port or connection is closed
EInOutError An I/O error occurred
EIllegalArgumentError A parameter is out of range
EBusProtocolException A protocol failure occurred. See descendants of EBusProtocolException for a more detailed failure list.
Note:
No broadcast supported
readInputMod10000 ( integer  slaveAddr,
integer  startRef,
integer[]  int32Arr 
) [inherited]

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.

Remarks:
Modbus does not know about any other data type than discretes and 16-bit registers. Because an modulo-10000 value is of 32-bit length, it will be transferred as two consecutive 16-bit registers. This means that the amount of registers transferred with this function is twice the amount of int values passed to this function.
Parameters:
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. The length of the array determines how many values are read (Range: 1-62).
Exceptions:
EIllegalStateError Port or connection is closed
EInOutError An I/O error occurred
EIllegalArgumentError A parameter is out of range
EBusProtocolException A protocol failure occurred. See descendants of EBusProtocolException for a more detailed failure list.
Note:
No broadcast supported
writeMultipleMod10000 ( integer  slaveAddr,
integer  startRef,
integer[]  int32Arr 
) [inherited]

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.

Remarks:
Modbus does not know about any other data type than discretes and 16-bit registers. Because a modulo-10000 value is of 32-bit length, it will be transferred as two consecutive 16-bit registers. This means that the amount of registers transferred with this function is twice the amount of int values passed to this function.
Parameters:
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. The length of the array determines how many values are written (Range: 1-61).
Exceptions:
EIllegalStateError Port or connection is closed
EInOutError An I/O error occurred
EIllegalArgumentError A parameter is out of range
EBusProtocolException A protocol failure occurred. See descendants of EBusProtocolException for a more detailed failure list.
Note:
Broadcast supported for serial protocols
readExceptionStatus ( integer  slaveAddr,
byte &  statusByte 
) [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 - 255)
statusByte Slave status byte. The meaning of this status byte is slave specific and varies from device to device.
Exceptions:
EIllegalStateError Port or connection is closed
EInOutError An I/O error occurred
EIllegalArgumentError A parameter is out of range
EBusProtocolException A protocol failure occurred. See descendants of EBusProtocolException for a more detailed failure list.
Note:
No broadcast supported
returnQueryData ( integer  slaveAddr,
byte[]  queryArr,
byte[]  echoArr 
) [inherited]

Modbus function code 8, sub-function 00, Return Query Data.

Parameters:
slaveAddr Modbus address of slave device or unit identifier (Range: 1 - 255)
queryArr Data to be sent
echoArr Buffer which will contain the data read. Array must be of the same size as queryArr.
Exceptions:
EIllegalStateError Port or connection is closed
EInOutError An I/O error occurred
EIllegalArgumentError A parameter is out of range
EBusProtocolException A protocol failure occurred. See descendants of EBusProtocolException for a more detailed failure list.
Note:
No broadcast supported
restartCommunicationsOption ( integer  slaveAddr,
boolean  clearEventLog 
) [inherited]

Modbus function code 8, sub-function 01, Restart Communications Option.

Parameters:
slaveAddr Modbus address of slave device or unit identifier (Range: 1 - 255)
clearEventLog Flag when set to one clears in addition the slave's communication even log.
Exceptions:
EIllegalStateError Port or connection is closed
EInOutError An I/O error occurred
EIllegalArgumentError A parameter is out of range
EBusProtocolException A protocol failure occurred. See descendants of EBusProtocolException for a more detailed failure list.
Note:
No broadcast supported
setTimeout ( const integer  timeOut  )  [inherited]

Configures time-out.

This function sets the operation or socket time-out to the specified value.

Remarks:
The time-out value is indicative only and not guaranteed to be maintained. How precise it is followed depends on the operating system used, it's scheduling priority and it's system timer resolution.
Note:
A protocol must be closed in order to configure it.
Parameters:
timeOut Timeout value in ms (Range: 1 - 100000)
Exceptions:
EIllegalStateError Protocol is already open
EIllegalArgumentError A parameter is out of range
integer getTimeout (  )  [inherited]

Returns the time-out value.

Remarks:
The time-out value is indicative only and not guaranteed to be maintained. How precise it is followed depends on the operating system used, it's scheduling priority and it's system timer resolution.
Returns:
Timeout value in ms
setPollDelay ( const integer  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.

Remarks:
The delay value is indicative only and not guaranteed to be maintained. How precise it is followed depends on the operating system used, it's scheduling priority and it's system timer resolution.
Note:
A protocol must be closed in order to configure it.
Parameters:
pollDelay Delay time in ms (Range: 0 - 100000), 0 disables poll delay
Exceptions:
EIllegalStateError Protocol is already open
EIllegalArgumentError A parameter is out of range
integer getPollDelay (  )  [inherited]

Returns the poll delay time.

Returns:
Delay time in ms, 0 if poll delay is switched off
setRetryCnt ( const integer  retryCnt  )  [inherited]

Configures the automatic retry setting.

A value of 0 disables any automatic retries.

Note:
A protocol must be closed in order to configure it.
Parameters:
retryCnt Retry count (Range: 0 - 10), 0 disables retries
Exceptions:
EIllegalStateError Protocol is already open
EIllegalArgumentError A parameter is out of range
integer getRetryCnt (  )  [inherited]

Returns the automatic retry count.

Returns:
Retry count
cardinal getTotalCounter (  )  [inherited]

Returns how often a message transfer has been executed.

Returns:
Counter value
cardinal getSuccessCounter (  )  [inherited]

Returns how often a message transfer was successful.

Returns:
Counter value
configureBigEndianInts (  )  [inherited]

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 machine.

configureBigEndianInts ( integer  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 - 255). A value of zero configures the behaviour for broadcasting.
Exceptions:
EIllegalArgumentError A parameter is out of range
configureSwappedFloats (  )  [inherited]

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.

Note:
Most platforms store floats in IEEE 754 little-endian order which does not need a word swap.
configureSwappedFloats ( integer  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 - 255). A value of zero configures the behaviour for broadcasting.
Exceptions:
EIllegalArgumentError A parameter is out of range
configureLittleEndianInts (  )  [inherited]

Configures int data type functions not to do a word swap.

This is the default.

configureLittleEndianInts ( integer  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 - 255). A value of zero configures the behaviour for broadcasting.
Exceptions:
EIllegalArgumentError A parameter is out of range
configureIeeeFloats (  )  [inherited]

Configures float data type functions not to do a word swap.

This is the default.

configureIeeeFloats ( integer  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 - 255). A value of zero configures the behaviour for broadcasting.
Exceptions:
EIllegalArgumentError A parameter is out of range
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
configureStandard32BitMode ( integer  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 - 255). A value of zero configures the behaviour for broadcasting.
Exceptions:
EIllegalArgumentError A parameter is out of range
configureEnron32BitMode (  )  [inherited]

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.

configureEnron32BitMode ( integer  slaveAddr  )  [inherited]

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.

Parameters:
slaveAddr Modbus address of slave device or unit identifier (Range: 1 - 255). A value of zero configures the behaviour for broadcasting.
Exceptions:
EIllegalArgumentError A parameter is out of range
configureCountFromOne (  )  [inherited]

Configures the reference counting scheme to start with one for all slaves.

This renders the reference range to be 1 to 65536 and register #0 is an illegal register.

Remarks:
This is the default mode
configureCountFromOne ( integer  slaveAddr  )  [inherited]

Configures a slave's reference counting scheme to start with one.

This renders the reference range to be 1 to 65536 and register #0 is an illegal register.

Parameters:
slaveAddr Modbus address of slave device or unit identifier (Range: 1 - 255). A value of zero configures the behaviour for broadcasting.
Remarks:
This is the default mode
Exceptions:
EIllegalArgumentError A parameter is out of range
configureCountFromZero (  )  [inherited]

Configures the reference counting scheme to start with zero for all slaves.

This renders the valid reference range to be 0 to 65535.

This renders the first register to be #0 for all slaves.

configureCountFromZero ( integer  slaveAddr  )  [inherited]

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.

Parameters:
slaveAddr Modbus address of slave device or unit identifier (Range: 1 - 255). A value of zero configures the behaviour for broadcasting.
Exceptions:
EIllegalArgumentError A parameter is out of range
boolean isOpen (  )  [inherited]

Returns whether the protocol is open or not.

Return values:
true = open
false = closed
class string getPackageVersion (  )  [inherited]

Returns the package version number.

Returns:
Package version string

Member Data Documentation

string portName [inherited]

Serial port identifier property (eg 'COM1').

Note:
A protocol must be closed in order to configure it.
See also:
fPortName For reading
fPortName For writing
longint baudRate [inherited]

Baud rate property in bps (typically 1200 - 115200, maximum value depends on UART hardware).

Note:
A protocol must be closed in order to configure it.
See also:
fBaudRate For reading
fBaudRate For writing
integer dataBits [inherited]

Data bits property.

SER_DATABITS_7: 7 data bits (ASCII protocol only), SER_DATABITS_8: 8 data bits

Note:
A protocol must be closed in order to configure it.
See also:
fDataBits For reading
fDataBits For writing
integer stopBits [inherited]

Stop bits property.

SER_STOPBITS_1: 1 stop bit, SER_STOPBITS_2: 2 stop bits

Note:
The Modbus standard requires two stop bits if no parity is chosen. This library is not enforcing this but it is a recommended configuration.
A protocol must be closed in order to configure it.
See also:
fStopBits For reading
fStopBits For writing
integer parity [inherited]

Parity property.

SER_PARITY_NONE: no parity, SER_PARITY_ODD: odd parity, SER_PARITY_EVEN: even parity

Note:
The Modbus standard requires two stop bits if no parity is chosen. This library is not enforcing this but it is a recommended configuration.
A protocol must be closed in order to configure it.
See also:
fParity For reading
fParity For writing
integer timeout [inherited]

Time-out port property.

Note:
A protocol must be closed in order to configure it.
See also:
getTimeout For reading
setTimeout For writing
integer pollDelay [inherited]

Poll delay property.

Delay between two Modbus read/writes in ms

Note:
A protocol must be closed in order to configure it.
See also:
getPollDelay For reading
setPollDelay For writing
integer retryCnt [inherited]

Retry count property.

Note:
A protocol must be closed in order to configure it.
See also:
getRetryCnt For reading
setRetryCnt For writing

FieldTalk Modbus Master Library, Delphi Edition
Library version 2.6.2
Speak to the Experts
Modbus Organization Member logo

We are member of the Modbus Organization, Inc.

Buy with Confidence
30-day money back guarantee All our FieldTalk web sales are backed by a 30-day Money Back Guarantee.
We Accept
Bank VISA MasterCard PayPal
Customer Info
  • Info & Contact
  • Customer Login
  • Terms of Service
  • Terms of Sale
  • Privacy Policy
© 2005-2025 proconX Pty Ltd. All rights reserved. proconX and FieldTalk are trademarks of proconX Pty Ltd.
All other trademarks and registered trademarks appearing on www.modbusdriver.com are the property of their respective owners.