src/states.c
changeset 183 4cddad17c81f
parent 178 01d81faa3350
child 195 1510dd61ead0
equal deleted inserted replaced
182:988f2b302aa6 183:4cddad17c81f
    97 }
    97 }
    98 
    98 
    99 /*****************************************************************************/
    99 /*****************************************************************************/
   100 UNS8 setState(CO_Data* d, e_nodeState newState)
   100 UNS8 setState(CO_Data* d, e_nodeState newState)
   101 {
   101 {
       
   102 	UNS16 wIndex = 0x1F22;
       
   103 	const indextable *ptrTable;
       
   104   	ODCallback_t *Callback;
       
   105 	UNS32 errorCode;
   102 	while(newState != d->nodeState){
   106 	while(newState != d->nodeState){
   103 		switch( newState ){
   107 		switch( newState ){
   104 			case Initialisation:
   108 			case Initialisation:
   105 			{
   109 			{
   106 				s_state_communication newCommunicationState = {1, 0, 0, 0, 0, 0};
   110 				s_state_communication newCommunicationState = {1, 0, 0, 0, 0, 0};
   121 				d->nodeState = Pre_operational;
   125 				d->nodeState = Pre_operational;
   122 				newState = Pre_operational;
   126 				newState = Pre_operational;
   123 				switchCommunicationState(d, &newCommunicationState);
   127 				switchCommunicationState(d, &newCommunicationState);
   124 				if (!(*(d->iam_a_slave)))
   128 				if (!(*(d->iam_a_slave)))
   125 				{
   129 				{
   126 					UNS32 res;
   130 					ptrTable =(*d->scanIndexOD)(wIndex, &errorCode, &Callback);
   127 					res = decompo_dcf(d,0x01);
   131   					
       
   132   					if (errorCode != OD_SUCCESSFUL)
       
   133   						{
       
   134   							(*d->preOperational)();
       
   135   						}
       
   136 					else
       
   137 						{
       
   138 							UNS32 res;
       
   139 							res = decompo_dcf(d,0x01);
       
   140 						}				
   128 				}
   141 				}
   129 				else 
   142 				else 
   130 				{
   143 				{
   131 					(*d->preOperational)();
   144 					(*d->preOperational)();
   132 				}
   145 				}