Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Symbol auto_update does not work with structs #372

Open
ascaron37 opened this issue Mar 13, 2024 · 0 comments · May be fixed by #427
Open

Symbol auto_update does not work with structs #372

ascaron37 opened this issue Mar 13, 2024 · 0 comments · May be fixed by #427

Comments

@ascaron37
Copy link

When trying to set auto_update to a struct symbol, I receive following error:

  File "/home/.../app/adapters/ads_client.py", line 93, in init_variables
    symbol.auto_update = True
    ^^^^^^^^^^^^^^^^^^
  File "/home/.../lib/python3.11/site-packages/pyads/symbol.py", line 364, in auto_update
    self._auto_update_handle = self.add_device_notification(
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/.../lib/python3.11/site-packages/pyads/symbol.py", line 252, in add_device_notification
    attr = NotificationAttrib(length=sizeof(self.plc_type))
                                     ^^^^^^^^^^^^^^^^^^^^^
TypeError: this type has no size

I guess it has something to do, that a struct symbol has no plc_type. I think there should be a query if it is a structure or a native type like this:

        if attr is None:
            if self.is_structure:
                size_of_struct = pyads.size_of_structure(self.structure_def)
                attr = NotificationAttrib(length=size_of_struct)
            else:
                attr = NotificationAttrib(length=sizeof(self.plc_type))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant