From d1302e6242523c26b2a1d73b9a7c1e51da5cd9dd Mon Sep 17 00:00:00 2001 From: "W. Eric Norum" Date: Wed, 7 Nov 2001 14:19:07 +0000 Subject: [PATCH] Don't lock up if no NTP time synchronization packet is received. Try for about 30 seconds then set the date and time to a default value (January 1, 2001). This should make it easier for people to get EPICS/RTEMS working since they can try out the example application without having an NTP server on their network. --- src/RTEMS/base/rtems_init.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/RTEMS/base/rtems_init.c b/src/RTEMS/base/rtems_init.c index f3b08ff4c..a6dddaabe 100644 --- a/src/RTEMS/base/rtems_init.c +++ b/src/RTEMS/base/rtems_init.c @@ -199,6 +199,8 @@ const void *rtemsConfigArray[] = { rtems_task Init (rtems_task_argument ignored) { + int i; + /* * Create a reasonable environment */ @@ -214,11 +216,29 @@ Init (rtems_task_argument ignored) rtems_bsdnet_initialize_network (); printf ("***** Initializing TFTP *****\n"); rtems_bsdnet_initialize_tftp_filesystem (); - for (;;) { + for (i = 0 ; ; i++) { printf ("***** Initializing NTP *****\n"); if (rtems_bsdnet_synchronize_ntp (0, 0) >= 0) break; - epicsThreadSleep (10.0); + epicsThreadSleep (5.0); + if (i >= 8) { + rtems_status_code sc; + rtems_time_of_day now; + printf (" *************** WARNING ***************\n"); + printf (" ***** NO RESPONSE FROM NTP SERVER *****\n"); + printf (" ***** TIME SET TO DEFAULT VALUE *****\n"); + printf (" ***************************************\n"); + now.year = 2001; + now.month = 1; + now.day = 1; + now.hour = 0; + now.minute = 0; + now.second = 0; + now.ticks = 0; + if ((sc = rtems_clock_set (&now)) != RTEMS_SUCCESSFUL) + printf ("***** Can't set time: %s\n", rtems_status_text (sc)); + break; + } } printf ("***** Initializing syslog *****\n"); openlog ("IOC", LOG_CONS, LOG_DAEMON);