Generic_Service (FB)ΒΆ

FUNCTION_BLOCK Generic_Service EXTENDS BaseService

This function block can be used to generate an own service for an EtherNet/IP Adapter. The message will be sent as an unconnected explicit message request.

Note

Data received and send needs to be swapped. See parent folder.

/// Set trigger to TRUE to execute the service.
/// Example device used here is EtherNet_IP_Adapter.
/// The following service is an example. It can be adapted and be changed to any service.
PROGRAM PLC_PRG
VAR
    dut : ENIP.Generic_Service ;
    data: usint:=16#FF;
    trigger: BOOL;
END_VAR

    dut.xExecute := trigger;
    dut.itfEtherNetIPDevice := EtherNet_IP_Adapter;
    dut.eClass := 16#F5; // TCPIP Interface Object
    dut.dwInstance := 1;
    dut.wAttribute := 13; // Encapsulation Inactivity Timeout
    dut.eService := ENIP.CIPCommonService.SET_ATTRIBUTE_SINGLE;
    dut.pWriteData := ADR(data);
    dut.udiWriteDataSize := 1;
    dut();
InOut:

Scope

Name

Type

Comment

Inherited from

Input

xExecute

BOOL

ETrig

Output

xDone

BOOL

ETrig

xBusy

BOOL

ETrig

xError

BOOL

ETrig

Input

itfEtherNetIPDevice

IEtherNetIPService

BaseService

eClass

CIPClass

BaseService

dwInstance

DWORD

BaseService

tTimeOut

TIME

BaseService

Output

eError

ERROR

BaseService

Input

wAttribute

WORD

Attribute the services is addressed to. Leave 0 if this service does not address an attribute.

eService

CIPCommonService

Choose one of the CIPCommonService members, or insert any vendor specific service code.

pWriteData

POINTER TO BYTE

Data to write to the EtherNet/IP Adapter. Leave 0 if no data should be sent to the EtherNet/IP Adapter.

udiWriteDataSize

UDINT

Size of data to write to the EtherNet/IP Adapter. Leave 0 if no data should be sent to the EtherNet/IP Adapter.

pReadData

POINTER TO BYTE

Data expected to receive from the EtherNet/IP Adapter. Leave 0 if no data is expected to be received from the EtherNet/IP Adapter.

udiReadDataSize

UDINT

Size of data expected to receive from the EtherNet/IP Adapter. Leave 0 if no data is expected to be received from the EtherNet/IP Adapter.

Output

udiReceivedDataSize

UDINT

Size of the received data