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.
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