You can add these special POUs to an application to equip them with implicit monitoring functions. At runtime, these functions check the limits of arrays or subrange types, the validity of pointer addresses, and division by zero. Please note: This option can be disabled for devices that are already equipped with these kinds of monitoring blocks by a special implicit library.
The command “Add Object POU for Implicit Checks” is used for adding to the application. The command opens the “Add POU for Implicit Checks” dialog where you can select a monitoring function type (see table below). Depending on the monitoring function, you have to adapt the implementation code or create it yourself from scratch.
To prevent multiple inclusions, monitoring functions that have already been inserted are disabled in the “Add POU for Implicit Checks” dialog.




NOTICE

To get the feature for monitoring functions, do not edit their declaration part. However, you are permitted to add local variables.
After removing an implicit monitoring function (example: Check Bounds
) from the project, only a download is possible, not an online change. A corresponding
message is issued.
By default, CODESYS does not run implicit checks for function blocks from libraries used in the application.
However, you can extend the check to the libraries by opening the “Properties” dialog of the application and specifying the compiler definition checks_in_libs
in the “Compiler-Defines” field in the “Build” tab. This definition affects implementation libraries (*.library
) only, not protected libraries (*.compiled-library
).
You can use the "no_check" attribute to deactivate the check for special POUs in the project.
Monitoring function |
Type |
---|---|
“Check Bounds” |
“Bound Checks” Appropriate handling of bound violations; such handling includes setting flags or changing field indices. |
“CheckDivDInt” |
“Division checks”: Monitors the divisor value to avoid division by zero. |
“CheckDivLInt” |
|
“CheckDivReal” |
|
“CheckDivLReal” |
|
“CheckRangeSigned” |
“Range checks”: Monitors the range limit of a subrange type in runtime mode. Valid for data types
|
“CheckRangeUnsigned” |
|
“CheckLRangeSigned” |
“L-range checks”: Monitors the range limit of a subrange type in runtime mode. Valid for data types
|
“CheckLRangeUnsigned” |
|
“CheckPointer” |
“Pointer checks” You are responsible for filling in this function completely with implementation code.
Refer to the help page for "POU 'CheckPointer'". The function should monitor whether
the passed pointer reference a valid memory address, and whether 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 |
See also