0

I have been trying to get a connection between TwinCAT 3 on Windows and Python on Ubuntu. I already have the connection between Twincat 3 Windows and Python Windows working, but not to Ubuntu. I have a virtual machine set up through Oracle VM Virtualbox. I tried many things but so far had no success in creating the connection. I have a bridged adapter network and tried to open the port of the IP address of the virtual machine in linux through sudo ufw allow I have the following code:

pyads.open_port()
pyads.add_route('10.11.104.206.1.1','127.0.0.1')
pyads.close_port()
plc = pyads.Connection('10.11.104.206.1.1', 851)
plc.open()
try:
    # try to connect to PLC
    plc.read_state()
    print('Connection succeeded')
except Exception:
    print('Connection failed') 

And this is the error I get:

2020-11-22T22:45:46+0100 Error: Connect TCP socket failed with: 111
Traceback (most recent call last):
  File "/home/laurence/ws_moveit/devel/lib/moveit_tutorials/move_panda_LKO.py", line 15, in <module>
    exec(compile(fh.read(), python_script, 'exec'), context)
  File "/home/laurence/ws_moveit/src/moveit_tutorials/doc/move_panda_LKO/scripts/move_panda_LKO.py", line 64, in <module>
    pyads.add_route('10.11.104.206.1.1','127.0.0.1')
  File "/usr/local/lib/python3.8/dist-packages/pyads/ads.py", line 188, in add_route
    return adsAddRoute(adr.netIdStruct(), ip_address)
  File "/usr/local/lib/python3.8/dist-packages/pyads/pyads_ex.py", line 155, in wrapper
    return fn(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/pyads/pyads_ex.py", line 177, in adsAddRoute
    raise ADSError(error_code)
pyads.pyads_ex.ADSError: ADSError: target port not found   ADS Server not started (6).

These are the netid/IPadresses.

-

-

-

CX-52EE70

169.254.64.202

5.82.238.112.1.1

TCP_IP

-

LEENLAPTOP19

127.0.0.1

10.11.104.206.1.1

TCP_IP

I have tried combinations with other netid/IP addresses so sometimes I get other errors (110,113) but usually 111 which means connection refused, but I do not know what I am doing wrong. Any ideas?

  • Hi, welcome to stack overflow! did you try to restart the Twincat server? this might solve your problem – ishahak Nov 26 '20 at 15:26

1 Answers1

0

Please make sure the plc runtime is running (a plc program) when you connect. If the plc is in config or exception mode the plc runtime ads port (851 (or 801 for TC2)) is not present. That is what the ADS error 6 target port not found is trying to tell us.

owillebo
  • 625
  • 5
  • 9