LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

network card question

Hi all

 

I have a pC with 2 NICs. A device is connected to one of the NIC. Is there a way to devise a program to tell the ip of the NIC in which the device is connected?

Thank you

0 Kudos
Message 1 of 6
(2,655 Views)

Hai,

 

When you try to connect to the device from pc via tcp/ip LabVIEW automatically finds out the NIC to which the device is connected.  So using the tcp/ip functions establish the connection to the device and try using String to IP with input as Local host. \\local host will return the current active connection in the pc.  I couldn try that since i have only one NIC

With regards,
JK
(Certified LabVIEW Developer)
Give Kudos for Good Answers, and Mark it a solution if your problem is solved.
0 Kudos
Message 2 of 6
(2,654 Views)

JK1 wrote:

Hai,

 

When you try to connect to the device from pc via tcp/ip LabVIEW automatically finds out the NIC to which the device is connected.  So using the tcp/ip functions establish the connection to the device and try using String to IP with input as Local host. \\local host will return the current active connection in the pc.  I couldn try that since i have only one NIC


HI JK

 

Thank you for ur reply. Based on ur reply, I did a small VI but it does not gives me the desired output. Attached is the VI for ur reference. Input localhost to string to IP function returns 127.0.0.1  while leaving the input to nothing always gives me the IP of the first NIC. Please help me in correcting the VI if it is wrong.

0 Kudos
Message 3 of 6
(2,642 Views)

Hai,

 

When establishing the connection ensure that you dont get any error and use \\local host as input to string to ip, find if you get the expected result.

If you dint get any solution create a network bridge with two NIC cards and assign a common IP to the bridge so only one IP will exist in the system.

 

Hope this helps.

With regards,
JK
(Certified LabVIEW Developer)
Give Kudos for Good Answers, and Mark it a solution if your problem is solved.
0 Kudos
Message 4 of 6
(2,636 Views)

hello

 

Thanks once again. \\local host results in 0.0.0.0. I don't think I can create the bridge because one NIC is used for internet connection. I can open tcp/ip connection to the device without any error. Basically, I need a program that can tell the IP of the NIC that the device is connected to. Is there a solution?

0 Kudos
Message 5 of 6
(2,632 Views)

Hi,

 

If I understand the situation correctly, here is my solution (there is probably an easier one but this would work), assuming you are in Windows.

 

1 - Using the VI "System Exec.vi", run "ipconfig" and parse the output to get the address of both your NIC. It's easy, it folow

2 - Alternatively the function "route print" can also list your NIC

3 - If you are trying to force a connection using a specific NIC, you can use the "VISA Open" VI  and pass a string in the format: "TCPIP[board]::host address::port::SOCKET" (ex:  TCPIP0::1.2.3.4::999::SOCKET) where 0 is your NIC internal ID (could be the same or different the one in "Route print)

 

Hope this helps. It's not the best as it wouldn't work on any system but you can definitely get a local ipaddress on any system with that.

 

Cheers,

 

Olivier

Message 6 of 6
(2,614 Views)