FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL3.cpp
Go to the documentation of this file.
00001 /*-------------------------------------------------------
00002 |                                                       |
00003 |      FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL3.cpp |
00004 |                                                       |
00005 ---------------------------------------------------------
00006 
00007 Copyright © 2009-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                   :       24.08.2009
00018 
00019 Version                 :       03.03.00 / 26.01.2011 / M. Hultsch
00020 
00021 Operation Systems       :       independent
00022 
00023 Function                        :       class for OBID® classic-pro transponder ISO14443-4 MIFARE Plus in Security Level 3
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_MIFARE_Plus_SL3.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_4_MIFARE_Plus_SL3
00051 // >> supports only ISO Host Commands <<
00052 //####################################################################
00053 
00054 FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL3::FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL3(
00055         FEDM_ISCReader* pReader, 
00056         FEDM_ISOTabItem* pTabItem )
00057         : FedmIscTagHandler_ISO14443_4_MIFARE_Plus(pReader, FedmIscTagHandler::TYPE_ISO14443_4_MIFARE_PLUS_SL3, pTabItem)
00058 {
00059         m_sTagName = "ISO 14443-4 Type A : MIFARE Plus in Security Level 3";
00060 }
00061 
00062 FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL3::FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL3(
00063         FEDM_ISCReader* pReader, 
00064         unsigned int uiTagHandlerType,
00065         FEDM_ISOTabItem* pTabItem )
00066         : FedmIscTagHandler_ISO14443_4_MIFARE_Plus(pReader, uiTagHandlerType, pTabItem)
00067 {
00068         m_sTagName = "ISO 14443-4 Type A : MIFARE Plus in Security Level 3";
00069 }
00070 
00071 FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL3::~FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL3()
00072 {
00073 }
00074 
00075 // set all data members to 0
00076 /*void FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL3::Init()
00077 {
00078 }*/
00079 
00080 
00081 
00082 /***************************************************************************
00083   Begin                 :       23.09.2009 / M. Hultsch
00084 
00085   Version               :       03.01.00 / 23.09.2009 / M. Hultsch
00086 
00087   Function                      :       [0xC2][0x78] SL3 Reset Authent
00088 
00089                                                 NOTE: only for selected tags
00090 
00091   Parameters            :       -
00092 
00093   Return value          :       0                               - if tramsmission was successful
00094                                                 status byte (>1)- if the reader signals a problem
00095                                                 error code (<0) - if something goes wrong
00096 ***************************************************************************/
00097 int FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL3::ResetAuthentication()
00098 {
00099         int iErr = 0;
00100 
00101         FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_CMD, (unsigned char)0x78));
00102         FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_MODE, (unsigned char)0x00));
00103 
00104         // ... and execute
00105         int iBack = m_pReader->SendProtocol(0xC2);
00106         if( iBack==0x00 )
00107         {
00108                 m_ucErrorSource = 0;
00109                 m_uiErrorCode = 0;
00110         }
00111         else if( iBack==0x97 )
00112         {
00113                 FEDM_CHK1(iErr, m_pReader->GetData(FEDM_ISC_TMP_0xC2_ERROR_SOURCE, &m_ucErrorSource));
00114                 FEDM_CHK1(iErr, m_pReader->GetData(FEDM_ISC_TMP_0xC2_ERROR_CODE, &m_uiErrorCode));
00115         }
00116 
00117         return iBack;
00118 }
00119 
00120         // [0xC2][0x30] SL3 Read Encrypted
00121 int FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL3::Read_Encrypted(
00122         unsigned int uiBlockNo, 
00123         unsigned char ucExt, 
00124         unsigned char* pucResponseData )
00125 {
00126         return Read(0x30, uiBlockNo, ucExt, pucResponseData);
00127 }
00128 
00129         // [0xC2][0x31] SL3 Read Encrypted Maced
00130 int FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL3::Read_EncryptedMaced(
00131         unsigned int uiBlockNo, 
00132         unsigned char ucExt, 
00133         unsigned char* pucResponseData )
00134 {
00135         return Read(0x31, uiBlockNo, ucExt, pucResponseData);
00136 }
00137 
00138         // [0xC2][0x32] SL3 Read Plain
00139 int FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL3::Read_Plain(
00140         unsigned int uiBlockNo, 
00141         unsigned char ucExt, 
00142         unsigned char* pucResponseData )
00143 {
00144         return Read(0x32, uiBlockNo, ucExt, pucResponseData);
00145 }
00146 
00147         // [0xC2][0x33] SL3 Read Plain Maced
00148 int FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL3::Read_PlainMaced(
00149         unsigned int uiBlockNo, 
00150         unsigned char ucExt, 
00151         unsigned char* pucResponseData )
00152 {
00153         return Read(0x33, uiBlockNo, ucExt, pucResponseData);
00154 }
00155 
00156         // [0xC2][0x34] SL3 Read Encrypted Unmaced
00157 int FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL3::Read_EncryptedUnmaced(
00158         unsigned int uiBlockNo, 
00159         unsigned char ucExt, 
00160         unsigned char* pucResponseData )
00161 {
00162         return Read(0x34, uiBlockNo, ucExt, pucResponseData);
00163 }
00164 
00165         // [0xC2][0x35] SL3 Read Encrypted Unmaced Respond Maced
00166 int FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL3::Read_EncryptedUnmaced_RespondMaced(
00167         unsigned int uiBlockNo, 
00168         unsigned char ucExt, 
00169         unsigned char* pucResponseData )
00170 {
00171         return Read(0x35, uiBlockNo, ucExt, pucResponseData);
00172 }
00173 
00174         // [0xC2][0x36] SL3 Read Plain Unmaced
00175 int FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL3::Read_PlainUnmaced(
00176         unsigned int uiBlockNo, 
00177         unsigned char ucExt, 
00178         unsigned char* pucResponseData )
00179 {
00180         return Read(0x36, uiBlockNo, ucExt, pucResponseData);
00181 }
00182 
00183         // [0xC2][0x37] SL3 Read Plain Unmaced Respond Maced
00184 int FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL3::Read_PlainUnmaced_RespondMaced(
00185         unsigned int uiBlockNo, 
00186         unsigned char ucExt, 
00187         unsigned char* pucResponseData )
00188 {
00189         return Read(0x37, uiBlockNo, ucExt, pucResponseData);
00190 }
00191 
00192         // [0xC2][0xA0] SL3 Write Encrypted
00193 int FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL3::Write_Encrypted(
00194         unsigned int uiBlockNo, 
00195         unsigned char ucLength,
00196         unsigned char* pucRequestData )
00197 {
00198         return Write(0xA0, uiBlockNo, ucLength, pucRequestData);
00199 }
00200 
00201         // [0xC2][0xA1] SL3 Write Encrypted Maced
00202 int FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL3::Write_EncryptedMaced(
00203         unsigned int uiBlockNo, 
00204         unsigned char ucLength,
00205         unsigned char* pucRequestData )
00206 {
00207         return Write(0xA1, uiBlockNo, ucLength, pucRequestData);
00208 }
00209 
00210         // [0xC2][0xA2] SL3 Write Plain
00211 int FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL3::Write_Plain(
00212         unsigned int uiBlockNo, 
00213         unsigned char ucLength,
00214         unsigned char* pucRequestData )
00215 {
00216         return Write(0xA2, uiBlockNo, ucLength, pucRequestData);
00217 }
00218 
00219         // [0xC2][0xA3] SL3 Write Plain Maced
00220 int FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL3::Write_PlainMaced(
00221         unsigned int uiBlockNo, 
00222         unsigned char ucLength,
00223         unsigned char* pucRequestData )
00224 {
00225         return Write(0xA3, uiBlockNo, ucLength, pucRequestData);
00226 }
00227 
00228 
00229 /***************************************************************************
00230   Begin                 :       23.09.2009 / M. Hultsch
00231 
00232   Version               :       03.01.00 / 23.09.2009 / M. Hultsch
00233 
00234   Function                      :       [0xC2][0xB0] SL3 Increment Encrypted
00235 
00236                                                 NOTE: only for selected tags
00237 
00238   Parameters            :       unsigned int uiSourceBlockNo    - [in] source data block address
00239                                                 unsigned int uiValue                    - [in] increment value
00240 
00241   Return value          :       0                               - if tramsmission was successful
00242                                                 status byte (>1)- if the reader signals a problem
00243                                                 error code (<0) - if something goes wrong
00244 ***************************************************************************/
00245 int FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL3::Increment_Encrypted(
00246         unsigned int uiSourceBlockNo, 
00247         unsigned int uiValue )
00248 {
00249         int iErr = 0;
00250 
00251         FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_CMD, (unsigned char)0xB0));
00252         FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_MODE, (unsigned char)0x00));
00253         FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_SRC_BLOCK_NO, uiSourceBlockNo));
00254         FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_VALUE, uiValue));
00255 
00256         // ... and execute
00257         int iBack = m_pReader->SendProtocol(0xC2);
00258         if( iBack==0x00 )
00259         {
00260                 m_ucErrorSource = 0;
00261                 m_uiErrorCode = 0;
00262         }
00263         else if( iBack==0x97 )
00264         {
00265                 FEDM_CHK1(iErr, m_pReader->GetData(FEDM_ISC_TMP_0xC2_ERROR_SOURCE, &m_ucErrorSource));
00266                 FEDM_CHK1(iErr, m_pReader->GetData(FEDM_ISC_TMP_0xC2_ERROR_CODE, &m_uiErrorCode));
00267         }
00268 
00269         return iBack;
00270 }
00271 
00272 
00273 /***************************************************************************
00274   Begin                 :       23.09.2009 / M. Hultsch
00275 
00276   Version               :       03.01.00 / 23.09.2009 / M. Hultsch
00277 
00278   Function                      :       [0xC2][0xB1] SL3 Increment Encrypted Maced
00279 
00280                                                 NOTE: only for selected tags
00281 
00282   Parameters            :       unsigned int uiSourceBlockNo    - [in] source data block address
00283                                                 unsigned int uiValue                    - [in] increment value
00284 
00285   Return value          :       0                               - if tramsmission was successful
00286                                                 status byte (>1)- if the reader signals a problem
00287                                                 error code (<0) - if something goes wrong
00288 ***************************************************************************/
00289 int FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL3::Increment_EncryptedMaced(
00290         unsigned int uiSourceBlockNo, 
00291         unsigned int uiValue )
00292 {
00293         int iErr = 0;
00294 
00295         FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_CMD, (unsigned char)0xB1));
00296         FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_MODE, (unsigned char)0x00));
00297         FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_SRC_BLOCK_NO, uiSourceBlockNo));
00298         FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_VALUE, uiValue));
00299 
00300         // ... and execute
00301         int iBack = m_pReader->SendProtocol(0xC2);
00302         if( iBack==0x00 )
00303         {
00304                 m_ucErrorSource = 0;
00305                 m_uiErrorCode = 0;
00306         }
00307         else if( iBack==0x97 )
00308         {
00309                 FEDM_CHK1(iErr, m_pReader->GetData(FEDM_ISC_TMP_0xC2_ERROR_SOURCE, &m_ucErrorSource));
00310                 FEDM_CHK1(iErr, m_pReader->GetData(FEDM_ISC_TMP_0xC2_ERROR_CODE, &m_uiErrorCode));
00311         }
00312 
00313         return iBack;
00314 }
00315 
00316 
00317 /***************************************************************************
00318   Begin                 :       23.09.2009 / M. Hultsch
00319 
00320   Version               :       03.01.00 / 23.09.2009 / M. Hultsch
00321 
00322   Function                      :       [0xC2][0xB2] SL3 Decrement Encrypted
00323 
00324                                                 NOTE: only for selected tags
00325 
00326   Parameters            :       unsigned int uiSourceBlockNo    - [in] source data block address
00327                                                 unsigned int uiValue                    - [in] decrement value
00328 
00329   Return value          :       0                               - if tramsmission was successful
00330                                                 status byte (>1)- if the reader signals a problem
00331                                                 error code (<0) - if something goes wrong
00332 ***************************************************************************/
00333 int FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL3::Decrement_Encrypted(
00334         unsigned int uiSourceBlockNo, 
00335         unsigned int uiValue )
00336 {
00337         int iErr = 0;
00338 
00339         FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_CMD, (unsigned char)0xB2));
00340         FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_MODE, (unsigned char)0x00));
00341         FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_SRC_BLOCK_NO, uiSourceBlockNo));
00342         FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_VALUE, uiValue));
00343 
00344         // ... and execute
00345         int iBack = m_pReader->SendProtocol(0xC2);
00346         if( iBack==0x00 )
00347         {
00348                 m_ucErrorSource = 0;
00349                 m_uiErrorCode = 0;
00350         }
00351         else if( iBack==0x97 )
00352         {
00353                 FEDM_CHK1(iErr, m_pReader->GetData(FEDM_ISC_TMP_0xC2_ERROR_SOURCE, &m_ucErrorSource));
00354                 FEDM_CHK1(iErr, m_pReader->GetData(FEDM_ISC_TMP_0xC2_ERROR_CODE, &m_uiErrorCode));
00355         }
00356 
00357         return iBack;
00358 }
00359 
00360 
00361 /***************************************************************************
00362   Begin                 :       23.09.2009 / M. Hultsch
00363 
00364   Version               :       03.01.00 / 23.09.2009 / M. Hultsch
00365 
00366   Function                      :       [0xC2][0xB3] SL3 Decrement Encrypted Maced
00367 
00368                                                 NOTE: only for selected tags
00369 
00370   Parameters            :       unsigned int uiSourceBlockNo    - [in] source data block address
00371                                                 unsigned int uiValue                    - [in] decrement value
00372 
00373   Return value          :       0                               - if tramsmission was successful
00374                                                 status byte (>1)- if the reader signals a problem
00375                                                 error code (<0) - if something goes wrong
00376 ***************************************************************************/
00377 int FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL3::Decrement_EncryptedMaced(
00378         unsigned int uiSourceBlockNo, 
00379         unsigned int uiValue )
00380 {
00381         int iErr = 0;
00382 
00383         FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_CMD, (unsigned char)0xB3));
00384         FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_MODE, (unsigned char)0x00));
00385         FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_SRC_BLOCK_NO, uiSourceBlockNo));
00386         FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_VALUE, uiValue));
00387 
00388         // ... and execute
00389         int iBack = m_pReader->SendProtocol(0xC2);
00390         if( iBack==0x00 )
00391         {
00392                 m_ucErrorSource = 0;
00393                 m_uiErrorCode = 0;
00394         }
00395         else if( iBack==0x97 )
00396         {
00397                 FEDM_CHK1(iErr, m_pReader->GetData(FEDM_ISC_TMP_0xC2_ERROR_SOURCE, &m_ucErrorSource));
00398                 FEDM_CHK1(iErr, m_pReader->GetData(FEDM_ISC_TMP_0xC2_ERROR_CODE, &m_uiErrorCode));
00399         }
00400 
00401         return iBack;
00402 }
00403 
00404 
00405 /***************************************************************************
00406   Begin                 :       23.09.2009 / M. Hultsch
00407 
00408   Version               :       03.01.00 / 23.09.2009 / M. Hultsch
00409 
00410   Function                      :       [0xC2][0xB4] SL3 Transfer
00411 
00412                                                 NOTE: only for selected tags
00413 
00414   Parameters            :       unsigned int uiDestinationBlockNo       - [in] destination data block address
00415 
00416   Return value          :       0                               - if tramsmission was successful
00417                                                 status byte (>1)- if the reader signals a problem
00418                                                 error code (<0) - if something goes wrong
00419 ***************************************************************************/
00420 int FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL3::Transfer(
00421         unsigned int uiDestinationBlockNo )
00422 {
00423         int iErr = 0;
00424 
00425         FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_CMD, (unsigned char)0xB4));
00426         FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_MODE, (unsigned char)0x00));
00427         FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_DST_BLOCK_NO, uiDestinationBlockNo));
00428 
00429         // ... and execute
00430         int iBack = m_pReader->SendProtocol(0xC2);
00431         if( iBack==0x00 )
00432         {
00433                 m_ucErrorSource = 0;
00434                 m_uiErrorCode = 0;
00435         }
00436         else if( iBack==0x97 )
00437         {
00438                 FEDM_CHK1(iErr, m_pReader->GetData(FEDM_ISC_TMP_0xC2_ERROR_SOURCE, &m_ucErrorSource));
00439                 FEDM_CHK1(iErr, m_pReader->GetData(FEDM_ISC_TMP_0xC2_ERROR_CODE, &m_uiErrorCode));
00440         }
00441 
00442         return iBack;
00443 }
00444 
00445 
00446 /***************************************************************************
00447   Begin                 :       23.09.2009 / M. Hultsch
00448 
00449   Version               :       03.01.00 / 23.09.2009 / M. Hultsch
00450 
00451   Function                      :       [0xC2][0xB5] SL3 Transfer Maced
00452 
00453                                                 NOTE: only for selected tags
00454 
00455   Parameters            :       unsigned int uiDestinationBlockNo       - [in] destination data block address
00456 
00457   Return value          :       0                               - if tramsmission was successful
00458                                                 status byte (>1)- if the reader signals a problem
00459                                                 error code (<0) - if something goes wrong
00460 ***************************************************************************/
00461 int FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL3::Transfer_Maced(
00462         unsigned int uiDestinationBlockNo )
00463 {
00464         int iErr = 0;
00465 
00466         FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_CMD, (unsigned char)0xB5));
00467         FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_MODE, (unsigned char)0x00));
00468         FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_DST_BLOCK_NO, uiDestinationBlockNo));
00469 
00470         // ... and execute
00471         int iBack = m_pReader->SendProtocol(0xC2);
00472         if( iBack==0x00 )
00473         {
00474                 m_ucErrorSource = 0;
00475                 m_uiErrorCode = 0;
00476         }
00477         else if( iBack==0x97 )
00478         {
00479                 FEDM_CHK1(iErr, m_pReader->GetData(FEDM_ISC_TMP_0xC2_ERROR_SOURCE, &m_ucErrorSource));
00480                 FEDM_CHK1(iErr, m_pReader->GetData(FEDM_ISC_TMP_0xC2_ERROR_CODE, &m_uiErrorCode));
00481         }
00482 
00483         return iBack;
00484 }
00485 
00486 
00487 /***************************************************************************
00488   Begin                 :       23.09.2009 / M. Hultsch
00489 
00490   Version               :       03.01.00 / 23.09.2009 / M. Hultsch
00491 
00492   Function                      :       [0xC2][0xB6] SL3 Increment Transfer Encrypted
00493 
00494                                                 NOTE: only for selected tags
00495 
00496   Parameters            :       unsigned int uiSourceBlockNo            - [in] source data block address
00497                                                 unsigned int uiDestinationBlockNo       - [in] destination data block address
00498                                                 unsigned int uiValue                            - [in] increment value
00499 
00500   Return value          :       0                               - if tramsmission was successful
00501                                                 status byte (>1)- if the reader signals a problem
00502                                                 error code (<0) - if something goes wrong
00503 ***************************************************************************/
00504 int FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL3::Increment_Transfer_Encrypted(
00505         unsigned int uiSourceBlockNo,
00506         unsigned int uiDestinationBlockNo,
00507         unsigned int uiValue )
00508 {
00509         int iErr = 0;
00510 
00511         FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_CMD, (unsigned char)0xB6));
00512         FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_MODE, (unsigned char)0x00));
00513         FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_SRC_BLOCK_NO, uiSourceBlockNo));
00514         FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_DST_BLOCK_NO, uiDestinationBlockNo));
00515         FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_VALUE, uiValue));
00516 
00517         // ... and execute
00518         int iBack = m_pReader->SendProtocol(0xC2);
00519         if( iBack==0x00 )
00520         {
00521                 m_ucErrorSource = 0;
00522                 m_uiErrorCode = 0;
00523         }
00524         else if( iBack==0x97 )
00525         {
00526                 FEDM_CHK1(iErr, m_pReader->GetData(FEDM_ISC_TMP_0xC2_ERROR_SOURCE, &m_ucErrorSource));
00527                 FEDM_CHK1(iErr, m_pReader->GetData(FEDM_ISC_TMP_0xC2_ERROR_CODE, &m_uiErrorCode));
00528         }
00529 
00530         return iBack;
00531 }
00532 
00533 
00534 /***************************************************************************
00535   Begin                 :       23.09.2009 / M. Hultsch
00536 
00537   Version               :       03.01.00 / 23.09.2009 / M. Hultsch
00538 
00539   Function                      :       [0xC2][0xB7] SL3 Increment Transfer Encrypted Maced
00540 
00541                                                 NOTE: only for selected tags
00542 
00543   Parameters            :       unsigned int uiSourceBlockNo            - [in] source data block address
00544                                                 unsigned int uiDestinationBlockNo       - [in] destination data block address
00545                                                 unsigned int uiValue                            - [in] increment value
00546 
00547   Return value          :       0                               - if tramsmission was successful
00548                                                 status byte (>1)- if the reader signals a problem
00549                                                 error code (<0) - if something goes wrong
00550 ***************************************************************************/
00551 int FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL3::Increment_Transfer_EncryptedMaced(
00552         unsigned int uiSourceBlockNo,
00553         unsigned int uiDestinationBlockNo,
00554         unsigned int uiValue )
00555 {
00556         int iErr = 0;
00557 
00558         FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_CMD, (unsigned char)0xB7));
00559         FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_MODE, (unsigned char)0x00));
00560         FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_SRC_BLOCK_NO, uiSourceBlockNo));
00561         FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_DST_BLOCK_NO, uiDestinationBlockNo));
00562         FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_VALUE, uiValue));
00563 
00564         // ... and execute
00565         int iBack = m_pReader->SendProtocol(0xC2);
00566         if( iBack==0x00 )
00567         {
00568                 m_ucErrorSource = 0;
00569                 m_uiErrorCode = 0;
00570         }
00571         else if( iBack==0x97 )
00572         {
00573                 FEDM_CHK1(iErr, m_pReader->GetData(FEDM_ISC_TMP_0xC2_ERROR_SOURCE, &m_ucErrorSource));
00574                 FEDM_CHK1(iErr, m_pReader->GetData(FEDM_ISC_TMP_0xC2_ERROR_CODE, &m_uiErrorCode));
00575         }
00576 
00577         return iBack;
00578 }
00579 
00580 
00581 /***************************************************************************
00582   Begin                 :       23.09.2009 / M. Hultsch
00583 
00584   Version               :       03.01.00 / 23.09.2009 / M. Hultsch
00585 
00586   Function                      :       [0xC2][0xB8] SL3 Decrement Transfer Encrypted
00587 
00588                                                 NOTE: only for selected tags
00589 
00590   Parameters            :       unsigned int uiSourceBlockNo            - [in] source data block address
00591                                                 unsigned int uiDestinationBlockNo       - [in] destination data block address
00592                                                 unsigned int uiValue                            - [in] decrement value
00593 
00594   Return value          :       0                               - if tramsmission was successful
00595                                                 status byte (>1)- if the reader signals a problem
00596                                                 error code (<0) - if something goes wrong
00597 ***************************************************************************/
00598 int FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL3::Decrement_Transfer_Encrypted(
00599         unsigned int uiSourceBlockNo,
00600         unsigned int uiDestinationBlockNo,
00601         unsigned int uiValue )
00602 {
00603         int iErr = 0;
00604 
00605         FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_CMD, (unsigned char)0xB8));
00606         FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_MODE, (unsigned char)0x00));
00607         FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_SRC_BLOCK_NO, uiSourceBlockNo));
00608         FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_DST_BLOCK_NO, uiDestinationBlockNo));
00609         FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_VALUE, uiValue));
00610 
00611         // ... and execute
00612         int iBack = m_pReader->SendProtocol(0xC2);
00613         if( iBack==0x00 )
00614         {
00615                 m_ucErrorSource = 0;
00616                 m_uiErrorCode = 0;
00617         }
00618         else if( iBack==0x97 )
00619         {
00620                 FEDM_CHK1(iErr, m_pReader->GetData(FEDM_ISC_TMP_0xC2_ERROR_SOURCE, &m_ucErrorSource));
00621                 FEDM_CHK1(iErr, m_pReader->GetData(FEDM_ISC_TMP_0xC2_ERROR_CODE, &m_uiErrorCode));
00622         }
00623 
00624         return iBack;
00625 }
00626 
00627 
00628 /***************************************************************************
00629   Begin                 :       23.09.2009 / M. Hultsch
00630 
00631   Version               :       03.01.00 / 23.09.2009 / M. Hultsch
00632 
00633   Function                      :       [0xC2][0xB9] SL3 Decrement Transfer Encrypted Maced
00634 
00635                                                 NOTE: only for selected tags
00636 
00637   Parameters            :       unsigned int uiSourceBlockNo            - [in] source data block address
00638                                                 unsigned int uiDestinationBlockNo       - [in] destination data block address
00639                                                 unsigned int uiValue                            - [in] decrement value
00640 
00641   Return value          :       0                               - if tramsmission was successful
00642                                                 status byte (>1)- if the reader signals a problem
00643                                                 error code (<0) - if something goes wrong
00644 ***************************************************************************/
00645 int FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL3::Decrement_Transfer_EncryptedMaced(
00646         unsigned int uiSourceBlockNo,
00647         unsigned int uiDestinationBlockNo,
00648         unsigned int uiValue )
00649 {
00650         int iErr = 0;
00651 
00652         FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_CMD, (unsigned char)0xB9));
00653         FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_MODE, (unsigned char)0x00));
00654         FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_SRC_BLOCK_NO, uiSourceBlockNo));
00655         FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_DST_BLOCK_NO, uiDestinationBlockNo));
00656         FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_VALUE, uiValue));
00657 
00658         // ... and execute
00659         int iBack = m_pReader->SendProtocol(0xC2);
00660         if( iBack==0x00 )
00661         {
00662                 m_ucErrorSource = 0;
00663                 m_uiErrorCode = 0;
00664         }
00665         else if( iBack==0x97 )
00666         {
00667                 FEDM_CHK1(iErr, m_pReader->GetData(FEDM_ISC_TMP_0xC2_ERROR_SOURCE, &m_ucErrorSource));
00668                 FEDM_CHK1(iErr, m_pReader->GetData(FEDM_ISC_TMP_0xC2_ERROR_CODE, &m_uiErrorCode));
00669         }
00670 
00671         return iBack;
00672 }
00673 
00674 
00675 /***************************************************************************
00676   Begin                 :       23.09.2009 / M. Hultsch
00677 
00678   Version               :       03.01.00 / 24.09.2009 / M. Hultsch
00679 
00680   Function                      :       [0xC2][0xC2] SL3 Restore
00681 
00682                                                 NOTE: only for selected tags
00683 
00684   Parameters            :       unsigned int uiSourceBlockNo    - [in] source data block address
00685 
00686   Return value          :       0                               - if tramsmission was successful
00687                                                 status byte (>1)- if the reader signals a problem
00688                                                 error code (<0) - if something goes wrong
00689 ***************************************************************************/
00690 int FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL3::Restore(
00691         unsigned int uiSourceBlockNo )
00692 {
00693         int iErr = 0;
00694 
00695         FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_CMD, (unsigned char)0xC2));
00696         FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_MODE, (unsigned char)0x00));
00697         FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_SRC_BLOCK_NO, uiSourceBlockNo));
00698 
00699         // ... and execute
00700         int iBack = m_pReader->SendProtocol(0xC2);
00701         if( iBack==0x00 )
00702         {
00703                 m_ucErrorSource = 0;
00704                 m_uiErrorCode = 0;
00705         }
00706         else if( iBack==0x97 )
00707         {
00708                 FEDM_CHK1(iErr, m_pReader->GetData(FEDM_ISC_TMP_0xC2_ERROR_SOURCE, &m_ucErrorSource));
00709                 FEDM_CHK1(iErr, m_pReader->GetData(FEDM_ISC_TMP_0xC2_ERROR_CODE, &m_uiErrorCode));
00710         }
00711 
00712         return iBack;
00713 }
00714 
00715 
00716 /***************************************************************************
00717   Begin                 :       23.09.2009 / M. Hultsch
00718 
00719   Version               :       03.01.00 / 24.09.2009 / M. Hultsch
00720 
00721   Function                      :       [0xC2][0xC3] SL3 Restore Maced
00722 
00723                                                 NOTE: only for selected tags
00724 
00725   Parameters            :       unsigned int uiSourceBlockNo    - [in] source data block address
00726 
00727   Return value          :       0                               - if tramsmission was successful
00728                                                 status byte (>1)- if the reader signals a problem
00729                                                 error code (<0) - if something goes wrong
00730 ***************************************************************************/
00731 int FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL3::Restore_Maced(
00732         unsigned int uiSourceBlockNo )
00733 {
00734         int iErr = 0;
00735 
00736         FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_CMD, (unsigned char)0xC3));
00737         FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_MODE, (unsigned char)0x00));
00738         FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_SRC_BLOCK_NO, uiSourceBlockNo));
00739 
00740         // ... and execute
00741         int iBack = m_pReader->SendProtocol(0xC2);
00742         if( iBack==0x00 )
00743         {
00744                 m_ucErrorSource = 0;
00745                 m_uiErrorCode = 0;
00746         }
00747         else if( iBack==0x97 )
00748         {
00749                 FEDM_CHK1(iErr, m_pReader->GetData(FEDM_ISC_TMP_0xC2_ERROR_SOURCE, &m_ucErrorSource));
00750                 FEDM_CHK1(iErr, m_pReader->GetData(FEDM_ISC_TMP_0xC2_ERROR_CODE, &m_uiErrorCode));
00751         }
00752 
00753         return iBack;
00754 }
00755 
00756 
00757 
00758 // ############################################################################
00759 // protected methods
00760 
00761 /***************************************************************************
00762   Begin                 :       24.08.2009 / M. Hultsch
00763 
00764   Version               :       03.03.00 / 26.01.2011 / M. Hultsch
00765 
00766   Function                      :       [0xC2][0x..] Read
00767 
00768                                                 NOTE: only for selected tags
00769 
00770   Parameters            :       unsigned char ucCmdByte                 - [in] sub command byte
00771                                                 unsigned int uiBlockNo                  - [in] first data block address
00772                                                 unsigned char ucLength                  - [in] number of blocks to be read
00773                                                 unsigned char* pucResponseData  - [in] pointer to response data buffer
00774 
00775   Return value          :       0                               - if tramsmission was successful
00776                                                 status byte (>1)- if the reader signals a problem
00777                                                 error code (<0) - if something goes wrong
00778 ***************************************************************************/
00779 int FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL3::Read(
00780         unsigned char ucCmdByte,
00781         unsigned int uiBlockNo, 
00782         unsigned char ucExt, 
00783         unsigned char* pucResponseData )
00784 {
00785         int iErr = 0;
00786         unsigned int uiBlockNoLsb = 0;
00787 
00788         if(ucExt * 16 > FEDM_ISC_ISO_TABLE_RxDB_SIZE)
00789                 return FEDM_ERROR_ARRAY_BOUNDARY;
00790 
00791         FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_CMD, ucCmdByte));
00792         FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_MODE, (unsigned char)0x00));
00793         FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_BLOCK_NO, uiBlockNo));
00794         FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_EXT, ucExt));
00795 
00796         // ... and execute
00797         int iBack = m_pReader->SendProtocol(0xC2);
00798         if( iBack==0x00 )
00799         {
00800                 uiBlockNoLsb = (uiBlockNo & 0x000000FF);
00801                 memcpy(pucResponseData, &m_pTabItem->m_ucRxDB[uiBlockNoLsb * 16], ucExt * 16);
00802                 m_ucErrorSource = 0;
00803                 m_uiErrorCode = 0;
00804         }
00805         else if( iBack==0x97 )
00806         {
00807                 FEDM_CHK1(iErr, m_pReader->GetData(FEDM_ISC_TMP_0xC2_ERROR_SOURCE, &m_ucErrorSource));
00808                 FEDM_CHK1(iErr, m_pReader->GetData(FEDM_ISC_TMP_0xC2_ERROR_CODE, &m_uiErrorCode));
00809         }
00810 
00811         return iBack;
00812 }
00813 
00814 /***************************************************************************
00815   Begin                 :       24.08.2009 / M. Hultsch
00816 
00817   Version               :       03.03.00 / 26.01.2011 / M. Hultsch
00818 
00819   Function                      :       [0xC2][0xA?] Write
00820 
00821                                                 NOTE: only for selected tags
00822 
00823   Parameters            :       unsigned char ucCmdByte                 - [in] sub command byte
00824                                                 unsigned int uiBlockNo                  - [in] first data block address
00825                                                 unsigned char ucLength                  - [in] number of blocks to be read
00826                                                 unsigned char* pucRequestData   - [in] pointer to request data buffer
00827 
00828   Return value          :       0                               - if tramsmission was successful
00829                                                 status byte (>1)- if the reader signals a problem
00830                                                 error code (<0) - if something goes wrong
00831 ***************************************************************************/
00832 int FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL3::Write(
00833         unsigned char ucCmdByte,
00834         unsigned int uiBlockNo, 
00835         unsigned char ucLength,
00836         unsigned char* pucRequestData )
00837 {
00838         int iErr = 0;
00839         unsigned int uiBlockNoLsb = 0;
00840 
00841         if(ucLength * 16 > FEDM_ISC_ISO_TABLE_TxDB_SIZE)
00842                 return FEDM_ERROR_ARRAY_BOUNDARY;
00843 
00844         FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_CMD, ucCmdByte));
00845         FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_MODE, (unsigned char)0x00));
00846         FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_BLOCK_NO, uiBlockNo));
00847         FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_EXT, ucLength));
00848 
00849         uiBlockNoLsb = (uiBlockNo & 0x000000FF);
00850 
00851         memcpy(&m_pTabItem->m_ucTxDB[uiBlockNoLsb * 16], pucRequestData, ucLength * 16);
00852 
00853         // ... and execute
00854         int iBack = m_pReader->SendProtocol(0xC2);
00855         if( iBack==0x00 )
00856         {
00857                 m_ucErrorSource = 0;
00858                 m_uiErrorCode = 0;
00859         }
00860         else if( iBack==0x97 )
00861         {
00862                 FEDM_CHK1(iErr, m_pReader->GetData(FEDM_ISC_TMP_0xC2_ERROR_SOURCE, &m_ucErrorSource));
00863                 FEDM_CHK1(iErr, m_pReader->GetData(FEDM_ISC_TMP_0xC2_ERROR_CODE, &m_uiErrorCode));
00864         }
00865 
00866         return iBack;
00867 }
00868 
00869 #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