nico@207: nico@207: nico@215: CanFestival: src/nmtSlave.c Source File nico@207: nico@207: nico@207: nico@207: nico@207:
nico@207:
nico@207:
nico@207:
nico@215: nico@215:

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@215: 00033 #include "nmtSlave.h"
nico@215: 00034 #include "states.h"
nico@215: 00035 #include "canfestival.h"
nico@210: 00036 
etisserant@240: 00043 void proceedNMTstateChange(CO_Data* d, Message *m)
nico@210: 00044 {
etisserant@240: 00045   if( d->nodeState == Pre_operational ||
etisserant@240: 00046       d->nodeState == Operational ||
etisserant@240: 00047       d->nodeState == Stopped ) {
nico@210: 00048 
etisserant@240: 00049     MSG_WAR(0x3400, "NMT received. for node :  ", (*m).data[1]);
nico@210: 00050 
nico@215: 00051     /* Check if this NMT-message is for this node */
nico@215: 00052     /* byte 1 = 0 : all the nodes are concerned (broadcast) */
nico@215: 00053 
etisserant@240: 00054     if( ( (*m).data[1] == 0 ) || ( (*m).data[1] == *d->bDeviceNodeId ) ){
nico@210: 00055 
nico@215: 00056       switch( (*m).data[0]){ /* command specifier (cs) */
etisserant@240: 00057       case NMT_Start_Node:
etisserant@240: 00058         if ( (d->nodeState == Pre_operational) || (d->nodeState == Stopped) )
etisserant@240: 00059           setState(d,Operational);
nico@210: 00060         break;
nico@210: 00061 
etisserant@240: 00062       case NMT_Stop_Node:
etisserant@240: 00063         if ( d->nodeState == Pre_operational ||
etisserant@240: 00064              d->nodeState == Operational )
etisserant@240: 00065           setState(d,Stopped);
nico@207: 00066         break;
nico@210: 00067 
etisserant@240: 00068       case NMT_Enter_PreOperational:
etisserant@240: 00069         if ( d->nodeState == Operational ||
etisserant@240: 00070              d->nodeState == Stopped )
etisserant@240: 00071           setState(d,Pre_operational);
nico@210: 00072         break;
nico@207: 00073 
etisserant@240: 00074       case NMT_Reset_Node:
etisserant@240: 00075         setState(d,Initialisation);
nico@210: 00076         break;
nico@210: 00077 
etisserant@240: 00078       case NMT_Reset_Comunication:
etisserant@240: 00079         setState(d,Initialisation);
nico@210: 00080         break;
nico@210: 00081 
nico@215: 00082       }/* end switch */
nico@215: 00083 
nico@215: 00084     }/* end if( ( (*m).data[1] == 0 ) || ( (*m).data[1] ==
nico@215: 00085         bDeviceNodeId ) ) */
nico@210: 00086   }
nico@210: 00087 }
nico@210: 00088 
nico@210: 00089 
etisserant@240: 00097 UNS8 slaveSendBootUp(CO_Data* d)
nico@210: 00098 {
nico@215: 00099   Message m;
nico@210: 00100 
etisserant@240: 00101   MSG_WAR(0x3407, "Send a Boot-Up msg ", 0);
nico@210: 00102 
nico@215: 00103   /* message configuration */
etisserant@240: 00104   m.cob_id.w = NODE_GUARD << 7 | *d->bDeviceNodeId;
etisserant@240: 00105   m.rtr = NOT_A_REQUEST;
etisserant@240: 00106   m.len = 1;
etisserant@240: 00107   m.data[0] = 0x00;
nico@210: 00108 
etisserant@240: 00109   return canSend(d->canHandle,&m);
nico@210: 00110 }
nico@210: 00111 
etisserant@240: 

Generated on Mon Jul 2 19:10:16 2007 for CanFestival by  nico@207: nico@207: doxygen 1.5.1
nico@207: nico@207: