From 5d862661639f78f4f90932e24e060186788e2e4d Mon Sep 17 00:00:00 2001 From: Florian Pose Date: Fri, 30 Apr 2010 21:34:18 +0200 Subject: [PATCH] Fixed AL state display in command-line tool. --- TODO | 1 - tool/Command.cpp | 22 +++++++++++++++------- tool/CommandConfig.cpp | 5 +---- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/TODO b/TODO index 041fbdfb..7d414c5f 100644 --- a/TODO +++ b/TODO @@ -42,7 +42,6 @@ Version 1.5.0: * 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: diff --git a/tool/Command.cpp b/tool/Command.cpp index 16db9141..12d35c68 100644 --- a/tool/Command.cpp +++ b/tool/Command.cpp @@ -371,14 +371,22 @@ Command::DomainList Command::selectedDomains(MasterDevice &m) 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; } /****************************************************************************/ diff --git a/tool/CommandConfig.cpp b/tool/CommandConfig.cpp index 4129db08..fdccdfbe 100644 --- a/tool/CommandConfig.cpp +++ b/tool/CommandConfig.cpp @@ -330,10 +330,7 @@ void CommandConfig::listConfigs( 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();