Troubleshooting
Why CODESYS 2 Net_Var sends no UDP data to TwinCAT 2
Short answer
Zero packets in a capture on the sender means the datagram never reaches the wire, so the fault sits in the CODESYS 2 project or its library setup, not in TwinCAT 2 or the ARM-to-x86 pair. Test CODESYS 2 against CODESYS 2 and TwinCAT 2 against TwinCAT 2 first, record the exact status value the library returns, and keep controller resets for the TCP dead-socket case where they belong.

On this page
Your capture has already made the first decision: the sending controller puts nothing on the wire, so the datagram never leaves the CODESYS 2 side, and nothing on the TwinCAT 2 side — its library, its x86 processor, its variable lists — can cause packets that do not exist. UDP, defined in RFC 768, has no connection setup and no acknowledgement, so a correctly configured sender transmits whether or not any receiver is listening. Work the fault in this order: prove the CODESYS 2 project can send to another CODESYS 2 controller, prove two TwinCAT 2 controllers exchange network variables with each other, and capture the exact numeric status value at the failing call instead of accepting the word timeout. The controller-reset workaround you may have been offered belongs to a different failure, a TCP connection left half-open, and it does nothing for a silent UDP sender.
What the empty capture rules out #
A capture on the sender's own network interface is authoritative: no UDP datagrams to the destination means the send never executed. That one observation removes whole branches from the search:
- The cable, switches and routing between the cabinets — traffic that is never generated cannot be blocked.
- The TwinCAT 2 receiver and Beckhoff Network 121.lib — a receiver cannot reject a datagram it never receives.
- Cross-platform framing — framing only matters once datagrams exist.
A timeout class in the library documentation tells you the block waited for a local operation to complete and gave up. UDP gives it no peer handshake to wait for, so the wait happened inside the sender: opening the socket, binding it, or the send call itself. Confirm, inside the sending project, that the call sits in a task that is actually running, that the enable input is held TRUE — the OSCAT variant of the block names that input Activate; use the equivalent on your library — and that the destination address, port and variable list are all set.
Run both same-stack tests first #
Two tests, each with its own capture, localize the fault:
- CODESYS 2 to CODESYS 2 with network 121_hf1.lib at both ends. Success proves the library transmits on your ARM controller.
- TwinCAT 2 to TwinCAT 2 with Beckhoff Network 121.lib at both ends. Success proves the receiver side can exchange network variables.
Read the pair of results as a decision:
- Both same-stack tests transmit and the mixed pair stays silent: the fault is a mismatch between what the two libraries expect — destination, port, variable list, send mode.
- The CODESYS pair is silent too: the fault is in your sending project; fix it before touching anything on the TwinCAT side.
- The TwinCAT pair fails: that is a separate receiver-side repair, and it still cannot explain the sender's zero packets.
Capture the status value, not the word timeout #
The documentation's timeout class covers more than one failing operation, and the number tells you which:
- Record the exact numeric status the block returns at the failing call, in the running task, with a timestamp, every time it is nonzero.
- Decode it against the status table of the library your project actually compiles, not against a table from a neighbouring project or a forum post.
- Correlate the timestamped status with the capture: a status that never clears while the capture stays empty confirms the send path, not the receive path.
The arithmetic that proves no send happens #
Turn the empty capture into a count so nobody argues about packet loss. Take a sender configured to transmit cyclically every 100 ms — an example cycle; substitute your configured value:
- 1000 ms ÷ 100 ms = 10 datagrams per second
- 10 datagrams/s × 30 s = 300 datagrams expected in a 30 s capture
Filter the capture on the configured port, for example udp.port == 12000 with 12000 as the example port, and count. Zero out of 300 is not loss; it is no send. If the send mode is on-change rather than cyclic, the expected count becomes the number of value changes in the window, so force the variables to alternate and count again. Capturing on the device that should transmit first is the same discipline you use when you monitor Modbus TCP remote I/O for random connection failures. If you count the full expected number but the TwinCAT variables never update, the fault has crossed the wire: compare variable order and data types on the two lists, which is a different repair.
Why the reset belongs to the TCP case #
The reset anecdote is real but attaches to TCP, not to your transport. In that reported case a communication partner disappeared without closing the connection, the local port stayed bound to the dead connection, an edge on the Activate input cleared nothing, and only a controller restart restored traffic. That is connection state, which TCP (RFC 793) keeps and UDP does not: every datagram is independent, and a vanished partner leaves nothing wedged in a UDP sender. Two consequences:
- Do not power-cycle to clear a silent UDP sender; it cannot help, and it hides the real fault.
- Whether the TwinCAT TCP/IP Connection Server is installed matters only for the TCP variant; over UDP the sender needs no server on the receiver to transmit.
Where you do restart a controller for the TCP case, do it with the machine stopped and safe: the restart drops the running program and the outputs follow their power-up behavior.
The decision for each case #
- CODESYS 2 to CODESYS 2 is silent too: the fault is in your sending project. Fix the task execution, the enable input, the destination and port, then re-capture; leave the TwinCAT side alone.
- Both same-stack tests transmit and the mixed pair does not: a mismatch between the two libraries' expected settings. Compare every field both expose, keep both working captures and the failing status value as evidence, and take that file to the library vendors — not a reset.
- The mixed pair transmits and the TwinCAT variables update: repaired. Power the receiver off and on once and confirm traffic resumes with no reset anywhere — the acceptance test UDP makes easy and the TCP variant failed.
Questions asked
Can the ARM versus x86 difference between the controllers cause the silence?
No. Processor architecture changes byte order and structure alignment inside the payload, which appears as swapped or garbled values after datagrams arrive. It cannot stop a send call from putting a datagram on the wire, so treat architecture as a payload problem only once the capture shows traffic and the TwinCAT variables hold wrong values.
What does an ICMP port-unreachable reply in the capture mean?
It means the datagram did leave the sender and nothing on the receiver was bound to the configured port. Most IP stacks answer a closed UDP port that way. Start the network-variable receiver on the TwinCAT controller, or correct the port on both sides, and delivery resumes. It is the one capture pattern that moves the fault from sender to receiver without a code change.
How do I capture a status value that appears for a single cycle?
Latch it. Copy the status output into a holding variable every scan, keep the last nonzero value together with its timestamp, and read that pair through the programming connection while the capture runs. A momentary code nobody wrote down is the most common reason a timeout gets blamed on the network.
Are the OSCAT Net_Var block and network 121_hf1.lib the same library?
No. They are separate libraries with separate status tables. Confirm which one the project's library list actually references, then decode the captured status value only against that library's table; mixing the two tables points you at the wrong failed operation.


