# HG changeset patch
# User greg
# Date 1178782387 -7200
# Node ID 4cddad17c81f90f7b7eebc1377ce27a7cc9a9336
# Parent  988f2b302aa6dc798bc81b74dcc64387dad4159f
Test if index 1F22 exists for Master OD (Concise DCF)

diff -r 988f2b302aa6 -r 4cddad17c81f src/states.c
--- a/src/states.c	Fri May 04 13:57:54 2007 +0200
+++ b/src/states.c	Thu May 10 09:33:07 2007 +0200
@@ -99,6 +99,10 @@
 /*****************************************************************************/
 UNS8 setState(CO_Data* d, e_nodeState newState)
 {
+	UNS16 wIndex = 0x1F22;
+	const indextable *ptrTable;
+  	ODCallback_t *Callback;
+	UNS32 errorCode;
 	while(newState != d->nodeState){
 		switch( newState ){
 			case Initialisation:
@@ -123,8 +127,17 @@
 				switchCommunicationState(d, &newCommunicationState);
 				if (!(*(d->iam_a_slave)))
 				{
-					UNS32 res;
-					res = decompo_dcf(d,0x01);
+					ptrTable =(*d->scanIndexOD)(wIndex, &errorCode, &Callback);
+  					
+  					if (errorCode != OD_SUCCESSFUL)
+  						{
+  							(*d->preOperational)();
+  						}
+					else
+						{
+							UNS32 res;
+							res = decompo_dcf(d,0x01);
+						}				
 				}
 				else 
 				{