ModTcpMast2 (FB)

FUNCTION_BLOCK ModTcpMast2 EXTENDS |dModTcpMast|

ParallelProcessing := FALSE: Next request to the same server requires previous process of send request and receive/evaluate response to be completed (behavior as known from FW versions < 3.7.0)

ParallelProcessing := TRUE: Multiple requests to the same server can be processed at the same time, previous process of send request and receive/evaluate response does not need to be completed before sending next request
-Maximum supported number of simultaneous requests depends on type of PLC.
-In case maximum number of requests is already pending and one tries to send another one function block returns ErrorID = ERROR_ID.ERR_NO_MEMORY.

2 instances addressing the same server, 1 x ParallelProcessing := FALSE and 1 x ParallelProcessing := TRUE -> 2 independent simultaneous TCP connections
InOut:

Scope

Name

Type

Initial

Comment

Inherited from

Input

Eth

BYTE

ETH1

Index number of the assigned Ethernet interface - input is ignored, existing for compatibility reasons only

ModTcpMast

IPAdr

DWORD

0

IP address of the remote Modbus TCP Server device

ModTcpMast

UnitID

BYTE

0

Unit identifier for the Modbus TCP frame

ModTcpMast

Fct

BYTE

0

Function Code as specified in Modbus Protocol Specification

ModTcpMast

Addr

WORD

0

Operand/Register address in remote Modbus TCP Server device

ModTcpMast

Nb

WORD

0

Amount of data units to be sent/received

ModTcpMast

Data

DWORD

0

Address of local buffer for data to be sent or received

ModTcpMast

ParallelProcessing

BOOL

FALSE

Allow multiple requests to one Server processed at the same time (TRUE) or not (FALSE

ModTcpMast

Output

ErrorID

ERROR_ID

ERROR_ID.NO_ERROR

Code of error occured during execution
NO_ERROR Execution successfully completed
ERR_NOT_CONFIGURED Modbus TCP not configured
ERR_FCT_NOT_SUPPORTED Function code not supported
ERR_ILLEGAL_REGISTER_ADDRESS Illegal register address
ERR_INVALID_ACCESS Invalid address of local storage of data to read/write, inputs DATA / NB
ERR_DATA_SIZE Number of data to read/write exceeds capabilities
ERR_INTERNAL_PORTING Porting layer error. Operating system signaled error
ERR_INTERNAL_INVALID_HANDLE Illegal argument, unknown instance ‘dwHandle’. Internal error
ERR_FAILED_CONNECT Failed to connect to Server
ERR_CONNECTION_CLOSED Connection closed or unexpected result reported by stack
ERR_TIMEOUT Timeout expired. Server did not respond within specified time
ERR_EXCEPT_01_ILLEGAL_FUNCTION Illegal function exception. Exception response by Server containing error code 01 / 16#01
ERR_EXCEPT_02_ILLEGAL_DATA_ADDRESS Illegal data address. Exception response by Server containing error code 02 / 16#02
ERR_EXCEPT_03_ILLEGAL_DATA_VALUE Illegal data value. Exception response by Server containing error code 03 / 16#03
ERR_EXCEPT_04_SERVER_DEVICE_FAILURE Server device failure. Exception response by Server containing error code 04 / 16#04
ERR_EXCEPT_05_SERVER_ACKNOWLEDGE Server acknowledge. Exception response by Server containing error code 05 / 16#05
ERR_EXCEPT_06_SERVER_DEVICE_BUSY Server device busy. Exception response by Server containing error code 06 / 16#06
ERR_EXCEPT_07_SERVER_NO_ACKNOWLEDGE Server no acknowledge. Exception response by Server containing error code 07 / 16#07
ERR_EXCEPT_08_MEMORY_PARITY_ERROR Memory parity error. Exception response by Server containing error code 08 / 16#08
ERR_EXCEPT_09_SERVER_PASSIVE Probably passive Server. Exception response by Server containing error code 09 / 16#09
ERR_EXCEPT_0A_GATEWAY_PATH_UNAVAILABLE Gateway path unavailable. Exception response by Server containing error code 10 / 16#0A
ERR_EXCEPT_0B_GATEWAY_TARGET_DEVICE Gateway target device failed to respond. Exception response by Server containing error code 11 / 16#0B
ERR_INTERNAL_INVALID_STATE Invalid state, fatal internal error
ERR_NO_MEMORY Not enough memory
BUSY Busy, call again
ERR_INTERNAL_IO Internal error in I/O layer
ERR_INTERNAL_ILLEGAL_STATE Protocol stack in illegal state. Fatal internal error
ERR_INTERNAL_IO_RETRY Retry I/O operation. Operation not yet completed, function to be called again
ERR_INTERNAL_UNEXPECTED_STATE Unexpected state. Fatal internal error
ERR_INVALID_TIMEOUT_VALUE Invalid value for response timeout
ERR_INVALID_ACCESS Invalid address of local storage of data to read/write
ERR_ENDIANESS_NOT_SUPPORTED Endianess / byte order not supported

ModTcpMast

Input

RespTimeout

WORD

DEFAULTS.CONFIG_RESPONSE_TIME

Slave response timeout in ms. Maximum time waiting for a response after having sent a request

KeepAlive

DWORD

DEFAULTS.CONFIG_KEEP_ALIVE

Open Modbus Time in ms. A connection to a Server stays open after sending a request

until the time is expired. If there is another request within this time, the timer is restarted. On expiration the connection is closed.

ByteOrder

CAA.ENDIANESS

DEFAULTS.CONFIG_BYTE_ORDER

Endianess of data, little or Big Endian; Modbus Standard is Big Endian

Port

WORD

DEFAULTS.CONFIG_PORT

TCP Port

ResetOnClose

BOOL

FALSE

Reset connection when closing it (TRUE) or gaceful close (FALSE) like ModTcpMast

ConnectTimeout

DWORD

DEFAULTS.CONFIG_CONNECT_TO

Connect timeout [ms]. Value 0 corresponds to OS default