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

Generated on Mon Jun 4 17:09:26 2007 for CanFestival by  nico@207: nico@207: doxygen 1.5.1
nico@207: nico@207: