include/lifegrd.h
author Laurent Bessard
Wed, 08 May 2013 09:14:59 +0200
changeset 784 8aefbd0d39ff
parent 750 bfb63ff7106e
permissions -rw-r--r--
Fixed set usage in eds_utils
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     1
/*
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     2
This file is part of CanFestival, a library implementing CanOpen Stack. 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     3
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     4
Copyright (C): Edouard TISSERANT and Francis DUPIN
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     5
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     6
See COPYING file for copyrights details.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     7
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     8
This library is free software; you can redistribute it and/or
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     9
modify it under the terms of the GNU Lesser General Public
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    10
License as published by the Free Software Foundation; either
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    11
version 2.1 of the License, or (at your option) any later version.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    12
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    13
This library is distributed in the hope that it will be useful,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    14
but WITHOUT ANY WARRANTY; without even the implied warranty of
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    16
Lesser General Public License for more details.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    17
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    18
You should have received a copy of the GNU Lesser General Public
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    19
License along with this library; if not, write to the Free Software
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    20
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    21
*/
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    22
529
c171e11707c5 Second time, Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 528
diff changeset
    23
/** @defgroup heartbeato Heartbeat Object
c171e11707c5 Second time, Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 528
diff changeset
    24
 *  The heartbeat mechanism for a device is established through cyclically transmitting a message by a
c171e11707c5 Second time, Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 528
diff changeset
    25
 *	heartbeat producer. One or more devices in the network are aware of this heartbeat message. If the
c171e11707c5 Second time, Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 528
diff changeset
    26
 *	heartbeat cycle fails for the heartbeat producer the local application on the heartbeat consumer will be
c171e11707c5 Second time, Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 528
diff changeset
    27
 *	informed about that event.
c171e11707c5 Second time, Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 528
diff changeset
    28
 *  @ingroup comobj
c171e11707c5 Second time, Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 528
diff changeset
    29
 */
750
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 635
diff changeset
    30
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 635
diff changeset
    31
/** @defgroup nodeguardo Node-guarding Object
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 635
diff changeset
    32
 *  The node-guarding mechanism for a device is established through cyclically polling all slaves by the NMT
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 635
diff changeset
    33
 *    	master. If one polled slave does not respond during a specified time (LifeTime), the local application
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 635
diff changeset
    34
 * 	will be informed about that event.<br>
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 635
diff changeset
    35
 *	It is also possible for the slaves to monitor the node-guarding requests coming from the master to
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 635
diff changeset
    36
 * 	determine, if the master operates in a right way
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 635
diff changeset
    37
 *  @ingroup comobj
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 635
diff changeset
    38
 *
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 635
diff changeset
    39
 * @todo The implementation is very basic. The toggle bit of the nodes confirmation is not checked at the moment
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 635
diff changeset
    40
 */
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 635
diff changeset
    41
	
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 635
diff changeset
    42
/**
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 635
diff changeset
    43
** @file   lifegrd.h
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 635
diff changeset
    44
** @author Markus WILDBOLZ
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 635
diff changeset
    45
** @date   Mon Oct 01 14:44:36 CEST 2012 
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 635
diff changeset
    46
**
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 635
diff changeset
    47
** @brief
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 635
diff changeset
    48
**
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 635
diff changeset
    49
**
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 635
diff changeset
    50
*/
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 635
diff changeset
    51
				 
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    52
#ifndef __lifegrd_h__
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    53
#define __lifegrd_h__
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    54
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    55
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    56
#include <applicfg.h>
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    57
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: 343
diff changeset
    58
typedef void (*heartbeatError_t)(CO_Data*, UNS8);
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: 343
diff changeset
    59
void _heartbeatError(CO_Data* d, UNS8 heartbeatID);
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    60
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: 343
diff changeset
    61
typedef void (*post_SlaveBootup_t)(CO_Data*, UNS8);
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: 343
diff changeset
    62
void _post_SlaveBootup(CO_Data* d, UNS8 SlaveID);
343
118c1cabd0b0 Primary LSS support, thanks to Jorge Berzosa.
etisserant
parents: 149
diff changeset
    63
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: 529
diff changeset
    64
typedef void (*post_SlaveStateChange_t)(CO_Data*, UNS8, e_nodeState);
30a0e926bb2e ADDED: - new callback post_SlaveStateChange so that a master can monitor the state of its slave nodes using a heartbeat.
Christian Taedcke
parents: 529
diff changeset
    65
void _post_SlaveStateChange(CO_Data* d, UNS8 nodeId, e_nodeState 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: 529
diff changeset
    66
750
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 635
diff changeset
    67
typedef void (*nodeguardError_t)(CO_Data*, UNS8);
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 635
diff changeset
    68
void _nodeguardError(CO_Data* d, UNS8 id);
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 635
diff changeset
    69
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    70
#include "data.h"
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    71
71
95cd3376cc9f compilator compatitibility
frdupin
parents: 0
diff changeset
    72
/*************************************************************************
95cd3376cc9f compilator compatitibility
frdupin
parents: 0
diff changeset
    73
 * Functions
74
c0b4b2ef7579 compiler compatibility : comments
frdupin
parents: 71
diff changeset
    74
 *************************************************************************/
750
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 635
diff changeset
    75
/** 
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 635
diff changeset
    76
 * @brief Start node guarding with respect to 0x100C and 0x100D
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 635
diff changeset
    77
 * in the object dictionary
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 635
diff changeset
    78
 * 
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 635
diff changeset
    79
 * @param *d Pointer on a CAN object data structure
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 635
diff changeset
    80
 * @ingroup nodeguardo
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 635
diff changeset
    81
 */
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 635
diff changeset
    82
void nodeguardInit(CO_Data* d);
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 635
diff changeset
    83
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 635
diff changeset
    84
/** 
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 635
diff changeset
    85
 * @brief Stop producing node guarding messages
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 635
diff changeset
    86
 *
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 635
diff changeset
    87
 * @param *d Pointer on a CAN object data structure
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 635
diff changeset
    88
 * @ingroup nodeguardo
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 635
diff changeset
    89
 */
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 635
diff changeset
    90
void nodeguardStop(CO_Data* d);
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 635
diff changeset
    91
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 635
diff changeset
    92
/** 
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 635
diff changeset
    93
 * @brief Start the life guarding service (heartbeat/node guarding).
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 635
diff changeset
    94
 * This service handles NMT error control messages either by using
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 635
diff changeset
    95
 * heartbeats and/or by using node guarding messages (defined via the
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 635
diff changeset
    96
 * object dictionary)
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 635
diff changeset
    97
 *
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 635
diff changeset
    98
 * @param *d Pointer on a CAN object data structure
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 635
diff changeset
    99
 */
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 635
diff changeset
   100
void lifeGuardInit(CO_Data* d);
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 635
diff changeset
   101
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 635
diff changeset
   102
/** 
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 635
diff changeset
   103
 * @brief Stop the life guarding service (heartbeat/node guarding).
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 635
diff changeset
   104
 *
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 635
diff changeset
   105
 * @param *d Pointer on a CAN object data structure
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 635
diff changeset
   106
 */
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 635
diff changeset
   107
void lifeGuardStop(CO_Data* d);
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   108
528
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 378
diff changeset
   109
/** 
529
c171e11707c5 Second time, Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 528
diff changeset
   110
 * @ingroup statemachine
528
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 378
diff changeset
   111
 * @brief To read the state of a node
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 378
diff changeset
   112
 * This can be used by the master after having sent a life guard request,
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 378
diff changeset
   113
 * of by any node if it is waiting for heartbeat.
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 378
diff changeset
   114
 * @param *d Pointer on a CAN object data structure
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 378
diff changeset
   115
 * @param nodeId Id of a node
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 378
diff changeset
   116
 * @return e_nodeState State of the node corresponding to the nodeId
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   117
 */
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   118
e_nodeState getNodeState (CO_Data* d, UNS8 nodeId);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   119
528
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 378
diff changeset
   120
/** 
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 378
diff changeset
   121
 * @brief Start heartbeat consumer and producer
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 378
diff changeset
   122
 * with respect to 0x1016 and 0x1017
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 378
diff changeset
   123
 * object dictionary entries
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 378
diff changeset
   124
 * @param *d Pointer on a CAN object data structure
750
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 635
diff changeset
   125
 * @ingroup heartbeato
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   126
 */
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   127
void heartbeatInit(CO_Data* d);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   128
528
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 378
diff changeset
   129
/** 
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 378
diff changeset
   130
 * @brief Stop heartbeat consumer and producer
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 378
diff changeset
   131
 * @param *d Pointer on a CAN object data structure
750
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 635
diff changeset
   132
 * @ingroup heartbeato
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   133
 */
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   134
void heartbeatStop(CO_Data* d);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   135
528
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 378
diff changeset
   136
/** 
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 378
diff changeset
   137
 * @brief This function is responsible to process a canopen-message which seams to be an NMT Error Control
750
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 635
diff changeset
   138
 * Messages.
528
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 378
diff changeset
   139
 * If a BootUp message is detected, it will return the nodeId of the Slave who booted up
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 378
diff changeset
   140
 * @param *d Pointer on a CAN object data structure 
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 378
diff changeset
   141
 * @param *m Pointer on the CAN-message which has to be analysed.
750
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 635
diff changeset
   142
 * @ingroup nodeguardo
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   143
 */
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   144
void proceedNODE_GUARD (CO_Data* d, Message* m);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   145
750
bfb63ff7106e Implementation of a basic working node-guarding
mwildbolz
parents: 635
diff changeset
   146
71
95cd3376cc9f compilator compatitibility
frdupin
parents: 0
diff changeset
   147
#endif /*__lifegrd_h__ */