Closed janwilch closed 4 months ago
Hello, thank you for your question. In order to assist with issue management, please keep the issue tracker reserved for bugs and feature requests. For any questions, particularly around usage, route creation and ads error messages when reading or writing variables, please use Stack Overflow tagging the question with twincat-ads and state you are using the pyads library. Thanks.
However, to answer your question here, I am not sure what you want to do is supported, as you say the structure definition wants consecutive bytes therefore the way you have defined it assumes you have a bool, and a lreal and a string one byte aligned. Structures must also be declared this way in the PLC. I am also not sure how the PLC represents a UNION of these 3 types underneath, you may find that it takes the largest of the datatypes, therefore you could just declare your structure def in python as only a string? You may have to experiment or if possible change to not read a structure. I am also not sure if just reading a union as read_by_name what you would get either...
I am closing this issue here and please ask if you need further support to post on stack overflow. Thanks.
I'm trying to use read_structure_by_name to read a STRUCT containing a UNION from the PLC. It seems this does not work properly because pyads interprets the structure_def as purely consecutive bytes, when the bytes on the PLC are in fact "overlapping" (I'm not sure about the exact data structure).
I would be very grateful if you could look into that and maybe have some suggestion for me!
TwinCAT type definitions
Python code
Expected output
Actual output