LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Advice on how to handle changing IP address

Up until now, I have been using an IP Constant value to communicate with a device under test and it seems to be working OK.  In reality, the device will possess a provisional address of 192.168.100.2 which can be changed by the user at any time; the last digit in the address can change and is stored on an SD card in the device tested and upon boot-up, this address is read and the device is identified with this new address. 

 

So my intention was to include a combobox which holds possible addresses and which can be written to.   The issue is setting up the IP communication correctly when the initial address is incorrect.  Please see attached.  Currently (using IP constant), I do not have a timeout set on the Open IP connection, I enter a loop and I stay in that loop until a command is issued, whereupon I exit the loop, the IP socket is closed and then recreated to open the loop again.   

 

 

I was thinking of creating a while loop around the TCP open connection with a timeout limit, and using error cluster to escape the loop when the status is OK, but this does not appear to work correctly.

 

Let me know your thoughts about the best approach to this.  Thanks

0 Kudos
Message 1 of 3
(1,179 Views)

Hi Froboz,

 

This may not be the best approach but here is what I do. I have starting sequence where I search for connected NI devices using system configuration VIs.  Please read about it and see if you find it useful. https://www.ni.com/docs/en-US/bundle/ni-system-configuration-lv-ref/page/nisyscfg/main_palette.html

 

This way, I know which device is connected and what IP to use. I also use device MAC ID information to shortlist connected devices if there are different devices connected on the network.

 

EDIT: Oops, I just read your post and comments on the block diagram image file. My solution may not be what you are looking for.

0 Kudos
Message 2 of 3
(1,176 Views)

Here's how I've handled a similar situation, slightly different as I "expect" a single IP to be there, and if there are more than one "available", I want to be prompted "Which one do you want to use?".

  • Get a list of the IPs (of a specified range) that you can reach with a Ping or a similar "Who's Out There?" method.  Note that you can do a Ping from LabVIEW (ask Google), and if you are trying to connect to an IP device that MAX knows about (like a Remote Target, my situation), there are LabVIEW functions that know how to find and list them.
  • If there's one item in the List, use it.  If there are no items in the list, complain.
  • If there are more than one item, put them in a Combo Box and ask the User to "Choose One".

Bob Schor

 

P.S. -- I use a similar technique when connecting to DAQmx devices.  The code for USB Multifunction boxes is often similar, and you can use the same DAQmx calls whether you are connecting to, say, a USB 6002 or 6009, or a USB 621x (where x = 0, 1, or 2).  Ask DAQmx to enumerate all of the Devices that MAX sees, filter the list for connected devices, and use the first one MAX finds.

0 Kudos
Message 3 of 3
(1,137 Views)