ping.c File Reference

Ping example. More...

#include <BoardSupport/inc/stdtypes.h>
#include <stdlib.h>
#include <stdio.h>
#include <stddef.h>
#include <inttypes.h>
#include <time.h>
#include <string.h>
#include <Libs/NETlib/net.h>
#include <BoardSupport/inc/BoardSpecific.h>
#include <Common/Common.h>
#include <Common/uartio.h>
#include <Common/timer.h>
#include <Common/CPrintf.h>
#include <BoardSupport/config/netconfig.c>

Macros

#define MAX_PING_DATA   5000 /* IP-fragmentation */
 

Functions

int main (void)
 

Variables

char * program_name = "Ping"
 

Detailed Description

                          _         _             _
                       __| |    ___(_) ____ _ __ | |_
                      / _` |   / __| |/ _` | '_ \| __|
                     | (_| | _ \__ \ | (_| | | | | |_
                      \__,_|(_) ___/_|\__, |_| |_|\__|
                     Signalprocessing |___/ Technology
Author
D.SignT GmbH & Co. KG, Claus Hermbusche
Date
2019-06-04

Macro Definition Documentation

#define MAX_PING_DATA   5000 /* IP-fragmentation */
Examples:
DNSTest.c, Ping.c, and Ping2.c.

Function Documentation

int main ( void  )
176 {
177  /***************************************************************************
178  locals
179  ***************************************************************************/
180  int main_loop = 1; /* main loop switch, set to 0 to exit */
181  timeval stamp1, stamp2, delta; /* used to determine startup time */
182 
183  /***************************************************************************
184  initialize application (e.g. timer clocks, PLL settings, EMIF etc.)
185  (ref. \Common\Common.c)
186  ***************************************************************************/
187  AppInit (GET_CLOCK);
188 
189 
190  /***************************************************************************
191  select output device for CPrintf (ref. \Common\cprintf.c)
192  possible settings:
193  CPRINTF_UART_OUTPUT -> output to UART
194  CPRINTF_CCS_OUTPUT -> output to CCS
195  CPRINTF_UART_OUTPUT | CPRINTF_CCS_OUTPUT -> output to UART and CCS
196  ***************************************************************************/
197  CPrintf_select_output (CPRINTF_DEFAULT_OUTPUT); /* default outputs */
198 
199  /***************************************************************************
200  print a start up message
201  ***************************************************************************/
202  START_UP_MESSAGE (BLANK_REV NETLIB_REV);
203 
204  /**************************************************************************/
205  // CPrintfProgress (" Heap check ");
206  // at least 0x2000 bytes required for this app
207  /**************************************************************************/
208  ASSERT_HEAP (initial_heap_size, 0x2000);
209  // CPrintfProgressSuccess();
210 
211  /**************************************************************************/
212  CPrintfProgress (" Setup system time ");
213  // CPU interrupt 14, timer 1, 1 milli seconds resolution
214  /**************************************************************************/
217  CPrintf (" *** timer %d mapped to CPU int %d ***\r\n",
219 
220  /**************************************************************************/
221  CPrintfProgress (" Enable interrupts ");
222  /**************************************************************************/
225 
226  /**************************************************************************/
227  CPrintfProgress (" Start system timer ");
228  /**************************************************************************/
229  StartSystemTimer ();
231  CPrintf (" *** timer %d running at %"PRId32" Hz ***\r\n", SystemTimerDev, RES_SECONDS/GetSystemTimerRes());
232 
233  /***************************************************************************
234  measure network initialization time
235  ***************************************************************************/
236  stamp1 = GetTimeStamp();
237 
238  /**************************************************************************/
239  CPrintfProgress (" Initialize network ");
240  /**************************************************************************/
243 
244  stamp2 = GetTimeStamp();
245 
246  tv_interval (&delta, &stamp1, &stamp2);
247  CPuts (" network startup time [sec]: ");
249  "%"PRId32".%03"PRId32"\r\n"
251  delta.tv_sec,
252  delta.tv_usec/1000);
253 
254 
255  /***************************************************************************
256  main loop
257  ***************************************************************************/
258  CPuts (" IP-fragmentation test:\r\n\n");
259  CPrintf (">ping %s -l 5000\r\n",eth.ip);
260 
261  /***************************************************************************
262  main program loop: set main_loop to 0 to exit loop
263  ***************************************************************************/
264  CPuts ("\r\n Entering main loop ...\r\n");
265  while ( main_loop )
266  {
267  /***********************************************************************
268  process net_isq()
269  ***********************************************************************/
270  net_isq (); // process ISQ
271 
272  /***********************************************************************
273  monitor link status
274  ***********************************************************************/
276 
277  /***********************************************************************
278  try to detect IP assignment
279  if DHCP is used, the assigned IP address may change
280  ***********************************************************************/
282 
283  /***********************************************************************
284  show that the program is running, perform symbol animation
285  ***********************************************************************/
287  }
288 
289  /***************************************************************************
290  exit program, shut down peripherals
291  ***************************************************************************/
292  return (0);
293 }
void BoardEnableInterrupts(void)
global enable interrupts
Definition: BoardSpecific.c:365
#define ANIMATE_SYMBOLS_COUNT
Definition: BoardSpecific.h:268
void StartSystemTimer(void)
start system timer
Definition: timer.c:447
#define RES_MSECONDS
Definition: timer.h:67
uint16_t CPrintf_select_output(uint16_t device)
Definition: cprintf.c:206
#define ASSERT_HEAP(i, h)
Definition: Common.h:262
#define MAX_PING_DATA
Definition: ping.c:145
time_t GetSystemTimerRes(void)
Definition: timer.c:160
#define GET_CLOCK
Definition: BoardSpecific.h:258
int CPrintf(const char *_format,...)
Custom printf function.
Definition: cprintf.c:708
#define VT100_DEFAULT
Definition: cprintf.h:150
void SetupSystemTime(int32_t cpuint, int port, time_t resolution)
Setup System Time.
Definition: timer.c:392
void AppInit(uint32_t dsp_clock)
Initialize application.
Definition: Common.c:230
uint32_t initial_heap_size
Definition: Common.c:140
#define CPRINTF_DEFAULT_OUTPUT
Definition: BoardSpecific.h:129
#define VT100_RED
Definition: cprintf.h:143
uint16_t CPrintAnimatedSymbol(char *c, time_t period, size_t size)
Definition: cprintf.c:816
int InitializeNetwork(uint16_t icmp_size)
Initialize MAC, sockets and protocols.
Definition: BoardSpecific.c:597
char sym_animate[]
Definition: BoardSpecific.c:129
Definition: timer.h:75
#define GetTimeStamp()
Definition: timer.h:81
void tv_interval(timeval *e, timeval *t1, timeval *t2)
compute elapsed time
Definition: timer.c:336
#define SYSTEM_TIMER_INT
Definition: BoardSpecific.h:174
#define SYSTEM_TIMER
Definition: BoardSpecific.h:167
void net_isq(void)
The main polling function for processing sockets, must be periodically called in the main application...
char ip[31]
Definition: net.h:170
#define BLANK_REV
Definition: BoardSpecific.h:191
Uint16 SystemTimerDev
adapter_t eth
Definition: netconfig.c:62
uint16_t monitor_ip_address(tpOutputFunc pLog)
monitor IP assignment
Definition: BoardSpecific.c:545
#define START_UP_MESSAGE(rev)
Definition: BoardSpecific.h:192
#define RES_SECONDS
Definition: timer.h:70
uint16_t monitor_link_status(tpOutputFunc pLog)
monitor link status change
Definition: BoardSpecific.c:497
int CPuts(const char *_ptr)
Definition: cprintf.c:399
time_t tv_sec
Definition: timer.h:77
#define CPrintfProgress(s)
Definition: cprintf.h:230
time_t tv_usec
Definition: timer.h:78
#define CPrintfProgressSuccess()
Definition: cprintf.h:263

Variable Documentation

char* program_name = "Ping"