stlehmann / pyads

Python wrapper for TwinCAT ADS
MIT License
247 stars 93 forks source link

pyads.pyads_ex.ADSError: ADSError: parameter size not correct (1797) #387

Closed welly93117 closed 1 month ago

welly93117 commented 1 month ago

Hello, my issue is that the route is created without issue from the code below. When line plc.open() is reached, this error is thrown. This code works locally fine from raspberry Pi to a twincat laptop, the issue is when I try to switch over to the BSD plc. Beckhoff CX5230 ifConfig:

TcOsSys.dll: 4026.3.55 TwinCAT Build: 3.1.4026.0 AMS Net Id: 5.143.161.116.1.1 TC/BSD: 13.2.9.0,2

PLEASE CHANGE STANDARD PASSWORD !!!! Administrator@CX-8FA174:~ $ ifconfig igb0: flags=8863<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500 options=4a004a9<RXCSUM,VLAN_MTU,JUMBO_MTU,VLAN_HWCSUM,LRO,RXCSUM_IPV6,NOMAP> ether 00:01:05:8f:a1:74 inet6 fe80::f7b0:2df3:d63b:f31%igb0 prefixlen 64 scopeid 0x1 inet6 fdb3:52cc:de0b:3647:cf5b:3862:94a8:7e1f prefixlen 64 autoconf inet 192.168.1.247 netmask 0xffffff00 broadcast 192.168.1.255 media: Ethernet autoselect (1000baseT ) status: active nd6 options=1 igb1: flags=8863<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500 options=4a004a9<RXCSUM,VLAN_MTU,JUMBO_MTU,VLAN_HWCSUM,LRO,RXCSUM_IPV6,NOMAP> ether 00:01:05:8f:a1:75 media: Ethernet autoselect status: no carrier nd6 options=1 lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384 options=680003<RXCSUM,TXCSUM,LINKSTATE,RXCSUM_IPV6,TXCSUM_IPV6> inet6 ::1 prefixlen 128 inet6 fe80::1%lo0 prefixlen 64 scopeid 0x3 inet 127.0.0.1 netmask 0xff000000 groups: lo nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>

I have already successfully switched to project to a local project, and been able to read and write all variables. When I switch the project to the plc, I change the AMS Net ID from '192.168.1.210.1.1' (laptop) to '5.143.161.116.1.1'(PLC) along with the IP address as seen in add route '192.168.1.247'

I have tried both port X000 and X001 on the PLC.

The route is added fine, it runs into the error when using plc.open(). raspberry pi's IP is 192.168.1.117 Raspberry pi 4B: pyads.open_port() pyads.set_local_address('192.168.1.117.1.1') pyads.add_route_to_plc('192.168.1.117.1.1', '192.168.1.117', '192.168.1.247', 'Administrator', '1') pyads.close_port()

plc = pyads.Connection('5.143.161.116.1.1', pyads.PORT_TC3PLC1) plc.open() print(plc.read_by_name('MAIN.nTest', pyads.PLCTYPE_INT) plc.close()