author | etisserant |
Fri, 21 Sep 2007 17:50:20 +0200 | |
changeset 279 | 9b69f2fabafe |
parent 215 | f49e5a6b7804 |
child 343 | 118c1cabd0b0 |
permissions | -rw-r--r-- |
0 | 1 |
/* |
208 | 2 |
This file is part of CanFestival, a library implementing CanOpen |
3 |
Stack. |
|
0 | 4 |
|
208 | 5 |
Copyright (C): Edouard TISSERANT and Francis DUPIN |
0 | 6 |
|
208 | 7 |
See COPYING file for copyrights details. |
0 | 8 |
|
208 | 9 |
This library is free software; you can redistribute it and/or |
10 |
modify it under the terms of the GNU Lesser General Public |
|
11 |
License as published by the Free Software Foundation; either |
|
12 |
version 2.1 of the License, or (at your option) any later version. |
|
0 | 13 |
|
208 | 14 |
This library is distributed in the hope that it will be useful, |
15 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
16 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
17 |
Lesser General Public License for more details. |
|
0 | 18 |
|
208 | 19 |
You should have received a copy of the GNU Lesser General Public |
20 |
License along with this library; if not, write to the Free Software |
|
21 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
|
22 |
USA |
|
0 | 23 |
*/ |
208 | 24 |
/*! |
25 |
** @file nmtSlave.c |
|
26 |
** @author Edouard TISSERANT and Francis DUPIN |
|
27 |
** @date Tue Jun 5 08:50:53 2007 |
|
28 |
** |
|
29 |
** @brief |
|
30 |
** |
|
31 |
** |
|
32 |
*/ |
|
0 | 33 |
#include "nmtSlave.h" |
34 |
#include "states.h" |
|
150
d2fc5d5f8a36
Some win32 fixes following yesterday's API changes.
etisserant
parents:
149
diff
changeset
|
35 |
#include "canfestival.h" |
0 | 36 |
|
208 | 37 |
/*! |
38 |
** put the slave in the state wanted by the master |
|
39 |
** |
|
40 |
** @param d |
|
41 |
** @param m |
|
42 |
**/ |
|
0 | 43 |
void proceedNMTstateChange(CO_Data* d, Message *m) |
44 |
{ |
|
45 |
if( d->nodeState == Pre_operational || |
|
46 |
d->nodeState == Operational || |
|
47 |
d->nodeState == Stopped ) { |
|
208 | 48 |
|
0 | 49 |
MSG_WAR(0x3400, "NMT received. for node : ", (*m).data[1]); |
208 | 50 |
|
215 | 51 |
/* Check if this NMT-message is for this node */ |
52 |
/* byte 1 = 0 : all the nodes are concerned (broadcast) */ |
|
208 | 53 |
|
0 | 54 |
if( ( (*m).data[1] == 0 ) || ( (*m).data[1] == *d->bDeviceNodeId ) ){ |
208 | 55 |
|
215 | 56 |
switch( (*m).data[0]){ /* command specifier (cs) */ |
0 | 57 |
case NMT_Start_Node: |
58 |
if ( (d->nodeState == Pre_operational) || (d->nodeState == Stopped) ) |
|
59 |
setState(d,Operational); |
|
208 | 60 |
break; |
61 |
||
0 | 62 |
case NMT_Stop_Node: |
63 |
if ( d->nodeState == Pre_operational || |
|
208 | 64 |
d->nodeState == Operational ) |
0 | 65 |
setState(d,Stopped); |
66 |
break; |
|
208 | 67 |
|
0 | 68 |
case NMT_Enter_PreOperational: |
208 | 69 |
if ( d->nodeState == Operational || |
70 |
d->nodeState == Stopped ) |
|
71 |
setState(d,Pre_operational); |
|
0 | 72 |
break; |
208 | 73 |
|
0 | 74 |
case NMT_Reset_Node: |
208 | 75 |
setState(d,Initialisation); |
0 | 76 |
break; |
208 | 77 |
|
0 | 78 |
case NMT_Reset_Comunication: |
208 | 79 |
setState(d,Initialisation); |
0 | 80 |
break; |
208 | 81 |
|
215 | 82 |
}/* end switch */ |
208 | 83 |
|
215 | 84 |
}/* end if( ( (*m).data[1] == 0 ) || ( (*m).data[1] == |
208 | 85 |
bDeviceNodeId ) ) */ |
0 | 86 |
} |
87 |
} |
|
88 |
||
89 |
||
208 | 90 |
/*! |
91 |
** |
|
92 |
** |
|
93 |
** @param d |
|
94 |
** |
|
95 |
** @return |
|
96 |
**/ |
|
0 | 97 |
UNS8 slaveSendBootUp(CO_Data* d) |
98 |
{ |
|
99 |
Message m; |
|
208 | 100 |
|
0 | 101 |
MSG_WAR(0x3407, "Send a Boot-Up msg ", 0); |
208 | 102 |
|
215 | 103 |
/* message configuration */ |
0 | 104 |
m.cob_id.w = NODE_GUARD << 7 | *d->bDeviceNodeId; |
105 |
m.rtr = NOT_A_REQUEST; |
|
106 |
m.len = 1; |
|
107 |
m.data[0] = 0x00; |
|
208 | 108 |
|
149 | 109 |
return canSend(d->canHandle,&m); |
0 | 110 |
} |
111 |