Output attachment failure messages only when debugging.
authorFlorian Pose <fp@igh-essen.com>
Wed, 18 Jun 2008 11:16:30 +0000
changeset 1025 ae175095f09a
parent 1024 fef0b1953770
child 1026 021b8cdeb384
Output attachment failure messages only when debugging.
TODO
master/slave_config.c
--- a/TODO	Wed Jun 18 11:15:36 2008 +0000
+++ b/TODO	Wed Jun 18 11:16:30 2008 +0000
@@ -10,8 +10,6 @@
 
 * Remove get_cycles() calls and references to cpu_khz to increase
   portability.
-* Make ecrt_master_slave_config() return no error when slave is not present
-  or invalid.
 * Make scanning and configuration run parallel (each).
 * Adapt remaining examples.
 * READMEs for examples.
--- a/master/slave_config.c	Wed Jun 18 11:15:36 2008 +0000
+++ b/master/slave_config.c	Wed Jun 18 11:16:30 2008 +0000
@@ -174,37 +174,39 @@
 
     if (!(slave = ec_master_find_slave(
                     sc->master, sc->alias, sc->position))) {
-        EC_WARN("Failed to find slave for configuration %u:%u.\n",
-                sc->alias, sc->position);
+        if (sc->master->debug_level)
+            EC_DBG("Failed to find slave for configuration %u:%u.\n",
+                    sc->alias, sc->position);
         return -1;
     }
 
 	if (slave->config) {
-		EC_ERR("Failed to attach slave configuration %u:%u. Slave %u"
-				" already has a configuration!\n", sc->alias,
-				sc->position, slave->ring_position);
-		return -2;
-	}
-	if (slave->sii.vendor_id != sc->vendor_id
-			|| slave->sii.product_code != sc->product_code) {
-		EC_ERR("Slave %u has an invalid type (0x%08X/0x%08X) for"
-				" configuration %u:%u (0x%08X/0x%08X).\n",
-				slave->ring_position, slave->sii.vendor_id,
-				slave->sii.product_code, sc->alias, sc->position,
-				sc->vendor_id, sc->product_code);
-		return -3;
+        if (sc->master->debug_level)
+            EC_DBG("Failed to attach slave configuration %u:%u. Slave %u"
+                    " already has a configuration!\n", sc->alias,
+                    sc->position, slave->ring_position);
+        return -2;
+    }
+    if (slave->sii.vendor_id != sc->vendor_id
+            || slave->sii.product_code != sc->product_code) {
+        if (sc->master->debug_level)
+            EC_DBG("Slave %u has an invalid type (0x%08X/0x%08X) for"
+                    " configuration %u:%u (0x%08X/0x%08X).\n",
+                    slave->ring_position, slave->sii.vendor_id,
+                    slave->sii.product_code, sc->alias, sc->position,
+                    sc->vendor_id, sc->product_code);
+        return -3;
 	}
 
 	// attach slave
 	slave->config = sc;
 	sc->slave = slave;
+    ec_slave_request_state(slave, EC_SLAVE_STATE_OP);
 
     if (sc->master->debug_level)
         EC_DBG("Attached slave %u to config %u:%u.\n",
                 slave->ring_position, sc->alias, sc->position);
 
-    ec_slave_request_state(slave, EC_SLAVE_STATE_OP);
-
 	return 0;
 }
 
@@ -259,14 +261,16 @@
                 " config %u:%u.\n", pdo->index, sc->alias, sc->position);
 
     if (!sc->slave) {
-        EC_WARN("Failed to load default Pdo configuration for %u:%u:"
-                " Slave not found.\n", sc->alias, sc->position);
+        if (sc->master->debug_level)
+            EC_DBG("Failed to load default Pdo configuration for %u:%u:"
+                    " Slave not found.\n", sc->alias, sc->position);
         return;
     }
 
     if (!(sync = ec_slave_get_pdo_sync(sc->slave, pdo->dir))) {
-        EC_WARN("Slave %u does not provide a default Pdo"
-                " configuration!\n", sc->slave->ring_position);
+        if (sc->master->debug_level)
+            EC_DBG("Slave %u does not provide a default Pdo"
+                    " configuration!\n", sc->slave->ring_position);
         return;
     }