syslocal(2) on 3b1 sick?

Thad P Floryan thad at cup.portal.com
Fri Nov 25 11:19:39 AEST 1988


Re: handling the UNIXpc's real-time clock, following is some code that WORKS,
extracted from a program I'll be posting to unix-pc.sources in the near future.

Enjoy!

Thad Floryan  [ thad at cup.portal.com (OR) ..!sun!portal!cup.portal.com!thad ]

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

#include <stdio.h>
#include <time.h>
#include <sys/types.h>

#ifdef UNIXPC
#include <sys/syslocal.h>
#include <sys/rtc.h>
#endif

	.
	.

#ifdef UNIXPC

/*	Sets the battery-backed Real Time Clock in the UNIXpc to the same
 *	date and time values as the system clock.
 */
set_rtc(tval)
time_t	tval;
{
	struct tm	*p_tm;
	struct rtc	rtc_s;
	struct rtc	*p_rtc;

	p_tm = localtime(&tval);

	p_rtc = &rtc_s;

	p_rtc->wkday = p_tm->tm_wday;
	p_rtc->yr10  = p_tm->tm_year / 10;
	p_rtc->yr1   = p_tm->tm_year % 10;
	p_rtc->mon10 = (p_tm->tm_mon + 1) / 10;
	p_rtc->mon1  = (p_tm->tm_mon + 1) % 10;
	p_rtc->day10 = p_tm->tm_mday / 10;
	p_rtc->day1  = p_tm->tm_mday % 10;
	p_rtc->hr10  = p_tm->tm_hour / 10;
	p_rtc->hr1   = p_tm->tm_hour % 10;
	p_rtc->min10 = p_tm->tm_min / 10;
	p_rtc->min1  = p_tm->tm_min % 10;
	p_rtc->sec10 = p_tm->tm_sec / 10;
	p_rtc->sec1  = p_tm->tm_sec % 10;

	syslocal(SYSL_WRTRTC, p_rtc);	/* write to RTC */

}
#endif



More information about the Comp.sys.att mailing list