'How can I connect twincats between two PC?

I met an error when I test the connection:

Target PC

  1. runs windows
  2. runs Twincat3 and plc
  3. TARGET_PC_ID = "144.214.174.72" and TARGET_AMS_ID = "169.254.42.168.1.1"

Client PC

  1. runs windows

  2. runs Twincat3

  3. Client_PC_ID = "144.214.174.69" and CLIENT_AMS_NET_ID = "144.214.174.69.1.1"

I have set the route on the target PC using Twincat. Here is my python script on Client PC:

import pyads
TARGET_AMS_ID = "169.254.42.168.1.1"
TARGET_PC_ID = "144.214.174.72"
plc = pyads.Connection(TARGET_AMS_ID, 851, TARGET_PC_ID)
plc.open()
print("state",plc.read_state())

But an error happened:

Traceback (most recent call last):
  File "C:/Users/xxwan/Desktop/py_keypoint/test_plc.py", line 14, in <module>
    print("state",plc.read_state())
  File "C:\Users\xxwan\AppData\Local\conda\conda\envs\tensorflow-gpu\lib\site-packages\pyads\connection.py", line 237, in read_state
    return adsSyncReadStateReqEx(self._port, self._adr)
  File "C:\Users\xxwan\AppData\Local\conda\conda\envs\tensorflow-gpu\lib\site-packages\pyads\pyads_ex.py", line 510, in adsSyncReadStateReqEx
    raise ADSError(error_code)
pyads.pyads_ex.ADSError: ADSError: target machine not found    Missing ADS routes (7). 

Whether I need to add route on my client PC (Similar to that on the target PC)? BTW, how to get the real port number on the target PC?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source