Generic_Service (FB)

FUNCTION_BLOCK Generic_Service EXTENDS BaseService

This function block performs a generic service at 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.

/// Force trigger to TRUE to activate.
/// Example device used here is WAGO 750-352 FC ETHERNET.
/// But you can adapt it, by using the services which are implemented by your prefered device.
PROGRAM PLC_PRG
VAR
    dut : ENIP.Generic_Service ;
    data: usint:=16#FF;
    trigger: BOOL;
END_VAR

    dut.xExecute := trigger;
    dut.itfEtherNetIPDevice := WAGO_750_352_FC_ETHERNET;
    dut.eClass := 100;
    dut.dwInstance := 1;
    dut.wAttribute := 11;
    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

Rising edge: Action starts

Falling edge: Resets outputs

If a falling edge occurs before the function block has completed its action, the outputs operate in the usual manner and are only reset if either the action is completed or in the event of an error. In this case, the corresponding output values (xDone, xError) are present at the outputs for exactly one cycle.

ETrig

Output

xDone

BOOL

TRUE: Action successfully completed

ETrig

xBusy

BOOL

TRUE: Function block active

ETrig

xError

BOOL

TRUE: Error occurred, function block aborts action

FALSE: No error

ETrig

Input

itfEtherNetIPDevice

IEtherNetIPService

BaseService

eClass

CIPClass

BaseService

dwInstance

DWORD

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