日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

应用程序 /dev/rtc 编程 获取时间 2011-12-13 01:01:06【转】

發布時間:2023/12/10 编程问答 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 应用程序 /dev/rtc 编程 获取时间 2011-12-13 01:01:06【转】 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

本文轉載自:http://blog.chinaunix.net/uid-16785183-id-3040310.html

分類:

原文地址:應用程序 /dev/rtc 編程 獲取時間?作者:yuweixian4230

?

找的一些rtc資料: 系統時鐘硬件與LINUX時間表示二 之 Linux內核對RTC的編程 S3C2440上RTC時鐘驅動開發實例講解 linux 實時時鐘(RTC)驅動 linux RTC 驅動模型分析 ? ubuntu10.10 /dev/rtc 功能: 簡單操作,打開/dev/rtc, 然后獲取 時間信息 ? 在busybox源碼src/include/rtc.h 和 linux /usr/include/linux/rtc.h有如下定義數據結構:
  • struct rtc_time?{
  • ????????int?tm_sec;
  • ????????int?tm_min;
  • ????????int?tm_hour;
  • ????????int?tm_mday;
  • ????????int?tm_mon;
  • ????????int?tm_year;
  • ????????int?tm_wday;
  • ????????int?tm_yday;
  • ????????int?tm_isdst;
  • };
  • ? ioctl命令 ?
  • #define RTC_AIE_ON ? 打開alarm中斷
  • #define RTC_AIE_OFF ? 關閉 alarm中斷
  • #define RTC_UIE_ON ? ?打開update類型的中斷
  • #define RTC_UIE_OFF ? 關閉
  • #define RTC_PIE_ON ? ?打開周期性中斷
  • #define RTC_PIE_OFF ? 關閉
  • #define RTC_WIE_ON ? ?
  • #define RTC_WIE_OFF
  • #define RTC_ALM_SET ? ? 設置alarm的時間
  • #define RTC_ALM_READ ? ? 讀取alarm的時間
  • #define?RTC_RD_TIME ? 讀取當前的rtc時間
  • #define?RTC_SET_TIME? ?設置當前的rtc時間
  • #define RTC_IRQP_READ ?讀取當前周期性中斷的頻率
  • #define RTC_IRQP_SET ? 設置當前周期性中斷的頻率
  • #define RTC_EPOCH_READ
  • ?
    附件源碼:?rtc.rar???將rar修改為 tar.bz2 ?
  • #include?<stdio.h>//printf funciton
  • #include?<stdlib.h>//EXIT_FAILURE
  • #include?<linux/rtc.h>?//usr/include/linux/rtc.h struct rtc_time
  • #include?<fcntl.h>?//O_RDONLY open close funciton
  • #include?<sys/ioctl.h>?//ioctl funciton?/usr/include/sys/ioctl
  • int?main(int?argc,char?*argv[])
  • {
  • ????int?retval,fd;
  • ????struct rtc_time rtc_tm;
  • ????fd=open("/dev/rtc",O_RDONLY);????
  • ????if(fd==-1)
  • ????{
  • ????????perror("error open /dev/rtc");
  • ????????exit(EXIT_FAILURE);
  • ????}
  • ????retval=ioctl(fd,RTC_RD_TIME,&rtc_tm);
  • ????if(retval==-1)
  • ????{
  • ????????perror("error RTC_RD_TIME ioctl");
  • ????????exit(EXIT_FAILURE);
  • ????}
  • ????printf("sec=%d,min=%d,hour=%d\n",rtc_tm.tm_sec,rtc_tm.tm_min,rtc_tm.tm_hour);
  • ????close(fd);
  • ????exit(EXIT_SUCCESS);
  • }
  • ?
  • ywx@ywx:~/desktop/module/rtc$ sudo?./rtc
  • [sudo]?password?for?ywx:?
  • sec=53,min=29,hour=1
  • 一篇網上的代碼:設置rtc時間 ?settime.rar???

    轉載于:https://www.cnblogs.com/zzb-Dream-90Time/p/7580471.html

    總結

    以上是生活随笔為你收集整理的应用程序 /dev/rtc 编程 获取时间 2011-12-13 01:01:06【转】的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。