import snap7
from snap7 import util
plc = snap7.client.Client()
plc.connect("192.168.1.40", 0, 2)
data = plc.db_read(db_number=1, start=0, size=10)
print("DBD0 als Real = ", util.get_real(data, 0))
print("DBD4 als DInt = ", util.get_dword(data, 4))
print("DBW8 als Int = ", util.get_int(data, 8))
plc.disconnect()
plc.destroy()
wdata = bytearray(10)
util.set_real(wdata, 0, 9.876)
util.set_dword(wdata, 4, 87654321)
util.set_int(wdata, 8, 4321)
plc.db_write(db_number=11, start=0, data=wdata)
danke,Du hast mit pip das Modul für Python 2.7 installiert, dein Programm ruft aber explizit die Python 3.7 auf.
Du musst dich für eine Python Version entscheiden. Wenn nichts zwingend dagegen spricht wie irgendwelche Legacy Module die nicht mehr aktualisiert werden, würde ich die 3er Version verwenden.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?