pyads
pyads copied to clipboard
WinError 10040 when communicating with network-connected PLC
When trying to read a symbol from a PLC connected to the local network, I get the following error:
OSError: [WinError 10040] A message sent on a datagram socket was larger than the internal message buffer or some other network limit, or the buffer used to receive a datagram into was smaller than the datagram itself
I am able to read symbols just fine when the PLC is connected directly to my PC with an ethernet cable. I am on a corporate network, so this might have something to do with it?
I tried increasing the PLC response length in adsGetNetIdForPLC() (in pyads_ex.py, line 395) from 395 bytes to 500 bytes. Now it works and it seems that the received packet is 432 bytes.
Windows 10 Python 3.11.2 pyads 3.4.0 TwinCAT 3.1.4024.44
hello, could you please paste a small reproducible sample bit of code for this? I suspect this is an issue with your network if it works directly. But I can look into it.
Thanks, Chris. Here is a bit of code that produces the error:
import pyads
conn = pyads.Connection(ams_net_port=10000, ip_address="10.10.10.10")
with conn:
state = conn.read_state()
print(state)
Hi @kristianklein
have you change the default port ? normally it's 851 (instead of 10000)
Regards,
@kryskool, port 10000 is for the system service. My TwinCAT 3 C++ task defaults to port 350, but the issue exists on both ports.
did this get resolved?