Supported platforms: CODESYS 3.5, CODESYS 3.5 SAFETY, CODESYS 3.5 SP19 SAFETY
This function checks if given response code match with challenge code.
|
|
Multitool Creator code template includes access code validation automatically. |
|
|
This function is endianness-aware, but given response code must be already in big-endian format. The response code is compared to big-endian result of CalculateAccessCode. |
The function calculates checksum using CalculateAccessCode function. The calculated sum is compared to given i_ResponseCode. If the codes match, output value o_OutputValid is set TRUE, and error code is not added to the pointed EventCode.
|
Input variable name |
Data type |
Range |
Description |
|
i_ChallengeCode |
WORD |
- |
Challenge code to be compared. |
|
i_ResponseCode |
WORD |
- |
Response code to be compared. |
|
i_ProjectKey |
STRING(80) |
- |
Data for code encryption. |
|
i_pEventCode |
POINTER TO EventCode |
≠ 0 |
Pointer to EventCode variable. |
|
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. |
|
Data type |
Description |
|
SAFEBOOL |
TRUE = Signature ok FALSE = Signature mismatch or calculation failure |
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 |
|
Length of i_ProjectKey = 0 |
FALSE |
FALSE |
TRUE |
VALIDATE_ ACCESS_CODE |
PARAMETER_ERROR |
|
i_pEventCode = 0 |
FALSE |
FALSE |
TRUE |
- |
- |
|
parameters ok AND response code match with encrypted challenge code |
TRUE |
TRUE |
FALSE |
NO_FUNC |
NO_ERROR |
|
parameters ok AND response code mismatch with encrypted challenge code |
FALSE |
TRUE |
FALSE |
VALIDATE_ ACCESS_CODE |
DATA_MISMATCH |
|
Non-safe Definitions: |
|
|
(* Challenge code and response mapped to OD *) (* 16#21FE Challenge code for safety parameter editing *) ChallengeCode : WORD := WORD#0; (* 16#21FF Response code for safety parameter editing *) ResponseCode : WORD := WORD#0;
|
|
|
Safe definitions: |
|
S_ValidationOk : SAFEBOOL:=FALSE; ParameterError: BOOL; OutputValid: BOOL; EC_ValidateAccessCode:EPEC_DITF.EventCode;
|
|
Init at safe PRG: |
|
EC_ValidateAccessCode.DeviceID := 16#C0; EC_ValidateAccessCode.ChannelID := BYTE#0; EC_ValidateAccessCode.FunctionID := EPEC_DITF.FunctionIDs.VALIDATE_ACCESS_CODE; EC_ValidateAccessCode.EventID := EPEC_DITF.ErrorIDs.NO_ERROR;
|
|
Code at safe PRG: |
|
S_ValidationOk:=S_ValidateAccessCode( i_ChallengeCode:=ChallengeCode, i_ResponseCode:=ResponseCode, i_ProjectKey:='MyProjectKey', i_pEventCode:=ADR(EC_ValidateAccessCode), o_ParameterError => ParameterError, o_OutputValid => OutputValid );
|
CalculateAccessCode (FUN)
Source file topic100398.htm
Last updated 4-Sep-2025