POU ‘CheckPointer’¶
Monitoring function for pointers (Checkpointer)
Use this function to monitor the memory access of pointers in runtime mode. As opposed to other monitoring functions, a standard suggestion does not exist for the implementation of CheckPointer
. You must define an implementation according to your own requirements.
The CheckPointer
function should check whether the returned pointer references a valid memory address; monitors whether the orientation of the referenced memory range matches the variable type that the pointer refers to. If both conditions are fulfilled, then the pointer is returned. If not, then the function should complete an appropriate error handling.
Caution
To obtain the feature for monitoring functions, do not edit the declaration section. However, you are permitted to add local variables.
Attention
An implicit monitoring function call does not occur for THIS pointer and SUPER pointer.
Attention
For complier version 3.5.7.40 and later, the implicit check function Checkpointer also acts on REFERENCE
variables in the same way as on pointer variables.
Model
Declaration:
// Automatically generated code: DO NOT EDIT
FUNCTION CheckPointer : POINTER TO BYTE
VAR_INPUT
\ ptToTest : POINTER TO BYTE;
\ iSize : DINT;
\ iGran : DINT;
\ bWrite: BOOL;
END_VAR
Implementation: (incomplete)
// Not a standard implementation. Please add your own code here.
CheckPointer := ptToTest;
When the function is called, CODESYS provides the following input parameters:
ptToTest
: Target address of the pointeriSize
: Size of the referenced variable; the data type ofiSize
must be compatible withINT
and cover the dimensional scope of the variables.iGran
: Granularity of the referenced size; this is the largest non-structured data type contained in the referenced variables; the data type ofiGran
must be compatible withINT
bWrite
: Access type (TRUE
= write access,FALSE
= read access); the data type ofbWrite
must beBOOL
When the result of the check is positive, the unchanged pointer is returned (ptToTest
).
See also