⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dogcheck.cpp

📁 看门狗测试程序
💻 CPP
字号:
#include <stdio.h>
//#include <conio.h>
#include <math.h>
#include <iostream.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <termios.h>


int main()
{
	int watchDogFD = open("/dev/watchdog",O_RDWR);
	
	printf("watch dog id:%d\n\r",watchDogFD);
	if(watchDogFD==-1)
	{
		printf("open dog failed,try again\n\r");
		return 0;
	}
	for(int i=9;i>0;i--)
	{
		usleep(1000*1000);
		printf("%d秒后喂狗\n\r",i);
	}
	printf("food dog\n");
	write(watchDogFD,NULL,0);
	for(int i=9;i>0;i--)
	{
		usleep(1000*1000);
		printf("装置将在%d秒后重启\n\r",i);
	}

	usleep(5000*1000);
	return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -