loadtime - v1.1

Setting the System Time via the TCP Time Service

Rich Neswold

$Date: 1999/05/24 16:40:59 $

This document describes a VxWorks module that queries a remote machine for the date and uses it to set the local system time.

Contents

1.  Introduction
2.  Using This Module
3.  Function Reference

1.   Introduction

This module provides a way to synchronize your VxWorks system time to a server on the network.

2.   Using This Module

This facility is provided as both a loadable module and a linkable library. The module is called loadtime-1.1.o and is found in the module products directory. If you wish to automatically load the latest module, you should load via the symbolic link loadtime.o, which always points to the most recent version. If you would rather link with the library, the function prototypes are found in loadtime.h. You'll also need to link with libloadtime-1.1.a. Similarly, the symbolic link libloadtime.a always points to the most recent library.

The time service, used by this module, returns Greenwich Mean Time (GMT). In order to properly adjust the time to a local representation, the environment variable TIMEZONE must be set. For 1999, the proper setting for this variable is:

putenv("TIMEZONE=CSTCDT::360:040402:100302");

You can check to see if this variable has been set by using the envShow function.

A typical use of this module would be to set the time from our operational Unix box in a VxWorks startup script1:

hostAdd("fecode-bd", "131.225.121.145");
ld(1, 1, "vxworks_boot/module/PPC603/loadtime.o");
systemTimeSet("fecode-bd");

3.   Function Reference

3.1.  systemTimeSet
3.2.  systemTimeShow

This section contains descriptions of all the available functions in the module.

3.1.   systemTimeSet

3.1.1.  Synopsis
3.1.2.  Description
3.1.3.  See Also

3.1.1.   Synopsis

STATUS systemTimeSet(char const* addr);

3.1.2.   Description

This function sets the system clock to the time obtained by a remote machine. The time is retrieved using the TCP/IP time service (TCP port 37). The addr parameter should point to the name of a machine. If DNS services aren't available, the machine name should first be defined using hostAdd().

3.1.3.   See Also

hostAdd()

3.2.   systemTimeShow

3.2.1.  Synopsis
3.2.2.  Description

3.2.1.   Synopsis

void systemTimeShow(void);

3.2.2.   Description

This function simply prints, to the console, the local time. The time is set using GMT, so to get a valid local time, the TIMEZONE environment variable needs to be set to the proper value.

Notes

1.

This is for a PowerPC-based system. 68K systems would replace PPC603 with MC68020. We are working on a way to make this transparent to the users of our products, but a solution hasn't been put in place, yet.

Security, Privacy, Legal