Skip to content
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

Connect to docker via pyads #11

Open
mw-muwo opened this issue Dec 14, 2023 · 2 comments
Open

Connect to docker via pyads #11

mw-muwo opened this issue Dec 14, 2023 · 2 comments
Assignees
Labels
enhancement New feature or request question Further information is requested

Comments

@mw-muwo
Copy link

mw-muwo commented Dec 14, 2023

hey @fbarresi thanks for this amazing docker.

i want to connect to this docker via pyads.

the pyads' documentation provides a simple code example:

import pyads

 # Connection(ams_net_id: str | None = None, ams_net_port: int | None = None, ip_address: str | None = None)
plc = pyads.Connection('127.0.0.1.1.1', 851)
plc.open()
i = plc.read_by_name("GVL.int_val")
print(i)
plc.close()

what do i have to do to access the test1 variable from the docker? right now i'm always getting a connection timeout:

pyads.pyads_ex.ADSError: ADSError: timeout elapsed (1861).

@fbarresi fbarresi self-assigned this Dec 17, 2023
@fbarresi fbarresi added enhancement New feature or request question Further information is requested labels Dec 17, 2023
@fbarresi
Copy link
Owner

Hi!

You should create a router before you attempt to connect. In the same way you would do with a normal plc.

I think the ads ignore all communication attempts without a configured router. The docker logs might tell you more.

Use the api in order to add a router in the container. In your machine you can add a one-directional router over the ui.

Best regards,
FB

@mw-muwo
Copy link
Author

mw-muwo commented Dec 18, 2023

hey, thx for the fast response. sorry i never worked with a PLC before, i just need to access the PLC from a python script for a small "proof of concept".

Can you provide me some informations how to configure the router?

i just tried to pass this data via swagger, but it didn't work.

{
  "name": "example",
  "ipAddress": "127.0.0.1",
  "amsNetId": "192.168.1.20.1.1"
}

i'll sponsor your for your help, so you don't have to do this for free 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants