tool/SoeCommand.cpp
changeset 1877 7b77000f9764
parent 1868 489ea0becd74
child 1966 23c638a81fe7
--- a/tool/SoeCommand.cpp	Fri Mar 19 11:07:49 2010 +0100
+++ b/tool/SoeCommand.cpp	Fri Mar 19 12:01:32 2010 +0100
@@ -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();
+}
+
 /****************************************************************************/