问题
could anyone please help me with more information about how pointers, references and interface references behave during an online change?
What do I have do watch out for? I understand from other answers that pointers may be dangerous if these are not written during each cycle, but I will primarily use Interfaces and References.
回答1:
When an online change is made, variables, function blocks and other program parts may move in a different memory location. Therefore, if the pointer address is old information, it might refer to a memory address containing something else.
So if the pointers are used, they should be updated regularly with the ADR command, like you said.
When using references and interfaces, I don't see any problems with online change because the system should handle them automatically. In TwinCAT 3, the system will readdress variables automatically (source: https://infosys.beckhoff.com/english.php?content=../content/1033/tc3_plc_intro/9007199390694027.html&id=) and because it is Codesys based, I think it is the same with other systems.
When using references, it might be a good idea to check that the reference is valid. In TwinCAT 3 there is a function __ISVALIDREF
and it should be also in other Codesys based systems.
来源:https://stackoverflow.com/questions/45781814/pointer-and-reference-behavour-during-online-change