FedmIscTagHandler_ISO14443_4_Maxim_MAX66020.cpp
Go to the documentation of this file.
00001 /*-------------------------------------------------------
00002 |                                                       |
00003 |      FedmIscTagHandler_ISO14443_4_Maxim_MAX66020.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 of manufacturer MAXIM
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_MAX66020.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_MAX66020::FedmIscTagHandler_ISO14443_4_Maxim_MAX66020(
00055         FEDM_ISCReader* pReader, 
00056         FEDM_ISOTabItem* pTabItem )
00057         : FedmIscTagHandler_ISO14443_4_Maxim(pReader, FedmIscTagHandler::TYPE_ISO14443_4_MAXIM_MAX66020, pTabItem)
00058 {
00059         m_sTagName = "ISO 14443 Type B : Maxim MAX66020";
00060 }
00061 
00062 FedmIscTagHandler_ISO14443_4_Maxim_MAX66020::FedmIscTagHandler_ISO14443_4_Maxim_MAX66020(
00063         FEDM_ISCReader* pReader, 
00064         unsigned int uiTagHandlerType,
00065         FEDM_ISOTabItem* pTabItem )
00066         : FedmIscTagHandler_ISO14443_4_Maxim(pReader, uiTagHandlerType, pTabItem)
00067 {
00068         m_sTagName = "ISO 14443 Type B : Maxim MAX66020";
00069 }
00070 
00071 FedmIscTagHandler_ISO14443_4_Maxim_MAX66020::~FedmIscTagHandler_ISO14443_4_Maxim_MAX66020()
00072 {
00073 }
00074 
00075 // set all data members to 0
00076 /*void FedmIscTagHandler_ISO14443::Init()
00077 {
00078 }*/
00079 
00080 
00081 /***************************************************************************
00082   Begin                 :       06.10.2010 / M. Raner
00083 
00084   Version               :       03.03.01 / 28.04.2011 / M. Raner, M. Hultsch
00085 
00086   Function                      :       [0xB2][0xBE][0x20] ReadSingleBlock
00087   
00088   Parameters            :       unsigned char   ucBlockNumber           - [in]  number of block(0x00 to 0x12)
00089                                                 unsigned char&  ucIndicator                     - [out] response indicator byte (if 0x00 then command execution was successful)
00090                                                 unsigned char*  pucMemoryData           - [out] readed memory data
00091 
00092   Return value          :       0                               - if tramsmission was successful
00093                                                 status byte (>1)- if the reader signals a problem
00094                                                 error code (<0) - if something goes wrong
00095 ***************************************************************************/
00096 int FedmIscTagHandler_ISO14443_4_Maxim_MAX66020::ReadSingleBlock(                                       
00097                 unsigned char ucBlockNumber,
00098                 unsigned char& ucIndicator,
00099                 unsigned char* pucMemoryData)
00100 {
00101         //********************************************************************
00102         // ParameterTesting
00103         //Test Pointer for NULL
00104         FEDM_CHK3(pucMemoryData);
00105 
00106         //********************************************************************
00107         // Declaration
00108         unsigned int uiLengthOfResponseData = 0;
00109 
00110         //********************************************************************
00111         // RequestData
00112         m_ucRequestData[0] = 0x20;      // Command
00113         m_ucRequestData[1] = ucBlockNumber;
00114 
00115         //********************************************************************
00116         // CommandExecute
00117         int iBack = Apdu(m_ucRequestData, 2, m_ucResponseData, 256, uiLengthOfResponseData);
00118         if(iBack)
00119                 return iBack;
00120 
00121         //********************************************************************
00122         // ResponseData
00123         if(uiLengthOfResponseData > 0)
00124         {
00125                 ucIndicator = m_ucResponseData[0];
00126                 if(ucIndicator == 0)
00127                 {
00128                         for(int iCnt = 0; iCnt < 8; iCnt++)
00129                         {
00130                                 pucMemoryData[iCnt] = m_ucResponseData[1 + iCnt];
00131                         }
00132                 }
00133         }
00134 
00135         return iBack;
00136 }
00137 
00138 /***************************************************************************
00139   Begin                 :       06.10.2010 / M. Raner
00140 
00141   Version               :       03.03.02 / 28.04.2011 / M. Raner, M. Hultsch
00142 
00143   Function                      :       [0xB2][0xBE][0xB0] ReadSingleBlockWithBlockSecurity
00144   
00145   Parameters            :       unsigned char   ucBlockNumber           - [in]  number of block(0x00 to 0x12)
00146                                                 unsigned char&  ucIndicator                     - [out] response indicator byte (if 0x00 then command execution was successful)
00147                                                 unsigned char&  ucSecurityStatus        - [out] security status code
00148                                                 unsigned char*  pucMemoryData           - [out] readed memory data
00149 
00150   Return value          :       0                               - if tramsmission was successful
00151                                                 status byte (>1)- if the reader signals a problem
00152                                                 error code (<0) - if something goes wrong
00153 ***************************************************************************/
00154 int FedmIscTagHandler_ISO14443_4_Maxim_MAX66020::ReadSingleBlockWithBlockSecurity(      
00155                 unsigned char ucBlockNumber,
00156                 unsigned char& ucIndicator,
00157                 unsigned char& ucSecurityStatus,
00158                 unsigned char* pucMemoryData)
00159 {
00160         //********************************************************************
00161         // ParameterTesting
00162         //Test Pointer for NULL
00163         FEDM_CHK3(pucMemoryData);
00164 
00165         //********************************************************************
00166         // Declaration
00167         unsigned int uiLengthOfResponseData = 0;
00168 
00169         //********************************************************************
00170         // RequestData
00171         m_ucRequestData[0] = 0xB0;      // Command
00172         m_ucRequestData[1] = ucBlockNumber;
00173 
00174         //********************************************************************
00175         // CommandExecute
00176         int iBack = Apdu(m_ucRequestData, 2, m_ucResponseData, 256, uiLengthOfResponseData);
00177         if(iBack)
00178                 return iBack;
00179 
00180         //********************************************************************
00181         // ResponseData
00182         if(uiLengthOfResponseData > 0)
00183         {
00184                 ucIndicator = m_ucResponseData[0];
00185                 if(ucIndicator == 0)
00186                 {
00187                         ucSecurityStatus = m_ucResponseData[1];
00188                         for(int iCnt = 0; iCnt < 8; iCnt++)
00189                         {
00190                                 pucMemoryData[iCnt] = m_ucResponseData[2 + iCnt];
00191                         }
00192                 }
00193         }
00194 
00195 
00196         return iBack;
00197 }
00198 
00199 /***************************************************************************
00200   Begin                 :       06.10.2010 / M. Raner
00201 
00202   Version               :       03.03.02 / 28.04.2011 / M. Raner, M. Hultsch
00203 
00204   Function                      :       [0xB2][0xBE][0xA4] CustomReadBlock
00205   
00206   Parameters            :       unsigned char   ucBlockNumber           - [in]  number of block(0x00 to 0x12)
00207                                                 unsigned char&  ucIndicator                     - [out] response indicator byte (if 0x00 then command execution was successful)
00208                                                 unsigned char*  pucMemoryData           - [out] readed memory data
00209                                                 unsigned char*  pucIntegrityBytes       - [out] integrity bytes(write counter) of datablock
00210 
00211   Return value          :       0                               - if tramsmission was successful
00212                                                 status byte (>1)- if the reader signals a problem
00213                                                 error code (<0) - if something goes wrong
00214 ***************************************************************************/
00215 int FedmIscTagHandler_ISO14443_4_Maxim_MAX66020::CustomReadBlock(                                       
00216                 unsigned char ucBlockNumber,
00217                 unsigned char& ucIndicator,
00218                 unsigned char* pucMemoryData,
00219                 unsigned char* pucIntegrityBytes)
00220 {
00221         //********************************************************************
00222         // ParameterTesting
00223         //Test Pointer for NULL
00224         FEDM_CHK3(pucMemoryData);
00225         FEDM_CHK3(pucIntegrityBytes);
00226 
00227         //********************************************************************
00228         // Declaration
00229         unsigned int uiLengthOfResponseData = 0;
00230 
00231         //********************************************************************
00232         // RequestData
00233         m_ucRequestData[0] = 0xA4;      // Command
00234         m_ucRequestData[1] = ucBlockNumber;
00235 
00236         //********************************************************************
00237         // CommandExecute
00238         int iBack = Apdu(m_ucRequestData, 2, m_ucResponseData, 256, uiLengthOfResponseData);
00239         if(iBack)
00240                 return iBack;
00241 
00242         //********************************************************************
00243         // ResponseData
00244         if(uiLengthOfResponseData > 0)
00245         {
00246                 ucIndicator = m_ucResponseData[0];
00247                 if(ucIndicator == 0)
00248                 {
00249                         for(int iCnt = 0; iCnt < 8; iCnt++)
00250                         {
00251                                 pucMemoryData[iCnt] = m_ucResponseData[1 + iCnt];
00252                         }
00253                         pucIntegrityBytes[0] = m_ucResponseData[9];
00254                         pucIntegrityBytes[1] = m_ucResponseData[10];
00255                 }
00256         }
00257 
00258         return iBack;
00259 }
00260 
00261 
00262 /*******************************************************************************
00263   Begin                 :       06.10.2010 / M. Raner
00264 
00265   Version               :       03.03.02 / 28.04.2011 / M. Raner, M. Hultsch
00266 
00267   Function                      :       [0xB2][0xBE][0x27] WriteAFI
00268   
00269   Parameters            :       unsigned char   ucAfiValue                      - [in]  new AFI Value that will be set on tag
00270                                                 unsigned char&  ucIndicator                     - [out] response indicator byte (if 0x00 then command execution was successful)
00271 
00272   Return value          :       0                               - if tramsmission was successful
00273                                                 status byte (>1)- if the reader signals a problem
00274                                                 error code (<0) - if something goes wrong
00275 *******************************************************************************/ 
00276 int FedmIscTagHandler_ISO14443_4_Maxim_MAX66020::WriteAFI(                                                      
00277                 unsigned char ucAfiValue,
00278                 unsigned char& ucIndicator)
00279 {
00280         //********************************************************************
00281         // Declaration
00282         unsigned int uiLengthOfResponseData = 0;
00283 
00284         //********************************************************************
00285         // RequestData
00286         m_ucRequestData[0] = 0x27;      // Command
00287         m_ucRequestData[1] = ucAfiValue;
00288 
00289         //********************************************************************
00290         // CommandExecute
00291         int iBack = Apdu(m_ucRequestData, 2, m_ucResponseData, 256, uiLengthOfResponseData);
00292         if(iBack)
00293                 return iBack;
00294 
00295         //********************************************************************
00296         // ResponseData
00297         if(uiLengthOfResponseData > 0)
00298         {
00299                 ucIndicator = m_ucResponseData[0];
00300         }
00301 
00302         return iBack;
00303 }
00304 
00305 /*******************************************************************************
00306   Begin                 :       06.10.2010 / M. Raner
00307 
00308   Version               :       03.03.02 / 28.04.2011 / M. Raner, M. Hultsch
00309 
00310   Function                      :       [0xB2][0xBE][0x28] LockAFI
00311   
00312   Parameters            :       unsigned char&  ucIndicator                     - [out] response indicator byte (if 0x00 then command execution was successful)
00313 
00314   Return value          :       0                               - if tramsmission was successful
00315                                                 status byte (>1)- if the reader signals a problem
00316                                                 error code (<0) - if something goes wrong
00317 *******************************************************************************/ 
00318 int FedmIscTagHandler_ISO14443_4_Maxim_MAX66020::LockAFI(                                                       
00319                 unsigned char& ucIndicator)
00320 {
00321         //********************************************************************
00322         // Declaration
00323         unsigned int uiLengthOfResponseData = 0;
00324 
00325         //********************************************************************
00326         // RequestData
00327         m_ucRequestData[0] = 0x28;      // Command
00328 
00329         //********************************************************************
00330         // CommandExecute
00331         int iBack = Apdu(m_ucRequestData, 1, m_ucResponseData, 256, uiLengthOfResponseData);
00332         if(iBack)
00333                 return iBack;
00334 
00335         //********************************************************************
00336         // ResponseData
00337         if(uiLengthOfResponseData > 0)
00338         {
00339                 ucIndicator = m_ucResponseData[0];
00340         }
00341 
00342         return iBack;
00343 }
00344 
00345 /***************************************************************************
00346   Begin                 :       21.04.2011 / M. Raner
00347 
00348   Version               :       03.03.02 / 28.04.2011 / M. Raner, M. Hultsch
00349 
00350   Function                      :       [0xB2][0xBE][0x21] WriteSingleBlock
00351   
00352   Parameters            :       unsigned char   ucBlockNumber           - [in]  number of block(0x00 to 0x12)
00353                                                 unsigned char&  ucIndicator                     - [out] response indicator byte (if 0x00 then command execution was successful)
00354                                                 unsigned char*  pucNewBlockData         - [out] the new block data, expect to be written into choosen memory block
00355 
00356   Return value          :       0                               - if tramsmission was successful
00357                                                 status byte (>1)- if the reader signals a problem
00358                                                 error code (<0) - if something goes wrong
00359 ***************************************************************************/
00360 int FedmIscTagHandler_ISO14443_4_Maxim_MAX66020::WriteSingleBlock(                                      
00361         unsigned char ucBlockNumber,
00362         unsigned char* pucNewBlockData,
00363         unsigned char& ucIndicator)
00364 {
00365         //********************************************************************
00366         // ParameterTesting
00367         //Test Pointer for NULL
00368         FEDM_CHK3(pucNewBlockData)
00369 
00370 
00371         //********************************************************************
00372         // Declaration
00373         unsigned int uiLengthOfResponseData = 0;
00374 
00375         //********************************************************************
00376         // RequestData
00377         m_ucRequestData[0] = 0x21;      // Command
00378         m_ucRequestData[1] = ucBlockNumber;
00379 
00380         //new block data
00381         for(int i = 0; i < 8; i++)
00382         {
00383                 m_ucRequestData[2 + i] = pucNewBlockData[i];
00384         }
00385 
00386         //********************************************************************
00387         // CommandExecute
00388         int iBack = Apdu(m_ucRequestData, 10, m_ucResponseData, 256, uiLengthOfResponseData);
00389         if(iBack)
00390                 return iBack;
00391 
00392         //********************************************************************
00393         // ResponseData
00394         if(uiLengthOfResponseData > 0)
00395         {
00396                 ucIndicator = m_ucResponseData[0];
00397         }
00398 
00399         return iBack;
00400 }
00401 
00402 /***************************************************************************
00403   Begin                 :       29.04.2011 / M. Raner
00404 
00405   Version               :       03.03.02 / 29.04.2011 / M. Raner, M. Hultsch
00406 
00407   Function                      :       [0xB2][0xBE][0x22] LockBlock
00408   
00409   Parameters            :       unsigned char   ucBlockNumber           - [in]  number of block(0x00 to 0x12)
00410                                                 unsigned char&  ucIndicator                     - [out] response indicator byte (if 0x00 then command execution was successful)
00411 
00412   Return value          :       0                               - if tramsmission was successful
00413                                                 status byte (>1)- if the reader signals a problem
00414                                                 error code (<0) - if something goes wrong
00415 ***************************************************************************/
00416 int FedmIscTagHandler_ISO14443_4_Maxim_MAX66020::LockBlock(                                     
00417                 unsigned char ucBlockNumber,
00418                 unsigned char& ucIndicator)
00419 {
00420         //********************************************************************
00421         // Declaration
00422         unsigned int uiLengthOfResponseData = 0;
00423 
00424         //********************************************************************
00425         // RequestData
00426         m_ucRequestData[0] = 0x22;      // Command
00427         m_ucRequestData[1] = ucBlockNumber;
00428 
00429         //********************************************************************
00430         // CommandExecute
00431         int iBack = Apdu(m_ucRequestData, 2, m_ucResponseData, 256, uiLengthOfResponseData);
00432         if(iBack)
00433                 return iBack;
00434 
00435         //********************************************************************
00436         // ResponseData
00437         if(uiLengthOfResponseData > 0)
00438         {
00439                 ucIndicator = m_ucResponseData[0];
00440         }
00441 
00442         return iBack;
00443 }
00444 
00445 #endif // #if !defined(_FEDM_NO_TAG_HANDLER_ISO14443)


rfid_drivers
Author(s): Raul Perula-Martinez
autogenerated on Thu Apr 2 2015 03:06:14