内核watchdog

配置内核看门狗支持:

              http://sunnyshineboy.blog.163.com/blog/static/2028151182012539552151/

 

提供给用户使用的API都在这里都有介绍:

              KERNEL_DIR/Documentation/watchdog/watchdog-api.txt

1、打开

 int wdt_fd;

 wdt_fd = open("/dev/watchdog", O_RDWR);

 if(fd < 0)                                        //检测是否成功打开

 {

     printf("open /dev/watchdog failed!!\n");

     exit(-1);

 }

2、关闭

 closefd);

3、喂狗

第一种方式:

 ioctl(wdt_fd, WDIOC_KEEPALIVE);

第二种方式:

 char flag = V’;

 writewdt_fd&flag1); 

4、设置超时时间

 int timeout = 45;                                 //单位是秒

 ioctl(wdt_fd, WDIOC_SETTIMEOUT, &timeout);

5、获得当前超时时间

 ioctl(wdt_fd, WDIOC_GETTIMEOUT, &timeout);

 printf("The timeout is %d seconds\n", timeout);

 

猜你喜欢

转载自blog.csdn.net/u014626722/article/details/39927757