src/lifegrd.c
author Laurent Bessard
Thu, 02 May 2013 09:42:37 +0200
changeset 782 c0869429c72a
parent 750 bfb63ff7106e
permissions -rw-r--r--
Removed call of deprecated function on wxSplitterWindow
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     1
/*
207
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
     2
  This file is part of CanFestival, a library implementing CanOpen
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
     3
  Stack.
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
     4
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
     5
  Copyright (C): Edouard TISSERANT and Francis DUPIN
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
     6
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
     7
  See COPYING file for copyrights details.
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
     8
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
     9
  This library is free software; you can redistribute it and/or
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
    10
  modify it under the terms of the GNU Lesser General Public
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
    11
  License as published by the Free Software Foundation; either
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
    12
  version 2.1 of the License, or (at your option) any later version.
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
    13
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
    14
  This library is distributed in the hope that it will be useful,
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
    15
  but WITHOUT ANY WARRANTY; without even the implied warranty of
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
    16
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
    17
  Lesser General Public License for more details.
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
    18
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
    19
  You should have received a copy of the GNU Lesser General Public
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
    20
  License along with this library; if not, write to the Free Software
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
    21
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
    22
  USA
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
    23
*/
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
    24
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
    25
/*!
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 207
diff changeset
    26
** @file   lifegrd.c
207
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
    27
** @author Edouard TISSERANT
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
    28
** @date   Mon Jun  4 17:19:24 2007
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
    29
**
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
    30
** @brief
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
    31
**
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
    32
**
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    33
*/
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    34
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    35
#include <data.h>
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    36
#include "lifegrd.h"
149
fe50ada8020b Changes in the API:
etisserant
parents: 71
diff changeset
    37
#include "canfestival.h"
357
838e5397ae67 Fixed some build errors and warnigs, thanks to Martin Hollenweger (geautomotive.eu)
etisserant
parents: 352
diff changeset
    38
#include "dcf.h"
370
6fecf36df407 Fixed some endianization problems caused by switch to UNS16 for cob_id member in CAN messages. To be continued.
etisserant
parents: 365
diff changeset
    39
#include "sysdep.h"
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    40
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 207
diff changeset
    41
750
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
    42
void ConsumerHeartbeatAlarm(CO_Data* d, UNS32 id);
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
    43
void ProducerHeartbeatAlarm(CO_Data* d, UNS32 id);
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
    44
UNS32 OnHearbeatProducerUpdate(CO_Data* d, const indextable * unused_indextable, UNS8 unused_bSubindex);
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
    45
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
    46
void GuardTimeAlarm(CO_Data* d, UNS32 id);
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
    47
UNS32 OnNodeGuardUpdate(CO_Data* d, const indextable * unused_indextable, UNS8 unused_bSubindex);
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
    48
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
    49
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    50
e_nodeState getNodeState (CO_Data* d, UNS8 nodeId)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    51
{
668
ba53613e94e4 Added some fixes from Jaroslav Fojtik submitted on sourceforge bug tracker:
Mongo
parents: 635
diff changeset
    52
  e_nodeState networkNodeState = Unknown_state;
ba53613e94e4 Added some fixes from Jaroslav Fojtik submitted on sourceforge bug tracker:
Mongo
parents: 635
diff changeset
    53
  #if NMT_MAX_NODE_ID>0
ba53613e94e4 Added some fixes from Jaroslav Fojtik submitted on sourceforge bug tracker:
Mongo
parents: 635
diff changeset
    54
  if(nodeId < NMT_MAX_NODE_ID)
ba53613e94e4 Added some fixes from Jaroslav Fojtik submitted on sourceforge bug tracker:
Mongo
parents: 635
diff changeset
    55
    networkNodeState = d->NMTable[nodeId];
ba53613e94e4 Added some fixes from Jaroslav Fojtik submitted on sourceforge bug tracker:
Mongo
parents: 635
diff changeset
    56
  #endif
207
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
    57
  return networkNodeState;
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
    58
}
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
    59
208
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 207
diff changeset
    60
/*! 
05d95c45b388 Manual convertion -> latex -> pdf
nico
parents: 207
diff changeset
    61
** The Consumer Timer Callback
207
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
    62
**
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
    63
** @param d
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
    64
** @param id
750
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
    65
 * @ingroup heartbeato
207
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
    66
**/
750
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
    67
void ConsumerHeartbeatAlarm(CO_Data* d, UNS32 id)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    68
{
635
30a0e926bb2e ADDED: - new callback post_SlaveStateChange so that a master can monitor the state of its slave nodes using a heartbeat.
Christian Taedcke
parents: 423
diff changeset
    69
  UNS8 nodeId = (UNS8)(((d->ConsumerHeartbeatEntries[id]) & (UNS32)0x00FF0000) >> (UNS8)16);
207
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
    70
  /*MSG_WAR(0x00, "ConsumerHearbeatAlarm", 0x00);*/
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
    71
352
3347581c3140 Fixed timer problem on late Heartbeat. Thanks to Jorge.
etisserant
parents: 349
diff changeset
    72
  /* timer have been notified and is now free (non periodic)*/
3347581c3140 Fixed timer problem on late Heartbeat. Thanks to Jorge.
etisserant
parents: 349
diff changeset
    73
  /* -> avoid deleting re-assigned timer if message is received too late*/
3347581c3140 Fixed timer problem on late Heartbeat. Thanks to Jorge.
etisserant
parents: 349
diff changeset
    74
  d->ConsumerHeartBeatTimers[id]=TIMER_NONE;
635
30a0e926bb2e ADDED: - new callback post_SlaveStateChange so that a master can monitor the state of its slave nodes using a heartbeat.
Christian Taedcke
parents: 423
diff changeset
    75
  
30a0e926bb2e ADDED: - new callback post_SlaveStateChange so that a master can monitor the state of its slave nodes using a heartbeat.
Christian Taedcke
parents: 423
diff changeset
    76
  /* set node state */
30a0e926bb2e ADDED: - new callback post_SlaveStateChange so that a master can monitor the state of its slave nodes using a heartbeat.
Christian Taedcke
parents: 423
diff changeset
    77
  d->NMTable[nodeId] = Disconnected;
207
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
    78
  /*! call heartbeat error with NodeId */
635
30a0e926bb2e ADDED: - new callback post_SlaveStateChange so that a master can monitor the state of its slave nodes using a heartbeat.
Christian Taedcke
parents: 423
diff changeset
    79
  (*d->heartbeatError)(d, nodeId);
207
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
    80
}
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
    81
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    82
void proceedNODE_GUARD(CO_Data* d, Message* m )
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    83
{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    84
  UNS8 nodeId = (UNS8) GET_NODE_ID((*m));
207
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
    85
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
    86
  if((m->rtr == 1) )
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
    87
    /*!
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
    88
    ** Notice that only the master can have sent this
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
    89
    ** node guarding request
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
    90
    */
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
    91
    {
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
    92
      /*!
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
    93
      ** Receiving a NMT NodeGuarding (request of the state by the
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
    94
      ** master)
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
    95
      ** Only answer to the NMT NodeGuarding request, the master is
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
    96
      ** not checked (not implemented)
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
    97
      */
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
    98
      if (nodeId == *d->bDeviceNodeId )
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
    99
        {
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   100
          Message msg;
370
6fecf36df407 Fixed some endianization problems caused by switch to UNS16 for cob_id member in CAN messages. To be continued.
etisserant
parents: 365
diff changeset
   101
          UNS16 tmp = *d->bDeviceNodeId + 0x700;
6fecf36df407 Fixed some endianization problems caused by switch to UNS16 for cob_id member in CAN messages. To be continued.
etisserant
parents: 365
diff changeset
   102
          msg.cob_id = UNS16_LE(tmp);
207
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   103
          msg.len = (UNS8)0x01;
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   104
          msg.rtr = 0;
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   105
          msg.data[0] = d->nodeState;
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   106
          if (d->toggle)
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   107
            {
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   108
              msg.data[0] |= 0x80 ;
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   109
              d->toggle = 0 ;
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   110
            }
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   111
          else
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   112
            d->toggle = 1 ;
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   113
          /* send the nodeguard response. */
207
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   114
          MSG_WAR(0x3130, "Sending NMT Nodeguard to master, state: ", d->nodeState);
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   115
          canSend(d->canHandle,&msg );
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   116
        }
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   117
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   118
    }else{ /* Not a request CAN */
635
30a0e926bb2e ADDED: - new callback post_SlaveStateChange so that a master can monitor the state of its slave nodes using a heartbeat.
Christian Taedcke
parents: 423
diff changeset
   119
      /* The state is stored on 7 bit */
30a0e926bb2e ADDED: - new callback post_SlaveStateChange so that a master can monitor the state of its slave nodes using a heartbeat.
Christian Taedcke
parents: 423
diff changeset
   120
      e_nodeState newNodeState = (e_nodeState) ((*m).data[0] & 0x7F);
207
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   121
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   122
      MSG_WAR(0x3110, "Received NMT nodeId : ", nodeId);
635
30a0e926bb2e ADDED: - new callback post_SlaveStateChange so that a master can monitor the state of its slave nodes using a heartbeat.
Christian Taedcke
parents: 423
diff changeset
   123
      
750
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   124
      /*!
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   125
      ** Record node response for node guarding service
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   126
      */
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   127
      d->nodeGuardStatus[nodeId] = *d->LifeTimeFactor;
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   128
635
30a0e926bb2e ADDED: - new callback post_SlaveStateChange so that a master can monitor the state of its slave nodes using a heartbeat.
Christian Taedcke
parents: 423
diff changeset
   129
      if (d->NMTable[nodeId] != newNodeState)
30a0e926bb2e ADDED: - new callback post_SlaveStateChange so that a master can monitor the state of its slave nodes using a heartbeat.
Christian Taedcke
parents: 423
diff changeset
   130
      {
30a0e926bb2e ADDED: - new callback post_SlaveStateChange so that a master can monitor the state of its slave nodes using a heartbeat.
Christian Taedcke
parents: 423
diff changeset
   131
        (*d->post_SlaveStateChange)(d, nodeId, newNodeState);
30a0e926bb2e ADDED: - new callback post_SlaveStateChange so that a master can monitor the state of its slave nodes using a heartbeat.
Christian Taedcke
parents: 423
diff changeset
   132
        /* the slave's state receievd is stored in the NMTable */
30a0e926bb2e ADDED: - new callback post_SlaveStateChange so that a master can monitor the state of its slave nodes using a heartbeat.
Christian Taedcke
parents: 423
diff changeset
   133
        d->NMTable[nodeId] = newNodeState;
30a0e926bb2e ADDED: - new callback post_SlaveStateChange so that a master can monitor the state of its slave nodes using a heartbeat.
Christian Taedcke
parents: 423
diff changeset
   134
      }
207
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   135
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   136
      /* Boot-Up frame reception */
207
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   137
      if ( d->NMTable[nodeId] == Initialisation)
669
50da44ebaf00 Configuration manager with DCF in object 0x1F22 rewritten almost from scratch.
Mongo
parents: 668
diff changeset
   138
      {
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   139
          /*
207
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   140
          ** The device send the boot-up message (Initialisation)
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   141
          ** to indicate the master that it is entered in
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   142
          ** pre_operational mode
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   143
          */
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   144
          MSG_WAR(0x3100, "The NMT is a bootup from node : ", nodeId);
669
50da44ebaf00 Configuration manager with DCF in object 0x1F22 rewritten almost from scratch.
Mongo
parents: 668
diff changeset
   145
          /* call post SlaveBootup with NodeId */
50da44ebaf00 Configuration manager with DCF in object 0x1F22 rewritten almost from scratch.
Mongo
parents: 668
diff changeset
   146
		  (*d->post_SlaveBootup)(d, nodeId);
50da44ebaf00 Configuration manager with DCF in object 0x1F22 rewritten almost from scratch.
Mongo
parents: 668
diff changeset
   147
      }
207
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   148
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   149
      if( d->NMTable[nodeId] != Unknown_state ) {
750
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   150
        UNS8 index, ConsumerHeartBeat_nodeId ;
207
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   151
        for( index = (UNS8)0x00; index < *d->ConsumerHeartbeatCount; index++ )
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   152
          {
750
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   153
            ConsumerHeartBeat_nodeId = (UNS8)( ((d->ConsumerHeartbeatEntries[index]) & (UNS32)0x00FF0000) >> (UNS8)16 );
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   154
            if ( nodeId == ConsumerHeartBeat_nodeId )
207
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   155
              {
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   156
                TIMEVAL time = ( (d->ConsumerHeartbeatEntries[index]) & (UNS32)0x0000FFFF ) ;
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   157
                /* Renew alarm for next heartbeat. */
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   158
                DelAlarm(d->ConsumerHeartBeatTimers[index]);
750
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   159
                d->ConsumerHeartBeatTimers[index] = SetAlarm(d, index, &ConsumerHeartbeatAlarm, MS_TO_TIMEVAL(time), 0);
207
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   160
              }
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   161
          }
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   162
      }
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   163
    }
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   164
}
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   165
750
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   166
/*! The Producer Timer Callback
207
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   167
**
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   168
**
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   169
** @param d
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   170
** @param id
750
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   171
 * @ingroup heartbeato
207
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   172
**/
750
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   173
void ProducerHeartbeatAlarm(CO_Data* d, UNS32 id)
207
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   174
{
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   175
  if(*d->ProducerHeartBeatTime)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   176
    {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   177
      Message msg;
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   178
      /* Time expired, the heartbeat must be sent immediately
207
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   179
      ** generate the correct node-id: this is done by the offset 1792
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   180
      ** (decimal) and additionaly
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   181
      ** the node-id of this device.
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   182
      */
370
6fecf36df407 Fixed some endianization problems caused by switch to UNS16 for cob_id member in CAN messages. To be continued.
etisserant
parents: 365
diff changeset
   183
      UNS16 tmp = *d->bDeviceNodeId + 0x700;
6fecf36df407 Fixed some endianization problems caused by switch to UNS16 for cob_id member in CAN messages. To be continued.
etisserant
parents: 365
diff changeset
   184
      msg.cob_id = UNS16_LE(tmp);
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   185
      msg.len = (UNS8)0x01;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   186
      msg.rtr = 0;
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   187
      msg.data[0] = d->nodeState; /* No toggle for heartbeat !*/
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   188
      /* send the heartbeat */
207
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   189
      MSG_WAR(0x3130, "Producing heartbeat: ", d->nodeState);
149
fe50ada8020b Changes in the API:
etisserant
parents: 71
diff changeset
   190
      canSend(d->canHandle,&msg );
207
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   191
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   192
    }else{
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   193
      d->ProducerHeartBeatTimer = DelAlarm(d->ProducerHeartBeatTimer);
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   194
    }
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   195
}
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   196
750
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   197
/**
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   198
 * @brief The guardTime - Timer Callback.
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   199
 * 
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   200
 * This function is called every GuardTime (OD 0x100C) ms <br>
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   201
 * On every call, a NodeGuard-Request is sent to all nodes which have a
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   202
 * node-state not equal to "Unknown" (according to NMTable). If the node has
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   203
 * not responded within the lifetime, the nodeguardError function is called and
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   204
 * the status of this node is set to "Disconnected"
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   205
 *
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   206
 * @param d 	Pointer on a CAN object data structure 
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   207
 * @param id
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   208
 * @ingroup nodeguardo
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   209
 */
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   210
void GuardTimeAlarm(CO_Data* d, UNS32 id)
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   211
{
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   212
  if (*d->GuardTime) {
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   213
    UNS8 i;
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   214
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   215
    MSG_WAR(0x00, "Producing nodeguard-requests: ", 0);
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   216
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   217
    for (i = 0; i < NMT_MAX_NODE_ID; i++) {
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   218
      /** Send node guard request to all nodes except this node, if the 
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   219
      * node state is not "Unknown_state"
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   220
      */
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   221
      if (d->NMTable[i] != Unknown_state && i != *d->bDeviceNodeId) {
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   222
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   223
        /** Check if the node has confirmed the guarding request within
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   224
        * the LifeTime (GuardTime x LifeTimeFactor)
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   225
        */
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   226
        if (d->nodeGuardStatus[i] <= 0) {
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   227
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   228
          MSG_WAR(0x00, "Node Guard alarm for nodeId : ", i);
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   229
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   230
          // Call error-callback function
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   231
          if (*d->nodeguardError) {
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   232
            (*d->nodeguardError)(d, i);
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   233
          }
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   234
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   235
          // Mark node as disconnected
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   236
          d->NMTable[i] = Disconnected;
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   237
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   238
        }
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   239
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   240
        d->nodeGuardStatus[i]--;
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   241
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   242
        masterSendNMTnodeguard(d, i);
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   243
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   244
      }
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   245
    }
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   246
  } else {
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   247
    d->GuardTimeTimer = DelAlarm(d->GuardTimeTimer);
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   248
  }
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   249
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   250
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   251
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   252
}
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   253
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   254
/**
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   255
 * This function is called, if index 0x100C or 0x100D is updated to
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   256
 * restart the node-guarding service with the new parameters
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   257
 *
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   258
 * @param d 	Pointer on a CAN object data structure 
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   259
 * @param unused_indextable
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   260
 * @param unused_bSubindex
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   261
 * @ingroup nodeguardo
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   262
 */
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   263
UNS32 OnNodeGuardUpdate(CO_Data* d, const indextable * unused_indextable, UNS8 unused_bSubindex)
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   264
{
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   265
  nodeguardStop(d);
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   266
  nodeguardInit(d);
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   267
  return 0;
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   268
}
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   269
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   270
207
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   271
/*! This is called when Index 0x1017 is updated.
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   272
**
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   273
**
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   274
** @param d
750
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   275
** @param unused_indextable
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   276
** @param unused_bSubindex
207
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   277
**
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   278
** @return
750
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   279
 * @ingroup heartbeato
207
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   280
**/
750
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   281
UNS32 OnHeartbeatProducerUpdate(CO_Data* d, const indextable * unused_indextable, UNS8 unused_bSubindex)
207
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   282
{
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   283
  heartbeatStop(d);
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   284
  heartbeatInit(d);
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   285
  return 0;
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   286
}
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   287
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   288
void heartbeatInit(CO_Data* d)
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   289
{
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   290
215
f49e5a6b7804 Manual and Documentation finish
nico
parents: 208
diff changeset
   291
  UNS8 index; /* Index to scan the table of heartbeat consumers */
207
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   292
  RegisterSetODentryCallBack(d, 0x1017, 0x00, &OnHeartbeatProducerUpdate);
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   293
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   294
  d->toggle = 0;
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   295
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   296
  for( index = (UNS8)0x00; index < *d->ConsumerHeartbeatCount; index++ )
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   297
    {
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   298
      TIMEVAL time = (UNS16) ( (d->ConsumerHeartbeatEntries[index]) & (UNS32)0x0000FFFF ) ;
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   299
      if ( time )
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   300
        {
750
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   301
          d->ConsumerHeartBeatTimers[index] = SetAlarm(d, index, &ConsumerHeartbeatAlarm, MS_TO_TIMEVAL(time), 0);
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   302
        }
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   303
    }
207
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   304
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   305
  if ( *d->ProducerHeartBeatTime )
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   306
    {
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   307
      TIMEVAL time = *d->ProducerHeartBeatTime;
750
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   308
      d->ProducerHeartBeatTimer = SetAlarm(d, 0, &ProducerHeartbeatAlarm, MS_TO_TIMEVAL(time), MS_TO_TIMEVAL(time));
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   309
    }
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   310
}
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   311
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   312
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   313
void nodeguardInit(CO_Data* d)
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   314
{
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   315
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   316
  RegisterSetODentryCallBack(d, 0x100C, 0x00, &OnNodeGuardUpdate);
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   317
  RegisterSetODentryCallBack(d, 0x100D, 0x00, &OnNodeGuardUpdate);
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   318
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   319
  if (*d->GuardTime && *d->LifeTimeFactor) {
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   320
    UNS8 i;
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   321
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   322
    TIMEVAL time = *d->GuardTime;
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   323
    d->GuardTimeTimer = SetAlarm(d, 0, &GuardTimeAlarm, MS_TO_TIMEVAL(time), MS_TO_TIMEVAL(time));
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   324
    MSG_WAR(0x0, "GuardTime: ", time);
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   325
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   326
    for (i = 0; i < NMT_MAX_NODE_ID; i++) {
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   327
      /** Set initial value for the nodes */
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   328
      if (d->NMTable[i] != Unknown_state && i != *d->bDeviceNodeId) { 
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   329
        d->nodeGuardStatus[i] = *d->LifeTimeFactor;
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   330
      }
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   331
    }
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   332
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   333
    MSG_WAR(0x0, "Timer for node-guarding startet", 0);
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   334
  }
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   335
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   336
}
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   337
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   338
void heartbeatStop(CO_Data* d)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   339
{
207
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   340
  UNS8 index;
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   341
  for( index = (UNS8)0x00; index < *d->ConsumerHeartbeatCount; index++ )
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   342
    {
423
d60363d872dd Probable bug fix in HeartBeatStop
etisserant
parents: 378
diff changeset
   343
      d->ConsumerHeartBeatTimers[index] = DelAlarm(d->ConsumerHeartBeatTimers[index]);
d60363d872dd Probable bug fix in HeartBeatStop
etisserant
parents: 378
diff changeset
   344
    }
d60363d872dd Probable bug fix in HeartBeatStop
etisserant
parents: 378
diff changeset
   345
d60363d872dd Probable bug fix in HeartBeatStop
etisserant
parents: 378
diff changeset
   346
  d->ProducerHeartBeatTimer = DelAlarm(d->ProducerHeartBeatTimer);
207
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   347
}
b6572d0336c3 First doxygen implementation
nico
parents: 185
diff changeset
   348
750
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   349
void nodeguardStop(CO_Data* d)
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   350
{
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   351
  d->GuardTimeTimer = DelAlarm(d->GuardTimeTimer);
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   352
}
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   353
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   354
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   355
void lifeGuardInit(CO_Data* d)
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   356
{
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   357
  heartbeatInit(d);
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   358
  nodeguardInit(d);
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   359
}
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   360
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   361
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   362
void lifeGuardStop(CO_Data* d)
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   363
{
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   364
  heartbeatStop(d);
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   365
  nodeguardStop(d);
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   366
}
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   367
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   368
378
d2abf6c8c27b As requested long ago, added CoData* parameter to all this applications callback, let application designer use identical callback for multiple nodes, and reduce source code length.
etisserant
parents: 370
diff changeset
   369
void _heartbeatError(CO_Data* d, UNS8 heartbeatID){}
d2abf6c8c27b As requested long ago, added CoData* parameter to all this applications callback, let application designer use identical callback for multiple nodes, and reduce source code length.
etisserant
parents: 370
diff changeset
   370
void _post_SlaveBootup(CO_Data* d, UNS8 SlaveID){}
635
30a0e926bb2e ADDED: - new callback post_SlaveStateChange so that a master can monitor the state of its slave nodes using a heartbeat.
Christian Taedcke
parents: 423
diff changeset
   371
void _post_SlaveStateChange(CO_Data* d, UNS8 nodeId, e_nodeState newNodeState){}
750
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   372
void _nodeguardError(CO_Data* d, UNS8 id){}
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 669
diff changeset
   373