Configure alternative PDO mapping only on slaves that have PDO sync
authorFlorian Pose <fp@igh-essen.com>
Fri, 16 Mar 2007 13:39:19 +0000
changeset 660 582a90a34303
parent 659 d7c5a958bad0
child 661 bc1de1362efb
Configure alternative PDO mapping only on slaves that have PDO sync
managers.
master/fsm_mapping.c
master/slave.c
--- a/master/fsm_mapping.c	Fri Mar 16 11:23:08 2007 +0000
+++ b/master/fsm_mapping.c	Fri Mar 16 13:39:19 2007 +0000
@@ -161,20 +161,23 @@
         ec_fsm_mapping_t *fsm /**< mapping state machine */
         )
 {
-    do {
+    while (1) {
         if (fsm->dir > EC_DIR_INPUT) {
-            // no more sync managers to configure mappings for
+            // no more directions to configure mappings for
             fsm->state = ec_fsm_mapping_state_end;
             return;
         }
 
         if (!(fsm->sync = ec_slave_get_pdo_sync(fsm->slave, fsm->dir))) {
-            fsm->state = ec_fsm_mapping_state_error;
-            return;
+            // no sync manager found for this direction
+            fsm->dir++;
+            continue;
         }
+
         fsm->dir++;
-    }
-    while (!fsm->sync->alt_mapping);
+        if (fsm->sync->alt_mapping)
+            break;
+    }
 
     if (fsm->slave->master->debug_level) {
         EC_DBG("Configuring PDO mapping for SM%u of slave %i.\n",
--- a/master/slave.c	Fri Mar 16 11:23:08 2007 +0000
+++ b/master/slave.c	Fri Mar 16 13:39:19 2007 +0000
@@ -1111,10 +1111,8 @@
     sync_index = (unsigned int) dir;
     if (slave->sii_mailbox_protocols) sync_index += 2;
 
-    if (sync_index >= slave->sii_sync_count) {
-        EC_ERR("No appropriate sync manager found.\n");
+    if (sync_index >= slave->sii_sync_count)
         return NULL;
-    }
 
     return &slave->sii_syncs[sync_index];
 }
@@ -1297,7 +1295,7 @@
     unsigned int not_found = 1;
 
     if (!(slave->sii_mailbox_protocols & EC_MBOX_COE)) {
-        EC_ERR("Slave %i does not support CoE!\n", slave->ring_position);
+        EC_ERR("Slave %u does not support CoE!\n", slave->ring_position);
         return -1;
     }
 
@@ -1310,7 +1308,7 @@
     }
 
     if (not_found) {
-        EC_ERR("Slave %i does not provide PDO %04X!\n",
+        EC_ERR("Slave %u does not provide PDO 0x%04X!\n",
                 slave->ring_position, pdo_index);
         return -1;
     }
@@ -1323,8 +1321,11 @@
     }
 
 
-    if (!(sync = ec_slave_get_pdo_sync(slave, dir)))
+    if (!(sync = ec_slave_get_pdo_sync(slave, dir))) {
+        EC_ERR("Failed to obtain sync manager for PDO mapping of slave %u!\n",
+                slave->ring_position);
         return -1;
+    }
 
     return ec_sync_add_pdo(sync, pdo);
 }