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);
}
/* 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);
}
相关文章推荐
- 【转】LINUX设备驱动之输入子系统(三)
- Linux设备驱动--块设备(三)之程序设计
- Linux设备驱动--块设备(三)之程序设计
- Linux输入子系统框架分析及输入设备驱动编程
- Linux嵌入式驱动初体验(六)--- LED驱动测试程序
- linux设备驱动中断程序深度完全解析
- LINUX设备驱动之输入子系统(二)
- openwrt系统之字符设备驱动软件包加载、测试程序加载
- LINUX设备驱动——输入子系统
- linux 字符设备驱动的验证程序(openplatform/android/externl/chr_dev/)
- linux设备驱动之输入(input)子系统——核心层实现
- Linux的input输入子系统:设备驱动之按键驱动
- Linux输入子系统(4):设备驱动层实例之按键驱动
- Linux触摸屏驱动测试程序范例【转】
- linux输入设备驱动实列
- Linux输入子系统(5):设备驱动层实例之触摸屏驱动
- 编写Linux设备驱动程序教程
- linux下的spi驱动及测试程序移植开发
- Linux输入子系统(6):设备驱动层之LED驱动
- 【嵌入式Linux驱动开发】四、输入设备驱动