ethercatprint.c
Go to the documentation of this file.
00001 /*
00002  * Simple Open EtherCAT Master Library 
00003  *
00004  * File    : ethercatprint.c
00005  * Version : 1.3.0
00006  * Date    : 24-02-2013
00007  * Copyright (C) 2005-2013 Speciaal Machinefabriek Ketels v.o.f.
00008  * Copyright (C) 2005-2013 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 "ethercat_soem/oshw.h"
00052 #include "ethercat_soem/ethercattype.h"
00053 #include "ethercat_soem/ethercatmain.h"
00054 
00055 #define EC_MAXERRORNAME 127
00056 
00058 typedef struct
00059 {
00061    uint32        errorcode;
00063    char          errordescription[EC_MAXERRORNAME + 1];
00064 } ec_sdoerrorlist_t;
00065 
00067 typedef struct
00068 {
00070    uint16        ALstatuscode;
00072    char          ALstatuscodedescription[EC_MAXERRORNAME + 1];
00073 } ec_ALstatuscodelist_t;
00074 
00076 typedef struct
00077 {
00079    uint16        errorcode;
00081    char          errordescription[EC_MAXERRORNAME + 1];
00082 } ec_soeerrorlist_t;
00083 
00085 typedef struct
00086 {
00088    uint16              errorcode;
00090    char                errordescription[EC_MAXERRORNAME + 1];
00091 } ec_mbxerrorlist_t;
00092 
00093 char estring[EC_MAXERRORNAME];
00094 
00096 const ec_sdoerrorlist_t ec_sdoerrorlist[] = {
00097    {0x00000000, "No error" },
00098    {0x05030000, "Toggle bit not changed" },
00099    {0x05040000, "SDO protocol timeout" },
00100    {0x05040001, "Client/Server command specifier not valid or unknown" },
00101    {0x05040005, "Out of memory" },
00102    {0x06010000, "Unsupported access to an object" },
00103    {0x06010001, "Attempt to read to a write only object" },
00104    {0x06010002, "Attempt to write to a read only object" },
00105    {0x06010003, "Subindex can not be written, SI0 must be 0 for write access" },
00106    {0x06010004, "SDO Complete access not supported for variable length objects" },
00107    {0x06010005, "Object length exceeds mailbox size" },
00108    {0x06010006, "Object mapped to RxPDO, SDO download blocked" },
00109    {0x06020000, "The object does not exist in the object directory" },
00110    {0x06040041, "The object can not be mapped into the PDO" },
00111    {0x06040042, "The number and length of the objects to be mapped would exceed the PDO length" },
00112    {0x06040043, "General parameter incompatibility reason" },
00113    {0x06040047, "General internal incompatibility in the device" },
00114    {0x06060000, "Access failed due to a hardware error" },
00115    {0x06070010, "Data type does not match, length of service parameter does not match" },
00116    {0x06070012, "Data type does not match, length of service parameter too high" },
00117    {0x06070013, "Data type does not match, length of service parameter too low" },
00118    {0x06090011, "Subindex does not exist" },
00119    {0x06090030, "Value range of parameter exceeded (only for write access)" },
00120    {0x06090031, "Value of parameter written too high" },
00121    {0x06090032, "Value of parameter written too low" },
00122    {0x06090036, "Maximum value is less than minimum value" },
00123    {0x08000000, "General error" },
00124    {0x08000020, "Data cannot be transferred or stored to the application" },
00125    {0x08000021, "Data cannot be transferred or stored to the application because of local control" },
00126    {0x08000022, "Data cannot be transferred or stored to the application because of the present device state" },
00127    {0x08000023, "Object dictionary dynamic generation fails or no object dictionary is present" },
00128    {0xffffffff, "Unknown" }
00129 };
00130 
00132 const ec_ALstatuscodelist_t ec_ALstatuscodelist[] = {
00133    {0x0000 , "No error" },
00134    {0x0001 , "Unspecified error" },
00135    {0x0002 , "No memory" },
00136    {0x0011 , "Invalid requested state change" },
00137    {0x0012 , "Unknown requested state" },
00138    {0x0013 , "Bootstrap not supported" },
00139    {0x0014 , "No valid firmware" },
00140    {0x0015 , "Invalid mailbox configuration" },
00141    {0x0016 , "Invalid mailbox configuration" },
00142    {0x0017 , "Invalid sync manager configuration" },
00143    {0x0018 , "No valid inputs available" },
00144    {0x0019 , "No valid outputs" },
00145    {0x001A , "Synchronization error" },
00146    {0x001B , "Sync manager watchdog" },
00147    {0x001C , "Invalid sync Manager types" },
00148    {0x001D , "Invalid output configuration" },
00149    {0x001E , "Invalid input configuration" },
00150    {0x001F , "Invalid watchdog configuration" },
00151    {0x0020 , "Slave needs cold start" },
00152    {0x0021 , "Slave needs INIT" },
00153    {0x0022 , "Slave needs PREOP" },
00154    {0x0023 , "Slave needs SAFEOP" },
00155    {0x0024 , "Invalid input mapping" },
00156    {0x0025 , "Invalid output mapping" },
00157    {0x0026 , "Inconsistent settings" },
00158    {0x0027 , "Freerun not supported" },
00159    {0x0028 , "Synchronisation not supported" },
00160    {0x0029 , "Freerun needs 3buffer mode" },
00161    {0x002A , "Background watchdog" },
00162    {0x002B , "No valid Inputs and Outputs" },
00163    {0x002C , "Fatal sync error" },
00164    {0x002D , "No sync error" }, // was "Invalid Output FMMU Configuration"
00165    {0x002E , "Invalid input FMMU configuration" },
00166    {0x0030 , "Invalid DC SYNC configuration" },
00167    {0x0031 , "Invalid DC latch configuration" },
00168    {0x0032 , "PLL error" },
00169    {0x0033 , "DC sync IO error" },
00170    {0x0034 , "DC sync timeout error" },
00171    {0x0035 , "DC invalid sync cycle time" },
00172    {0x0035 , "DC invalid sync0 cycle time" },
00173    {0x0035 , "DC invalid sync1 cycle time" },
00174    {0x0042 , "MBX_EOE" },
00175    {0x0043 , "MBX_COE" },
00176    {0x0044 , "MBX_FOE" },
00177    {0x0045 , "MBX_SOE" },
00178    {0x004F , "MBX_VOE" },
00179    {0x0050 , "EEPROM no access" },
00180    {0x0051 , "EEPROM error" },
00181    {0x0060 , "Slave restarted locally" },
00182    {0x0061 , "Device identification value updated" },
00183    {0x00f0 , "Application controller available" },
00184    {0xffff , "Unknown" }
00185 };
00186 
00188 const ec_soeerrorlist_t ec_soeerrorlist[] = {
00189    {0x0000, "No error" },
00190    {0x1001, "No IDN" },
00191    {0x1009, "Invalid access to element 1" },
00192    {0x2001, "No Name" },
00193    {0x2002, "Name transmission too short" },
00194    {0x2003, "Name transmission too long" },
00195    {0x2004, "Name cannot be changed (read only)" },
00196    {0x2005, "Name is write-protected at this time" },
00197    {0x3002, "Attribute transmission too short" },
00198    {0x3003, "Attribute transmission too long" },
00199    {0x3004, "Attribute cannot be changed (read only)" },
00200    {0x3005, "Attribute is write-protected at this time" },
00201    {0x4001, "No units" },
00202    {0x4002, "Unit transmission too short" },
00203    {0x4003, "Unit transmission too long" },
00204    {0x4004, "Unit cannot be changed (read only)" },
00205    {0x4005, "Unit is write-protected at this time" },
00206    {0x5001, "No minimum input value" },
00207    {0x5002, "Minimum input value transmission too short" },
00208    {0x5003, "Minimum input value transmission too long" },
00209    {0x5004, "Minimum input value cannot be changed (read only)" },
00210    {0x5005, "Minimum input value is write-protected at this time" },
00211    {0x6001, "No maximum input value" },
00212    {0x6002, "Maximum input value transmission too short" },
00213    {0x6003, "Maximum input value transmission too long" },
00214    {0x6004, "Maximum input value cannot be changed (read only)" },
00215    {0x6005, "Maximum input value is write-protected at this time" },
00216    {0x7002, "Operation data transmission too short" },
00217    {0x7003, "Operation data transmission too long" },
00218    {0x7004, "Operation data cannot be changed (read only)" },
00219    {0x7005, "Operation data is write-protected at this time (state)" },
00220    {0x7006, "Operation data is smaller than the minimum input value" },
00221    {0x7007, "Operation data is smaller than the maximum input value" },
00222    {0x7008, "Invalid operation data:Configured IDN will not be supported" },
00223    {0x7009, "Operation data write protected by a password" },
00224    {0x700A, "Operation data is write protected, it is configured cyclically" },
00225    {0x700B, "Invalid indirect addressing: (e.g., data container, list handling)" },
00226    {0x700C, "Operation data is write protected, due to other settings" },
00227    {0x700D, "Reserved" },
00228    {0x7010, "Procedure command already active" },
00229    {0x7011, "Procedure command not interruptible" },
00230    {0x7012, "Procedure command at this time not executable (state)" },
00231    {0x7013, "Procedure command not executable (invalid or false parameters)" },
00232    {0x7014, "No data state" },
00233    {0x8001, "No default value" },
00234    {0x8002, "Default value transmission too long" },
00235    {0x8004, "Default value cannot be changed, read only" },
00236    {0x800A, "Invalid drive number" },
00237    {0x800A, "General error" },
00238    {0x800A, "No element addressed" },
00239    {0xffff, "Unknown" }
00240 };
00241    
00243 const ec_mbxerrorlist_t ec_mbxerrorlist[] = {
00244    {0x0000, "No error" },
00245    {0x0001, "Syntax of 6 octet Mailbox Header is wrong" },
00246    {0x0002, "The mailbox protocol is not supported" },
00247    {0x0003, "Channel Field contains wrong value"},
00248    {0x0004, "The service is no supported"},
00249    {0x0005, "Invalid mailbox header"},
00250    {0x0006, "Length of received mailbox data is too short"},
00251    {0x0007, "No more memory in slave"},
00252    {0x0008, "The lenght of data is inconsistent"},
00253    {0xffff, "Unknown"}
00254 };
00255 
00261 char* ec_sdoerror2string( uint32 sdoerrorcode)
00262 {
00263    int i = 0;
00264 
00265    while ( (ec_sdoerrorlist[i].errorcode != 0xfffffffful) && 
00266            (ec_sdoerrorlist[i].errorcode != sdoerrorcode) ) 
00267    {
00268       i++;
00269    }
00270    
00271    return (char*) ec_sdoerrorlist[i].errordescription;
00272 }
00273 
00279 char* ec_ALstatuscode2string( uint16 ALstatuscode)
00280 {
00281    int i = 0;
00282 
00283    while ( (ec_ALstatuscodelist[i].ALstatuscode != 0xffff) && 
00284            (ec_ALstatuscodelist[i].ALstatuscode != ALstatuscode) ) 
00285    {
00286       i++;
00287    }
00288    
00289    return (char *) ec_ALstatuscodelist[i].ALstatuscodedescription;
00290 }
00291 
00297 char* ec_soeerror2string( uint16 errorcode)
00298 {
00299    int i = 0;
00300 
00301    while ( (ec_soeerrorlist[i].errorcode != 0xffff) && 
00302            (ec_soeerrorlist[i].errorcode != errorcode) ) 
00303    {
00304       i++;
00305    }
00306    
00307    return (char *) ec_soeerrorlist[i].errordescription;
00308 }
00309 
00315 char* ec_mbxerror2string( uint16 errorcode)
00316 {
00317    int i = 0;
00318 
00319    while ( (ec_mbxerrorlist[i].errorcode != 0xffff) && 
00320            (ec_mbxerrorlist[i].errorcode != errorcode) ) 
00321    {
00322       i++;
00323    }
00324     
00325    return (char *) ec_mbxerrorlist[i].errordescription;
00326 }
00327 
00333 char* ecx_elist2string(ecx_contextt *context)
00334 {
00335    ec_errort Ec;
00336    char timestr[20];
00337    
00338    if (ecx_poperror(context, &Ec))
00339    {
00340       sprintf(timestr, "Time:%12.3f", Ec.Time.sec + (Ec.Time.usec / 1000000.0) );
00341       switch (Ec.Etype)
00342       {
00343          case EC_ERR_TYPE_SDO_ERROR:
00344          {
00345             sprintf(estring, "%s SDO slave:%d index:%4.4x.%2.2x error:%8.8x %s\n", 
00346                     timestr, Ec.Slave, Ec.Index, Ec.SubIdx, Ec.AbortCode, ec_sdoerror2string(Ec.AbortCode));            
00347             break;
00348          }
00349          case EC_ERR_TYPE_EMERGENCY:
00350          {   
00351             sprintf(estring, "%s EMERGENCY slave:%d error:%4.4x\n", 
00352                     timestr, Ec.Slave, Ec.ErrorCode);            
00353             break;
00354          }
00355          case EC_ERR_TYPE_PACKET_ERROR:
00356          {
00357             sprintf(estring, "%s PACKET slave:%d index:%4.4x.%2.2x error:%d\n", 
00358                     timestr, Ec.Slave, Ec.Index, Ec.SubIdx, Ec.ErrorCode);            
00359             break;
00360          }
00361          case EC_ERR_TYPE_SDOINFO_ERROR:
00362          {   
00363             sprintf(estring, "%s SDO slave:%d index:%4.4x.%2.2x error:%8.8x %s\n", 
00364                     timestr, Ec.Slave, Ec.Index, Ec.SubIdx, Ec.AbortCode, ec_sdoerror2string(Ec.AbortCode));            
00365             break;
00366          }
00367          case EC_ERR_TYPE_SOE_ERROR:
00368          {   
00369             sprintf(estring, "%s SoE slave:%d IDN:%4.4x error:%4.4x %s\n", 
00370                     timestr, Ec.Slave, Ec.Index, Ec.AbortCode, ec_soeerror2string(Ec.ErrorCode));            
00371             break;
00372          }
00373          case EC_ERR_TYPE_MBX_ERROR:
00374          {
00375             sprintf(estring, "%s MBX slave:%d error:%4.4x %s\n", 
00376                     timestr, Ec.Slave, Ec.ErrorCode, ec_mbxerror2string(Ec.ErrorCode));             
00377             break;
00378          }
00379          default:
00380          {
00381             sprintf(estring, "%s error:%8.8x\n", 
00382                     timestr, Ec.AbortCode);
00383          }
00384       }
00385       return (char*) estring;
00386    }
00387    else 
00388    {
00389       return "";
00390    }
00391 }
00392 
00393 #ifdef EC_VER1
00394 char* ec_elist2string(void)
00395 {
00396    return ecx_elist2string(&ecx_context);
00397 }
00398 #endif


ethercat_soem
Author(s): Arthur Ketels, M.J.G. van de Molengraft
autogenerated on Wed Aug 26 2015 11:32:40