Set slave_states to 0x00 when no slaves are present.
authorFlorian Pose <fp@igh-essen.com>
Wed, 18 Jun 2008 09:27:04 +0000
changeset 1021 fa5cf205f4f0
parent 1020 9bf2ddf05e17
child 1022 8e49b519e6ba
Set slave_states to 0x00 when no slaves are present.
master/fsm_master.c
--- a/master/fsm_master.c	Wed Jun 18 09:26:46 2008 +0000
+++ b/master/fsm_master.c	Wed Jun 18 09:27:04 2008 +0000
@@ -202,12 +202,16 @@
         return;
     }
 
-    // slave states changed?
-    if (EC_READ_U8(datagram->data) != fsm->slave_states) {
-        char states[EC_STATE_STRING_SIZE];
-        fsm->slave_states = EC_READ_U8(datagram->data);
-        ec_state_string(fsm->slave_states, states);
-        EC_INFO("Slave states: %s.\n", states);
+    if (fsm->slaves_responding) {
+        uint8_t states = EC_READ_U8(datagram->data);
+        if (states != fsm->slave_states) { // slave states changed?
+            char state_str[EC_STATE_STRING_SIZE];
+            fsm->slave_states = states;
+            ec_state_string(fsm->slave_states, state_str);
+            EC_INFO("Slave states: %s.\n", state_str);
+        }
+    } else {
+        fsm->slave_states = 0x00;
     }
 
     if (fsm->topology_change_pending) {