To download NI software, including the products shown below, visit ni.com/downloads.
Overview
This VI allows you to ping a host and pass parameters to define the number of attempts and timeout.
Description
Have you ever looked to ping a target from your application? LabVIEW does not seem to have a built-in ping function. Using the System Exec VI can take a long time for the result to come back if the host or IP is unreachable. I'm sure a lot of us have wondered which port would be best to choose for a quick TCP Open and then Close it after checking for errors - but that's not really a "nice" way to do it. What's the solution? Well, we can add parameters to the command that we send to the System Exec VI. Using this VI, we can set the number of attempts and specify a timeout.
Use this VI directly, or use it as a sub VI. Modify it if needed.
Requirements
Steps to Implement or Execute Code
Additional Information or References
VI Snippet
**This document has been updated to meet the current required format for the NI Code Exchange.**
Regards,
Imtiaz Chowdhury
Project Manager
Green Running / Austin Consultants
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.
Glad to hear that! Perhaps you could upload your modified application as well with a link?
Regards,
Imtiaz Chowdhury
Project Manager
Green Running / Austin Consultants
Anyone know if there is a way to Ping from both Windows (as shown here) or from RT (The system Exec doesn't work on RT for the PING command).
the first Labview ping vi I found, which is working well
thanks-
Thanks very much, this was quite helpful to me as well, so I gave you a Kudos!
Be carefull, approach below may give you fake positive result. I've got this situation on my Win10 PC with Mikrotik router, when host was connected and later disconnected, ping sometimes returned code as zero, but std output tells "host is unreachable". That is why to look only at returned code is not really reliable solution, better to analyze std output string.
Below is my solution. I am not very good in regular expressions, so I believe parsing could be easily improved. Another thing to improve - make compatible with different formats of ping output string. Please share your version of improvements 🙂
Still not perfect :-), ping may report % lost less than 100% but all packets are actually lost, see screenshot again:
So, my parsing will return not actual statistics. Here is simple fix:
For an abbreviated version that will work on either linux or Windows. This is simply looking for the average round trip and will also look at other errors and give a simple connected or not connected flag. NOTE: if you put a malformed name (not IP address), the DNS resolution time is not taken into account so it may take longer than your expected timeout.