1-6、讯为系统编程adc

#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>

#define LED_NUM 2
#define LED_C 2

int main(int argc,char *argv[])
{
	int fd,led_num,led_c;
	char *leds = "/dev/leds";
	
	led_num = LED_NUM;
	led_c = led_c;

	printf("argv1 is cmd;argv2 is io\n");
	if(atoi(argv[1])>=led_c){
		printf("argv1 is 0 or 1\n");
		exit(1);
	}
	if(atoi(argv[2])>=led_num){
		printf("argv2 is 0 or 1\n");
		exit(1);
	}
	if((fd == open(leds,O_RDWR))<0){
		printf("open %s failed\n",leds);
	}
	else
	{
		ioctl(fd,atoi(argv[1]),atoi(argv[2]));
		printf("ioctl %s success\n",leds);
	}
	close(fd);
}
发布了113 篇原创文章 · 获赞 1 · 访问量 1222

猜你喜欢

转载自blog.csdn.net/poor_guy_liu/article/details/103565851
1-6