Ping

TwinCAT TIA
Network Network tools

ns=2;s=DEPRAG Smart/Network/Tools/Ping

This command sends an ICMP (Internet Control Message Protocol) request to the configured host address. A corresponding response is expected from the host address within the configured time. This function is useful for testing network availability, PLC reachability, network status diagnostics, etc.

Parameters:

    TimeOutInMilliseconds
    The amount of time in milliseconds (after sending the message) to wait for the response from the host address.

Returns:

    Ping
    A structure variable of type OpcMethodReturnValueToolsReturnValue. The Result property contains the command-specific return values.

Examples:

In addition to the parameters already explained, the following variables must be created / transferred for the implementation in TwinCAT 3:

Beckhoff parameter:

    bPingServer
    A boolean variable that can be used to trigger the execution of the Ping command.
    OutputDataPing
    An instance of the "ST_PingOutputData" structure into which the return value of the Ping method is written.
    hrPing
    This can be used to monitor the execution of the command. Error codes have the type "HRESULT".
    fbTools
    An instance of the "FB_Tools" function block supplied with the DEPRAG Smart library.
    ConnectionHandle
    "ConnectionHandle" received when establishing a connection between DEPRAG Smart Server and your OPC UA client.


VAR
    bPingServer  : BOOL;
    OutputDataPing : ST_PingOutputData;
    hrPing  : HRESULT;
                            
    fbTools             : FB_Tools;
END_VAR

hrPing := fbTools.Ping(bPingServer, depragSmartConnection.ConnectionHandle, '10.10.222.110', 3, 5000, OutputData => OutputDataPing);
IF hrPing <> S_FALSE THEN 
    bPingServer := FALSE;
END_IF
                                                    

For examples and explanations regarding the calls of nodes via Siemens TIA Portal please refer to the sub-menu "Siemens TIA Portal" in section "Getting Started".