util.set_string doesn't provide a max. char size (Byte 0) which leads to undefined behaviour on SPS side (seems that DB breaks partly).
Two changes are needed:
1) bytearray_[byte_index + 1] = max_size has to be added.
2) for r in range(i + 1, bytearray_[byte_index]): has to be changed to for r in range(i + 1, bytearray_[byte_index] - 2):, so that no out of range error appears.
This would fix the wrong behaviour, PR will income soon.
In #291 was an error mentioned, which I have now as well.
https://github.com/gijzelaerr/python-snap7/blob/5b1fa247e6efab34b4af5fec77d5926293305d10/snap7/util.py#L414
util.set_string
doesn't provide a max. char size (Byte 0) which leads to undefined behaviour on SPS side (seems that DB breaks partly).Two changes are needed:
1)
bytearray_[byte_index + 1] = max_size
has to be added. 2)for r in range(i + 1, bytearray_[byte_index]):
has to be changed tofor r in range(i + 1, bytearray_[byte_index] - 2):
, so that no out of range error appears.This would fix the wrong behaviour, PR will income soon.