Retry reading assigned pdos using timeout.
authorRichard Hacker <ha@igh-essen.com>
Wed, 18 Jun 2008 15:03:03 +0000
changeset 1034 36cd81362f10
parent 1033 b98259cc7d40
child 1035 7fafc1a7451e
Retry reading assigned pdos using timeout.
master/fsm_coe_map.c
master/fsm_coe_map.h
--- a/master/fsm_coe_map.c	Wed Jun 18 14:37:20 2008 +0000
+++ b/master/fsm_coe_map.c	Wed Jun 18 15:03:03 2008 +0000
@@ -44,6 +44,10 @@
 #include "sdo_request.h"
 #include "fsm_coe_map.h"
 
+/** Retry reading the number of assigned Pdos if this time is not elapsed.
+ */
+#define EC_FSM_COE_MAP_TIMEOUT 5
+
 /*****************************************************************************/
 
 void ec_fsm_coe_map_state_start(ec_fsm_coe_map_t *);
@@ -183,7 +187,7 @@
 
         ec_sdo_request_address(&fsm->request, fsm->sync_sdo_index, 0);
         ecrt_sdo_request_read(&fsm->request);
-        fsm->retries = 5;
+        fsm->jiffies_start = jiffies;
         fsm->state = ec_fsm_coe_map_state_pdo_count;
         ec_fsm_coe_transfer(fsm->fsm_coe, fsm->slave, &fsm->request);
         ec_fsm_coe_exec(fsm->fsm_coe); // execute immediately
@@ -210,7 +214,7 @@
     if (ec_fsm_coe_exec(fsm->fsm_coe)) return;
 
     if (!ec_fsm_coe_success(fsm->fsm_coe)) {
-        if (fsm->retries--) {
+        if (jiffies - fsm->jiffies_start < HZ * EC_FSM_COE_MAP_TIMEOUT) {
             if (fsm->slave->master->debug_level)
                 EC_DBG("Failed to read number of assigned Pdos from "
                         "slave %u. Retrying...\n", fsm->slave->ring_position);
--- a/master/fsm_coe_map.h	Wed Jun 18 14:37:20 2008 +0000
+++ b/master/fsm_coe_map.h	Wed Jun 18 15:03:03 2008 +0000
@@ -73,7 +73,7 @@
     uint8_t pdo_subindices; /**< Number of Pdo entries. */
     uint16_t pdo_subindex; /**< Current subindex in Pdo Sdo. */
 
-    unsigned int retries; /**< Retry count. */
+    unsigned long jiffies_start; /**< Timestamp. */
 };
 
 /*****************************************************************************/