配置内核看门狗支持:
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");
扫描二维码关注公众号,回复:
2631445 查看本文章
exit(-1);
}
2、关闭
close(fd);
3、喂狗
第一种方式:
ioctl(wdt_fd, WDIOC_KEEPALIVE);
第二种方式:
char flag = ‘V’;
write(wdt_fd,&flag,1);
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);