00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include "nmtSlave.h"
00024 #include "states.h"
00025 #include "canfestival.h"
00026
00027
00028
00029 void proceedNMTstateChange(CO_Data* d, Message *m)
00030 {
00031 if( d->nodeState == Pre_operational ||
00032 d->nodeState == Operational ||
00033 d->nodeState == Stopped ) {
00034
00035 MSG_WAR(0x3400, "NMT received. for node : ", (*m).data[1]);
00036
00037
00038
00039
00040 if( ( (*m).data[1] == 0 ) || ( (*m).data[1] == *d->bDeviceNodeId ) ){
00041
00042 switch( (*m).data[0]){
00043 case NMT_Start_Node:
00044 if ( (d->nodeState == Pre_operational) || (d->nodeState == Stopped) )
00045 setState(d,Operational);
00046 break;
00047
00048 case NMT_Stop_Node:
00049 if ( d->nodeState == Pre_operational ||
00050 d->nodeState == Operational )
00051 setState(d,Stopped);
00052 break;
00053
00054 case NMT_Enter_PreOperational:
00055 if ( d->nodeState == Operational ||
00056 d->nodeState == Stopped )
00057 setState(d,Pre_operational);
00058 break;
00059
00060 case NMT_Reset_Node:
00061 setState(d,Initialisation);
00062 break;
00063
00064 case NMT_Reset_Comunication:
00065 setState(d,Initialisation);
00066 break;
00067
00068 }
00069
00070 }
00071 }
00072 }
00073
00074
00075
00076 UNS8 slaveSendBootUp(CO_Data* d)
00077 {
00078 Message m;
00079
00080 MSG_WAR(0x3407, "Send a Boot-Up msg ", 0);
00081
00082
00083 m.cob_id.w = NODE_GUARD << 7 | *d->bDeviceNodeId;
00084 m.rtr = NOT_A_REQUEST;
00085 m.len = 1;
00086 m.data[0] = 0x00;
00087
00088 return canSend(d->canHandle,&m);
00089 }
00090