Advertisement
gizero

Untitled

Jul 29th, 2014
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.45 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <errno.h>
  4. #include <fcntl.h>
  5.  
  6. #define LEDSYSFILE "/sys/class/leds/led1/brightness"
  7.  
  8. int main(void) {
  9.   int fd;
  10.   ssize_t ret;
  11.   char buf[1024];
  12.  
  13.   snprintf(buf, sizeof(buf), "%d\n", 1);
  14.  
  15.   fd = open(LEDSYSFILE, O_RDWR);
  16.   if (fd < 0) {
  17.     perror("open()");
  18.     return -errno;
  19.   }
  20.  
  21.   ret = write(fd, buf, strlen(buf));
  22.   printf("write() returned: %d\n", ret);
  23.  
  24.   close(fd);
  25.  
  26.   return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement