diff --git a/pyads/connection.py b/pyads/connection.py index 4e02e93..fd0f813 100644 --- a/pyads/connection.py +++ b/pyads/connection.py @@ -50,7 +50,6 @@ ads_type_to_ctype, PLCSimpleDataType, PLCDataType, - STRING_BUFFER, ) from .filetimes import filetime_to_dt from .pyads_ex import ( @@ -449,7 +448,7 @@ def get_all_symbols(self) -> List[AdsSymbol]: symbol_size_msg = self.read( ADSIGRP_SYM_UPLOADINFO2, ADSIOFFS_DEVDATA_ADSSTATE, - PLCTYPE_STRING * STRING_BUFFER, + PLCTYPE_STRING, return_ctypes=True, ) sym_count = struct.unpack("I", symbol_size_msg[0:4])[0] diff --git a/pyads/pyads_ex.py b/pyads/pyads_ex.py index bec56a9..b39edb7 100644 --- a/pyads/pyads_ex.py +++ b/pyads/pyads_ex.py @@ -840,7 +840,11 @@ def adsSyncReadReqEx2( index_offset_c = ctypes.c_ulong(index_offset) # Strings were handled specifically before, but their sizes are contained and we - # can proceed as normal: + # can proceed as normal + if data_type == PLCTYPE_STRING or data_type == PLCTYPE_WSTRING: + # This implies a string of size 1, which is so are we instead use a large fixed + # size buffer: + data_type = data_type * STRING_BUFFER data = data_type() data_pointer = ctypes.pointer(data)