|
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 "nmtMaster.h" |
|
24 |
|
25 /******************************************************************************/ |
|
26 UNS8 masterSendNMTstateChange(CO_Data* d, UNS8 Node_ID, UNS8 cs) |
|
27 { |
|
28 Message m; |
|
29 |
|
30 MSG_WAR(0x3501, "Send_NMT cs : ", cs); |
|
31 MSG_WAR(0x3502, " to node : ", Node_ID); |
|
32 /* message configuration */ |
|
33 m.cob_id.w = 0x0000; /*(NMT) << 7*/ |
|
34 m.rtr = NOT_A_REQUEST; |
|
35 m.len = 2; |
|
36 m.data[0] = cs; |
|
37 m.data[1] = Node_ID; |
|
38 |
|
39 return (*d->canSend)(&m); |
|
40 } |
|
41 |
|
42 |
|
43 /****************************************************************************/ |
|
44 UNS8 masterSendNMTnodeguard(CO_Data* d, UNS8 nodeId) |
|
45 { |
|
46 Message m; |
|
47 |
|
48 MSG_WAR(0x3503, "Send_NODE_GUARD to node : ", nodeId); |
|
49 |
|
50 /* message configuration */ |
|
51 m.cob_id.w = nodeId | (NODE_GUARD << 7); |
|
52 m.rtr = REQUEST; |
|
53 m.len = 1; |
|
54 |
|
55 return (*d->canSend)(&m); |
|
56 } |
|
57 |
|
58 /******************************************************************************/ |
|
59 void masterRequestNodeState(CO_Data* d, UNS8 nodeId) |
|
60 { |
|
61 // FIXME: should warn for bad toggle bit. |
|
62 |
|
63 /* NMTable configuration to indicate that the master is waiting |
|
64 * for a Node_Guard frame from the slave whose node_id is ID */ |
|
65 d->NMTable[nodeId] = Unknown_state; // A state that does not exist |
|
66 |
|
67 if (nodeId == 0) { // NMT broadcast |
|
68 UNS8 i = 0; |
|
69 for (i = 0 ; i < NMT_MAX_NODE_ID ; i++) { |
|
70 d->NMTable[i] = Unknown_state; |
|
71 } |
|
72 } |
|
73 masterSendNMTnodeguard(d,nodeId); |
|
74 } |
|
75 |
|
76 |
|
77 |
|
78 |
|
79 |
|
80 |
|
81 |
|
82 |
|
83 |