Home AMX User Forum AMX General Discussion

Determine own IP address

Does anyone know if there is a way to determine the IP address assigned to a master from within Netlinx? I want to have the code determine the IP of the master, picked up via DHCP, and then do some configuration depending on what the IP is.

Comments

  • Joe HebertJoe Hebert Posts: 2,159
    Look up GET_IP_ADDRESS() in the help file and you will find what you're looking for.

    Here is an example how to get the address of the NI.
    DEFINE_DEVICE
    
    dvMaster     = 0:1:0
    dvTP         = 10001:1:0
    
    DEFINE_FUNCTION PrintIP() {
    
       IP_ADDRESS_STRUCT IPInfo
    
       GET_IP_ADDRESS(dvMaster,IPInfo)
       
       SEND_STRING 0,"'My IP Address is: ',IPInfo.IPADDRESS"
    
    }
    
    DEFINE_EVENT
    
    BUTTON_EVENT[dvTP,1] {
    
       PUSH: {PrintIP()}
    
    }
    
    


    After I push button 1:
    Line     23 (15:30:25)::  My IP Address is: 192.168.1.10
    


  • ariesaries Posts: 27
    Thank you.. this was tremendously helpful!
Sign In or Register to comment.