Syntax
int SyncPing(
unsigned int ipAddress,
unsigned char ttl,
int *rtt
);
Parameters
- ipAddress
- [in] Specify the IP address.
- sock
- [in] Specify the TL.
- rtt
- [out] Specifies a pointer to receive the round trip time.
Return value
The following values will be returned.Value | Description |
---|---|
PING_ERR_SUCCESS | Ping succeeded |
PING_ERR_FAIL | Illegal parameter |
PING_ERR_TIMEOUT | PING time out |
PING_ERR_DEST_UNREACH | PING Unreach |
PING_ERR_WRONG_RESPONSE | Receive PING from a network device different from the specified one. |
Remarks
Sends a PING to the specified IP address.It will time out in about 5 seconds.
Requirements
Header file:
lib.hLibrary file:
libSTARTUPOPH5000.a
Sample
#include <stdio.h>
#include "lib.h"
void main(void)
{
int ret;
int i;
int connectStatus = SYS_WLAN_STATUS_UNAVAILABLE;
unsigned int hostIp = nmi_inet_addr("192.168.0.1");
char *ipAddress;
unsigned char ttl = 128;
unsigned int rtt;
ret = SysWLANInit(NULL);
while (connectStatus != SYS_WLAN_STATUS_CONNECTED)
{
ret = SysGetWLANConnectStatus(&connectStatus);
Idle();
}
for (i = 0; i < 4; i++)
{
ret = SyncPing(hostIp, ttl, &rtt);
printf("SyncPing(%x,%d,%p):\n\r", hostIp, ttl, &rtt);
ipAddress = (char *)&hostIp;
printf("IP:%u.%u.%u.%u\n\r", ipAddress[0], ipAddress[1], ipAddress[2], ipAddress[3]);
printf("ret=%d,ttl=%d,rtt=%d\n\r", ret, ttl, rtt);
Idle();
}
while(1)
Idle();
}
Last updated: 2020/10/14