tool/SoeCommand.cpp
changeset 1877 7b77000f9764
parent 1868 489ea0becd74
child 1966 23c638a81fe7
equal deleted inserted replaced
1876:0ebb802ac08d 1877:7b77000f9764
    29 
    29 
    30 #include <iomanip>
    30 #include <iomanip>
    31 using namespace std;
    31 using namespace std;
    32 
    32 
    33 #include "SoeCommand.h"
    33 #include "SoeCommand.h"
       
    34 
       
    35 extern const ec_code_msg_t soe_error_codes[];
    34 
    36 
    35 /*****************************************************************************/
    37 /*****************************************************************************/
    36 
    38 
    37 SoeCommand::SoeCommand(const string &name, const string &briefDesc):
    39 SoeCommand::SoeCommand(const string &name, const string &briefDesc):
    38     Command(name, briefDesc)
    40     Command(name, briefDesc)
   103     }
   105     }
   104 
   106 
   105     return idn;
   107     return idn;
   106 }
   108 }
   107 
   109 
       
   110 /*****************************************************************************/
       
   111 
       
   112 /** Outputs an SoE error code.
       
   113 */
       
   114 std::string SoeCommand::errorMsg(uint16_t code)
       
   115 {
       
   116     const ec_code_msg_t *error_msg;
       
   117 	stringstream str;
       
   118 
       
   119 	str << "0x" << hex << setfill('0') << setw(4) << code << ": ";
       
   120 
       
   121     for (error_msg = soe_error_codes; error_msg->code; error_msg++) {
       
   122         if (error_msg->code == code) {
       
   123 			str << error_msg->message;
       
   124 			return str.str();
       
   125         }
       
   126     }
       
   127 
       
   128 	str << "(Unknown)";
       
   129 	return str.str();
       
   130 }
       
   131 
   108 /****************************************************************************/
   132 /****************************************************************************/