I am trying to communicate Python with the CPU1212C PLC (using PLCSIM), but an error always occurs.
Code:
IP = '192.168.100.100'
RACK = 0
SLOT = 1
plc = snap7.client.Client()
plc.connect(IP, RACK, SLOT)
print(plc.get_cpu_state())
No handlers could be found for logger "snap7.common"
Traceback (most recent call last):
File "C:/Python27/Teste_Snap7.py", line 8, in plc.connect(IP, RACK, SLOT)
File "C:\Python27\lib\site-packages\snap7\client.py", line 25, in f check_error(code, context="client")
File "C:\Python27\lib\site-packages\snap7\common.py", line 65, in check_error raise Snap7Exception(error)
Snap7Exception: TCP : Connection timed out
Is this a problem with Windows10?
I am using Windows10 64 bit, Python 2.7.17, Snap7 1.1.0, Python-Snap7 0.10.
I copied and pasted the snap7.dll and snap7.lib file into the System32, Python27, Python27 / site-packages / snap7 folders. And I created for each folder a path in the environment variables in an attempt to work.
I followed this tutorial: https://www.youtube.com/watch?v=BKnK4AT_WKs
It's not a problem related with Windows, in the error message you can see the problem:
Verify your physical connection to the machine and then verify the client IP.