Ping a device
deps
Junior Member
I need to know online\offline status of a SAT tuner by Ethernet. There is no standart command like a PING in Netlinx, so I'm using
IP_CLIENT_OPEN command and looking at error I'm receiving: if it is 6 - Connection refused - device is Online, if another - Offline. It works correctly few days, and then becomes unstable. May be too much tryings to open connection.
Maybe somebody knows another ways to ping?
IP_CLIENT_OPEN command and looking at error I'm receiving: if it is 6 - Connection refused - device is Online, if another - Offline. It works correctly few days, and then becomes unstable. May be too much tryings to open connection.
Maybe somebody knows another ways to ping?
Comments
-
It is not ideal, but you can have the AMX master telnet into itself and send the ping command to your device. I just tried it on my master running 4.1.400 firmware, and the ping responds much faster than it used to. You don't need to send the "msg on" command after you connect.
Welcome to NetLinx v4.1.400 Copyright AMX LLC 2012 >ping 8.8.8.8 8.8.8.8 is alive. >ping 8.1.1.1 8.1.1.1 did not respond.
-
It is not ideal, but you can have the AMX master telnet into itself and send the ping command to your device.
[/code]
Thank you! How do I do it? -
Here is some very basic code off the top of my head to give you an idea...
DEFINE_DEVICE LocalPort = 0:4:0 //Local IP Port DEFINE_FUNCTION Ping() { IP_CLIENT_OPEN(LocalPort.Port, '127.0.0.1', 23, IP_TCP) } DATA_EVENT [LocalPort] { ONLINE: { SEND_STRING LocalPort, "'ping 8.8.8.8', $0D" } STRING: { IF (FIND_STRING(Data.Text, 'is alive', 1)) { //Success } ELSE IF (FIND_STRING(Data.Text, 'did not respond', 1)) { //Fail } IP_CLIENT_CLOSE(LocalPort.Port) } }
You will want to add more code for error trapping, port connection status, etc. -
Oops, I forgot to catch the login banner. You will want to make sure you don't close the port when you receive the "Welcome to NetLinx " message. Try this...
DEFINE_DEVICE LocalPort = 0:4:0 //Local IP Port DEFINE_FUNCTION Ping() { IP_CLIENT_OPEN(LocalPort.Port, '127.0.0.1', 23, IP_TCP) } DATA_EVENT [LocalPort] { STRING: { IF (FIND_STRING(Data.Text, 'Welcome to NetLinx', 1)) { SEND_STRING LocalPort, "'ping 8.8.8.8', $0D" } ELSE { IF (FIND_STRING(Data.Text, 'is alive', 1)) { //Success } ELSE IF (FIND_STRING(Data.Text, 'did not respond', 1)) { //Fail } IP_CLIENT_CLOSE(LocalPort.Port) } } } -
Thank you, I'll try it!
Leave a Comment
Categories
- All Categories
- 2.5K AMX General Discussion
- 922 AMX Technical Discussion
- 514 AMX Hardware
- 502 AMX Control Products
- 3 AMX Video Distribution Products
- 9 AMX Networked AV (SVSI) Products
- AMX Workspace & Collaboration Products
- 3.4K AMX Software
- 151 AMX Resource Management Suite Software
- 386 AMX Design Tools
- 2.4K NetLinx Studio
- 135 Duet/Cafe Duet
- 248 NetLinx Modules & Duet Modules
- 57 AMX RPM Forum
- 228 MODPEDIA - The Public Repository of Modules for Everyone
- 943 AMX Specialty Forums
- 2.6K AMXForums Archive
- 2.6K AMXForums Archive Threads
- 1.5K AMX Hardware
- 432 AMX Applications and Solutions
- 249 Residential Forum
- 182 Tips and Tricks
- 146 AMX Website/Forums