S3C2440独立键盘Linux设备驱动(4)

/*************************************************************************
NAME:test_keyboard.c
AUTHOR:Ma Dongpeng<madongpeng@hrbeu.edu.cn>
TIME:2011-02-19 17:03:57
VERSION:1.0.0
**************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <fcntl.h>
int main(int argc, char **argv)
{
 char read_data[4]={0,0,0,0};
 int fd,i;
 printf("****************open keyboard***************\n");
 fd = open("/dev/keyboard",O_RDONLY);
 if (fd < 0) {
  perror("erro open device keyboard");
  exit(1);
 }
 while(1)
 {
  read(fd,read_data,4);
  printf("\nread data:");
  for(i=0;i<4;i++) printf("%d ",read_data[i]);
  printf("\n");
 }
 printf("*****************close keyboard***************\n");
 close(fd);
 return 0;
}

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wwsyxy.html