Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!ucla-cs!ames!ucbcad!ucbvax!hplabs!hpcea!hpfcdc!hpfclp!diamant From: diamant@hpfclp.UUCP Newsgroups: comp.os.minix Subject: Re: Clock setting program for AST Six Pack Message-ID: <9490005@hpfclp.HP.COM> Date: Sun, 19-Apr-87 19:25:16 EST Article-I.D.: hpfclp.9490005 Posted: Sun Apr 19 19:25:16 1987 Date-Received: Sat, 25-Apr-87 03:50:53 EST References: <771@killer.UUCP> Organization: HP, Fort Collins, CO Lines: 56 I have also written an astclock replacement program (for a MegaPlus, but it probably works the same for the other AST cards). I also took the port_in routine the same as Tom. The compilation command is identical. Tom, mine is considerably simpler than yours. There are two main reasons I see for this: 1) You copied the code for date into astclock. I just called date. 2) You seem to have bullet proofed your code against conditions I don't understand (such as why do you need to call the clock twice -- do you get garbage back sometimes -- I never have). Tom, maybe you'd care to comment on why you do as much as you do in your version. -------- astclock.c (not shar) -- cut here: /* Written by: John Diamant 04/15/1987 Contributed to the public domain This was written for the AST MegaPlus card, but it probably works for the other AST cards. Should be called in /etc/rc as follows: "date `astclock`" where path information has been deleted. This only works within the range inputtable by date (what happens in 2000?) and will be a few seconds off because of the time to call date after astclock returns its answer. The algorithm is also only tested within the years specifiable by date in MS-DOS (the way the clock is set on the board), which means 1980-2099. Since I had virtually no documentation for the clock chip, I could only figure out the representation for the dates I could set */ #include #define CLOCK_PORT 0x2C0 #define SECOND 2 #define MINUTE 3 #define HOUR 4 #define DAY 6 #define MONTH 7 #define Y1 8 #define Y2 9 #define Y3 10 main() { int month, day, year, hour, minute, second; port_in(CLOCK_PORT + SECOND, &second); port_in(CLOCK_PORT + MINUTE, &minute); port_in(CLOCK_PORT + HOUR, &hour); port_in(CLOCK_PORT + DAY, &day); port_in(CLOCK_PORT + MONTH, &month); port_in(CLOCK_PORT + Y3, &year); year += 80; printf("%02x%02x%02d%02x%02x%02x", month, day, year, hour, minute, second); }