fbarresi / SoftBeckhoff

Virtual Beckhoff PLC for local testing with docker support

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Connect to docker via pyads

mw-muwo opened this issue · comments

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

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

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 🚀