LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Programmatically Change Network Settings for Linux RT

Solved!
Go to solution

Hi. I would like to be able to set the IP Adress and related NIC-parameters of an cDaq9132 which runs Labview's RT-OS. The version is 2018.

 

I have tried to use the vi which is linked here: https://forums.ni.com/t5/Example-Code/Programmatically-Change-Network-Settings-for-Linux-RT-CompactR...

 

This works if I start it on my laptop and connect to the RT-Target by using it's IP-Adress. But I want to change the settings from within a vi that runs on the RT-Target itself. This does not work. I tried to use the IP-address of the unit and the phrase "localhost" instead. The message says "cannot find the system" or something similar (don't have the message text here at the moment).

0 Kudos
Message 1 of 10
(4,290 Views)

Suppose you have two PCs connected to each other using a Cross-over Cable.  PC A uses 192.168.1.100, while PC B uses 192.168.1.101.  They exchange messages just fine, since A "listens" to B and when something is there, it "reads" B's message, meanwhile sending its messages to B (knowing where B lives).

 

Now assume B changes its IP to 102.  The communication instantly "breaks".  A doesn't get any messages from B (because it is "listening" to 1.101, not 1.102), and any request that A sends to B ("Hey, B, where are you?") aren't received (because B is no longer listening on 1.101, where A is sending).

 

You could, I suppose, have a complicate "Song and Dance" routine.  B sends "I'm thinking of changing my IP to 1.102.  Is that OK?".  A replies "OK, warn me before you do it").  B sends "OK, I'm doing it ...") and does it.  The link breaks.  Now A tries to establish a new link to 1.102, waiting for B to respond.

 

This seems very messy to me.  When I've done TCP communications, I've always tried to establish the links first, and not change them for the duration of the routine.  When running LabVIEW Real-Time code, where there are independent devices communicating over TCP/IP, I use MAX to "search out" devices out there using some protocol that I don't worry about.  When it finds a Device, it "knows" how to set low-level "hooks" to it, MAX, can control setting the IP of the Device.

 

I guess the bottom line is "There Needs to Be a Single Boss when setting up IPs".

 

Bob Schor

0 Kudos
Message 2 of 10
(4,224 Views)

Thanks for your answer and I am sure that you are correct. I also use max to set the IP-addresses, but what I am trying to do has another background. 

I have created a system that takes dimensions of a product In a rolling mill continuously. The hardware is a cdaq 9132 with RT-Os. It provides the data by being a opc-ua Server.  The data can be read by the rolling mills plc and is used to control the roll setting. 

If I sell such a system to a customer, then I have to set a static IP adress before shipping, because my customer does not use DHCP in the PLC‘s network. I do this with Ni-Max or I could even use the tool as per the downloading above. But it would be much nicer, if my customer could just start the system an set the IP in the application itself. 

0 Kudos
Message 3 of 10
(4,219 Views)

... and of course I know that my customer could set the IP via the web access through the IE browser, but still this is not very comfortable. 

0 Kudos
Message 4 of 10
(4,204 Views)

Any ideas?

0 Kudos
Message 5 of 10
(4,169 Views)

As it happens, I'm creating a new LabVIEW-RT routine, and plan to try to have the Host "discover" the Target.  I vaguely remember doing this a decade ago, hope to figure it out shortly ...

 

Bob "Famous Last Words" Schor

0 Kudos
Message 6 of 10
(4,160 Views)

Ah, I may have been doing the "inverse problem".  I'm writing code that will connect to a remote LabVIEW RT Target, and have to know the Target's IP in order to "reach out" and establish contact.  You know how MAX can "discover" Remote Targets?  LabVIEW can do the same, and it can take 5-10 seconds to do so (in which case you might want to do this once and save the IP in a Config file if you are sure it won't change, just to save time).

 

As I re-read your question about what you want to do, it occurs to me you are perhaps wanting to do a different thing (but also setup-able, if that's a word, from a Configuration file).  Namely you Ship your product, the User runs a little utility that says "Enter the IP of the device you want me to monitor", and it saves it.  You'd do this if the device was not "MAX-discoverable", for example.

 

I assume that if you know the Remote IP (either because you found it in MAX or the User told you want it was), you know how to configure your LabVIEW code to establish a Connection with a Remote Target at that address.  So does this "hand-waving" solve your problem?

 

If, in fact, you want your Shipping Product to "act like MAX and find me all of the Remotes that MAX would find", you need only to use the "Find Systems", which (for me) was under the Real-Time Palette in RT Utilities/System Configuration.  I recommend you look at the Help and not accept the default settings (by default, it will return cached systems that might be no longer present).

 

Bob Schor

0 Kudos
Message 7 of 10
(4,145 Views)
Solution
Accepted by topic author Volker64

Hi Bob and once again thanks for your input. I have gone through the labview project which I linked above and took the core steps to create a quite simple vi which allows me to change the IP of one of the two nics of my cdaq 9136 by selecting it by the Mac-Address. I will extend this to a sub vi wich enables me to set some other nic parameters like gateway, dhcp, etc.

 

I upload this simple solution so anyone who has the same problem may use this as a basis. I don't know if it is coded correctly, but i works.

 

I am sorry for my wordings in the previous posts which obviously created some misunderstandings. I am German ...

Message 8 of 10
(4,142 Views)

I wish I would of know that was what you were looking for... I am just finishing up a project that does exactly that (IE configure cRIO NIC)
They make it look so easy in <\LabVIEW 20XX\examples\nisyscfg\Format Real-Time Target.vi> 🙄

---------------------------------------------
Former Certified LabVIEW Developer (CLD)
0 Kudos
Message 9 of 10
(4,117 Views)

Thank you Volker64. Your solution helped me.

0 Kudos
Message 10 of 10
(4,025 Views)