Supported platforms: CODESYS 3.5, CODESYS 3.5 SAFETY
This function validates safety configuration signature of one SRDO message.
The function shall be used to validate safety configuration signatures of all SRDOs at unit start-up.
Signature calculation is described in CANopen safety standard EN50325-5. |
Unlike all other CRCs, safety configuration signature is specified to be calculated little-endian. |
This function is endianness-aware. Separate endian format conversions shall NOT be used. |
MultiTool Creator code template includes signature validation automatically. |
The function uses CalculateSRDOSignature function for calculation of signature.
If the calculated signature match with given value, output o_OutputValid is set TRUE, and error code is not added to the pointed EventCode.
Input variable name |
Data type |
Unit |
Range |
Description |
i_pSRDOSignature |
POINTER TO WORD |
- |
≠ 0 |
Pointer to SRDO safety configuration signature variable |
i_InfoDirection |
BYTE |
- |
0 - 2 |
0 = not valid 1 = SRDO producer 2 = SRDO consumer |
i_SCTime |
UINT |
ms |
- |
Safety Cycle Time / Refresh Time of SRDO |
i_SRVTime |
USINT |
ms |
- |
Safety-Related Validation Time of SRDO |
i_COBID1 |
DWORD |
- |
101h - 17Fh, odd values only |
Plain SRDO message COB-ID |
i_COBID2 |
DWORD |
- |
102h – 180h, even values only |
Inverted SRDO message COB-ID |
i_Mappings |
USINT |
- |
> 0 |
Number of variable mappings of one SRDO message |
i_pMapping |
POINTER TO BYTE |
- |
≠ 0 |
Pointer to variable mapping table of one SRDO message |
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 |
i_pSRDOSignature = 0 OR i_pMappingParameter = 0 OR i_Mappings = 0 OR i_InfoDirection out of range OR i_COBID1 out of range OR i_COBID2 out of range |
FALSE |
FALSE |
TRUE |
VALIDATE_ SRDO_ SIGNATURE |
PARAMETER_ERROR |
i_pEventCode = 0 |
FALSE |
FALSE |
TRUE |
- |
- |
parameters ok AND inputs match |
TRUE |
TRUE |
FALSE |
NO_FUNC |
NO_ERROR |
parameters ok AND inputs mismatch |
FALSE |
TRUE |
FALSE |
VALIDATE_ SRDO_ SIGNATURE |
DATA_MISMATCH |
Definitions at global variable list G_CAN1_TSRDO: |
|
(*NOTE! This object is created by Epec MultiTool*)
/// Plain SRDO variables tdw1 AT %MD0: DWORD := DWORD#16#0; tdw2 AT %MD1: DWORD := DWORD#16#0;
/// Inverted SRDO variables tdw1_i AT %MD2: DWORD := DWORD#16#0; tdw2_i AT %MD3: DWORD := DWORD#16#0;
/// Plain SRDO variable timestamps tdw1_TIME: UDINT := UDINT#0; tdw2_TIME: UDINT := UDINT#0;
/// Inverted SRDO variable timestamps tdw1_i_TIME: UDINT := UDINT#0; tdw2_i_TIME: UDINT := UDINT#0;
|
Definitions at global variable list G_CANopen_CAN1: |
|
(*NOTE! This object is created by Epec MultiTool Creator*)
/// SRDO SRDO: EPEC_CANopen.SRDOData; (* Protocol data *) SRDOS: ARRAY[1..2] OF EPEC_CANopen.CANopenSRDO; (* SRDO instances *) SRDO_Handler: EPEC_CANopen.CANopenSRDOHandler; (* Protocol handler *) SRDO_Error: EPEC_CANopen.Errors := EPEC_CANopen.Errors.NotInitialized; SRDO_Triggers: ARRAY[1..2] OF BOOL; SRDO_Signatures: ARRAY[1..2] OF WORD; SRDO_EventCodes: ARRAY[1..2] OF EPEC_DITF.EventCode;
|
Definitions at global variable list G_CANopen_CAN1_Mappings: |
|
(*NOTE! This object is created by Epec MultiTool Creator*)
/// SRDO variable mappings SRDO1Mappings: ARRAY [1..G_CANOPEN_NUMBER_OF_LAST_SRDO_MAP*2] OF DWORD := [ DWORD#16#5FD60120, (* G_CAN1_TSRDO.tdw1 *) DWORD#16#5FD50120, (* G_CAN1_TSRDO.tdw1_i *) DWORD#16#5FD60220, (* G_CAN1_TSRDO.tdw2 *) DWORD#16#5FD50220, (* G_CAN1_TSRDO.tdw2_i *) 12(DWORD#16#0)]; (* 16 - 4 = 12 *)
|
SRDO protocol initialization at non-safe Init_CANopen_CAN1 (PRG): |
|
(*NOTE! This object is created by Epec MultiTool Creator*)
(*Define SRDO protocol*) G_CANopen_CAN1.Protocols[6].Protocol:=EPEC_CANopen.ProtocolType.SRDO; G_CANopen_CAN1.Protocols[6].pData:=ADR(G_CANopen_CAN1.SRDO); G_CANopen_CAN1.Protocols[6].itfProtocol:=G_CANopen_CAN1.SRDO_Handler; G_CANopen_CAN1.Protocols[6].pError:=ADR(G_CANopen_CAN1.SRDO_Error); G_CANopen_CAN1.ProtocolAdded[6] := CANopenDeviceAddProtocol( (* Add to protocol stack *) i_pDevice:=ADR(G_CANopen_CAN1.Device), i_pProtocol:=ADR(G_CANopen_CAN1.Protocols[6]) ); IF G_CANopen_CAN1.ProtocolAdded[6] THEN G_CANopen_CAN1.SRDO_Handler.Init( i_pDevice := ADR(G_CANopen_CAN1.Device) ); ELSE G_CANopen_CAN1.SRDO_Error := EPEC_CANopen.Errors.ProtocolDataMissing; END_IF
SRDO initialization at non-safe Init_CANopen_CAN1 (PRG):
(* Init SRDOs *) G_CANopen_CAN1.SRDOS[1].i_pTimings[1]:= ADR(G_CAN1_TSRDO.tdw1_TIME); (*tdw1 *) G_CANopen_CAN1.SRDOS[1].i_pTimings[2]:= ADR(G_CAN1_TSRDO.tdw1_i_TIME); (*tdw1_i *) G_CANopen_CAN1.SRDOS[1].i_pTimings[3]:= ADR(G_CAN1_TSRDO.tdw2_TIME); (*tdw2 *) G_CANopen_CAN1.SRDOS[1].i_pTimings[4]:= ADR(G_CAN1_TSRDO.tdw2_i_TIME); (*tdw2_i *) G_CANopen_CAN1.SRDOS[1].Init( i_pDevice := ADR(G_CANopen_CAN1.Device), i_SRDONumber := 1, i_SRDOType := EPEC_CANopen.SRDOType.TransmitSRDO, i_SCTime := UINT#25, (* TSRDO Refresh Time (ms) *) i_SRVTime := USINT#0, (* Validation time (rx) (ms) *) i_COB_ID1 := DWORD#16#101, (* Plain message COB-ID *) i_COB_ID2 := DWORD#16#102, (* Inverted message COB-ID *) i_Mapping := G_CANopen_CAN1_Mappings.SRDO1Mappings, (* Plain + Inverted data mappings *) i_Mappings := 4, (* Plain + Inverted data mappings *) o_Error => G_CANopen_CAN1.SRDO_Error );
|
Definitions: |
srdoerror: BOOL; srdovalid: BOOL; SignatureValid: BOOL := FALSE; SignatureError: BOOL := FALSE;
S_SRDOValid: SAFEBOOL := FALSE;
|
Code: |
SignatureValid := TRUE; S_SRDOValid := TRUE;
FOR i := UINT#1 TO SIZEOF(G_CANopen_CAN1.SRDOS)/SIZEOF(G_CANopen_CAN1.SRDOS[1]) DO
S_SRDOValid := S_SRDOValid AND EPEC_SDV.S_ValidateSRDOSignature ( i_pSRDOSignature := ADR(G_CANopen_CAN1.SRDO_Signatures[i]), i_InfoDirection := G_CANopen_CAN1.SRDOS[i].i_SRDOType, i_SCTime := G_CANopen_CAN1.SRDOS[i].i_SCTime, i_SRVTime := G_CANopen_CAN1.SRDOS[i].i_SRVTime, i_COBID1 := G_CANopen_CAN1.SRDOS[i].i_COB_ID1, i_COBID2 := G_CANopen_CAN1.SRDOS[i].i_COB_ID2, i_Mappings := G_CANopen_CAN1.SRDOS[i].i_Mappings, i_pMappingParameter := ADR(G_CANopen_CAN1.SRDOS[i].i_Mapping), i_pEventCode := ADR(G_CANopen_CAN1.SRDO_EventCodes[i]), o_ParameterError => srdoerror, o_OutputValid => srdovalid ); (* calculation status *) SignatureValid := SignatureValid AND srdovalid; SignatureError := SignatureError OR srdoerror;
END_FOR
|
CalculateSRDOSignature (FUN)
Source file topic100387.htm
Last updated 19-Dec-2024