strace hwclock看到ioctl调用  

读取rtc时间

    int fd;
    struct rtc_time rtc_tm;
    int ret;

    fd = open("/dev/rtc0", O_RDONLY, 0);

    // the ioctl command RTC_RD_TIME is used to read the current timer.
    // about the detail ioctl command, refer to section 3
    ret = ioctl(fd, RTC_RD_TIME, &rtc_tm);

    ::close(fd);
////////////////

读取系统时间
    QDateTime datetime = QDateTime::currentDateTime();
    QDate sysdate = datetime.date();
    QDate hwdate(rtc_tm.tm_year+1900, rtc_tm.tm_mon+1, rtc_tm.tm_mday);

    qDebug()<<sysdate<<hwdate;
    if(sysdate!=hwdate)

 

 

http://www.uclinux.org/pub/uClinux/ports/blackfin/docs/Device%20Driver%20Integration%20Notes%20and%20Tests/RTC_device_driver.txt

http://download.analog.com/27516/trackeritem/1/2/4/1247/rtc_test.c

相关文章:

  • 2021-07-30
  • 2021-12-08
  • 2021-10-30
  • 2021-12-15
猜你喜欢
  • 2021-05-26
  • 2022-12-23
  • 2021-12-15
  • 2021-11-18
  • 2021-06-30
  • 2021-06-18
相关资源
相似解决方案