Mailing List archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[linux-dvb] Re: About saving energie



Hi,

> Last weekend I have written a small program to set the alarm registers of
> the RTC, it worked fine, the interrupt was triggered exactly at the time
> set, but whenever I shut down the PC, the alarm registers were overwritten
> with the values in the BIOS (before the PC was switched off).
> Of course the reason for this could be my BIOS and it could behave
> differently with your BIOS.

The following tiny program works for me, if i setup my BIOS to wake up 
"everyday". But a look at Ralf Brown's Interrupt List reveals, that every 
BIOS has its own register and methods for the "wake up" procedure.
It should work for all Award 4.51P BIOS.

<snip>
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <linux/rtc.h>

#define RTC "/dev/rtc"

int main(int argc, char *argv[])
{
	struct rtc_time t, t2;
	int fh, ioret;

	if( argc != 4 )	{
		printf("usage: rtc <hour> <min> <sec>\n");
		exit( EXIT_SUCCESS );
	}

	t.tm_hour = atoi( argv[1] );
	t.tm_min = atoi( argv[2] );
	t.tm_sec = atoi( argv[3] );

	fh = open(RTC, O_RDWR);
	if( fh < 0 ) perror("open /dev/rtc");

	ioret = ioctl( fh, RTC_ALM_READ, &t2);
	printf("old alarm %02i:%02i:%02i\n", t2.tm_hour, t2.tm_min, t2.tm_sec);
	/* set alarm time */
	ioret = ioctl( fh, RTC_ALM_SET, &t);

	ioret = ioctl( fh, RTC_ALM_READ, &t2);
	printf("new alarm %02i:%02i:%02i\n", t2.tm_hour, t2.tm_min, t2.tm_sec);
	close(fh);
	return EXIT_SUCCESS;
}
<snap>

> I could post this little program here (it's really just a few lines) and so
> everybody could try it out.

Do you write the registers directly? 

> Ralf.

Christian

Christian


--- 
Info:
To unsubscribe send a mail to listar@linuxtv.org with "unsubscribe linux-dvb" as subject.



Home | Main Index | Thread Index