Beckhoff / ADS

Beckhoff protocol to communicate with TwinCAT devices.
MIT License
513 stars 194 forks source link

Error: Connect TCP socket failed with: 110 ? #60

Closed lianhub closed 6 years ago

lianhub commented 6 years ago

I am wondering if I understood the programming model correctly. Here is the IP info:

Here is what I did on my Windows-PC:

Here is what I did on Linux target:

Then I got:

debian@beaglebone:~/ADS/example$ make test
./example.bin
     (after a couple of minutes)
2018-03-17T21:34:43+0000 Error: Connect TCP socket failed with: 110
Adding ADS route failed, did you specified valid addresses?

Anything wrong with my procedure?

Thanks! Jerry

pbruenn commented 6 years ago

On the first look, everything seems correct.

  1. can you ping 192.168.2.41 from your Linux machine?
  2. Does your Windows Firewall accept connections on ADS Port (48898)
lianhub commented 6 years ago

pbruenn:

Thanks for your information!

By the way, when I add AMS route, is route name critical? (I just chose the name randomly)

Route               AmsNetId                 Address         Type
any-name?      192.168.2.116.1.1          192.168.2.116      TCP_IP

Thanks!

pbruenn commented 6 years ago

If you have run TwinCAT3 from a different machine than 192.168.2.41, then yes that port should be open. If you just run it on localhost (192.168.2.41), than your firewall wouldn't intervene. In case you didn't run TwinCAT from a different machine try this: run telnet 192.168.2.41 48898 on your Linux machine depending on the result you see:

You find more details here: https://stackoverflow.com/questions/273159/how-to-determine-if-a-port-is-open-on-a-windows-server

lianhub commented 6 years ago

OK, I run telnet 192.168.2.41 48898, and it failed with 'timeout'! Now I got further question:

My question is:

Thanks, Jerry

pbruenn commented 6 years ago

Hmm, now I am confused. Where is your TwinCAT EtherCAT master running? On Windows-PC and CX5020 or only on the CX5020?

When you connect from Linux to 192.168.2.41:48898 the firewall on 192.168.2.41 is blocking the incoming port 48898 But when you connect from 192.168.2.41 to CX5020:48898 then the firewall on 192.168.2.41 don't necessarily has a rule to block outgoing connections to 48898 on some remote machine.

In fact I am pretty sure Windows standard firewall will allow everything outgoing, or just ask you to open the outgoing port.

If you really want to connect from Linux to 192.168.2.41, make sure you add some exception to your firewall. But I suspect you want to connect from Linux to your CX5020, don't you? In that case with that network configuration you would have to enable IP routing on your windows machine@192.168.2.41 (Don't ask me how to do this, I don't know ;-)

lianhub commented 6 years ago

OK, I guess I misunderstood the programming model/function of this ADS repository. Here is what I want:

Here is what I understood:

Here is what I don't understand:

Thanks!

pbruenn commented 6 years ago

Okay, did I understand correctly: You want to run an ADS server on Linux and then connect to that server with TwinCAT3, just like you use TiwnCAT 3 Windows-PC to connect to CX5020(with TwinCAT)? That's not possible with this implementation . Right now only client mode is implemented. And even that is limited as there is no real ADS router. For your other questions I assume you are running TwinCAT on CX5020, too. Then yes, there are EtherCAT masters on both your Windows PC and CX5020. In case you don't have an active configuration on your windows PC, the EtherCAT master on it will be disabled. And yes, ADS server/client is running on both Windows-PC and CX5020(with TwinCAT) Then yes, TwinCAT on your Windows PC will talk to ADS router(server) on your CX5020 and the router will forward to the EtherCAT master In that case Windows PC will be "client".

Not sure if that was helpful...

lianhub commented 6 years ago

Yes: You want to run an ADS server on Linux and then connect to that server with TwinCAT3, just like you use TiwnCAT 3 Windows-PC to connect to CX5020(with TwinCAT)?

Yes: For your other questions I assume you are running TwinCAT on CX5020, too.

Thanks pbruenn:

One last question:

Thanks again!

pbruenn commented 6 years ago

Oh! Okay, I never expected that constellation. As far as I know the ADS protocol is implemented only by Beckhoff. So for us the "natural" use case is a customer who operates a plant with machines from different vendors. Some of these vendors use TwinCAT to control their machine. But in case the plant operator runs Linux on his management PC, he needs a way to communicate with TwinCAT. That's the point where this AdsLib comes in. You can use it on Linux to build a client application to query and set values on your TwinCAT machines.

If you want to take this library and advance it for server side usage, feel free to do so. And of course it would be great if you share your work , so I could try to merge it back here.

Regards, Patrick

lianhub commented 6 years ago

Thanks Patrick very much for your insightful explanation!

For now, we can close this issue! Later, I will raise questions by open new issues.

pbruenn commented 6 years ago

I am looking forward to it!