Example #1
0
/* Compal Earvin 20120419 begin */
static void indigo_pm_restart(char mode, const char *cmd) {
	SysRestart();
}
Example #2
0
/**
* @brief 监测任务
*/
static void *MonitorTask(void *arg)
{
	//@change later 温度监测(高温关屏)

	//alarm_t alarmbuf;
	//int countbat = 29;
	//int countcycs = CYCSAVE_TIMEOUT - CYCSAVE_FIRSTCNT;
	int countdbclr = DBCLR_TIMEOUT - DBCLR_FIRSETCNT;
	int countclkchk = 0;
	int countclkread = 0;
	int WatchdogTimer = 0;
	int GPRSLineStatTimer = 0;
	sysclock_t clock;
	
	Sleep(20);


	WatchdogTimer = 0;
	GPRSLineStatTimer = 0;
	//Sleep(1000);
	//Sleep(50);
	watchdog_fd = 0;
	watchdog_fd = open("/dev/watchdog",O_RDWR);
	printf("watchdog_fd = %d\n",watchdog_fd);
	PrintLog(0, "watchdog_fd = %d\n",watchdog_fd);
	
	


	while(1) {
		#if 0
		//PowerMonitor(&alarmbuf);
		//SignalMonitor(&alarmbuf);
		//ClockBatMonitor(&alarmbuf);
		//CommFlowsMonitor(&alarmbuf);
		
		//countbat++;
		//if(countbat >= 30) {
		//	countbat = 0;

		//	BatteryMonitor();
		//}

		countcycs++;
		if(countcycs > CYCSAVE_TIMEOUT) {
			countcycs = 0;
			PrintLog(LOGTYPE_SHORT, "start cycle save...\n");
			SysCycleSave(0);
			DebugPrint(LOGTYPE_SHORT, "end\n");
		}
		#endif

		
		countdbclr++;
		if(countdbclr > DBCLR_TIMEOUT) {//16个小时检测一次过时数据
		//if(countdbclr > 3) {
			countdbclr = 0;
			DbaseClear();
		}

		countclkchk++;
		if(countclkchk > CLKCHK_TIMEOUT) {
			countclkchk = 0;

			SysClockCilibrate();//5个小时校准一次系统时间
		}
		countclkread++;
		if(countclkread> 98 * 6) {
			countclkread = 0;
			ReadExternSysClock(&clock);
		}		
		
		
		WatchdogTimer++;
		if(WatchdogTimer>= 5)	
		{
			WatchdogTimer = 0;
			if(watchdog_fd>0)
			{
				//PrintLog(1,"watchdog_fd = %d\n",watchdog_fd);
				//PrintLog(1,"write(watchdog_fd, wBuf, 2 );\n");
       			write(watchdog_fd, wBuf, 2 );
			}
			/*
			else
			{	
				system("killall -9 watchdog");
				Sleep(100);
				watchdog_fd = open("/dev/watchdog", O_RDWR);
				PrintLog(1, "watchdog_fd = %d\n",watchdog_fd);
				//printf("watchdog_fd = %d\n",watchdog_fd);
				//if(watchdog_fd<=0)
				//{
				//	system("./home/run/watchdog");
				//	PrintLog(0, "system/home/run/watchdog");
				//}
			}
			*/
		}
		SysTimerTask_watchdog++;
		//EthShellTask_watchdog++;
	
		if(SysTimerTask_watchdog>(10 * 60 * 60 * 5))
		{
			SysRestart();
		} 
		//if(EthShellTask_watchdog>(10 * 60 * 5))
		//{
		//	SysRestart();
		//}
		if(SvrCommInterface == UPLINKITF_GPRS)
		{
			GprsActiveTask_watchdog++;
			if(GprsActiveTask_watchdog>(10 * 60 * 60 * 5))
			{
				SysRestart();
			}
			if(LINESTAT_OFF == SvrCommLineState) 
			{
				GPRSLineStatTimer++;
			}
			else if(LINESTAT_ON == SvrCommLineState) 
			{
				GPRSLineStatTimer = 0;
			}
			if(GPRSLineStatTimer>(10 * 60 * 60 * 25))///////25个小时不在线,则重启
			{
				SavePlMdb();
				SysRestart();
			}
		}
		PlcTask_watchdog++;
		if(PlcTask_watchdog>(10 * 60 * 60 * 3))
		{
			SysRestart();
		} 
		PlFrezTask_watchdog++;
		if(PlFrezTask_watchdog>(10 * 60 * 60 * 3))
		{
			SysRestart();
		} 
		
		Sleep(10);
	}
}