应用程序 /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脚本方便进行一些性能测试的控制(比如希望能 ...
随机推荐
- debounce还是throttle(去抖和节流)
debounce 去抖 我的理解很简单,比方说window.onscroll会疯狂触发handler,此时给它一个debounce(handler, delayTime). 就是不管你延时时间内触发了 ...
- python--9、进程及并发知识
进程 一个文件的正在执行.运行过程就成为一个进程.执行多个程序,把程序文件都加载到内存,并且多个程序的内存空间隔离--空间上的复用. 遇到IO等待,切CPU到别的程序,提升效率.没有IO,一个程序占用 ...
- SpringBoot 搭建
1.使用Eclipse 建立Maven项目(webapp OR quickstart) 2.配置Maven,如下: <parent> <groupId>org.springfr ...
- 使用jquery animate实现锚点慢慢平滑滚动效果
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- html5——多媒体(一)
<audio> 1.autoplay 自动播放 2.controls 是否显不默认播放控件 3.loop 循环播放 4.preload 预加载 同时设置autoplay时些属性失效 5.由 ...
- JS——鼠标在盒子中的坐标
核心思想: 1.复杂版本:鼠标pageX.pageY的值减去盒子距离顶端的offsetLeft.offsetTop值就是鼠标在盒子中的坐标 2.简单版本:offsetX.offsetY就可获取鼠标相对 ...
- VC++文件监控 ReadDirectoryChangesW
#include <windows.h> #include <tchar.h> #include <stdio.h> #include <assert.h&g ...
- Codeforces_731F_(前缀和)
F. Video Cards time limit per test 1 second memory limit per test 256 megabytes input standard input ...
- 本地读取服务器Xml文件及本地读本地的xml
updateUrl="ServerUrl"(服务器路径) WebClient wc = new WebClient(); Stream stream = wc.OpenRead(u ...
- java中关于数组的初始化