程序中的一块要实现软件看门狗功能,中间到reboot(0x00)并不能实现目标机重启,求高手指点~~~
/*includes*/
#include "vxWorks.h"
#include "logLib.h"
#include "math.h"
#include "stdioLib.h"
#include "stdio.h"
#include "strLib.h"
#include "ioLib.h"
#include "taskLib.h"
#include "fioLib.h"
#include "ftpLib.h"
#include "ioLib.h"
#include "stdio.h"
#include "sysLib.h"
#include "symLib.h"
#include "symbol.h"
#include "unldLib.h"
#include "moduleLib.h"
#include "rebootLib.h"
/*function prototypes*/
void dogschdule();
void taskdog();
/*defines(these two better in header file)*/
#define MSEL 20/*20ms watch dog timer*/
int taskdogid;
long int wdcount=1;
void RedunSimDogCreate()
{
if((taskdogid=taskSpawn("tdog",100,0,5000,(FUNCPTR)taskdog,0,0,0,0,0,0,0,0,0,0))==ERROR)
{
perror("taskSpawn");
printf("taskSpawn dog failed\n");
}
/*timer*/
sysClkDisable();
sysClkRateSet(1000);/*1ms/tick*/
if(sysClkConnect((FUNCPTR)dogschdule,0)==OK)
{
printf("\nwatch dog timer starting\n");
sysClkEnable();
}
}
void dogschdule()
{
if(wdcount/(MSEL*1000)==1&&wdcount%(MSEL*1000)==0)/*20ms watchdog timer*/
{
taskResume(taskdogid);
printf("task resume is oktask resume is oktask resume is oktask resume is oktask resume is ok\n");
printf("wdcount++:%d\n",wdcount);
}
wdcount++; //logMsg("\r times=%f",wdcount,0,0,0,0,0);
}
void taskdog()
{
while(1)
{
taskSuspend(taskdogid);
printf("system reboot\n");
reboot(0x00);
}
}
[ 本帖最后由 h052315 于 2012-2-27 14:17 编辑 ]
|