[comp.sys.atari.st] help - a little of your time, if not the ST's

turner@imagen.UUCP (D'arc Angel) (12/16/86)

i have spent the weekend pounding my head against this problem, i
run the following program (compiler - Megamax, OS - microCshell), it
seems to set the date, the time returned by Gettime is the same as 
what i passed to Settime and it even changes (the secs tic by) in
the loop, but when i return to GEM and look in the control panel,
the time is unchanged even after waiting upto 5 min. as you can see
from the commented out part, i also tried the InteliKeyboard, but
alas with no better success. (BTW how do you read back packets from
Ikbdws ?????)

if it matters, i am running on a 520ST with a 1 meg upgrade and TOS
in rom

=====================================================================
#include <stdio.h>
#include <osbind.h>

main()

{
	long time,time1,sstack;
	unsigned char kcmds[20];
	int i,j,k;
		

	time = 0x0d304000;
	printf("before call time = %lx\n",time);
	Settime(time);
	for(i=0;i<100;i++) {
		time1 = Gettime(); 
		printf("after call time = %lx\n",time1);
	}
/***********************************************************************
	kcmds[0] = 0x1b;
	kcmds[1] = 0x86;
	kcmds[2] = 0x12;
	kcmds[3] = 0x13;
	kcmds[4] = 0x14;
	kcmds[5] = 0x25;
	kcmds[6] = 0x00;
	Ikbdws(7, &kcmds[0]); 
**************************************************************************/
}

===========================================================================

-- 
"I will drink of every cup once" saith Jurgen - James Branch Cambell
Name:	James M. Turner 			   
Mail:	Imagen Corp. 2650 San Tomas Expressway Santa Clara, CA 95052-8101 
UUCP:	...{decvax,ucbvax}!decwrl!imagen!turner      AT&T: (408) 986-9400

apratt@atari.UUcp (Allan Pratt) (12/16/86)

The problem here is that you are changing the IKBD time/date, not the
GEMDOS time/date.  These are two different things.  The IKBD time
survives system resets, while the GEMDOS time does not.  The time you
see in the Control Panel (and on file stamps) is the GEMDOS time.
Included below is a program which lives very happily in my AUTO
folder.  It checks the IKBD time, and, if it's valid, sets the GEMDOS
time to that value.  If the IKBD time is invalid (like on power-up)
or if you specify any options on the command line, the program prompts
for a new time and sets BOTH the GEMDOS and IKBD time to that.

The key calls are Gettime/Settime (for the IKBD) and Tgetdate/Tsetdate
and Tgettime/Tsettime (for GEMDOS).

Note that the old control panel sets the GEMDOS time to zero (that is,
11/85) when it starts up (AFTER the AUTO folder executes), clobbering
anything this program has done.  If you have that version of the
control panel, you should get the new version from the Atari bulletin
board.

settime.c and settime.prg (uuencoded) follow.  Note that it's written
for Alcyon C, and you DON'T link with GEMSTART (but you do link with
osbind).  Also note that it's not especially good code, but it does
the job, and even has some error checking.  Read the first part of the
source for documentation.

/*************************  cut here for settime.c ************************/

/*
 * Settime: get the time from the Ikbd, or from the user, if that's wrong.
 *
 * usage: settime [f]
 *
 * The Intelligent Keyboard's time and date are checked for validity.
 * If they are valid, GEM's time and date are set accordingly. If not,
 * or if you provide the FORCE argument on the command line, you will
 * be prompted for the time and date, and BOTH GEM's and the IKBD's time
 * will be set to what you typed.
 *
 * If you put this program in the AUTO folder of your boot device, you
 * only have to set the time on power-up, not after every reset.
 *
 * The new version of the control panel will not clobber this time setting.
 *
 * Written by Allan Pratt for Atari Corp. Copyright (C) 1986 by Atari Corp.
 * This program may be freely copied and distributed at no charge.
 *
 * NOTE: THIS PROGRAM DOES NOT USE GEMLIB AT ALL. This makes it small & quick.
 *
 * LINK: link68 [u] settime.68k=settime,osbind
 *       relmod settime
 */

#include <osbind.h>

#define fixup(s) (s[s[1]+2] = '\0')	/* null-terminate a GEMDOS string */

main(basepage)
register char *basepage;
{
    register unsigned long datime;
    register int date, time, temp;
    char buffer[10];
    char *s;

    /* set s to command line and null-terminate the string */
    s = basepage + 0x81;
    s[basepage[0x80]] = '\0';
    
    while (*s == ' ') s++;
    
    if (*s == '\0') {
	/* no force argument: see if IKBD time is valid */
	datime = Gettime();		/* get ikbd date & time */
	date = datime >> 16;
	time = datime & 0xffff;

/* if the month and day are nonzero, and if GEMDOS doesn't barf on either, */
/*   just exit: you're done!	*/

	if (((date & 0x1f) != 0) &&
	    (((date >> 5) & 0x0f) != 0))
		if (!Tsetdate(date) && !Tsettime(time)) Pterm(0);
    }

    /* either there was an argument (force) or ikbd's date/time was bad */
    /* in any case, getting here means we want to prompt the user	*/

    buffer[0] = 7;	/* set up buffer for Cconrs call */
    do {
	Cconws("Enter the time (hhmm[ss]): ");
	Cconrs(buffer);
	fixup(buffer);
    } while (dotime(buffer+2));

    do {
	Cconws("\r\nEnter the date (mmddyy): ");
	Cconrs(buffer);
	fixup(buffer);
    } while (dodate(buffer+2));

    datime = ((long)Tgetdate() << 16) + Tgettime();	/* get GEM's time */
    Settime(datime);				/* update the ikbd's time */
    Cconws("\r\n");			/* be nice - end with newline */
    Pterm(0);
}

dotime(s)
register char *s;
{
	register int len;
	register int hour, minute, second;

	len = strlen(s);
	if (len < 4 || len == 5 || len > 6) goto badtime;  /* bad string */

	hour = (s[0]-'0') * 10 + (s[1]-'0');
	minute = (s[2]-'0') * 10 + (s[3]-'0');
	if (len == 6) second = (s[4]-'0') * 10 + (s[5]-'0');
	else second = 0;

	if (hour < 0 || hour > 23 ||
	    minute < 0 || minute > 59 ||
	    second < 0 || second > 59) goto badtime;

	if (!Tsettime((hour << 11) + (minute << 5) + (second >> 1)))
	    return 0;

badtime:
	Cconws("\r\nIllegal time (bad format or out of range)\r\n");
	return 1;
}

dodate(s)
register char *s;
{
	register int len;
	register int month,day,year;

	len = strlen(s);
	if (len != 6) goto baddate;

	month = (s[0]-'0') * 10 + (s[1]-'0');
	day = (s[2]-'0') * 10 + (s[3]-'0');
	year = (	s[4]-'0') * 10 + (s[5]-'0') - 80;

	if (year < 0 || year > 119 || 
	    month < 1 || month > 12 || 
	    day < 1 || day > 31) goto baddate;	/* out of range */

	if (!Tsetdate((year << 9) + (month << 5) + day)) return 0;

baddate:
	Cconws("\r\nIllegal date (bad format or out of range)\r\n");
	return 1;
}

strlen(s)
register char *s;
{
	register int i;
	for (i=0; *s++; i++) ;
	return i;
}


/***************************** cut here for settime.prg ******************/

begin 644 settime.prg
M8!H```.&````F`````0``````````````````$Y6__)(YQ\$*FX`"$'M`($M
M2/_R$"T`@$B`2,#0KO_R($!"$&`$4J[_\B!N__(,$``@9_(@;O_R2A!F8CZ\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!!Y.=2/?
M```$'DY-+SD```0>3G4CWP``!!Y.02\Y```$'DYU16YT97(@=&AE('1I;64@
M*&AH;6U;<W-=*3H@``T*16YT97(@=&AE(&1A=&4@*&UM9&1Y>2DZ(``-"@`-
M"DEL;&5G86P@=&EM92`H8F%D(&9O<FUA="!O<B!O=70@;V8@<F%N9V4I#0H`
M#0I);&QE9V%L(&1A=&4@*&)A9"!F;W)M870@;W(@;W5T(&]F(')A;F=E*0T*
B``````!",A(2#@H4)`H4*!(0"`H.RA`*M!`*-@@("`@(`&]F
`
end

tynor@gitpyr.gatech.EDU (Steve Tynor) (12/18/86)

In article <488@atari.UUcp> apratt@atari.UUcp (Allan Pratt) writes:
>
>Note that the old control panel sets the GEMDOS time to zero (that is,
>11/85) when it starts up (AFTER the AUTO folder executes), clobbering
>anything this program has done.  If you have that version of the
>control panel, you should get the new version from the Atari bulletin
>board.

This explains why I've never been able to get an AUTO time program to work on
my system!  However, calling the Atari bboard is a long distance call and at 
1200 baud, I thought I'd ask if someone could post a UUENCODEd new control panel
for those of us unfortunate enough to need it...

AtDhVaAnNkCsE

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Progress means replacing something wrong with something more subtly wrong.
                     
    Steve Tynor
    Georgia Instutute of Technology

 ...{akgua, allegra, amd, harpo, hplabs,
     ihnp4, masscomp, ut-ngp, rlgvax, sb1,
     uf-cgrl, unmvax, ut-sally}  !gatech!gitpyr!tynor

turner@imagen.UUCP (D'arc Angel) (12/19/86)

In article <2811@gitpyr.gatech.EDU>, tynor@gitpyr.gatech.EDU (Steve Tynor) writes:
> In article <488@atari.UUcp> apratt@atari.UUcp (Allan Pratt) writes:
> >
> >control panel, you should get the new version from the Atari bulletin
> >board.
> 
> This explains why I've never been able to get an AUTO time program to work on
> my system!  However, calling the Atari bboard is a long distance call and at 
> 1200 baud, I thought I'd ask if someone could post a UUENCODEd new control panel
> for those of us unfortunate enough to need it...
> 
> AtDhVaAnNkCsE

i downloaded the control.acc from the atari bbs 3 times now and get
the same problem each time, when i 'close' the acc it causes a
system reboot. anyone else seen this or is this just the luck of the
turners.









again, lots of lf's to defeat 2.11's 50% rule, which is getting to
be a pain






-- 
---------------
"I will drink of every cup once" saith Jurgen - James Branch Cambell
Mail:	Imagen Corp. 2650 San Tomas Expressway Santa Clara, CA 95052-8101 
UUCP:	...{decvax,ucbvax}!decwrl!imagen!turner      AT&T: (408) 986-9400

apratt@atari.UUcp (Allan Pratt) (12/19/86)

>     Steve Tynor
>     Georgia Instutute of Technology

asks me (or somebody) to post a uuencoded copy of the Control Panel to
the net.  I encourage everybody not to do this.

If your control panel clobbers a date you set with one of the (many)
time programs running around, you have the old version.  Please call
your Atari dealer: s/he should let you get a copy from a newer
language disk, especially if you bring in your original Atari system
disk.

You can also call a local bulletin board -- the new Control Panel has
been out for some time, and I know it was on several BBSes around the
country as early as last May.

/----------------------------------------------\
| Opinions expressed above do not necessarily  |  -- Allan Pratt, Atari Corp.
| reflect those of Atari Corp. or anyone else. |     ...lll-lcc!atari!apratt
\----------------------------------------------/