diff -r 5d57fe1e3a5b -r d485a3fc5739 src/lifegrd.c --- a/src/lifegrd.c Mon Apr 30 16:56:21 2007 +0200 +++ b/src/lifegrd.c Fri May 04 12:22:48 2007 +0200 @@ -27,6 +27,7 @@ /* Prototypes for internals functions */ void ConsumerHearbeatAlarm(CO_Data* d, UNS32 id); void ProducerHearbeatAlarm(CO_Data* d, UNS32 id); +UNS32 OnHearbeatUpdate(CO_Data* d, const indextable * unsused_indextable, UNS8 unsused_bSubindex); /*****************************************************************************/ @@ -120,6 +121,7 @@ * (decimal) and additionaly * the node-id of this device. */ + msg.cob_id.w = *d->bDeviceNodeId + 0x700; msg.len = (UNS8)0x01; msg.rtr = 0; @@ -127,18 +129,30 @@ /* send the heartbeat */ MSG_WAR(0x3130, "Producing heartbeat: ", d->nodeState); canSend(d->canHandle,&msg ); + }else{ d->ProducerHeartBeatTimer = DelAlarm(d->ProducerHeartBeatTimer); } } /*****************************************************************************/ +/* This is called when Index 0x1017 is updated.*/ +UNS32 OnHeartbeatProducerUpdate(CO_Data* d) +{ + heartbeatStop(d); + heartbeatInit(d); + return 0; +} +/*****************************************************************************/ + void heartbeatInit(CO_Data* d) { + UNS8 index; /* Index to scan the table of heartbeat consumers */ - + RegisterSetODentryCallBack(d, 0x1017,0x00, &OnHeartbeatProducerUpdate); + d->toggle = 0; - + for( index = (UNS8)0x00; index < *d->ConsumerHeartbeatCount; index++ ) { TIMEVAL time = (UNS16) ( (d->ConsumerHeartbeatEntries[index]) & (UNS32)0x0000FFFF ) ;