Ping (ICMP) Demo

Microchip TCP/IP Stack

Microchip TCP/IP Stack Help
Ping (ICMP) Demo

Overview 

The Ping Demo explains how to use the ICMP client to check if a remote node is reachable. If the project with this demo includes the DNS module, the PIC will ping "ww1.microchip.com." Otherwise, it will ping the local gateway. This demo is only available on hardware setups with LCD displays (e.g. Explorer 16 or PICDEM.net 2). 

Instructions 

  1. Press Button 0 on your demo board. Button 0 is usually the rightmost or topmost button on the board (check the BUTTON0_IO macro in the copy of HardwareProfile.h that corresponds to your project to determine exactly which button is Button 0).
  2. When the device receives an echo response from the remote node or when the ping times out, the LCD will be updated with the appropriate information.

Description 

The PingDemo task function implements a two-state state machine. The task will wait in the SM_HOME state until the user presses button 0. Once the button is pressed, the task will attempt to obtain ownership of the ICMP module with the ICMPBeginUsage function. If it does, it will send a ping to the specified address and transition to the SM_GET_ICMP_RESPONSE state. 

In the SM_GET_ICMP_RESPONSE state, the task will call the ICMPGetReply callback function and take action depending on the return value:

Value 
Action 
-2 
Remain in this state and keep waiting for a response. 
-1 
Write a message to the LCD indicating that the ping timed out. Change state to SM_HOME. 
-3 
Write a message to the LCD indicating that the DNS module couldn't resolve the target address. Change state to SM_HOME. 
Other 
Convert the response time to a text string and print it to the LCD. Change state to SM_HOME. 
Functions
 
Name 
Description 
 
Demonstrates use of the ICMP (Ping) client. 
Topics
Name 
Description 
The following table lists macros in this documentation. 
Macros
 
Name 
Description 
 
Address that ICMP client will ping. If the DNS client module is not available in the stack, then this hostname is ignored and the local gateway IP address will be pinged instead. 
Microchip TCP/IP Stack 5.42.08 - June 15, 2013
Copyright © 2012 Microchip Technology, Inc.  All rights reserved.