Replaced self_configured flag with force_config flag.
authorFlorian Pose <fp@igh-essen.com>
Fri, 25 Apr 2008 14:32:56 +0000
changeset 908 386b908033be
parent 907 570ae1c64465
child 909 3b3087d4cdc5
Replaced self_configured flag with force_config flag.
TODO
master/fsm_master.c
master/fsm_slave_config.c
master/slave.c
master/slave.h
--- a/TODO	Fri Apr 25 14:07:38 2008 +0000
+++ b/TODO	Fri Apr 25 14:32:56 2008 +0000
@@ -8,8 +8,6 @@
 
 Version 1.4.0:
 
-* Remove self_configured flag to avoid unnecessary process data
-  interruptions.
 * Replace Sysfs interface with cdev and a user space program
   to replace lsec; move a few sysfs attributes to proc.
 * Implement realtime interface via cdev.
--- a/master/fsm_master.c	Fri Apr 25 14:07:38 2008 +0000
+++ b/master/fsm_master.c	Fri Apr 25 14:32:56 2008 +0000
@@ -261,6 +261,11 @@
                     return;
                 }
 
+                // do not force reconfiguration in operation mode to avoid
+                // unnecesssary process data interruptions
+                if (master->mode != EC_MASTER_MODE_OPERATION)
+                    slave->force_config = 1;
+
                 list_add_tail(&slave->list, &master->slaves);
             }
 
@@ -514,7 +519,7 @@
     // Does the slave have to be configured?
     if (!slave->error_flag
             && (slave->current_state != slave->requested_state
-                || !slave->self_configured)) {
+                || slave->force_config)) {
         // Start slave configuration, if it is allowed.
         down(&master->config_sem);
         if (!master->allow_config) {
@@ -524,19 +529,19 @@
             up(&master->config_sem);
 
             if (master->debug_level) {
-                char old_state[EC_STATE_STRING_SIZE];
+                char old_state[EC_STATE_STRING_SIZE],
+                     new_state[EC_STATE_STRING_SIZE];
                 ec_state_string(slave->current_state, old_state);
-                if (slave->current_state != slave->requested_state) {
-                    char new_state[EC_STATE_STRING_SIZE];
-                    ec_state_string(slave->requested_state, new_state);
-                    EC_DBG("Changing state of slave %u (%s -> %s).\n",
-                            slave->ring_position, old_state, new_state);
-                } else if (!slave->self_configured) {
-                    EC_DBG("Reconfiguring slave %u (%s).\n",
-                            slave->ring_position, old_state);
-                }
+                ec_state_string(slave->requested_state, new_state);
+                EC_DBG("Changing state of slave %u from %s to %s%s.\n",
+                        slave->ring_position, old_state, new_state,
+                        slave->force_config ? " (forced)" : "");
             }
 
+            // configuration will be done immediately; therefore reset the
+            // force flag
+            slave->force_config = 0;
+
             fsm->idle = 0;
             fsm->state = ec_fsm_master_state_configure_slave;
             ec_fsm_slave_config_start(&fsm->fsm_slave_config, slave);
--- a/master/fsm_slave_config.c	Fri Apr 25 14:07:38 2008 +0000
+++ b/master/fsm_slave_config.c	Fri Apr 25 14:32:56 2008 +0000
@@ -197,8 +197,6 @@
         return;
     }
 
-    slave->self_configured = 1;
-
     if (master->debug_level) {
         EC_DBG("Slave %i is now in INIT.\n", slave->ring_position);
     }
--- a/master/slave.c	Fri Apr 25 14:07:38 2008 +0000
+++ b/master/slave.c	Fri Apr 25 14:32:56 2008 +0000
@@ -118,8 +118,8 @@
     slave->config = NULL;
     slave->requested_state = EC_SLAVE_STATE_PREOP;
     slave->current_state = EC_SLAVE_STATE_UNKNOWN;
-    slave->self_configured = 0;
     slave->error_flag = 0;
+    slave->force_config = 0;
 
     slave->base_type = 0;
     slave->base_revision = 0;
--- a/master/slave.h	Fri Apr 25 14:07:38 2008 +0000
+++ b/master/slave.h	Fri Apr 25 14:32:56 2008 +0000
@@ -173,8 +173,8 @@
     ec_slave_config_t *config; /**< Current configuration. */
     ec_slave_state_t requested_state; /**< Requested application state. */
     ec_slave_state_t current_state; /**< Current application state. */
-    unsigned int self_configured; /**< Slave was configured by this master. */
     unsigned int error_flag; /**< Stop processing after an error. */
+    unsigned int force_config; /**< Force (re-)configuration. */
 
     // base data
     uint8_t base_type; /**< slave type */