如何在两台PC之间连接Twincats?

发布于 2025-01-25 14:25:31 字数 1411 浏览 1 评论 0原文

测试连接时,我遇到了一个错误:

target pc

  1. 运行Windows
  2. 运行Windows和PLC
  3. target_pc_id =“ 144.214.174.72”和target_ams_id =“ 169.254.42.168.1.1.1”

>

  1. 运行Windows

  2. 运行twincat3

  3. client_pc_id =“ 144.214.174.69”和client_ams_net_id =“ 144.214.174.69.1.1”

我已经使用twincat在目标PC上设置了路由。这是我在客户端PC上的Python脚本:

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())

但是发生了错误:

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

我是否需要在客户端PC上添加路由(类似于目标PC上的路由)?顺便说一句,如何在目标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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文