ModbusTCPRequestServer (FB)ΒΆ

FUNCTION_BLOCK ModbusTCPRequestServer

This function block provides the option to control how MODBUS requests sent to this server are processed by the MODBUS server application

InOut:

Scope

Name

Type

Initial

Comment

Input

xEnable

BOOL

FALSE

Flag to enable execution - default is FALSE

xReset

BOOL

FALSE

Flag to reset - default is FALSE

InterfaceName

WSTRING(255)

Name of ethernet interface (optional). If specified, the modbus server binds to the IP address of this interface.

Port

UINT

502

Modbus server port - 502 is Modbus default

tSocketTimeout

TIME

TIME#5s0ms

Modbus tcp connection timeout. Tcp socket is closed in case of a timeout

Mode

RecvReqMode

Request handling mode: Receive => Look for new request, Neg_Response => Sent a negative response for latest (unhandled) request, Pos_Response => Sent a positive response for latest (unhandled) request

ExceptionCode

BYTE

Exception code used for the negative response

Inout

DataBufferCoils

ARRAY [0..255] OF BYTE

Buffer for read and write data of bit access operations

DataBufferRegisters

ARRAY [0..127] OF WORD

Buffer for read and write data of register operations

Output

xBusy

BOOL

Function block is active

xError

BOOL

An Error occured

ErrorCode

UDINT

Latest error code

xOnline

BOOL

Function block is running and not in error state

ClientConnections

BYTE

0

Number of open TCP-connections

xNewRequest

BOOL

TRUE if a new request was received

ModbusRequest

ModbusCommand

Contains the request data of the current request in processing

uiUnitId

UINT

Unit-ID of the request

Methods:

Structure: