点亮led驱动程序(应用测试部分)

#include <sys/types.h>

#include <sys/stat.h>

#include <fcntl.h>

#include <stdio.h>

/*Firstdrvtest on

*Firstdrvtest off */

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

int fd;

int val=1;

fd=open("/dev/xyz",O_RDWR );

//这个" /dev/xxx"  后面不能有空格

if (fd<0) {

printf("can't open!\n");

}

if(argc !=2 ) {

printf ("Usage :\n");

printf ("%s <on|off>\n",argv[0]);

//linux里面尖括号表示尖括号不能省略

return 0; }

if (strcmp(argv[1],"on")== 0)

{

//点亮

val=1;

}

else

{

//熄灭

val=0;

}

write (fd,&val,4);

return 0;

}

 

posted @ 2016-01-21 10:20  蜗牛的爬行  阅读(258)  评论(0编辑  收藏  举报