DB_write Issue in Snap7 #291
Replies: 3 comments 17 replies
-
The first two bytes in the 'String' data type contain additional information about the size of the string. You should use
|
Beta Was this translation helpful? Give feedback.
-
Please help me, I'm new to this topic: When I execute the following instructions: plc_info = plc.get_cpu_info() I get an error: b'CPU : Item not available' Does anyone have any idea about this problem? |
Beta Was this translation helpful? Give feedback.
-
Hi all, I have the same problem. In particular I would use the client.full_upload("DB", 100) function with SIEMENS 1200 but the function seems not available |
Beta Was this translation helpful? Give feedback.
-
While writing String from my Python application to TIA Portal, I am not getting the exact string in my TIA portal as well as in Python program as attached. Where as it is working fine in case of read operation. Can anyone help me out?It is getting random values.
Python Code-
import snap7
IP='192.168.0.1'
RACK=0
SLOT=1
DB_NUMBER=100
START_ADDRESS=1
SIZE=259
plc=snap7.client.Client()
plc.connect(IP,RACK,SLOT)
plc_info=plc.get_cpu_info()
print(f'Module Type: {plc_info.ModuleTypeName}')
print(f'State: {plc.get_cpu_state()}')
db=plc.db_read(DB_NUMBER,START_ADDRESS,SIZE)
plc.db_write(DB_NUMBER, START_ADDRESS, b'Python to TIA')
product_name=db[0:255].decode('UTF-8').strip('\x00')
print(f'Product Name: {product_name}')
product_value=int.from_bytes(db[255:257], byteorder='big')
print(f'Product Value: {product_value}')
product_status=bool(db[257])
print(f'Product Status: {product_status}')
Python Output-
Module Type: b'CPU 1510SP-1 PN'
State: S7CpuStatusRun
Product Name: �TIA Portal to Python // problem in writing this output
Product Value: 14
Product Status: True
Beta Was this translation helpful? Give feedback.
All reactions