Supported platforms: CODESYS 3.5, CODESYS 3.5 SAFETY

 

S_ValidateSafetyParameterIndex (FUN)

Description

This function validates checksum of a CANopen parameter index. The function shall be used to check all safety related parameter indices at unit start-up. The function uses CalculateParameterIndexCRC function for calculation.

 

MultiTool Creator code template includes safety parameter validation automatically.

 

This function is endianness-aware, but given CRC must be already in big-endian format. The CRC is compared to big-endian result of CalculateParameterIndexCRC.

 

Operation

The function calculates checksum of given parameter data array. The checksum is compared to given CRC. If checksums match, the output value o_OutputValid is set TRUE, and error code is not added to the pointed EventCode.

 

Limitations

Supported parameter types described in CalculateParameterIndexCRC.

 

Inputs

Input variable name

Data type

Range

Description

i_pData

POINTER TO BYTE

≠ 0

Pointer to parameters.

i_pCRC

POINTER TO WORD

≠ 0

Pointer to checksum to be compared with calculated checksum.

i_DataType

ENUM

ParameterDataType

Parameter index data type.

i_NumberOfIndices

USINT

-

Number of parameters in index.

i_pEventCode

POINTER TO EventCode

≠ 0

Pointer to EventCode variable

 

Outputs

Output variable name

Data type

Range

Description

o_OutputValid

BOOL

TRUE/FALSE

Calculated value is valid.

o_ParameterError

BOOL

TRUE/FALSE

Error in input parameters.

Return value

Data type

Description

SAFEBOOL

TRUE = Checksum match

FALSE = Checksum mismatch or calculation failure

Error diagnostic

See Diagnostic Interface library description of error status and event code functionality.

 

Conditions

Return value

o_OutputValid

o_ParameterError

Event code FunctionID

Event code EventID

i_pData = 0 OR

i_pCRC = 0 OR

i_NumberOfIndices = 0

FALSE

FALSE

TRUE

VALIDATE_ SAFETY_ PARINDEX

PARAMETER_ERROR

i_pEventCode = 0

FALSE

FALSE

TRUE

-

-

parameters ok AND

calculated crc match with given value

TRUE

TRUE

FALSE

NO_FUNC

NO_ERROR

parameters ok AND

calculated crc mismatch with given value

FALSE

TRUE

FALSE

VALIDATE_ SAFETY_ PARINDEX

DATA_MISMATCH

 

Example code

 

Definitions:

 

SafetyParameterIndexCRCs: ARRAY[0..1] OF WORD := [2(WORD#0)];

 

Index2200: ARRAY[0..24] OF INT := [25(INT#0)];

Index2201: ARRAY[0..37] OF UDINT := [38(UDINT#0)];

 

 

Safe definitions:

 

(* Validator output ststuses *)

sparvalid: BOOL;

sparerror: BOOL;

EC_ParameterValidation: EPEC_DITF.EventCode;

 

 

Init:

 

EC_ParameterValidation.DeviceID := DeviceIDs.ParameterValidation;

EC_ParameterValidation.ChannelID := ChannelIDs.Ch1;

EC_ParameterValidation.FunctionID := EPEC_DITF.FunctionIDs.NO_FUNC;

EC_ParameterValidation.EventID := EPEC_DITF.ErrorIDs.NO_ERROR;

 

 

 

Code:

 

S_SafetyParametersValid := EPEC_SDV.S_ValidateSafetyParameterIndex(

    i_pData := ADR(Index2200),

    i_NumberOfIndices := USINT#25,

    i_DataType := EPEC_SDV.ParameterDataType.Deftype_INTEGER16,

    i_pCRC := ADR(SafetyParameterIndexCRCs[0]),

    i_pEventCode := ADR(EC_ParameterValidation),

    o_ParameterError => sparerror,

    o_OutputValid => sparvalid

);

 

IF S_SafetyParametersValid THEN

    S_SafetyParametersValid := EPEC_SDV.S_ValidateSafetyParameterIndex(

        i_pData := ADR(Index2201),

        i_NumberOfIndices := USINT#38,

        i_DataType := EPEC_SDV.ParameterDataType.Deftype_UNSIGNED32,

        i_pCRC := ADR(SafetyParameterIndexCRCs[1]),

        i_pEventCode := ADR(EC_ParameterValidation),

        o_ParameterError => sparerror,

        o_OutputValid => sparvalid

    );

END_IF

 

 

See also

 

 

 

 

 

Source file topic100389.htm

Last updated 13-Jun-2024