Time and NTP on RTEMS

Eric Norum eric.norum at usask.ca
Mon Jan 29 14:10:47 UTC 2001

Jake Janovetz wrote:
> Hello...
>     I've recently needed to integrate time into my RTEMS applications
> and have a couple questions.  I see that the NTP is supported, but only
> in single-query mode (not a daemon).  This should be adequate for what
> I want.  I have called time(), then localtime(), then strftime() to
> get a printout of the current time, but I see that the time is off
> by several hours, so I assume the timezone has not been properly
> set.  How is this supposed to be done in RTEMS?
>     Daemon mode of NTP is relatively complicated if I understand it
> correctly (having to continually make small adjustments to slide the
> device time to the proper time).  Is this something currently under
> development (for RTEMS)?

RTEMS has no notion of timezone.  The NTP client routine just sets
gmtime with the value obtained from the NTP server.  I put a hack in to
allow an offset using the DHCP/BOOTP time-offset option. This makes
gmtime wrong, but local time right.

The offset, in seconds, from GMT is stored in rtems_bsdnet_timeoffset. 
Now that I look at the code, it appears to me that I've got the sign
wrong -- the offset (which will be negative west of the prime meridian)
should be added to the NTP base value.

A true NTP client for RTEMS is on my to-do list, but way, way, waaaaay,
down the list.
Eric Norum                                 eric.norum at usask.ca
Department of Electrical Engineering       Phone: (306) 966-5394
University of Saskatchewan                 FAX:   (306) 966-5407
Saskatoon, Canada.

More information about the users mailing list