Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched. Close

Working with UDP packets.

2015-06-03
2015-06-10
  • frankputnamjr - 2015-06-03

    I am trying to work with UDP packets in Codesys V3. Which library would be best for reading and writing UDP packets?

     
  • TimvH

    TimvH - 2015-06-03

    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.

    IMG: ScreenShot.jpg

     
  • frankputnamjr - 2015-06-03

    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.

     
  • frankputnamjr - 2015-06-09

    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?

    IMG: Capture.JPG

     
  • TimvH

    TimvH - 2015-06-09

    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.

     
  • frankputnamjr - 2015-06-09

    IMG: Capture.JPG

    IMG: Capture1.JPG

     
  • TimvH

    TimvH - 2015-06-09

    You don't have to specify the ipAddr (IP_string) for the UDP peer receiver.
    It might work if you remove this input.

     
  • frankputnamjr - 2015-06-09

    Thanks.

    Always use Wireshark when developing.

    IMG: Capture.JPG

     
  • frankputnamjr - 2015-06-09

    Are the devices "Ethernet" and "EtherNet_IP_Scanner" required for the network connection? I had removed them Friday and it worked fine.

     
  • TimvH

    TimvH - 2015-06-10

    No, you don't need to have any "I/O" devices connected.

     

Log in to post a comment.