Dec 252017
Set time to US Naval Obs with Turbo C source.
File NAVYTIME.ZIP from The Programmer’s Corner in
Category Communications
Set time to US Naval Obs with Turbo C source.
File Name File Size Zip Size Zip Type
ATFINISH.C 1510 624 deflated
ATFINISH.H 130 62 deflated
COMM.C 7620 1799 deflated
COMM.H 477 163 deflated
MAKEFILE 357 147 deflated
NAVYTIME.C 6831 2002 deflated
NAVYTIME.DOC 7808 2676 deflated
NAVYTIME.EXE 15562 9656 deflated
NAVYTIME.PRJ 103 67 deflated
NAVYTIME.RC 77 74 deflated
NAVYTIME.RV 60 57 deflated
SETTZ.C 1147 519 deflated
TIMER.C 2063 684 deflated
TIMER.H 189 98 deflated

Download File NAVYTIME.ZIP Here

Contents of the NAVYTIME.DOC file

NAVYTIME -- Get Date/Time from Naval Observatory Page 1

Copyright 1987 Michael M Rubenstein

This software may be freely distributed as long as no fee is
assessed and the copyright notice is retained.

The functions contained in COMM.C, TIMER.C, and ATFINISH.C may be
distributed as part of an executable program (including
commercial distribution) provided the following copyright notice
is included:

Portions copyright 1987 Michael M Rubenstein


NAVYTIME calls the 1200 baud Naval Observatory time service for
digital clocks at (202) 653-0351 and sets the system time.
Because of delays in the phone system, the time may be off by as
much as .5 second.


Before using NAVYTIME certain things have to be set up. The
program must know the time zone and whether daylight savings time
is used. This is done by setting an environment variable TZ with
the command

set TZ=xxxnyyy

where xxx and yyy are any letters and n is the number of hours
behind Greenwich Mean time for standard time. If yyy is omitted,
the NAVYTIME assumes that daylight savings time is NOT used. xxx
and yyy are intended to be the abbreviation for the time used
(xxx for standard time, yyy for daylight savings time).

For example, if the area you are in uses Eastern Standard/Eastern
Daylight time, the command would be


(Eastern Standard is 5 hours behind GMT). If Eastern Standard is
used throughout the year, the command would be

set TZ=EST5

Note that the number of hours behind GMT may be more than one
digit (in the Pacific) or may be negative (in most of Europe,
Africa, and Asia). The program, however, determines if Daylight
savings time is in effect based on the United States conventions.

It will also be necessary to modify the the configuration file,
NAVYTIME.RC. Users not in the Washington DC local calling area
will have to change the phone number on the second line to
include the area code. If your modem is not on COM1 or is not
NAVYTIME -- Get Date/Time from Naval Observatory Page 2

compatible with the Hayes 1200, other changes will be required.

The configuration file has a rather inflexible format. Each line
has a specific meaning. It is important that there be no spaces
at the ends of lines. The lines have the following meanings

Line Meaning
---- -------------------------------------------------
1 The COM port to use. Only 1 and 2 are supported.

2 The command to initialize the modem and dial. It
consists of any combination of the following

- Strings in quotes which are sent to the
modem verbatim.

- Pairs of the form ^x where x is any
printing character which results in the
control character corresponding to x to be
sent. For example, to send a carriage
return, include the pair


- Integers which specify a delay in tenths of
a second. To pause one second include the
integer 10. Numbers larger than 3600 (if
your modem needs a delay any where close to
that, you have my deepest sympathy) will
not work properly.

- Any other characters, typically spaces,
which are ignored.

3 The command to send to terminate a call. This
line may be empty if the modem is configured to
disconnect when DTR is dropped.

4 The string to match to recognize establishment of
a connection. The modem must send a connection
message terminated by a carriage return or line
feed. A message containing this string in any
position (for example, NNEC will match CONNECT)
will be taken as indicating that the connection is
complete. Upper and lower case letters are
considered different.

4-19 Up to 15 strings to match to recognize failure to
make a connection. These are matched in the same
way as the connect string.

An alternate configuration file for the Racal Vadic 2400V (and
possibly other Racal Vadic) modems is included as NAVYTIME.RV.

Finally, it is necessary to inform the program where the
NAVYTIME -- Get Date/Time from Naval Observatory Page 3

configuration file will be found. Normally, it assumes that the
configuration file will be C:\ETC\NAVYTIME.RC. If this is not
convenient, set the environment variable NAVYTIME to the full
name of the configuration file. For example, if the file will be
D:\CONFIG\NAVYTIME.CFG, use the command

set NAVYTIME=d:\config\navytime.cfg


If invoked with no parameters, NAVYTIME will call the time
service and set the DOS time, displaying no messages if
successful. If the command line parameter -v is given, the time
will be displayed. If the parameter -vv is given, modem messages
will also be displayed.

NAVYTIME does not set a battery backed up clock unless this is
done by MSDOS when the DOS time is set. To set a battery backed
up clock, invoke NAVYTIME with a batch file includes a command to
set the battery clock from the MSDOS time.

For the Hacker.

NAVYTIME is written in Turbo C. Since one of the reasons for
writing this program was to evaluate Turbo C, no attempt was made
to keep compatibility with other versions of C. Most other C
compilers will have difficulty with the prototype declarations
and the inline assembly code of comm.c.

Three files, COMM.C, TIMER.C, and ATFINISH.C will be of general
interest to Turbo C programmers.

COMM.C implements simple interrupt driven output, polled input to
COM1 and COM2. The main limitations are no checking for parity
or other errors and flow control is not implemented.

TIMER.C is a simple stopwatch timer. Because of MSDOS
limitations, timer completion must be polled with chk_timer().

ATFINISH is similar to the library function ATEXIT except that
the registered function will always be executed when the program
terminates (ATEXIT functions are executed only on normal
termination). Up to 8 functions may be registered.

These functions may be used for both free and commercial
distribution provided my copyright notice is included.
Commercial distributions may not include source or relocatables.

 December 25, 2017  Add comments

Leave a Reply