Only warn (and do not abort) if Pdo assignment/mapping configuration
authorFlorian Pose <fp@igh-essen.com>
Thu, 31 Jul 2008 09:30:38 +0000
changeset 1173 2ec9651a6c89
parent 1172 74ee632c3b5e
child 1174 235f34ca50e2
Only warn (and do not abort) if Pdo assignment/mapping configuration
fails, or is impossible.
TODO
master/fsm_pdo_assign.c
master/fsm_pdo_mapping.c
master/fsm_slave_config.c
--- a/TODO	Wed Jul 30 15:31:01 2008 +0000
+++ b/TODO	Thu Jul 31 09:30:38 2008 +0000
@@ -13,6 +13,7 @@
 * Update documentation.
 * Get original driver for r8169.
 * Race in jiffies frame timeout?
+* Error at no sync manager for configuration.
 
 Future issues:
 
--- a/master/fsm_pdo_assign.c	Wed Jul 30 15:31:01 2008 +0000
+++ b/master/fsm_pdo_assign.c	Thu Jul 31 09:30:38 2008 +0000
@@ -171,8 +171,8 @@
         
         if (!(fsm->sync = ec_slave_get_sync(fsm->slave, fsm->sync_index))) {
             if (!list_empty(&fsm->pdos->list)) {
-                EC_ERR("Slave %u does not provide a configuration for sync "
-                        "manager %u!\n", fsm->slave->ring_position,
+                EC_WARN("Slave %u does not provide a configuration "
+                        "for SM%u!\n", fsm->slave->ring_position,
                         fsm->sync_index);
                 fsm->state = ec_fsm_pdo_assign_state_error;
                 return;
@@ -185,8 +185,7 @@
             continue;
 
         if (fsm->slave->master->debug_level) {
-            EC_DBG("Pdo assignment of SM%u differs in slave %u:\n",
-                    fsm->sync_index, fsm->slave->ring_position);
+            EC_DBG("Pdo assignment of SM%u differs:\n", fsm->sync_index);
             EC_DBG("Currently assigned Pdos: ");
             ec_pdo_list_print(&fsm->sync->pdos);
             printk("\n");
@@ -199,7 +198,7 @@
         if (!(fsm->slave->sii.mailbox_protocols & EC_MBOX_COE)
                 || (fsm->slave->sii.has_general
                     && !fsm->slave->sii.coe_details.enable_pdo_assign)) {
-            EC_ERR("Slave %u does not support assigning Pdos!\n",
+            EC_WARN("Slave %u does not support assigning Pdos!\n",
                     fsm->slave->ring_position);
             fsm->state = ec_fsm_pdo_assign_state_error;
             return;
@@ -207,11 +206,6 @@
 
         fsm->num_configured_syncs++;
 
-        if (fsm->slave->master->debug_level) {
-            EC_DBG("Changing Pdo assignment for SM%u of slave %u.\n",
-                    fsm->sync_index, fsm->slave->ring_position);
-        }
-
         if (ec_sdo_request_alloc(&fsm->request, 2)) {
             fsm->state = ec_fsm_pdo_assign_state_error;
             return;
@@ -222,8 +216,9 @@
         fsm->request.data_size = 1;
         ec_sdo_request_address(&fsm->request, 0x1C10 + fsm->sync_index, 0);
         ecrt_sdo_request_write(&fsm->request);
+
         if (fsm->slave->master->debug_level)
-            EC_DBG("Setting Pdo count to zero for SM%u.\n", fsm->sync_index);
+            EC_DBG("Setting Pdo count to zero.\n");
 
         fsm->state = ec_fsm_pdo_assign_state_zero_count;
         ec_fsm_coe_transfer(fsm->fsm_coe, fsm->slave, &fsm->request);
@@ -232,8 +227,7 @@
     }
 
     if (fsm->slave->master->debug_level && !fsm->num_configured_syncs)
-        EC_DBG("Pdo assignments of slave %u are already configured"
-                " correctly.\n", fsm->slave->ring_position);
+        EC_DBG("Pdo assignments are already configured correctly.\n");
     fsm->state = ec_fsm_pdo_assign_state_end;
 }
 
@@ -265,6 +259,7 @@
     ec_sdo_request_address(&fsm->request,
             0x1C10 + fsm->sync_index, fsm->pdo_count);
     ecrt_sdo_request_write(&fsm->request);
+
     if (fsm->slave->master->debug_level)
         EC_DBG("Assigning Pdo 0x%04X at position %u.\n",
                 fsm->pdo->index, fsm->pdo_count);
@@ -285,8 +280,7 @@
     if (ec_fsm_coe_exec(fsm->fsm_coe)) return;
 
     if (!ec_fsm_coe_success(fsm->fsm_coe)) {
-        EC_ERR("Failed to clear Pdo assignment of slave %u.\n",
-                fsm->slave->ring_position);
+        EC_WARN("Failed to clear Pdo assignment of SM%u.\n", fsm->sync_index);
         fsm->state = ec_fsm_pdo_assign_state_error;
         return;
     }
@@ -296,8 +290,7 @@
     // find first Pdo
     if (!(fsm->pdo = ec_fsm_pdo_assign_next_pdo(fsm, &fsm->pdos->list))) {
         if (fsm->slave->master->debug_level)
-            EC_DBG("No Pdos to assign for SM%u of slave %u.\n",
-                    fsm->sync_index, fsm->slave->ring_position);
+            EC_DBG("No Pdos to assign.\n");
         ec_fsm_pdo_assign_next_sync(fsm);
         return;
     }
@@ -318,8 +311,8 @@
     if (ec_fsm_coe_exec(fsm->fsm_coe)) return;
 
     if (!ec_fsm_coe_success(fsm->fsm_coe)) {
-        EC_ERR("Failed to map Pdo 0x%04X for SM%u of slave %u.\n",
-                fsm->pdo->index, fsm->sync_index, fsm->slave->ring_position);
+        EC_WARN("Failed to assign Pdo 0x%04X to position %u in SM%u.\n",
+                fsm->pdo->index, fsm->pdo_count, fsm->sync_index);
         fsm->state = ec_fsm_pdo_assign_state_error;
         return;
     }
@@ -331,6 +324,7 @@
         fsm->request.data_size = 1;
         ec_sdo_request_address(&fsm->request, 0x1C10 + fsm->sync_index, 0);
         ecrt_sdo_request_write(&fsm->request);
+
         if (fsm->slave->master->debug_level)
             EC_DBG("Setting number of assigned Pdos to %u.\n",
                     fsm->pdo_count);
@@ -357,15 +351,14 @@
     if (ec_fsm_coe_exec(fsm->fsm_coe)) return;
 
     if (!ec_fsm_coe_success(fsm->fsm_coe)) {
-        EC_ERR("Failed to set number of assigned Pdos for slave %u.\n",
-                fsm->slave->ring_position);
+        EC_WARN("Failed to set number of assigned Pdos for SM%u.\n",
+                fsm->sync_index);
         fsm->state = ec_fsm_pdo_assign_state_error;
         return;
     }
 
     if (fsm->slave->master->debug_level)
-        EC_DBG("Successfully configured Pdo assignment for SM%u of"
-                " slave %u.\n", fsm->sync_index, fsm->slave->ring_position);
+        EC_DBG("Pdo assignment successful for SM%u.\n", fsm->sync_index);
 
     // assignment for this sync manager finished
     ec_fsm_pdo_assign_next_sync(fsm);
--- a/master/fsm_pdo_mapping.c	Wed Jul 30 15:31:01 2008 +0000
+++ b/master/fsm_pdo_mapping.c	Thu Jul 31 09:30:38 2008 +0000
@@ -186,8 +186,7 @@
 
     if (!fsm->pdo) {
         if (fsm->slave->master->debug_level && !fsm->num_configured_pdos)
-            EC_DBG("Pdo mappings of slave %u are already configured"
-                    " correctly.\n", fsm->slave->ring_position);
+            EC_DBG("Pdo mappings are already configured correctly.\n");
         fsm->state = ec_fsm_pdo_mapping_state_end;
         return;
     }
@@ -196,15 +195,14 @@
     if (!(fsm->slave->sii.mailbox_protocols & EC_MBOX_COE)
             || (fsm->slave->sii.has_general
                 && !fsm->slave->sii.coe_details.enable_pdo_configuration)) {
-        EC_ERR("Slave %u does not support changing the Pdo mapping!\n",
+        EC_WARN("Slave %u does not support Pdo mapping configuration!\n",
                 fsm->slave->ring_position);
         fsm->state = ec_fsm_pdo_mapping_state_error;
         return;
     }
 
     if (fsm->slave->master->debug_level) {
-        EC_DBG("Changing mapping of Pdo 0x%04X of slave %u.\n",
-                fsm->pdo->index, fsm->slave->ring_position);
+        EC_DBG("Changing mapping of Pdo 0x%04X.\n", fsm->pdo->index);
     }
 
     if (ec_sdo_request_alloc(&fsm->request, 4)) {
@@ -218,8 +216,7 @@
     ec_sdo_request_address(&fsm->request, fsm->pdo->index, 0);
     ecrt_sdo_request_write(&fsm->request);
     if (fsm->slave->master->debug_level)
-        EC_DBG("Setting entry count to zero for Pdo 0x%04X.\n",
-                fsm->pdo->index);
+        EC_DBG("Setting entry count to zero.\n");
 
     fsm->state = ec_fsm_pdo_mapping_state_zero_count;
     ec_fsm_coe_transfer(fsm->fsm_coe, fsm->slave, &fsm->request);
@@ -279,8 +276,7 @@
     if (ec_fsm_coe_exec(fsm->fsm_coe)) return;
 
     if (!ec_fsm_coe_success(fsm->fsm_coe)) {
-        EC_ERR("Failed to clear Pdo mapping for slave %u.\n",
-                fsm->slave->ring_position);
+        EC_WARN("Failed to clear mapping of Pdo 0x%04X.\n", fsm->pdo->index);
         fsm->state = ec_fsm_pdo_mapping_state_error;
         return;
     }
@@ -289,8 +285,7 @@
     if (!(fsm->entry =
                 ec_fsm_pdo_mapping_next_entry(fsm, &fsm->pdo->entries))) {
         if (fsm->slave->master->debug_level)
-            EC_DBG("No entries to map for Pdo 0x%04X of slave %u.\n",
-                    fsm->pdo->index, fsm->slave->ring_position);
+            EC_DBG("No entries to map.\n");
         ec_fsm_pdo_mapping_next_pdo(fsm);
         return;
     }
@@ -311,9 +306,9 @@
     if (ec_fsm_coe_exec(fsm->fsm_coe)) return;
 
     if (!ec_fsm_coe_success(fsm->fsm_coe)) {
-        EC_ERR("Failed to add entry 0x%04X:%02X for slave %u.\n",
-                fsm->entry->index, fsm->entry->subindex,
-                fsm->slave->ring_position);
+        EC_WARN("Failed to map Pdo entry 0x%04X:%02X at 0x%04X:%02X.\n",
+                fsm->entry->index, fsm->entry->subindex, fsm->pdo->index,
+                fsm->entry_count);
         fsm->state = ec_fsm_pdo_mapping_state_error;
         return;
     }
@@ -325,9 +320,9 @@
         fsm->request.data_size = 1;
         ec_sdo_request_address(&fsm->request, fsm->pdo->index, 0);
         ecrt_sdo_request_write(&fsm->request);
+
         if (fsm->slave->master->debug_level)
-            EC_DBG("Setting number of Pdo entries to %u.\n",
-                    fsm->entry_count);
+            EC_DBG("Setting number of Pdo entries to %u.\n", fsm->entry_count);
         
         fsm->state = ec_fsm_pdo_mapping_state_entry_count;
         ec_fsm_coe_transfer(fsm->fsm_coe, fsm->slave, &fsm->request);
@@ -351,15 +346,14 @@
     if (ec_fsm_coe_exec(fsm->fsm_coe)) return;
 
     if (!ec_fsm_coe_success(fsm->fsm_coe)) {
-        EC_ERR("Failed to set number of entries for slave %u.\n",
-                fsm->slave->ring_position);
+        EC_WARN("Failed to set number of entries for Pdo 0x%04X.\n",
+                fsm->pdo->index);
         fsm->state = ec_fsm_pdo_mapping_state_error;
         return;
     }
 
     if (fsm->slave->master->debug_level)
-        EC_DBG("Successfully configured mapping for Pdo 0x%04X on slave %u.\n",
-                fsm->pdo->index, fsm->slave->ring_position);
+        EC_DBG("Pdo mapping configuration successful.\n");
 
     ec_fsm_pdo_mapping_next_pdo(fsm);
 }
--- a/master/fsm_slave_config.c	Wed Jul 30 15:31:01 2008 +0000
+++ b/master/fsm_slave_config.c	Thu Jul 31 09:30:38 2008 +0000
@@ -588,14 +588,11 @@
     if (ec_fsm_pdo_mapping_exec(&fsm->fsm_pdo_mapping)) return;
 
     if (!ec_fsm_pdo_mapping_success(&fsm->fsm_pdo_mapping)) {
-        EC_ERR("Configuration of Pdo mapping failed for slave %u.\n",
+        EC_WARN("Configuration of Pdo mappings failed on slave %u.\n",
                 fsm->slave->ring_position);
-        fsm->slave->error_flag = 1;
-        fsm->state = ec_fsm_slave_config_state_error;
-        return;
-    }
-
-    // start applying alternate Pdo assignments
+    }
+
+    // start applying Pdo assignments
     ec_fsm_pdo_assign_start(&fsm->fsm_pdo_assign, fsm->slave);
     fsm->state = ec_fsm_slave_config_state_pdo_assign;
     fsm->state(fsm); // execute immediately
@@ -612,11 +609,8 @@
     if (ec_fsm_pdo_assign_exec(&fsm->fsm_pdo_assign)) return;
 
     if (!ec_fsm_pdo_assign_success(&fsm->fsm_pdo_assign)) {
-        EC_ERR("Pdo assignment failed for slave %u.\n",
+        EC_WARN("Configuration of Pdo assignments failed on slave %u.\n",
                 fsm->slave->ring_position);
-        fsm->slave->error_flag = 1;
-        fsm->state = ec_fsm_slave_config_state_error;
-        return;
     }
 
     ec_fsm_slave_config_enter_fmmu(fsm);