I used pycharm for writing my code and plcsim for simulatio. When I run my code and run plcsim I get an error. I used Tia portal V16 and s7-1200 and I want to communicate between S7-1200 and python-snap7 This is the error:
PS C:\Users\Badro\PycharmProjects\pythonProject1\venv> py test.py
b' TCP : Unreachable peer'
Traceback (most recent call last):
- File "C:\Users\Badro\PycharmProjects\pythonProject1\venv\test.py", line 8, in <module>
plc.connect(IP, RACK, SLOT)
- File "C:\Users\Badro\AppData\Local\Programs\Python\Python310\lib\site-
packages\snap7\client.py",
line 24, in f
check_error(code, context="client")
- File "C:\Users\Badro\AppData\Local\Programs\Python\Python310\lib\site-
packages\snap7\common.py",
line 89, in check_error
raise RuntimeError(error)
RuntimeError: b' TCP : Unreachable peer'enter code here
and this is my code:
import snap7
IP = '192.168.100.100'
RACK = 0
SLOT = 1
plc = snap7.client.Client()
plc.connect(IP, RACK, SLOT)
print(plc.get_cpu_state())
I watched this videohttps://www.youtube.com/watch?v=BKnK4AT_WKs
Where is the problem or is the problem that plcsim must be the real plc for simulation not plcsim?