FB_EcGetLastProtErrInfo

FB_EcGetLastProtErrInfo 1:

FB_EcGetLastProtErrInfo gives additional error information about the last occurred mailbox protocol parameter.  An error-free mailbox command resets the last error each time.

VAR_INPUT

VAR_INPUT
    sNetId      : T_AmsNetId;  
    nSlaveAddr  : UINT;
    eProtocol   : E_EcMbxProtType := eEcMbxProt_FoE;
    bExecute    : BOOL;
    tTimeout    : TIME := DEFAULT_ADS_TIMEOUT;
END_VAR

sNetId: This is a string that contains the AMS network identifier of the EtherCAT master device.

nSlaveAddr: Fixed address of the EtherCAT slave, whose error information should be read.

eProtocol: EtherCAT Mailbox protocol type.

bExecute: The block is activated by a rising edge at this input.

tTimeout: Maximum time allowed for the execution of the function block.

VAR_OUTPUT

VAR_OUTPUT
    bBusy       : BOOL;
    bError      : BOOL;
    nErrId      : UDINT;
    info        : ST_EcLastProtErrInfo;       
END_VAR

bBusy: This output is set when the function block is activated and remains set until an acknowledgement is received.

bError: This output is set up after the bBusy output has been reset if there has been an error in transmission of the command.

nErrId: Supplies the ADS error code associated with the most recently executed command if the bError output is set.

info: Structure with additional error information.

Example in ST: 

Additional error information about the last occurred mailbox protocol error is read at an rising edge at bGet .

PROGRAM MAIN
VAR
    fbGetInfo : FB_EcGetLastProtErrInfo := ( sNetID := '172.16.6.195.2.1',
                        nSlaveAddr := 1004,
                        eProtocol := eEcMbxProt_FoE,
                        tTimeout := DEFAULT_ADS_TIMEOUT );
    bGet    : BOOL;
    bBusy   : BOOL;
    bError  : BOOL;
    nErrID  : UDINT;
    sInfo   : T_MaxString;
END_VAR
fbGetInfo(       bExecute:= bGet,
        bBusy=>bBusy,
        bError=>bError,
        nErrId=>nErrId );

sInfo := BYTEARR_TO_MAXSTRING( fbGetInfo.info.binDesc );

 

Requirements

Development Environment

Target System

PLC Libraries to include

TwinCAT v2.10.0 Build > 1307 or higher

PC or CX (x86)
CX (ARM)

TcEtherCAT.Lib
( Standard.Lib; TcBase.Lib; TcSystem.Lib, TcUtilities.Lib are included automatically )