Retry reading Pdo assignment.
authorFlorian Pose <fp@igh-essen.com>
Wed, 18 Jun 2008 14:37:20 +0000
changeset 1033 b98259cc7d40
parent 1032 748c34ab66b6
child 1034 36cd81362f10
Retry reading Pdo assignment.
master/fsm_coe_map.c
master/fsm_coe_map.h
--- a/master/fsm_coe_map.c	Wed Jun 18 14:37:00 2008 +0000
+++ b/master/fsm_coe_map.c	Wed Jun 18 14:37:20 2008 +0000
@@ -183,6 +183,7 @@
 
         ec_sdo_request_address(&fsm->request, fsm->sync_sdo_index, 0);
         ecrt_sdo_request_read(&fsm->request);
+        fsm->retries = 5;
         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
@@ -209,6 +210,15 @@
     if (ec_fsm_coe_exec(fsm->fsm_coe)) return;
 
     if (!ec_fsm_coe_success(fsm->fsm_coe)) {
+        if (fsm->retries--) {
+            if (fsm->slave->master->debug_level)
+                EC_DBG("Failed to read number of assigned Pdos from "
+                        "slave %u. Retrying...\n", fsm->slave->ring_position);
+            ecrt_sdo_request_read(&fsm->request);
+            ec_fsm_coe_transfer(fsm->fsm_coe, fsm->slave, &fsm->request);
+            ec_fsm_coe_exec(fsm->fsm_coe); // execute immediately
+            return;
+        }
         EC_ERR("Failed to read number of assigned Pdos from slave %u.\n",
                 fsm->slave->ring_position);
         fsm->state = ec_fsm_coe_map_state_error;
--- a/master/fsm_coe_map.h	Wed Jun 18 14:37:00 2008 +0000
+++ b/master/fsm_coe_map.h	Wed Jun 18 14:37:20 2008 +0000
@@ -72,6 +72,8 @@
     ec_sdo_t *pdo_sdo; /**< Current Pdo Sdo. */
     uint8_t pdo_subindices; /**< Number of Pdo entries. */
     uint16_t pdo_subindex; /**< Current subindex in Pdo Sdo. */
+
+    unsigned int retries; /**< Retry count. */
 };
 
 /*****************************************************************************/