应用程序 /dev/rtc 编程 获取时间 2011-12-13 01:01:06【转】
本文转载自:http://blog.chinaunix.net/uid-16785183-id-3040310.html
分类:
原文地址:应用程序 /dev/rtc 编程 获取时间 作者:yuweixian4230
ubuntu10.10 /dev/rtc
- 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;
- };
- #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
- #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
应用程序 /dev/rtc 编程 获取时间 2011-12-13 01:01:06【转】的更多相关文章
- linux c 编程 ------ 获取时间,计算程序执行时间
#include <time.h> #include <stdio.h> #include <unistd.h> int main(int argc, char a ...
- C++常见编程--获取当前系统时间
C++常见编程--获取当前系统时间 文章首发https://www.cppentry.com 本文主要使用time() 及strftime() 函数 C++系统和时间相关的函数基本上都是使用C语言提供 ...
- 【转】vc++MCF/C++/C中怎样让应用程序获得或以管理员权限运行 ,ShellExecuteEX编程 --- 获取管理员权限
ShellExecuteEX编程 --- 获取管理员权限:http://blog.csdn.net/jhui163/article/details/5873027 怎样让你的应用程序获得管理员权限:就 ...
- 体温数据上传程序开发+获取时间的三种方法+DB Browser下载及安装
今天开始了体温上传程序的开发 今日所学: 获取时间 (21条消息) (转)安卓获取时间的三种方法_sharpeha的博客-CSDN博客_安卓获取时间 DB Browser安装教程 (20条消息) sq ...
- 小程序 js中获取时间new date()的用法(网络复制过来自用)
js中获取时间new date()的用法 获取时间: 1 var myDate = new Date();//获取系统当前时间 获取特定格式的时间: 1 myDate.getYear(); //获 ...
- Delphi编程获取系统当前进程、窗口句柄、文件属性以(转)
Delphi编程获取系统当前进程.窗口句柄.文件属性以及程序运行状态. uses TLHelp32,PsAPI; (1)显示进程列表:procedure TForm1.Button2Click(Sen ...
- 【转载】c/c++在windows下获取时间和计算时间差的几种方法总结
一.标准C和C++都可用 1.获取时间用time_t time( time_t * timer ),计算时间差使用double difftime( time_t timer1, time_t time ...
- linux编程获取本机网络相关参数
getifaddrs()和struct ifaddrs的使用,获取本机IP 博客分类: Linux C编程 ifaddrs结构体定义如下: struct ifaddrs { struct ifad ...
- shell获取时间的相关命令
Linux shell获取时间和时间间隔(ms级别) 说明:在进行一些性能测试的时候,有时候我们希望能计算一个程序运行的时间,有时候可能会自己写一个shell脚本方便进行一些性能测试的控制(比如希望能 ...
随机推荐
- [转]python模块全面
python模块 http://www.cnblogs.com/wupeiqi/articles/4963027.html 模块概念:用一砣代码实现了某个功能的代码集合. 类似于函数式编程和面向过程编 ...
- 高级Java知识
高级Java知识(JVM.字节码.内存模型) 内存=方法区+栈空间+堆+程序计数器 栈(stack)包括虚拟机栈(VM stack)和本地方法栈(native method stack). 方法区(m ...
- [Windows Server 2008] ASP.net安装方法
★ 欢迎来到[护卫神·V课堂],网站地址:http://v.huweishen.com★ 护卫神·V课堂 是护卫神旗下专业提供服务器教学视频的网站,每周更新视频.★ 本节我们将带领大家:安装ASP.n ...
- 常见Android安装启动失败问题
1.INSTALL_FAILED_VERSION_DOWNGRADE版本过低2.Failed to install Funm_AND.apk on device 'QWOJLVR8KNHYA6NR': ...
- php 在Linux下的安装
1.获取php源码 wget http://cn2.php.net/get/php-5.6.6.tar.gz/from/this/mirror mv mirror php-5.6.6.tar.gz t ...
- select2下拉插件
下拉单选: 1.行内 1)初始化数据: <select class="form-control select5"> <option selected>张三1 ...
- PHP 魔术方法浅谈
php中把以两个下划线(__)开头的方法称之为魔术方法.魔术方法包括: __construct() 类的构造方法 构建方法时被调用 __destruct() 类的析构方法 明确销毁 ...
- 本地读取服务器Xml文件及本地读本地的xml
updateUrl="ServerUrl"(服务器路径) WebClient wc = new WebClient(); Stream stream = wc.OpenRead(u ...
- php第十五节课
租房表 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3. ...
- [pytorch学习]1.pytorch ubuntu安装
看完了Deep Learning with Python,尝试了部分Keras的demo代码. 感觉Keras虽然容易上手,能够快速搭建出一个通用的模型,但是缺乏对底层的控制. 同时,在使用了自己编译 ...