-
-
Notifications
You must be signed in to change notification settings - Fork 246
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
set_string not working correctly #54
Comments
Sorry, my fault, I was doing something wrong. Ignore this. |
I spend significant time making sure writing strings is done safely. |
Are you aware that there are two types of strings in the S7 series? The String type is preceded by 2 bytes. Byte one is the maximum string length, byte 2 is the actual string length. I believe your string function does nothing with byte one, only byte 2 is written? |
no I had no need for the character array so i have not encountered it. The reason I don't write the first byte is is that the first byte value (max_size) is set by the siemens step7 project and snap7 / python should under no circumstance change the first byte!! The max size is given to the function set_string for two reasons. 1 to make sure you know about what you put in and 2 set_string function among others is user by the DB class to edit large a object. The DB object expects a specification / layout of the data and in it the max string size is also specified. |
I try to use set_string in a byte array, but only the first 2 characters are written correctly, the rest is garbled. For example, when I use: set_string(db10, 0, 'abcd')
and I read it back with get_string, I get: 'ab@I'
Also, the docstring mentions a size argument that is not present..
The text was updated successfully, but these errors were encountered: