-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Linux AMS server not working. Connection via Windows is working #34
Comments
Please try to run the tests by calling
Do the tests pass or are you getting errors? If the tests pass the problem must be somewhere else... |
Have you added a route on the target machine? You need to manually add a route on your target PLC to allow it to send the response to the right place. This is handled automatically with the TwinCAT router on Windows, however there's no equivalent with the Linux version. To add the route on the target you'll need the IP address (or hostname) of your Linux machine, and its AMS address. You can get the AMS address like this: >>> remote_ip = '192.168.0.100' # Replace with target IP
>>> adr = pyads.AmsAddr('127.0.0.1.1.1', pyads.PORT_SPS1) # Replace with target AMS address
>>> pyads.add_route(adr, remote_ip)
# NOTE: get_local_address() won't work properly until you've added a route as above
>>> pyads.get_local_address()
'192.168.1.10.1.1' Then you can login to the remote machine (PLC), open up the TwinCAT router UI and add a static route using these details (set the 'Remote Route' to None). |
You can also use the new-style |
Yes I should have mentioned that. The connection class will automatically add the local route, but you will still need to manually add a return route on the target PLC from my experience. |
Thanks for your help, guys. Very kind.. @ dabrowne
|
@MrLeeH
|
@MrLeeH
|
@wouterjoris Yes, to get the local address you still need to call Did your routing work now? I could imagine you run into trouble because you are mixing the remote ip
|
I think this last tip of you certainly is most helpful. I did mixup those addresses. But the problem however stays the same: "connection closed by remote" There is also the option of a broadcast search but I don't see a response out of pyads. Is pyads meant to answer to these multicasts? |
Have a look if your Firewall is active. I just had the same issue here. If you deactivate the firewalls on both sides you should be able to see the other side via Broadcast Search. |
@wouterjoris |
I finally got a reply from the PLC. :-) Thanks again for the assistance! |
Happy that it works for you now. However TwinCAT3 should work too. I'm doing my testing with TwinCAT3 ... but from a Windows PC. This works well. Would be nice to know if it is a general issue with Linux and TwinCAT3 or maybe just a setting thing. Let us know if you found anything ;) Greetings |
The connection with TC3 works on Windows. For the Linux case only TC2 works for now. I'll let you know for sure if I manage to get some progress in the situation but I'm a bit out of ideas at the moment. kind greetings |
I'm happily using a TC3 PLC with a Linux pyads client. I suspect that the issue may be separate from pyads as the manual route failed on the PLC. I added my routes by logging into the PLC with remote desktop (or if you have a monitor attached, just working on the PLC directly), right clicking on the TwinCAT icon on the taskbar and going Here's a screenshot of the configuration just to make extra sure. Note that your linux machine will need a static IP. Also note that Remote Route is set to None. Route name can be whatever you like, normally it's set to the Hostname of your client. |
Yes, I finally got a working connection with TC3.
For some reason I was not able to add a route on the PLC to the master Linux machine so I used the same settings with my Windows machine using Twincat 3 VC2013. ( which I need anyway to program the PLC. ) Once setup the route could be added on the PLC and this works all the same when switched back to Linux. I must say I'm not impressed with the Beckhoff software provisions but like they say here at the office: I'm happy with the working connection and thanks you again for the kind help. Kind greetings |
Hi reader,
how do I add the route?
I mannaged to make something similar to this to work, so I know my AmsAdress... what do I do with it? |
Hello Sofia,
could please you post the code you used to establish the connection.
You will need to create a route on the PLC for the communication to
work.
Did you use add_route_to_plc for this?
…---
Freundliche Grüße
Stefan Lehmann
Am 24.02.2021 08:51 schrieb Sofia:
Hi reader,
I have to communicate a PLC (Beckhoff CX9020) with a raspberri pi
thru python, and I have been hitting my head against the wall for the
past 3 days. For the record, I have the communication going well with
TwinCAT and I can read variables with python if I do it from Windows.
It seems like the issue is very related to this thread, I tried
following but I couldn't solve the puzzle.
I need help, please contact
> The connection class will automatically add the local route, but you
> will still need to manually add a return route on the target PLC
> from my experience.
how do I add the route?
> Thanks for your help, guys. Very kind..
>
> @ dabrowne
> Yes I tried al sorts of variants of this setup, and we do get a AMS
> address like expected but the connection itself failes.
> The testserver ( $ python -m pyads.testserver ) also works and I
> can even poll for dummy variables like indicated within the official
> documentation.
>
> pyads.open_port()
> 30000
> remote_ip='192.16.17.9'
> adr=pyads.AmsAddr('127.0.0.1.1.1', pyads.PORT_SPS1)
> pyads.add_route(adr,remote_ip)
> 2017-09-25T11:59:25+0200 Info: Connecting to 192.16.17.9
> 2017-09-25T11:59:25+0200 Info: connection closed by remote
>
> pyads.get_local_address()
> <AmsAddress 192.16.17.10.1.1:30000>
I mannaged to make something similar to this to work, so I know my
AmsAdress... what do I do with it?
any help is more than welcome
--
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub [1], or unsubscribe
[2].
Links:
------
[1] #34 (comment)
[2]
https://github.com/notifications/unsubscribe-auth/ABDNGBQQJ5LK6KRYDXHB5ADTASVWXANCNFSM4D4F6LTA
|
Hello Stefan Lehmann, I somehow managed to make th connection work from linux. I wanted to let you know that the method "add_route_to_plc" gives me a timed_out every time. I had to add the route manually from TwinCAT and it worked (after lots of tweaks to my code).
this gives me a connection status of "(5, 0)". |
The most issues we had with route_to_plc so far were because the parameter names are a bit confusing and got mixed up. Would you mind sending the code you used for that so we can investigate? |
Hi Stefan. |
The other day I was trying to connect to a Beckhoff CX5120 PLC running windows and TC3 runtime. We managed to connect via a windows machine and read back some PLC variables. Our master machine is a Linux PC so windows is no option in this case.
On Linux ( Arch ) however, the pyads 2.2 package does not work, it seems the AMS server is not working properly. Netstat tells me a tcp connection is opened but when I try to make a ADS connection it fails with a timeout.
Is there a good way to debug this thing? What kind of information can I collect in order to get to a working sollution?
The text was updated successfully, but these errors were encountered: