Skip to content

Commit fd78232

Browse files
committed
fix symbol info for function block properties with monitoring = call #261
1 parent 4bdfef5 commit fd78232

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

pyads/symbol.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,14 @@ def _create_symbol_from_info(self) -> None:
162162
info = adsGetSymbolInfo(self._plc._port, self._plc._adr, self.name)
163163

164164
self.index_group = info.iGroup
165-
self.index_offset = info.iOffs
165+
if self.index_group == 0xF019:
166+
# For function block properties with monitoring = call
167+
# get symbol using handle instead
168+
self.index_group = constants.ADSIGRP_SYM_VALBYHND
169+
self.index_offset = self._plc.get_handle(self.name)
170+
else:
171+
self.index_offset = info.iOffs
172+
166173
if info.comment:
167174
self.comment = info.comment
168175

@@ -230,6 +237,8 @@ def __repr__(self) -> str:
230237
def __del__(self) -> None:
231238
"""Destructor"""
232239
self.clear_device_notifications()
240+
if self.index_group == constants.ADSIGRP_SYM_VALBYHND:
241+
self._plc.release_handle(self.index_offset)
233242

234243
def add_device_notification(
235244
self,

0 commit comments

Comments
 (0)