Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rutgers!sri-spam!mordor!styx!ptsfa!hoptoad!academ!killer!tsp From: tsp@killer.UUCP (Tom Poindexter) Newsgroups: comp.os.minix Subject: Re: Clock setting program for AST Six Pack Message-ID: <805@killer.UUCP> Date: Mon, 27-Apr-87 14:32:49 EDT Article-I.D.: killer.805 Posted: Mon Apr 27 14:32:49 1987 Date-Received: Wed, 6-May-87 05:25:27 EDT References: <771@killer.UUCP> <9490005@hpfclp.HP.COM> Organization: The Unix(tm) Connection, Dallas, Texas Lines: 54 Summary: astclock.c rationale [ In <9490005@hpfclp.HP.COM>, diamant@hpfclp.HP.COM (John Diamant) writes: ] >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. John, here are the reasons for writing my version of astclock.c as I did: 1. The code from `date.c' to compute the number of seconds since epoch and calling stime() was used because of a comment to an earlier posting of an AT clock reading & setting program. The commentator cautioned against using pipes during init becase of possible (or prior) damage to the file system. I don't have the posting any longer to pinpoint the possible hazards, but I took the advice anyway. I will also have to hack both date.c and my astclock.c in Dec. 2099, assuming I still have my PC & AST board and I am not {a higher life form/a frog/dust}, since date.c doesn't figure leap years quite correctly. :-) 2. I read the clock chip twice based on the programming suggestions in my AST Six Pack manual. I never experienced a situation where two readings were different in my testing, but just in case..... 3. I didn't experiment with the clock chip much, so I didn't know one could read directly from the clock registers. The valid clock i/o addressing is listed as 0x02c0 through 0x02c7 in the manual; your program addresses ports beyond 0x02c7 (CLOCK_PORT + Y3 to address year, where CLOCK_PORT is 0x02c0 and Y3 is 10). Could be that my documenation doesn't tell all or your MegaPlus is wired up differently, or uses a different clock chip. My Six Pack clock chip always returned 'F' as the high nibble, so I and'ed the value returned with LOW_4 (0x0f) after reading it. 4. As a matter of my programming style, I tend to bullet-proof, write verbosely, add comments, etc., especially on code that I release publicly, so that others can make changes, find bugs, etc. My previous iterations of the program were rather terse and clunky. In any case, thanks for your comments and code; I always look for easier ways of doing things. Perhaps someone can verify if the Six Pack Plus clock chip & i/o addressing are the same for the MegaPlus. -Tom Tom Poindexter ..!ihnp4!killer!tsp