I currently have a challenge. I have a library with some communication classes. These communication classes need to be linked to an interface like this:
This is executed via a FB_Init() method. When I try to do this in a program this works fine. But when I declare the FB_Init() in the library the FB_Init() method is being called but the link is not made (interface still has the value 0000000000). The Objects and interfaces are defined in the library (GVL), so Iβm assuming the data should be there.
When I call the FB_Init method explicitly in the program it also works fine.
Whys is this not working when it is all defined in the library? And is it even possible to create a structure like this in Codesys?
Kind regards
Alex
Last edit: alexgooi 2024-05-22
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Dear Forum,
I currently have a challenge. I have a library with some communication classes. These communication classes need to be linked to an interface like this:
Devices_and_controllers.Comm_Frame.Modbus_GVL_Link.KNX_TCP[Interface_Index] := THIS^;
This is executed via a FB_Init() method. When I try to do this in a program this works fine. But when I declare the FB_Init() in the library the FB_Init() method is being called but the link is not made (interface still has the value 0000000000). The Objects and interfaces are defined in the library (GVL), so Iβm assuming the data should be there.
When I call the FB_Init method explicitly in the program it also works fine.
Whys is this not working when it is all defined in the library? And is it even possible to create a structure like this in Codesys?
Kind regards
Alex
Last edit: alexgooi 2024-05-22
I think the attribute here will help you: https://content.helpme-codesys.com/en/CODESYS%20Development%20System/_cds_pragma_attribute_global_init_slot.html
https://content.helpme-codesys.com/en/CODESYS%20Development%20System/_cds_global_init_slots.html
Hi Paro, I have tried this and it seemed to have solved the problem, thank you very much!