Output state names instead of codes in change FSM.
authorFlorian Pose <fp@igh-essen.com>
Tue, 24 Oct 2006 08:41:39 +0000
changeset 438 64edce89fe9b
parent 437 ef80f2faa2c5
child 439 0f5a3d983908
Output state names instead of codes in change FSM.
master/fsm_change.c
--- a/master/fsm_change.c	Tue Oct 24 08:09:42 2006 +0000
+++ b/master/fsm_change.c	Tue Oct 24 08:41:39 2006 +0000
@@ -167,10 +167,11 @@
 
     if (datagram->working_counter != 1) {
         if (datagram->jiffies_received - fsm->jiffies_start >= 3 * HZ) {
+            char state_str[EC_STATE_STRING_SIZE];
+            ec_state_string(fsm->requested_state, state_str);
             fsm->state = ec_fsm_change_error;
-            EC_ERR("Failed to set state 0x%02X on slave %i: Slave did not"
-                   " respond.\n", fsm->requested_state,
-                   fsm->slave->ring_position);
+            EC_ERR("Failed to set state %s on slave %i: Slave did not"
+                   " respond.\n", state_str, fsm->slave->ring_position);
             return;
         }
 
@@ -223,9 +224,11 @@
 
     if (slave->current_state & EC_SLAVE_STATE_ACK_ERR) {
         // state change error
-        EC_ERR("Failed to set state 0x%02X - Slave %i refused state change"
-               " (code 0x%02X)!\n", fsm->requested_state, slave->ring_position,
-               slave->current_state);
+        char req_state[EC_STATE_STRING_SIZE], cur_state[EC_STATE_STRING_SIZE];
+        ec_state_string(fsm->requested_state, req_state);
+        ec_state_string(slave->current_state, cur_state);
+        EC_ERR("Failed to set %s state, slave %i refused state change (%s).\n",
+               req_state, slave->ring_position, cur_state);
         // fetch AL status error code
         ec_datagram_nprd(datagram, slave->station_address, 0x0134, 2);
         ec_master_queue_datagram(fsm->slave->master, datagram);
@@ -236,9 +239,11 @@
     if (datagram->jiffies_received
         - fsm->jiffies_start >= 100 * HZ / 1000) { // 100ms
         // timeout while checking
-        fsm->state = ec_fsm_change_error;
-        EC_ERR("Timeout while setting state 0x%02X on slave %i.\n",
-               fsm->requested_state, slave->ring_position);
+        char state_str[EC_STATE_STRING_SIZE];
+        ec_state_string(fsm->requested_state, state_str);
+        fsm->state = ec_fsm_change_error;
+        EC_ERR("Timeout while setting state %s on slave %i.\n",
+               state_str, slave->ring_position);
         return;
     }
 
@@ -376,19 +381,23 @@
     slave->current_state = EC_READ_U8(datagram->data);
 
     if (!(slave->current_state & EC_SLAVE_STATE_ACK_ERR)) {
-        fsm->state = ec_fsm_change_error;
-        EC_INFO("Acknowledged state 0x%02X on slave %i.\n",
-                slave->current_state, slave->ring_position);
+        char state_str[EC_STATE_STRING_SIZE];
+        ec_state_string(slave->current_state, state_str);
+        fsm->state = ec_fsm_change_error;
+        EC_INFO("Acknowledged state %s on slave %i.\n",
+                state_str, slave->ring_position);
         return;
     }
 
     if (datagram->jiffies_received
         - fsm->jiffies_start >= 100 * HZ / 1000) { // 100ms
+        char state_str[EC_STATE_STRING_SIZE];
+        ec_state_string(fsm->requested_state, state_str);
         // timeout while checking
         slave->current_state = EC_SLAVE_STATE_UNKNOWN;
         fsm->state = ec_fsm_change_error;
-        EC_ERR("Timeout while acknowledging state 0x%02X on slave %i.\n",
-               fsm->requested_state, slave->ring_position);
+        EC_ERR("Timeout while acknowledging state %s on slave %i.\n",
+               state_str, slave->ring_position);
         return;
     }