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 or not the passed pointer references a valid memory address, and whether or not the orientation of the referenced memory area matches the variable type to which the pointer refers. If both conditions are fulfilled, then the pointer is returned. If not, then the function should complete an appropriate error handling.
Caution
To get the feature for monitoring functions, do not edit the declaration part. However, you are permitted to add local variables.
Important
An implicit monitoring function call does not occur for THIS pointer and SUPER pointer.
Important
In compiler version 3.5.7.40 and higher, the CheckPointer also affects REFERENCE variables the same as pointer variables.
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_VARImplementation: (incomplete)
// Not a standard implementation. Insert your code here. CheckPointer := ptToTest;
ptToTest: Target address of the pointeriSize: Size of the referenced variable; the data type ofiSizemust be compatible withINTand cover the dimensional scope of the variablesiGran: Granularity of the referenced size; this is the largest non-structured data type contained in the referenced variables; the data type ofiGranmust be compatible withINTbWrite: Access type (TRUE= write access,FALSE= read access); the data type ofbWritehas to beBOOL
When the result of the check is positive, the unchanged pointer is returned (ptToTest).