tmr_strerror.c
Go to the documentation of this file.
00001 
00009 /*
00010  * Copyright (c) 2009 ThingMagic, Inc.
00011  *
00012  * Permission is hereby granted, free of charge, to any person obtaining a copy
00013  * of this software and associated documentation files (the "Software"), to deal
00014  * in the Software without restriction, including without limitation the rights
00015  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00016  * copies of the Software, and to permit persons to whom the Software is
00017  * furnished to do so, subject to the following conditions:
00018  *
00019  * The above copyright notice and this permission notice shall be included in
00020  * all copies or substantial portions of the Software.
00021  * 
00022  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00023  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00024  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00025  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00026  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00027  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
00028  * THE SOFTWARE.
00029  */
00030 
00031 #include <stdio.h>
00032 #include <string.h>
00033 
00034 #include "tm_reader.h"
00035 
00036 #if defined(TMR_ENABLE_ERROR_STRINGS)
00037 
00038 const char *
00039 TMR_strerror(TMR_Status status)
00040 {
00041   return TMR_strerr(NULL, status);
00042 }
00043 
00044 const char *
00045 TMR_strerr(TMR_Reader *reader, TMR_Status status)
00046 {
00047 
00048   if (TMR_ERROR_IS_COMM(status) && TMR_ERROR_COMM_IS_ERRNO(status))
00049   {
00050 #ifdef TMR_USE_STRERROR 
00051     return strerror(TMR_ERROR_COMM_GET_ERRNO(status));
00052 #else
00053     return "Error";
00054 #endif    
00055   }
00056 
00057 #ifdef TMR_ENABLE_LLRP_READER
00058   if (TMR_ERROR_IS_LLRP_SPECIFIC(status))
00059   {
00060     switch (status)
00061     {
00062       case TMR_ERROR_LLRP_MSG_PARSE_ERROR:
00063         return "Error parsing LLRP message";
00064       case TMR_ERROR_LLRP_ALREADY_CONNECTED:
00065         return "Already connected to reader";
00066       case TMR_ERROR_LLRP_INVALID_RFMODE:
00067         return "Specified RF Mode operation is not supported";
00068       case TMR_ERROR_LLRP_UNDEFINED_VALUE:
00069         return "Undefined Value";
00070       case TMR_ERROR_LLRP_READER_ERROR:
00071         return "LLRP reader unknown error";
00072       case TMR_ERROR_LLRP_READER_CONNECTION_LOST:
00073         return "LLRP reader connection lost";
00074       case TMR_ERROR_LLRP_GETTYPEREGISTRY:
00075         return "LLRP Reader GetTypeRegistry Failed";
00076       case TMR_ERROR_LLRP_CONNECTIONFAILED:
00077         return "LLRP Reader Connection attempt is failed";
00078       case TMR_ERROR_LLRP_SENDIO_ERROR:
00079         return "LLRP Reader Send Messages failed";
00080       case TMR_ERROR_LLRP_RECEIVEIO_ERROR:
00081         return "LLRP Reader Receive Messages failed";
00082       case TMR_ERROR_LLRP_RECEIVE_TIMEOUT:
00083         return "LLRP Reader Receive Messages Timeout";
00084       default:
00085         {
00086           if (NULL == reader)
00087             return "Unknown error: Reader reference lost";
00088           else
00089         return reader->u.llrpReader.errMsg;
00090     }
00091   }
00092   }
00093 #endif
00094 
00095   switch (status)
00096   {
00097   case TMR_ERROR_MSG_WRONG_NUMBER_OF_DATA:
00098     return "Message command length is incorrect";
00099   case TMR_ERROR_INVALID_OPCODE:
00100     return "Invalid command opcode";
00101   case TMR_ERROR_UNIMPLEMENTED_OPCODE:
00102     return "Unimplemented opcode";
00103   case TMR_ERROR_MSG_POWER_TOO_HIGH:
00104     return "Command attempted to set power above maximum";
00105   case TMR_ERROR_MSG_INVALID_FREQ_RECEIVED:
00106     return "Command attempted to set an unsupported frequency";
00107   case TMR_ERROR_MSG_INVALID_PARAMETER_VALUE:
00108     return "Parameter to command is invalid";
00109   case TMR_ERROR_MSG_POWER_TOO_LOW:
00110     return "Command attempted to set power below minimum";
00111   case TMR_ERROR_UNIMPLEMENTED_FEATURE:
00112     return "Unimplemented feature";
00113   case TMR_ERROR_INVALID_BAUD_RATE:
00114     return "Invalid baud rate";
00115   case TMR_ERROR_INVALID_REGION:
00116     return "Invalid region";
00117   case TMR_ERROR_INVALID_LICENSE_KEY:
00118     return "The license key code received is invalid";
00119   case TMR_ERROR_BL_INVALID_IMAGE_CRC:
00120     return "Application image failed CRC check";
00121   case TMR_ERROR_BL_INVALID_APP_END_ADDR:
00122     return "Application image failed data check";
00123   case TMR_ERROR_FLASH_BAD_ERASE_PASSWORD:
00124     return "Incorrect password to erase flash sector";
00125   case TMR_ERROR_FLASH_BAD_WRITE_PASSWORD:
00126     return "Incorrect password to write to flash sector";
00127   case TMR_ERROR_FLASH_UNDEFINED_SECTOR:
00128     return "Internal error in flash";
00129   case TMR_ERROR_FLASH_ILLEGAL_SECTOR:
00130     return "Incorrect password to erase or write to flash sector";
00131   case TMR_ERROR_FLASH_WRITE_TO_NON_ERASED_AREA:
00132     return "Area of flash to write to is not erased";
00133   case TMR_ERROR_FLASH_WRITE_TO_ILLEGAL_SECTOR:
00134     return "Flash write attempted to cross sector boundary";
00135   case TMR_ERROR_FLASH_VERIFY_FAILED:
00136     return "Flash verify failed";
00137   case TMR_ERROR_NO_TAGS_FOUND:
00138     return "No tags found";
00139   case TMR_ERROR_NO_PROTOCOL_DEFINED:
00140     return "Protocol not set";
00141   case TMR_ERROR_INVALID_PROTOCOL_SPECIFIED:
00142     return "Specified protocol not supported";
00143   case TMR_ERROR_WRITE_PASSED_LOCK_FAILED:
00144     return "Lock failed after write operation";
00145   case TMR_ERROR_PROTOCOL_NO_DATA_READ:
00146     return "No data could be read from a tag";
00147   case TMR_ERROR_AFE_NOT_ON:
00148     return "AFE not on - reader not sufficiently configured";
00149   case TMR_ERROR_PROTOCOL_WRITE_FAILED:
00150     return "Tag write operation failed";
00151   case TMR_ERROR_NOT_IMPLEMENTED_FOR_THIS_PROTOCOL:
00152     return "Operation not supported for this protocol";
00153   case TMR_ERROR_PROTOCOL_INVALID_WRITE_DATA:
00154     return "Tag ID supplied in write operation is incorrect";
00155   case TMR_ERROR_PROTOCOL_INVALID_ADDRESS:
00156     return "Invalid address in tag address space";
00157   case TMR_ERROR_GENERAL_TAG_ERROR:
00158     return "General tag error";
00159   case TMR_ERROR_DATA_TOO_LARGE:
00160     return "Size specified in read tag data command is too large";
00161   case TMR_ERROR_PROTOCOL_INVALID_KILL_PASSWORD:
00162     return "Kill password is not correct";
00163   case TMR_ERROR_PROTOCOL_KILL_FAILED:
00164     return "Kill failed";
00165   case TMR_ERROR_PROTOCOL_BIT_DECODING_FAILED:
00166     return "Bit decoding failed";
00167   case TMR_ERROR_PROTOCOL_INVALID_EPC:
00168     return "Invalid EPC provided";
00169   case TMR_ERROR_PROTOCOL_INVALID_NUM_DATA:
00170     return "Invalid amount of data provided";
00171   case TMR_ERROR_GEN2_PROTOCOL_OTHER_ERROR:
00172     return "Other Gen2 error";
00173   case TMR_ERROR_GEN2_PROTOCOL_MEMORY_OVERRUN_BAD_PC:
00174     return "Gen2 memory overrun - bad PC";
00175   case TMR_ERROR_GEN2_PROCOCOL_MEMORY_LOCKED:\
00176     return "Gen2 memory locked";
00177   case TMR_ERROR_GEN2_PROTOCOL_INSUFFICIENT_POWER:
00178     return "Gen2 tag has insufficent power for operation";
00179   case TMR_ERROR_GEN2_PROTOCOL_NON_SPECIFIC_ERROR:
00180     return "Gen2 nonspecific error";
00181   case TMR_ERROR_GEN2_PROTOCOL_UNKNOWN_ERROR:
00182     return "Gen2 unknown error";
00183         case TMR_ERROR_GEN2_PROTOCOL_V2_AUTHEN_FAILED:
00184                 return "Authentication failed with specified key.";
00185         case TMR_ERROR_GEN2_PROTOCOL_V2_UNTRACE_FAILED:
00186                 return "Untrace opearation failed.";
00187   case TMR_ERROR_AHAL_INVALID_FREQ:
00188     return "Invalid frequency";
00189   case TMR_ERROR_AHAL_CHANNEL_OCCUPIED:
00190     return "Channel occupied";
00191   case TMR_ERROR_AHAL_TRANSMITTER_ON:
00192     return "Transmitter already on";
00193   case TMR_ERROR_ANTENNA_NOT_CONNECTED:
00194     return "Antenna not connected";
00195   case TMR_ERROR_TEMPERATURE_EXCEED_LIMITS:
00196     return "Reader temperature too high";
00197   case TMR_ERROR_HIGH_RETURN_LOSS:
00198     return "High return loss detected, RF ended to avoid damage";
00199   case TMR_ERROR_INVALID_ANTENNA_CONFIG:
00200     return "Invalid antenna configuration";
00201   case TMR_ERROR_TAG_ID_BUFFER_NOT_ENOUGH_TAGS_AVAILABLE:
00202     return "Not enough tag IDs in buffer";
00203   case TMR_ERROR_TAG_ID_BUFFER_FULL:
00204     return "Tag ID buffer full";
00205   case TMR_ERROR_TAG_ID_BUFFER_REPEATED_TAG_ID:
00206     return "Tag ID buffer repeated tag ID";
00207   case TMR_ERROR_TAG_ID_BUFFER_NUM_TAG_TOO_LARGE:
00208     return "Number of tags too large";
00209   case TMR_ERROR_SYSTEM_UNKNOWN_ERROR:
00210     return "Unknown system error";
00211   case TMR_ERROR_TM_ASSERT_FAILED:
00212         {
00213           if (NULL == reader)
00214           {
00215     return "Assertion failed";
00216           }
00217           else
00218           {
00219             return reader->u.serialReader.errMsg;
00220           }
00221         }
00222   case TMR_ERROR_BUFFER_OVERFLOW:
00223   return "Buffer overflow";
00224   case TMR_ERROR_TIMEOUT:
00225     return "Timeout";
00226   case TMR_ERROR_NO_HOST:
00227     return "No matching host found";
00228   case TMR_ERROR_LLRP:
00229     return "LLRP error";
00230   case TMR_ERROR_PARSE:
00231     return "Error parsing device response";
00232   case TMR_ERROR_DEVICE_RESET:
00233     return "Device was reset externally";
00234   case TMR_ERROR_CRC_ERROR:
00235     return "CRC Error";
00236   case TMR_ERROR_INVALID:
00237     return "Invalid argument";
00238   case TMR_ERROR_UNIMPLEMENTED:
00239     return "Unimplemented operation";
00240   case TMR_ERROR_NO_ANTENNA:
00241     return "No antenna or invalid antenna";
00242   case TMR_ERROR_READONLY:
00243     return "Value is read-only";
00244   case TMR_ERROR_TOO_BIG:
00245     return "Value too big";
00246   case TMR_ERROR_NO_THREADS:
00247     return "Thread initialization failed";
00248   case TMR_ERROR_NO_TAGS:
00249     return "No tags to be retrieved";
00250   case TMR_ERROR_NOT_FOUND:
00251     return "Key not found";
00252   case TMR_ERROR_FIRMWARE_FORMAT:
00253     return "Size or format of firmware image is incorrect";
00254   case TMR_ERROR_TRYAGAIN:
00255     return "Temporary error, try again";
00256   case TMR_ERROR_OUT_OF_MEMORY:
00257     return "Out of memory";
00258   case TMR_ERROR_UNSUPPORTED:
00259     return "Unsupported operation";
00260   case TMR_ERROR_INVALID_WRITE_MODE:
00261         return "Invalid write mode";
00262   case TMR_ERROR_ILLEGAL_VALUE:
00263     return "Illegal value";
00264   case TMR_ERROR_UNSUPPORTED_READER_TYPE:
00265     return "Unsupported reader type";
00266   case TMR_ERROR_AUTOREAD_ENABLED:
00267     return "Autonomous mode is enabled on reader. Please disable it";
00268   case TMR_ERROR_FIRMWARE_UPDATE_ON_AUTOREAD:
00269     return "Firmware update is successful. Autonomous mode is already enabled on reader";
00270   case TMR_ERROR_TIMESTAMP_NULL:
00271     return "Timestamp cannot be null";
00272 
00273   default:
00274     {
00275       if (NULL == reader)
00276         return "Unknown error: Reader reference lost";
00277       else
00278       {
00279 #ifdef TMR_ENABLE_LLRP_READER
00280         if (TMR_READER_TYPE_LLRP == reader->readerType)
00281         {
00282           return reader->u.llrpReader.errMsg;
00283         }
00284         else
00285 #endif
00286         {
00287           return reader->u.serialReader.errMsg;
00288         }
00289       }
00290     }
00291   }
00292 }
00293 
00294 #endif /* defined(TMR_ENABLE_ERROR_STRINGS) */


thingmagic_rfid
Author(s): Brian Bingham
autogenerated on Thu May 16 2019 03:01:24