?? vciled_test.c
字號:
#include <sys/mman.h>#include <limits.h>#include <stdio.h>#include <stdlib.h>#include <fcntl.h>#include <unistd.h>#include <string.h>#include <time.h>#include <ctype.h>#include <errno.h>#include <sys/ioctl.h>#include <sys/types.h>#include <asm/types.h>#include <sys/select.h>#include <termios.h>#include <stropts.h>#include "LED_Config.h"#define LED_CONFIG_MAJOR 0/* Use 'k' as magic number *///#define LED_Config_IOC_MAGIC 'X'/* Please use a different 8-bit number in your code *///#define LED_Config_IOC_Status _IOWR(LED_Config_IOC_MAGIC, 9,int)//#define LED_Config_IOC_Setting _IOWR(LED_Config_IOC_MAGIC, 8,int)#define LED_Config_Data_fail 0x4#define LED_low_Data_fail 0x0int main(int argc, char **argv){ char *fname; int f; int status=1; int ret=-1; //int mcudata; if (argc != 2) { fprintf(stderr, "%s: Usage \"%s <parameter>\"\n", argv[0],argv[0]); exit(1); } fname="/dev/LED_Config"; status = atoi(argv[1]); if (!(f=open(fname,O_RDWR))) { fprintf(stderr, "%s: %s: %s\n", argv[0], fname, strerror(errno)); exit(1); } switch(status) { case 0: ret = ioctl(f, LED_PRE_ON, &status); // fprintf(stderr, " COMMAND = %d\n",LED_PRE_ON); break; case 1: ret = ioctl(f,LED_PRE_OFF,&status); break; case 2: ret=ioctl(f,LED_PRE_BLINK,&status); break; case 3: ret = ioctl(f, LED_COM_ON, &status); break; case 4: ret= ioctl(f, LED_COM_OFF,&status); break; case 5: ret = ioctl(f, LED_COM_BLINK,&status); break; default: ret=-1; break; }// ret = ioctl(f, LED_Config_IOC_Setting, &status); fprintf(stderr, " LED Set status = %x\n",status); if (ret < 0) { fprintf(stderr, "executing this operation error\n"); } close(f); return ret;}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -