FB_CUSTOM_SERVICE

FB_CUSTOM_SERVICE 1:

The function block FB_CUSTOM_SERVICE enables virtually any CIP services to be created by the user.

VAR_INPUT

VAR_INPUT
    sNetId               : T_AmsNetID;
    sIPv4Addr            : T_IPv4Addr;
    bExecute             : BOOL;
    nServiceCode         : BYTE
    nClass               : WORD;
    nInstance            : WORD;
    nAttribute           : WORD;
    pDst                 : POINTER TO BYTE;
    nMaxLen              : WORD;
    pSrc                 : POINTER TO BYTE;
    nSrcDataLen          : WORD;
    nSessionTimeoutMSec  : DWORD;
    nCmdTimeoutMSec      : DWORD;
    bRackComm            : BOOL;
    nPort                : BYTE;
    nSlot                : BYTE;
END_VAR

sNetId: AMSNetId of the TwinCAT EtherNet/IP scanner through which the command is to run

sIPv4Addr: IP address of the target device

bExecute: A positive edge starts the command

nServiceCode: Service code of the CIP service

nClasss: Class number of the CIP service

nInstance: Instance number of the CIP service

nAttribut: Attribute number of CIP service

pDst: Pointer to the variable to which the value is be copied (the pointer is determined with ADR)

nMaxLen: Size of the variable to which the pointer pDst points (determined with SizeOf)

pSrc: Pointer to the variable containing the value for sending the service (the pointer is determined with ADR)

nSrcDataLen: Size of the variable to which the pointer pSrc points (determined with SizeOf), or the number of bytes to be sent. Usually this is the size of the variable.

nSessionTimeoutMSec: Timeout for the session; the default is 30 seconds

nCmdTimeoutMSec: Timeout for the command; the default is 7.5 seconds

bRackComm: TRUE if the CPU is modular, i.e. a CPU with a rack design, for example a CompactLogix

nPort: Port number of the CPU (the TF6281 currently only supports port 1)

nSlot: Slot number if the CPU is not plugged into slot 0

VAR_OUTPUT

VAR_OUTPUT
    bBusy     : BOOL;
    bError    : BOOL;
    nErrId    : UDINT;
    nDataLen  : WORD;
END_VAR

bBusy: When the function block is activated this output is set. It remains set until a feedback is received. While Busy = TRUE, no new command will be accepted at the inputs.

bError: If an error should occur during the transfer of the command, then this output is set once the bBusy output was reset.

nErrId: If an bError output is set, this parameter supplies an error number.

nDataLen: Returns the number of valid data (number of bytes)