hamilton@intersil.uucp (Fred Hamilton) (02/08/90)
I can read the Amiga system time with DateStamp(). But how do I SET it? Thanks. (I'm installing a battery backed up clock in my 1000.) -- Fred Hamilton Any views, comments, or ideas expressed here Harris Semiconductor are entirely my own. Even good ones. Santa Clara, CA
ZZFRICK@DHVRRZN1.BITNET (02/10/90)
Date: 9 February 1990, 19:47:03 MEZ From: Harald Fricke 05 11/790-20 25 ZZFRICK at DHVRRZN1 To: COMP-SYS-AMIGA-TECH at UCBVAX.BERKELEY.EDU Setting the system time is a bit complicated. Given Date and Time in a human- readable format, you'll have to calculate the number of seconds elapsed since Jan 01, 1978. Then open the timer.device, UNIT_MICROHZ and send a SETSYSTIME command with the number of seconds in it. This approach is from a clock project published in a back issue of the German c't computer magazine. It works, I used the code in a program that reads the contents of a DCF77 clock receiver over the serial line and stuffs the result into the system clock of my A1000. I'd be grateful to hear if there is an easier way to do this... ------------------------------------------------------------------------- Harald Fricke <ZZFRICK@DHVRRZN1.BITNET> Disclaimer: RRZN Hannover and me have no opinions in common. Any opinions expressed are my own. Some computer stores sell incredibly bad machines ...
a218@mindlink.UUCP (Charlie Gibbs) (02/11/90)
In article <77.25d0c638@intersil.uucp> hamilton@intersil.uucp (Fred Hamilton) writes: >I can read the Amiga system time with DateStamp(). > >But how do I SET it? > >Thanks. (I'm installing a battery backed up clock in my 1000.) I couldn't figure it out either, so I cheated - I just built an appropriate DATE command and Execute()d it. Working in assembly language I got my program down to 400 bytes. Charlie_Gibbs@mindlink.UUCP "I have never met Napoleon, but I plan to find the time." -- Steely Dan
<LEEK@QUCDN.QueensU.CA> (02/17/90)
> I can read the Amiga system time with DateStamp(). > But how do I SET it? You can use the Execute() to call up Amiga DOS command - Date in your C: directory. Here is the bit and pieces of code from my own Real Time Clock... static char *DOS_CMD = "Date HH:MM:SS DD-MMM-YY"; /* your code can substitute the actual time & date into HH:MM:SS */ Execute(DOS_CMD,NULL,NULL); /* Execute the Date command to set time */ Hope this help. If you or anyone else that need more info (for a 4 chips real time clock - source code & schematic), please send me EMail. K. C. Lee P.S. I do not represent Queen's University nor any groups. (No wonder I am struck building my hardware.)
p554mve@mpirbn.UUCP (Michael van Elst) (02/18/90)
In article <1113@mindlink.UUCP> a218@mindlink.UUCP (Charlie Gibbs) writes: >In article <77.25d0c638@intersil.uucp> hamilton@intersil.uucp >(Fred Hamilton) writes: >>I can read the Amiga system time with DateStamp(). >>But how do I SET it? >>Thanks. (I'm installing a battery backed up clock in my 1000.) > > I couldn't figure it out either, so I cheated - I just built >an appropriate DATE command and Execute()d it. Working in assembly >language I got my program down to 400 bytes. I tried to mail to the orignal poster but did not succeed. Here comes the letter. > By the way, I re-mapped my clock to $980000 and it works great. I still > haven't figured out how to set the Amiga system time from within a C > program (I'm new to C and all these structures, DoIO calls, and lousy > documentation are really making my brain hurt), but I can set my clock > to the Amiga system time and dump it to verify that it works. Hello, you should get the new manuals (the complete set is the stores for about 4 weeks). It's not easy for a C novice but the examples will say you much about C and Amiga programming. Now, for your question. The system clock is managed by the timer.device. You should open the device for unit UNIT_VBLANK. Then use the TR_SETSYSTIME command to set the date and time. You'll need to convert date/time into system time which is seconds and microseconds since 1.january 1978 0:00. (Is the year correct ? Hmm) Example: #include <devices/timer.h> struct timerequest *treq; struct MsgPort *port; /* create an IO reply port */ port = CreatePort(0,0); if (port == NULL) cleanup("can't get io reply port"); /* create the IO message */ treq = (struct timerequest *)CreateExtIO(port,sizeof(struct timerequest)) if (treq == NULL) cleanup("can't get timer request"); /* get access to the timers */ if (OpenDevice(TIMERNAME, UNIT_VBLANK, treq, 0)) cleanup("can't open timer.device"); /* and now set the system time, seconds and micros should be the time you want to set */ treq.tr_node.io_Command = TR_SETSYSTIME; treq.tr_time.tv_secs = seconds; treq.tr_time.tv_micro = micros; DoIO(treq); /* and free all resources */ CloseDevice(treq); DeleteExtIO(treq); DeletePort(port); --------------------- Most of the code is needed only once in a real program, you may use the same timerequest over and over again. Oh, and cleanup() doesn't exist. I use one routine that frees all the resources I've claimed throughout the whole program, it something like: cleanup(message) char *message; { if (treq != NULL && treq->tr_node.io_Device != -1) CloseDevice(treq); if (treq != NULL) DeleteExtIO(treq); if (port != NULL) DeletePort(port); if (s != NULL) fprintf(stderr,"cleanup: %s\n",message); } If you want to read the current system time then use instead: treq.tr_node.io_Command = TR_GETSYSTIME; DoIO(treq); seconds = treq.tr_time.tv_secs; micros = treq.tr_time.tv_micro; ---------------------- And I recommend it a second time, all the information is in the Rom Kernal Manuals. -- Michael van Elst E-Mail: uunet!unido!mpirbn!p554mve Internet: p554mve@mpirbn.UUCP