Reconfiguration of slaves, though they are in the correct state at startup.
authorFlorian Pose <fp@igh-essen.com>
Fri, 20 Oct 2006 10:48:30 +0000
changeset 421 2b3ce4f51bd6
parent 420 0ae52c37179b
child 422 439cd1650c36
Reconfiguration of slaves, though they are in the correct state at startup.
master/fsm.c
master/slave.c
master/slave.h
--- a/master/fsm.c	Fri Oct 20 10:05:52 2006 +0000
+++ b/master/fsm.c	Fri Oct 20 10:48:30 2006 +0000
@@ -571,15 +571,24 @@
 
     // check if any slaves are not in the state, they're supposed to be
     list_for_each_entry(slave, &master->slaves, list) {
-        if (slave->error_flag ||
-            !slave->online ||
-            slave->requested_state == EC_SLAVE_STATE_UNKNOWN ||
-            slave->current_state == slave->requested_state) continue;
-
-        ec_state_string(slave->current_state, old_state);
-        ec_state_string(slave->requested_state, new_state);
-        EC_INFO("Changing state of slave %i from %s to %s.\n",
-                slave->ring_position, old_state, new_state);
+        if (slave->error_flag
+            || !slave->online
+            || slave->requested_state == EC_SLAVE_STATE_UNKNOWN
+            || (slave->current_state == slave->requested_state
+                && (slave->configured
+                    || slave->current_state == EC_SLAVE_STATE_INIT))) continue;
+
+        if (!slave->configured
+            && slave->current_state != EC_SLAVE_STATE_INIT) {
+            EC_INFO("Reconfiguring slave %i.\n", slave->ring_position);
+        }
+
+        if (slave->current_state != slave->requested_state) {
+            ec_state_string(slave->current_state, old_state);
+            ec_state_string(slave->requested_state, new_state);
+            EC_INFO("Changing state of slave %i from %s to %s.\n",
+                    slave->ring_position, old_state, new_state);
+        }
 
         fsm->slave = slave;
         fsm->slave_state = ec_fsm_slaveconf_init;
@@ -1399,6 +1408,8 @@
 
     if (fsm->change_state != ec_fsm_end) return;
 
+    slave->configured = 1;
+
     if (master->debug_level) {
         EC_DBG("Slave %i is now in INIT.\n", slave->ring_position);
     }
--- a/master/slave.c	Fri Oct 20 10:05:52 2006 +0000
+++ b/master/slave.c	Fri Oct 20 10:48:30 2006 +0000
@@ -132,6 +132,7 @@
 
     slave->requested_state = EC_SLAVE_STATE_UNKNOWN;
     slave->current_state = EC_SLAVE_STATE_UNKNOWN;
+    slave->configured = 0;
     slave->error_flag = 0;
     slave->online = 1;
     slave->fmmu_count = 0;
--- a/master/slave.h	Fri Oct 20 10:05:52 2006 +0000
+++ b/master/slave.h	Fri Oct 20 10:48:30 2006 +0000
@@ -197,6 +197,7 @@
 
     ec_slave_state_t requested_state; /**< requested slave state */
     ec_slave_state_t current_state; /**< current slave state */
+    unsigned int configured; /**< the slave is configured by this master */
     unsigned int error_flag; /**< stop processing after an error */
     unsigned int online; /**< non-zero, if the slave responds. */
     uint8_t registered; /**< true, if slave has been registered */