soldom opened a new pull request, #2630:
URL: https://github.com/apache/plc4x/pull/2630

   Closes #2629.
   
   ### Problem
   
   The ADS connect handshake (`AdsTcpConnection.doConnectHandshake()` and 
`onPing()`) sent its probe
   requests — `ReadDeviceInfo`, online-version, symbol-version — to a hardcoded 
AMS port
   `DefaultAmsPorts.RUNTIME_SYSTEM_01` (851) with a hardcoded source port 
`800`, ignoring the configured
   `target-ams-port` / `source-ams-port`. Only the handshake was affected; the 
symbol/datatype-table
   reads and the read/write path already use 
`getConfiguration().getTargetAmsPort()`.
   
   Consequence: any PLC runtime not on 851 — a second PLC project (852), a 
non-default port, or parallel
   runtimes — failed to connect during the handshake with ADS error `0x6` 
("target port not found"),
   even with `target-ams-port` set correctly. Full analysis and a packet 
capture are in #2629.
   
   It may be intended to have the handshake port hardcoded to "System_01" 
(851), but the reason escapes me
   and it does break the above mentioned PLC setup use cases.
   
   ### Change
   
   In 
`plc4j/drivers/ads/src/main/java/org/apache/plc4x/java/ads/AdsTcpConnection.java`,
 the four
   handshake/ping request builders now use the configured ports, matching the 
data path:
   
   ```diff
   -    getConfiguration().getTargetAmsNetId(), 
DefaultAmsPorts.RUNTIME_SYSTEM_01.getValue(),
   -    getConfiguration().getSourceAmsNetId(), 800, ReturnCode.OK, 
getInvokeId());
   +    getConfiguration().getTargetAmsNetId(), 
getConfiguration().getTargetAmsPort(),
   +    getConfiguration().getSourceAmsNetId(), 
getConfiguration().getSourceAmsPort(), ReturnCode.OK, getInvokeId());
   ```
   
   No behavior change for the common case: `target-ams-port` already defaults 
to 851.
   
   ### Testing
   
   Verified against a real Beckhoff TwinCAT `3.1.4026` IPC:
   
   - PLC runtime on AMS port **852**, nothing on 851 — **before:** connect 
fails (`AdsErrorResponse`,
     AMS error 0x6); **after:** connects and reads a live symbol successfully.
   - A packet capture (Wireshark AMS dissector) confirms the handshake 
`ReadDeviceInfo` is now sent to
     the configured `target-ams-port` (852) instead of 851.
   - Regression check: with the PLC on 851 the connection still works as before.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to