tool/SoeCommand.cpp
changeset 1980 a89e2bedf004
parent 1877 7b77000f9764
child 1966 23c638a81fe7
--- a/tool/SoeCommand.cpp	Fri Mar 19 13:27:08 2010 +0100
+++ b/tool/SoeCommand.cpp	Thu Apr 29 14:05:15 2010 +0200
@@ -32,6 +32,8 @@
 
 #include "SoeCommand.h"
 
+extern const ec_code_msg_t soe_error_codes[];
+
 /*****************************************************************************/
 
 SoeCommand::SoeCommand(const string &name, const string &briefDesc):
@@ -105,4 +107,26 @@
     return idn;
 }
 
+/*****************************************************************************/
+
+/** Outputs an SoE error code.
+*/
+std::string SoeCommand::errorMsg(uint16_t code)
+{
+    const ec_code_msg_t *error_msg;
+	stringstream str;
+
+	str << "0x" << hex << setfill('0') << setw(4) << code << ": ";
+
+    for (error_msg = soe_error_codes; error_msg->code; error_msg++) {
+        if (error_msg->code == code) {
+			str << error_msg->message;
+			return str.str();
+        }
+    }
+
+	str << "(Unknown)";
+	return str.str();
+}
+
 /****************************************************************************/