Add the "Use Case" library Network to the library manager.
See the screenshot for a simple example to receive UDP packages.
If you are using this to communicate between 2 CODESYS controllers, then maybe you want to consider using Global Network Variables instead of UDP packages.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Friday the system was working perfectly. The messages came in and the valve indicators lit as requested.
Monday and today I am no longer getting the messages into the program.
When NBS.UDP_Peer is enabled the xActive goes true and hPeer has an address. There are no errors. xBusy stays true and xDone never goes active.
NBS.UDP_Peer.xActive enables NBS.UDP_Receive. NBS.UDP_Peer.hPeer drives NBS.UDP_Receive.hPeer. There are no errors. xDone and xReady never go active and xBusy is always true. ipFrom, uiPortFrom, and szCount all report zero.
Is there something missing?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
What I would do is:
- Disable the firewall. When this is enabled, it might block incoming messages.
- Install wireshark and check if the UDP packages are received. This will give you the general information if it is related to the PC/Network or CODESYS.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am trying to work with UDP packets in Codesys V3. Which library would be best for reading and writing UDP packets?
Add the "Use Case" library Network to the library manager.
See the screenshot for a simple example to receive UDP packages.
If you are using this to communicate between 2 CODESYS controllers, then maybe you want to consider using Global Network Variables instead of UDP packages.
Tim,
Thanks for the info. It works perfectly.
The reason for UDP is a CAN to Ethernet converter. Using the CAN messages from the local controller to display information at the control cabin.
Friday the system was working perfectly. The messages came in and the valve indicators lit as requested.
Monday and today I am no longer getting the messages into the program.
When NBS.UDP_Peer is enabled the xActive goes true and hPeer has an address. There are no errors. xBusy stays true and xDone never goes active.
NBS.UDP_Peer.xActive enables NBS.UDP_Receive. NBS.UDP_Peer.hPeer drives NBS.UDP_Receive.hPeer. There are no errors. xDone and xReady never go active and xBusy is always true. ipFrom, uiPortFrom, and szCount all report zero.
Is there something missing?
What I would do is:
- Disable the firewall. When this is enabled, it might block incoming messages.
- Install wireshark and check if the UDP packages are received. This will give you the general information if it is related to the PC/Network or CODESYS.
You don't have to specify the ipAddr (IP_string) for the UDP peer receiver.
It might work if you remove this input.
Thanks.
Always use Wireshark when developing.
Are the devices "Ethernet" and "EtherNet_IP_Scanner" required for the network connection? I had removed them Friday and it worked fine.
No, you don't need to have any "I/O" devices connected.