Included list of common SoE error messages.
--- a/TODO Fri Mar 19 11:07:49 2010 +0100
+++ b/TODO Fri Mar 19 12:01:32 2010 +0100
@@ -41,7 +41,6 @@
- Implement 0xXXXX:YY format for specifying SDOs.
- Implement reading from stream for soe_write.
* recompile tool/CommandVersion.cpp if revision changes.
-* Include SoE error codes.
* Log SoE IDNs with real name ([SP]-x-yyyy).
* Output SoE IDN configurations in 'ethercat config'.
--- a/master/Kbuild.in Fri Mar 19 11:07:49 2010 +0100
+++ b/master/Kbuild.in Fri Mar 19 12:01:32 2010 +0100
@@ -62,6 +62,7 @@
sdo_request.o \
slave.o \
slave_config.o \
+ soe_errors.o \
soe_request.o \
sync.o \
sync_config.o \
--- a/master/Makefile.am Fri Mar 19 11:07:49 2010 +0100
+++ b/master/Makefile.am Fri Mar 19 12:01:32 2010 +0100
@@ -63,6 +63,7 @@
sdo_request.c sdo_request.h \
slave.c slave.h \
slave_config.c slave_config.h \
+ soe_errors.c \
soe_request.c soe_request.h \
sync.c sync.h \
sync_config.c sync_config.h \
--- a/master/fsm_soe.c Fri Mar 19 11:07:49 2010 +0100
+++ b/master/fsm_soe.c Fri Mar 19 12:01:32 2010 +0100
@@ -74,6 +74,29 @@
/*****************************************************************************/
+extern const ec_code_msg_t soe_error_codes[];
+
+/*****************************************************************************/
+
+/** Outputs an SoE error code.
+*/
+void ec_print_soe_error(uint16_t error_code)
+{
+ const ec_code_msg_t *error_msg;
+
+ for (error_msg = soe_error_codes; error_msg->code; error_msg++) {
+ if (error_msg->code == error_code) {
+ EC_ERR("SoE error 0x%04X: \"%s\".\n",
+ error_msg->code, error_msg->message);
+ return;
+ }
+ }
+
+ EC_ERR("Unknown SoE error 0x%04X.\n", error_code);
+}
+
+/*****************************************************************************/
+
/** Constructor.
*/
void ec_fsm_soe_init(
@@ -353,8 +376,8 @@
if (error_flag) {
req->error_code = EC_READ_U16(data + rec_size - 2);
- EC_ERR("Received error response: 0x%04x.\n",
- req->error_code);
+ EC_ERR("Received error response:\n");
+ ec_print_soe_error(req->error_code);
fsm->state = ec_fsm_soe_error;
return;
} else {
@@ -658,8 +681,8 @@
" but received size is %zu.\n", rec_size);
} else {
req->error_code = EC_READ_U16(data + EC_SOE_WRITE_RESPONSE_SIZE);
- EC_ERR("Received error response: 0x%04x.\n",
- req->error_code);
+ EC_ERR("Received error response:\n");
+ ec_print_soe_error(req->error_code);
}
ec_print_data(data, rec_size);
fsm->state = ec_fsm_soe_error;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/master/soe_errors.c Fri Mar 19 12:01:32 2010 +0100
@@ -0,0 +1,96 @@
+/******************************************************************************
+ *
+ * $Id$
+ *
+ * Copyright (C) 2006-2008 Florian Pose, Ingenieurgemeinschaft IgH
+ *
+ * This file is part of the IgH EtherCAT Master.
+ *
+ * The IgH EtherCAT Master is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version 2, as
+ * published by the Free Software Foundation.
+ *
+ * The IgH EtherCAT Master is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+ * Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with the IgH EtherCAT Master; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * ---
+ *
+ * The license mentioned above concerns the source code only. Using the
+ * EtherCAT technology and brand is only permitted in compliance with the
+ * industrial property and similar rights of Beckhoff Automation GmbH.
+ *
+ *****************************************************************************/
+
+/**
+ \file
+ EtherCAT SoE errors.
+*/
+
+/*****************************************************************************/
+
+#include "globals.h"
+
+/*****************************************************************************/
+
+/** SoE error codes.
+ */
+const ec_code_msg_t soe_error_codes[] = {
+ {0x1001, "No IDN"},
+ {0x1009, "Invalid access to element 1"},
+ {0x2001, "No name"},
+ {0x2002, "Name transmission too short"},
+ {0x2003, "Name transmission too long"},
+ {0x2004, "Name cannot be changed, read only"},
+ {0x2005, "Name is write protected at this time"},
+ {0x3002, "Attribute transmission too short"},
+ {0x3003, "Attribute transmission too long"},
+ {0x3004, "Attribute cannot be changed, read only"},
+ {0x3005, "Attribute is write protected at this time"},
+ {0x4001, "No unit"},
+ {0x4002, "Unit transmission too short"},
+ {0x4003, "Unit transmission too long"},
+ {0x4004, "Unit cannot be changed, read only"},
+ {0x4005, "Unit is write proteced at this time"},
+ {0x5001, "No minimum input value"},
+ {0x5002, "Minimum input value transmission too short"},
+ {0x5003, "Minimum input value transmission too long"},
+ {0x5004, "Minimum input value cannot be changed, read only"},
+ {0x5005, "Minimum input value is write protected at this time"},
+ {0x6001, "No maximum input value"},
+ {0x6002, "Maximum input value transmission too short"},
+ {0x6003, "Maximum input value transmission too long"},
+ {0x6004, "Maximum input value cannot be changed, read only"},
+ {0x6005, "Maximum input value is write protected at this time"},
+ {0x7002, "Operation data value transmission too short"},
+ {0x7003, "Operation data value transmission too long"},
+ {0x7004, "Operation data value cannot be changed, read only"},
+ {0x7005, "Operation data value is write protected at this time"},
+ {0x7006, "Operation data value is smaller than the minimum input value"},
+ {0x7007, "Operation data value is greater than the minimum input value"},
+ {0x7008, "Invalid operation data"},
+ {0x7009, "Operation data is write protected by a password"},
+ {0x700A, "Operation data is write protected"},
+ {0x700B, "Invalid indirect addressing"},
+ {0x700C, "Operation data is write protected due to other settings"},
+ {0x700D, "Reserved"},
+ {0x7010, "Procedure command already active"},
+ {0x7011, "Procedure command not interruptible"},
+ {0x7012, "Procedure command is at this time not executable"},
+ {0x7013, "Procedure command not executable"},
+ {0x7014, "No data state"},
+ {0x8001, "No default value"},
+ {0x8002, "Default value transmission too long"},
+ {0x8004, "Default value cannot be changed, read only"},
+ {0x800A, "Invalid drive number"},
+ {0x800B, "General error"},
+ {0x800C, "No element addressed"},
+ {}
+};
+
+/*****************************************************************************/
--- a/tool/CommandSoeRead.cpp Fri Mar 19 11:07:49 2010 +0100
+++ b/tool/CommandSoeRead.cpp Fri Mar 19 12:01:32 2010 +0100
@@ -28,7 +28,6 @@
****************************************************************************/
#include <iostream>
-#include <iomanip>
using namespace std;
#include "CommandSoeRead.h"
@@ -127,8 +126,7 @@
m.readSoe(&ioctl);
} catch (MasterDeviceSoeException &e) {
delete [] ioctl.data;
- err << "SoE read command aborted with code 0x"
- << setfill('0') << hex << setw(4) << e.errorCode;
+ err << "SoE read command failed with code " << errorMsg(e.errorCode);
throwCommandException(err);
} catch (MasterDeviceException &e) {
delete [] ioctl.data;
--- a/tool/CommandSoeWrite.cpp Fri Mar 19 11:07:49 2010 +0100
+++ b/tool/CommandSoeWrite.cpp Fri Mar 19 12:01:32 2010 +0100
@@ -28,7 +28,6 @@
****************************************************************************/
#include <iostream>
-#include <iomanip>
using namespace std;
#include "CommandSoeWrite.h"
@@ -148,8 +147,7 @@
m.writeSoe(&ioctl);
} catch (MasterDeviceSoeException &e) {
delete [] ioctl.data;
- err << "SoE write command aborted with code 0x"
- << setfill('0') << hex << setw(4) << e.errorCode << ".";
+ err << "SoE write command failed with code " << errorMsg(e.errorCode);
throwCommandException(err);
} catch (MasterDeviceException &e) {
delete [] ioctl.data;
--- a/tool/Makefile.am Fri Mar 19 11:07:49 2010 +0100
+++ b/tool/Makefile.am Fri Mar 19 12:01:32 2010 +0100
@@ -36,6 +36,7 @@
bin_PROGRAMS = ethercat
ethercat_SOURCES = \
+ ../master/soe_errors.c \
Command.cpp \
CommandAlias.cpp \
CommandCStruct.cpp \
--- 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();
+}
+
/****************************************************************************/
--- a/tool/SoeCommand.h Fri Mar 19 11:07:49 2010 +0100
+++ b/tool/SoeCommand.h Fri Mar 19 12:01:32 2010 +0100
@@ -25,6 +25,8 @@
* EtherCAT technology and brand is only permitted in compliance with the
* industrial property and similar rights of Beckhoff Automation GmbH.
*
+ * vim: expandtab
+ *
****************************************************************************/
#ifndef __SOECOMMAND_H__
@@ -44,6 +46,7 @@
protected:
static uint16_t parseIdn(const string &);
+ static std::string errorMsg(uint16_t);
};
/****************************************************************************/