nico@207: nico@207: nico@207: CanFestival: /home/epimerde/documents/tc11/CanFestival-3/src/nmtSlave.c Source File nico@207: nico@207: nico@207: nico@207: nico@207:
nico@207:
nico@207:
nico@207:
nico@207:

/home/epimerde/documents/tc11/CanFestival-3/src/nmtSlave.c

Go to the documentation of this file.
00001 /*
nico@210: 00002   This file is part of CanFestival, a library implementing CanOpen
nico@210: 00003   Stack.
nico@210: 00004 
nico@210: 00005   Copyright (C): Edouard TISSERANT and Francis DUPIN
nico@210: 00006 
nico@210: 00007   See COPYING file for copyrights details.
nico@210: 00008 
nico@210: 00009   This library is free software; you can redistribute it and/or
nico@210: 00010   modify it under the terms of the GNU Lesser General Public
nico@210: 00011   License as published by the Free Software Foundation; either
nico@210: 00012   version 2.1 of the License, or (at your option) any later version.
nico@210: 00013 
nico@210: 00014   This library is distributed in the hope that it will be useful,
nico@210: 00015   but WITHOUT ANY WARRANTY; without even the implied warranty of
nico@210: 00016   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
nico@210: 00017   Lesser General Public License for more details.
nico@210: 00018 
nico@210: 00019   You should have received a copy of the GNU Lesser General Public
nico@210: 00020   License along with this library; if not, write to the Free Software
nico@210: 00021   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
nico@210: 00022   USA
nico@210: 00023 */
nico@210: 00033 #include "nmtSlave.h"
nico@210: 00034 #include "states.h"
nico@210: 00035 #include "canfestival.h"
nico@210: 00036 
nico@210: 00043 void proceedNMTstateChange(CO_Data* d, Message *m)
nico@210: 00044 {
nico@210: 00045   if( d->nodeState == Pre_operational ||
nico@210: 00046       d->nodeState == Operational ||
nico@210: 00047       d->nodeState == Stopped ) {
nico@210: 00048 
nico@210: 00049     MSG_WAR(0x3400, "NMT received. for node :  ", (*m).data[1]);
nico@210: 00050 
nico@210: 00054     if( ( (*m).data[1] == 0 ) || ( (*m).data[1] == *d->bDeviceNodeId ) ){
nico@210: 00055 
nico@210: 00056       switch( (*m).data[0]){ 
nico@210: 00057       case NMT_Start_Node:
nico@210: 00058         if ( (d->nodeState == Pre_operational) || (d->nodeState == Stopped) )
nico@210: 00059           setState(d,Operational);
nico@210: 00060         break;
nico@210: 00061 
nico@210: 00062       case NMT_Stop_Node:
nico@210: 00063         if ( d->nodeState == Pre_operational ||
nico@210: 00064              d->nodeState == Operational )
nico@210: 00065           setState(d,Stopped);
nico@207: 00066         break;
nico@210: 00067 
nico@210: 00068       case NMT_Enter_PreOperational:
nico@210: 00069         if ( d->nodeState == Operational ||
nico@210: 00070              d->nodeState == Stopped )
nico@210: 00071           setState(d,Pre_operational);
nico@210: 00072         break;
nico@207: 00073 
nico@210: 00074       case NMT_Reset_Node:
nico@210: 00075         setState(d,Initialisation);
nico@210: 00076         break;
nico@210: 00077 
nico@210: 00078       case NMT_Reset_Comunication:
nico@210: 00079         setState(d,Initialisation);
nico@210: 00080         break;
nico@210: 00081 
nico@210: 00082       }
nico@210: 00084     }
nico@210: 00086   }
nico@210: 00087 }
nico@210: 00088 
nico@210: 00089 
nico@210: 00097 UNS8 slaveSendBootUp(CO_Data* d)
nico@210: 00098 {
nico@210: 00099   Message m;
nico@210: 00100 
nico@210: 00101   MSG_WAR(0x3407, "Send a Boot-Up msg ", 0);
nico@210: 00102 
nico@210: 00104   m.cob_id.w = NODE_GUARD << 7 | *d->bDeviceNodeId;
nico@210: 00105   m.rtr = NOT_A_REQUEST;
nico@210: 00106   m.len = 1;
nico@210: 00107   m.data[0] = 0x00;
nico@210: 00108 
nico@210: 00109   return canSend(d->canHandle,&m);
nico@210: 00110 }
nico@210: 00111 
nico@210: 

Generated on Tue Jun 5 18:32:05 2007 for CanFestival by  nico@207: nico@207: doxygen 1.5.1
nico@207: nico@207: