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

Modbus TCP Slave via dynamic DNS

tcave42
2021-02-23
2021-02-24
  • tcave42 - 2021-02-23

    Is it possible to run an Modbus TCP connection to a device that is offsite on a different network via a dynamic DNS like for example DuckDNS?

     
  • i-campbell

    i-campbell - 2021-02-23

    In Library Manager, add the Net Base Services library.
    In your program declare a variable of type NBS.ResolveHostname
    Call this instance to resolve the hostname.

     

    Last edit: i-campbell 2021-02-23
    • tcave42 - 2021-02-23

      thank you for your reply, I'm still not having any luck, could you make an example?

       
      • i-campbell

        i-campbell - 2021-02-24
        PROGRAM PLC_PRG
        VAR
            instResolveHostname : NBS.ResolveHostname;
            xResolved: BOOL;
            xResolve: BOOL;
            myIP: NBS.IPv4Address;
            myIPInterface : NBS.IIPAddress := myIP;
            TheIPYouAreLookingFor: UDINT;
        END_VAR
        
        instResolveHostname(
            xExecute:= xResolve, 
            udiTimeOut:= 10_000_000, //10sec timeout
            xDone=> xResolved, 
            sHostname:= 'www.codesys.com', 
            itfIPAddress:= myIPInterface
            );
        
        TheIPYouAreLookingFor := myIP._udiIPAddress;
        
         

Log in to post a comment.