2 This file is part of CanFestival, a library implementing CanOpen
5 Copyright (C): Edouard TISSERANT and Francis DUPIN
7 See COPYING file for copyrights details.
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.
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.
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
26 ** @author Edouard TISSERANT and Francis DUPIN
27 ** @date Tue Jun 5 08:50:53 2007
35 #include "canfestival.h"
39 ** put the slave in the state wanted by the master
44 void proceedNMTstateChange(CO_Data* d, Message *m)
46 if( d->nodeState == Pre_operational ||
47 d->nodeState == Operational ||
48 d->nodeState == Stopped ) {
50 MSG_WAR(0x3400, "NMT received. for node : ", (*m).data[1]);
52 /* Check if this NMT-message is for this node */
53 /* byte 1 = 0 : all the nodes are concerned (broadcast) */
55 if( ( (*m).data[1] == 0 ) || ( (*m).data[1] == *d->bDeviceNodeId ) ){
57 switch( (*m).data[0]){ /* command specifier (cs) */
59 if ( (d->nodeState == Pre_operational) || (d->nodeState == Stopped) )
60 setState(d,Operational);
64 if ( d->nodeState == Pre_operational ||
65 d->nodeState == Operational )
69 case NMT_Enter_PreOperational:
70 if ( d->nodeState == Operational ||
71 d->nodeState == Stopped )
72 setState(d,Pre_operational);
76 if(d->NMT_Slave_Node_Reset_Callback != NULL)
77 d->NMT_Slave_Node_Reset_Callback(d);
79 if(getNodeId(d)!=d->lss_transfer.nodeID)
80 setNodeId(d, d->lss_transfer.nodeID);
82 setState(d,Initialisation);
85 case NMT_Reset_Comunication:
86 if(d->NMT_Slave_Communications_Reset_Callback != NULL)
87 d->NMT_Slave_Communications_Reset_Callback(d);
89 if(getNodeId(d)!=d->lss_transfer.nodeID && getNodeId(d)>0 && getNodeId(d)<=127)
90 setNodeId(d, d->lss_transfer.nodeID);
92 setState(d,Initialisation);
97 }/* end if( ( (*m).data[1] == 0 ) || ( (*m).data[1] ==
110 UNS8 slaveSendBootUp(CO_Data* d)
115 if(*d->bDeviceNodeId==0xFF)return 0;
118 MSG_WAR(0x3407, "Send a Boot-Up msg ", 0);
120 /* message configuration */
122 UNS16 tmp = NODE_GUARD << 7 | *d->bDeviceNodeId;
123 m.cob_id = UNS16_LE(tmp);
125 m.rtr = NOT_A_REQUEST;
129 return canSend(d->canHandle,&m);