Jump to content

Change Remote IP in Host EXE


Jordan Kuehn

Recommended Posts

Hopefully this hasn't been addressed elsewhere, didn't see any relevant posts. We are wrapping up the software development phase of a project that involves the production of a few dozen units. Each one has a cRIO controlling it. We've chosen to give each cRIO a unique IP address so that in the event we have a couple units back for servicing, we won't have IP collisions.

Now what I need to be able to do is take a built host executable and modify the IP address it thinks the cRIO target has. I've tried modifying the aliases file to no avail. Currently I'm stuck rebuilding the exe for each new IP address. Any thoughts or suggestions, or perhaps I'm simply modifying the file incorrectly?

Link to comment

The alias file is basically a short-circuit for DNS name resolution - this won't change what IP your EXE is trying to connect to unless you're connecting by name in your code.

You can pretty easily expose the IP to connect to, either in the UI, as an INI setting, in the registry, by the command line ...

Link to comment

You can pretty easily expose the IP to connect to, either in the UI, as an INI setting, in the registry, by the command line ...

I'm just using normal Network Shared Variables, no datasocket or anything. Does that change your assessment of the ability to configure what the SVE is looking for? I'm not entirely sure what steps to take to programmatically configure the NSVs. This is a unique use case for me as most systems we build are static.

Link to comment

I'm just using normal Network Shared Variables, no datasocket or anything. Does that change your assessment of the ability to configure what the SVE is looking for? I'm not entirely sure what steps to take to programmatically configure the NSVs. This is a unique use case for me as most systems we build are static.

Ah, in that case, yes it does. I haven't messed around enough with NSVs to guide you here.

Link to comment

I am assuming that you don't want to do that (change the IP Address) in MAX.

Please note that the IP address is not defined in the executable per say (as far as I recall) but somewhere else on the RT target. If you feel adventurous look at the "Automated LabVIEW Real-Time Deployment (RTAD) Reference Application". This tool does more than just changing the IP Address of an RT device, but if you look at the code I think you will probably find what change is required to change the target IP address (most of the code is not pwd protected). I did use that code to create a simple utility for one of my customer to do just that (change the IP address of the image).

On a side note, if you have instruments with an embedded cRIO controller, I will strongly advise considering using the above mentioned tool to avoid future driver set upgrade/downgrade issues when trying to deploy your exe. The above utility take a complete image of the entire cRIO device (OS, driver set, executable [everything]) and allow an image to be created and deploy to target(s).

Good luck

PJM

Link to comment

PJM,

That looks quite useful for replicating the cRIO code across units, and I will likely need to move towards making a cRIO image in addition to the image of the host machine that I'm also replicating. Right now it doesn't bother me much to manually configure each cRIO. The thing I am more concerned with is configuring the host machine to know what IP address to look for the cRIO at. (NSVs are hosted on the cRIO). Each unit has a cRIO and a laptop host. In addition to helping me set up each laptop, it would allow us to have a single backup laptop that could be quickly reconfigured in the field by a technician to target a different cRIO.

The obvious answer may be to give each cRIO the same IP address and then it doesn't matter, but I think it's a legitimate concern that at some point we may be servicing multiple units and wanting to place them all on the same router to access from a single computer. If you have higher level suggestions that may eliminate the problem I have, I'd love to hear them.

Link to comment

If you change the cRIO IP address using MAX, does your cRIO executable code stop working? If this is the case, you might want to consider the following (although at this time this might be too much work for your project).

Instead of using "naked" share variable, use the share variable API (Function>>Data Communication>>Share Variable).

post-121-0-17952200-1315415334.png

By using this palette function you are able to use string "path" reference (NI Call this this string the "Share Variable reference In") to address the share variable.

post-121-0-98986300-1315416573.png

This string path reference look like this: ni.var.psp://IP Address/Mod#/IOName.

So for instance:

  • For code running in the cRIO, the IP address will be 127.0.0.1. For code running in the laptop the IP address will be the cRIO IP [ex: 192.168.10.125].
  • Mod# is the module number (ex: Mod2).
  • IOName is the name that you gave that specific IO on that specific module (ex: External Interlock Status)

Withe the above parameters:

  • in the cRIO the SV path reference is: ni.var.psp://127.0.0.1/Mod2/External Interlock Status
  • in the laptop this would be: ni.var.psp://192.168.10.125/Mod2/External Interlock Status

If you do something like this, you can the store the cRIO share variable configuration string path reference in ini files (possibly one for the cRIO itself and one for the laptop).

Now when you change your cRIO IP Address, you just need to change your IP address in your laptop ini file and everything will work fine.

I am using this method on a shipping instrument that can have various IP address and this method works great.

I Hope that this help.

PJM

Note: Now, the crazy/cool thing with that approach is depending on what is in your cRIO code, you could potentially run part (or all) of the cRIO code directly into the laptop by replacing the cRIO IP Address from 127.0.0.1 to its "real" one (ex: 192.168.10.15).

  • Like 1
Link to comment

jkuehn,

for shared variables changing the aliases file should work supposed you are using them by adding a library to project, adding a shared variable to library and drag&drop the shared variable to your code.

By double clicking the shared variable on the block diagramm the URL to the variable should start with your cRIO target name, not with an IP address. On my machine it works ;)

If your host executable has to connect to the target by e.g. VI server, or UDP/TCP you could parse the aliases file upon start-up for the actual IP address to use.

post-17093-0-97001400-1315474540_thumb.j

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.