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