linux中poll用法
来源:互联网 发布:如何求最大公约数 算法 编辑:程序博客网 时间:2024/05/01 10:00
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <poll.h>
/* thirddrvtest
*/
int main(int argc, char **argv)
{
int fd;
int ret;
unsigned char key_val;
struct pollfd *fds;
fd = open("/dev/buttons", O_RDWR);
if (fd < 0)
{
printf("can't open!\n");
}
fds->fd = fd;
fds->events = POLLIN ;
while (1)
{
ret = poll(fds, 1, 5000);
if(ret ==0)
{printf("time out\n");
}
else{
read(fd, &key_val, 1);
printf("key_val = 0x%x\n", key_val);
}
}
return 0;
}
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <poll.h>
/* thirddrvtest
*/
int main(int argc, char **argv)
{
int fd;
int ret;
unsigned char key_val;
struct pollfd *fds;
fd = open("/dev/buttons", O_RDWR);
if (fd < 0)
{
printf("can't open!\n");
}
fds->fd = fd;
fds->events = POLLIN ;
while (1)
{
ret = poll(fds, 1, 5000);
if(ret ==0)
{printf("time out\n");
}
else{
read(fd, &key_val, 1);
printf("key_val = 0x%x\n", key_val);
}
}
return 0;
}
0 0
- linux中poll用法
- linux中多路复用poll浅析
- linux下select 和 poll的用法
- linux下select 和 poll的用法
- linux下select和poll的用法
- linux下select和poll的用法
- linux下select 和 poll的用法
- Linux下select和poll的用法
- Linux下select和poll的用法
- Linux中select、poll和epoll
- Linux中poll机制的理解
- linux中poll,epoll,select区别,等等
- linux poll
- Linux - poll()
- Linux poll
- Linux poll
- select,poll,epoll用法
- select,poll,epoll用法
- 数据库编程总结
- 用eclipse运行和部署myeclipse项目
- hdu1880 hash算法学习
- 2014多校联合五(HDU 4911 HDU 4915 HDU 4920)
- bin目录下hadoop脚本使用
- linux中poll用法
- KD-tree学习笔记
- 同网段地址判断
- ubuntu 12.04设置源
- 五子棋AI大赛
- hdu 1018 斯特灵公式
- Android体系结构
- 手机短号(2081)
- 运行*.run文件