Search the Community
Showing results for tags 'ping'.
Found 2 results
Sometimes it can be hard to tell if a failure to communicate with a device is caused by a networking issue (cut cable, no power to remote device) or something else (protocol error, etc.) In these cases, the first thing we tend to do is ping the device. A successful ping at least tells us that the device is powered up and the IP is accessible from this computer. It doesn't tell us if the device will allow us to connect to it, a firewall is blocking the desired ports (say 502 for Modbus), or other issues, but it does eliminate some possible problems. There are many times when we wish to do this automatically. So, here is a simple script we'd like to share that you can use to ping a device from script: function checkPing(string ip, string path) system.ShellExecute("cmd","","/C ping " + ip + " > " + path, "", "hide") delay(5) private h = file.Open(path,1,0,0,0) private string data = file.Read(h, file.GetLength(h)) file.Close(h) return(find(data,"TTL=",0) != -1) It does this by triggering the command line ping, just like you would type it, and then piping the result to a file. Then it opens the file and looks for "TTL=" which really only appears if a ping is successful. The delay(5) is to give the ping command time to execute as there is no way us to know. ShellExecute() is a non-blocking function, meaning it will trigger the command but then immediately return. Because we are using command line piping we have to have shellExecute() run "CMD" not "Ping" directly. We pass the /C flag to CMD to tell it to run the Ping command then quit. The design of this function is to allow you to, in script, check the network status on many devices. Simply call this function with the ip and a path to the file you'd like ping to create with the result. You'll want to make sure if you are calling this function from multiple threads for multiple IPs that you pass a different path. Note also that this function will take at least 5 seconds to run, so don't call it from the command line or a button press. Make sure and call it from a sequence running in a background thread.
Hi, What is the best way to test connectivity of RS485 and TCP devices ? I want to test devices and if connection fails (like wire broken, radio connection lost etc ) device will be on alarm list..? I guess that result can be added to virtual channel like 0 or 1 for each device ??