Fixed AL state display in command-line tool.
authorFlorian Pose <fp@igh-essen.com>
Fri, 30 Apr 2010 21:34:18 +0200
changeset 1918 c58633eed20b
parent 1917 6129a5f715fb
child 1919 df2b21f15939
Fixed AL state display in command-line tool.
TODO
tool/Command.cpp
tool/CommandConfig.cpp
--- a/TODO	Fri Apr 30 15:08:09 2010 +0200
+++ b/TODO	Fri Apr 30 21:34:18 2010 +0200
@@ -42,7 +42,6 @@
 * recompile tool/CommandVersion.cpp if revision changes.
 * Log SoE IDNs with real name ([SP]-x-yyyy).
 * Output SoE IDN configurations in 'ethercat config'.
-* Output AL status error flag correctly in 'ethercat slaves'.
 * Fix casting away constness during expected WC calculation.
 
 Future issues:
--- a/tool/Command.cpp	Fri Apr 30 15:08:09 2010 +0200
+++ b/tool/Command.cpp	Fri Apr 30 21:34:18 2010 +0200
@@ -371,14 +371,22 @@
 
 string Command::alStateString(uint8_t state)
 {
-    switch (state) {
-        case 1: return "INIT";
-        case 2: return "PREOP";
-        case 3: return "BOOT";
-        case 4: return "SAFEOP";
-        case 8: return "OP";
-        default: return "???";
-    }
-}
-
-/****************************************************************************/
+    string ret;
+
+    switch (state & EC_SLAVE_STATE_MASK) {
+        case 1: ret = "INIT"; break;
+        case 2: ret = "PREOP"; break;
+        case 3: ret = "BOOT"; break;
+        case 4: ret = "SAFEOP"; break;
+        case 8: ret = "OP"; break;
+        default: ret = "???";
+    }
+
+    if (state & EC_SLAVE_STATE_ACK_ERR) { 
+        ret += "+ERROR";
+    }
+
+    return ret;
+}
+
+/****************************************************************************/
--- a/tool/CommandConfig.cpp	Fri Apr 30 15:08:09 2010 +0200
+++ b/tool/CommandConfig.cpp	Fri Apr 30 21:34:18 2010 +0200
@@ -330,10 +330,7 @@
             str.clear();
             str.str("");
 
-            str << alStateString(slave.al_state);
-            info.state = str.str();
-            str.clear();
-            str.str("");
+            info.state = alStateString(slave.al_state);
         } else {
             str << "-";
             info.slavePos = str.str();