src/states.c
changeset 215 f49e5a6b7804
parent 208 05d95c45b388
child 235 f812bf6b7237
equal deleted inserted replaced
214:003cc3c63855 215:f49e5a6b7804
    68 	{
    68 	{
    69 		case SYNC:
    69 		case SYNC:
    70 			if(d->CurrentCommunicationState.csSYNC)
    70 			if(d->CurrentCommunicationState.csSYNC)
    71 				proceedSYNC(d,m);
    71 				proceedSYNC(d,m);
    72 			break;
    72 			break;
    73 		/** case TIME_STAMP: */
    73 		/* case TIME_STAMP: */
    74 		case PDO1tx:
    74 		case PDO1tx:
    75 		case PDO1rx:
    75 		case PDO1rx:
    76 		case PDO2tx:
    76 		case PDO2tx:
    77 		case PDO2rx:
    77 		case PDO2rx:
    78 		case PDO3tx:
    78 		case PDO3tx:
   144 	while(newState != d->nodeState){
   144 	while(newState != d->nodeState){
   145 		switch( newState ){
   145 		switch( newState ){
   146 			case Initialisation:
   146 			case Initialisation:
   147 			{
   147 			{
   148 				s_state_communication newCommunicationState = {1, 0, 0, 0, 0, 0};
   148 				s_state_communication newCommunicationState = {1, 0, 0, 0, 0, 0};
   149 				/** This will force a second loop for the state switch */
   149 				/* This will force a second loop for the state switch */
   150 				d->nodeState = Initialisation;
   150 				d->nodeState = Initialisation;
   151 				newState = Pre_operational;
   151 				newState = Pre_operational;
   152 				switchCommunicationState(d, &newCommunicationState);
   152 				switchCommunicationState(d, &newCommunicationState);
   153 				/** call user app related state func. */
   153 				/* call user app related state func. */
   154 				(*d->initialisation)();
   154 				(*d->initialisation)();
   155 				
   155 				
   156 			}
   156 			}
   157 			break;
   157 			break;
   158 								
   158 								
   206 			}
   206 			}
   207 			break;
   207 			break;
   208 			
   208 			
   209 			default:
   209 			default:
   210 				return 0xFF;
   210 				return 0xFF;
   211 		}/** end switch case */
   211 		}/* end switch case */
   212 	
   212 	
   213 	}
   213 	}
   214 	return 0;
   214 	return 0;
   215 }
   215 }
   216 
   216 
   234 **/   
   234 **/   
   235 void setNodeId(CO_Data* d, UNS8 nodeId)
   235 void setNodeId(CO_Data* d, UNS8 nodeId)
   236 {
   236 {
   237   UNS16 offset = d->firstIndex->SDO_SVR;
   237   UNS16 offset = d->firstIndex->SDO_SVR;
   238   if(offset){
   238   if(offset){
   239       /** cob_id_client = 0x600 + nodeId; */
   239       /* cob_id_client = 0x600 + nodeId; */
   240       *(UNS32*)d->objdict[offset].pSubindex[1].pObject = 0x600 + nodeId;
   240       *(UNS32*)d->objdict[offset].pSubindex[1].pObject = 0x600 + nodeId;
   241       /** cob_id_server = 0x580 + nodeId; */
   241       /* cob_id_server = 0x580 + nodeId; */
   242       *(UNS32*)d->objdict[offset].pSubindex[2].pObject = 0x580 + nodeId;
   242       *(UNS32*)d->objdict[offset].pSubindex[2].pObject = 0x580 + nodeId;
   243       /** node Id client. As we do not know the value, we put the node Id Server */
   243       /* node Id client. As we do not know the value, we put the node Id Server */
   244       /** *(UNS8*)d->objdict[offset].pSubindex[3].pObject = nodeId; */
   244       /* *(UNS8*)d->objdict[offset].pSubindex[3].pObject = nodeId; */
   245   }
   245   }
   246 
   246 
   247   /** 
   247   /* 
   248    	Initialize the server(s) SDO parameters
   248    	Initialize the server(s) SDO parameters
   249   	Remember that only one SDO server is allowed, defined at index 0x1200	
   249   	Remember that only one SDO server is allowed, defined at index 0x1200	
   250  		
   250  		
   251   	Initialize the client(s) SDO parameters 	
   251   	Initialize the client(s) SDO parameters 	
   252   	Nothing to initialize (no default values required by the DS 401)	
   252   	Nothing to initialize (no default values required by the DS 401)	
   276 	      *(UNS32*)d->objdict[offset].pSubindex[1].pObject = cobID[i] + nodeId;
   276 	      *(UNS32*)d->objdict[offset].pSubindex[1].pObject = cobID[i] + nodeId;
   277       i ++;
   277       i ++;
   278       offset ++;
   278       offset ++;
   279     }
   279     }
   280   }
   280   }
   281   /** bDeviceNodeId is defined in the object dictionary. */
   281   /* bDeviceNodeId is defined in the object dictionary. */
   282   *d->bDeviceNodeId = nodeId;
   282   *d->bDeviceNodeId = nodeId;
   283 }
   283 }
   284 
   284 
   285 void _initialisation(){}
   285 void _initialisation(){}
   286 void _preOperational(){}
   286 void _preOperational(){}