Can a command like "ping" be used in the R1 controller

Hi all, is it possible to use a command like “ping” in the R1 controller to check if a network device is online? Thanks!

I’ve never used the node, but Node-Red has that

The forums search function works really well for finding things on the forums.
Its always fun and interesting to search for your question as you end up learning more with just a few minutes reading.

Here is your answer…
https://www.opto22.com/support/resources-tools/downloads/pingbasicexample-cxf

thank you very much!

I have used this Ping Chart with an R1 and it works well.
I’d like to run this on an Epic, because it is a Pac-Control-only solution. But I get an “invalid address” error -56, on the mmp write command.
The comments in the chart mention the MMP Addresses it uses are undocumented. It looks like they still are. I can’t find them in form 1465.

For example, 0xF0321000
From GroovManage / Generic MMP , the Epic shows this address as Invalid as well.

Maybe I’ve got something else wrong, but is there any chance to do this Ping from the Epic? Were these R1 features ever duplicated in the Epic?

Here are the mmp comments from the ping chart:

// Although this section of the memory map is not "official" yet (could get removed anytime, but most likely won't)
// here's what form 1465 might say about these addresses if/when we do make this section official (fully tested/documented)

// =======> Ping Client Configuration Area <=======
// This read/write area contains configuration information for the ping client. (Type B = binary, IP = IP address, UI = unsigned Integer)
//  Memory Map Address    Length  Type    Description 
//  ---------------------------------------------------
//  0xF0321000            4       B       Enable ping client. 0 = Disabled, 1 = Enabled. 
//  0xF0321004            4       IP      IP address of target to which ping requests are sent. 
//  0xF032100xF032100008            4       UI      Size of ping request data payload. (Defaults to 56 if set to 0.) 
//  0xF032100C            4       UI      How long to wait (in seconds) between ping requests. 


// =======> Ping Client Status Area <=======
// This read only area contains status information for the ping client. 
//  Memory Map Address    Length  Type    Description 
//  ---------------------------------------------------
//  0xF0321400            4       UI      Status (0=disabled, 1=running, 2=size configured is too big, 3=target host unreachable)

// These millisecond values, on SNAP-PAC, are rounded down to the nearest 100ms
//  0xF0321404            4       UI      Last RTT. Time (in milliseconds) between the last ping request and the associated response.
//  0xF0321408            4       UI      Maximum RTT. Maximum time (in milliseconds) between ping request and associated response.
//  0xF032140C            4       UI      Minimum RTT. Minimum time (in milliseconds) between ping request and associated response.
//  0xF0321410            4       UI      Average RTT. Average time (in milliseconds) between ping request and associated response.


//  0xF0321414            4       UI      Number of requests transmitted.
//  0xF0321418            4       UI      Number of responses received. 

//  0xF032141C            4       UI      Number of duplicate responses received. 

No chance. This area is not there on EPIC or RIO.
You will need to use the ping node (there are a few to chose from) in Node-RED and move the results into the scratchpad or a variable with the PAC nodes.

EDIT, if it really really needs to be a PAC Control only application, see if there are any services running on the IP address you intend to ping and use a PAC Control comm handle to connect to that service. If it connects, the ‘ping’ is good, if it not, the host or service is down.

I figured out another way. httpGet

Here is the code. I have not tested it well yet, but it is a good start.


  // set a default value if it is empty
  if (Online_Setting_Ping_Url == "") then
    Online_Setting_Ping_Url = "www.google.com";
  endif

  online_port = 80;
  online_cmd = "/";
  online_result = HttpGet(online_DestStringTableBody, online_DestStringTableHeader, online_SourceStringTableBody, 0, online_cmd, online_http_status, online_port, Online_Setting_Ping_Url);
  if (online_result >= 200 AND online_result < 400) then
    // Internet is up
    Online_Status=1;
  else
    // Internet is down
    Online_Status=0;
  endif


1 Like

Yup, that was my EDIT suggestion. Make a connection with a comm handle.
You can do telnet, web, FTP and perhaps some other services that might be running on the host you are looking to see if its alive or not.

In a lot of ways I prefer this solution as it tells you both if the host is up and the service is running.
I’ve had times with ping when “the lights are on, but no one is home” that has cost me some time.

Didn’t take long. I already found a mistake I made on testing the results -
This works better…

  // set a default value if it is empty
  if (Online_Setting_Ping_Url == "") then
    Online_Setting_Ping_Url = "www.google.com";
  endif

  online_port = 80;
  online_cmd = "/";
  online_result = HttpGet(online_DestStringTableBody, online_DestStringTableHeader, online_SourceStringTableBody, 0, online_cmd, online_http_status, online_port, Online_Setting_Ping_Url);
  if (online_result==0 AND (online_http_status >= 200 AND online_http_status < 400)) then
    // Internet is up
    Online_Status=1;
  else
    // Internet is down
    Online_Status=0;
  endif
1 Like

Why not just make a TCP connection and then disconnect? Pulling in an entire webpage to check if your connection is good is a tad bit overkill.

Depends on if you are looking for is the host alive, or is the service running.
But yeah, if its just a ‘ping’, then just a connect is enough.

Great point… who needs all that webpage body.

I found a google page with no body. Apparently it is a long-standing URL that is specifically designed by Google for connectivity testing

Online_Setting_Ping_Url = “clients3.google.com”;
online_cmd = “/generate_204”;

1 Like