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

Bug#358017: ioctl rtc example



Hello

After re-reading my mail i considerd sending some example code, wich shouldn work with:

Kernel 2.6.8-2-686 and module genrtc.ko loaded

but works with:

Kernel 2.6.8-2-686 and module rtc.ko loaded.


Maybe this is a general kernel issue, or an issue with my machine. If so, i am again really sorry for the inconvenience.

Thank you very much
konrad









#include <stdio.h>
#include <linux/rtc.h>
#include <sys/ioctl.h>
#include <sys/time.h>
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>

int main() {
	int fd;
	unsigned long int ioret;
	int rtcread;
	int counter;
	int fc;
	unsigned long rtcdata;
	unsigned long irqrate = 8;
	unsigned long test;


	fd = open("/dev/rtc", O_RDONLY);

	if ( fd == -1 ) { 
		printf("error opening rtc \n");
		exit(0);
	}

	ioret = ioctl(fd,RTC_IRQP_SET,64);

	/* breaks here with 'set failed: invalid argument' on genrtc.ko */
	if ( ioret == -1 ) { 
		perror("set failed");
		exit(0); 
	}

	ioret = ioctl(fd,RTC_PIE_ON,0);

	if ( ioret == -1 ) { 
		printf(": %u \n",ioret);
		perror("set failed");
		exit(0); 
	} 


	for ( counter = 0; counter < 4 ; counter++ ) {
		
		rtcread = read(fd,&rtcdata,sizeof(unsigned long));
	

		printf(".",rtcread);
		fflush(stdout);

	} 

	printf("\n");

	close(fd);
	

}



Reply to: