ethercatprint.c
Go to the documentation of this file.
00001 /*
00002  * Simple Open EtherCAT Master Library 
00003  *
00004  * File    : ethercatprint.c
00005  * Version : 1.2.5
00006  * Date    : 09-04-2011
00007  * Copyright (C) 2005-2011 Speciaal Machinefabriek Ketels v.o.f.
00008  * Copyright (C) 2005-2011 Arthur Ketels
00009  * Copyright (C) 2008-2009 TU/e Technische Universiteit Eindhoven 
00010  *
00011  * SOEM is free software; you can redistribute it and/or modify it under
00012  * the terms of the GNU General Public License version 2 as published by the Free
00013  * Software Foundation.
00014  *
00015  * SOEM is distributed in the hope that it will be useful, but WITHOUT ANY
00016  * WARRANTY; without even the implied warranty of MERCHANTABILITY or
00017  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00018  * for more details.
00019  *
00020  * As a special exception, if other files instantiate templates or use macros
00021  * or inline functions from this file, or you compile this file and link it
00022  * with other works to produce a work based on this file, this file does not
00023  * by itself cause the resulting work to be covered by the GNU General Public
00024  * License. However the source code for this file must still be made available
00025  * in accordance with section (3) of the GNU General Public License.
00026  *
00027  * This exception does not invalidate any other reasons why a work based on
00028  * this file might be covered by the GNU General Public License.
00029  *
00030  * The EtherCAT Technology, the trade name and logo “EtherCAT” are the intellectual
00031  * property of, and protected by Beckhoff Automation GmbH. You can use SOEM for
00032  * the sole purpose of creating, using and/or selling or otherwise distributing
00033  * an EtherCAT network master provided that an EtherCAT Master License is obtained
00034  * from Beckhoff Automation GmbH.
00035  *
00036  * In case you did not receive a copy of the EtherCAT Master License along with
00037  * SOEM write to Beckhoff Automation GmbH, Eiserstraße 5, D-33415 Verl, Germany
00038  * (www.beckhoff.com).
00039  */
00040 
00050 #include <stdio.h>
00051 #include <youbot_driver/soem/ethercattype.h>
00052 #include <youbot_driver/soem/ethercatmain.h>
00053 
00054 #define EC_MAXERRORNAME 127
00055 
00057 typedef const struct
00058 {
00060   uint32 errorcode;
00062   char errordescription[EC_MAXERRORNAME + 1];
00063 } ec_sdoerrorlist_t;
00064 
00066 typedef const struct
00067 {
00069   uint16 ALstatuscode;
00071   char ALstatuscodedescription[EC_MAXERRORNAME + 1];
00072 } ec_ALstatuscodelist_t;
00073 
00075 typedef const struct
00076 {
00078   uint16 errorcode;
00080   char errordescription[EC_MAXERRORNAME + 1];
00081 } ec_soeerrorlist_t;
00082 
00083 char estring[EC_MAXERRORNAME];
00084 
00086 const ec_sdoerrorlist_t ec_sdoerrorlist[] = {
00087     {0x00000000, "No error"}, {0x05030000, "Toggle bit not changed"}, {0x05040000, "SDO protocol timeout"}, {
00088         0x05040001, "Client/Server command specifier not valid or unknown"},
00089     {0x05040005, "Out of memory"}, {0x06010000, "Unsupported access to an object"}, {
00090         0x06010001, "Attempt to read to a write only object"},
00091     {0x06010002, "Attempt to write to a read only object"}, {0x06020000,
00092                                                              "The object does not exist in the object directory"},
00093     {0x06040041, "The object can not be mapped into the PDO"}, {
00094         0x06040042, "The number and length of the objects to be mapped would exceed the PDO length"},
00095     {0x06040043, "General parameter incompatibility reason"}, {0x06040047,
00096                                                                "General internal incompatibility in the device"},
00097     {0x06060000, "Access failed due to a hardware error"}, {
00098         0x06070010, "Data type does not match, length of service parameter does not match"},
00099     {0x06070012, "Data type does not match, length of service parameter too high"}, {
00100         0x06070013, "Data type does not match, length of service parameter too low"},
00101     {0x06090011, "Subindex does not exist"}, {0x06090030, "Value range of parameter exceeded (only for write access)"},
00102     {0x06090031, "Value of parameter written too high"}, {0x06090032, "Value of parameter written too low"}, {
00103         0x06090036, "Maximum value is less than minimum value"},
00104     {0x08000000, "General error"}, {0x08000020, "Data cannot be transferred or stored to the application"}, {
00105         0x08000021, "Data cannot be transferred or stored to the application because of local control"},
00106     {0x08000022, "Data cannot be transferred or stored to the application because of the present device state"}, {
00107         0x08000023, "Object dictionary dynamic generation fails or no object dictionary is present"},
00108     {0xffffffff, "Unknown"}};
00109 
00111 const ec_ALstatuscodelist_t ec_ALstatuscodelist[] = { {0x0000, "No error"}, {0x0001, "Unspecified error"}, {
00112     0x0011, "Invalid requested state change"},
00113                                                      {0x0012, "Unknown requested state"}, {0x0013,
00114                                                                                            "Bootstrap not supported"},
00115                                                      {0x0014, "No valid firmware"}, {0x0015,
00116                                                                                      "Invalid mailbox configuration"},
00117                                                      {0x0016, "Invalid mailbox configuration"}, {
00118                                                          0x0017, "Invalid sync manager configuration"},
00119                                                      {0x0018, "No valid inputs available"},
00120                                                      {0x0019, "No valid outputs"}, {0x001A, "Synchronization error"}, {
00121                                                          0x001B, "Sync manager watchdog"},
00122                                                      {0x001C, "Invalid Sync Manager Types"}, {
00123                                                          0x001D, "Invalid Output Configuration"},
00124                                                      {0x001E, "Invalid Input Configuration"}, {
00125                                                          0x001F, "Invalid Watchdog Configuration"},
00126                                                      {0x0020, "Slave needs cold start"}, {0x0021, "Slave needs INIT"}, {
00127                                                          0x0022, "Slave needs PREOP"},
00128                                                      {0x0023, "Slave needs SAFEOP"}, {
00129                                                          0x002D, "Invalid Output FMMU Configuration"},
00130                                                      {0x002E, "Invalid Input FMMU Configuration"}, {
00131                                                          0x0030, "Invalid DC SYNCH Configuration"},
00132                                                      {0x0031, "Invalid DC Latch Configuration"}, {0x0032, "PLL Error"},
00133                                                      {0x0033, "Invalid DC IO Error"}, {0x0034,
00134                                                                                        "Invalid DC Timeout Error"},
00135                                                      {0x0042, "MBX_EOE"}, {0x0043, "MBX_COE"}, {0x0044, "MBX_FOE"}, {
00136                                                          0x0045, "MBX_SOE"},
00137                                                      {0x004F, "MBX_VOE"}, {0xffff, "Unknown"}};
00138 
00140 const ec_soeerrorlist_t ec_soeerrorlist[] = { {0x0000, "No error"}, {0x1001, "No IDN"}, {0x1009,
00141                                                                                          "Invalid access to element 1"},
00142                                              {0x2001, "No Name"}, {0x2002, "Name transmission too short"}, {
00143                                                  0x2003, "Name transmission too long"},
00144                                              {0x2004, "Name cannot be changed (read only)"}, {
00145                                                  0x2005, "Name is write-protected at this time"},
00146                                              {0x3002, "Attribute transmission too short"}, {
00147                                                  0x3003, "Attribute transmission too long"},
00148                                              {0x3004, "Attribute cannot be changed (read only)"}, {
00149                                                  0x3005, "Attribute is write-protected at this time"},
00150                                              {0x4001, "No units"}, {0x4002, "Unit transmission too short"}, {
00151                                                  0x4003, "Unit transmission too long"},
00152                                              {0x4004, "Unit cannot be changed (read only)"}, {
00153                                                  0x4005, "Unit is write-protected at this time"},
00154                                              {0x5001, "No minimum input value"}, {
00155                                                  0x5002, "Minimum input value transmission too short"},
00156                                              {0x5003, "Minimum input value transmission too long"}, {
00157                                                  0x5004, "Minimum input value cannot be changed (read only)"},
00158                                              {0x5005, "Minimum input value is write-protected at this time"}, {
00159                                                  0x6001, "No maximum input value"},
00160                                              {0x6002, "Maximum input value transmission too short"}, {
00161                                                  0x6003, "Maximum input value transmission too long"},
00162                                              {0x6004, "Maximum input value cannot be changed (read only)"}, {
00163                                                  0x6005, "Maximum input value is write-protected at this time"},
00164                                              {0x7002, "Operation data transmission too short"}, {
00165                                                  0x7003, "Operation data transmission too long"},
00166                                              {0x7004, "Operation data cannot be changed (read only)"}, {
00167                                                  0x7005, "Operation data is write-protected at this time (state)"},
00168                                              {0x7006, "Operation data is smaller than the minimum input value"}, {
00169                                                  0x7007, "Operation data is smaller than the maximum input value"},
00170                                              {0x7008, "Invalid operation data:Configured IDN will not be supported"}, {
00171                                                  0x7009, "Operation data write protected by a password"},
00172                                              {0x700A, "Operation data is write protected, it is configured cyclically"},
00173                                              {0x700B,
00174                                               "Invalid indirect addressing: (e.g., data container, list handling)"},
00175                                              {0x700C, "Operation data is write protected, due to other settings"}, {
00176                                                  0x700D, "Reserved"},
00177                                              {0x7010, "Procedure command already active"}, {
00178                                                  0x7011, "Procedure command not interruptible"},
00179                                              {0x7012, "Procedure command at this time not executable (state)"}, {
00180                                                  0x7013,
00181                                                  "Procedure command not executable (invalid or false parameters)"},
00182                                              {0x7014, "No data state"}, {0x8001, "No default value"}, {
00183                                                  0x8002, "Default value transmission too long"},
00184                                              {0x8004, "Default value cannot be changed, read only"}, {
00185                                                  0x800A, "Invalid drive number"},
00186                                              {0x800A, "General error"}, {0x800A, "No element addressed"}, {0xffff,
00187                                                                                                            "Unknown"}};
00188 
00194 char* ec_sdoerror2string(uint32 sdoerrorcode)
00195 {
00196   int i = 0;
00197 
00198   do
00199   {
00200     i++;
00201   } while ((ec_sdoerrorlist[i].errorcode != 0xfffffffful) && (ec_sdoerrorlist[i].errorcode != sdoerrorcode));
00202 
00203   return (char*)ec_sdoerrorlist[i].errordescription;
00204 }
00205 
00211 char* ec_ALstatuscode2string(uint16 ALstatuscode)
00212 {
00213   int i = 0;
00214 
00215   do
00216   {
00217     i++;
00218   } while ((ec_ALstatuscodelist[i].ALstatuscode != 0xffff) && (ec_ALstatuscodelist[i].ALstatuscode != ALstatuscode));
00219 
00220   return (char *)ec_ALstatuscodelist[i].ALstatuscodedescription;
00221 }
00222 
00228 char* ec_soeerror2string(uint16 errorcode)
00229 {
00230   int i = 0;
00231 
00232   do
00233   {
00234     i++;
00235   } while ((ec_soeerrorlist[i].errorcode != 0xffff) && (ec_soeerrorlist[i].errorcode != errorcode));
00236 
00237   return (char *)ec_soeerrorlist[i].errordescription;
00238 }
00239 
00244 char* ec_elist2string(void)
00245 {
00246   ec_errort Ec;
00247   char timestr[20];
00248 
00249   if (ec_poperror(&Ec))
00250   {
00251     sprintf(timestr, "Time:%12.3f", Ec.Time.tv_sec + (Ec.Time.tv_usec / 1000000.0));
00252     switch (Ec.Etype)
00253     {
00254       case EC_ERR_TYPE_SDO_ERROR:
00255         sprintf(estring, "%s SDO slave:%d index:%4.4x.%2.2x error:%8.8x %s\n", timestr, Ec.Slave, Ec.Index, Ec.SubIdx,
00256                 Ec.AbortCode, ec_sdoerror2string(Ec.AbortCode));
00257         break;
00258       case EC_ERR_TYPE_EMERGENCY:
00259         sprintf(estring, "%s EMERGENCY slave:%d error:%4.4x\n", timestr, Ec.Slave, Ec.ErrorCode);
00260         break;
00261       case EC_ERR_TYPE_PACKET_ERROR:
00262         sprintf(estring, "%s PACKET slave:%d index:%4.4x.%2.2x error:%d\n", timestr, Ec.Slave, Ec.Index, Ec.SubIdx,
00263                 Ec.ErrorCode);
00264         break;
00265       case EC_ERR_TYPE_SDOINFO_ERROR:
00266         sprintf(estring, "%s SDO slave:%d index:%4.4x.%2.2x error:%8.8x %s\n", timestr, Ec.Slave, Ec.Index, Ec.SubIdx,
00267                 Ec.AbortCode, ec_sdoerror2string(Ec.AbortCode));
00268         break;
00269       case EC_ERR_TYPE_SOE_ERROR:
00270         sprintf(estring, "%s SoE slave:%d IDN:%4.4x error:%4.4x %s\n", timestr, Ec.Slave, Ec.Index, Ec.AbortCode,
00271                 ec_soeerror2string(Ec.ErrorCode));
00272         break;
00273       default:
00274         sprintf(estring, "%s error:%8.8x\n", timestr, Ec.AbortCode);
00275     }
00276     return (char*)estring;
00277   }
00278   else
00279     return "";
00280 }


youbot_driver
Author(s): Jan Paulus
autogenerated on Mon Oct 6 2014 09:08:01