#include #include #include #include #include #include #include #include #include #include "asm/fam3rtos/fam3rtos_sysctl.h" char* onoff[] = {"off", "on"}; char* ledname[] = {"run", "alm", "err"}; char* command[] = { "run_off", "run_on", "alm_off", "alm_on", "err_off", "err_on", "status", }; void help(char* s) { int i; const int ncommand = sizeof(command)/sizeof(command[0])-1; fprintf(stderr, "usage : %s commands\n", s); fprintf(stderr, " commands: %s\n", command[ncommand]); for (i=0; i>iled)&1]); } } else { if (sscanf(argv[iarg], "%3s_%s", led, status)!=2) { help(argv[0]); } if (strcmp(status, onoff[0])!=0 && strcmp(status, onoff[1])!=0) { help(argv[0]); } switch(led[0]) { case 'r': // RUN if (status[1]=='n') { ledval |= RP6X_LED_RUN_ON; } else { ledval |= RP6X_LED_RUN_OFF; } break; case 'a': // ALM if (status[1]=='n') { ledval |= RP6X_LED_ALM_ON; } else { ledval |= RP6X_LED_ALM_OFF; } break; case 'e': // ERR if (status[1]=='n') { ledval |= RP6X_LED_ERR_ON; } else { ledval |= RP6X_LED_ERR_OFF; } default: break; } if (ioctl(fd, RP6X_SYSIOC_SETLED, &ledval)==EFAULT) { fprintf(stderr, "%s: %s\n", strerror(errno), devicefile); close(fd); return EXIT_FAILURE; } } } close(fd); return ledval; }