In the Advanced IEC Check Library are String[4] used in the Check Range for enums Function and others. This does not work for all DINT values and can caus a Pagefault for values > 9999.
Is there a Repo somewhere, where I can push a fix?
Thanks for sharing this discovery! Unfortunately, I don’t think that this library is stored on any repositories (at least not any of the public B&R ones I know). Maintaining a repository for this sounds like a great idea though. I’ll put it on my list of items to work on in my “free time”.
If you have an updated version that you’d like to share, feel free to post it here though!
I’m happy to do a MR with my changes.
I don’t think it’s my right to publish the complete code in a repository of mine, because I didn’t write it and it’s initaly shipped with AS.
I’ve been working on an updated version of this library. It addresses the issue that Explain5972 found and also adds some additional features. I don’t have it hosted publicly yet, but I can share it here if you want to test it out. If you do, take a look at the ReadMe for some helpful info, and please provide feedback if you have any!
Thanks for posting! In your Automation Studio project, go to Project → Settings. Then go to the IEC compliance tab and check the “Allow preprocessor directives” box.
I’ll make sure to update the documentation; I forgot that this setting isn’t on by default.
Thank you for sharing the updated AdvIECCheck library. However, I am experiencing an issue with the new library where it will cause a page fault on a variable with enum type. According to the information provided by the library in the logger, it looks like the library triggered the page fault because it thinks that the variable is out of the enum range, even though the VALUE of the variable is still within the enum range. I suspect that the library is using the variable ADDRESS to check against the enum range instead of using the value of the variable since I have the variable connecting to a VAR_IN_OUT parameter on a function block.
After I removed the AdvIECCheck library from the project and download it to the PLC, I don’t have a page fault crash anymore. However, I would like to have the AdvIECCheck library added to my project in case a page fault occurs.
I can provide the project if you need to troubleshoot. Thanks.
Thanks for sharing! This is actually really interesting.
The function that’s called to check an enumeration value is CheckRange. I’ve modified the implementation of that function for this library, but the compiler actually determines when that function is called and what values are passed during normal operation, so I can’t change that.
I agree that it looks like the function is being passed an address. In fact, this should not be happening because of a line in the documentation for the CheckRange function:
When calling functions and function blocks, CheckRange is not called when the actual parameters are assigned to VAR_IN_OUT parameters.
Even more strangely, I can only replicate this if I call a function block from a Function Block Diagram program. If I call a function block containing a VAR_IN_OUT input from a Structured Text program, everything is fine. This is the case with both the stock IecCheck library as well as the AdvIecCheck library.
I’m not sure if this is a known issue or not, but I’ll try to find out and report back. In the meantime, is it possible to use a different program type to call this function? If not, you could also comment out the CheckRange implementation until a fix is found. This means your enumeration values won’t be checked, but it does allow the rest of the functions to run normally.