标题: 读RTC出错
lyl_allen
新生入学
Rank: 1



UID 200923
精华 0
积分 10(积分有什么用?)
帖子 10
阅读权限 10
注册 2007-7-3
状态 离线
发表于 2007-8-14 02:00  资料  个人空间  短消息  加为好友 
读RTC出错

本人在2410上运行一段读RTC程序,开始的二十分钟可以读,时间不段更新,但过了一段时间后读出来的数据就不变了,即时间一直停留在过去某一时刻,下面是我的程序,请大侠们指点一下阿,万分感谢:

#include<unistd.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<fcntl.h>
#include<stdlib.h>
#include<stdio.h>
#include<string.h>
#include <stdlib.h>

int main(void)
{
while(1)
{
int fd,size;
int gd,sd[8],m;
char hour,min,sec,month,day;
  unsigned char tr[25];
int year;
char time[30];
  float rd[8];


fd=open("/proc/driver/rtc",O_RDONLY);

lseek(fd,11,SEEK_SET);

read(fd,time,30);


  year=(time[20]-48)*1000+(time[21]-48)*100+(time[22]-48)*10+time[23]-48;
  month=(time[25]-48)*10+time[26]-48;
  day=(time[28]-48)*10+time[29]-48;
  hour=(time[0]-48)*10+time[1]-48;
  min=(time[3]-48)*10+time[4]-48;
  sec=(time[6]-48)*10+time[7]-48;
   printf("the year is:%d\n",year);
  printf("the month is:%d\n",month);
  printf("the day is:%d\n",day);
  printf("the hour is:%d\n",hour);
  printf("the min is:%d\n",min);
  printf("the sec is:%d\n",sec);
  sleep ( 1 );
  close ( fd );
}
}

顶部
AIKO_sex
特聘作家
Rank: 5Rank: 5
伊甸园杰出贡献会员



UID 12054
精华 20
积分 41(积分有什么用?)
帖子 11559
阅读权限 10
注册 2002-3-20
状态 离线
发表于 2007-8-14 10:22  资料  个人空间  短消息  加为好友 
20分钟之前关闭再重新打开

如此overoll

[ 本帖最后由 AIKO_sex 于 2007-8-14 10:25 编辑 ]





象一阵风 拂过我身边 忽然间 想要去很远 和你去看繁华世界
顶部
不容错过的IBM 集群技术资源汇总
 



当前时区 GMT+8, 现在时间是 2008-5-17 15:09

    Powered by Discuz! 5.5.0  © 2001-2007 Comsenz Inc.
Processed in 0.102874 second(s), 5 queries

清除 Cookies - 联系我们 - Linux伊甸园 - Archiver - WAP