/*应用程序*/
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <fcntl.h> #include <signal.h> #include <sys/stat.h> main() { int fd; int counter = 0; int old_counter = 0; /*打开/dev/second设备文件*/ fd = open("/dev/second", O_RDONLY); if (fd != - 1) { while (1) { read(fd,&counter, sizeof(unsigned int));/* 读目前经历的秒数 */ if(counter!=old_counter) { printf("seconds after open /dev/second :%d\n",counter); old_counter = counter; } } } else { printf("Device open failure\n"); } }S3C6410实时时钟RTC 秒字符设备(2)
内容版权声明:除非注明,否则皆为本站原创文章。
转载注明出处:http://www.heiqu.com/a460fae4273f6e12f0cfea1fcd8252e0.html