FedmIscTagHandler_ISO14443_4_Maxim.cpp
Go to the documentation of this file.
00001 /*-------------------------------------------------------
00002 |                                                       |
00003 |      FedmIscTagHandler_ISO14443_4_Maxim.cpp           |
00004 |                                                       |
00005 ---------------------------------------------------------
00006 
00007 Copyright © 2010-2011   FEIG ELECTRONIC GmbH, All Rights Reserved.
00008                                                 Lange Strasse 4
00009                                                 D-35781 Weilburg
00010                                                 Federal Republic of Germany
00011                                                 phone    : +49 6471 31090
00012                                                 fax      : +49 6471 310999
00013                                                 e-mail   : obid-support@feig.de
00014                                                 Internet : http://www.feig.de
00015                                         
00016 Author                  :       Markus Hultsch
00017 Begin                   :       04.10.2010
00018 
00019 Version                 :       03.03.02 / 29.04.2011 / M. Raner, M. Hultsch
00020 
00021 Operation Systems       :       independent
00022 
00023 Function                        :       class for OBID® classic-pro transponder ISO14443
00024 
00025 NOTE                            :       this class supports only selected or addressed mode in Host-Mode
00026 
00027 
00028 Trademarks:
00029 -----------
00030 OBID®, OBID i-scan® and OBID myAXXESS® are registered Trademarks of FEIG ELECTRONIC GmbH
00031 Other Trademarks: see FEDM.h
00032 */
00033 
00034 #if !defined(_FEDM_NO_TAG_HANDLER_ISO14443)
00035 
00036 #include "FedmIscTagHandler_ISO14443_4_Maxim.h"
00037 #include "../FEDM_ISCReader.h"
00038 #include "../FEDM_ISOTabItem.h"
00039 #include "../FEDM_ISCReaderID.h"
00040 #include "../FEDM_ISC.h"
00041 
00042 
00043 #if _MSC_VER >= 1400
00044         #pragma warning(disable : 4996)
00045 #endif
00046 
00047 
00048 
00049 //####################################################################
00050 // class FedmIscTagHandler_ISO14443_Maxim
00051 // >> supports only ISO Host Commands <<
00052 //####################################################################
00053 
00054 FedmIscTagHandler_ISO14443_4_Maxim::FedmIscTagHandler_ISO14443_4_Maxim(
00055         FEDM_ISCReader* pReader, 
00056         FEDM_ISOTabItem* pTabItem )
00057         : FedmIscTagHandler_ISO14443_4(pReader, FedmIscTagHandler::TYPE_ISO14443_4_MAXIM, pTabItem)
00058 {
00059         m_sTagName = "ISO 14443 Type B : Maxim";
00060 }
00061 
00062 FedmIscTagHandler_ISO14443_4_Maxim::FedmIscTagHandler_ISO14443_4_Maxim(
00063         FEDM_ISCReader* pReader, 
00064         unsigned int uiTagHandlerType,
00065         FEDM_ISOTabItem* pTabItem )
00066         : FedmIscTagHandler_ISO14443_4(pReader, uiTagHandlerType, pTabItem)
00067 {
00068         m_sTagName = "ISO 14443 Type B : Maxim";
00069 }
00070 
00071 FedmIscTagHandler_ISO14443_4_Maxim::~FedmIscTagHandler_ISO14443_4_Maxim()
00072 {
00073 }
00074 
00075 // set all data members to 0
00076 /*void FedmIscTagHandler_ISO14443_4_Maxim::Init()
00077 {
00078 }*/
00079 
00080 
00081 /***************************************************************************
00082   Begin                 :       06.10.2010 / M. Raner
00083 
00084   Version               :       03.03.02 / 28.04.2011 / M. Raner, M. Hultsch
00085 
00086   Function                      :       Get System Information of Tag
00087   
00088   Parameters            :       unsigned char&  ucIndicator                     - [out] response indicator byte (if 0x00 then command execution was successful)
00089                                                 unsigned char&  ucInfoFlags                     - [out] info flags of tag
00090                                                 unsigned char*  ucUID                           - [out] uid of tag
00091                                                 unsigned char&  ucU1                            - [out] U1 Byte from Memory
00092                                                 unsigned char&  ucAFI                           - [out] AFI Byte from Memory
00093                                                 unsigned char&  ucNumberOfBlocks        - [out] Number of memory blocks aviable on tag
00094                                                 unsigned char&  ucMemoryBlockSize       - [out] size of a single memory block
00095                                                 unsigned char&  ucIcReference           - [out] revision of tag such as 0xA1, 0xA2, 0xB1, etc.
00096 
00097   Return value          :       0                               - if tramsmission was successful
00098                                                 status byte (>1)- if the reader signals a problem
00099                                                 error code (<0) - if something goes wrong
00100 ***************************************************************************/
00101 int FedmIscTagHandler_ISO14443_4_Maxim::GetSystemInformation(                           
00102                 unsigned char& ucIndicator,
00103                 unsigned char& ucInfoFlags,
00104                 unsigned char* ucUID,
00105                 unsigned char& ucU1,
00106                 unsigned char& ucAFI,
00107                 unsigned char& ucNumberOfBlocks,
00108                 unsigned char& ucMemoryBlockSize,
00109                 unsigned char& ucIcReference)
00110 {
00111         //********************************************************************
00112         // Declaration
00113         unsigned char ucRequestData[1];
00114         unsigned char ucResponseData[256];
00115         unsigned int uiLengthOfResponseData = 0;
00116 
00117         //********************************************************************
00118         // RequestData
00119         ucRequestData[0] = 0x2B;        // Command
00120 
00121         //********************************************************************
00122         // CommandExecute
00123         int iBack = Apdu(ucRequestData, 1, ucResponseData, 256, uiLengthOfResponseData);
00124         if(iBack)
00125                 return iBack;
00126 
00127         //********************************************************************
00128         // ResponseData
00129         if(uiLengthOfResponseData > 0)
00130         {
00131                 ucIndicator = ucResponseData[0];
00132                 if(ucIndicator == 0)
00133                 {
00134                         ucInfoFlags = ucResponseData[1];
00135                         for(int i = 0; i < 8; i++)
00136                         {
00137                                 ucUID[i] = ucResponseData[2+i];
00138                         }
00139                         ucU1 = ucResponseData[10];
00140                         ucAFI = ucResponseData[11];
00141                         ucNumberOfBlocks = ucResponseData[12];
00142                         ucMemoryBlockSize = ucResponseData[13];
00143                         ucIcReference = ucResponseData[14];
00144                 }
00145         }
00146 
00147         return iBack;
00148 }
00149 
00150 
00151 /*******************************************************************************
00152   Begin                 :       06.10.2010 / M. Raner
00153 
00154   Version               :       03.03.02 / 28.04.2011 / M. Raner, M. Hultsch
00155 
00156   Function                      :       [0xB2][0xBE][0x30] GetUID
00157   
00158   Parameters            :       unsigned char&  ucIndicator                     - [out] response indicator byte (if 0x00 then command execution was successful)
00159                                                 unsigned char*  pucUID                          - [out] UID of tag
00160 
00161   Return value          :       0                               - if tramsmission was successful
00162                                                 status byte (>1)- if the reader signals a problem
00163                                                 error code (<0) - if something goes wrong
00164 *******************************************************************************/ 
00165 int FedmIscTagHandler_ISO14443_4_Maxim::GetUID(
00166                 unsigned char& ucIndicator,
00167                 unsigned char* pucUID)
00168 {
00169         //********************************************************************
00170         // ParameterTesting
00171         //Test Pointer for NULL
00172         FEDM_CHK3(pucUID);
00173 
00174         //********************************************************************
00175         // Declaration
00176         unsigned char ucRequestData[1];
00177         unsigned char ucResponseData[256];
00178         unsigned int uiLengthOfResponseData = 0;
00179 
00180         //********************************************************************
00181         // RequestData
00182         ucRequestData[0] = 0x30;        // Command
00183 
00184         //********************************************************************
00185         // CommandExecute
00186         int iBack = Apdu(ucRequestData, 1, ucResponseData, 256, uiLengthOfResponseData);
00187         if(iBack != 0)
00188     {
00189         return iBack;
00190     }
00191 
00192         //********************************************************************
00193         // ResponseData
00194         if(uiLengthOfResponseData > 0)
00195         {
00196                 ucIndicator = ucResponseData[0];
00197                 if(ucIndicator == 0)
00198                 {
00199                         for(int iCnt = 0; iCnt < 8; iCnt++)
00200                         {
00201                                 pucUID[iCnt] = ucResponseData[1 + iCnt];
00202                         }
00203                 }
00204         }
00205 
00206         return iBack;
00207 }
00208 
00209 std::string FedmIscTagHandler_ISO14443_4_Maxim::GetErrorText(unsigned char ucIndicator)
00210 {
00211         switch(ucIndicator)
00212         {
00213         case 0x01:
00214                 return "The memory block is write protected";
00215                 break;
00216         case 0x02: 
00217                 return "The memory block is read protected";
00218                 break;
00219         case 0x03: 
00220                 return "The memory block is read protected and write protected";
00221                 break;
00222         case 0x50: 
00223                 return "The memory page involved in the computation did not end with a correct 8-bit CRC";
00224                 break;
00225         case 0x10: 
00226                 return "Invalid block number";
00227                 break;
00228         case 0x11: 
00229                 return "Already locked";
00230                 break;
00231         case 0x12: 
00232                 return "Write access failed because block is locked";
00233                 break;
00234         case 0x13: 
00235                 return "Power failure during generate secret";
00236                 break;
00237         case 0xA0: 
00238                 return "Invalid generate secret control code";
00239                 break;
00240         case 0xA1: 
00241                 return "The computed secret was not locked because secret locking was not enabled";
00242                 break;
00243         case 0xA2: 
00244                 return "Invalid compute page MAC page number";
00245                 break;
00246         case 0xA3: 
00247                 return "No valid data in read/write buffer";
00248                 break;
00249         case 0xA4: 
00250                 return "Copy buffer block number mismatch";
00251                 break;
00252         case 0xA6: 
00253                 return "Copy buffer invalid MAC";
00254                 break;
00255         case 0xA7: 
00256                 return "Secret in memory corrupted";
00257                 break;
00258         case 0xA8: 
00259                 return "The computed secret was not locked because secret locking was not enabled in conjunction with 8-bit page CRC";
00260                 break;
00261         default:
00262                 return "";
00263         }
00264 }
00265 
00266 #endif // #if !defined(_FEDM_NO_TAG_HANDLER_ISO14443)


maggie_rfid_drivers
Author(s): Raul Perula-Martinez
autogenerated on Mon Sep 14 2015 03:05:30