Comments (4)
Sorry, my fault, I was doing something wrong. Ignore this.
from python-snap7.
I spend significant time making sure writing strings is done safely.
There was a serious bug where the set_string function did not check if the input string fitted in the intended space and just used some extra memory in the plc if the string was too big.. oops..
from python-snap7.
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?
But the other type is a character array, that can start anywhere in a DB and has no preceding bytes...
This type has no functions for it to read or write...
from python-snap7.
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!!
By setting the actual string size it was still needed for the functions to clear's out the rest of the bytes with ' ' empty space to make it work correctly and prevent weird string values to show 'newvalue_partoflargeroldstring' on the siemen screens.
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.
The DB object makes it possible to use a DB in a PLC like a Dict in Python but it is rather hard to setup correctly and I don't know how to make it any more easy..
from python-snap7.
Related Issues (20)
- Too much logging in client db_read() method HOT 2
- PLC crashed when executing the "get_cpu_info" function HOT 1
- How to read and write values of type bool using snap7 module?
- Can not use this library to read timers of simatic S7-200 smart PLC HOT 2
- Redundant 400-H get_cpu_state() returning incorrect value.
- Add python 3.12 support, build wheels HOT 2
- RuntimeError: b' ISO : An error occurred during recv TCP : Connection timed out'
- Error in util.Set_String and util.Get_String
- as_db_read() doesnt work
- Wrong values set_lreal
- db[0]['x']=22.33 raises ValueError HOT 2
- Improve doc for area_read in client HOT 2
- Communication between PLC and PC HOT 1
- Can't read from S210 Drive
- Get data block layout
- TypeError: '_ctypes.PyCArrayType' object is not subscriptable HOT 1
- Make client and server a contextmanager HOT 1
- Drop Python 3.8 from metadata and doc HOT 1
- Drop Snap7Library singleton and use python functools caching HOT 1
- version 1.4 broken on python 3.8 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-snap7.