您的位置:首页 > 运维架构 > Linux

Linux: 输入设备驱动测试程序

2010-09-09 11:27 453 查看
测试写好的输入设备模块,比如遥控器,交叉编译后bin档放到rootfs/bin,直接运行

/* test remote.ko
* you should insmod remote.ko and config it before
*/
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <linux/input.h>

struct input_event buff;

int main(int argc, char **argv)
{
int fd;

printf("%s: entered/n", argv[0]);

fd = open("/dev/input/event0", O_RDONLY);
if(fd == -1) {
printf("open failed");
exit(-1);
}
printf("%s: open successful: %d/n", argv[0], fd);
while(1) {
if(read(fd,&buff,sizeof(struct input_event))!=0)
printf("type:%d code:%d value:%d/n",buff.type,buff.code,buff.value);
}

close(fd);

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: