LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Linkup / Linkdown detection; Network cable plugged or unplugged ?

Hello there,
 
I´m looking for an easy way to detect if a network cable is plugged or unplugged (linkup or linkdown) Does anyone knows what register contains this information?!
0 Kudos
Message 1 of 11
(14,163 Views)


@_avr_ wrote:
Hello there,
 
I´m looking for an easy way to detect if a network cable is plugged or unplugged (linkup or linkdown) Does anyone knows what register contains this information?!


The simplest way would be to run "ipconfig" in a DOS command and parse its output. Doing this over WinAPI with Call Library Nodes would be rather involved as you would first have to enumerate the adapters installed, decide then which adapter you are interersted in and then request its status.

Possibly this information could be retrieved from the registry but it won't be in one specific place either. You would just as much have to first find where the different adapters are registered find the one you are interested in and then retrieve its status. And in nowadays world with VPN and such do not assume that you have only one adapter in a computer. My computer with fixed Ethernet, Wireless Ethernet and one active VPN connection shows at the moment 4 installed adapters (two are for the VPN connection).

Rolf Kalbermatter
Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
Message 2 of 11
(14,155 Views)

Hi Rolf,

what library must I use to get the information?

 

 

Thanks for reply!

 

0 Kudos
Message 3 of 11
(14,151 Views)
ipconfig is a Windows system command and you would run it from LabVIEW with the System Exec.vi in the Communication palette. Just use "ipconfig" as command line and then look at the standard output string to see what the command produced as string. Parsing this output won't be trivial but trying to get at this information using Winapi calls or registry queries will be at least as difficult and more work.

Rolf Kalbermatter
Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
Message 4 of 11
(14,146 Views)

Rolf,

 

yes, ipconfig is well known, parsing that string too, but what happends if the the VI runs on an english or chinese OS!? Some keyword will change in the result string and.......

So, better solution would be to use a LIB, but I don´t know at present wich one is the correct one....

0 Kudos
Message 5 of 11
(14,148 Views)


@_avr_ wrote:

Rolf,

 

yes, ipconfig is well known, parsing that string too, but what happends if the the VI runs on an english or chinese OS!? Some keyword will change in the result string and.......

So, better solution would be to use a LIB, but I don´t know at present wich one is the correct one....


First you ask for an easy (simple) solution and then you complain about language differences Smiley Wink

If you want to go the WinAPI route you will have to access IPHLPAPI.DLL which is explained on MSDN. I have however already a small library which incidentially does provide the information you are after too. It is attached. To get even more information you would have to dig into MSDN.

Rolf Kalbermatter


Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
Message 7 of 11
(14,129 Views)

Thank you Rolf!

Looks like I am going to learn something here. Smiley Wink

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 8 of 11
(14,107 Views)

Hello Rolf -

Thanks for posting your IPTools - they are going to be a great help to me. I wonder if you can help me take it one step further. I have a NIC that is connected to 4 IP addresses. Is there a Windows API to quickly sense if the connection to one or more of these individual connections has been dropped for any reason?

Thanks!

0 Kudos
Message 9 of 11
(13,647 Views)


@red Sox Fanatic wrote:

Hello Rolf -

Thanks for posting your IPTools - they are going to be a great help to me. I wonder if you can help me take it one step further. I have a NIC that is connected to 4 IP addresses. Is there a Windows API to quickly sense if the connection to one or more of these individual connections has been dropped for any reason?

Thanks!



No I'm sorry.Rolf Kalbermatter

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 10 of 11
(13,630 Views)