基于ARM9-Linux下红外驱动APP

#include 
#include 
#include 
#include 
#include 

int fd,fd2;

void *func(void *p)
{
      int on=1;
      char buf;
       while(1)
 {
   read(fd,&buf,1);
  
   switch(buf){
     case 'w':
  on=1;ioctl(fd2, on, 0);break;
     case 'b':
  on=0;ioctl(fd2, on, 0);break;
     case 's':
  on=2;ioctl(fd2, on, 0);break;
     case 'l':
  on=3;ioctl(fd2, on, 0);break;
     case 'r':
  on=4;ioctl(fd2, on, 0);break; 
         case 'p':
  on=5;ioctl(fd2, on, 0);break;
     }
 }

      return 0;
}

int main(int argc, char **argv)
{
 int led_no;
  int on=1;
 char ch,buf;
        char fileName[50]="";
 
        sprintf(fileName,"/dev/con_device%d",atoi(argv[1]));
 
        fd = open(fileName, O_RDWR);
 fd2 = open("/dev/move_device0",O_RDWR);


 if (fd < 0) {
  perror("open device leds");
  exit(1);
 }
 if(ioctl(fd2, on, 0)<0)//没有用到参数arg
        {
                printf("Control led%d failed!\n",led_no);
                exit(1);
        }
        else printf("Control led%d status:%d\n",led_no,on);
       
 pthread_t p;
 
 
 pthread_create(&p,NULL,func,NULL);
 while(1);
 
 close(fd);close(fd2);
 

 return 0;
}

你可能感兴趣的:(基于ARM9-Linux下红外驱动APP)