04clock_01misc_app

 1 #include <stdio.h>
 2 #include <sys/stat.h>
 3 #include <fcntl.h>
 4 #include <unistd.h>
 5 
 6 #define DEV_NAME "/dev/my_led"
 7 
 8 int main(int argc, char const *argv[])
 9 {
10     
11     int  fd = open(DEV_NAME, O_RDWR);
12     if(fd < 0) {
13         perror("open");
14         return -1;
15     }
16 
17     char buf[10] = {0};
18 
19     int ret = read(fd, buf, 10);
20     printf("buf = %s\n", buf); 
21 
22     close(fd);
23     return 0;
24 }

 

posted @ 2017-02-19 16:55  小黑·.·  阅读(143)  评论(0编辑  收藏  举报