1 #include <sys/types.h>
2 #include <sys/stat.h>
3 #include <fcntl.h>
4 #include <stdio.h>
5
6 /* led_test on
7 * led_test off
8 */
9 int main(int argc, char **argv)
10 {
11 int fd;
12 int val = 1;
13 fd = open("/dev/led", O_RDWR);
14 if (fd < 0)
15 {
16 printf("can't open!\n");
17 }
18 if (argc != 2)
19 {
20 printf("Usage :\n");
21 printf("%s <on|off>\n", argv[0]);
22 return 0;
23 }
24
25 if (strcmp(argv[1], "on") == 0)
26 {
27 val = 1;
28 }
29 else
30 {
31 val = 0;
32 }
33
34 write(fd, &val, 4);
35 return 0;
36 }