FB_SoEReadDiagNumberList_ByDriveRef

FB_SoEReadDiagNumberList_ByDriveRef 1:

The functionblock FB_SoEReadDiagNumberList_ByDriveRef can be used to read the history of the diagnose numbers as a list (S-0-0375).  

VAR_INPUT

VAR_INPUT
    stDriveRef   : ST_DriveRef; 
    bExecute     : BOOL; 
    tTimeout     : TIME := DEFAULT_ADS_TIMEOUT;
    piDiagNumber : POINTER TO ST_SoE_DiagNumList;
    iSize        : UDINT;
END_VAR

stDriveRef: The drive reference can be linked in the System Manager between PLC and drive. The link can be done to an instance of the ST_PlcDriveRef. The structure ST_PlcDriveRef contains the NetID as byte array. The byte array can be converted to a string. See ST_DriveRef.

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

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

piDiagNumber: Pointer to the list of the last max. 30 error numbers. The list consists of the actual and maximum number of bytes in the list, and of the last 30 list entries

iSize: Size of the list in bytes (as Sizeof())

VAR_OUTPUT

VAR_OUTPUT
    bBusy        : BOOL;
    bError       : BOOL;
    iAdsErrId    : UINT;
    iSercosErrId : UINT;
    dwAttribute  : DWORD;
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.

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

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

dwAttribute: Supplies the attribut of the Sercos parameter.

Sample

fbDiagNumberList     : FB_SoEReadDiagNumberList_ByDriveRef;
bDiagNumberList      : BOOL;
stDiagNumberList     : ST_SoE_DiagNumList;
stPlcDriveRef AT %I* : ST_PlcDriveRef;
stDriveRef           : ST_DriveRef;

IF bInit THEN
    stDriveRef.sNetId     := F_CreateAmsNetId(stPlcDriveRef.aNetId);
    stDriveRef.nSlaveAddr := stPlcDriveRef.nSlaveAddr;
    stDriveRef.nDriveNo   := stPlcDriveRef.nDriveNo;
    stDriveRef.nDriveType := stPlcDriveRef.nDriveType;

    IF (stDriveRef.sNetId <> '') AND (stDriveRef.nSlaveAddr <> 0) THEN
        bInit := FALSE;
    END_IF
END_IF

IF bDiagNumberList AND NOT bInit THEN
    fbDiagNumberList(
        stDriveRef := stDriveRef,
        bExecute := TRUE,
        tTimeout := DEFAULT_ADS_TIMEOUT,
        piDiagNumber:= ADR(stDiagNumberList),
        iSize := SIZEOF(stDiagNumberList),
    );

    IF NOT fbDiagNumberList.bBusy THEN
        fbDiagNumberList(stDriveRef := stDriveRef, bExecute := FALSE);

        bDiagNumberList := FALSE;
    END_IF
END_IF