Implemented retry on SDO timeout in dcf.c.
authoretisserant
Fri, 06 Jun 2008 22:18:13 +0200
changeset 478 4306e851d95c
parent 477 ec7654f71964
child 479 92891f53630b
Implemented retry on SDO timeout in dcf.c.
src/dcf.c
--- a/src/dcf.c	Thu Jun 05 09:09:56 2008 +0200
+++ b/src/dcf.c	Fri Jun 06 22:18:13 2008 +0200
@@ -43,6 +43,12 @@
 
 static void send_consise_dcf_loop(CO_Data* d,UNS8 nodeId);
 
+/* Seek to next NodeID's DCF */
+#define SEEK_NEXT_DCF() \
+   	nodeId=(nodeId+1) % d->dcf_odentry->bSubCount; \
+   	if(nodeId==0) nodeId=1; \
+   	d->dcf_cursor = NULL;
+
 /**
 **
 **
@@ -51,7 +57,7 @@
 */
 static void CheckSDOAndContinue(CO_Data* d, UNS8 nodeId)
 {
-  UNS32 abortCode;
+  UNS32 abortCode = 0;
 
   if(getWriteResultNetworkDict (d, nodeId, &abortCode) != SDO_FINISHED)
     {
@@ -60,6 +66,13 @@
     }
 
   closeSDOtransfer(d, nodeId, SDO_CLIENT);
+  /* Timedout ? */
+  if(abortCode == SDOABT_TIMED_OUT){
+    /* Node may not be ready, try another one */
+    /* Warning, this might leed to endless attempts */
+    /* if node does never answer */
+	SEEK_NEXT_DCF()
+  }
   send_consise_dcf_loop(d,nodeId);
 }
 
@@ -182,11 +195,7 @@
       	}
  	}
  	
-   	/* Check the next element*/
-   	nodeId=(nodeId+1) % d->dcf_odentry->bSubCount;
-   	if(nodeId==0)nodeId=1;
-   	d->dcf_cursor = NULL;
-
+	SEEK_NEXT_DCF()
   }
 
 }