stlehmann / pyads

Python wrapper for TwinCAT ADS
MIT License
254 stars 94 forks source link

Support WSTRING in structures. #291

Closed stlehmann closed 2 years ago

stlehmann commented 2 years ago

WSTRINGS are supported since version 3.3.9. Structure handling should also support this. This should mainly affect the functions dict_from_bytes and bytes_from_dict. Also some testing needs to be added.

stlehmann commented 2 years ago
if plc_datatype == PLCTYPE_STRING:
                    if str_len is None:
                        str_len = PLC_DEFAULT_STRING_SIZE
                    var_array.append(
                        bytearray(byte_list[index: (index + (str_len + 1))])
                        .partition(b"\0")[0]
                        .decode("utf-8")
                    )
                    index += str_len + 1
if plc_datatype == PLCTYPE_WSTRING:
    .... 
stlehmann commented 2 years ago

Solved with #293