gijzelaerr / python-snap7

A Python wrapper for the snap7 PLC communication library
http://python-snap7.readthedocs.org/
MIT License
643 stars 246 forks source link

Util 'set_string' function error. #394

Closed xxBXSD closed 1 year ago

xxBXSD commented 1 year ago

In the latest version (1.2) there is an error in the util.py 'set_string' function. The code does not set the string length in the first byte as required by the Siemens string format. Add the following code to the end of the function to fix the problem:

set the max length of the string in the first byte

bytearray_[byte_index] = max_size
swamper123 commented 1 year ago

Your line of code was already implemented in #368 :

https://github.com/gijzelaerr/python-snap7/blame/076dbee171639b27d7179c9ce69f9444f5669067/snap7/util.py#L486

Try out the master branch, instead of pypi package.