Replies: 1 comment
-
|
Yes, you can access data blocks on an S7-1200 with python-snap7. Make sure PUT/GET communication is enabled in TIA Portal (PLC properties → Protection & Security → Connection mechanisms → Permit access with PUT/GET). For data blocks (DB), use import snap7
client = snap7.Client()
client.connect("192.168.0.1", 0, 1)
# Read 100 bytes from DB1 starting at offset 0
data = client.db_read(1, 0, 100)Note: the DB must have Optimized block access disabled in TIA (right-click DB → Properties → Attributes → uncheck "Optimized block access"), otherwise S7 protocol cannot address the data by byte offset. For program blocks (OB, FC, FB), you can upload the compiled block bytecode with from snap7.type import Block
data = client.full_upload(Block.FC, 1)This gives you the raw block binary — useful for backup/comparison, but not a human-readable TIA project export. python-snap7 cannot read the TIA Portal project file itself, only what is on the PLC over the network. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
There are some program block in my TIA portal,is it possible to access it with Python-snap7?I am using plc 1200
Beta Was this translation helpful? Give feedback.
All reactions