FEDM_ISCReaderModule.cpp
Go to the documentation of this file.
00001 /*-------------------------------------------------------
00002 |                                                       |
00003 |                FEDM_ISCReaderModule.cpp               |
00004 |                                                       |
00005 ---------------------------------------------------------
00006 
00007 Copyright  2000-2014    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                   :       06.11.2003
00018 
00019 Version                 :       04.06.06 / 23.09.2014 / M. Hultsch
00020                                                 - TagHandler support for ISO 14443-4 Tags with 10 byte UID
00021 
00022                                                 04.06.01 / 13.03.2014 / M. Hultsch
00023                                                 - [0x6E] Reader Diagnostic: support for new mode 0x07
00024                                                 - modification in ApplyConfiguration for Paerameter Range Error (status 0x11)
00025 
00026                                                 04.05.05 / 29.11.2013 / M. Hultsch
00027                                                 - new reader: ID ISC.PRH200
00028                                                 - [0x66] Reader Info: new mode 0x09 for WLAN-Firmware
00029 
00030                                                 04.05.04 / 04.09.2013 / M. Hultsch
00031                                                 - new reader: ID ISC.LRU1002
00032 
00033                                                 04.05.03 / 15.07.2013 / M. Hultsch
00034                                                 - new reader: OBID myAXXESS onTop
00035                                                 - TagSelect: bugfix for UID-Length != 8
00036 
00037                                                 04.05.02 / 02.07.2013 / M. Hultsch
00038                                                 - support for new TagHandler for ISO 15693: NXP SLIX, SLIX-L, SLIX-S
00039 
00040                                                 04.04.02 / 18.01.2013 / M. Hultsch
00041                                                 - support for new reader ID CPR47
00042 
00043                                                 04.04.00 / 06.12.2012 / M. Hultsch
00044                                                 - [0x6E] Reader Diagnostic: support for new mode 0x21
00045                  
00046                                                 04.02.08 / 13.08.2012 / M. Hultsch
00047                                                 - support for events from People Counter
00048                  
00049                                                 04.02.06 / 23.07.2012 / M. Hultsch
00050                                                 - bugfix in cbsTaskRsp1 for FEISC_TASKID_FIRST_NEW_TAG
00051                                                 - [0x66] Read Reader Info: new mode 0x08 (with firmware supported tag drivers)
00052 
00053                                                 04.02.01 / 31.05.2012 / M. Hultsch
00054                                                 - support for new tag types: Innovatron and ASK CTx
00055 
00056                                                 04.02.00 / 04.04.2012 / M. Hultsch
00057                                                 - renamed method: GetNonAddressedTagHandler to CreateNonAddressedTagHandler
00058                  
00059                                                 04.00.10 / 10.02.2012 / M. Hultsch
00060                                                 - support for external logmanager (FELOGMNG.dll), when #define _FELOGMNG_SUPPORT is set
00061                                                 - non-addressed EPC Class1 Gen2 supported
00062 
00063                                                 04.00.08 / 05.01.2012 / M. Hultsch
00064                                                 - creation of ISO 14443 TagHandler after Select command only, if card type is changed
00065 
00066                                                 04.00.02 / 11.08.2011 / M. Hultsch
00067                                                 - check of identical UID in TagInventory
00068 
00069                                                 04.00.00 / 21.07.2011 / M. Hultsch
00070                                                 - LRU3000: ACC configuration moved to device RFC
00071                                                 - support for [0x74] Input Event from CPR50
00072                                                 - multiple TCP connections with different Reader Objects causes error
00073                                                 
00074                                                 03.03.01 / 31.03.2011 / M. Hultsch
00075                                                 - new TagHandler class for ISO 15693 IDS SL13A
00076                                                 - new TagHandler class for EPC Class1 Gen2 IDS SL900A
00077 
00078                                                 03.03.00 / 01.02.2011 / M. Hultsch
00079                                                 - Updated ReadReaderInfo()
00080                                                 - ID ISC.LR2500-A added
00081 
00082                                                 03.02.07 / 29.10.2010 / M. Hultsch
00083                                                 - Updated ReadReaderInfo()
00084                                                 - Updated TagSelect() for Maxim Tags
00085                                                 - new method: GetNonAddressedTagHandler()
00086 
00087                                                 03.02.03 / 29.07.2010 / M. Hultsch
00088                                                 - PortPrefix for FECOM under Linux to support Bluetooth
00089 
00090                                                 03.02.00 / 22.06.2010 / M. Hultsch
00091 
00092                                                 03.01.06 / 31.05.2010 / M. Hultsch
00093                                                 - ExclusiveAccess f�r FEUSB mit SetPortPara
00094 
00095                                                 03.01.05 / 23.04.2010 / M. Hultsch
00096                                                 - ID ISC.MR102 and ID ISC.LR2500-B added
00097 
00098                                                 03.01.01 / 16.03.2010 / M. Hultsch
00099                                                 - Reader-Info for external peripheral devices added
00100                                                 - ResetCompleteConfiguration with final CPU-Reset
00101 
00102                                                 03.01.00 / 17.02.2010 / M. Hultsch
00103                                                 - new Reader-Info for ID CPR50.xx/MAX50.xx added
00104                                                 - support for Reader Authentification
00105 
00106                                                 03.00.18 / 16.12.2009 / M. Hultsch
00107                                                 - ID MAX50.xx added
00108 
00109 Operation Systems       :       independent
00110 
00111 Function                        :       classes for OBID i-scan and OBID classic-pro reader family
00112 
00113 
00114 Trademarks:
00115 -----------
00116 OBID®, OBID i-scan® and OBID myAXXESS® are registered Trademarks of FEIG ELECTRONIC GmbH
00117 Other Trademarks: see FEDM.h
00118 */
00119 
00120 
00121 #include "FEDM_ISCReaderModule.h"
00122 #include "FEDM_ISOTabItem.h"
00123 #include "FEDM_ISCReaderID.h"
00124 //#include "FEDM_ISCReaderConfig.h"
00125 #include "FEDM_ISCReaderConfig.h"
00126 #include "../FEDM_Functions.h"
00127 #include "feisc.h"      // declaration of constants, datatypes and DLL-functions
00128 #ifdef _FEDM_TAG_HANDLER
00129         #include "./tag_handler/FedmIscTagHandler.h"
00130 #if !defined(_FEDM_NO_TAG_HANDLER_EPC_C1_G2)
00131         #include "./tag_handler/FedmIscTagHandler_EPC_Class1_Gen2.h"
00132         #include "./tag_handler/FedmIscTagHandler_EPC_Class1_Gen2_IDS_SL900A.h"
00133 #endif
00134 #if !defined(_FEDM_NO_TAG_HANDLER_ISO18000_3M3)
00135         #include "./tag_handler/FedmIscTagHandler_ISO18000_3M3.h"
00136 #endif
00137 #if !defined(_FEDM_NO_TAG_HANDLER_ISO14443)
00138         #include "fetcl.h"
00139         #include "./tag_handler/FedmIscTagHandler_ISO14443.h"
00140         #include "./tag_handler/FedmIscTagHandler_ISO14443_2.h"
00141         #include "./tag_handler/FedmIscTagHandler_ISO14443_2_Innovision_Jewel.h"
00142         #include "./tag_handler/FedmIscTagHandler_ISO14443_2_STM_SR176.h"
00143         #include "./tag_handler/FedmIscTagHandler_ISO14443_2_STM_SRIxxx.h"
00144         #include "./tag_handler/FedmIscTagHandler_ISO14443_3.h"
00145         #include "./tag_handler/FedmIscTagHandler_ISO14443_3_Infineon_my_d.h"
00146         #include "./tag_handler/FedmIscTagHandler_ISO14443_3_Infineon_my_d_move.h"
00147         #include "./tag_handler/FedmIscTagHandler_ISO14443_3_MIFARE_Classic.h"
00148         #include "./tag_handler/FedmIscTagHandler_ISO14443_3_MIFARE_Ultralight.h"
00149         #include "./tag_handler/FedmIscTagHandler_ISO14443_3_MIFARE_Plus.h"
00150         #include "./tag_handler/FedmIscTagHandler_ISO14443_3_MIFARE_Plus_SL1.h"
00151         #include "./tag_handler/FedmIscTagHandler_ISO14443_3_MIFARE_Plus_SL2.h"
00152         #include "./tag_handler/FedmIscTagHandler_ISO14443_4.h"
00153         #include "./tag_handler/FedmIscTagHandler_ISO14443_4_Maxim.h"
00154         #include "./tag_handler/FedmIscTagHandler_ISO14443_4_Maxim_MAX66000.h"
00155         #include "./tag_handler/FedmIscTagHandler_ISO14443_4_Maxim_MAX66020.h"
00156         #include "./tag_handler/FedmIscTagHandler_ISO14443_4_Maxim_MAX66040.h"
00157         #include "./tag_handler/FedmIscTagHandler_ISO14443_4_MIFARE_DESFire.h"
00158         #include "./tag_handler/FedmIscTagHandler_ISO14443_4_MIFARE_Plus.h"
00159         #include "./tag_handler/FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL1.h"
00160         #include "./tag_handler/FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL2.h"
00161         #include "./tag_handler/FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL3.h"
00162 #endif
00163 #if !defined(_FEDM_NO_TAG_HANDLER_ISO15693)
00164         #include "./tag_handler/FedmIscTagHandler_ISO15693.h"
00165         #include "./tag_handler/FedmIscTagHandler_ISO15693_STM.h"
00166         #include "./tag_handler/FedmIscTagHandler_ISO15693_STM_LRI2K.h"
00167         #include "./tag_handler/FedmIscTagHandler_ISO15693_STM_LRIS2K.h"
00168         #include "./tag_handler/FedmIscTagHandler_ISO15693_STM_LRIS64K.h"
00169         #include "./tag_handler/FedmIscTagHandler_ISO15693_STM_M24LR64R.h"
00170         #include "./tag_handler/FedmIscTagHandler_ISO15693_STM_M24LRxxER.h"
00171         #include "./tag_handler/FedmIscTagHandler_ISO15693_NXP.h"
00172         #include "./tag_handler/FedmIscTagHandler_ISO15693_NXP_ICODE_SLI.h"
00173         #include "./tag_handler/FedmIscTagHandler_ISO15693_NXP_ICODE_SLIX.h"
00174         #include "./tag_handler/FedmIscTagHandler_ISO15693_NXP_ICODE_SLI_L.h"
00175         #include "./tag_handler/FedmIscTagHandler_ISO15693_NXP_ICODE_SLIX_L.h"
00176         #include "./tag_handler/FedmIscTagHandler_ISO15693_NXP_ICODE_SLI_S.h"
00177         #include "./tag_handler/FedmIscTagHandler_ISO15693_NXP_ICODE_SLIX_S.h"
00178         #include "./tag_handler/FedmIscTagHandler_ISO15693_Infineon.h"
00179         #include "./tag_handler/FedmIscTagHandler_ISO15693_Infineon_my_d.h"
00180         #include "./tag_handler/FedmIscTagHandler_ISO15693_TI.h"
00181         #include "./tag_handler/FedmIscTagHandler_ISO15693_TI_Tag_it_HFI_Pro.h"
00182         #include "./tag_handler/FedmIscTagHandler_ISO15693_TI_Tag_it_HFI_Plus.h"
00183         #include "./tag_handler/FedmIscTagHandler_ISO15693_Fujitsu.h"
00184         #include "./tag_handler/FedmIscTagHandler_ISO15693_Fujitsu_MB89R1xx.h"
00185         #include "./tag_handler/FedmIscTagHandler_ISO15693_EM.h"
00186         #include "./tag_handler/FedmIscTagHandler_ISO15693_EM_4034.h"
00187         #include "./tag_handler/FedmIscTagHandler_ISO15693_KSW.h"
00188         #include "./tag_handler/FedmIscTagHandler_ISO15693_Maxim.h"
00189         #include "./tag_handler/FedmIscTagHandler_ISO15693_Maxim_MAX66100.h"
00190         #include "./tag_handler/FedmIscTagHandler_ISO15693_Maxim_MAX66120.h"
00191         #include "./tag_handler/FedmIscTagHandler_ISO15693_Maxim_MAX66140.h"
00192         #include "./tag_handler/FedmIscTagHandler_ISO15693_IDS_SL13A.h"
00193 #endif
00194 #endif
00195 
00196 //#if defined(_FEDM_WITH_NAMESPACE)
00197 //using namespace OBID::FEDM::Core;
00198 //#endif
00199 
00201 // Construction/Destruction
00203 
00204 FEDM_ISCReaderModule::FEDM_ISCReaderModule()
00205 {
00206         FEDM_TRACE(m_pLogger, FELOGMNG_DBG_FUNCTION_CALL | FELOGMNG_DBG_LF_ADMIN, __FUNCTION__);
00207 
00208         m_iCommMode = FEDM_COMM_MODE_UNDEF;     // see constants in fedm.h
00209         m_bActiveAsyncTask = false;
00210 
00211         // clear flag filed for modified config pages
00212         memset(m_ucModifiedCfgPages, 0, 16);
00213 
00214         memset(&m_TaskInit, 0, sizeof(FEDM_TASK_INIT));
00215 
00216         // create new reader object in FEISC
00217         int iReaderHnd = FEISC_NewReader(0);
00218         if(iReaderHnd > 0)
00219         {
00220                 // save reader handle (see FEDM_DataBase)
00221                 m_iReaderHnd = iReaderHnd;
00222                 FEISC_SetReaderPara(m_iReaderHnd, "LOGPROT", "1");
00223         }
00224 }
00225 
00226 FEDM_ISCReaderModule::~FEDM_ISCReaderModule()
00227 {
00228         FEDM_TRACE(m_pLogger, FELOGMNG_DBG_FUNCTION_CALL | FELOGMNG_DBG_LF_ADMIN, __FUNCTION__);
00229 
00230         FEISC_SetReaderPara(m_iReaderHnd, "LOGPROT", "0");
00231         if(m_iReaderHnd > 0)
00232                 FEISC_DeleteReader(m_iReaderHnd);
00233 }
00234 
00235 
00237 // entry functions
00239 
00240 /***************************************************************************
00241   Begin                 :       06.11.2003 / M. Hultsch
00242 
00243   Version               :       03.00.00 / 22.08.2008 / M. Hultsch
00244 
00245   Function                      :       opens serial port with FECOM and if successful,
00246                                                 create a reader object in FEISC
00247 
00248   Parameters            :       int iPortNr             -       number of port (1..256)
00249 
00250   Return value          :       FEDM_OK or error code (<0)
00251 ***************************************************************************/
00252 int FEDM_ISCReaderModule::ConnectCOMM(int iPortNr)
00253 {
00254         FEDM_SETPROP2(m_pLogger, FELOGMNG_PROP_PORT_NR, (unsigned int)iPortNr);
00255         FEDM_TRACE_FNC(m_pLogger, FELOGMNG_DBG_FUNCTION_CALL | FELOGMNG_DBG_LF_ADMIN, __FUNCTION__, FELOGMNG_DBG_FUNCTION_PARAMETER, "Port-Number=" << iPortNr);
00256 
00257 #ifdef _FEDM_COM_SUPPORT
00258         if(m_iCommMode != FEDM_COMM_MODE_UNDEF)
00259         {
00260                 FEDM_TRACE(m_pLogger, FELOGMNG_DBG_ERROR, __FUNCTION__ << " " << GetErrorText(FEDM_ERROR_ALREADY_CONNECTED));
00261                 FEDM_RETURN(FEDM_ERROR_ALREADY_CONNECTED);
00262         }
00263 
00264         if(iPortNr <= 0 || iPortNr > 256)
00265         {
00266                 FEDM_TRACE(m_pLogger, FELOGMNG_DBG_ERROR, __FUNCTION__ << " " << GetErrorText(FEDM_ERROR_PARAMETER));
00267                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
00268         }
00269 
00270         bool bOpen = false;
00271         char cPortNr[5];
00272         int iErr;
00273         int iPortHnd = 0;
00274         int iReaderHnd = 0;
00275 
00276 #if !defined(_FEDM_SUPPORT_SLINK)
00277         LPFN_FECOM_GET_PORT_HND lpfnGetPortHnd = (LPFN_FECOM_GET_PORT_HND)GetFeComFunction(FECOM_GET_PORT_HND);
00278         LPFN_FECOM_OPEN_PORT lpfnOpenPort = (LPFN_FECOM_OPEN_PORT)GetFeComFunction(FECOM_OPEN_PORT);
00279         LPFN_FECOM_CLOSE_PORT lpfnClosePort = (LPFN_FECOM_CLOSE_PORT)GetFeComFunction(FECOM_CLOSE_PORT);
00280         LPFN_FECOM_SET_PORT_PARA lpfnSetPortPara = (LPFN_FECOM_SET_PORT_PARA)GetFeComFunction(FECOM_SET_PORT_PARA);
00281 
00282         FEDM_CHK5(lpfnGetPortHnd);
00283         FEDM_CHK5(lpfnOpenPort);
00284         FEDM_CHK5(lpfnClosePort);
00285         FEDM_CHK5(lpfnSetPortPara);
00286 #endif
00287 
00288         sprintf(cPortNr, "%d", iPortNr);
00289 
00290         // is port still open?
00291 #if !defined(_FEDM_SUPPORT_SLINK)
00292         iPortHnd = lpfnGetPortHnd(cPortNr);
00293 #else
00294         iPortHnd = FECOM_GetPortHnd(cPortNr);
00295 #endif
00296         if(iPortHnd <= 0)
00297         {
00298                 // open port
00299 #if !defined(_FEDM_SUPPORT_SLINK)
00300                 iPortHnd = lpfnOpenPort(cPortNr);
00301 #else
00302                 iPortHnd = FECOM_OpenPort(cPortNr);
00303 #endif
00304                 if(iPortHnd < 0)
00305                 {
00306                         FEDM_RETURN(iPortHnd);
00307                 }
00308                 bOpen = true;
00309         }
00310 
00311         if(m_iReaderHnd == 0)
00312         {
00313                 // create new reader object in FEISC
00314                 iReaderHnd = FEISC_NewReader(0);
00315                 if(iReaderHnd < 0)
00316                 {
00317                         if(bOpen)
00318                         {
00319 #if !defined(_FEDM_SUPPORT_SLINK)
00320                                 lpfnClosePort(iPortHnd);        // close port, if this has open it
00321 #else
00322                                 FECOM_ClosePort(iPortHnd);      // close port, if this has open it
00323 #endif
00324                         }
00325                         FEDM_RETURN(iReaderHnd);
00326                 }
00327 
00328                 // save reader handle (see FEDM_DataBase)
00329                 m_iReaderHnd = iReaderHnd;
00330                 FEISC_SetReaderPara(m_iReaderHnd, "LOGPROT", "1");
00331         }
00332 
00333         // save port handle
00334         FEDM_CHK2(iErr, FEDM_ISCReaderModule::SetPortHnd(iPortHnd));
00335         // set communication mode
00336         m_iCommMode = FEDM_COMM_MODE_SERIAL;
00337 
00338         // set port parameters
00339 #if !defined(_FEDM_SUPPORT_SLINK)
00340         FEDM_CHK2(iErr, lpfnSetPortPara(iPortHnd, "BAUD", "38400"));
00341         FEDM_CHK2(iErr, lpfnSetPortPara(iPortHnd, "FRAME", "8E1"));
00342         FEDM_CHK2(iErr, lpfnSetPortPara(iPortHnd, "TIMEOUT", "3000"));
00343 #else
00344         FEDM_CHK2(iErr, FECOM_SetPortPara(iPortHnd, "BAUD", "38400"));
00345         FEDM_CHK2(iErr, FECOM_SetPortPara(iPortHnd, "FRAME", "8E1"));
00346         FEDM_CHK2(iErr, FECOM_SetPortPara(iPortHnd, "TIMEOUT", "3000"));
00347 #endif
00348 
00349         FEDM_RETURN(FEDM_OK);
00350 #else
00351         FEDM_RETURN(FEDM_ERROR_UNSUPPORTED);
00352 #endif
00353 }
00354 
00355 /***************************************************************************
00356   Begin                 :       06.11.2003 / M. Hultsch
00357 
00358   Version               :       04.00.00 / 21.07.2011 / M. Hultsch
00359                                                 - multiple TCP connections with different Reader Objects causes error
00360                                                 
00361                                                 03.00.00 / 22.08.2008 / M. Hultsch
00362 
00363   Function                      :       opens socket with FETCP and if successful,
00364                                                 create a reader object in FEISC
00365 
00366   Parameters            :       char* cHostAdr  -       pointer to host address
00367                                                 int iPortNr             -       port number (1..65535)
00368 
00369   Return value          :       FEDM_OK or error code (<0)
00370 ***************************************************************************/
00371 int FEDM_ISCReaderModule::ConnectTCP(char* cHostAdr, int iPortNr)
00372 {
00373         FEDM_SETPROP1(m_pLogger, (unsigned int)iPortNr, cHostAdr);
00374         FEDM_TRACE_FNC(m_pLogger, FELOGMNG_DBG_FUNCTION_CALL | FELOGMNG_DBG_LF_ADMIN, __FUNCTION__, FELOGMNG_DBG_FUNCTION_PARAMETER, "IP-Address=" << cHostAdr << ", Port-Number=" << iPortNr);
00375 
00376 #ifdef _FEDM_TCP_SUPPORT
00377         FEDM_CHK5(cHostAdr);
00378 
00379         if(m_iCommMode != FEDM_COMM_MODE_UNDEF)
00380         {
00381                 FEDM_TRACE(m_pLogger, FELOGMNG_DBG_ERROR, __FUNCTION__ << " " << GetErrorText(FEDM_ERROR_ALREADY_CONNECTED));
00382                 FEDM_RETURN(FEDM_ERROR_ALREADY_CONNECTED);
00383         }
00384 
00385         if(iPortNr <= 0 || iPortNr > 65535)
00386         {
00387                 FEDM_TRACE(m_pLogger, FELOGMNG_DBG_ERROR, __FUNCTION__ << " " << GetErrorText(FEDM_ERROR_PARAMETER));
00388                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
00389         }
00390 
00391         bool bOpen = false;
00392         int iPortHnd = 0;
00393         int iReaderHnd = 0;
00394 
00395 #if !defined(_FEDM_SUPPORT_SLINK)
00396         LPFN_FETCP_GET_SOCKET_HND lpfnGetSocketHnd = (LPFN_FETCP_GET_SOCKET_HND)GetFeTcpFunction(FETCP_GET_SOCKET_HND);
00397         LPFN_FETCP_CONNECT lpfnConnect = (LPFN_FETCP_CONNECT)GetFeTcpFunction(FETCP_CONNECT);
00398         LPFN_FETCP_DISCONNECT lpfnDisConnect = (LPFN_FETCP_DISCONNECT)GetFeTcpFunction(FETCP_DISCONNECT);
00399 
00400         FEDM_CHK5(lpfnGetSocketHnd);
00401         FEDM_CHK5(lpfnConnect);
00402         FEDM_CHK5(lpfnDisConnect);
00403 #endif
00404 
00405         // is port still open?
00406 #if !defined(_FEDM_SUPPORT_SLINK)
00407         iPortHnd = lpfnGetSocketHnd(cHostAdr, iPortNr);
00408 #else
00409         iPortHnd = FETCP_GetSocketHnd(cHostAdr, iPortNr);
00410 #endif
00411         if(iPortHnd > 0)
00412         {
00413                 // prevent multiple TCP connections from one app to the same Reader
00414                 FEDM_TRACE(m_pLogger, FELOGMNG_DBG_ERROR, __FUNCTION__ << " " << GetErrorText(FEDM_ERROR_CONNECTED_WITH_OTHER_MODULE));
00415                 FEDM_RETURN(FEDM_ERROR_CONNECTED_WITH_OTHER_MODULE);
00416         }
00417 
00418         // open port
00419 #if !defined(_FEDM_SUPPORT_SLINK)
00420         iPortHnd = lpfnConnect(cHostAdr, iPortNr);
00421 #else
00422         iPortHnd = FETCP_Connect(cHostAdr, iPortNr);
00423 #endif
00424         if(iPortHnd < 0)
00425         {
00426                 FEDM_RETURN(iPortHnd);
00427         }
00428         bOpen = true;
00429 
00430         if(m_iReaderHnd == 0)
00431         {
00432                 // create new reader object in FEISC
00433                 iReaderHnd = FEISC_NewReader(0);
00434                 if(iReaderHnd < 0)
00435                 {
00436                         if(bOpen)
00437                         {
00438 #if !defined(_FEDM_SUPPORT_SLINK)
00439                                 lpfnDisConnect(iPortHnd);       // close port, if this has open it
00440 #else
00441                                 FETCP_DisConnect(iPortHnd);     // close port, if this has open it
00442 #endif
00443                         }
00444                         FEDM_RETURN(iReaderHnd);
00445                 }
00446 
00447                 // save reader handle (see FEDM_DataBase)
00448                 m_iReaderHnd = iReaderHnd;
00449                 FEISC_SetReaderPara(m_iReaderHnd, "LOGPROT", "1");
00450         }
00451 
00452         // save port handle
00453         FEDM_ISCReaderModule::SetPortHnd(iPortHnd);
00454         // set communication mode
00455         m_iCommMode = FEDM_COMM_MODE_TCP;
00456 
00457         FEDM_RETURN(FEDM_OK);
00458 #else
00459         FEDM_RETURN(FEDM_ERROR_UNSUPPORTED);
00460 #endif
00461 }
00462 
00463 /***************************************************************************
00464   Begin                 :       06.11.2003 / M. Hultsch
00465 
00466   Version               :       03.00.00 / 22.08.2008 / M. Hultsch
00467 
00468   Function                      :       opens USB device and if successful,
00469                                                 create a reader object in FEISC
00470 
00471   Parameters            :       long nDeviceID  -       device id
00472 
00473   Return value          :       FEDM_OK or error code (<0)
00474 ***************************************************************************/
00475 int FEDM_ISCReaderModule::ConnectUSB(unsigned long dwDeviceID)
00476 {
00477         FEDM_SETPROP2(m_pLogger, FELOGMNG_PROP_DEVICED_ID, (unsigned int)dwDeviceID);
00478         FEDM_TRACE_FNC(m_pLogger, FELOGMNG_DBG_FUNCTION_CALL | FELOGMNG_DBG_LF_ADMIN, __FUNCTION__, FELOGMNG_DBG_FUNCTION_PARAMETER, "Device-ID=" << dwDeviceID);
00479 
00480 #ifdef _FEDM_USB_SUPPORT
00481         if(m_iCommMode != FEDM_COMM_MODE_UNDEF)
00482         {
00483                 FEDM_TRACE(m_pLogger, FELOGMNG_DBG_ERROR, __FUNCTION__ << " " << GetErrorText(FEDM_ERROR_ALREADY_CONNECTED));
00484                 FEDM_RETURN(FEDM_ERROR_ALREADY_CONNECTED);
00485         }
00486 
00487         bool bOpen = false;
00488         int iBack = 0;
00489         int iPortHnd = 0;
00490         int iReaderHnd = 0;
00491         char cDeviceID[32];
00492 
00493 #if !defined(_FEDM_SUPPORT_SLINK)
00494         LPFN_FEUSB_GET_DEVICE_HND       lpfnGetDeviceHnd        = (LPFN_FEUSB_GET_DEVICE_HND)GetFeUsbFunction(FEUSB_GET_DEVICE_HND);
00495         LPFN_FEUSB_OPEN_DEVICE          lpfnOpenDevice          = (LPFN_FEUSB_OPEN_DEVICE)GetFeUsbFunction(FEUSB_OPEN_DEVICE);
00496         LPFN_FEUSB_CLOSE_DEVICE         lpfnCloseDevice         = (LPFN_FEUSB_CLOSE_DEVICE)GetFeUsbFunction(FEUSB_CLOSE_DEVICE);
00497         LPFN_FEUSB_SCAN_AND_OPEN        lpfnScanAndOpen         = (LPFN_FEUSB_SCAN_AND_OPEN)GetFeUsbFunction(FEUSB_SCAN_AND_OPEN);
00498         LPFN_FEUSB_SCAN                         lpfnScan                        = (LPFN_FEUSB_SCAN)GetFeUsbFunction(FEUSB_SCAN);
00499         LPFN_FEUSB_GET_SCAN_LIST_SIZE   lpfnGetScanListSize     = (LPFN_FEUSB_GET_SCAN_LIST_SIZE)GetFeUsbFunction(FEUSB_GET_SCAN_LIST_SIZE);
00500         LPFN_FEUSB_GET_SCAN_LIST_PARA   lpfnGetScanListPara     = (LPFN_FEUSB_GET_SCAN_LIST_PARA)GetFeUsbFunction(FEUSB_GET_SCAN_LIST_PARA);
00501         LPFN_FEUSB_CLEAR_SCAN_LIST      lpfnClearScanList       = (LPFN_FEUSB_CLEAR_SCAN_LIST)GetFeUsbFunction(FEUSB_CLEAR_SCAN_LIST);
00502         LPFN_FEUSB_GET_DEVICE_PARA      lpfnGetDevicePara       = (LPFN_FEUSB_GET_DEVICE_PARA)GetFeUsbFunction(FEUSB_GET_DEVICE_PARA);
00503 
00504         FEDM_CHK5(lpfnGetDeviceHnd);
00505         FEDM_CHK5(lpfnOpenDevice);
00506         FEDM_CHK5(lpfnCloseDevice);
00507         FEDM_CHK5(lpfnScanAndOpen);
00508         FEDM_CHK5(lpfnScan);
00509         FEDM_CHK5(lpfnGetScanListSize);
00510         FEDM_CHK5(lpfnGetScanListPara);
00511         FEDM_CHK5(lpfnClearScanList);
00512         FEDM_CHK5(lpfnGetDevicePara);
00513 #endif
00514 
00515         if(dwDeviceID == 0)
00516         {
00517 #if !defined(_FEDM_SUPPORT_SLINK)
00518                 lpfnClearScanList();
00519 //              iPortHnd = lpfnScanAndOpen(FEUSB_SCAN_FIRST, NULL);
00520                 FEDM_CHK2(iBack, lpfnScan(FEUSB_SCAN_ALL, NULL));
00521                 iBack = lpfnGetScanListSize();
00522                 if(iBack > 0)
00523                 {
00524                         // take the first device
00525                         lpfnGetScanListPara(0, "Device-ID", cDeviceID);
00526                         sscanf((const char*)cDeviceID, "%lx", &dwDeviceID);
00527                         iPortHnd = lpfnOpenDevice(dwDeviceID);
00528                 }
00529 #else
00530                 FEUSB_ClearScanList();
00531 //              iPortHnd = FEUSB_ScanAndOpen(FEUSB_SCAN_FIRST, NULL);
00532                 FEDM_CHK2(iBack, FEUSB_Scan(FEUSB_SCAN_ALL, NULL));
00533                 iBack = FEUSB_GetScanListSize();
00534                 if(iBack > 0)
00535                 {
00536                         // take the first device
00537                         FEUSB_GetScanListPara(0, "Device-ID", cDeviceID);
00538                         sscanf((const char*)cDeviceID, "%lx", &dwDeviceID);
00539                         iPortHnd = FEUSB_OpenDevice(dwDeviceID);
00540                 }
00541 #endif
00542                 if(iPortHnd < 0)
00543                 {
00544                         FEDM_RETURN(iPortHnd);
00545                 }
00546                 bOpen = true;
00547         }
00548         else
00549         {
00550                 // is port still open?
00551 #if !defined(_FEDM_SUPPORT_SLINK)
00552                 iPortHnd = lpfnGetDeviceHnd(dwDeviceID);
00553 #else
00554                 iPortHnd = FEUSB_GetDeviceHnd(dwDeviceID);
00555 #endif
00556                 if(iPortHnd <= 0)
00557                 {
00558                         // open port
00559 #if !defined(_FEDM_SUPPORT_SLINK)
00560 //                      iBack = lpfnScan(FEUSB_SCAN_NEW, NULL);
00561                         iBack = lpfnScan(FEUSB_SCAN_ALL, NULL);
00562                         iPortHnd = lpfnOpenDevice(dwDeviceID);
00563 #else
00564 //                      iBack = FEUSB_Scan(FEUSB_SCAN_NEW, NULL);
00565                         iBack = FEUSB_Scan(FEUSB_SCAN_ALL, NULL);
00566                         iPortHnd = FEUSB_OpenDevice(dwDeviceID);
00567 #endif
00568                         if(iPortHnd < 0)
00569                         {
00570                                 FEDM_RETURN(iPortHnd);
00571                         }
00572                         bOpen = true;
00573                 }
00574         }
00575 
00576         if(m_iReaderHnd == 0)
00577         {
00578                 // create new reader object in FEISC
00579                 iReaderHnd = FEISC_NewReader(iPortHnd);
00580                 if(iReaderHnd < 0)
00581                 {
00582                         if(bOpen)
00583                         {
00584 #if !defined(_FEDM_SUPPORT_SLINK)
00585                                 lpfnCloseDevice(iPortHnd);      // close port, if this has open it
00586 #else
00587                                 FEUSB_CloseDevice(iPortHnd);    // close port, if this has open it
00588 #endif
00589                         }
00590                         FEDM_RETURN(iReaderHnd);
00591                 }
00592 
00593                 // save reader handle (see FEDM_DataBase)
00594                 m_iReaderHnd = iReaderHnd;
00595                 FEISC_SetReaderPara(m_iReaderHnd, "LOGPROT", "1");
00596         }
00597 
00598         // save port handle
00599         SetPortHnd(iPortHnd);
00600         // set communication mode
00601         m_iCommMode = FEDM_COMM_MODE_USB;
00602 
00603 
00604         // get TR-RESPONSE-TIME from reader and initialize USB-Timeout
00605         // for future use
00606         /*char cTmp[128];
00607         int iMultiplier = 5;
00608         unsigned int uiTrResponseTime = 0;
00609         GetPortPara("DeviceName", cTmp);
00610         if(strcmp(cTmp, "ID CPR.04-USB") == 0)
00611                 SetProtocolFrameSupport(FEDM_PRT_FRAME_STANDARD);
00612         else
00613                 SetProtocolFrameSupport(FEDM_PRT_FRAME_ADVANCED);
00614 
00615         SetData(FEDM_ISC_TMP_READ_CFG,          (unsigned char)0);
00616         SetData(FEDM_ISC_TMP_READ_CFG_ADR,      (unsigned char)1);
00617         SetData(FEDM_ISC_TMP_READ_CFG_LOC,      false);
00618 
00619         iBack = SendProtocol(0x80);
00620         if(iBack == 0x00)
00621         {
00622                 GetPortPara("FamilyName", cTmp);
00623                 if(strcmp(cTmp, "OBID classic-pro") == 0 || strcmp(cTmp, "OBID myAXXESS") == 0)
00624                 {
00625                         iMultiplier = 100;
00626                 }
00627                 else if(strcmp(cTmp, "OBID i-scan Midrange") == 0)
00628                 {
00629                         GetPortPara("DeviceName", cTmp);
00630                         if(strcmp(cTmp, "ID ISC.MR101-U") == 0 || strcmp(cTmp, "ID ISC.PR101-U") == 0 || strcmp(cTmp, "ID ISC.PRH101-U") == 0)
00631                                 iMultiplier = 100;
00632                 }
00633 
00634                 GetConfigPara(ReaderConfig::AirInterface::TimeLimit, &uiTrResponseTime, false);
00635                 if((uiTrResponseTime*iMultiplier) < 3000)
00636                         iBack = SetPortPara("Timeout", (int)3000);
00637                 else
00638                         iBack = SetPortPara("Timeout", (int)((uiTrResponseTime*iMultiplier) + 100));
00639         }*/
00640 
00641 
00642         FEDM_RETURN(FEDM_OK);
00643 #else
00644         FEDM_RETURN(FEDM_ERROR_UNSUPPORTED);
00645 #endif
00646 }
00647 
00648 /***************************************************************************
00649   Begin                 :       06.11.2003 / M. Hultsch
00650 
00651   Version               :       04.00.00 / 21.07.2011 / M. Hultsch
00652                                                 - TCP: return of last state, if not TIME_WAIT
00653 
00654                                                 03.00.05 / 26.02.2009 / M. Hultsch
00655 
00656   Function                      :       - deletes reader object in FEISC
00657                                                 - close serial port in FECOM or FETCP or FEUSB,
00658                                                   if no other FEDM_ISCReaderModule object use this port
00659 
00660   Parameters            :       -
00661 
00662   Return value          :        0      - FEDM_OK
00663                                                 >0      - last TCP state
00664                                                 <0      - error code
00665 ***************************************************************************/
00666 int FEDM_ISCReaderModule::DisConnect()
00667 {
00668         FEDM_TRACE(m_pLogger, FELOGMNG_DBG_FUNCTION_CALL | FELOGMNG_DBG_LF_ADMIN, __FUNCTION__);
00669 
00670         if(m_iCommMode == FEDM_COMM_MODE_UNDEF)
00671         {
00672                 FEDM_TRACE(m_pLogger, FELOGMNG_DBG_ERROR, __FUNCTION__ << " " << GetErrorText(FEDM_ERROR_NOT_CONNECTED));
00673                 FEDM_RETURN(FEDM_ERROR_NOT_CONNECTED);
00674         }
00675 
00676         bool bCanClose = true;
00677         int iNextHnd = 0;
00678         int iPortHnd = 0;
00679         int iHnd;
00680         int iErr;
00681         char cPortHnd[11];
00682 
00683 
00684         // query the reader object in FEISC
00685         if(m_iReaderHnd > 0)
00686         {
00687                 // query the port handle before deletion of reader object
00688                 cPortHnd[0] = '\0';
00689                 FEDM_CHK2(iErr, FEISC_GetReaderPara(m_iReaderHnd, "PortHnd", cPortHnd));
00690                 sscanf(cPortHnd, "%d", &iPortHnd);
00691 
00692                 if(iPortHnd <= 0)
00693                 {
00694                         m_iCommMode = FEDM_COMM_MODE_UNDEF;
00695                         FEDM_TRACE(m_pLogger, FELOGMNG_DBG_ERROR, __FUNCTION__ << " " << GetErrorText(FEDM_ERROR_NOT_CONNECTED));
00696                         FEDM_RETURN(FEDM_ERROR_NOT_CONNECTED);
00697                 }
00698         }
00699 
00700 
00701         // check, if port can be closed
00702         // port will only been closed, if no other reader object uses it
00703         iNextHnd = FEISC_GetReaderList(0);
00704         while(iNextHnd > 0)
00705         {
00706                 cPortHnd[0] = '\0';
00707                 iErr = FEISC_GetReaderPara(iNextHnd, "PortHnd", cPortHnd);
00708                 if(iErr < 0)
00709                         break;
00710 
00711                 sscanf(cPortHnd, "%d", &iHnd);
00712                 if((m_iReaderHnd != iNextHnd) && (iHnd == iPortHnd))
00713                 {
00714                         bCanClose = false;      // another FEDM_ISCReaderModule object uses this port
00715                         break;
00716                 }
00717 
00718                 iNextHnd = FEISC_GetReaderList(iNextHnd);
00719         }
00720         
00721 
00722         // close port
00723         if(bCanClose)
00724         {
00725                 if(m_iCommMode == FEDM_COMM_MODE_SERIAL)
00726                 {
00727 #ifdef _FEDM_COM_SUPPORT
00728         #if !defined(_FEDM_SUPPORT_SLINK)
00729                         LPFN_FECOM_CLOSE_PORT lpfnClosePort = (LPFN_FECOM_CLOSE_PORT)GetFeComFunction(FECOM_CLOSE_PORT);
00730                         FEDM_CHK5(lpfnClosePort);
00731                         iErr = lpfnClosePort(iPortHnd);
00732                         if(iErr < 0)
00733                         {
00734                                 m_iCommMode = FEDM_COMM_MODE_UNDEF;
00735                                 SetPortHnd(0);
00736                         }
00737         #else
00738                         iErr = FECOM_ClosePort(iPortHnd);
00739                         if(iErr < 0)
00740                         {
00741                                 m_iCommMode = FEDM_COMM_MODE_UNDEF;
00742                                 SetPortHnd(0);
00743                         }
00744         #endif
00745 #endif
00746                 }
00747                 else if(m_iCommMode == FEDM_COMM_MODE_TCP)
00748                 {
00749 #ifdef _FEDM_TCP_SUPPORT
00750         #if !defined(_FEDM_SUPPORT_SLINK)
00751                         LPFN_FETCP_DISCONNECT lpfnDisConnect = (LPFN_FETCP_DISCONNECT)GetFeTcpFunction(FETCP_DISCONNECT);
00752                         FEDM_CHK5(lpfnDisConnect);
00753                         iErr = lpfnDisConnect(iPortHnd);
00754                         if(iErr < 0)
00755                         {
00756                                 m_iCommMode = FEDM_COMM_MODE_UNDEF;
00757                                 SetPortHnd(0);
00758                         }
00759         #else
00760                         iErr = FETCP_DisConnect(iPortHnd);
00761                         if(iErr < 0)
00762                         {
00763                                 m_iCommMode = FEDM_COMM_MODE_UNDEF;
00764                                 SetPortHnd(0);
00765                         }
00766         #endif
00767                         if(iErr > 0)
00768                         {
00769                                 m_iCommMode = FEDM_COMM_MODE_UNDEF;
00770                                 SetPortHnd(0);
00771                                 SetLastError(0);
00772                                 return iErr; // return of last state
00773                         }
00774 #endif
00775                 }
00776                 else if(m_iCommMode == FEDM_COMM_MODE_USB)
00777                 {
00778 #ifdef _FEDM_USB_SUPPORT
00779         #if !defined(_FEDM_SUPPORT_SLINK)
00780                         LPFN_FEUSB_CLOSE_DEVICE lpfnCloseDevice = (LPFN_FEUSB_CLOSE_DEVICE)GetFeUsbFunction(FEUSB_CLOSE_DEVICE);
00781                         LPFN_FEUSB_SCAN lpfnScan = (LPFN_FEUSB_SCAN)GetFeUsbFunction(FEUSB_SCAN);
00782                         FEDM_CHK5(lpfnCloseDevice);
00783                         FEDM_CHK5(lpfnScan);
00784                         iErr = lpfnCloseDevice(iPortHnd);
00785                         if(iErr < 0)
00786                         {
00787                                 m_iCommMode = FEDM_COMM_MODE_UNDEF;
00788                                 SetPortHnd(0);
00789                         }
00790                         FEDM_CHK2(iErr, lpfnScan(FEUSB_SCAN_PACK, NULL));
00791         #else
00792                         iErr = FEUSB_CloseDevice(iPortHnd);
00793                         if(iErr < 0)
00794                         {
00795                                 m_iCommMode = FEDM_COMM_MODE_UNDEF;
00796                                 SetPortHnd(0);
00797                         }
00798                         FEDM_CHK2(iErr, FEUSB_Scan(FEUSB_SCAN_PACK, NULL));
00799         #endif
00800 #endif
00801                 }
00802         }
00803 
00804         // reset communication mode
00805         m_iCommMode = FEDM_COMM_MODE_UNDEF;
00806         SetPortHnd(0);
00807 
00808         FEDM_RETURN(FEDM_OK);
00809 }
00810 
00811 /***************************************************************************
00812   Begin                 :       07.11.2003 / M. Hultsch
00813 
00814   Version               :       01.09.00 / 07.11.2003 / M. Hultsch
00815 
00816   Function                      :       - checks, if reader module is connected to a port
00817 
00818   Parameters            :       -
00819 
00820   Return value          :       true/false
00821 ***************************************************************************/
00822 bool FEDM_ISCReaderModule::IsConnected()
00823 {
00824         if(m_iCommMode == FEDM_COMM_MODE_UNDEF)
00825         {
00826                 if(FEDM_IS_PIPORT(GetPortHnd()))
00827                 {
00828                         // communication with plug-in port module
00829                         return true;
00830                 }
00831 
00832                 return false;
00833         }
00834 
00835         return true;
00836 }
00837 
00838 /***************************************************************************
00839   Begin                 :       18.07.2011 / M. Hultsch
00840 
00841   Version               :       04.00.00 / 21.07.2011 / M. Hultsch
00842 
00843   Function                      :       returns the actual state of an open socket
00844 
00845   Parameters            :       -
00846 
00847   Return value          :       <0 error code
00848                                                 >0 TCP state:
00849                                                 FETCP_STATE_CLOSED                       1
00850                                                 FETCP_STATE_LISTEN                       2
00851                                                 FETCP_STATE_SYN_SENT                     3
00852                                                 FETCP_STATE_SYN_RCVD                     4
00853                                                 FETCP_STATE_ESTABLISHED                  5
00854                                                 FETCP_STATE_FIN_WAIT1                    6
00855                                                 FETCP_STATE_FIN_WAIT2                    7
00856                                                 FETCP_STATE_CLOSE_WAIT                   8
00857                                                 FETCP_STATE_CLOSING                      9
00858                                                 FETCP_STATE_LAST_ACK                    10
00859                                                 FETCP_STATE_TIME_WAIT                   11
00860 
00861 ***************************************************************************/
00862 int FEDM_ISCReaderModule::GetTcpConnectionState()
00863 {
00864 #ifdef _FEDM_TCP_SUPPORT
00865         if(m_iCommMode != FEDM_COMM_MODE_TCP)
00866         {
00867                 FEDM_TRACE(m_pLogger, FELOGMNG_DBG_ERROR, __FUNCTION__ << " " << GetErrorText(FEDM_ERROR_UNSUPPORTED));
00868                 FEDM_RETURN(FEDM_ERROR_UNSUPPORTED);
00869         }
00870 
00871         int iPortNr = 0;
00872         char cHostAdr[32];
00873 
00874         GetPortPara("HOSTADR", cHostAdr);
00875         GetPortPara("PORTNR", &iPortNr);
00876 
00877         #if !defined(_FEDM_SUPPORT_SLINK)
00878                 LPFN_FETCP_GET_SOCKET_STATE lpfnGetSocketState = (LPFN_FETCP_GET_SOCKET_STATE)GetFeTcpFunction(FETCP_GET_SOCKET_STATE);
00879                 FEDM_CHK5(lpfnGetSocketState);
00880                 SetLastError(0);
00881                 return lpfnGetSocketState(cHostAdr, iPortNr);
00882         #else
00883                 SetLastError(0);
00884                 return FETCP_GetSocketState(cHostAdr, iPortNr);
00885         #endif
00886 #else
00887         FEDM_RETURN(FEDM_ERROR_UNSUPPORTED);
00888 #endif
00889 }
00890 
00891 
00892 /***************************************************************************
00893   Begin                 :       29.01.2010 / M. Hultsch
00894 
00895   Version               :       03.00.19 / 29.10.2010 / M. Hultsch
00896 
00897   Function                      :       start of Authentication process
00898 
00899   Parameters            :       unsigned char ucAuthentType     - authentication type (e.g. AES256)
00900                                                                                                           0 : AES 128
00901                                                                                                           1 : AES 192
00902                                                                                                           2 : AES 256
00903                                                 string sAuthentKey                      - authentication key
00904 
00905   Return value          :       FEDM_OK (0) or error code (<0) or status byte (>0)
00906 ***************************************************************************/
00907 int FEDM_ISCReaderModule::ReaderAuthentication(unsigned char ucAuthentType, string sAuthentKey)
00908 {
00909         FEDM_TRACE_FNC(m_pLogger, FELOGMNG_DBG_FUNCTION_CALL | FELOGMNG_DBG_LF_COMM_HIGH_LEVEL, __FUNCTION__, FELOGMNG_DBG_FUNCTION_PARAMETER, "AuthentType=" << (int)ucAuthentType);
00910 
00911         switch(ucAuthentType)
00912         {
00913         case 0: // AES 128 Bit
00914                 if(sAuthentKey.length() != 32)
00915                 {
00916                         FEDM_TRACE(m_pLogger, FELOGMNG_DBG_ERROR, __FUNCTION__ << " " << GetErrorText(FEDM_ERROR_STRING_LENGTH));
00917                         FEDM_RETURN(FEDM_ERROR_STRING_LENGTH);
00918                 }
00919                 break;
00920 
00921         case 1: // AES 192 Bit
00922                 if(sAuthentKey.length() != 48)
00923                 {
00924                         FEDM_TRACE(m_pLogger, FELOGMNG_DBG_ERROR, __FUNCTION__ << " " << GetErrorText(FEDM_ERROR_STRING_LENGTH));
00925                         FEDM_RETURN(FEDM_ERROR_STRING_LENGTH);
00926                 }
00927                 break;
00928 
00929         case 2: // AES 256 Bit
00930                 if(sAuthentKey.length() != 64)
00931                 {
00932                         FEDM_TRACE(m_pLogger, FELOGMNG_DBG_ERROR, __FUNCTION__ << " " << GetErrorText(FEDM_ERROR_STRING_LENGTH));
00933                         FEDM_RETURN(FEDM_ERROR_STRING_LENGTH);
00934                 }
00935                 break;
00936 
00937         default:
00938                 FEDM_TRACE(m_pLogger, FELOGMNG_DBG_ERROR, __FUNCTION__ << " " << GetErrorText(FEDM_ERROR_PARAMETER));
00939                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
00940         }
00941 
00942         return FEISC_0xAE_ReaderAuthent(m_iReaderHnd, 
00943                                                                         m_ucBusAdr,
00944                                                                         0,
00945                                                                         ucAuthentType,
00946                                                                         (unsigned char)sAuthentKey.length(),
00947                                                                         (unsigned char*)sAuthentKey.c_str(),
00948                                                                         1);
00949 }
00950 
00951 
00952 /***************************************************************************
00953   Begin                 :       29.01.2010 / M. Hultsch
00954 
00955   Version               :       03.00.19 / 29.10.2010 / M. Hultsch
00956 
00957   Function                      :       start of Authentication process
00958 
00959   Parameters            :       unsigned char ucAuthentType     - authentication type (e.g. AES256)
00960                                                                                                           0 : AES 128
00961                                                                                                           1 : AES 192
00962                                                                                                           2 : AES 256
00963                                                 unsigned int uiAuthentKeyLength - length in bytes of AuthentKey
00964                                                 unsigned char* ucAuthentKey     - buffer with authentication key
00965 
00966   Return value          :       FEDM_OK (0) or error code (<0) or status byte (>0)
00967 ***************************************************************************/
00968 int FEDM_ISCReaderModule::ReaderAuthentication(unsigned char ucAuthentType, unsigned int uiAuthentKeyLength, unsigned char* ucAuthentKey)
00969 {
00970         FEDM_TRACE_FNC(m_pLogger, FELOGMNG_DBG_FUNCTION_CALL | FELOGMNG_DBG_LF_COMM_HIGH_LEVEL, __FUNCTION__, FELOGMNG_DBG_FUNCTION_PARAMETER, "AuthentType=" << (int)ucAuthentType);
00971 
00972         FEDM_CHK5(ucAuthentKey);
00973 
00974         switch(ucAuthentType)
00975         {
00976         case 0: // AES 128 Bit
00977                 if(uiAuthentKeyLength != 16)
00978                 {
00979                         FEDM_TRACE(m_pLogger, FELOGMNG_DBG_ERROR, __FUNCTION__ << " " << GetErrorText(FEDM_ERROR_STRING_LENGTH));
00980                         FEDM_RETURN(FEDM_ERROR_STRING_LENGTH);
00981                 }
00982                 break;
00983 
00984         case 1: // AES 192 Bit
00985                 if(uiAuthentKeyLength != 24)
00986                 {
00987                         FEDM_TRACE(m_pLogger, FELOGMNG_DBG_ERROR, __FUNCTION__ << " " << GetErrorText(FEDM_ERROR_STRING_LENGTH));
00988                         FEDM_RETURN(FEDM_ERROR_STRING_LENGTH);
00989                 }
00990                 break;
00991 
00992         case 2: // AES 256 Bit
00993                 if(uiAuthentKeyLength != 32)
00994                 {
00995                         FEDM_TRACE(m_pLogger, FELOGMNG_DBG_ERROR, __FUNCTION__ << " " << GetErrorText(FEDM_ERROR_STRING_LENGTH));
00996                         FEDM_RETURN(FEDM_ERROR_STRING_LENGTH);
00997                 }
00998                 break;
00999 
01000         default:
01001                 FEDM_TRACE(m_pLogger, FELOGMNG_DBG_ERROR, __FUNCTION__ << " " << GetErrorText(FEDM_ERROR_PARAMETER));
01002                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
01003         }
01004 
01005         return FEISC_0xAE_ReaderAuthent(m_iReaderHnd, 
01006                                                                         m_ucBusAdr,
01007                                                                         0,
01008                                                                         ucAuthentType,
01009                                                                         (unsigned char)uiAuthentKeyLength,
01010                                                                         ucAuthentKey,
01011                                                                         0);
01012 }
01013 
01014 
01015 /***************************************************************************
01016   Begin                 :       04.01.2007 / M. Hultsch
01017 
01018   Version               :       03.00.00 / 25.08.2008 / M. Hultsch
01019 
01020   Function                      :       - set of communication handle, if connection is established
01021                                                   with communication library FECOM, FEUSB or FETCP
01022 
01023   Parameters            :       -
01024 
01025   Return value          :       true/false
01026 ***************************************************************************/
01027 int FEDM_ISCReaderModule::SetPortHnd(int iPortHnd)
01028 {
01029         int iErr = 0;
01030 
01031         FEDM_CHK2(iErr, FEDM_ISCReader::SetPortHnd(iPortHnd));
01032 
01033         if(iPortHnd > 0)
01034         {
01035                 if(FEDM_IS_COMPORT(iPortHnd))
01036                         m_iCommMode = FEDM_COMM_MODE_SERIAL;
01037                 else if(FEDM_IS_USBPORT(iPortHnd))
01038                         m_iCommMode = FEDM_COMM_MODE_USB;
01039                 else if(FEDM_IS_TCPPORT(iPortHnd))
01040                         m_iCommMode = FEDM_COMM_MODE_TCP;
01041                 else
01042                         m_iCommMode = FEDM_COMM_MODE_UNDEF;
01043         }
01044         else
01045         {
01046                 m_iCommMode = FEDM_COMM_MODE_UNDEF;
01047         }
01048 
01049         return FEDM_OK;
01050 }
01051 
01052 
01054 // methods for tag communication
01056 
01057 /***************************************************************************
01058   Begin                 :       01.04.2009 / M. Hultsch
01059   
01060   Version               :       04.00.02 / 11.08.2011 / M. Hultsch
01061                                                 - check of identical UID
01062 
01063                                                 03.00.12 / 23.09.2009 / M. Hultsch
01064 
01065   Function                      :       method executes synchronous Inventory (for all i-scan and classic-pro Readers)
01066                                                 Inventory with More-Data handling (preset by bAll)
01067                                                 NOTE: all MODE flags must be set before invoke of TagInventory
01068                                                           and will be respected, except MORE
01069 
01070   Parameters            :       bool bAll (=true)                               - automatic mode with internal ResetTable and MORE-loop
01071                                                 unsigned char ucMode (=0x00)    - manual control of inventory (if bAll=true, MORE-Flag will be ignored)
01072                                                 unsigned char ucAntennas (=1)   - flag field with antennas (only for i-scan Readers)
01073 
01074   Return value          :       FEDM_ISC_TAG_LIST*
01075 ***************************************************************************/
01076 #ifdef _FEDM_TAG_HANDLER
01077 FEDM_ISC_TAG_LIST* FEDM_ISCReaderModule::TagInventory(  bool bAll,
01078                                                                                                                 unsigned char ucMode,
01079                                                                                                                 unsigned char ucAntennas )
01080 {
01081         FEDM_TRACE_FNC(m_pLogger, FELOGMNG_DBG_FUNCTION_CALL | FELOGMNG_DBG_LF_COMM_TAG_HANDLER, __FUNCTION__, FELOGMNG_DBG_FUNCTION_PARAMETER, "bAll=" << (int)bAll << ", Mode=0x" << std::hex << std::uppercase << (int)ucMode << ", Antennas=0x" << std::hex << std::uppercase << (int)ucAntennas);
01082 
01083         string sSnr;
01084 
01085         m_mapTagHandler.clear();
01086         SetLastError(FEDM_OK);
01087 
01088         // command byte for inventory
01089         SetData(FEDM_ISC_TMP_B0_CMD, (unsigned char)0x01);
01090 
01091         if(bAll)
01092         {
01093                 SetData(FEDM_ISC_TMP_B0_MODE, ucMode);
01094                 SetData(FEDM_ISC_TMP_B0_MODE_MORE, false);
01095                 ResetTable(FEDM_ISC_ISO_TABLE);
01096         }
01097         else
01098         {
01099                 SetData(FEDM_ISC_TMP_B0_MODE, ucMode);
01100         }
01101 
01102         if(ucMode & FEDM_ISC_ISO_MODE_ANT)
01103                 SetData(FEDM_ISC_TMP_B0_REQ_ANT_SEL, ucAntennas);
01104 
01105         // synchronous execution of inventory command
01106         int iBack = SendProtocol(0xB0);
01107         if( ! ( iBack==0x00 || 
01108                         iBack==0x01 || 
01109                         iBack==0x02 || 
01110                         iBack==0x03 || 
01111                         iBack==0x83 || 
01112                         iBack==0x84 || 
01113                         iBack==0x90 || 
01114                         iBack==0x93 || 
01115                         iBack==0x94 || 
01116                         iBack==0x95 ) )
01117         {
01118                 SetLastError(iBack);
01119                 return &m_mapTagHandler;
01120         }
01121 
01122         if( bAll )
01123         {
01124                 while(iBack == 0x94) // more data
01125                 {
01126                         SetData(FEDM_ISC_TMP_B0_MODE_MORE, true);
01127                         iBack = SendProtocol(0xB0);
01128                 }
01129         }
01130 
01131         if( m_bEnableTagHandler )
01132         {
01133                 // build new tag handler list
01134                 for(unsigned int uiCnt=0; uiCnt<m_uiISOTableLength; uiCnt++)
01135                 {
01136                         if(m_ISOTable[uiCnt]->m_pTagHandler != NULL)
01137                         {
01138                                 if(m_ISOTable[uiCnt]->GetSnr(sSnr) != FEDM_OK)
01139                                         continue;
01140 
01141                                 // check for double UID; identical UID is ignored
01142                                 if( m_mapTagHandler.find(sSnr) != m_mapTagHandler.end())
01143                                         continue;
01144 
01145                                 m_mapTagHandler.insert(make_pair(sSnr, m_ISOTable[uiCnt]->m_pTagHandler));
01146                         }
01147                 }
01148         }
01149 
01150         return &m_mapTagHandler;
01151 }
01152 #endif
01153 
01154 
01155 /***************************************************************************
01156   Begin                 :       01.04.2009 / M. Hultsch
01157   
01158   Version               :       04.05.03 / 30.08.2013 / M. Hultsch
01159                                                 - bugfix for UID-Length != 8
01160 
01161                                                 04.02.01 / 31.05.2012 / M. Hultsch
01162                                                 - support for Innovatron and ASK CTx
01163 
01164                                                 03.00.12 / 01.09.2009 / M. Hultsch
01165 
01166   Function                      :       Select of transponder
01167                                                 - with automatic CINF-flag for classic-pro Reader
01168 
01169   Parameters            :       FedmIscTagHandler*                      - pointer to tag handler base class
01170                                                 unsigned int uiTagDriver        - optional: for explizit tag driver selection  in reader
01171 
01172   Return value          :       FedmIscTagHandler*      - pointer to new tag handler (base class) of selected tag
01173                                                                                           or NULL       -       in error case
01174                                                                                                                 -       if no tag could be selected
01175                                                                                                                 -       if transponder type could not be identified
01176 ***************************************************************************/
01177 #ifdef _FEDM_TAG_HANDLER
01178 FedmIscTagHandler* FEDM_ISCReaderModule::TagSelect(     FedmIscTagHandler* pTagHandler,
01179                                                                                                         unsigned int uiTagDriver )
01180 {
01181         FEDM_TRACE_FNC(m_pLogger, FELOGMNG_DBG_FUNCTION_CALL | FELOGMNG_DBG_LF_COMM_TAG_HANDLER, __FUNCTION__, FELOGMNG_DBG_FUNCTION_PARAMETER, "TagDriver=" << uiTagDriver);
01182         
01183         SetLastError(FEDM_OK);
01184 
01185         if( !m_bEnableTagHandler )
01186         {
01187                 FEDM_TRACE(m_pLogger, FELOGMNG_DBG_ERROR, __FUNCTION__ << " Support for TagHandler disabled");
01188                 SetLastError(FEDM_ERROR_UNSUPPORTED);
01189                 return NULL;
01190         }
01191 
01192         if(pTagHandler == NULL)
01193         {
01194                 FEDM_TRACE(m_pLogger, FELOGMNG_DBG_ERROR, __FUNCTION__ << " TagHandler is NULL");
01195                 SetLastError(FEDM_ERROR_NULL_POINTER);
01196                 return NULL;
01197         }
01198 
01199         int iBack = 0;
01200         int iErr = 0;
01201 
01202         // prepare select command
01203         FEDM_CHK7(iErr, SetData(FEDM_ISC_TMP_B0_MODE, (unsigned char)0));
01204         FEDM_CHK7(iErr, SetData(FEDM_ISC_TMP_B0_MODE_ADR, (unsigned char)FEDM_ISC_ISO_MODE_ADR));
01205         if( m_bSelectWithCinf && (!m_bDisableSelectWithCinf) )
01206         {
01207                 FEDM_CHK7(iErr, SetData(FEDM_ISC_TMP_B0_MODE_CINF, true));
01208         }
01209 
01210         // manual selection of special transponder driver
01211         if(uiTagDriver > 0)
01212         {
01213                 FEDM_CHK7(iErr, SetData(FEDM_ISC_TMP_B0_MODE_DRV_SEL, true));
01214                 FEDM_CHK7(iErr, SetData(FEDM_ISC_TMP_B0_REQ_TR_DRIVER, uiTagDriver));
01215         }
01216         else
01217         {
01218                 FEDM_CHK7(iErr, SetData(FEDM_ISC_TMP_B0_MODE_DRV_SEL, false));
01219         }
01220 
01221         if(strlen(pTagHandler->GetUID()) != 16)
01222         {
01223                 FEDM_CHK7(iErr, SetData(FEDM_ISC_TMP_B0_MODE_UID_LF, true));
01224                 FEDM_CHK7(iErr, SetData(FEDM_ISC_TMP_B0_REQ_UID_LEN, (unsigned int)strlen(pTagHandler->GetUID()) >> 1 ));
01225         }
01226         FEDM_CHK7(iErr, SetData(FEDM_ISC_TMP_B0_REQ_UID, (char*)pTagHandler->GetUID(), (int)strlen(pTagHandler->GetUID())));
01227         
01228         FEDM_CHK7(iErr, SetData(FEDM_ISC_TMP_B0_CMD, (unsigned char)0x25));
01229 
01230         // execute select command
01231         iBack = SendProtocol(0xB0);
01232         if(iBack)
01233         {
01234                 SetLastError(iBack);
01235                 return NULL;
01236         }
01237 
01238         int iIdx = FindTableIndex(0, FEDM_ISC_ISO_TABLE, FEDM_ISC_DATA_IS_SELECTED, true);
01239         if(iIdx < 0)
01240                 return NULL;
01241 
01242         // create concrete transponder handler class
01243         switch(pTagHandler->m_pTabItem->m_ucTrType)
01244         {
01245         // HF transponder types
01246         case FEDM_ISC_TR_TYPE_ICODE1:
01247         case FEDM_ISC_TR_TYPE_TAGIT:
01248         case FEDM_ISC_TR_TYPE_ISO15693:
01249                 pTagHandler->m_bNonAddressedMode = false;
01250                 return pTagHandler;
01251 
01252 #if !defined(_FEDM_NO_TAG_HANDLER_ISO14443)
01253         case FEDM_ISC_TR_TYPE_ISO14443A:
01254         case FEDM_ISC_TR_TYPE_ISO14443B:
01255                 {
01256                         if(uiTagDriver > 0)
01257                         {
01258                                 return TagSelect_CreateNewTagHandler(iIdx, uiTagDriver, pTagHandler);
01259                         }
01260                         else
01261                         {
01262                                 unsigned char ucFormat = 0;
01263 
01264                                 FEDM_CHK7(iErr, GetData(FEDM_ISC_TMP_B0_RSP_FORMAT, &ucFormat));
01265                                 switch(ucFormat)
01266                                 {
01267                                 case 0: // no card info available
01268                                         return pTagHandler;
01269 
01270                                 case 1: // card info for ISO14443-4 type A transponder
01271                                         return TagSelect_EvaFormat1(iIdx, pTagHandler);
01272 
01273                                 case 2: // card info for ISO14443-3 or -4 type B transponder
01274                                         return TagSelect_EvaFormat2(iIdx, pTagHandler);
01275 
01276                                 case 3: // card info for ISO14443-3 type A transponder
01277                                         return TagSelect_EvaFormat3(iIdx, pTagHandler);
01278                                 }
01279                         }
01280                 }
01281                 break;
01282 #endif
01283 
01284         case FEDM_ISC_TR_TYPE_EPC:
01285         case FEDM_ISC_TR_TYPE_ICODE_UID:
01286         case FEDM_ISC_TR_TYPE_JEWEL:
01287         case FEDM_ISC_TR_TYPE_ISO18000_3M3:
01288         case FEDM_ISC_TR_TYPE_STM_SR176:
01289         case FEDM_ISC_TR_TYPE_STM_SRIxx:
01290         case FEDM_ISC_TR_TYPE_MCRFxxx:
01291         case FEDM_ISC_TR_TYPE_INNOVATRON:
01292         case FEDM_ISC_TR_TYPE_ASK_CTx:
01293         //case FEDM_ISC_TR_TYPE_0x64:
01294                 pTagHandler->m_bNonAddressedMode = false;
01295                 return pTagHandler;
01296 
01297         // UHF transponder types
01298         case FEDM_ISC_TR_TYPE_ISO18000_6_A:
01299         case FEDM_ISC_TR_TYPE_ISO18000_6_B:
01300         case FEDM_ISC_TR_TYPE_EM4222:
01301         case FEDM_ISC_TR_TYPE_EPC_CLASS1_GEN2:
01302         case FEDM_ISC_TR_TYPE_EPC_CLASS0:
01303         case FEDM_ISC_TR_TYPE_EPC_CLASS1_GEN1:
01304                 pTagHandler->m_bNonAddressedMode = false;
01305                 return pTagHandler;
01306         }
01307 
01308         FEDM_TRACE(m_pLogger, FELOGMNG_DBG_ERROR, __FUNCTION__ << " Unknown Transponder-Type 0x" << std::hex << std::uppercase << (int)pTagHandler->m_pTabItem->m_ucTrType);
01309         return NULL;
01310 }
01311 #endif
01312 
01313 
01314 
01315 
01317 // protected functions
01319 
01320 /***************************************************************************
01321   Begin                 :       01.09.2009 / M. Hultsch
01322   
01323   Version               :       04.00.08 / 05.01.2012 / M. Hultsch
01324                                                 - creation of TagHandler only if card type is changed
01325 
01326                                                 03.01.00 / 17.02.2010 / M. Hultsch
01327 
01328   Function                      :       create tag handler class identified by uiTagDriver
01329 
01330   Parameters            :       int iIdx                                        - index in FEDM_ISOTabItem
01331                                                 unsigned int uiTagDriver        - manual selected special tag driver
01332                                                                                                           value according system manual of Reader
01333                                                 FedmIscTagHandler*                      - pointer to tag handler base class
01334 
01335   Return value          :       FedmIscTagHandler*      - pointer to new tag handler (base class) of selected tag
01336                                                                                           or NULL       -       in error case
01337                                                                                                                 -       if transponder type could not be identified
01338 ***************************************************************************/
01339 #ifdef _FEDM_TAG_HANDLER
01340 #if !defined(_FEDM_NO_TAG_HANDLER_ISO14443)
01341 FedmIscTagHandler* FEDM_ISCReaderModule::TagSelect_CreateNewTagHandler(int iIdx, unsigned int uiTagDriver, FedmIscTagHandler* pTagHandler)
01342 {
01343         FEDM_TRACE_FNC(m_pLogger, FELOGMNG_DBG_FUNCTION_CALL | FELOGMNG_DBG_LF_COMM_TAG_HANDLER, __FUNCTION__, FELOGMNG_DBG_FUNCTION_PARAMETER, "TagDriver=" << uiTagDriver);
01344         
01345         if(dynamic_cast<FedmIscTagHandler_ISO14443*>(pTagHandler) == NULL)
01346         {
01347                 FEDM_TRACE(m_pLogger, FELOGMNG_DBG_ERROR, __FUNCTION__ << " TagHandler is not of type ISO 14443");
01348                 return NULL;
01349         }
01350 
01351         if(uiTagDriver == 1)
01352         {
01353                 if(pTagHandler->GetTagHandlerType() != FedmIscTagHandler::TYPE_ISO14443_4)
01354                 {
01355                         FedmIscTagHandler_ISO14443_4* pNewTagHandler = NULL;
01356                         pNewTagHandler = new FedmIscTagHandler_ISO14443_4(this, pTagHandler->m_pTabItem);
01357                         if(pNewTagHandler != NULL)
01358                         {
01359                                 delete pTagHandler;
01360                                 m_ISOTable[iIdx]->m_pTagHandler = (FedmIscTagHandler*)pNewTagHandler;
01361                                 return (FedmIscTagHandler*)pNewTagHandler;
01362                         }
01363                 }
01364                 else
01365                 {
01366                         pTagHandler->Init();
01367                         return pTagHandler;
01368                 }
01369         }
01370         else if(uiTagDriver == 2)
01371         {
01372                 if(pTagHandler->GetTagHandlerType() != FedmIscTagHandler::TYPE_ISO14443_3_MIFARE_CLASSIC)
01373                 {
01374                         FedmIscTagHandler_ISO14443_3_MIFARE_Classic* pNewTagHandler = NULL;
01375                         pNewTagHandler = new FedmIscTagHandler_ISO14443_3_MIFARE_Classic(this, pTagHandler->m_pTabItem);
01376                         if(pNewTagHandler != NULL)
01377                         {
01378                                 delete pTagHandler;
01379                                 m_ISOTable[iIdx]->m_pTagHandler = (FedmIscTagHandler*)pNewTagHandler;
01380                                 return (FedmIscTagHandler*)pNewTagHandler;
01381                         }
01382                 }
01383                 else
01384                 {
01385                         pTagHandler->Init();
01386                         return pTagHandler;
01387                 }
01388         }
01389         else if(uiTagDriver == 3)
01390         {
01391                 if(pTagHandler->GetTagHandlerType() != FedmIscTagHandler::TYPE_ISO14443_3_MIFARE_ULTRALIGHT)
01392                 {
01393                         FedmIscTagHandler_ISO14443_3_MIFARE_Ultralight* pNewTagHandler = NULL;
01394                         pNewTagHandler = new FedmIscTagHandler_ISO14443_3_MIFARE_Ultralight(this, pTagHandler->m_pTabItem);
01395                         if(pNewTagHandler != NULL)
01396                         {
01397                                 delete pTagHandler;
01398                                 m_ISOTable[iIdx]->m_pTagHandler = (FedmIscTagHandler*)pNewTagHandler;
01399                                 return (FedmIscTagHandler*)pNewTagHandler;
01400                         }
01401                 }
01402                 else
01403                 {
01404                         pTagHandler->Init();
01405                         return pTagHandler;
01406                 }
01407         }
01408         else if(uiTagDriver == 4)
01409         {
01410                 if(pTagHandler->GetTagHandlerType() != FedmIscTagHandler::TYPE_ISO14443_3_MIFARE_PLUS_SL1)
01411                 {
01412                         FedmIscTagHandler_ISO14443_3_MIFARE_Plus_SL1* pNewTagHandler = NULL;
01413                         pNewTagHandler = new FedmIscTagHandler_ISO14443_3_MIFARE_Plus_SL1(this, pTagHandler->m_pTabItem);
01414                         if(pNewTagHandler != NULL)
01415                         {
01416                                 delete pTagHandler;
01417                                 m_ISOTable[iIdx]->m_pTagHandler = (FedmIscTagHandler*)pNewTagHandler;
01418                                 return (FedmIscTagHandler*)pNewTagHandler;
01419                         }
01420                 }
01421                 else
01422                 {
01423                         pTagHandler->Init();
01424                         return pTagHandler;
01425                 }
01426         }
01427         else if(uiTagDriver == 5)
01428         {
01429                 if(pTagHandler->GetTagHandlerType() != FedmIscTagHandler::TYPE_ISO14443_4_MIFARE_PLUS_SL1)
01430                 {
01431                         FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL1* pNewTagHandler = NULL;
01432                         pNewTagHandler = new FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL1(this, pTagHandler->m_pTabItem);
01433                         if(pNewTagHandler != NULL)
01434                         {
01435                                 delete pTagHandler;
01436                                 m_ISOTable[iIdx]->m_pTagHandler = (FedmIscTagHandler*)pNewTagHandler;
01437                                 return (FedmIscTagHandler*)pNewTagHandler;
01438                         }
01439                 }
01440                 else
01441                 {
01442                         pTagHandler->Init();
01443                         return pTagHandler;
01444                 }
01445         }
01446         else if(uiTagDriver == 6)
01447         {
01448                 if(pTagHandler->GetTagHandlerType() != FedmIscTagHandler::TYPE_ISO14443_3_MIFARE_PLUS_SL2)
01449                 {
01450                         FedmIscTagHandler_ISO14443_3_MIFARE_Plus_SL2* pNewTagHandler = NULL;
01451                         pNewTagHandler = new FedmIscTagHandler_ISO14443_3_MIFARE_Plus_SL2(this, pTagHandler->m_pTabItem);
01452                         if(pNewTagHandler != NULL)
01453                         {
01454                                 delete pTagHandler;
01455                                 m_ISOTable[iIdx]->m_pTagHandler = (FedmIscTagHandler*)pNewTagHandler;
01456                                 return (FedmIscTagHandler*)pNewTagHandler;
01457                         }
01458                 }
01459                 else
01460                 {
01461                         pTagHandler->Init();
01462                         return pTagHandler;
01463                 }
01464         }
01465         else if(uiTagDriver == 7)
01466         {
01467                 if(pTagHandler->GetTagHandlerType() != FedmIscTagHandler::TYPE_ISO14443_4_MIFARE_PLUS_SL2)
01468                 {
01469                         FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL2* pNewTagHandler = NULL;
01470                         pNewTagHandler = new FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL2(this, pTagHandler->m_pTabItem);
01471                         if(pNewTagHandler != NULL)
01472                         {
01473                                 delete pTagHandler;
01474                                 m_ISOTable[iIdx]->m_pTagHandler = (FedmIscTagHandler*)pNewTagHandler;
01475                                 return (FedmIscTagHandler*)pNewTagHandler;
01476                         }
01477                 }
01478                 else
01479                 {
01480                         pTagHandler->Init();
01481                         return pTagHandler;
01482                 }
01483         }
01484         else if(uiTagDriver == 8)
01485         {
01486                 if(pTagHandler->GetTagHandlerType() != FedmIscTagHandler::TYPE_ISO14443_4_MIFARE_PLUS_SL3)
01487                 {
01488                         FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL3* pNewTagHandler = NULL;
01489                         pNewTagHandler = new FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL3(this, pTagHandler->m_pTabItem);
01490                         if(pNewTagHandler != NULL)
01491                         {
01492                                 delete pTagHandler;
01493                                 m_ISOTable[iIdx]->m_pTagHandler = (FedmIscTagHandler*)pNewTagHandler;
01494                                 return (FedmIscTagHandler*)pNewTagHandler;
01495                         }
01496                 }
01497                 else
01498                 {
01499                         pTagHandler->Init();
01500                         return pTagHandler;
01501                 }
01502         }
01503         else if(uiTagDriver == 9)
01504         {
01505                 if(pTagHandler->GetTagHandlerType() != FedmIscTagHandler::TYPE_ISO14443_4_MIFARE_DESFIRE)
01506                 {
01507                         FedmIscTagHandler_ISO14443_4_MIFARE_DESFire* pNewTagHandler = NULL;
01508                         pNewTagHandler = new FedmIscTagHandler_ISO14443_4_MIFARE_DESFire(       this, pTagHandler->m_pTabItem);
01509                         if(pNewTagHandler != NULL)
01510                         {
01511                                 pNewTagHandler->Init();
01512                                 delete pTagHandler;
01513                                 m_ISOTable[iIdx]->m_pTagHandler = (FedmIscTagHandler*)pNewTagHandler;
01514                                 return (FedmIscTagHandler*)pNewTagHandler;
01515                         }
01516                 }
01517                 else
01518                 {
01519                         pTagHandler->Init();
01520                         return pTagHandler;
01521                 }
01522         }
01523         else if(uiTagDriver == 10)
01524         {
01525                 if(pTagHandler->GetTagHandlerType() != FedmIscTagHandler::TYPE_ISO14443_3_INFINEON_MY_D)
01526                 {
01527                         FedmIscTagHandler_ISO14443_3_Infineon_my_d* pNewTagHandler = NULL;
01528                         pNewTagHandler = new FedmIscTagHandler_ISO14443_3_Infineon_my_d(this, pTagHandler->m_pTabItem);
01529                         if(pNewTagHandler != NULL)
01530                         {
01531                                 delete pTagHandler;
01532                                 m_ISOTable[iIdx]->m_pTagHandler = (FedmIscTagHandler*)pNewTagHandler;
01533                                 return (FedmIscTagHandler*)pNewTagHandler;
01534                         }
01535                 }
01536                 else
01537                 {
01538                         pTagHandler->Init();
01539                         return pTagHandler;
01540                 }
01541         }
01542         else if(uiTagDriver == 11)
01543         {
01544                 if(pTagHandler->GetTagHandlerType() != FedmIscTagHandler::TYPE_ISO14443_3_INFINEON_MY_D_MOVE)
01545                 {
01546                         FedmIscTagHandler_ISO14443_3_Infineon_my_d_move* pNewTagHandler = NULL;
01547                         pNewTagHandler = new FedmIscTagHandler_ISO14443_3_Infineon_my_d_move(this, pTagHandler->m_pTabItem);
01548                         if(pNewTagHandler != NULL)
01549                         {
01550                                 delete pTagHandler;
01551                                 m_ISOTable[iIdx]->m_pTagHandler = (FedmIscTagHandler*)pNewTagHandler;
01552                                 return (FedmIscTagHandler*)pNewTagHandler;
01553                         }
01554                 }
01555                 else
01556                 {
01557                         pTagHandler->Init();
01558                         return pTagHandler;
01559                 }
01560         }
01561         else
01562         {
01563                 FEDM_TRACE(m_pLogger, FELOGMNG_DBG_ERROR, __FUNCTION__ << " Unvalid TagDriver parameter");
01564         }
01565 
01566         FEDM_TRACE(m_pLogger, FELOGMNG_DBG_ERROR, __FUNCTION__ << " Creation of TagHandler failed - no more mem?");
01567         return NULL;
01568 }
01569 #endif
01570 #endif
01571 
01572 /***************************************************************************
01573   Begin                 :       20.04.2009 / M. Hultsch
01574   
01575   Version               :       04.06.06 / 23.09.2014 / M. Hultsch
01576                                                 - support for ISO 14443-4 Tags with 10 byte UID
01577 
01578                                                 04.00.08 / 05.01.2012 / M. Hultsch
01579                                                 - creation of TagHandler only if card type is changed
01580 
01581                                                 03.00.07 / 06.05.2009 / M. Hultsch
01582 
01583   Function                      :       evaluate the returned SAK
01584 
01585   Parameters            :       int iIdx                        - index in FEDM_ISOTabItem
01586                                                 FedmIscTagHandler*      - pointer to tag handler base class
01587 
01588   Return value          :       FedmIscTagHandler*      - pointer to new tag handler (base class) of selected tag
01589                                                                                           or NULL       -       in error case
01590                                                                                                                 -       if transponder type could not be identified
01591 ***************************************************************************/
01592 #ifdef _FEDM_TAG_HANDLER
01593 #if !defined(_FEDM_NO_TAG_HANDLER_ISO14443)
01594 FedmIscTagHandler* FEDM_ISCReaderModule::TagSelect_EvaFormat1(int iIdx, FedmIscTagHandler* pTagHandler)
01595 {
01596         FEDM_TRACE(m_pLogger, FELOGMNG_DBG_FUNCTION_CALL | FELOGMNG_DBG_LF_COMM_TAG_HANDLER, __FUNCTION__);
01597 
01598         // evaluate ATQA
01599         unsigned int uiAtqA = ((unsigned int)m_TmpData[2048] << 8) + m_TmpData[2049];
01600 
01601         // evaluate SAK
01602         unsigned char ucSAK = m_TmpData[2050];
01603 
01604         if( (m_ISOTable[iIdx]->m_ucOptInfo & 0x03) == 0x00 )
01605         {
01606                 // cascade level 1 == 4 byte UID
01607 
01608                 if(ucSAK & 0x20)
01609                 {
01610                         // any ISO14443-4 compatible tag types
01611                         if(dynamic_cast<FedmIscTagHandler_ISO14443*>(pTagHandler) == NULL)
01612                                 return NULL;
01613 
01614                         switch(ucSAK)
01615                         {
01616                         case 0x20:
01617                                 if(uiAtqA == 0x0002 || uiAtqA == 0x0004)
01618                                 {
01619                                         unsigned char ucTL = m_TmpData[2051];
01620                                         unsigned char ucT0 = m_TmpData[2052];
01621                                         unsigned char* pucAts = &m_TmpData[2052];
01622                                         unsigned char ucMfPx[] = {0xC1, 0x05, 0x2F, 0x2F, 0x01, 0xBC, 0xD6};
01623                                         unsigned char ucMfPs[] = {0xC1, 0x05, 0x2F, 0x2F, 0x00, 0x35, 0xC7};
01624 
01625                                         if(ucTL >= 9)
01626                                         {
01627                                                 if(ucT0 & 0x10)
01628                                                 {
01629                                                         pucAts++;
01630                                                 }
01631                                                 if(ucT0 & 0x20)
01632                                                 {
01633                                                         pucAts++;
01634                                                 }
01635                                                 if(ucT0 & 0x40)
01636                                                 {
01637                                                         pucAts++;
01638                                                 }
01639                                                 pucAts++;
01640                                                 
01641                                                 if( memcmp(pucAts, ucMfPx, 7) == 0 || memcmp(pucAts, ucMfPs, 7) == 0)
01642                                                 {
01643                                                         // MIFARE Plus Security Level 0 or 3 with 4 byte fix UID or 4 byte random UID
01644 
01645                                                         if(pTagHandler->GetTagHandlerType() != FedmIscTagHandler::TYPE_ISO14443_4_MIFARE_PLUS_SL3)
01646                                                         {
01647                                                                 FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL3* pNewTagHandler = NULL;
01648                                                                 pNewTagHandler = new FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL3(this, pTagHandler->m_pTabItem);
01649                                                                 if(pNewTagHandler != NULL)
01650                                                                 {
01651                                                                         delete pTagHandler;
01652                                                                         m_ISOTable[iIdx]->m_pTagHandler = (FedmIscTagHandler*)pNewTagHandler;
01653                                                                         return (FedmIscTagHandler*)pNewTagHandler;
01654                                                                 }
01655                                                         }
01656                                                         else
01657                                                         {
01658                                                                 pTagHandler->Init();
01659                                                                 return pTagHandler;
01660                                                         }
01661                                                 }
01662                                                 else
01663                                                 {
01664                                                         if(pTagHandler->GetTagHandlerType() != FedmIscTagHandler::TYPE_ISO14443_4)
01665                                                         {
01666                                                                 FedmIscTagHandler_ISO14443_4* pNewTagHandler = NULL;
01667                                                                 pNewTagHandler = new FedmIscTagHandler_ISO14443_4(this, pTagHandler->m_pTabItem);
01668                                                                 if(pNewTagHandler != NULL)
01669                                                                 {
01670                                                                         delete pTagHandler;
01671                                                                         m_ISOTable[iIdx]->m_pTagHandler = (FedmIscTagHandler*)pNewTagHandler;
01672                                                                         return (FedmIscTagHandler*)pNewTagHandler;
01673                                                                 }
01674                                                         }
01675                                                         else
01676                                                         {
01677                                                                 pTagHandler->Init();
01678                                                                 return pTagHandler;
01679                                                         }
01680                                                 }
01681                                         } // if(ucTL >= 9)
01682                                         else
01683                                         {
01684                                                 if(pTagHandler->GetTagHandlerType() != FedmIscTagHandler::TYPE_ISO14443_4)
01685                                                 {
01686                                                         FedmIscTagHandler_ISO14443_4* pNewTagHandler = NULL;
01687                                                         pNewTagHandler = new FedmIscTagHandler_ISO14443_4(this, pTagHandler->m_pTabItem);
01688                                                         if(pNewTagHandler != NULL)
01689                                                         {
01690                                                                 delete pTagHandler;
01691                                                                 m_ISOTable[iIdx]->m_pTagHandler = (FedmIscTagHandler*)pNewTagHandler;
01692                                                                 return (FedmIscTagHandler*)pNewTagHandler;
01693                                                         }
01694                                                 }
01695                                                 else
01696                                                 {
01697                                                         pTagHandler->Init();
01698                                                         return pTagHandler;
01699                                                 }
01700                                         }
01701                                 }
01702                                 else if(uiAtqA == 0x0304 && m_ISOTable[iIdx]->m_ucSnr[7] == 0x80)
01703                                 {
01704                                         // MIFARE DESFire with 4 byte random UID (filled with leading/following zero to complete 8 byte UID)
01705                                         if(pTagHandler->GetTagHandlerType() != FedmIscTagHandler::TYPE_ISO14443_4_MIFARE_DESFIRE)
01706                                         {
01707                                                 //MIFARE DESFire CL2, MIFARE DESFire EV1 CL2
01708                                                 FedmIscTagHandler_ISO14443_4_MIFARE_DESFire* pNewTagHandler = NULL;
01709                                                 pNewTagHandler = new FedmIscTagHandler_ISO14443_4_MIFARE_DESFire(this, pTagHandler->m_pTabItem);
01710                                                 if(pNewTagHandler != NULL)
01711                                                 {
01712                                                         delete pTagHandler;
01713                                                         m_ISOTable[iIdx]->m_pTagHandler = (FedmIscTagHandler*)pNewTagHandler;
01714                                                         return (FedmIscTagHandler*)pNewTagHandler;
01715                                                 }
01716                                         }
01717                                         else
01718                                         {
01719                                                 pTagHandler->Init();
01720                                                 return pTagHandler;
01721                                         }
01722                                 }
01723                                 else
01724                                 {
01725                                         if(pTagHandler->GetTagHandlerType() != FedmIscTagHandler::TYPE_ISO14443_4)
01726                                         {
01727                                                 FedmIscTagHandler_ISO14443_4* pNewTagHandler = NULL;
01728                                                 pNewTagHandler = new FedmIscTagHandler_ISO14443_4(this, pTagHandler->m_pTabItem);
01729                                                 if(pNewTagHandler != NULL)
01730                                                 {
01731                                                         delete pTagHandler;
01732                                                         m_ISOTable[iIdx]->m_pTagHandler = (FedmIscTagHandler*)pNewTagHandler;
01733                                                         return (FedmIscTagHandler*)pNewTagHandler;
01734                                                 }
01735                                         }
01736                                         else
01737                                         {
01738                                                 pTagHandler->Init();
01739                                                 return pTagHandler;
01740                                         }
01741                                 }
01742                                 break;
01743 
01744                         default:
01745                                 if(pTagHandler->GetTagHandlerType() != FedmIscTagHandler::TYPE_ISO14443_4)
01746                                 {
01747                                         FedmIscTagHandler_ISO14443_4* pNewTagHandler = NULL;
01748                                         pNewTagHandler = new FedmIscTagHandler_ISO14443_4(this, pTagHandler->m_pTabItem);
01749                                         if(pNewTagHandler != NULL)
01750                                         {
01751                                                 delete pTagHandler;
01752                                                 m_ISOTable[iIdx]->m_pTagHandler = (FedmIscTagHandler*)pNewTagHandler;
01753                                                 return (FedmIscTagHandler*)pNewTagHandler;
01754                                         }
01755                                 }
01756                                 else
01757                                 {
01758                                         pTagHandler->Init();
01759                                         return pTagHandler;
01760                                 }
01761                                 break;
01762                         
01763                         } // switch(ucSAK)
01764                 
01765                 } // if(ucSAK & 0x20)
01766         }
01767         else if( (m_ISOTable[iIdx]->m_ucOptInfo & 0x03) == 0x01 )
01768         {
01769                 // cascade level 2 == 7 byte UID
01770 
01771                 if(m_ISOTable[iIdx]->m_ucSnr[7] == FEDM_ISC_ISO_MFR_NXP)
01772                 {
01773                         if(ucSAK & 0x20)
01774                         {
01775                                 // any ISO14443-4 compatible tag types
01776                                 if(dynamic_cast<FedmIscTagHandler_ISO14443*>(pTagHandler) == NULL)
01777                                         return NULL;
01778 
01779                                 switch(ucSAK)
01780                                 {
01781                                 case 0x20:      // MIFARE DESFire CL2, MIFARE DESFire EV1 CL2, MIFARE Plus CL2 (Security Level 0 oder 3)
01782                                         if(uiAtqA == 0x0344)
01783                                         {
01784                                                 if(pTagHandler->GetTagHandlerType() != FedmIscTagHandler::TYPE_ISO14443_4_MIFARE_DESFIRE)
01785                                                 {
01786                                                         //MIFARE DESFire CL2, MIFARE DESFire EV1 CL2
01787                                                         FedmIscTagHandler_ISO14443_4_MIFARE_DESFire* pNewTagHandler = NULL;
01788                                                         pNewTagHandler = new FedmIscTagHandler_ISO14443_4_MIFARE_DESFire(this, pTagHandler->m_pTabItem);
01789                                                         if(pNewTagHandler != NULL)
01790                                                         {
01791                                                                 delete pTagHandler;
01792                                                                 m_ISOTable[iIdx]->m_pTagHandler = (FedmIscTagHandler*)pNewTagHandler;
01793                                                                 return (FedmIscTagHandler*)pNewTagHandler;
01794                                                         }
01795                                                 }
01796                                                 else
01797                                                 {
01798                                                         pTagHandler->Init();
01799                                                         return pTagHandler;
01800                                                 }
01801                                         }
01802                                         else if(uiAtqA == 0x0042 || uiAtqA == 0x0044)
01803                                         {
01804                                                 unsigned char ucTL = m_TmpData[2051];
01805                                                 unsigned char ucT0 = m_TmpData[2052];
01806                                                 unsigned char* pucAts = &m_TmpData[2052];
01807                                                 unsigned char ucMfPx[] = {0xC1, 0x05, 0x2F, 0x2F, 0x01, 0xBC, 0xD6};
01808                                                 unsigned char ucMfPs[] = {0xC1, 0x05, 0x2F, 0x2F, 0x00, 0x35, 0xC7};
01809 
01810                                                 if(ucTL >= 9)
01811                                                 {
01812                                                         if(ucT0 & 0x10)
01813                                                         {
01814                                                                 pucAts++;
01815                                                         }
01816                                                         if(ucT0 & 0x20)
01817                                                         {
01818                                                                 pucAts++;
01819                                                         }
01820                                                         if(ucT0 & 0x40)
01821                                                         {
01822                                                                 pucAts++;
01823                                                         }
01824                                                         pucAts++;
01825                                                         
01826                                                         if( memcmp(pucAts, ucMfPx, 7) == 0 || memcmp(pucAts, ucMfPs, 7) == 0)
01827                                                         {
01828                                                                 if(pTagHandler->GetTagHandlerType() != FedmIscTagHandler::TYPE_ISO14443_4_MIFARE_PLUS_SL3)
01829                                                                 {
01830                                                                         FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL3* pNewTagHandler = NULL;
01831                                                                         pNewTagHandler = new FedmIscTagHandler_ISO14443_4_MIFARE_Plus_SL3(this, pTagHandler->m_pTabItem);
01832                                                                         if(pNewTagHandler != NULL)
01833                                                                         {
01834                                                                                 delete pTagHandler;
01835                                                                                 m_ISOTable[iIdx]->m_pTagHandler = (FedmIscTagHandler*)pNewTagHandler;
01836                                                                                 return (FedmIscTagHandler*)pNewTagHandler;
01837                                                                         }
01838                                                                 }
01839                                                                 else
01840                                                                 {
01841                                                                         pTagHandler->Init();
01842                                                                         return pTagHandler;
01843                                                                 }
01844                                                         }
01845                                                         else
01846                                                         {
01847                                                                 if(pTagHandler->GetTagHandlerType() != FedmIscTagHandler::TYPE_ISO14443_4)
01848                                                                 {
01849                                                                         FedmIscTagHandler_ISO14443_4* pNewTagHandler = NULL;
01850                                                                         pNewTagHandler = new FedmIscTagHandler_ISO14443_4(this, pTagHandler->m_pTabItem);
01851                                                                         if(pNewTagHandler != NULL)
01852                                                                         {
01853                                                                                 delete pTagHandler;
01854                                                                                 m_ISOTable[iIdx]->m_pTagHandler = (FedmIscTagHandler*)pNewTagHandler;
01855                                                                                 return (FedmIscTagHandler*)pNewTagHandler;
01856                                                                         }
01857                                                                 }
01858                                                                 else
01859                                                                 {
01860                                                                         pTagHandler->Init();
01861                                                                         return pTagHandler;
01862                                                                 }
01863                                                         }
01864                                                 } // if(ucTL >= 9)
01865                                                 else
01866                                                 {
01867                                                         if(pTagHandler->GetTagHandlerType() != FedmIscTagHandler::TYPE_ISO14443_4)
01868                                                         {
01869                                                                 FedmIscTagHandler_ISO14443_4* pNewTagHandler = NULL;
01870                                                                 pNewTagHandler = new FedmIscTagHandler_ISO14443_4(this, pTagHandler->m_pTabItem);
01871                                                                 if(pNewTagHandler != NULL)
01872                                                                 {
01873                                                                         delete pTagHandler;
01874                                                                         m_ISOTable[iIdx]->m_pTagHandler = (FedmIscTagHandler*)pNewTagHandler;
01875                                                                         return (FedmIscTagHandler*)pNewTagHandler;
01876                                                                 }
01877                                                         }
01878                                                         else
01879                                                         {
01880                                                                 pTagHandler->Init();
01881                                                                 return pTagHandler;
01882                                                         }
01883                                                 }
01884                                         }
01885                                         else
01886                                         {
01887                                                 if(pTagHandler->GetTagHandlerType() != FedmIscTagHandler::TYPE_ISO14443_4)
01888                                                 {
01889                                                         FedmIscTagHandler_ISO14443_4* pNewTagHandler = NULL;
01890                                                         pNewTagHandler = new FedmIscTagHandler_ISO14443_4(this, pTagHandler->m_pTabItem);
01891                                                         if(pNewTagHandler != NULL)
01892                                                         {
01893                                                                 delete pTagHandler;
01894                                                                 m_ISOTable[iIdx]->m_pTagHandler = (FedmIscTagHandler*)pNewTagHandler;
01895                                                                 return (FedmIscTagHandler*)pNewTagHandler;
01896                                                         }
01897                                                 }
01898                                                 else
01899                                                 {
01900                                                         pTagHandler->Init();
01901                                                         return pTagHandler;
01902                                                 }
01903                                         }
01904                                         break;
01905 
01906                                 default:
01907                                         if(pTagHandler->GetTagHandlerType() != FedmIscTagHandler::TYPE_ISO14443_4)
01908                                         {
01909                                                 FedmIscTagHandler_ISO14443_4* pNewTagHandler = NULL;
01910                                                 pNewTagHandler = new FedmIscTagHandler_ISO14443_4(this, pTagHandler->m_pTabItem);
01911                                                 if(pNewTagHandler != NULL)
01912                                                 {
01913                                                         delete pTagHandler;
01914                                                         m_ISOTable[iIdx]->m_pTagHandler = (FedmIscTagHandler*)pNewTagHandler;
01915                                                         return (FedmIscTagHandler*)pNewTagHandler;
01916                                                 }
01917                                         }
01918                                         else
01919                                         {
01920                                                 pTagHandler->Init();
01921                                                 return pTagHandler;
01922                                         }
01923                                         break;
01924                                 
01925                                 } // switch(ucSAK)
01926                         
01927                         } // if(ucSAK & 0x20)
01928                 }
01929                 else
01930                 {       
01931                         // non NXP tag
01932 
01933                         if(ucSAK & 0x20)
01934                         {
01935                                 // any ISO14443-4 compatible tag types
01936                                 if(dynamic_cast<FedmIscTagHandler_ISO14443*>(pTagHandler) == NULL)
01937                                         return NULL;
01938 
01939                                 if(pTagHandler->GetTagHandlerType() != FedmIscTagHandler::TYPE_ISO14443_4)
01940                                 {
01941                                         FedmIscTagHandler_ISO14443_4* pNewTagHandler = NULL;
01942                                         pNewTagHandler = new FedmIscTagHandler_ISO14443_4(this, pTagHandler->m_pTabItem);
01943                                         if(pNewTagHandler != NULL)
01944                                         {
01945                                                 delete pTagHandler;
01946                                                 m_ISOTable[iIdx]->m_pTagHandler = (FedmIscTagHandler*)pNewTagHandler;
01947                                                 return (FedmIscTagHandler*)pNewTagHandler;
01948                                         }
01949                                 }
01950                                 else
01951                                 {
01952                                         pTagHandler->Init();
01953                                         return pTagHandler;
01954                                 }
01955                         }
01956                 }
01957         }
01958         else
01959         {
01960                 // cascade level 3 == 10 byte UID
01961 
01962                 // non NXP tag
01963 
01964                 if(ucSAK & 0x20)
01965                 {
01966                         // any ISO14443-4 compatible tag types
01967                         if(dynamic_cast<FedmIscTagHandler_ISO14443*>(pTagHandler) == NULL)
01968                                 return NULL;
01969 
01970                         if(pTagHandler->GetTagHandlerType() != FedmIscTagHandler::TYPE_ISO14443_4)
01971                         {
01972                                 FedmIscTagHandler_ISO14443_4* pNewTagHandler = NULL;
01973                                 pNewTagHandler = new FedmIscTagHandler_ISO14443_4(this, pTagHandler->m_pTabItem);
01974                                 if(pNewTagHandler != NULL)
01975                                 {
01976                                         delete pTagHandler;
01977                                         m_ISOTable[iIdx]->m_pTagHandler = (FedmIscTagHandler*)pNewTagHandler;
01978                                         return (FedmIscTagHandler*)pNewTagHandler;
01979                                 }
01980                         }
01981                         else
01982                         {
01983                                 pTagHandler->Init();
01984                                 return pTagHandler;
01985                         }
01986                 }
01987         }
01988 
01989         FEDM_TRACE(m_pLogger, FELOGMNG_DBG_ERROR, __FUNCTION__ << " Creation of TagHandler failed");
01990         SetLastError(FEDM_ERROR_UNKNOWN_TRANSPONDER_TYPE);
01991         return NULL;
01992 }
01993 #endif
01994 #endif
01995 
01996 /***************************************************************************
01997   Begin                 :       20.04.2009 / M. Hultsch
01998   
01999   Version               :       04.00.08 / 05.01.2012 / M. Hultsch
02000                                                 - creation of TagHandler only if card type is changed
02001 
02002                                                 03.00.07 / 06.05.2009 / M. Hultsch
02003 
02004   Function                      :       evaluate the returned protocol type
02005 
02006   Parameters            :       int iIdx                        - index in FEDM_ISOTabItem
02007                                                 FedmIscTagHandler*      - pointer to tag handler base class
02008 
02009   Return value          :       FedmIscTagHandler*      - pointer to new tag handler (base class) of selected tag
02010                                                                                           or NULL       -       in error case
02011                                                                                                                 -       if transponder type could not be identified
02012 ***************************************************************************/
02013 #ifdef _FEDM_TAG_HANDLER
02014 #if !defined(_FEDM_NO_TAG_HANDLER_ISO14443)
02015 FedmIscTagHandler* FEDM_ISCReaderModule::TagSelect_EvaFormat2(int iIdx, FedmIscTagHandler* pTagHandler)
02016 {
02017         FEDM_TRACE(m_pLogger, FELOGMNG_DBG_FUNCTION_CALL | FELOGMNG_DBG_LF_COMM_TAG_HANDLER, __FUNCTION__);
02018 
02019         // evaluate protocol type
02020         unsigned char ucProtocolType = m_TmpData[2049] & 0x0F;
02021 
02022         switch(ucProtocolType&0x01)
02023         {
02024         case 0: // ISO 14443-3 Type B transponder
02025                 {
02026                         if(dynamic_cast<FedmIscTagHandler_ISO14443*>(pTagHandler) == NULL)
02027                                 return NULL;
02028 
02029                         if(pTagHandler->GetTagHandlerType() != FedmIscTagHandler::TYPE_ISO14443_3)
02030                         {
02031                                 FedmIscTagHandler_ISO14443_3* pNewTagHandler = NULL;
02032                                 pNewTagHandler = new FedmIscTagHandler_ISO14443_3(this, pTagHandler->m_pTabItem);
02033                                 if(pNewTagHandler != NULL)
02034                                 {
02035                                         delete pTagHandler;
02036                                         m_ISOTable[iIdx]->m_pTagHandler = (FedmIscTagHandler*)pNewTagHandler;
02037                                         return (FedmIscTagHandler*)pNewTagHandler;
02038                                 }
02039                         }
02040                         else
02041                         {
02042                                 pTagHandler->Init();
02043                                 return pTagHandler;
02044                         }
02045                 }
02046                 break;
02047 
02048         case 1: // ISO 14443-4 Type B transponder
02049                 {
02050                         if(dynamic_cast<FedmIscTagHandler_ISO14443*>(pTagHandler) == NULL)
02051                                 return NULL;
02052 
02053                         unsigned int uiTmpAppData = 0;
02054                         uiTmpAppData = ((pTagHandler->m_pTabItem->m_ucSnr[0] << 24) | (pTagHandler->m_pTabItem->m_ucSnr[1] << 16) | (pTagHandler->m_pTabItem->m_ucSnr[2] << 8) | (pTagHandler->m_pTabItem->m_ucSnr[3]));
02055 
02056                         if(uiTmpAppData == 0xe02b0010)
02057                         {
02058                                 if(pTagHandler->GetTagHandlerType() != FedmIscTagHandler::TYPE_ISO14443_4_MAXIM_MAX66000)
02059                                 {
02060                                         FedmIscTagHandler_ISO14443_4_Maxim_MAX66000* pNewTagHandler = NULL;
02061                                         pNewTagHandler = new FedmIscTagHandler_ISO14443_4_Maxim_MAX66000(this, pTagHandler->m_pTabItem);
02062                                         if(pNewTagHandler != NULL)
02063                                         {
02064                                                 delete pTagHandler;
02065                                                 m_ISOTable[iIdx]->m_pTagHandler = (FedmIscTagHandler*)pNewTagHandler;
02066                                                 return (FedmIscTagHandler*)pNewTagHandler;
02067                                         }
02068                                 }
02069                                 else
02070                                 {
02071                                         pTagHandler->Init();
02072                                         return pTagHandler;
02073                                 }
02074                         }
02075                         else if(uiTmpAppData == 0xe02b0020)
02076                         {
02077                                 if(pTagHandler->GetTagHandlerType() != FedmIscTagHandler::TYPE_ISO14443_4_MAXIM_MAX66020)
02078                                 {
02079                                         FedmIscTagHandler_ISO14443_4_Maxim_MAX66020* pNewTagHandler = NULL;
02080                                         pNewTagHandler = new FedmIscTagHandler_ISO14443_4_Maxim_MAX66020(this, pTagHandler->m_pTabItem);
02081                                         if(pNewTagHandler != NULL)
02082                                         {
02083                                                 delete pTagHandler;
02084                                                 m_ISOTable[iIdx]->m_pTagHandler = (FedmIscTagHandler*)pNewTagHandler;
02085                                                 return (FedmIscTagHandler*)pNewTagHandler;
02086                                         }
02087                                 }
02088                                 else
02089                                 {
02090                                         pTagHandler->Init();
02091                                         return pTagHandler;
02092                                 }
02093                         }
02094                         else if(uiTmpAppData == 0xe02b0030)
02095                         {
02096                                 if(pTagHandler->GetTagHandlerType() != FedmIscTagHandler::TYPE_ISO14443_4_MAXIM_MAX66040)
02097                                 {
02098                                         FedmIscTagHandler_ISO14443_4_Maxim_MAX66040* pNewTagHandler = NULL;
02099                                         pNewTagHandler = new FedmIscTagHandler_ISO14443_4_Maxim_MAX66040(this, pTagHandler->m_pTabItem);
02100                                         if(pNewTagHandler != NULL)
02101                                         {
02102                                                 delete pTagHandler;
02103                                                 m_ISOTable[iIdx]->m_pTagHandler = (FedmIscTagHandler*)pNewTagHandler;
02104                                                 return (FedmIscTagHandler*)pNewTagHandler;
02105                                         }
02106                                 }
02107                                 else
02108                                 {
02109                                         pTagHandler->Init();
02110                                         return pTagHandler;
02111                                 }
02112                         }
02113                         else
02114                         {
02115                                 if(pTagHandler->GetTagHandlerType() != FedmIscTagHandler::TYPE_ISO14443_4)
02116                                 {
02117                                         FedmIscTagHandler_ISO14443_4* pNewTagHandler = NULL;
02118                                         pNewTagHandler = new FedmIscTagHandler_ISO14443_4(this, pTagHandler->m_pTabItem);
02119                                         if(pNewTagHandler != NULL)
02120                                         {
02121                                                 delete pTagHandler;
02122                                                 m_ISOTable[iIdx]->m_pTagHandler = (FedmIscTagHandler*)pNewTagHandler;
02123                                                 return (FedmIscTagHandler*)pNewTagHandler;
02124                                         }
02125                                 }
02126                                 else
02127                                 {
02128                                         pTagHandler->Init();
02129                                         return pTagHandler;
02130                                 }
02131                         }
02132                 }
02133                 break;
02134         }
02135 
02136         FEDM_TRACE(m_pLogger, FELOGMNG_DBG_ERROR, __FUNCTION__ << " Creation of TagHandler failed");
02137         SetLastError(FEDM_ERROR_UNKNOWN_TRANSPONDER_TYPE);
02138         return NULL;
02139 }
02140 #endif
02141 #endif
02142 
02143 /***************************************************************************
02144   Begin                 :       20.04.2009 / M. Hultsch
02145   
02146   Version               :       04.00.08 / 05.01.2012 / M. Hultsch
02147                                                 - creation of TagHandler only if card type is changed
02148 
02149                                                 03.00.07 / 06.05.2009 / M. Hultsch
02150 
02151   Function                      :       evaluate the returned SAK
02152 
02153   Parameters            :       int iIdx                        - index in FEDM_ISOTabItem
02154                                                 FedmIscTagHandler*      - pointer to tag handler base class
02155 
02156   Return value          :       FedmIscTagHandler*      - pointer to new tag handler (base class) of selected tag
02157                                                                                           or NULL       -       in error case
02158                                                                                                                 -       if transponder type could not be identified
02159 ***************************************************************************/
02160 #ifdef _FEDM_TAG_HANDLER
02161 #if !defined(_FEDM_NO_TAG_HANDLER_ISO14443)
02162 FedmIscTagHandler* FEDM_ISCReaderModule::TagSelect_EvaFormat3(int iIdx, FedmIscTagHandler* pTagHandler)
02163 {
02164         FEDM_TRACE(m_pLogger, FELOGMNG_DBG_FUNCTION_CALL | FELOGMNG_DBG_LF_COMM_TAG_HANDLER, __FUNCTION__);
02165 
02166         // evaluate SAK
02167         unsigned char ucSAK = m_TmpData[2050];
02168 
02169         if( (m_ISOTable[iIdx]->m_ucOptInfo & 0x03) == 0x00 )
02170         {
02171                 // cascade level 1 == 4 byte UID
02172                 switch(ucSAK)
02173                 {
02174                 case 0x00:      // Infineon my-d (SLE55Rxx
02175                         {
02176                                 if(dynamic_cast<FedmIscTagHandler_ISO14443*>(pTagHandler) == NULL)
02177                                         return NULL;
02178 
02179                                 if(pTagHandler->GetTagHandlerType() != FedmIscTagHandler::TYPE_ISO14443_3_INFINEON_MY_D)
02180                                 {
02181                                         FedmIscTagHandler_ISO14443_3_Infineon_my_d* pNewTagHandler = NULL;
02182                                         pNewTagHandler = new FedmIscTagHandler_ISO14443_3_Infineon_my_d(this, pTagHandler->m_pTabItem);
02183                                         if(pNewTagHandler != NULL)
02184                                         {
02185                                                 delete pTagHandler;
02186                                                 m_ISOTable[iIdx]->m_pTagHandler = (FedmIscTagHandler*)pNewTagHandler;
02187                                                 return (FedmIscTagHandler*)pNewTagHandler;
02188                                         }
02189                                 }
02190                                 else
02191                                 {
02192                                         pTagHandler->Init();
02193                                         return pTagHandler;
02194                                 }
02195                         }
02196                         break;
02197 
02198                 case 0x08:      // MIFARE 1K
02199                                         // MIFARE Plus with 2KB memory in security level 1
02200                 case 0x09:      // MIFARE Mini
02201                 case 0x18:      // MIFARE 4K
02202                                         // MIFARE Plus with 4KB memory in security level 1
02203                 case 0x88:      // Infineon MIFARE 1K
02204                         {
02205                                 if(dynamic_cast<FedmIscTagHandler_ISO14443*>(pTagHandler) == NULL)
02206                                         return NULL;
02207 
02208                                 if(pTagHandler->GetTagHandlerType() != FedmIscTagHandler::TYPE_ISO14443_3_MIFARE_CLASSIC)
02209                                 {
02210                                         FedmIscTagHandler_ISO14443_3_MIFARE_Classic* pNewTagHandler = NULL;
02211                                         pNewTagHandler = new FedmIscTagHandler_ISO14443_3_MIFARE_Classic(this, pTagHandler->m_pTabItem);
02212                                         if(pNewTagHandler != NULL)
02213                                         {
02214                                                 delete pTagHandler;
02215                                                 m_ISOTable[iIdx]->m_pTagHandler = (FedmIscTagHandler*)pNewTagHandler;
02216                                                 return (FedmIscTagHandler*)pNewTagHandler;
02217                                         }
02218                                 }
02219                                 else
02220                                 {
02221                                         pTagHandler->Init();
02222                                         return pTagHandler;
02223                                 }
02224                         }
02225                         break;
02226 
02227                 case 0x10:      // MIFARE Plus CL2 with 2KB memory in security level 2
02228                 case 0x11:      // MIFARE Plus CL2 with 4KB memory in security level 2
02229                         {
02230                                 if(dynamic_cast<FedmIscTagHandler_ISO14443*>(pTagHandler) == NULL)
02231                                         return NULL;
02232 
02233                                 if(pTagHandler->GetTagHandlerType() != FedmIscTagHandler::TYPE_ISO14443_3_MIFARE_PLUS_SL2)
02234                                 {
02235                                         FedmIscTagHandler_ISO14443_3_MIFARE_Plus_SL2* pNewTagHandler = NULL;
02236                                         pNewTagHandler = new FedmIscTagHandler_ISO14443_3_MIFARE_Plus_SL2(this, pTagHandler->m_pTabItem);
02237                                         if(pNewTagHandler != NULL)
02238                                         {
02239                                                 delete pTagHandler;
02240                                                 m_ISOTable[iIdx]->m_pTagHandler = (FedmIscTagHandler*)pNewTagHandler;
02241                                                 return (FedmIscTagHandler*)pNewTagHandler;
02242                                         }
02243                                 }
02244                                 else
02245                                 {
02246                                         pTagHandler->Init();
02247                                         return pTagHandler;
02248                                 }
02249                         }
02250                         break;
02251                 }
02252         }
02253         else if( (m_ISOTable[iIdx]->m_ucOptInfo & 0x03) == 0x01 )
02254         {
02255                 // cascade level 2 == 7 byte UID
02256                 if(m_ISOTable[iIdx]->m_ucSnr[7] == FEDM_ISC_ISO_MFR_NXP)
02257                 {
02258                         switch(ucSAK)
02259                         {
02260                         case 0x00:      // MIFARE Ultralight CL2
02261                                 {
02262                                         if(dynamic_cast<FedmIscTagHandler_ISO14443*>(pTagHandler) == NULL)
02263                                                 return NULL;
02264 
02265                                         if(pTagHandler->GetTagHandlerType() != FedmIscTagHandler::TYPE_ISO14443_3_MIFARE_ULTRALIGHT)
02266                                         {
02267                                                 FedmIscTagHandler_ISO14443_3_MIFARE_Ultralight* pNewTagHandler = NULL;
02268                                                 pNewTagHandler = new FedmIscTagHandler_ISO14443_3_MIFARE_Ultralight(this, pTagHandler->m_pTabItem);
02269                                                 if(pNewTagHandler != NULL)
02270                                                 {
02271                                                         delete pTagHandler;
02272                                                         m_ISOTable[iIdx]->m_pTagHandler = (FedmIscTagHandler*)pNewTagHandler;
02273                                                         return (FedmIscTagHandler*)pNewTagHandler;
02274                                                 }
02275                                         }
02276                                         else
02277                                         {
02278                                                 pTagHandler->Init();
02279                                                 return pTagHandler;
02280                                         }
02281                                 }
02282                                 break;
02283 
02284                         case 0x08:      // MIFARE Plus CL2 with 2KB memory in security level 1
02285                         case 0x18:      // MIFARE Plus CL2 with 4KB memory in security level 1
02286                                 {
02287                                         if(dynamic_cast<FedmIscTagHandler_ISO14443*>(pTagHandler) == NULL)
02288                                                 return NULL;
02289 
02290                                         if(pTagHandler->GetTagHandlerType() != FedmIscTagHandler::TYPE_ISO14443_3_MIFARE_CLASSIC)
02291                                         {
02292                                                 FedmIscTagHandler_ISO14443_3_MIFARE_Classic* pNewTagHandler = NULL;
02293                                                 pNewTagHandler = new FedmIscTagHandler_ISO14443_3_MIFARE_Classic(this, pTagHandler->m_pTabItem);
02294                                                 if(pNewTagHandler != NULL)
02295                                                 {
02296                                                         delete pTagHandler;
02297                                                         m_ISOTable[iIdx]->m_pTagHandler = (FedmIscTagHandler*)pNewTagHandler;
02298                                                         return (FedmIscTagHandler*)pNewTagHandler;
02299                                                 }
02300                                         }
02301                                         else
02302                                         {
02303                                                 pTagHandler->Init();
02304                                                 return pTagHandler;
02305                                         }
02306                                 }
02307                                 break;
02308 
02309                         case 0x10:      // MIFARE Plus CL2 with 2KB memory in security level 2
02310                         case 0x11:      // MIFARE Plus CL2 with 4KB memory in security level 2
02311                                 {
02312                                         if(dynamic_cast<FedmIscTagHandler_ISO14443*>(pTagHandler) == NULL)
02313                                                 return NULL;
02314 
02315                                         if(pTagHandler->GetTagHandlerType() != FedmIscTagHandler::TYPE_ISO14443_3_MIFARE_PLUS_SL2)
02316                                         {
02317                                                 FedmIscTagHandler_ISO14443_3_MIFARE_Plus_SL2* pNewTagHandler = NULL;
02318                                                 pNewTagHandler = new FedmIscTagHandler_ISO14443_3_MIFARE_Plus_SL2(this, pTagHandler->m_pTabItem);
02319                                                 if(pNewTagHandler != NULL)
02320                                                 {
02321                                                         delete pTagHandler;
02322                                                         m_ISOTable[iIdx]->m_pTagHandler = (FedmIscTagHandler*)pNewTagHandler;
02323                                                         return (FedmIscTagHandler*)pNewTagHandler;
02324                                                 }
02325                                         }
02326                                         else
02327                                         {
02328                                                 pTagHandler->Init();
02329                                                 return pTagHandler;
02330                                         }
02331                                 }
02332                                 break;
02333                         }
02334                 }
02335                 else if(m_ISOTable[iIdx]->m_ucSnr[7] == FEDM_ISC_ISO_MFR_INFINEON)
02336                 {
02337                         if((m_ISOTable[iIdx]->m_ucSnr[6] & 0x30) == 0x30)
02338                         {
02339                                 if(dynamic_cast<FedmIscTagHandler_ISO14443*>(pTagHandler) == NULL)
02340                                         return NULL;
02341 
02342                                 if(pTagHandler->GetTagHandlerType() != FedmIscTagHandler::TYPE_ISO14443_3_INFINEON_MY_D_MOVE)
02343                                 {
02344                                         FedmIscTagHandler_ISO14443_3_Infineon_my_d_move* pNewTagHandler = NULL;
02345                                         pNewTagHandler = new FedmIscTagHandler_ISO14443_3_Infineon_my_d_move(this, pTagHandler->m_pTabItem);
02346                                         if(pNewTagHandler != NULL)
02347                                         {
02348                                                 delete pTagHandler;
02349                                                 m_ISOTable[iIdx]->m_pTagHandler = (FedmIscTagHandler*)pNewTagHandler;
02350                                                 return (FedmIscTagHandler*)pNewTagHandler;
02351                                         }
02352                                 }
02353                                 else
02354                                 {
02355                                         pTagHandler->Init();
02356                                         return pTagHandler;
02357                                 }
02358                         }
02359                         else
02360                         {
02361                                 //No Valid INFINEON Tag found
02362                                 return pTagHandler;                     
02363                         }
02364                 }
02365                 else
02366                 {       
02367                         //No Valid Manufacturer found
02368                         return pTagHandler;
02369                 }
02370         }
02371         else if( (m_ISOTable[iIdx]->m_ucOptInfo & 0x03) == 0x02 )
02372         {
02373                 // cascade level 3 == 10 byte UID
02374         }
02375 
02376 
02377         FEDM_TRACE(m_pLogger, FELOGMNG_DBG_ERROR, __FUNCTION__ << " Creation of TagHandler failed");
02378         SetLastError(FEDM_ERROR_UNKNOWN_TRANSPONDER_TYPE);
02379         return NULL;
02380 }
02381 #endif
02382 #endif
02383 
02384 
02385 
02387 // public functions
02389 
02390 /***************************************************************************
02391   Begin                 :       01.04.2009 / M. Hultsch
02392   
02393   Version               :       03.00.12 / 23.09.2009 / M. Hultsch
02394 
02395   Function                      :       returns the list with all tag handlers
02396                                                 - tag handlers can be invalid due to its RF-Status
02397 
02398   Parameters            :       -
02399 
02400   Return value          :       map<string, FedmIscTagHandler*>*
02401 ***************************************************************************/
02402 #ifdef _FEDM_TAG_HANDLER
02403 FEDM_ISC_TAG_LIST* FEDM_ISCReaderModule::GetTagList()
02404 {
02405         string sSnr;
02406 
02407         if( m_bEnableTagHandler )
02408         {
02409                 m_mapTagHandler.clear();
02410 
02411                 // build new tag handler list
02412                 for(unsigned int uiCnt=0; uiCnt<m_uiISOTableLength; uiCnt++)
02413                 {
02414                         if(m_ISOTable[uiCnt]->m_pTagHandler != NULL)
02415                         {
02416                                 if(m_ISOTable[uiCnt]->GetSnr(sSnr) != FEDM_OK)
02417                                         continue;
02418                                 
02419                                 m_mapTagHandler.insert(make_pair(sSnr, m_ISOTable[uiCnt]->m_pTagHandler));
02420                         }
02421                 }
02422         }
02423 
02424         return &m_mapTagHandler;
02425 }
02426 #endif
02427 
02428 /***************************************************************************
02429   Begin                 :       24.08.2009 / M. Hultsch
02430   
02431   Version               :       03.00.12 / 24.08.2009 / M. Hultsch
02432 
02433   Function                      :       returns the tag handler from list
02434 
02435   Parameters            :       string sSnr     - serial number or UID
02436 
02437   Return value          :       FedmIscTagHandler* or NULL
02438 ***************************************************************************/
02439 #ifdef _FEDM_TAG_HANDLER
02440 #ifdef _WIN32_WCE
02441 FedmIscTagHandler*  FEDM_ISCReaderModule::GetTagHandler(char* sSnr)
02442 {
02443         string stlSnr;
02444 
02445         // rebuild the internal tag list
02446         GetTagList();
02447 
02448         stlSnr = sSnr;
02449         FEDM_ISC_TAG_LIST_ITOR itor = m_mapTagHandler.find(stlSnr);
02450         if(itor == m_mapTagHandler.end())
02451                 return NULL;
02452 
02453         return itor->second;
02454 }
02455 #else
02456 FedmIscTagHandler*  FEDM_ISCReaderModule::GetTagHandler(string sSnr)
02457 {
02458         // rebuild the internal tag list
02459         GetTagList();
02460 
02461         FEDM_ISC_TAG_LIST_ITOR itor = m_mapTagHandler.find(sSnr);
02462         if(itor == m_mapTagHandler.end())
02463                 return NULL;
02464 
02465         itor->second->m_bNonAddressedMode = false;
02466         return itor->second;
02467 }
02468 #endif
02469 #endif
02470 
02471 
02472 /***************************************************************************
02473   Begin                 :       24.08.2009 / M. Hultsch
02474   
02475   Version               :       03.00.12 / 24.08.2009 / M. Hultsch
02476 
02477   Function                      :       returns the tag handler with selected state from list
02478 
02479   Parameters            :       -
02480 
02481   Return value          :       FedmIscTagHandler* or NULL
02482 ***************************************************************************/
02483 #ifdef _FEDM_TAG_HANDLER
02484 FedmIscTagHandler*  FEDM_ISCReaderModule::GetSelectedTagHandler()
02485 {
02486         FEDM_ISC_TAG_LIST_ITOR itor;
02487 
02488         // rebuild the internal tag list
02489         GetTagList();
02490 
02491         for(itor  = m_mapTagHandler.begin();
02492                 itor != m_mapTagHandler.end();
02493                 itor++ )
02494         {
02495                 if(itor->second->m_pTabItem->m_bIsSelected)
02496                         return itor->second;
02497         }
02498 
02499         return NULL;
02500 }
02501 #endif
02502 
02503 
02504 /***************************************************************************
02505   Begin                 :       25.10.2010 / M. Hultsch
02506   Version               :       04.05.02 / 02.07.2013 / M. Hultsch
02507                                                 - support for new tag types: ISO 15693 NXP SLIX, SLIX-L, SLIX-S
02508 
02509                                                 04.03.01 / 25.09.2012 / M. Hultsch
02510                                                 - support for new tag types: ISO 15693 STM M24LRxxE-R, STM LRIS64K
02511 
02512                                                 04.02.00 / 04.04.2012 / M. Hultsch
02513                                                 - renamed from GetNonAddressedTagHandler to CreateNonAddressedTagHandler
02514                  
02515                                                 04.00.10 / 13.02.2012 / M. Hultsch
02516                                                 - EPC Class1 Gen2 supported
02517                  
02518                                                 03.03.02 / 03.05.2011 / M. Hultsch
02519 
02520   Function                      :       creates a new taghandler in tagitem with index 0
02521 
02522   Parameters            :       unsigned int uiTagHandlerType - one of a type from TagHandler
02523 
02524   Return value          :       FedmIscTagHandler or null
02525 ***************************************************************************/
02526 #ifdef _FEDM_TAG_HANDLER
02527 FedmIscTagHandler* FEDM_ISCReaderModule::CreateNonAddressedTagHandler(unsigned int uiTagHandlerType)
02528 {
02529         FEDM_TRACE_FNC(m_pLogger, FELOGMNG_DBG_FUNCTION_CALL | FELOGMNG_DBG_LF_COMM_TAG_HANDLER, __FUNCTION__, FELOGMNG_DBG_FUNCTION_PARAMETER, "TagHandlerType=0x" << std::hex << std::uppercase << uiTagHandlerType);
02530         
02531         FedmIscTagHandler* pNewTagHandler = NULL;
02532         FEDM_ISOTabItem* tabItem = GetISOTableItem(0);
02533 
02534         if( !m_bEnableTagHandler )
02535         {
02536                 FEDM_TRACE(m_pLogger, FELOGMNG_DBG_ERROR, __FUNCTION__ << " Support for TagHandler disabled");
02537                 SetLastError(FEDM_ERROR_UNSUPPORTED);
02538                 return NULL;
02539         }
02540 
02541         if(uiTagHandlerType == FedmIscTagHandler::TYPE_BASIC)
02542         {
02543                 if(tabItem->m_pTagHandler != NULL)
02544                 {
02545                         pNewTagHandler = tabItem->m_pTagHandler; // all taghandler are type of BASIC
02546                 }
02547                 else
02548                 {
02549                         pNewTagHandler = new FedmIscTagHandler(this, FedmIscTagHandler::TYPE_BASIC, tabItem);
02550                 }
02551         }
02552 #if !defined(_FEDM_NO_TAG_HANDLER_EPC_C1_G2)
02553         else if(uiTagHandlerType == FedmIscTagHandler::TYPE_EPC_CLASS1_GEN2)
02554         {
02555                 if(tabItem->m_pTagHandler != NULL)
02556                 {
02557                         if(dynamic_cast<FedmIscTagHandler_EPC_Class1_Gen2*>(tabItem->m_pTagHandler) == NULL)
02558                         {
02559                                 delete tabItem->m_pTagHandler;
02560                                 tabItem->m_pTagHandler = NULL;
02561                                 pNewTagHandler = new FedmIscTagHandler_EPC_Class1_Gen2(this, tabItem);
02562                         }
02563                         else
02564                         {
02565                                 pNewTagHandler = tabItem->m_pTagHandler;
02566                         }
02567                 }
02568                 else
02569                 {
02570                         pNewTagHandler = new FedmIscTagHandler_EPC_Class1_Gen2(this, tabItem);
02571                 }
02572         }
02573         else if(uiTagHandlerType == FedmIscTagHandler::TYPE_EPC_CLASS1_GEN2_IDS_SL900A)
02574         {
02575                 if(tabItem->m_pTagHandler != NULL)
02576                 {
02577                         if(dynamic_cast<FedmIscTagHandler_EPC_Class1_Gen2_IDS_SL900A*>(tabItem->m_pTagHandler) == NULL)
02578                         {
02579                                 delete tabItem->m_pTagHandler;
02580                                 tabItem->m_pTagHandler = NULL;
02581                                 pNewTagHandler = new FedmIscTagHandler_EPC_Class1_Gen2_IDS_SL900A(this, tabItem);
02582                         }
02583                         else
02584                         {
02585                                 pNewTagHandler = tabItem->m_pTagHandler;
02586                         }
02587                 }
02588                 else
02589                 {
02590                         pNewTagHandler = new FedmIscTagHandler_EPC_Class1_Gen2_IDS_SL900A(this, tabItem);
02591                 }
02592         }
02593 #endif
02594 #if !defined(_FEDM_NO_TAG_HANDLER_ISO14443)
02595         else if(uiTagHandlerType == FedmIscTagHandler::TYPE_ISO14443 ||
02596                         uiTagHandlerType == FedmIscTagHandler::TYPE_ISO14443_2 ||
02597                         uiTagHandlerType == FedmIscTagHandler::TYPE_ISO14443_2_INNOVISION_JEWEL ||
02598                         uiTagHandlerType == FedmIscTagHandler::TYPE_ISO14443_2_STM_SR176 ||
02599                         uiTagHandlerType == FedmIscTagHandler::TYPE_ISO14443_2_STM_SRIxxx ||
02600                         uiTagHandlerType == FedmIscTagHandler::TYPE_ISO14443_3 ||
02601                         uiTagHandlerType == FedmIscTagHandler::TYPE_ISO14443_3_INFINEON_MY_D ||
02602                         uiTagHandlerType == FedmIscTagHandler::TYPE_ISO14443_3_INFINEON_MY_D_MOVE ||
02603                         uiTagHandlerType == FedmIscTagHandler::TYPE_ISO14443_3_MIFARE_CLASSIC ||
02604                         uiTagHandlerType == FedmIscTagHandler::TYPE_ISO14443_3_MIFARE_PLUS_SL1 ||
02605                         uiTagHandlerType == FedmIscTagHandler::TYPE_ISO14443_3_MIFARE_PLUS_SL2 ||
02606                         uiTagHandlerType == FedmIscTagHandler::TYPE_ISO14443_3_MIFARE_ULTRALIGHT ||
02607                         uiTagHandlerType == FedmIscTagHandler::TYPE_ISO14443_4 ||
02608                         uiTagHandlerType == FedmIscTagHandler::TYPE_ISO14443_4_MAXIM ||
02609                         uiTagHandlerType == FedmIscTagHandler::TYPE_ISO14443_4_MAXIM_MAX66000 ||
02610                         uiTagHandlerType == FedmIscTagHandler::TYPE_ISO14443_4_MAXIM_MAX66020 ||
02611                         uiTagHandlerType == FedmIscTagHandler::TYPE_ISO14443_4_MAXIM_MAX66040 ||
02612                         uiTagHandlerType == FedmIscTagHandler::TYPE_ISO14443_4_MIFARE_DESFIRE ||
02613                         uiTagHandlerType == FedmIscTagHandler::TYPE_ISO14443_4_MIFARE_PLUS_SL1 ||
02614                         uiTagHandlerType == FedmIscTagHandler::TYPE_ISO14443_4_MIFARE_PLUS_SL2 ||
02615                         uiTagHandlerType == FedmIscTagHandler::TYPE_ISO14443_4_MIFARE_PLUS_SL3 )
02616         {
02617                 FEDM_TRACE(m_pLogger, FELOGMNG_DBG_ERROR, __FUNCTION__ << " Not applicable for ISO 14443 and EPC C1G2 TagHandler ");
02618                 SetLastError(FEDM_ERROR_UNSUPPORTED);
02619                 return NULL;
02620         }
02621 #endif
02622 
02623 #if !defined(_FEDM_NO_TAG_HANDLER_ISO15693)
02624         else if(uiTagHandlerType == FedmIscTagHandler::TYPE_ISO15693)
02625         {
02626                 if(tabItem->m_pTagHandler != NULL)
02627                 {
02628                         if(dynamic_cast<FedmIscTagHandler_ISO15693*>(tabItem->m_pTagHandler) == NULL)
02629                         {
02630                                 delete tabItem->m_pTagHandler;
02631                                 tabItem->m_pTagHandler = NULL;
02632                                 pNewTagHandler = new FedmIscTagHandler_ISO15693(this, tabItem);
02633                         }
02634                         else
02635                         {
02636                                 pNewTagHandler = tabItem->m_pTagHandler;
02637                         }
02638                 }
02639                 else
02640                 {
02641                         pNewTagHandler = new FedmIscTagHandler_ISO15693(this, tabItem);
02642                 }
02643         }
02644         else if(uiTagHandlerType == FedmIscTagHandler::TYPE_ISO15693_EM ||
02645                         uiTagHandlerType == FedmIscTagHandler::TYPE_ISO15693_Fujitsu ||
02646                         uiTagHandlerType == FedmIscTagHandler::TYPE_ISO15693_MAXIM ||
02647                         uiTagHandlerType == FedmIscTagHandler::TYPE_ISO15693_NXP ||
02648                         uiTagHandlerType == FedmIscTagHandler::TYPE_ISO15693_STM ||
02649                         uiTagHandlerType == FedmIscTagHandler::TYPE_ISO15693_TI ||
02650                         uiTagHandlerType == FedmIscTagHandler::TYPE_ISO15693_TI_Tag_it_HFI_Pro )
02651         {
02652                 FEDM_TRACE(m_pLogger, FELOGMNG_DBG_ERROR, __FUNCTION__ << " Not applicable for this ISO 15693 TagHandler: " << std::hex << std::uppercase << uiTagHandlerType);
02653                 SetLastError(FEDM_ERROR_UNSUPPORTED);
02654                 return NULL;
02655         }
02656         
02657         
02658         else if(uiTagHandlerType == FedmIscTagHandler::TYPE_ISO15693_EM_4034)
02659         {
02660                 if(tabItem->m_pTagHandler != NULL)
02661                 {
02662                         if(dynamic_cast<FedmIscTagHandler_ISO15693_EM_4034*>(tabItem->m_pTagHandler) == NULL)
02663                         {
02664                                 delete tabItem->m_pTagHandler;
02665                                 tabItem->m_pTagHandler = NULL;
02666                                 pNewTagHandler = new FedmIscTagHandler_ISO15693_EM_4034(this, tabItem);
02667                         }
02668                         else
02669                         {
02670                                 pNewTagHandler = tabItem->m_pTagHandler;
02671                         }
02672                 }
02673                 else
02674                 {
02675                         pNewTagHandler = new FedmIscTagHandler_ISO15693_EM_4034(this, tabItem);
02676                 }
02677         }
02678         else if(uiTagHandlerType == FedmIscTagHandler::TYPE_ISO15693_Fujitsu_MB89R1xx)
02679         {
02680                 if(tabItem->m_pTagHandler != NULL)
02681                 {
02682                         if(dynamic_cast<FedmIscTagHandler_ISO15693_Fujitsu_MB89R1xx*>(tabItem->m_pTagHandler) == NULL)
02683                         {
02684                                 delete tabItem->m_pTagHandler;
02685                                 tabItem->m_pTagHandler = NULL;
02686                                 pNewTagHandler = new FedmIscTagHandler_ISO15693_Fujitsu_MB89R1xx(this, tabItem);
02687                         }
02688                         else
02689                         {
02690                                 pNewTagHandler = tabItem->m_pTagHandler;
02691                         }
02692                 }
02693                 else
02694                 {
02695                         pNewTagHandler = new FedmIscTagHandler_ISO15693_Fujitsu_MB89R1xx(this, tabItem);
02696                 }
02697         }
02698         else if(uiTagHandlerType == FedmIscTagHandler::TYPE_ISO15693_IDS_SL13A)
02699         {
02700                 if(tabItem->m_pTagHandler != NULL)
02701                 {
02702                         if(dynamic_cast<FedmIscTagHandler_ISO15693_IDS_SL13A*>(tabItem->m_pTagHandler) == NULL)
02703                         {
02704                                 delete tabItem->m_pTagHandler;
02705                                 tabItem->m_pTagHandler = NULL;
02706                                 pNewTagHandler = new FedmIscTagHandler_ISO15693_IDS_SL13A(this, tabItem);
02707                         }
02708                         else
02709                         {
02710                                 pNewTagHandler = tabItem->m_pTagHandler;
02711                         }
02712                 }
02713                 else
02714                 {
02715                         pNewTagHandler = new FedmIscTagHandler_ISO15693_IDS_SL13A(this, tabItem);
02716                 }
02717         }
02718         else if(uiTagHandlerType == FedmIscTagHandler::TYPE_ISO15693_Infineon)
02719         {
02720                 if(tabItem->m_pTagHandler != NULL)
02721                 {
02722                         if(dynamic_cast<FedmIscTagHandler_ISO15693_Infineon*>(tabItem->m_pTagHandler) == NULL)
02723                         {
02724                                 delete tabItem->m_pTagHandler;
02725                                 tabItem->m_pTagHandler = NULL;
02726                                 pNewTagHandler = new FedmIscTagHandler_ISO15693_Infineon(this, tabItem);
02727                         }
02728                         else
02729                         {
02730                                 pNewTagHandler = tabItem->m_pTagHandler;
02731                         }
02732                 }
02733                 else
02734                 {
02735                         pNewTagHandler = new FedmIscTagHandler_ISO15693_Infineon(this, tabItem);
02736                 }
02737         }
02738         else if(uiTagHandlerType == FedmIscTagHandler::TYPE_ISO15693_Infineon_my_d)
02739         {
02740                 if(tabItem->m_pTagHandler != NULL)
02741                 {
02742                         if(dynamic_cast<FedmIscTagHandler_ISO15693_Infineon_my_d*>(tabItem->m_pTagHandler) == NULL)
02743                         {
02744                                 delete tabItem->m_pTagHandler;
02745                                 tabItem->m_pTagHandler = NULL;
02746                                 pNewTagHandler = new FedmIscTagHandler_ISO15693_Infineon_my_d(this, tabItem);
02747                         }
02748                         else
02749                         {
02750                                 pNewTagHandler = tabItem->m_pTagHandler;
02751                         }
02752                 }
02753                 else
02754                 {
02755                         pNewTagHandler = new FedmIscTagHandler_ISO15693_Infineon_my_d(this, tabItem);
02756                 }
02757         }
02758         else if(uiTagHandlerType == FedmIscTagHandler::TYPE_ISO15693_KSW)
02759         {
02760                 if(tabItem->m_pTagHandler != NULL)
02761                 {
02762                         if(dynamic_cast<FedmIscTagHandler_ISO15693_KSW*>(tabItem->m_pTagHandler) == NULL)
02763                         {
02764                                 delete tabItem->m_pTagHandler;
02765                                 tabItem->m_pTagHandler = NULL;
02766                                 pNewTagHandler = new FedmIscTagHandler_ISO15693_KSW(this, tabItem);
02767                         }
02768                         else
02769                         {
02770                                 pNewTagHandler = tabItem->m_pTagHandler;
02771                         }
02772                 }
02773                 else
02774                 {
02775                         pNewTagHandler = new FedmIscTagHandler_ISO15693_KSW(this, tabItem);
02776                 }
02777         }
02778         else if(uiTagHandlerType == FedmIscTagHandler::TYPE_ISO15693_MAXIM_MAX66100)
02779         {
02780                 if(tabItem->m_pTagHandler != NULL)
02781                 {
02782                         if(dynamic_cast<FedmIscTagHandler_ISO15693_Maxim_MAX66100*>(tabItem->m_pTagHandler) == NULL)
02783                         {
02784                                 delete tabItem->m_pTagHandler;
02785                                 tabItem->m_pTagHandler = NULL;
02786                                 pNewTagHandler = new FedmIscTagHandler_ISO15693_Maxim_MAX66100(this, tabItem);
02787                         }
02788                         else
02789                         {
02790                                 pNewTagHandler = tabItem->m_pTagHandler;
02791                         }
02792                 }
02793                 else
02794                 {
02795                         pNewTagHandler = new FedmIscTagHandler_ISO15693_Maxim_MAX66100(this, tabItem);
02796                 }
02797         }
02798         else if(uiTagHandlerType == FedmIscTagHandler::TYPE_ISO15693_MAXIM_MAX66120)
02799         {
02800                 if(tabItem->m_pTagHandler != NULL)
02801                 {
02802                         if(dynamic_cast<FedmIscTagHandler_ISO15693_Maxim_MAX66120*>(tabItem->m_pTagHandler) == NULL)
02803                         {
02804                                 delete tabItem->m_pTagHandler;
02805                                 tabItem->m_pTagHandler = NULL;
02806                                 pNewTagHandler = new FedmIscTagHandler_ISO15693_Maxim_MAX66120(this, tabItem);
02807                         }
02808                         else
02809                         {
02810                                 pNewTagHandler = tabItem->m_pTagHandler;
02811                         }
02812                 }
02813                 else
02814                 {
02815                         pNewTagHandler = new FedmIscTagHandler_ISO15693_Maxim_MAX66120(this, tabItem);
02816                 }
02817         }
02818         else if(uiTagHandlerType == FedmIscTagHandler::TYPE_ISO15693_MAXIM_MAX66140)
02819         {
02820                 if(tabItem->m_pTagHandler != NULL)
02821                 {
02822                         if(dynamic_cast<FedmIscTagHandler_ISO15693_Maxim_MAX66140*>(tabItem->m_pTagHandler) == NULL)
02823                         {
02824                                 delete tabItem->m_pTagHandler;
02825                                 tabItem->m_pTagHandler = NULL;
02826                                 pNewTagHandler = new FedmIscTagHandler_ISO15693_Maxim_MAX66140(this, tabItem);
02827                         }
02828                         else
02829                         {
02830                                 pNewTagHandler = tabItem->m_pTagHandler;
02831                         }
02832                 }
02833                 else
02834                 {
02835                         pNewTagHandler = new FedmIscTagHandler_ISO15693_Maxim_MAX66140(this, tabItem);
02836                 }
02837         }
02838         else if(uiTagHandlerType == FedmIscTagHandler::TYPE_ISO15693_NXP_ICODE_SLI)
02839         {
02840                 if(tabItem->m_pTagHandler != NULL)
02841                 {
02842                         if(dynamic_cast<FedmIscTagHandler_ISO15693_NXP_ICODE_SLI*>(tabItem->m_pTagHandler) == NULL)
02843                         {
02844                                 delete tabItem->m_pTagHandler;
02845                                 tabItem->m_pTagHandler = NULL;
02846                                 pNewTagHandler = new FedmIscTagHandler_ISO15693_NXP_ICODE_SLI(this, tabItem);
02847                         }
02848                         else
02849                         {
02850                                 pNewTagHandler = tabItem->m_pTagHandler;
02851                         }
02852                 }
02853                 else
02854                 {
02855                         pNewTagHandler = new FedmIscTagHandler_ISO15693_NXP_ICODE_SLI(this, tabItem);
02856                 }
02857         }
02858         else if(uiTagHandlerType == FedmIscTagHandler::TYPE_ISO15693_NXP_ICODE_SLI_L)
02859         {
02860                 if(tabItem->m_pTagHandler != NULL)
02861                 {
02862                         if(dynamic_cast<FedmIscTagHandler_ISO15693_NXP_ICODE_SLI_L*>(tabItem->m_pTagHandler) == NULL)
02863                         {
02864                                 delete tabItem->m_pTagHandler;
02865                                 tabItem->m_pTagHandler = NULL;
02866                                 pNewTagHandler = new FedmIscTagHandler_ISO15693_NXP_ICODE_SLI_L(this, tabItem);
02867                         }
02868                         else
02869                         {
02870                                 pNewTagHandler = tabItem->m_pTagHandler;
02871                         }
02872                 }
02873                 else
02874                 {
02875                         pNewTagHandler = new FedmIscTagHandler_ISO15693_NXP_ICODE_SLI_L(this, tabItem);
02876                 }
02877         }
02878         else if(uiTagHandlerType == FedmIscTagHandler::TYPE_ISO15693_NXP_ICODE_SLI_S)
02879         {
02880                 if(tabItem->m_pTagHandler != NULL)
02881                 {
02882                         if(dynamic_cast<FedmIscTagHandler_ISO15693_NXP_ICODE_SLI_S*>(tabItem->m_pTagHandler) == NULL)
02883                         {
02884                                 delete tabItem->m_pTagHandler;
02885                                 tabItem->m_pTagHandler = NULL;
02886                                 pNewTagHandler = new FedmIscTagHandler_ISO15693_NXP_ICODE_SLI_S(this, tabItem);
02887                         }
02888                         else
02889                         {
02890                                 pNewTagHandler = tabItem->m_pTagHandler;
02891                         }
02892                 }
02893                 else
02894                 {
02895                         pNewTagHandler = new FedmIscTagHandler_ISO15693_NXP_ICODE_SLI_S(this, tabItem);
02896                 }
02897         }
02898         else if(uiTagHandlerType == FedmIscTagHandler::TYPE_ISO15693_NXP_ICODE_SLIX)
02899         {
02900                 if(tabItem->m_pTagHandler != NULL)
02901                 {
02902                         if(dynamic_cast<FedmIscTagHandler_ISO15693_NXP_ICODE_SLIX*>(tabItem->m_pTagHandler) == NULL)
02903                         {
02904                                 delete tabItem->m_pTagHandler;
02905                                 tabItem->m_pTagHandler = NULL;
02906                                 pNewTagHandler = new FedmIscTagHandler_ISO15693_NXP_ICODE_SLIX(this, tabItem);
02907                         }
02908                         else
02909                         {
02910                                 pNewTagHandler = tabItem->m_pTagHandler;
02911                         }
02912                 }
02913                 else
02914                 {
02915                         pNewTagHandler = new FedmIscTagHandler_ISO15693_NXP_ICODE_SLIX(this, tabItem);
02916                 }
02917         }
02918         else if(uiTagHandlerType == FedmIscTagHandler::TYPE_ISO15693_NXP_ICODE_SLIX_L)
02919         {
02920                 if(tabItem->m_pTagHandler != NULL)
02921                 {
02922                         if(dynamic_cast<FedmIscTagHandler_ISO15693_NXP_ICODE_SLIX_L*>(tabItem->m_pTagHandler) == NULL)
02923                         {
02924                                 delete tabItem->m_pTagHandler;
02925                                 tabItem->m_pTagHandler = NULL;
02926                                 pNewTagHandler = new FedmIscTagHandler_ISO15693_NXP_ICODE_SLIX_L(this, tabItem);
02927                         }
02928                         else
02929                         {
02930                                 pNewTagHandler = tabItem->m_pTagHandler;
02931                         }
02932                 }
02933                 else
02934                 {
02935                         pNewTagHandler = new FedmIscTagHandler_ISO15693_NXP_ICODE_SLIX_L(this, tabItem);
02936                 }
02937         }
02938         else if(uiTagHandlerType == FedmIscTagHandler::TYPE_ISO15693_NXP_ICODE_SLIX_S)
02939         {
02940                 if(tabItem->m_pTagHandler != NULL)
02941                 {
02942                         if(dynamic_cast<FedmIscTagHandler_ISO15693_NXP_ICODE_SLIX_S*>(tabItem->m_pTagHandler) == NULL)
02943                         {
02944                                 delete tabItem->m_pTagHandler;
02945                                 tabItem->m_pTagHandler = NULL;
02946                                 pNewTagHandler = new FedmIscTagHandler_ISO15693_NXP_ICODE_SLIX_S(this, tabItem);
02947                         }
02948                         else
02949                         {
02950                                 pNewTagHandler = tabItem->m_pTagHandler;
02951                         }
02952                 }
02953                 else
02954                 {
02955                         pNewTagHandler = new FedmIscTagHandler_ISO15693_NXP_ICODE_SLIX_S(this, tabItem);
02956                 }
02957         }
02958         else if(uiTagHandlerType == FedmIscTagHandler::TYPE_ISO15693_STM_LRI2K)
02959         {
02960                 if(tabItem->m_pTagHandler != NULL)
02961                 {
02962                         if(dynamic_cast<FedmIscTagHandler_ISO15693_STM_LRI2K*>(tabItem->m_pTagHandler) == NULL)
02963                         {
02964                                 delete tabItem->m_pTagHandler;
02965                                 tabItem->m_pTagHandler = NULL;
02966                                 pNewTagHandler = new FedmIscTagHandler_ISO15693_STM_LRI2K(this, tabItem);
02967                         }
02968                         else
02969                         {
02970                                 pNewTagHandler = tabItem->m_pTagHandler;
02971                         }
02972                 }
02973                 else
02974                 {
02975                         pNewTagHandler = new FedmIscTagHandler_ISO15693_STM_LRI2K(this, tabItem);
02976                 }
02977         }
02978         else if(uiTagHandlerType == FedmIscTagHandler::TYPE_ISO15693_STM_LRIS2K)
02979         {
02980                 if(tabItem->m_pTagHandler != NULL)
02981                 {
02982                         if(dynamic_cast<FedmIscTagHandler_ISO15693_STM_LRIS2K*>(tabItem->m_pTagHandler) == NULL)
02983                         {
02984                                 delete tabItem->m_pTagHandler;
02985                                 tabItem->m_pTagHandler = NULL;
02986                                 pNewTagHandler = new FedmIscTagHandler_ISO15693_STM_LRIS2K(this, tabItem);
02987                         }
02988                         else
02989                         {
02990                                 pNewTagHandler = tabItem->m_pTagHandler;
02991                         }
02992                 }
02993                 else
02994                 {
02995                         pNewTagHandler = new FedmIscTagHandler_ISO15693_STM_LRIS2K(this, tabItem);
02996                 }
02997         }
02998         else if(uiTagHandlerType == FedmIscTagHandler::TYPE_ISO15693_STM_LRIS64K)
02999         {
03000                 if(tabItem->m_pTagHandler != NULL)
03001                 {
03002                         if(dynamic_cast<FedmIscTagHandler_ISO15693_STM_LRIS64K*>(tabItem->m_pTagHandler) == NULL)
03003                         {
03004                                 delete tabItem->m_pTagHandler;
03005                                 tabItem->m_pTagHandler = NULL;
03006                                 pNewTagHandler = new FedmIscTagHandler_ISO15693_STM_LRIS64K(this, tabItem);
03007                         }
03008                         else
03009                         {
03010                                 pNewTagHandler = tabItem->m_pTagHandler;
03011                         }
03012                 }
03013                 else
03014                 {
03015                         pNewTagHandler = new FedmIscTagHandler_ISO15693_STM_LRIS64K(this, tabItem);
03016                 }
03017         }
03018         else if(uiTagHandlerType == FedmIscTagHandler::TYPE_ISO15693_STM_M24LR64R)
03019         {
03020                 if(tabItem->m_pTagHandler != NULL)
03021                 {
03022                         if(dynamic_cast<FedmIscTagHandler_ISO15693_STM_M24LR64R*>(tabItem->m_pTagHandler) == NULL)
03023                         {
03024                                 delete tabItem->m_pTagHandler;
03025                                 tabItem->m_pTagHandler = NULL;
03026                                 pNewTagHandler = new FedmIscTagHandler_ISO15693_STM_M24LR64R(this, tabItem);
03027                         }
03028                         else
03029                         {
03030                                 pNewTagHandler = tabItem->m_pTagHandler;
03031                         }
03032                 }
03033                 else
03034                 {
03035                         pNewTagHandler = new FedmIscTagHandler_ISO15693_STM_M24LR64R(this, tabItem);
03036                 }
03037         }
03038         else if(uiTagHandlerType == FedmIscTagHandler::TYPE_ISO15693_STM_M24LRxxER)
03039         {
03040                 if(tabItem->m_pTagHandler != NULL)
03041                 {
03042                         if(dynamic_cast<FedmIscTagHandler_ISO15693_STM_M24LRxxER*>(tabItem->m_pTagHandler) == NULL)
03043                         {
03044                                 delete tabItem->m_pTagHandler;
03045                                 tabItem->m_pTagHandler = NULL;
03046                                 pNewTagHandler = new FedmIscTagHandler_ISO15693_STM_M24LRxxER(this, tabItem);
03047                         }
03048                         else
03049                         {
03050                                 pNewTagHandler = tabItem->m_pTagHandler;
03051                         }
03052                 }
03053                 else
03054                 {
03055                         pNewTagHandler = new FedmIscTagHandler_ISO15693_STM_M24LRxxER(this, tabItem);
03056                 }
03057         }
03058         else if(uiTagHandlerType == FedmIscTagHandler::TYPE_ISO15693_TI_Tag_it_HFI_Plus)
03059         {
03060                 if(tabItem->m_pTagHandler != NULL)
03061                 {
03062                         if(dynamic_cast<FedmIscTagHandler_ISO15693_TI_Tag_it_HFI_Plus*>(tabItem->m_pTagHandler) == NULL)
03063                         {
03064                                 delete tabItem->m_pTagHandler;
03065                                 tabItem->m_pTagHandler = NULL;
03066                                 pNewTagHandler = new FedmIscTagHandler_ISO15693_TI_Tag_it_HFI_Plus(this, tabItem);
03067                         }
03068                         else
03069                         {
03070                                 pNewTagHandler = tabItem->m_pTagHandler;
03071                         }
03072                 }
03073                 else
03074                 {
03075                         pNewTagHandler = new FedmIscTagHandler_ISO15693_TI_Tag_it_HFI_Plus(this, tabItem);
03076                 }
03077         }
03078 #endif
03079 #if !defined(_FEDM_NO_TAG_HANDLER_ISO18000_3M3)
03080         else if(uiTagHandlerType == FedmIscTagHandler::TYPE_ISO18000_3M3)
03081         {
03082                 if(tabItem->m_pTagHandler != NULL)
03083                 {
03084                         if(dynamic_cast<FedmIscTagHandler_ISO18000_3M3*>(tabItem->m_pTagHandler) == NULL)
03085                         {
03086                                 delete tabItem->m_pTagHandler;
03087                                 tabItem->m_pTagHandler = NULL;
03088                                 pNewTagHandler = new FedmIscTagHandler_ISO18000_3M3(this, tabItem);
03089                         }
03090                         else
03091                         {
03092                                 pNewTagHandler = tabItem->m_pTagHandler;
03093                         }
03094                 }
03095                 else
03096                 {
03097                         pNewTagHandler = new FedmIscTagHandler_ISO18000_3M3(this, tabItem);
03098                 }
03099         }
03100 #endif
03101         else
03102         {
03103                 FEDM_TRACE(m_pLogger, FELOGMNG_DBG_ERROR, __FUNCTION__ << " Unknown TagHandler-Type " << std::hex << std::uppercase << uiTagHandlerType);
03104                 SetLastError(FEDM_ERROR_UNKNOWN_TAG_HANDLER_TYPE);
03105                 return NULL;
03106         }
03107 
03108         if (pNewTagHandler != NULL)
03109         {
03110                 // insert new taghandler and mark it for use in non-addressed mode
03111                 tabItem->m_pTagHandler = pNewTagHandler;
03112                 pNewTagHandler->m_bNonAddressedMode = true;
03113         }
03114         else
03115         {
03116                 FEDM_TRACE(m_pLogger, FELOGMNG_DBG_ERROR, __FUNCTION__ << " Creation of TagHandler failed - no more mem");
03117                 SetLastError(FEDM_ERROR_NO_MORE_MEM);
03118         }
03119 
03120         return pNewTagHandler;
03121 }
03122 #endif
03123 
03124 /***************************************************************************
03125   Begin                 :       25.10.2010 / M. Hultsch
03126   Version               :       03.02.07 / 25.10.2010 / M. Hultsch
03127 
03128   Function                      :       convert a taghandler to the specified type
03129 
03130   Parameters            :       FedmIscTagHandler*      pTagHandler                     pointer to the source tag handler
03131                         unsigned char ucMfrCode                                 Manufacturer Code
03132                                                 uiTagHandlerType                                                target type
03133 
03134   Return value          :       FedmIscTagHandler or null
03135 ***************************************************************************/
03136 #ifdef _FEDM_TAG_HANDLER
03137 #if !defined(_FEDM_NO_TAG_HANDLER_EPC_C1_G2)
03138 FedmIscTagHandler* FEDM_ISCReaderModule::Convert_EPC_C1_G2_TagHandler(FedmIscTagHandler* pTagHandler, unsigned char ucMfrCode, unsigned int uiTagHandlerType)
03139 {
03140         FEDM_TRACE_FNC(m_pLogger, FELOGMNG_DBG_FUNCTION_CALL | FELOGMNG_DBG_LF_COMM_TAG_HANDLER, __FUNCTION__, FELOGMNG_DBG_FUNCTION_PARAMETER, "MfrCode=0x" << std::hex <<::std::uppercase << (int)ucMfrCode << "TagHandlerType=0x" << std::hex <<::std::uppercase << uiTagHandlerType);
03141         
03142         if( !m_bEnableTagHandler )
03143         {
03144                 FEDM_TRACE(m_pLogger, FELOGMNG_DBG_ERROR, __FUNCTION__ << " Support for TagHandler disabled");
03145                 SetLastError(FEDM_ERROR_UNSUPPORTED);
03146                 return NULL;
03147         }
03148 
03149         if(pTagHandler == NULL)
03150         {
03151                 FEDM_TRACE(m_pLogger, FELOGMNG_DBG_ERROR, __FUNCTION__ << " TagHandler is NULL");
03152                 SetLastError(FEDM_ERROR_NULL_POINTER);
03153                 return NULL;
03154         }
03155 
03156         if(dynamic_cast<FedmIscTagHandler_EPC_Class1_Gen2*>(pTagHandler) == NULL)
03157         {
03158                 FEDM_TRACE(m_pLogger, FELOGMNG_DBG_ERROR, __FUNCTION__ << " TagHandler is not of type EPC C1G2");
03159                 SetLastError(FEDM_ERROR_UNSUPPORTED_TRANSPONDER_TYPE);
03160                 return NULL;
03161         }
03162 
03163         int iIdx = pTagHandler->m_pTabItem->m_uiTabIndex;
03164 
03165         switch(ucMfrCode)
03166         {
03167         case FEDM_ISC_ISO_MFR_IDS:
03168                 if(uiTagHandlerType == FedmIscTagHandler::TYPE_EPC_CLASS1_GEN2_IDS_SL900A)
03169                 {
03170                         FedmIscTagHandler_EPC_Class1_Gen2_IDS_SL900A* pNewTagHandler = NULL;
03171                         pNewTagHandler = new FedmIscTagHandler_EPC_Class1_Gen2_IDS_SL900A(this, pTagHandler->m_pTabItem);
03172                         if(pNewTagHandler != NULL)
03173                         {
03174                                 delete pTagHandler;
03175                                 m_ISOTable[iIdx]->m_pTagHandler = (FedmIscTagHandler*)pNewTagHandler;
03176                                 return (FedmIscTagHandler*)pNewTagHandler;
03177                         }
03178                 }
03179                 break;
03180 
03181         default:
03182                 FEDM_TRACE(m_pLogger, FELOGMNG_DBG_ERROR, __FUNCTION__ << " Unsupported manufacturer code");
03183                 break;
03184         }
03185 
03186         SetLastError(FEDM_ERROR_PARAMETER);
03187         return NULL;
03188 }
03189 #endif
03190 #endif
03191 
03192 
03194 // methods for executing asynchronous tasks
03196 
03197 /***************************************************************************
03198   Begin                 :       20.02.2006 / M. Hultsch
03199 
03200   Version               :       04.02.08 / 13.08.2012 / M. Hultsch
03201                                                 - support for events from People Counter
03202 
03203                                                 03.00.13 / 24.09.2009 / M. Hultsch
03204                                                 - add of MAX event handling
03205 
03206                                                 02.04.04 / 25.08.2006 / M. Hultsch
03207 
03208   Function                      :       function to execute an asynchronous task
03209 
03210   Parameters            :       initialization structure
03211 
03212   Return value          :       FEDM_OK (0) or error code (<0)
03213 ***************************************************************************/
03214 int FEDM_ISCReaderModule::StartAsyncTask(FEDM_TASK_INIT* pInit)
03215 {
03216         int iBack = 0;
03217         string sDbgMsg;
03218         FEISC_TASK_INIT         TI;
03219 
03220         if(pInit == NULL)
03221         {
03222                 FEDM_TRACE(m_pLogger, FELOGMNG_DBG_ERROR, __FUNCTION__ <<  " pInit=NULL");              
03223                 FEDM_RETURN(FEDM_ERROR_NULL_POINTER);
03224         }
03225 
03226         // filter unsupported flags
03227         switch(pInit->uiFlag)
03228         {
03229         case FEDM_TASKCB1:
03230                 sDbgMsg = "Flag=CB1";
03231                 if(pInit->cbFct1 == NULL)
03232                         iBack = FEDM_ERROR_NULL_POINTER;
03233                 break;
03234         case FEDM_TASKCB2:
03235                 sDbgMsg = "Flag=CB2";
03236                 if(pInit->cbFct2 == NULL)
03237                         iBack = FEDM_ERROR_NULL_POINTER;
03238                 break;
03239 #ifdef _FEDM_WINDOWS
03240         case FEDM_TASKCB_NET1:
03241                 sDbgMsg = "Flag=CBNet1";
03242                 if(pInit->cbFctNET1 == NULL)
03243                         iBack = FEDM_ERROR_NULL_POINTER;
03244                 break;
03245 #endif
03246         default:
03247                 iBack = FEDM_ERROR_UNSUPPORTED;
03248         }
03249 
03250         // filter unsupported events
03251         switch(pInit->uiUse)
03252         {
03253         case FEDM_TASKID_FIRST_NEW_TAG:
03254                 sDbgMsg += ", Use=FirstNewTag";
03255                 switch(pInit->uiFlag)
03256                 {
03257                 case FEDM_TASKCB1:
03258                 case FEDM_TASKCB_NET1:
03259                         break;
03260                 default:
03261                         iBack = FEDM_ERROR_UNSUPPORTED;
03262                 }
03263                 break;
03264 
03265         case FEDM_TASKID_EVERY_NEW_TAG:
03266                 sDbgMsg += ", Use=EveryNewTag";
03267                 switch(pInit->uiFlag)
03268                 {
03269                 case FEDM_TASKCB1:
03270                 case FEDM_TASKCB_NET1:
03271                         break;
03272                 default:
03273                         iBack = FEDM_ERROR_UNSUPPORTED;
03274                 }
03275                 break;
03276 
03277         case FEDM_TASKID_NOTIFICATION:
03278                 sDbgMsg += ", Use=Notification";
03279                 switch(pInit->uiFlag)
03280                 {
03281                 case FEDM_TASKCB1:
03282                 case FEDM_TASKCB2:
03283                 case FEDM_TASKCB_NET1: // TODO - verify
03284                         break;
03285                 default:
03286                         iBack = FEDM_ERROR_UNSUPPORTED;
03287                 }
03288                 break;
03289 
03290 /*      case FEDM_TASKID_PEOPLE_COUNTER_EVENT:
03291                 sDbgMsg += ", Use=PeopleCounterEvent";
03292                 switch(pInit->uiFlag)
03293                 {
03294                 case FEDM_TASKCB1:
03295                 case FEDM_TASKCB2:
03296                 case FEDM_TASKCB_NET1: // TODO - verify
03297                         break;
03298                 default:
03299                         iBack = FEDM_ERROR_UNSUPPORTED;
03300                 }
03301                 break;*/
03302 
03303         default:
03304                 iBack = FEDM_ERROR_UNSUPPORTED;
03305         }
03306 
03307         if(pInit->bCryptoMode)
03308                 sDbgMsg += ", Crypto=On";
03309         else
03310                 sDbgMsg += ", Crypto=Off";
03311 
03312         if(pInit->bKeepAlive)
03313                 sDbgMsg += ", KeepAlive=On";
03314         else
03315                 sDbgMsg += ", KeepAlive=Off";
03316 
03317         FEDM_TRACE_FNC(m_pLogger, FELOGMNG_DBG_FUNCTION_CALL | FELOGMNG_DBG_LF_EVENTING, __FUNCTION__, FELOGMNG_DBG_FUNCTION_PARAMETER, sDbgMsg);
03318 
03319         if(iBack < 0)
03320         {
03321                 FEDM_TRACE(m_pLogger, FELOGMNG_DBG_ERROR, __FUNCTION__ << " " << GetErrorText(iBack));
03322                 FEDM_RETURN(iBack);
03323         }
03324 
03325         memset(&m_TaskInit, 0, sizeof(FEDM_TASK_INIT));
03326         m_TaskInit.uiFlag                       = pInit->uiFlag;
03327         m_TaskInit.uiUse                        = pInit->uiUse;
03328         m_TaskInit.pAny                         = pInit->pAny;
03329         m_TaskInit.iConnectByHost       = pInit->iConnectByHost;
03330         m_TaskInit.iNotifyWithAck       = pInit->iNotifyWithAck;
03331         m_TaskInit.uiTimeout            = pInit->uiTimeout;
03332         if(pInit->bCryptoMode)
03333         {
03334                 m_TaskInit.bCryptoMode = true;
03335                 if(     pInit->uiAuthentKeyLength != 16 &&
03336                         pInit->uiAuthentKeyLength != 24 &&
03337                         pInit->uiAuthentKeyLength != 32)
03338                 {
03339                         FEDM_TRACE(m_pLogger, FELOGMNG_DBG_ERROR, __FUNCTION__ << " " << GetErrorText(FEDM_ERROR_PARAMETER));
03340                         FEDM_RETURN(FEDM_ERROR_PARAMETER);
03341                 }
03342                 m_TaskInit.uiAuthentKeyLength   = pInit->uiAuthentKeyLength;
03343                 memcpy(m_TaskInit.ucAuthentKey, pInit->ucAuthentKey, pInit->uiAuthentKeyLength);
03344         }
03345         if(pInit->bKeepAlive)
03346         {
03347                 m_TaskInit.bKeepAlive = true;
03348                 m_TaskInit.uiKeepAliveIdleTime = pInit->uiKeepAliveIdleTime;
03349                 m_TaskInit.uiKeepAliveProbeCount = pInit->uiKeepAliveProbeCount;
03350                 m_TaskInit.uiKeepAliveIntervalTime = pInit->uiKeepAliveIntervalTime;
03351         }
03352 
03353         // flag dependent initialization
03354         switch(pInit->uiFlag)
03355         {
03356         case FEDM_TASKCB1:
03357                 m_TaskInit.cbFct1       = pInit->cbFct1;
03358                 break;
03359         case FEDM_TASKCB2:
03360                 m_TaskInit.cbFct2       = pInit->cbFct2;
03361                 break;
03362 #ifdef _FEDM_WINDOWS
03363         case FEDM_TASKCB_NET1:
03364                 m_TaskInit.cbFctNET1    = pInit->cbFctNET1;
03365                 break;
03366 #endif
03367         }
03368 
03369         memset(&TI, 0, sizeof(FEISC_TASK_INIT));
03370 
03371         // event dependent initialization
03372         switch(pInit->uiUse)
03373         {
03374         case FEDM_TASKID_FIRST_NEW_TAG:
03375                 TI.uiFlag               = FEISC_TASKCB_1;
03376 #if defined(__BORLANDC__)
03377                 TI.cbFct1               = (void(*)(void*, int, int, int, unsigned char, unsigned char*, int))cbsTaskRsp1;               // static member function
03378 #else
03379                 TI.cbFct1               = cbsTaskRsp1;          // static member function
03380 #endif
03381                 TI.uiChannelType = FEISC_TASK_CHANNEL_TYPE_AS_OPEN;
03382                 TI.ucBusAdr             = GetBusAddress();
03383                 TI.iConnectByHost = 0; // unused
03384                 memset(TI.cIPAdr, 0, 16);
03385                 TI.iPortNr              = 0;
03386                 TI.pAny                 = (void*)this;          // backpointer to caller object
03387                 TI.uiTimeout    = m_TaskInit.uiTimeout;
03388                 if(m_TaskInit.bCryptoMode)
03389                 {
03390                         TI.bCryptoMode = true;
03391                         TI.uiAuthentKeyLength   = m_TaskInit.uiAuthentKeyLength;
03392                         memcpy(TI.ucAuthentKey, m_TaskInit.ucAuthentKey, m_TaskInit.uiAuthentKeyLength);
03393                 }
03394                 FEDM_CHK2(iBack, SetData(FEDM_ISC_TMP_B0_CMD, (unsigned char)0x01));
03395 
03396                 FEDM_CHK2(iBack, FEISC_StartAsyncTask(GetReaderHnd(), FEISC_TASKID_FIRST_NEW_TAG, &TI, NULL));
03397                 break;
03398 
03399         case FEDM_TASKID_EVERY_NEW_TAG:
03400                 TI.uiFlag               = FEISC_TASKCB_1;
03401 #if defined(__BORLANDC__)
03402                 TI.cbFct1               = (void(*)(void*, int, int, int, unsigned char, unsigned char*, int))cbsTaskRsp1;               // static member function
03403 #else
03404                 TI.cbFct1               = cbsTaskRsp1;          // static member function
03405 #endif
03406                 TI.uiChannelType = FEISC_TASK_CHANNEL_TYPE_AS_OPEN;
03407                 TI.ucBusAdr             = GetBusAddress();
03408                 TI.iConnectByHost = 0; // unused
03409                 memset(TI.cIPAdr, 0, 16);
03410                 TI.iPortNr              = 0;
03411                 TI.pAny                 = (void*)this;          // backpointer to caller object
03412                 TI.uiTimeout    = m_TaskInit.uiTimeout;
03413                 if(m_TaskInit.bCryptoMode)
03414                 {
03415                         TI.bCryptoMode = true;
03416                         TI.uiAuthentKeyLength   = m_TaskInit.uiAuthentKeyLength;
03417                         memcpy(TI.ucAuthentKey, m_TaskInit.ucAuthentKey, m_TaskInit.uiAuthentKeyLength);
03418                 }
03419                 FEDM_CHK2(iBack, SetData(FEDM_ISC_TMP_B0_CMD, (unsigned char)0x01));
03420 
03421                 FEDM_CHK2(iBack, FEISC_StartAsyncTask(GetReaderHnd(), FEISC_TASKID_EVERY_NEW_TAG, &TI, NULL));
03422                 break;
03423 
03424         case FEDM_TASKID_NOTIFICATION:
03425         //case FEDM_TASKID_PEOPLE_COUNTER_EVENT:
03426                 TI.uiFlag               = FEISC_TASKCB_2;
03427 #if defined(__BORLANDC__)
03428                 TI.cbFct2               = (void(*)(void*, int, int, int, unsigned char, unsigned char*, int, char*, int))cbsTaskRsp2;           // static member function
03429 #else
03430                 TI.cbFct2               = cbsTaskRsp2;          // static member function
03431 #endif
03432                 TI.uiChannelType = FEISC_TASK_CHANNEL_TYPE_NEW_TCP;
03433                 TI.ucBusAdr             = GetBusAddress();
03434                 TI.iConnectByHost = pInit->iConnectByHost;
03435                 strcpy(TI.cIPAdr, pInit->cIPAdr);
03436                 TI.iPortNr              = pInit->iPortNr;
03437                 TI.pAny                 = (void*)this;          // backpointer to caller object
03438                 TI.uiTimeout    = m_TaskInit.uiTimeout;
03439                 TI.iNotifyWithAck = pInit->iNotifyWithAck;
03440                 if(m_TaskInit.bCryptoMode)
03441                 {
03442                         TI.bCryptoMode = true;
03443                         TI.uiAuthentKeyLength   = m_TaskInit.uiAuthentKeyLength;
03444                         memcpy(TI.ucAuthentKey, m_TaskInit.ucAuthentKey, m_TaskInit.uiAuthentKeyLength);
03445                 }
03446                 if(m_TaskInit.bKeepAlive)
03447                 {
03448                         TI.bKeepAlive = true;
03449                         TI.uiKeepAliveIdleTime = m_TaskInit.uiKeepAliveIdleTime;
03450                         TI.uiKeepAliveProbeCount = m_TaskInit.uiKeepAliveProbeCount;
03451                         TI.uiKeepAliveIntervalTime = m_TaskInit.uiKeepAliveIntervalTime;
03452                 }
03453 
03454                 if(pInit->uiUse == FEDM_TASKID_NOTIFICATION)
03455                 {
03456                         FEDM_CHK2(iBack, FEISC_StartAsyncTask(GetReaderHnd(), FEISC_TASKID_NOTIFICATION, &TI, NULL));
03457                 }
03458                 /*else if(pInit->uiUse == FEDM_TASKID_PEOPLE_COUNTER_EVENT)
03459                 {
03460                         FEDM_CHK2(iBack, FEISC_StartAsyncTask(GetReaderHnd(), FEISC_TASKID_PEOPLE_COUNTER_EVENT, &TI, NULL));
03461                 }*/
03462                 break;
03463         }
03464 
03465         m_bActiveAsyncTask = true; // asynchronous task is started successfully
03466 
03467         FEDM_RETURN(FEDM_OK);
03468 }
03469 
03470 int FEDM_ISCReaderModule::CancelAsyncTask()
03471 {
03472         FEDM_TRACE(m_pLogger, FELOGMNG_DBG_FUNCTION_CALL | FELOGMNG_DBG_LF_EVENTING, __FUNCTION__);
03473 
03474         int iBack = 0;
03475 
03476         if(m_bActiveAsyncTask)
03477         {
03478                 FEDM_CHK2(iBack, FEISC_CancelAsyncTask(GetReaderHnd()));
03479                 m_bActiveAsyncTask = false;
03480         }
03481 
03482         FEDM_RETURN(FEDM_OK);
03483 }
03484 
03485 int FEDM_ISCReaderModule::TriggerAsyncTask()
03486 {
03487         FEDM_TRACE(m_pLogger, FELOGMNG_DBG_FUNCTION_CALL | FELOGMNG_DBG_LF_EVENTING, __FUNCTION__);
03488 
03489         int iBack = 0;
03490 
03491         if(m_bActiveAsyncTask)
03492         {
03493                 FEDM_CHK2(iBack, FEISC_TriggerAsyncTask(GetReaderHnd()));
03494         }
03495 
03496         FEDM_RETURN(FEDM_OK);
03497 }
03498 
03499 
03500 
03501 
03503 // parameter exchange with OBID libraries
03505 
03506 /***************************************************************************
03507   Begin                 :       06.11.2003 / M. Hultsch
03508 
03509   Version               :       03.02.03 / 29.07.2010 / M. Hultsch
03510                                                 - PortPrefix for FECOM under Linux to support Bluetooth
03511 
03512                                                 03.01.06 / 31.05.2010 / M. Hultsch
03513                                                 - ExclusiveAccess for FEUSB
03514 
03515                                                 02.03.05 / 14.11.2005 / M. Hultsch
03516                                                 - Modification for uClinux
03517 
03518                                                 02.03.00 / 04.08.2004 / M. Hultsch
03519                                                 - Extension for USB
03520                                                 - SetRTS, SetDTR for serial port
03521 
03522                                                 01.09.00 / 13.11.2003 / M. Hultsch
03523 
03524   Function                      :       sets one port parameter in port library
03525 
03526   Parameters            :       char* cPara             -       pointer to parameter string (see port manual)
03527                                                 char* cValue    -       pointer to value string (see port manual)
03528 
03529   Return value          :       FEDM_OK or error code (<0)
03530 ***************************************************************************/
03531 int FEDM_ISCReaderModule::SetPortPara(char* cPara, char* cValue)
03532 {
03533         FEDM_TRACE_FNC(m_pLogger, FELOGMNG_DBG_FUNCTION_CALL | FELOGMNG_DBG_LF_ADMIN_SET_GET, __FUNCTION__, FELOGMNG_DBG_FUNCTION_PARAMETER, "Para=" << cPara << ", Value=" << cValue);
03534         
03535         int iBack = 0;
03536 
03537 #if defined(_FEDM_COM_SUPPORT)
03538         // it's a global setting
03539         if(strcmp(cPara, "PortPrefix")==0)
03540         {
03541 #if !defined(_FEDM_LINUX)
03542                 return 0;
03543 #else
03544 #if !defined(_FEDM_SUPPORT_SLINK)
03545                 LPFN_FECOM_SET_PORT_PARA lpfnSetPortPara = (LPFN_FECOM_SET_PORT_PARA)GetFeComFunction(FECOM_SET_PORT_PARA);
03546                 FEDM_CHK5(lpfnSetPortPara);
03547                 iBack = lpfnSetPortPara(0, cPara, cValue);
03548                 FEDM_RETURN(iBack);
03549 #else
03550                 iBack = FECOM_SetPortPara(0, cPara, cValue);
03551                 FEDM_RETURN(iBack);
03552 #endif
03553 #endif // #if !defined(_FEDM_LINUX)
03554         }
03555 #endif // #if defined(_FEDM_COM_SUPPORT)
03556 
03557 
03558 #ifdef _FEDM_USB_SUPPORT
03559         // it's a global setting
03560         if(strcmp(cPara, "ExclusiveAccess")==0)
03561         {
03562 #if !defined(_FEDM_SUPPORT_SLINK)
03563                 LPFN_FEUSB_SET_DEVICE_PARA lpfnSetDevicePara = (LPFN_FEUSB_SET_DEVICE_PARA)GetFeUsbFunction(FEUSB_SET_DEVICE_PARA);
03564                 FEDM_CHK5(lpfnSetDevicePara);
03565                 iBack = lpfnSetDevicePara(0, cPara, cValue);
03566                 FEDM_RETURN(iBack);
03567 #else
03568                 iBack = FEUSB_SetDevicePara(0, cPara, cValue);
03569                 FEDM_RETURN(iBack);
03570 #endif
03571         }
03572 #endif // #ifdef _FEDM_USB_SUPPORT
03573 
03574 
03575         if(m_iCommMode == FEDM_COMM_MODE_UNDEF)
03576         {
03577                 FEDM_TRACE(m_pLogger, FELOGMNG_DBG_ERROR, __FUNCTION__ << " " << GetErrorText(FEDM_ERROR_NOT_CONNECTED));
03578                 FEDM_RETURN(FEDM_ERROR_NOT_CONNECTED);
03579         }
03580 
03581         int iPortHnd = GetPortHnd();
03582         if(iPortHnd <= 0)
03583         {
03584                 FEDM_TRACE(m_pLogger, FELOGMNG_DBG_ERROR, __FUNCTION__ << " " << GetErrorText(FEDM_ERROR_NOT_CONNECTED));
03585                 FEDM_RETURN(FEDM_ERROR_NOT_CONNECTED);
03586         }
03587 
03588 
03589 #ifdef _FEDM_COM_SUPPORT
03590 #if !defined(_FEDM_SUPPORT_SLINK)
03591         LPFN_FECOM_SET_PORT_PARA lpfnSetPortPara = (LPFN_FECOM_SET_PORT_PARA)GetFeComFunction(FECOM_SET_PORT_PARA);
03592         LPFN_FECOM_DO_PORT_CMD lpfnDoPortCmd = (LPFN_FECOM_DO_PORT_CMD)GetFeComFunction(FECOM_DO_PORT_CMD);
03593         if(m_iCommMode == FEDM_COMM_MODE_SERIAL)
03594         {
03595                 FEDM_CHK5(lpfnSetPortPara);
03596                 FEDM_CHK5(lpfnDoPortCmd);
03597         }
03598 #endif
03599 #endif
03600 
03601 #ifdef _FEDM_USB_SUPPORT
03602 #if !defined(_FEDM_SUPPORT_SLINK)
03603         LPFN_FEUSB_SET_DEVICE_PARA lpfnSetDevicePara = (LPFN_FEUSB_SET_DEVICE_PARA)GetFeUsbFunction(FEUSB_SET_DEVICE_PARA);
03604         if(m_iCommMode == FEDM_COMM_MODE_USB)
03605         {
03606                 FEDM_CHK5(lpfnSetDevicePara);
03607         }
03608 #endif
03609 #endif
03610 
03611 #ifdef _FEDM_TCP_SUPPORT
03612 #if !defined(_FEDM_SUPPORT_SLINK)
03613         LPFN_FETCP_SET_SOCKET_PARA lpfnSetSocketPara = (LPFN_FETCP_SET_SOCKET_PARA)GetFeTcpFunction(FETCP_SET_SOCKET_PARA);
03614         if(m_iCommMode == FEDM_COMM_MODE_TCP)
03615         {
03616                 FEDM_CHK5(lpfnSetSocketPara);
03617         }
03618 #endif
03619 #endif
03620 
03621 
03622         if(m_iCommMode == FEDM_COMM_MODE_SERIAL)
03623         {
03624 #ifdef _FEDM_COM_SUPPORT
03625                 if(strcmp(cPara, "SetRTS")==0)
03626                 {
03627 #if !defined(_FEDM_SUPPORT_SLINK)
03628                         iBack = lpfnDoPortCmd(iPortHnd, cPara, cValue);
03629                         FEDM_RETURN(iBack);
03630 #else
03631                         iBack = FECOM_DoPortCmd(iPortHnd, cPara, cValue);
03632                         FEDM_RETURN(iBack);
03633 #endif
03634                 }
03635                 else if(strcmp(cPara, "SetDTR")==0)
03636                 {
03637 #if !defined(_FEDM_SUPPORT_SLINK)
03638                         iBack = lpfnDoPortCmd(iPortHnd, cPara, cValue);
03639                         FEDM_RETURN(iBack);
03640 #else
03641                         iBack = FECOM_DoPortCmd(iPortHnd, cPara, cValue);
03642                         FEDM_RETURN(iBack);
03643 #endif
03644                 }
03645                 else
03646                 {
03647 #if !defined(_FEDM_SUPPORT_SLINK)
03648                         iBack = lpfnSetPortPara(iPortHnd, cPara, cValue);
03649                         FEDM_RETURN(iBack);
03650 #else
03651                         iBack = FECOM_SetPortPara(iPortHnd, cPara, cValue);
03652                         FEDM_RETURN(iBack);
03653 #endif
03654                 }
03655 #else
03656                 FEDM_TRACE(m_pLogger, FELOGMNG_DBG_ERROR, __FUNCTION__ << " " << GetErrorText(FEDM_ERROR_UNSUPPORTED));
03657                 FEDM_RETURN(FEDM_ERROR_UNSUPPORTED);
03658 #endif
03659         }
03660         else if(m_iCommMode == FEDM_COMM_MODE_TCP)
03661         {
03662 #ifdef _FEDM_TCP_SUPPORT
03663 #if !defined(_FEDM_SUPPORT_SLINK)
03664                 iBack = lpfnSetSocketPara(iPortHnd, cPara, cValue);
03665                 FEDM_RETURN(iBack);
03666 #else
03667                 iBack = FETCP_SetSocketPara(iPortHnd, cPara, cValue);
03668                 FEDM_RETURN(iBack);
03669 #endif
03670 #else
03671                 FEDM_TRACE(m_pLogger, FELOGMNG_DBG_ERROR, __FUNCTION__ << " " << GetErrorText(FEDM_ERROR_UNSUPPORTED));
03672                 FEDM_RETURN(FEDM_ERROR_UNSUPPORTED);
03673 #endif
03674         }
03675         else if(m_iCommMode == FEDM_COMM_MODE_USB)
03676         {
03677 #ifdef _FEDM_USB_SUPPORT
03678 #if !defined(_FEDM_SUPPORT_SLINK)
03679                 iBack = lpfnSetDevicePara(iPortHnd, cPara, cValue);
03680                 FEDM_RETURN(iBack);
03681 #else
03682                 iBack = FEUSB_SetDevicePara(iPortHnd, cPara, cValue);
03683                 FEDM_RETURN(iBack);
03684 #endif
03685 #else
03686                 FEDM_TRACE(m_pLogger, FELOGMNG_DBG_ERROR, __FUNCTION__ << " " << GetErrorText(FEDM_ERROR_UNSUPPORTED));
03687                 FEDM_RETURN(FEDM_ERROR_UNSUPPORTED);
03688 #endif
03689         }
03690 
03691         FEDM_TRACE(m_pLogger, FELOGMNG_DBG_ERROR, __FUNCTION__ << " " << GetErrorText(FEDM_ERROR_UNSUPPORTED));
03692         FEDM_RETURN(FEDM_ERROR_UNSUPPORTED);
03693 }
03694 
03695 /***************************************************************************
03696   Begin                 :       06.11.2003 / M. Hultsch
03697 
03698   Version               :       03.01.06 / 05.05.2010 / M. Hultsch
03699                                                 - ExclusiveAccess f�r FEUSB
03700 
03701                                                 02.03.05 / 14.11.2005 / M. Hultsch
03702                                                 - Modifikation f�r uClinux
03703 
03704                                                 02.03.00 / 04.05.2004 / M. Hultsch
03705                                                 - Erweiterung f�r USB, TCP
03706 
03707                                                 01.09.00 / 06.11.2003 / M. Hultsch
03708 
03709   Function                      :       sets one port parameter in port library
03710 
03711   Parameters            :       char* cPara             -       pointer to parameter string (see port manual)
03712                                                 int       iValue        -       value (see port manual)
03713 
03714   Return value          :       FEDM_OK or error code (<0)
03715 ***************************************************************************/
03716 int FEDM_ISCReaderModule::SetPortPara(char* cPara, int iValue)
03717 {
03718         FEDM_TRACE_FNC(m_pLogger, FELOGMNG_DBG_FUNCTION_CALL | FELOGMNG_DBG_LF_ADMIN_SET_GET, __FUNCTION__, FELOGMNG_DBG_FUNCTION_PARAMETER, "Para=" << cPara << ", Value=" << iValue);
03719 
03720         int iBack = 0;
03721         char cValue[16];
03722 
03723 #ifdef _FEDM_USB_SUPPORT
03724         // it's a global setting
03725         if(strcmp(cPara, "ExclusiveAccess")==0)
03726         {
03727 #if !defined(_FEDM_SUPPORT_SLINK)
03728                 LPFN_FEUSB_SET_DEVICE_PARA lpfnSetDevicePara = (LPFN_FEUSB_SET_DEVICE_PARA)GetFeUsbFunction(FEUSB_SET_DEVICE_PARA);
03729                 FEDM_CHK5(lpfnSetDevicePara);
03730                 sprintf(cValue,"%d", iValue);
03731                 iBack = lpfnSetDevicePara(0, cPara, cValue);
03732                 FEDM_RETURN(iBack);
03733 #else
03734                 iBack = FEUSB_SetDevicePara(0, cPara, cValue);
03735                 FEDM_RETURN(iBack);
03736 #endif
03737         }
03738 #endif
03739 
03740         if(m_iCommMode == FEDM_COMM_MODE_UNDEF)
03741         {
03742                 FEDM_TRACE(m_pLogger, FELOGMNG_DBG_ERROR, __FUNCTION__ << " " << GetErrorText(FEDM_ERROR_NOT_CONNECTED));
03743                 FEDM_RETURN(FEDM_ERROR_NOT_CONNECTED);
03744         }
03745 
03746         int iPortHnd = GetPortHnd();
03747         if(iPortHnd < 0)
03748         {
03749                 FEDM_TRACE(m_pLogger, FELOGMNG_DBG_ERROR, __FUNCTION__ << " " << GetErrorText(FEDM_ERROR_NOT_CONNECTED));
03750                 FEDM_RETURN(FEDM_ERROR_NOT_CONNECTED);
03751         }
03752 
03753 
03754 #ifdef _FEDM_COM_SUPPORT
03755 #if !defined(_FEDM_SUPPORT_SLINK)
03756         LPFN_FECOM_SET_PORT_PARA lpfnSetPortPara = (LPFN_FECOM_SET_PORT_PARA)GetFeComFunction(FECOM_SET_PORT_PARA);
03757         if(m_iCommMode == FEDM_COMM_MODE_SERIAL)
03758         {
03759                 FEDM_CHK5(lpfnSetPortPara);
03760         }
03761 #endif
03762 #endif
03763 
03764 #ifdef _FEDM_USB_SUPPORT
03765 #if !defined(_FEDM_SUPPORT_SLINK)
03766         LPFN_FEUSB_SET_DEVICE_PARA lpfnSetDevicePara = (LPFN_FEUSB_SET_DEVICE_PARA)GetFeUsbFunction(FEUSB_SET_DEVICE_PARA);
03767         if(m_iCommMode == FEDM_COMM_MODE_USB)
03768         {
03769                 FEDM_CHK5(lpfnSetDevicePara);
03770         }
03771 #endif
03772 #endif
03773 
03774 #ifdef _FEDM_TCP_SUPPORT
03775 #if !defined(_FEDM_SUPPORT_SLINK)
03776         LPFN_FETCP_SET_SOCKET_PARA lpfnSetSocketPara = (LPFN_FETCP_SET_SOCKET_PARA)GetFeTcpFunction(FETCP_SET_SOCKET_PARA);
03777         if(m_iCommMode == FEDM_COMM_MODE_TCP)
03778         {
03779                 FEDM_CHK5(lpfnSetSocketPara);
03780         }
03781 #endif
03782 #endif
03783 
03784         if(m_iCommMode == FEDM_COMM_MODE_SERIAL)
03785         {
03786 #ifdef _FEDM_COM_SUPPORT
03787                 sprintf(cValue,"%d", iValue);
03788 #if !defined(_FEDM_SUPPORT_SLINK)
03789                 iBack = lpfnSetPortPara(iPortHnd, cPara, cValue);
03790                 FEDM_RETURN(iBack);
03791 #else
03792                 iBack = FECOM_SetPortPara(iPortHnd, cPara, cValue);
03793                 FEDM_RETURN(iBack);
03794 #endif
03795 #else
03796                 FEDM_TRACE(m_pLogger, FELOGMNG_DBG_ERROR, __FUNCTION__ << " " << GetErrorText(FEDM_ERROR_UNSUPPORTED));
03797                 FEDM_RETURN(FEDM_ERROR_UNSUPPORTED);
03798 #endif
03799         }
03800         else if(m_iCommMode == FEDM_COMM_MODE_TCP)
03801         {
03802 #ifdef _FEDM_TCP_SUPPORT
03803                 sprintf(cValue,"%d", iValue);
03804 #if !defined(_FEDM_SUPPORT_SLINK)
03805                 iBack = lpfnSetSocketPara(iPortHnd, cPara, cValue);
03806                 FEDM_RETURN(iBack);
03807 #else
03808                 iBack = FETCP_SetSocketPara(iPortHnd, cPara, cValue);
03809                 FEDM_RETURN(iBack);
03810 #endif
03811 #else
03812                 FEDM_TRACE(m_pLogger, FELOGMNG_DBG_ERROR, __FUNCTION__ << " " << GetErrorText(FEDM_ERROR_UNSUPPORTED));
03813                 FEDM_RETURN(FEDM_ERROR_UNSUPPORTED);
03814 #endif
03815         }
03816         else if(m_iCommMode == FEDM_COMM_MODE_USB)
03817         {
03818 #ifdef _FEDM_USB_SUPPORT
03819                 sprintf(cValue,"%d", iValue);
03820 #if !defined(_FEDM_SUPPORT_SLINK)
03821                 iBack = lpfnSetDevicePara(iPortHnd, cPara, cValue);
03822                 FEDM_RETURN(iBack);
03823 #else
03824                 iBack = FEUSB_SetDevicePara(iPortHnd, cPara, cValue);
03825                 FEDM_RETURN(iBack);
03826 #endif
03827 #else
03828                 FEDM_TRACE(m_pLogger, FELOGMNG_DBG_ERROR, __FUNCTION__ << " " << GetErrorText(FEDM_ERROR_UNSUPPORTED));
03829                 FEDM_RETURN(FEDM_ERROR_UNSUPPORTED);
03830 #endif
03831         }
03832 
03833         FEDM_TRACE(m_pLogger, FELOGMNG_DBG_ERROR, __FUNCTION__ << " " << GetErrorText(FEDM_ERROR_UNSUPPORTED));
03834         FEDM_RETURN(FEDM_ERROR_UNSUPPORTED);
03835 }
03836 
03837 /***************************************************************************
03838   Begin                 :       06.11.2003 / M. Hultsch
03839 
03840   Version               :       03.01.06 / 05.05.2010 / M. Hultsch
03841                                                 - ExclusiveAccess f�r FEUSB
03842 
03843                                                 02.03.05 / 14.11.2005 / M. Hultsch
03844                                                 - Modifikation f�r uClinux
03845 
03846                                                 01.09.05 / 18.02.2004 / M. Hultsch
03847 
03848   Function                      :       gets one port parameter from port library
03849 
03850   Parameters            :       char* cPara             -       pointer to parameter string (see port manual)
03851                                                 char* cValue    -       pointer to value string (see port manual)
03852 
03853   Return value          :       FEDM_OK or error code (<0)
03854 ***************************************************************************/
03855 int FEDM_ISCReaderModule::GetPortPara(char* cPara, char* cValue)
03856 {
03857         if(m_iCommMode == FEDM_COMM_MODE_UNDEF)
03858         {
03859                 FEDM_TRACE(m_pLogger, FELOGMNG_DBG_ERROR, __FUNCTION__ << " " << GetErrorText(FEDM_ERROR_NOT_CONNECTED));
03860                 FEDM_RETURN(FEDM_ERROR_NOT_CONNECTED);
03861         }
03862 
03863         int iBack = 0;
03864         int iPortHnd = GetPortHnd();
03865         if(iPortHnd < 0)
03866         {
03867                 FEDM_TRACE(m_pLogger, FELOGMNG_DBG_ERROR, __FUNCTION__ << " " << GetErrorText(FEDM_ERROR_NOT_CONNECTED));
03868                 FEDM_RETURN(FEDM_ERROR_NOT_CONNECTED);
03869         }
03870 
03871 
03872 #ifdef _FEDM_COM_SUPPORT
03873 #if !defined(_FEDM_SUPPORT_SLINK)
03874         LPFN_FECOM_GET_PORT_PARA lpfnGetPortPara = (LPFN_FECOM_GET_PORT_PARA)GetFeComFunction(FECOM_GET_PORT_PARA);
03875         FEDM_CHK5(lpfnGetPortPara);
03876 #endif
03877 #endif
03878 
03879 #ifdef _FEDM_USB_SUPPORT
03880 #if !defined(_FEDM_SUPPORT_SLINK)
03881         LPFN_FEUSB_GET_DEVICE_PARA lpfnGetDevicePara = (LPFN_FEUSB_GET_DEVICE_PARA)GetFeUsbFunction(FEUSB_GET_DEVICE_PARA);
03882         FEDM_CHK5(lpfnGetDevicePara);
03883 #endif
03884 #endif
03885 
03886 #ifdef _FEDM_TCP_SUPPORT
03887 #if !defined(_FEDM_SUPPORT_SLINK)
03888         LPFN_FETCP_GET_SOCKET_PARA lpfnGetSocketPara = (LPFN_FETCP_GET_SOCKET_PARA)GetFeTcpFunction(FETCP_GET_SOCKET_PARA);
03889         FEDM_CHK5(lpfnGetSocketPara);
03890 #endif
03891 #endif
03892 
03893         if(m_iCommMode == FEDM_COMM_MODE_SERIAL)
03894         {
03895 #ifdef _FEDM_COM_SUPPORT
03896 #if !defined(_FEDM_SUPPORT_SLINK)
03897                 iBack = lpfnGetPortPara(iPortHnd, cPara, cValue);
03898                 FEDM_RETURN(iBack);
03899 #else
03900                 iBack = FECOM_GetPortPara(iPortHnd, cPara, cValue);
03901                 FEDM_RETURN(iBack);
03902 #endif
03903 #else
03904                 FEDM_TRACE(m_pLogger, FELOGMNG_DBG_ERROR, __FUNCTION__ << " " << GetErrorText(FEDM_ERROR_UNSUPPORTED));
03905                 FEDM_RETURN(FEDM_ERROR_UNSUPPORTED);
03906 #endif
03907         }
03908         else if(m_iCommMode == FEDM_COMM_MODE_USB)
03909         {
03910 #ifdef _FEDM_USB_SUPPORT
03911                 if(strcmp(cPara, "ExclusiveAccess")==0)
03912                 {
03913                         iPortHnd = 0; // it's a global setting
03914                 }
03915 #if !defined(_FEDM_SUPPORT_SLINK)
03916                 iBack = lpfnGetDevicePara(iPortHnd, cPara, cValue);
03917                 FEDM_RETURN(iBack);
03918 #else
03919                 iBack = FEUSB_GetDevicePara(iPortHnd, cPara, cValue);
03920                 FEDM_RETURN(iBack);
03921 #endif
03922 #else
03923                 FEDM_TRACE(m_pLogger, FELOGMNG_DBG_ERROR, __FUNCTION__ << " " << GetErrorText(FEDM_ERROR_UNSUPPORTED));
03924                 FEDM_RETURN(FEDM_ERROR_UNSUPPORTED);
03925 #endif
03926         }
03927         else if(m_iCommMode == FEDM_COMM_MODE_TCP)
03928         {
03929 #ifdef _FEDM_TCP_SUPPORT
03930 #if !defined(_FEDM_SUPPORT_SLINK)
03931                 iBack = lpfnGetSocketPara(iPortHnd, cPara, cValue);
03932                 FEDM_RETURN(iBack);
03933 #else
03934                 iBack = FETCP_GetSocketPara(iPortHnd, cPara, cValue);
03935                 FEDM_RETURN(iBack);
03936 #endif
03937 #else
03938                 FEDM_TRACE(m_pLogger, FELOGMNG_DBG_ERROR, __FUNCTION__ << " " << GetErrorText(FEDM_ERROR_UNSUPPORTED));
03939                 FEDM_RETURN(FEDM_ERROR_UNSUPPORTED);
03940 #endif
03941         }
03942 
03943         FEDM_TRACE(m_pLogger, FELOGMNG_DBG_ERROR, __FUNCTION__ << " " << GetErrorText(FEDM_ERROR_UNSUPPORTED));
03944         FEDM_RETURN(FEDM_ERROR_UNSUPPORTED);
03945 }
03946 
03947 /***************************************************************************
03948   Begin                 :       06.11.2003 / M. Hultsch
03949 
03950   Version               :       03.01.06 / 05.05.2010 / M. Hultsch
03951                                                 - ExclusiveAccess f�r FEUSB
03952 
03953                                                 02.03.05 / 14.11.2005 / M. Hultsch
03954                                                 - Modifikation f�r uClinux
03955 
03956                                                 02.03.00 / 04.05.2004 / M. Hultsch
03957                                                 - Erweiterung f�r USB, TCP
03958 
03959                                                 01.09.00 / 06.11.2003 / M. Hultsch
03960 
03961   Function                      :       gets one port parameter from port library
03962 
03963   Parameters            :       char* cPara             -       pointer to parameter string (see port manual)
03964                                                 int*  iValue    -       pointer to value (see port manual)
03965 
03966   Return value          :       FEDM_OK or error code (<0)
03967 ***************************************************************************/
03968 int FEDM_ISCReaderModule::GetPortPara(char* cPara, int* iValue)
03969 {
03970         if(m_iCommMode == FEDM_COMM_MODE_UNDEF)
03971         {
03972                 FEDM_TRACE(m_pLogger, FELOGMNG_DBG_ERROR, __FUNCTION__ << " " << GetErrorText(FEDM_ERROR_NOT_CONNECTED));
03973                 FEDM_RETURN(FEDM_ERROR_NOT_CONNECTED);
03974         }
03975 
03976         int iPortHnd = GetPortHnd();
03977         if(iPortHnd < 0)
03978         {
03979                 FEDM_TRACE(m_pLogger, FELOGMNG_DBG_ERROR, __FUNCTION__ << " " << GetErrorText(FEDM_ERROR_NOT_CONNECTED));
03980                 FEDM_RETURN(FEDM_ERROR_NOT_CONNECTED);
03981         }
03982 
03983 
03984         char cValue[16];
03985         int iErr;
03986 
03987 #ifdef _FEDM_COM_SUPPORT
03988 #if !defined(_FEDM_SUPPORT_SLINK)
03989         LPFN_FECOM_GET_PORT_PARA lpfnGetPortPara = (LPFN_FECOM_GET_PORT_PARA)GetFeComFunction(FECOM_GET_PORT_PARA);
03990         FEDM_CHK5(lpfnGetPortPara);
03991 #endif
03992 #endif
03993 
03994 #ifdef _FEDM_USB_SUPPORT
03995 #if !defined(_FEDM_SUPPORT_SLINK)
03996         LPFN_FEUSB_GET_DEVICE_PARA lpfnGetDevicePara = (LPFN_FEUSB_GET_DEVICE_PARA)GetFeUsbFunction(FEUSB_GET_DEVICE_PARA);
03997         FEDM_CHK5(lpfnGetDevicePara);
03998 #endif
03999 #endif
04000 
04001 #ifdef _FEDM_TCP_SUPPORT
04002 #if !defined(_FEDM_SUPPORT_SLINK)
04003         LPFN_FETCP_GET_SOCKET_PARA lpfnGetSocketPara = (LPFN_FETCP_GET_SOCKET_PARA)GetFeTcpFunction(FETCP_GET_SOCKET_PARA);
04004         FEDM_CHK5(lpfnGetSocketPara);
04005 #endif
04006 #endif
04007 
04008         if(m_iCommMode == FEDM_COMM_MODE_SERIAL)
04009         {
04010 #ifdef _FEDM_COM_SUPPORT
04011 #if !defined(_FEDM_SUPPORT_SLINK)
04012                 FEDM_CHK2(iErr, lpfnGetPortPara(iPortHnd, cPara, cValue));
04013 #else
04014                 FEDM_CHK2(iErr, FECOM_GetPortPara(iPortHnd, cPara, cValue));
04015 #endif
04016                 sscanf(cValue,"%d", iValue);
04017 #else
04018                 FEDM_TRACE(m_pLogger, FELOGMNG_DBG_ERROR, __FUNCTION__ << " " << GetErrorText(FEDM_ERROR_UNSUPPORTED));
04019                 FEDM_RETURN(FEDM_ERROR_UNSUPPORTED);
04020 #endif
04021         }
04022         else if(m_iCommMode == FEDM_COMM_MODE_TCP)
04023         {
04024 #ifdef _FEDM_TCP_SUPPORT
04025 #if !defined(_FEDM_SUPPORT_SLINK)
04026                 FEDM_CHK2(iErr, lpfnGetSocketPara(iPortHnd, cPara, cValue));
04027 #else
04028                 FEDM_CHK2(iErr, FETCP_GetSocketPara(iPortHnd, cPara, cValue));
04029 #endif
04030                 sscanf(cValue,"%d", iValue);
04031 #else
04032                 FEDM_TRACE(m_pLogger, FELOGMNG_DBG_ERROR, __FUNCTION__ << " " << GetErrorText(FEDM_ERROR_UNSUPPORTED));
04033                 FEDM_RETURN(FEDM_ERROR_UNSUPPORTED);
04034 #endif
04035         }
04036         else if(m_iCommMode == FEDM_COMM_MODE_USB)
04037         {
04038 #ifdef _FEDM_USB_SUPPORT
04039                 if(strcmp(cPara, "ExclusiveAccess")==0)
04040                 {
04041                         iPortHnd = 0; // it's a global setting
04042                 }
04043 #if !defined(_FEDM_SUPPORT_SLINK)
04044                 FEDM_CHK2(iErr, lpfnGetDevicePara(iPortHnd, cPara, cValue));
04045 #else
04046                 FEDM_CHK2(iErr, FEUSB_GetDevicePara(iPortHnd, cPara, cValue));
04047 #endif
04048                 sscanf(cValue,"%d", iValue);
04049 #else
04050                 FEDM_TRACE(m_pLogger, FELOGMNG_DBG_ERROR, __FUNCTION__ << " " << GetErrorText(FEDM_ERROR_UNSUPPORTED));
04051                 FEDM_RETURN(FEDM_ERROR_UNSUPPORTED);
04052 #endif
04053         }
04054         else
04055         {
04056                 FEDM_TRACE(m_pLogger, FELOGMNG_DBG_ERROR, __FUNCTION__ << " " << GetErrorText(FEDM_ERROR_UNSUPPORTED_PORT_DRIVER));
04057                 FEDM_RETURN(FEDM_ERROR_UNSUPPORTED_PORT_DRIVER);
04058         }
04059 
04060         FEDM_RETURN(FEDM_OK);
04061 }
04062 
04063 
04064 
04066 // complex communication functions
04068 
04069 /***************************************************************************
04070   Begin                 :       11.11.2003 / M. Hultsch
04071 
04072   Version               :       04.05.04 / 03.09.2013 / M. Hultsch
04073                                                 - new reader: ID ISC.LRU1002
04074 
04075                                                 03.03.00 / 01.02.2011 / M. Hultsch
04076                                                 - ID LR2500-A and -B added
04077   
04078                                                 03.01.00 / 12.02.2010 / M. Hultsch
04079                                                 - support for crypto mode
04080   
04081                                                 03.00.13 / 28.09.2009 / M. Hultsch
04082                                                 - ID MAX50.xx added
04083   
04084                                                 03.00.08 / 09.06.2009 / M. Hultsch
04085                                                 - ID CPR44.xx added
04086   
04087                                                 03.00.07 / 29.04.2009 / M. Hultsch
04088                                                 - ID ISC.M02.M8 added
04089   
04090                                                 03.00.06 / 16.04.2009 / M. Hultsch
04091                                                 - ID ISC.UM02 added
04092   
04093                                                 03.00.05 / 12.03.2009 / M. Hultsch
04094 
04095   Function                      :       reads complete reader configuration
04096 
04097   Parameters            :       bool bEEPROM    - true, if location is EEPROM
04098 
04099   Return value          :       FEDM_OK or error code (<0) or status byte (>0)
04100 ***************************************************************************/
04101 int FEDM_ISCReaderModule::ReadCompleteConfiguration(bool bEEPROM)
04102 {
04103         if(bEEPROM)
04104         {
04105                 FEDM_TRACE_FNC(m_pLogger, FELOGMNG_DBG_FUNCTION_CALL | FELOGMNG_DBG_LF_COMM_HIGH_LEVEL, __FUNCTION__, FELOGMNG_DBG_FUNCTION_PARAMETER, "EEPROM");
04106         }
04107         else
04108         {
04109                 FEDM_TRACE_FNC(m_pLogger, FELOGMNG_DBG_FUNCTION_CALL | FELOGMNG_DBG_LF_COMM_HIGH_LEVEL, __FUNCTION__, FELOGMNG_DBG_FUNCTION_PARAMETER, "RAM");
04110         }
04111 
04112         int iErr = 0;
04113         int iBitNr = 0;
04114         int iBitPos = 0;
04115         int iIdx = 0;
04116         unsigned char ucPage     = 0;
04117         unsigned int uiMaxPages = 0;
04118         unsigned __int64 ui64CfgReadPermissions = 0; // read permissions, based on system manuals
04119         unsigned __int64 ui64BitNr = 0;
04120 
04121         if(! IsConnected())
04122         {
04123                 FEDM_TRACE(m_pLogger, FELOGMNG_DBG_ERROR, __FUNCTION__ << " " << GetErrorText(FEDM_ERROR_NOT_CONNECTED));
04124                 FEDM_RETURN(FEDM_ERROR_NOT_CONNECTED);
04125         }
04126 
04127         switch(m_uiReaderType)
04128         {
04129         case FEDM_ISC_TYPE_ISCM02:
04130         case FEDM_ISC_TYPE_ISCM02_M8:
04131         case FEDM_ISC_TYPE_ISCPRH100:
04132         case FEDM_ISC_TYPE_ISCPRH100_U:
04133         case FEDM_ISC_TYPE_ISCMR100:    // also FEDM_ISC_TYPE_ISCPR100
04134         case FEDM_ISC_TYPE_ISCMR100_U:
04135         case FEDM_ISC_TYPE_CPRM02:
04136         case FEDM_ISC_TYPE_CPR02:
04137         case FEDM_ISC_TYPE_CPR04_U:
04138         case FEDM_ISC_TYPE_CPR40_XX_U:
04139         case FEDM_ISC_TYPE_CPR40_XX:
04140         case FEDM_ISC_TYPE_CPR44_XX:
04141                 if(m_ReaderInfo.bIsMode0x40Read)
04142                 {
04143                         uiMaxPages = m_ReaderInfo.GetNoOfCfgPages();
04144                 }
04145                 else
04146                 {
04147                         uiMaxPages = 8;
04148 #ifdef __GNUC__
04149                         ui64CfgReadPermissions = 0xFF00000000000000LL; // 0-7
04150 #else
04151                         ui64CfgReadPermissions = 0xFF00000000000000; // 0-7
04152 #endif
04153                 }
04154                 break;
04155 
04156         case FEDM_ISC_TYPE_CPR50_XX:
04157                 if(m_ReaderInfo.bIsMode0x40Read)
04158                 {
04159                         uiMaxPages = m_ReaderInfo.GetNoOfCfgPages();
04160                 }
04161                 else
04162                 {
04163                         uiMaxPages = 64;
04164 #ifdef __GNUC__
04165                         ui64CfgReadPermissions = 0xFFC0800000C00001LL; // 0-9,16,40-41,63
04166 #else
04167                         ui64CfgReadPermissions = 0xFFC0800000C00001; // 0-9,16,40-41,63
04168 #endif
04169                 }
04170                 break;
04171 
04172         case FEDM_ISC_TYPE_ISCPRH101:
04173                 if(m_ReaderInfo.bIsMode0x40Read)
04174                 {
04175                         uiMaxPages = m_ReaderInfo.GetNoOfCfgPages();
04176                 }
04177                 else
04178                 {
04179                         uiMaxPages = 64;
04180 #ifdef __GNUC__
04181                         ui64CfgReadPermissions = 0xFFC0800000008001LL; // 0-9,16,48,63
04182 #else
04183                         ui64CfgReadPermissions = 0xFFC0800000008001; // 0-9,16,48,63
04184 #endif
04185                 }
04186                 break;
04187 
04188         case FEDM_ISC_TYPE_ISCPRH101_U:
04189                 if(m_ReaderInfo.bIsMode0x40Read)
04190                 {
04191                         uiMaxPages = m_ReaderInfo.GetNoOfCfgPages();
04192                 }
04193                 else
04194                 {
04195                         uiMaxPages = 64;
04196 #ifdef __GNUC__
04197                         ui64CfgReadPermissions = 0xFFC0800000000001LL; // 0-9,16,63
04198 #else
04199                         ui64CfgReadPermissions = 0xFFC0800000000001; // 0-9,16,63
04200 #endif
04201                 }
04202                 break;
04203 
04204         case FEDM_ISC_TYPE_ISCMR101:    // also FEDM_ISC_TYPE_ISCPR101
04205         case FEDM_ISC_TYPE_ISCMR101_U:
04206                 if(m_ReaderInfo.bIsMode0x40Read)
04207                 {
04208                         uiMaxPages = m_ReaderInfo.GetNoOfCfgPages();
04209                 }
04210                 else
04211                 {
04212                         uiMaxPages = 64;
04213 #ifdef __GNUC__
04214                         ui64CfgReadPermissions = 0xFFE0800000000001LL; // 0-10,16,63
04215 #else
04216                         ui64CfgReadPermissions = 0xFFE0800000000001; // 0-10,16,63
04217 #endif
04218                 }
04219                 break;
04220 
04221         case FEDM_ISC_TYPE_ISCLR200:
04222                 if(m_ReaderInfo.bIsMode0x40Read)
04223                 {
04224                         uiMaxPages = m_ReaderInfo.GetNoOfCfgPages();
04225                 }
04226                 else
04227                 {
04228                         uiMaxPages = 16;
04229 #ifdef __GNUC__
04230                         ui64CfgReadPermissions = 0xFFFF000000000000LL; // 0-15
04231 #else
04232                         ui64CfgReadPermissions = 0xFFFF000000000000; // 0-15
04233 #endif
04234                 }
04235                 break;
04236 
04237         case FEDM_ISC_TYPE_ISCMU02:
04238         case FEDM_ISC_TYPE_ISCPRH102:
04239         case FEDM_ISC_TYPE_ISCPRHD102:
04240         case FEDM_ISC_TYPE_ISCMR200:
04241         case FEDM_ISC_TYPE_ISCMRU200:
04242         case FEDM_ISC_TYPE_ISCLRU1000:
04243         case FEDM_ISC_TYPE_ISCLRU2000:
04244         case FEDM_ISC_TYPE_ISCLR2000:
04245         case FEDM_ISC_TYPE_MAX50_XX:
04246                 if(m_ReaderInfo.bIsMode0x40Read)
04247                 {
04248                         uiMaxPages = m_ReaderInfo.GetNoOfCfgPages();
04249                 }
04250                 else
04251                 {
04252                         uiMaxPages = 64;
04253 #ifdef __GNUC__
04254                         ui64CfgReadPermissions = 0xFFFFFFFFFFFFFFFFLL; // 0-63
04255 #else
04256                         ui64CfgReadPermissions = 0xFFFFFFFFFFFFFFFF; // 0-63
04257 #endif
04258                 }
04259                 break;
04260 
04261 #ifndef FEDM_NEW_LRU3000_ACC_CFG
04262         case FEDM_ISC_TYPE_ISCLRU3000:
04263                 if(bEEPROM)
04264                         SetData(FEDM_ISC_TMP_0x8A_READ_MODE,            (unsigned char)0x41);   // mode: read all from EEPROM
04265                 else
04266                         SetData(FEDM_ISC_TMP_0x8A_READ_MODE,            (unsigned char)0x40);   // mode: read all from RAM
04267 
04268                 SetData(FEDM_ISC_TMP_0x8A_READ_DEVICE,          (unsigned char)FEDM_CNTRL_TYPE_ACC);            // device: ACC
04269                 SetData(FEDM_ISC_TMP_0x8A_READ_BANK,            (unsigned char)FEDM_MEM_BANK_TYPE_MAIN);        // bank: main
04270                 SetData(FEDM_ISC_TMP_0x8A_READ_REQ_CFG_ADR,     (unsigned int)0);       // first block address not necessary
04271                 SetData(FEDM_ISC_TMP_0x8A_READ_REQ_CFG_N,       (unsigned char)0);      // number of blocks not necessary
04272                 FEDM_CHK2(iErr, SendProtocol(0x8A));
04273                 if( iErr == 0x13 || // Login-Request
04274                         iErr == 0x19 ) // crypto processing error
04275                 {
04276                         FEDM_RETURN(iErr);
04277                 }
04278                 FEDM_RETURN(FEDM_OK);
04279 #endif
04280 
04281         case FEDM_ISC_TYPE_ISCLR2500_A:
04282 #ifdef FEDM_NEW_LRU3000_ACC_CFG
04283         case FEDM_ISC_TYPE_ISCLRU3000:
04284 #endif
04285                 if(bEEPROM)
04286                         SetData(FEDM_ISC_TMP_0x8A_READ_MODE,            (unsigned char)0x41);   // mode: read all from EEPROM
04287                 else
04288                         SetData(FEDM_ISC_TMP_0x8A_READ_MODE,            (unsigned char)0x40);   // mode: read all from RAM
04289 
04290                 SetData(FEDM_ISC_TMP_0x8A_READ_DEVICE,          (unsigned char)FEDM_CNTRL_TYPE_RFC);            // device: RFC
04291                 SetData(FEDM_ISC_TMP_0x8A_READ_BANK,            (unsigned char)FEDM_MEM_BANK_TYPE_MAIN);        // bank: main
04292                 SetData(FEDM_ISC_TMP_0x8A_READ_REQ_CFG_ADR,     (unsigned int)0);       // first block address not necessary
04293                 SetData(FEDM_ISC_TMP_0x8A_READ_REQ_CFG_N,       (unsigned char)0);      // number of blocks not necessary
04294                 FEDM_CHK2(iErr, SendProtocol(0x8A));
04295                 if( iErr == 0x13 || // Login-Request
04296                         iErr == 0x19 ) // crypto processing error
04297                 {
04298                         FEDM_RETURN(iErr);
04299                 }
04300                 FEDM_RETURN(FEDM_OK);
04301 
04302         default:
04303                 if(m_ReaderInfo.bIsMode0x40Read)
04304                 {
04305                         uiMaxPages = m_ReaderInfo.GetNoOfCfgPages();
04306                 }
04307                 else
04308                 {
04309                         FEDM_RETURN(FEDM_ERROR_UNKNOWN_READER_TYPE);
04310                 }
04311         }
04312 
04313 
04314         // read configuration from RAM or EEPROM
04315         FEDM_CHK2(iErr, SetData( FEDM_ISC_TMP_READ_CFG, (unsigned char)0));
04316         FEDM_CHK2(iErr, SetData( FEDM_ISC_TMP_READ_CFG_LOC, bEEPROM));
04317 
04318         FEDM_CHK2(iErr, SetData(FEDM_ISC_TMP_0x8A_READ_MODE, (unsigned char)0));
04319         FEDM_CHK2(iErr, SetData(FEDM_ISC_TMP_0x8A_READ_MODE_LOC, bEEPROM));     // memory location
04320 
04321         if(m_ReaderInfo.bIsMode0x40Read)
04322         {
04323                 // read with knowledge about read permissions
04324                 ucPage = 0;
04325                 for(iIdx=0; iIdx<16; iIdx++) // max 16 permission bytes
04326                 {
04327                         iBitNr = 0x80;
04328                         for(iBitPos=0; iBitPos<8; iBitPos++)
04329                         {
04330                                 if(m_ReaderInfo.ucCfgReadPermissions[iIdx] & iBitNr)
04331                                 {
04332                                         switch(m_uiReaderType)
04333                                         {
04334                                         case FEDM_ISC_TYPE_ISCLR2500_A:
04335                                         case FEDM_ISC_TYPE_ISCLR2500_B:
04336 #ifdef FEDM_NEW_LRU3000_ACC_CFG
04337                                         case FEDM_ISC_TYPE_ISCLRU3000:
04338 #endif
04339                                                 SetData(FEDM_ISC_TMP_0x8A_READ_DEVICE,          (unsigned char)FEDM_CNTRL_TYPE_RFC);            // device: RFC
04340                                                 SetData(FEDM_ISC_TMP_0x8A_READ_BANK,            (unsigned char)FEDM_MEM_BANK_TYPE_MAIN);        // bank: main
04341                                                 SetData(FEDM_ISC_TMP_0x8A_READ_REQ_CFG_ADR,     (unsigned int)ucPage);  // first block address
04342                                                 SetData(FEDM_ISC_TMP_0x8A_READ_REQ_CFG_N,       (unsigned char)1);              // number of blocks
04343                                                 FEDM_CHK2(iErr, SendProtocol(0x8A));
04344                                                 if( iErr == 0x13 || // Login-Request
04345                                                         iErr == 0x19 ) // crypto processing error
04346                                                 {
04347                                                         FEDM_RETURN(iErr);
04348                                                 }
04349                                                 break;
04350 
04351                                         default:
04352                                                 FEDM_CHK2(iErr, SetData( FEDM_ISC_TMP_READ_CFG_ADR, ucPage));
04353                                                 FEDM_CHK2(iErr, SendProtocol(0x80));
04354                                                 if(     iErr == 0x13 || // Login-Request
04355                                                         iErr == 0x19 ) // crypto processing error
04356                                                 {
04357                                                         FEDM_RETURN(iErr);
04358                                                 }
04359                                         }
04360                                 }
04361                                 
04362                                 iBitNr >>= 1;
04363                                 ucPage++;
04364                         }
04365                 }
04366         }
04367         else
04368         {
04369                 // read with explicite knowledge about read permissions from system manuals
04370                 ucPage = 0;
04371 #ifdef __GNUC__
04372                 ui64BitNr = 0x8000000000000000LL;
04373 #else
04374                 ui64BitNr = 0x8000000000000000;
04375 #endif
04376                 for(iBitPos=0; iBitPos<64; iBitPos++)
04377                 {
04378                         if(ui64CfgReadPermissions & ui64BitNr)
04379                         {
04380                                 FEDM_CHK2(iErr, SetData( FEDM_ISC_TMP_READ_CFG_ADR, ucPage));
04381                                 FEDM_CHK2(iErr, SendProtocol(0x80));
04382                                 if(     iErr == 0x13 || // Login-Request
04383                                         iErr == 0x19 ) // crypto processing error
04384                                 {
04385                                         FEDM_RETURN(iErr);
04386                                 }
04387                         }
04388                         
04389                         ui64BitNr >>= 1;
04390                         ucPage++;
04391                 }
04392         }
04393 
04394         FEDM_RETURN(FEDM_OK);
04395 }
04396 
04397 /***************************************************************************
04398   Begin                 :       11.11.2003 / M. Hultsch
04399 
04400   Version               :       04.05.04 / 03.09.2013 / M. Hultsch
04401                                                 - new reader: ID ISC.LRU1002
04402 
04403                                                 03.03.00 / 01.02.2011 / M. Hultsch
04404                                                 - ID LR2500-A and -B added
04405   
04406                                                 03.01.00 / 12.02.2010 / M. Hultsch
04407                                                 - support for crypto mode
04408   
04409                                                 03.00.13 / 28.09.2009 / M. Hultsch
04410                                                 - ID MAX50.xx added
04411   
04412                                                 03.00.08 / 09.06.2009 / M. Hultsch
04413                                                 - ID CPR44.xx added
04414   
04415                                                 03.00.07 / 29.04.2009 / M. Hultsch
04416                                                 - ID ISC.M02.M8 added
04417   
04418                                                 03.00.06 / 16.04.2009 / M. Hultsch
04419                                                 - ID ISC.UM02 added
04420   
04421                                                 03.00.05 / 12.03.2009 / M. Hultsch
04422 
04423   Function                      :       writes complete reader configuration
04424 
04425   Parameters            :       bool bEEPROM    - true, if location is EEPROM
04426 
04427   Return value          :       FEDM_OK or error code (<0) or status byte (>0)
04428 ***************************************************************************/
04429 int FEDM_ISCReaderModule::WriteCompleteConfiguration(bool bEEPROM)
04430 {
04431         if(bEEPROM)
04432         {
04433                 FEDM_TRACE_FNC(m_pLogger, FELOGMNG_DBG_FUNCTION_CALL | FELOGMNG_DBG_LF_COMM_HIGH_LEVEL, __FUNCTION__, FELOGMNG_DBG_FUNCTION_PARAMETER, "EEPROM");
04434         }
04435         else
04436         {
04437                 FEDM_TRACE_FNC(m_pLogger, FELOGMNG_DBG_FUNCTION_CALL | FELOGMNG_DBG_LF_COMM_HIGH_LEVEL, __FUNCTION__, FELOGMNG_DBG_FUNCTION_PARAMETER, "RAM");
04438         }
04439 
04440         int iErr = 0;
04441         int iBitNr = 0;
04442         int iBitPos = 0;
04443         int iIdx = 0;
04444         int iTmpMemAdr = 0;
04445         unsigned char ucPage     = 0;
04446         unsigned int uiMaxPages = 0;
04447         unsigned __int64 ui64CfgWritePermissions = 0; // read permissions, based on system manuals
04448         unsigned __int64 ui64BitNr = 0;
04449 
04450         if(! IsConnected())
04451         {
04452                 FEDM_TRACE(m_pLogger, FELOGMNG_DBG_ERROR, __FUNCTION__ << " " << GetErrorText(FEDM_ERROR_NOT_CONNECTED));
04453                 FEDM_RETURN(FEDM_ERROR_NOT_CONNECTED);
04454         }
04455 
04456 
04457         switch(m_uiReaderType)
04458         {
04459         case FEDM_ISC_TYPE_ISCM02:
04460         case FEDM_ISC_TYPE_ISCM02_M8:
04461         case FEDM_ISC_TYPE_ISCPRH100:
04462         case FEDM_ISC_TYPE_ISCPRH100_U:
04463         case FEDM_ISC_TYPE_ISCMR100:    // also FEDM_ISC_TYPE_ISCPR100
04464         case FEDM_ISC_TYPE_ISCMR100_U:
04465         case FEDM_ISC_TYPE_CPRM02:
04466         case FEDM_ISC_TYPE_CPR02:
04467         case FEDM_ISC_TYPE_CPR04_U:
04468         case FEDM_ISC_TYPE_CPR40_XX_U:
04469         case FEDM_ISC_TYPE_CPR40_XX:
04470         case FEDM_ISC_TYPE_CPR44_XX:
04471                 if(m_ReaderInfo.bIsMode0x41Read)
04472                 {
04473                         uiMaxPages = m_ReaderInfo.GetNoOfCfgPages();
04474                 }
04475                 else
04476                 {
04477                         uiMaxPages = 8;
04478 #ifdef __GNUC__
04479                         ui64CfgWritePermissions = 0xFF00000000000000LL; // 0-7
04480 #else
04481                         ui64CfgWritePermissions = 0xFF00000000000000; // 0-7
04482 #endif
04483                 }
04484                 break;
04485 
04486         case FEDM_ISC_TYPE_CPR50_XX:
04487                 if(m_ReaderInfo.bIsMode0x41Read)
04488                 {
04489                         uiMaxPages = m_ReaderInfo.GetNoOfCfgPages();
04490                 }
04491                 else
04492                 {
04493                         uiMaxPages = 64;
04494 #ifdef __GNUC__
04495                         ui64CfgWritePermissions = 0xFFC0800000C00001LL; // 0-9,16,40-41,63
04496 #else
04497                         ui64CfgWritePermissions = 0xFFC0800000C00001; // 0-9,16,40-41,63
04498 #endif
04499                 }
04500                 break;
04501 
04502         case FEDM_ISC_TYPE_ISCPRH101:
04503                 if(m_ReaderInfo.bIsMode0x41Read)
04504                 {
04505                         uiMaxPages = m_ReaderInfo.GetNoOfCfgPages();
04506                 }
04507                 else
04508                 {
04509                         uiMaxPages = 64;
04510 #ifdef __GNUC__
04511                         ui64CfgWritePermissions = 0xFFC0800000008001LL; // 0-9,16,48,63
04512 #else
04513                         ui64CfgWritePermissions = 0xFFC0800000008001; // 0-9,16,48,63
04514 #endif
04515                 }
04516                 break;
04517 
04518         case FEDM_ISC_TYPE_ISCPRH101_U:
04519                 if(m_ReaderInfo.bIsMode0x41Read)
04520                 {
04521                         uiMaxPages = m_ReaderInfo.GetNoOfCfgPages();
04522                 }
04523                 else
04524                 {
04525                         uiMaxPages = 64;
04526 #ifdef __GNUC__
04527                         ui64CfgWritePermissions = 0xFFC0800000000001LL; // 0-9,16,63
04528 #else
04529                         ui64CfgWritePermissions = 0xFFC0800000000001; // 0-9,16,63
04530 #endif
04531                 }
04532                 break;
04533 
04534         case FEDM_ISC_TYPE_ISCMR101:    // also FEDM_ISC_TYPE_ISCPR101
04535         case FEDM_ISC_TYPE_ISCMR101_U:
04536                 if(m_ReaderInfo.bIsMode0x41Read)
04537                 {
04538                         uiMaxPages = m_ReaderInfo.GetNoOfCfgPages();
04539                 }
04540                 else
04541                 {
04542                         uiMaxPages = 64;
04543 #ifdef __GNUC__
04544                         ui64CfgWritePermissions = 0xFFE0800000000001LL; // 0-10,16,63
04545 #else
04546                         ui64CfgWritePermissions = 0xFFE0800000000001; // 0-10,16,63
04547 #endif
04548                 }
04549                 break;
04550 
04551         case FEDM_ISC_TYPE_ISCLR200:
04552                 if(m_ReaderInfo.bIsMode0x41Read)
04553                 {
04554                         uiMaxPages = m_ReaderInfo.GetNoOfCfgPages();
04555                 }
04556                 else
04557                 {
04558                         uiMaxPages = 16;
04559 #ifdef __GNUC__
04560                         ui64CfgWritePermissions = 0xFFFF000000000000LL; // 0-15
04561 #else
04562                         ui64CfgWritePermissions = 0xFFFF000000000000; // 0-15
04563 #endif
04564                 }
04565                 break;
04566 
04567         case FEDM_ISC_TYPE_ISCMU02:
04568         case FEDM_ISC_TYPE_ISCPRHD102:
04569         case FEDM_ISC_TYPE_ISCPRH102:
04570         case FEDM_ISC_TYPE_ISCMR200:
04571         case FEDM_ISC_TYPE_ISCMRU200:
04572         case FEDM_ISC_TYPE_ISCLRU1000:
04573         case FEDM_ISC_TYPE_ISCLRU2000:
04574         case FEDM_ISC_TYPE_ISCLR2000:
04575         case FEDM_ISC_TYPE_MAX50_XX:
04576                 if(m_ReaderInfo.bIsMode0x41Read)
04577                 {
04578                         uiMaxPages = m_ReaderInfo.GetNoOfCfgPages();
04579                 }
04580                 else
04581                 {
04582                         uiMaxPages = 64;
04583 #ifdef __GNUC__
04584                         ui64CfgWritePermissions = 0xFFFFFFFFFFFFFFFFLL; // 0-63
04585 #else
04586                         ui64CfgWritePermissions = 0xFFFFFFFFFFFFFFFF; // 0-63
04587 #endif
04588                 }
04589                 break;
04590 
04591 #ifndef FEDM_NEW_LRU3000_ACC_CFG
04592         case FEDM_ISC_TYPE_ISCLRU3000:
04593                 if(bEEPROM)
04594                         SetData(FEDM_ISC_TMP_0x8B_WRITE_MODE,           (unsigned char)0x01);   // mode: write to EEPROM
04595                 else
04596                         SetData(FEDM_ISC_TMP_0x8B_WRITE_MODE,           (unsigned char)0x00);   // mode: write to RAM
04597 
04598                 SetData(FEDM_ISC_TMP_0x8B_WRITE_DEVICE,         (unsigned char)FEDM_CNTRL_TYPE_ACC);            // device: ACC
04599                 SetData(FEDM_ISC_TMP_0x8B_WRITE_BANK,           (unsigned char)FEDM_MEM_BANK_TYPE_MAIN);        // bank: main
04600                 SetData(FEDM_ISC_TMP_0x8B_WRITE_CFG_SIZE,       (unsigned char)30);     // blocksize
04601                 iTmpMemAdr = FEDM_GetAdrOfID(FEDM_ISC_TMP_0x8B_WRITE_CFG_ADR, 32);      // start address in memory
04602 
04603                 uiMaxPages = 0;
04604 
04605                 if(m_ReaderInfo.bIsMode0x41Read)
04606                 {
04607                         // write with knowledge about write permissions
04608                         ucPage = 0;
04609                         for(iIdx=0; iIdx<16; iIdx++) // max 16 permission bytes
04610                         {
04611                                 iBitNr = 0x80;
04612                                 for(iBitPos=0; iBitPos<8; iBitPos++)
04613                                 {
04614                                         if(m_ReaderInfo.ucCfgWritePermissions[iIdx] & iBitNr)
04615                                         {
04616                                                 m_TmpData[iTmpMemAdr]   = 0x00;
04617                                                 m_TmpData[iTmpMemAdr+1] = ucPage;
04618                                                 iTmpMemAdr += 2;
04619 
04620                                                 uiMaxPages++;
04621                                         }
04622                                         
04623                                         iBitNr >>= 1;
04624                                         ucPage++;
04625                                 }
04626                         }
04627                 }
04628                 else
04629                 {
04630                         // write without knowledge
04631                         for(ucPage=0; ucPage<=85; ucPage++)
04632                         {
04633                                 m_TmpData[iTmpMemAdr]   = 0x00;
04634                                 m_TmpData[iTmpMemAdr+1] = ucPage;
04635                                 iTmpMemAdr += 2;
04636 
04637                                 uiMaxPages++;
04638                         }
04639                 }
04640 
04641                 SetData(FEDM_ISC_TMP_0x8B_WRITE_CFG_N,          (unsigned char)ucMaxPages);     // read one or multiple blocks
04642                 FEDM_CHK2(iErr, SendProtocol(0x8B));
04643                 if(     iErr == 0x13 || // Login-Request
04644                         iErr == 0x19 ) // crypto processing error
04645                 {
04646                         FEDM_RETURN(iErr);
04647                 }
04648                 FEDM_RETURN(FEDM_OK);
04649                 break;
04650 #endif
04651 
04652         case FEDM_ISC_TYPE_ISCLR2500_A:
04653 #ifdef FEDM_NEW_LRU3000_ACC_CFG
04654         case FEDM_ISC_TYPE_ISCLRU3000:
04655 #endif
04656                 if(bEEPROM)
04657                         SetData(FEDM_ISC_TMP_0x8B_WRITE_MODE,           (unsigned char)0x01);   // mode: write to EEPROM
04658                 else
04659                         SetData(FEDM_ISC_TMP_0x8B_WRITE_MODE,           (unsigned char)0x00);   // mode: write to RAM
04660 
04661                 SetData(FEDM_ISC_TMP_0x8B_WRITE_DEVICE,         (unsigned char)FEDM_CNTRL_TYPE_RFC);            // device: RFC
04662                 SetData(FEDM_ISC_TMP_0x8B_WRITE_BANK,           (unsigned char)FEDM_MEM_BANK_TYPE_MAIN);        // bank: main
04663                 SetData(FEDM_ISC_TMP_0x8B_WRITE_CFG_SIZE,       (unsigned char)30);     // blocksize
04664                 iTmpMemAdr = FEDM_GetAdrOfID(FEDM_ISC_TMP_0x8B_WRITE_CFG_ADR, 32);      // start address in memory
04665 
04666                 uiMaxPages = 0;
04667 
04668                 if(m_ReaderInfo.bIsMode0x41Read)
04669                 {
04670                         // write with knowledge about write permissions
04671                         ucPage = 0;
04672                         for(iIdx=0; iIdx<16; iIdx++) // max 16 permission bytes
04673                         {
04674                                 iBitNr = 0x80;
04675                                 for(iBitPos=0; iBitPos<8; iBitPos++)
04676                                 {
04677                                         if(m_ReaderInfo.ucCfgWritePermissions[iIdx] & iBitNr)
04678                                         {
04679                                                 m_TmpData[iTmpMemAdr]   = 0x00;
04680                                                 m_TmpData[iTmpMemAdr+1] = ucPage;
04681                                                 iTmpMemAdr += 2;
04682 
04683                                                 uiMaxPages++;
04684                                         }
04685                                         
04686                                         iBitNr >>= 1;
04687                                         ucPage++;
04688                                 }
04689                         }
04690                 }
04691                 else
04692                 {
04693                         // write without knowledge
04694                         for(ucPage=0; ucPage<=85; ucPage++)
04695                         {
04696                                 m_TmpData[iTmpMemAdr]   = 0x00;
04697                                 m_TmpData[iTmpMemAdr+1] = ucPage;
04698                                 iTmpMemAdr += 2;
04699 
04700                                 uiMaxPages++;
04701                         }
04702                 }
04703 
04704                 SetData(FEDM_ISC_TMP_0x8B_WRITE_CFG_N,          (unsigned char)uiMaxPages);     // read one or multiple blocks
04705                 FEDM_CHK2(iErr, SendProtocol(0x8B));
04706                 if(     iErr == 0x13 || // Login-Request
04707                         iErr == 0x19 ) // crypto processing error
04708                 {
04709                         FEDM_RETURN(iErr);
04710                 }
04711                 FEDM_RETURN(FEDM_OK);
04712                 break;
04713 
04714         default:
04715                 if(m_ReaderInfo.bIsMode0x41Read)
04716                 {
04717                         uiMaxPages = m_ReaderInfo.GetNoOfCfgPages();
04718                 }
04719                 else
04720                 {
04721                         FEDM_RETURN(FEDM_ERROR_UNKNOWN_READER_TYPE);
04722                 }
04723         }
04724 
04725 
04726         // write configuration to RAM or EEPROM
04727         FEDM_CHK2(iErr, SetData( FEDM_ISC_TMP_WRITE_CFG, (unsigned char)0));
04728         FEDM_CHK2(iErr, SetData( FEDM_ISC_TMP_WRITE_CFG_LOC, bEEPROM));
04729 
04730         FEDM_CHK2(iErr, SetData(FEDM_ISC_TMP_0x8B_WRITE_MODE, (unsigned char)0));       // mode: write to EEPROM
04731         FEDM_CHK2(iErr, SetData(FEDM_ISC_TMP_0x8B_WRITE_MODE_LOC, bEEPROM));    // mode: write to EEPROM
04732 
04733         if(m_ReaderInfo.bIsMode0x41Read)
04734         {
04735                 // write with knowledge about write permissions
04736                 ucPage = 0;
04737                 for(iIdx=0; iIdx<16; iIdx++) // max 16 permission bytes
04738                 {
04739                         iBitNr = 0x80;
04740                         for(iBitPos=0; iBitPos<8; iBitPos++)
04741                         {
04742                                 if(m_ReaderInfo.ucCfgWritePermissions[iIdx] & iBitNr)
04743                                 {
04744                                         switch(m_uiReaderType)
04745                                         {
04746                                         case FEDM_ISC_TYPE_ISCLR2500_A:
04747                                         case FEDM_ISC_TYPE_ISCLR2500_B:
04748 #ifdef FEDM_NEW_LRU3000_ACC_CFG
04749                                         case FEDM_ISC_TYPE_ISCLRU3000:
04750 #endif
04751                                                 FEDM_CHK2(iErr, SetData(FEDM_ISC_TMP_0x8B_WRITE_DEVICE,         (unsigned char)FEDM_CNTRL_TYPE_RFC));           // device: RFC
04752                                                 FEDM_CHK2(iErr, SetData(FEDM_ISC_TMP_0x8B_WRITE_BANK,           (unsigned char)FEDM_MEM_BANK_TYPE_MAIN));       // bank: main
04753                                                 FEDM_CHK2(iErr, SetData(FEDM_ISC_TMP_0x8B_WRITE_CFG_SIZE,       (unsigned char)(m_iRFC_DataBlockSize-2)));      // blocksize
04754                                                 FEDM_CHK2(iErr, SetData(FEDM_ISC_TMP_0x8B_WRITE_CFG_ADR,        (unsigned int)ucPage)); // start address in memory
04755                                                 FEDM_CHK2(iErr, SetData(FEDM_ISC_TMP_0x8B_WRITE_CFG_N,          (unsigned char)0x01));  // number of blocks
04756                                                 FEDM_CHK2(iErr, SendProtocol(0x8B));
04757                                                 if(     iErr == 0x13 || // Login-Request
04758                                                         iErr == 0x19 ) // crypto processing error
04759                                                 {
04760                                                         FEDM_RETURN(iErr);
04761                                                 }
04762                                                 break;
04763 
04764                                         default:
04765                                                 FEDM_CHK2(iErr, SetData( FEDM_ISC_TMP_WRITE_CFG_ADR, ucPage));
04766                                                 FEDM_CHK2(iErr, SendProtocol(0x81));
04767                                                 if(     iErr == 0x13 || // Login-Request
04768                                                         iErr == 0x19 ) // crypto processing error
04769                                                 {
04770                                                         FEDM_RETURN(iErr);
04771                                                 }
04772                                         }
04773                                 }
04774                                 
04775                                 iBitNr >>= 1;
04776                                 ucPage++;
04777                         }
04778                 }
04779         }
04780         else
04781         {
04782                 // write with explicite knowledge about write permissions from system manuals
04783                 ucPage = 0;
04784 #ifdef __GNUC__
04785                 ui64BitNr = 0x8000000000000000LL;
04786 #else
04787                 ui64BitNr = 0x8000000000000000;
04788 #endif
04789                 for(iBitPos=0; iBitPos<64; iBitPos++)
04790                 {
04791                         if(ui64CfgWritePermissions & ui64BitNr)
04792                         {
04793                                 FEDM_CHK2(iErr, SetData( FEDM_ISC_TMP_WRITE_CFG_ADR, ucPage));
04794                                 FEDM_CHK2(iErr, SendProtocol(0x81));
04795                                 if(     iErr == 0x13 || // Login-Request
04796                                         iErr == 0x19 ) // crypto processing error
04797                                 {
04798                                         FEDM_RETURN(iErr);
04799                                 }
04800                         }
04801                         
04802                         ui64BitNr >>= 1;
04803                         ucPage++;
04804                 }
04805         }
04806 
04807         FEDM_RETURN(FEDM_OK);
04808 }
04809 
04810 /***************************************************************************
04811   Begin                 :       29.07.2008 / M. Hultsch
04812 
04813   Version               :       04.06.01 / 13.03.2014 / M. Hultsch
04814                                                 - return of status 0x11 (Parameter Range Error), when the Reader signals this error
04815 
04816                                                 04.05.04 / 03.09.2013 / M. Hultsch
04817                                                 - new reader: ID ISC.LRU1002
04818 
04819                                                 03.03.00 / 01.02.2011 / M. Hultsch
04820                                                 - ID LR2500-A and -B added
04821   
04822                                                 03.01.00 / 12.02.2010 / M. Hultsch
04823                                                 - support for crypto mode
04824   
04825                                                 03.00.13 / 28.09.2009 / M. Hultsch
04826                                                 - ID MAX50.xx added
04827                                                 - read page back from Reader after status 0x11 (Parameter Range Error)
04828   
04829                                                 03.00.12 / 25.08.2009 / M. Hultsch
04830                                                 - bugfix for ID LRU3000
04831   
04832                                                 03.00.08 / 10.06.2009 / M. Hultsch
04833                                                 - ID CPR44.xx added
04834                                                 - with knowledge of write permission
04835   
04836                                                 03.00.07 / 29.04.2009 / M. Hultsch
04837                                                 - ID ISC.M02.M8 added
04838   
04839                                                 03.00.06 / 16.04.2009 / M. Hultsch
04840                                                 - ID ISC.UM02 added
04841   
04842                                                 03.00.05 / 11.03.2009 / M. Hultsch
04843 
04844   Function                      :       writes modified configuration pages to reader
04845 
04846   Parameters            :       bool bEEPROM    - true, if location is EEPROM
04847 
04848   Return value          :       FEDM_OK                 - if nothing to be applied to
04849                                                 FEDM_MODIFIED   - if at least one page is successfully written
04850                                                 error code (<0) - if something goes wrong
04851                                                 status byte (>1)- if the reader signals a problem
04852 ***************************************************************************/
04853 int FEDM_ISCReaderModule::ApplyConfiguration(bool bEEPROM)
04854 {
04855         if(bEEPROM)
04856         {
04857                 FEDM_TRACE_FNC(m_pLogger, FELOGMNG_DBG_FUNCTION_CALL | FELOGMNG_DBG_LF_COMM_HIGH_LEVEL, __FUNCTION__, FELOGMNG_DBG_FUNCTION_PARAMETER, "EEPROM");
04858         }
04859         else
04860         {
04861                 FEDM_TRACE_FNC(m_pLogger, FELOGMNG_DBG_FUNCTION_CALL | FELOGMNG_DBG_LF_COMM_HIGH_LEVEL, __FUNCTION__, FELOGMNG_DBG_FUNCTION_PARAMETER, "RAM");
04862         }
04863 
04864         bool bModified = false;
04865         bool bIsMode0x41Read = false;
04866         int iErr = 0;
04867         int iBitNr = 0;
04868         int iBitPos = 0;
04869         int iIdx = 0;
04870         int iReturnStatus = FEDM_OK;
04871         unsigned int uiPage      = 0;
04872         unsigned int uiMaxPages = 0;
04873         unsigned char ucData[32];
04874         unsigned char ucCfgWritePermissions[16];
04875 
04876         if(! IsConnected())
04877         {
04878                 FEDM_TRACE(m_pLogger, FELOGMNG_DBG_ERROR, __FUNCTION__ << " " << GetErrorText(FEDM_ERROR_NOT_CONNECTED));
04879                 FEDM_RETURN(FEDM_ERROR_NOT_CONNECTED);
04880         }
04881 
04882         // clear flag field for modified config pages
04883         memset(m_ucModifiedCfgPages, 0, 16);
04884         memset(ucCfgWritePermissions, 0, 16);
04885 
04886         // query write permissions
04887         if(m_ReaderInfo.bIsMode0x41Read)
04888         {
04889                 uiMaxPages = m_ReaderInfo.GetNoOfCfgPages();
04890                 memcpy(ucCfgWritePermissions, m_ReaderInfo.ucCfgWritePermissions, 16);
04891                 bIsMode0x41Read = true;
04892         }
04893         else
04894         {
04895                 FEDM_CHK2(iErr, SetData(FEDM_ISC_TMP_READER_INFO_MODE, (unsigned char)0x41));
04896                 FEDM_CHK2(iErr, SendProtocol(0x66));
04897                 if(     iErr == 0x19 ) // crypto processing error
04898                 {
04899                         FEDM_RETURN(iErr);
04900                 }
04901                 else if(iErr == 0)
04902                 {
04903                         FEDM_CHK2(iErr, GetData(FEDM_GetAdrOfID(FEDM_ISC_TMP_READER_INFO, 32), &ucData[0], 31, FEDM_TMPDATA_MEM));
04904                         uiMaxPages = ((unsigned int)ucData[0]<<8) + (unsigned int)ucData[1];
04905                         memcpy(ucCfgWritePermissions, &ucData[2], 16);
04906                         bIsMode0x41Read = true;
04907                 }
04908         }
04909 
04910         // write configuration to RAM and/or EEPROM
04911 
04912         if(uiMaxPages == 0)
04913         {
04914                 switch(m_uiReaderType)
04915                 {
04916                 case FEDM_ISC_TYPE_ISCM02:
04917                 case FEDM_ISC_TYPE_ISCM02_M8:
04918                 case FEDM_ISC_TYPE_ISCPRH100:
04919                 case FEDM_ISC_TYPE_ISCPRH100_U:
04920                 case FEDM_ISC_TYPE_ISCMR100:    // also FEDM_ISC_TYPE_ISCPR100
04921                 case FEDM_ISC_TYPE_ISCMR100_U:
04922                 case FEDM_ISC_TYPE_CPRM02:
04923                 case FEDM_ISC_TYPE_CPR02:
04924                 case FEDM_ISC_TYPE_CPR04_U:
04925                         uiMaxPages = 8;
04926                         break;
04927                 case FEDM_ISC_TYPE_CPR20_XX:
04928                 case FEDM_ISC_TYPE_CPR40_XX_U:
04929                 case FEDM_ISC_TYPE_CPR40_XX:
04930                 case FEDM_ISC_TYPE_CPR44_XX:
04931                         uiMaxPages = 16;
04932                         break;
04933                 case FEDM_ISC_TYPE_ISCLR200:
04934                         uiMaxPages = 16;
04935                         break;
04936                 case FEDM_ISC_TYPE_ISCPRH101:
04937                 case FEDM_ISC_TYPE_ISCPRH101_U:
04938                 case FEDM_ISC_TYPE_ISCMR101:    // also FEDM_ISC_TYPE_ISCPR101
04939                 case FEDM_ISC_TYPE_ISCMR101_U:
04940                 case FEDM_ISC_TYPE_CPR50_XX:
04941                 case FEDM_ISC_TYPE_ISCMU02:
04942                 case FEDM_ISC_TYPE_ISCMR102:
04943                 case FEDM_ISC_TYPE_ISCPRHD102:
04944                 case FEDM_ISC_TYPE_ISCPRH102:
04945                 case FEDM_ISC_TYPE_ISCMR200:
04946                 case FEDM_ISC_TYPE_ISCMRU200:
04947                 case FEDM_ISC_TYPE_ISCLRU1000:
04948                 case FEDM_ISC_TYPE_ISCLRU2000:
04949                 case FEDM_ISC_TYPE_ISCLR2000:
04950                         uiMaxPages = 64;
04951                         break;
04952                 default:
04953                         uiMaxPages = 64;
04954                         break;
04955                 }
04956         }
04957 
04958         switch(m_uiReaderType)
04959         {
04960         // classic-pro family
04961         case FEDM_ISC_TYPE_CPRM02:
04962         case FEDM_ISC_TYPE_CPR02:
04963         case FEDM_ISC_TYPE_CPR04_U:
04964         case FEDM_ISC_TYPE_CPR20_XX:
04965         case FEDM_ISC_TYPE_CPR40_XX_U:
04966         case FEDM_ISC_TYPE_CPR40_XX:
04967         case FEDM_ISC_TYPE_CPR44_XX:
04968         case FEDM_ISC_TYPE_CPR46_XX:
04969         case FEDM_ISC_TYPE_CPR50_XX:
04970 
04971         // OBID myAXXESS Reader
04972         case FEDM_ISC_TYPE_MAX50_XX:
04973 
04974         // i-scan HF short-range reader
04975         case FEDM_ISC_TYPE_ISCM02:
04976         case FEDM_ISC_TYPE_ISCM02_M8:
04977 
04978         // i-scan HF mid-range reader
04979         case FEDM_ISC_TYPE_ISCPRH100:
04980         case FEDM_ISC_TYPE_ISCPRH100_U:
04981         case FEDM_ISC_TYPE_ISCMR100:    // also FEDM_ISC_TYPE_ISCPR100
04982         case FEDM_ISC_TYPE_ISCMR100_U:
04983         case FEDM_ISC_TYPE_ISCPRH101:
04984         case FEDM_ISC_TYPE_ISCPRH101_U:
04985         case FEDM_ISC_TYPE_ISCMR101:    // also FEDM_ISC_TYPE_ISCPR101
04986         case FEDM_ISC_TYPE_ISCMR101_U:
04987         case FEDM_ISC_TYPE_ISCPRH102:
04988         case FEDM_ISC_TYPE_ISCMR200:
04989         case FEDM_ISC_TYPE_ISCMR10X:
04990 
04991         // i-scan HF long-range reader
04992         case FEDM_ISC_TYPE_ISCLR200:
04993         case FEDM_ISC_TYPE_ISCLR2000:
04994 
04995         // i-scan UHF short-range reader
04996         case FEDM_ISC_TYPE_ISCMU02:
04997 
04998         // i-scan UHF mid-range reader
04999         case FEDM_ISC_TYPE_ISCMRU200:
05000 
05001         // i-scan UHF long-range reader
05002         case FEDM_ISC_TYPE_ISCLRU1000:
05003         case FEDM_ISC_TYPE_ISCLRU2000:
05004 
05005         // i-scan HF/UHF mid-range reader
05006         case FEDM_ISC_TYPE_ISCPRHD102:
05007                 FEDM_CHK2(iErr, SetData( FEDM_ISC_TMP_WRITE_CFG, (unsigned char)0));
05008                 FEDM_CHK2(iErr, SetData( FEDM_ISC_TMP_WRITE_CFG_LOC, bEEPROM));
05009                 if(bIsMode0x41Read)
05010                 {
05011                         // write with knowledge about write permissions
05012                         uiPage = 0;
05013                         for(iIdx=0; iIdx<16; iIdx++) // max 16 permission bytes
05014                         {
05015                                 iBitNr = 0x80;
05016                                 for(iBitPos=0; iBitPos<8; iBitPos++)
05017                                 {
05018                                         if(ucCfgWritePermissions[iIdx] & iBitNr)
05019                                         {
05020                                                 if(uiPage*16 + 15 >= FEDM_ISC_MAX_RFC_EEDATA_MEM)
05021                                                         continue;
05022 
05023                                                 if(     (  bEEPROM  && (m_RFC_EEData[uiPage*16+15] & 0x02)) ||
05024                                                         ((!bEEPROM) && (m_RFC_RAMData[uiPage*16+15] & 0x02)) )
05025                                                 {
05026                                                         FEDM_CHK2(iErr, SetData( FEDM_ISC_TMP_WRITE_CFG_ADR, uiPage));
05027                                                         FEDM_CHK2(iErr, SendProtocol(0x81));
05028                                                         if(iErr == 0x11) // Parameter Range Error
05029                                                         {
05030                                                                 FEDM_CHK2(iErr, SetData( FEDM_ISC_TMP_READ_CFG_LOC, bEEPROM));
05031                                                                 FEDM_CHK2(iErr, SetData( FEDM_ISC_TMP_READ_CFG_ADR, uiPage));
05032                                                                 FEDM_CHK2(iErr, SendProtocol(0x80));
05033                                                                 iReturnStatus = 0x11;
05034                                                         }
05035                                                         else if(iErr == 0x13 || // Login-Request
05036                                                                         iErr == 0x19 ) // crypto processing error
05037                                                         {
05038                                                                 FEDM_RETURN(iErr);
05039                                                         }
05040                                                         else
05041                                                         {
05042                                                                 bModified = true;
05043                                                         }
05044 
05045                                                         // mark modified page in flag field
05046                                                         m_ucModifiedCfgPages[iIdx] |= iBitNr;
05047                                                 }
05048                                         }
05049 
05050                                         iBitNr >>= 1;
05051                                         uiPage++;
05052                                 }
05053                         }
05054                 }
05055                 else
05056                 {
05057                         for(uiPage=0; uiPage<uiMaxPages; ++uiPage)
05058                         {
05059                                 if(uiPage*16 + 15 >= FEDM_ISC_MAX_RFC_EEDATA_MEM)
05060                                         continue;
05061 
05062                                 if(     (  bEEPROM  && (m_RFC_EEData[uiPage*16+15] & 0x02)) ||
05063                                         ((!bEEPROM) && (m_RFC_RAMData[uiPage*16+15] & 0x02)) )
05064                                 {
05065                                         FEDM_CHK2(iErr, SetData( FEDM_ISC_TMP_WRITE_CFG_ADR, uiPage));
05066                                         FEDM_CHK2(iErr, SendProtocol(0x81));
05067                                         if(iErr == 0x11) // Parameter Range Error
05068                                         {
05069                                                 FEDM_CHK2(iErr, SetData( FEDM_ISC_TMP_READ_CFG_LOC, bEEPROM));
05070                                                 FEDM_CHK2(iErr, SetData( FEDM_ISC_TMP_READ_CFG_ADR, uiPage));
05071                                                 FEDM_CHK2(iErr, SendProtocol(0x80));
05072                                                 iReturnStatus = 0x11;
05073                                         }
05074                                         else if(iErr == 0x13 || // Login-Request
05075                                                         iErr == 0x19 ) // crypto processing error
05076                                         {
05077                                                 FEDM_RETURN(iErr);
05078                                         }
05079                                         else
05080                                         {
05081                                                 bModified = true;
05082                                         }
05083 
05084                                         // mark modified page in flag field
05085                                         iIdx = uiPage/8;
05086                                         iBitPos = uiPage % 8;
05087                                         iBitNr = 0x80;
05088                                         iBitNr >>= iBitPos;
05089                                         m_ucModifiedCfgPages[iIdx] |= iBitNr;
05090                                 }
05091                         }
05092                 }
05093                 break;
05094 
05095         case FEDM_ISC_TYPE_ISCLR2500_A:
05096         case FEDM_ISC_TYPE_ISCLR2500_B:
05097 #ifdef FEDM_NEW_LRU3000_ACC_CFG
05098         case FEDM_ISC_TYPE_ISCLRU3000:
05099 #endif
05100                 FEDM_CHK2(iErr, SetData(FEDM_ISC_TMP_0x8B_WRITE_DEVICE,         (unsigned char)FEDM_CNTRL_TYPE_RFC));           // device: ACC
05101                 FEDM_CHK2(iErr, SetData(FEDM_ISC_TMP_0x8B_WRITE_BANK,           (unsigned char)FEDM_MEM_BANK_TYPE_MAIN));       // bank: main
05102                 FEDM_CHK2(iErr, SetData(FEDM_ISC_TMP_0x8B_WRITE_MODE,           (unsigned char)0));             // reset mode byte
05103                 FEDM_CHK2(iErr, SetData(FEDM_ISC_TMP_0x8B_WRITE_MODE_LOC,       bEEPROM));                              // mode: write to EEPROM
05104                 FEDM_CHK2(iErr, SetData(FEDM_ISC_TMP_0x8B_WRITE_CFG_N,          (unsigned char)1));             // write one block
05105                 FEDM_CHK2(iErr, SetData(FEDM_ISC_TMP_0x8B_WRITE_CFG_SIZE,       (unsigned char)(m_iRFC_DataBlockSize-2)));      // blocksize
05106 
05107                 FEDM_CHK2(iErr, SetData(FEDM_ISC_TMP_0x8A_READ_DEVICE,          (unsigned char)FEDM_CNTRL_TYPE_RFC));           // device: ACC
05108                 FEDM_CHK2(iErr, SetData(FEDM_ISC_TMP_0x8A_READ_BANK,            (unsigned char)FEDM_MEM_BANK_TYPE_MAIN));       // bank: main
05109                 FEDM_CHK2(iErr, SetData(FEDM_ISC_TMP_0x8A_READ_MODE,            (unsigned char)0));             // reset mode byte
05110                 FEDM_CHK2(iErr, SetData(FEDM_ISC_TMP_0x8A_READ_MODE_LOC,        bEEPROM));                              // mode: write to EEPROM
05111                 FEDM_CHK2(iErr, SetData(FEDM_ISC_TMP_0x8A_READ_REQ_CFG_N,       (unsigned char)1));             // write one block
05112 
05113                 if(bIsMode0x41Read)
05114                 {
05115                         // write with knowledge about write permissions
05116                         uiPage = 0;
05117                         for(iIdx=0; iIdx<16; iIdx++) // max 16 permission bytes
05118                         {
05119                                 iBitNr = 0x80;
05120                                 for(iBitPos=0; iBitPos<8; iBitPos++)
05121                                 {
05122                                         if(ucCfgWritePermissions[iIdx] & iBitNr)
05123                                         {
05124                                                 if( (  bEEPROM  && (m_RFC_EEData[uiPage*m_iRFC_DataBlockSize+m_iRFC_DataBlockSize-1] & 0x02))  ||
05125                                                         ((!bEEPROM) && (m_RFC_RAMData[uiPage*m_iRFC_DataBlockSize+m_iRFC_DataBlockSize-1] & 0x02)) )
05126                                                 {
05127                                                         FEDM_CHK2(iErr, SetData( FEDM_ISC_TMP_0x8B_WRITE_CFG_ADR, uiPage));
05128                                                         FEDM_CHK2(iErr, SendProtocol(0x8B));
05129                                                         if(iErr == 0x11) // Parameter Range Error
05130                                                         {
05131                                                                 FEDM_CHK2(iErr, SetData( FEDM_ISC_TMP_0x8A_READ_REQ_CFG_ADR, uiPage));
05132                                                                 FEDM_CHK2(iErr, SendProtocol(0x8A));
05133                                                                 iReturnStatus = 0x11;
05134                                                         }
05135                                                         else if(iErr == 0x13 || // Login-Request
05136                                                                         iErr == 0x19 ) // crypto processing error
05137                                                         {
05138                                                                 FEDM_RETURN(iErr);
05139                                                         }
05140                                                         else
05141                                                         {
05142                                                                 bModified = true;
05143                                                         }
05144 
05145                                                         // mark modified page in flag field
05146                                                         m_ucModifiedCfgPages[iIdx] |= iBitNr;
05147                                                 }
05148                                         }
05149 
05150                                         iBitNr >>= 1;
05151                                         uiPage++;
05152                                 }
05153                         }
05154                 }
05155                 else
05156                 {
05157                         FEDM_RETURN(FEDM_ERROR_UNSUPPORTED);
05158                 }
05159 
05160                 break;
05161 
05162 #ifndef FEDM_NEW_LRU3000_ACC_CFG
05163         case FEDM_ISC_TYPE_ISCLRU3000:
05164                 FEDM_CHK2(iErr, SetData(FEDM_ISC_TMP_0x8B_WRITE_DEVICE,         (unsigned char)FEDM_CNTRL_TYPE_ACC));           // device: ACC
05165                 FEDM_CHK2(iErr, SetData(FEDM_ISC_TMP_0x8B_WRITE_BANK,           (unsigned char)FEDM_MEM_BANK_TYPE_MAIN));       // bank: main
05166                 FEDM_CHK2(iErr, SetData(FEDM_ISC_TMP_0x8B_WRITE_MODE,           (unsigned char)0));             // reset mode byte
05167                 FEDM_CHK2(iErr, SetData(FEDM_ISC_TMP_0x8B_WRITE_MODE_LOC,       bEEPROM));                              // mode: write to EEPROM
05168                 FEDM_CHK2(iErr, SetData(FEDM_ISC_TMP_0x8B_WRITE_CFG_N,          (unsigned char)1));             // write one block
05169                 FEDM_CHK2(iErr, SetData(FEDM_ISC_TMP_0x8B_WRITE_CFG_SIZE,       (unsigned char)30));    // blocksize 30-Byte
05170 
05171                 FEDM_CHK2(iErr, SetData(FEDM_ISC_TMP_0x8A_READ_DEVICE,          (unsigned char)FEDM_CNTRL_TYPE_ACC));           // device: ACC
05172                 FEDM_CHK2(iErr, SetData(FEDM_ISC_TMP_0x8A_READ_BANK,            (unsigned char)FEDM_MEM_BANK_TYPE_MAIN));       // bank: main
05173                 FEDM_CHK2(iErr, SetData(FEDM_ISC_TMP_0x8A_READ_MODE,            (unsigned char)0));             // reset mode byte
05174                 FEDM_CHK2(iErr, SetData(FEDM_ISC_TMP_0x8A_READ_MODE_LOC,        bEEPROM));                              // mode: write to EEPROM
05175                 FEDM_CHK2(iErr, SetData(FEDM_ISC_TMP_0x8A_READ_REQ_CFG_N,       (unsigned char)1));             // write one block
05176 
05177                 if(bIsMode0x41Read)
05178                 {
05179                         // write with knowledge about write permissions
05180                         uiPage = 0;
05181                         for(iIdx=0; iIdx<16; iIdx++) // max 16 permission bytes
05182                         {
05183                                 iBitNr = 0x80;
05184                                 for(iBitPos=0; iBitPos<8; iBitPos++)
05185                                 {
05186                                         if(ucCfgWritePermissions[iIdx] & iBitNr)
05187                                         {
05188                                                 if( (  bEEPROM  && (uiPage < 64 && (m_RFC_EEData[uiPage*16+15] & 0x02)))  ||
05189                                                         (  bEEPROM  && (uiPage > 63 && (m_ACC_EEData[uiPage*32+31] & 0x02)))  ||
05190                                                         ((!bEEPROM) && (uiPage < 64 && (m_RFC_RAMData[uiPage*16+15] & 0x02))) ||
05191                                                         ((!bEEPROM) && (uiPage > 63 && (m_ACC_RAMData[uiPage*32+31] & 0x02))) )
05192                                                 {
05193                                                         FEDM_CHK2(iErr, SetData( FEDM_ISC_TMP_0x8B_WRITE_CFG_ADR, uiPage));
05194                                                         FEDM_CHK2(iErr, SendProtocol(0x8B));
05195                                                         if(iErr == 0x11) // Parameter Range Error
05196                                                         {
05197                                                                 FEDM_CHK2(iErr, SetData( FEDM_ISC_TMP_0x8A_READ_REQ_CFG_ADR, uiPage));
05198                                                                 FEDM_CHK2(iErr, SendProtocol(0x8A));
05199                                                                 iReturnStatus = 0x11;
05200                                                         }
05201                                                         else if(iErr == 0x13 || // Login-Request
05202                                                                         iErr == 0x19 ) // crypto processing error
05203                                                         {
05204                                                                 FEDM_RETURN(iErr);
05205                                                         }
05206                                                         else
05207                                                         {
05208                                                                 bModified = true;
05209                                                         }
05210 
05211                                                         // mark modified page in flag field
05212                                                         m_ucModifiedCfgPages[iIdx] |= iBitNr;
05213                                                 }
05214                                         }
05215 
05216                                         iBitNr >>= 1;
05217                                         uiPage++;
05218                                 }
05219                         }
05220                 }
05221                 else
05222                 {
05223                         for(uiPage=0; uiPage<63; ++uiPage)
05224                         {
05225                                 if(     (  bEEPROM  && (m_RFC_EEData[uiPage*16+15] & 0x02)) ||
05226                                         ((!bEEPROM) && (m_RFC_RAMData[uiPage*16+15] & 0x02)) )
05227                                 {
05228                                         FEDM_CHK2(iErr, SetData(FEDM_ISC_TMP_0x8B_WRITE_CFG_ADR, uiPage));      // block address
05229                                         FEDM_CHK2(iErr, SendProtocol(0x8B));
05230                                         if(iErr == 0x11) // Parameter Range Error
05231                                         {
05232                                                 FEDM_CHK2(iErr, SetData( FEDM_ISC_TMP_0x8A_READ_REQ_CFG_ADR, uiPage));
05233                                                 FEDM_CHK2(iErr, SendProtocol(0x8A));
05234                                                 iReturnStatus = 0x11;
05235                                         }
05236                                         else if(iErr == 0x13 || // Login-Request
05237                                                         iErr == 0x19 ) // crypto processing error
05238                                         {
05239                                                 FEDM_RETURN(iErr);
05240                                         }
05241                                         else
05242                                         {
05243                                                 bModified = true;
05244                                         }
05245 
05246                                         // mark modified page in flag field
05247                                         iIdx = uiPage/8;
05248                                         iBitPos = uiPage % 8;
05249                                         iBitNr = 0x80;
05250                                         iBitNr >>= iBitPos;
05251                                         m_ucModifiedCfgPages[iIdx] |= iBitNr;
05252                                 }
05253                         }
05254 
05255                         for(uiPage=64; uiPage<84; ++uiPage)
05256                         {
05257                                 if(     (  bEEPROM  && (m_ACC_EEData[uiPage*32+31] & 0x02)) ||
05258                                         ((!bEEPROM) && (m_ACC_RAMData[uiPage*32+31] & 0x02)) )
05259                                 {
05260                                         FEDM_CHK2(iErr, SetData(FEDM_ISC_TMP_0x8B_WRITE_CFG_ADR, uiPage));      // block address
05261                                         FEDM_CHK2(iErr, SendProtocol(0x8B));
05262                                         if(iErr == 0x11) // Parameter Range Error
05263                                         {
05264                                                 FEDM_CHK2(iErr, SetData( FEDM_ISC_TMP_0x8A_READ_REQ_CFG_ADR, uiPage));
05265                                                 FEDM_CHK2(iErr, SendProtocol(0x8A));
05266                                                 iReturnStatus = 0x11;
05267                                         }
05268                                         else if(iErr == 0x13 || // Login-Request
05269                                                         iErr == 0x19 ) // crypto processing error
05270                                         {
05271                                                 FEDM_RETURN(iErr);
05272                                         }
05273                                         else
05274                                         {
05275                                                 bModified = true;
05276                                         }
05277 
05278                                         // mark modified page in flag field
05279                                         iIdx = uiPage/8;
05280                                         iBitPos = uiPage % 8;
05281                                         iBitNr = 0x80;
05282                                         iBitNr >>= iBitPos;
05283                                         m_ucModifiedCfgPages[iIdx] |= iBitNr;
05284                                 }
05285                         }
05286                 }
05287                 break;
05288 #endif
05289         default:
05290                 FEDM_CHK2(iErr, SetData( FEDM_ISC_TMP_WRITE_CFG, (unsigned char)0));
05291                 FEDM_CHK2(iErr, SetData( FEDM_ISC_TMP_WRITE_CFG_LOC, bEEPROM));
05292                 if(bIsMode0x41Read)
05293                 {
05294                         // write with knowledge about write permissions
05295                         uiPage = 0;
05296                         for(iIdx=0; iIdx<16; iIdx++) // max 16 permission bytes
05297                         {
05298                                 iBitNr = 0x80;
05299                                 for(iBitPos=0; iBitPos<8; iBitPos++)
05300                                 {
05301                                         if(ucCfgWritePermissions[iIdx] & iBitNr)
05302                                         {
05303                                                 if(uiPage*16 + 15 >= FEDM_ISC_MAX_RFC_EEDATA_MEM)
05304                                                         continue;
05305 
05306                                                 if(     (  bEEPROM  && (m_RFC_EEData[uiPage*16+15] & 0x02)) ||
05307                                                         ((!bEEPROM) && (m_RFC_RAMData[uiPage*16+15] & 0x02)) )
05308                                                 {
05309                                                         FEDM_CHK2(iErr, SetData( FEDM_ISC_TMP_WRITE_CFG_ADR, uiPage));
05310                                                         FEDM_CHK2(iErr, SendProtocol(0x81));
05311                                                         if(iErr == 0x11) // Parameter Range Error
05312                                                         {
05313                                                                 FEDM_CHK2(iErr, SetData( FEDM_ISC_TMP_READ_CFG_ADR, uiPage));
05314                                                                 FEDM_CHK2(iErr, SendProtocol(0x80));
05315                                                                 iReturnStatus = 0x11;
05316                                                         }
05317                                                         else if(iErr == 0x13 || // Login-Request
05318                                                                         iErr == 0x19 ) // crypto processing error
05319                                                         {
05320                                                                 FEDM_RETURN(iErr);
05321                                                         }
05322                                                         else
05323                                                         {
05324                                                                 bModified = true;
05325                                                         }
05326 
05327                                                         // mark modified page in flag field
05328                                                         m_ucModifiedCfgPages[iIdx] |= iBitNr;
05329                                                 }
05330                                         }
05331 
05332                                         iBitNr >>= 1;
05333                                         uiPage++;
05334                                 }
05335                         }
05336                 }
05337                 else
05338                 {
05339                         FEDM_RETURN(FEDM_ERROR_UNKNOWN_READER_TYPE);
05340                 }
05341         }
05342 
05343         if(bModified)
05344         {
05345                 if(iReturnStatus == FEDM_OK)
05346                 {
05347                         FEDM_RETURN(FEDM_MODIFIED);
05348                 }
05349                 else
05350                 {
05351                         FEDM_RETURN(iReturnStatus);
05352                 }
05353         }
05354         else
05355         {
05356                 FEDM_RETURN(iReturnStatus);
05357         }
05358 }
05359 
05360 
05361 unsigned char* FEDM_ISCReaderModule::GetModifiedCfgPageFlags()
05362 {
05363         return m_ucModifiedCfgPages;
05364 }
05365 
05366 
05367 /***************************************************************************
05368   Begin                 :       05.08.2008 / M. Hultsch
05369 
05370   Version               :       04.05.04 / 03.09.2013 / M. Hultsch
05371                                                 - new reader: ID ISC.LRU1002
05372 
05373                                                 03.03.00 / 31.01.2011 / M. Hultsch
05374                                                 - with automatic detect, when busaddress, baudrate or frame are modified
05375   
05376                                                 03.01.01 / 10.03.2010 / M. Hultsch
05377                                                 - with final CPU-Reset
05378   
05379                                                 03.01.00 / 12.02.2010 / M. Hultsch
05380                                                 - support for crypto mode
05381   
05382                                                 03.00.03 / 27.01.2009 / M. Hultsch
05383 
05384   Function                      :       resets complete configuration to factory default
05385 
05386   Parameters            :       bool bEEPROM    - true, if location is EEPROM
05387 
05388   Return value          :       FEDM_OK or error code (<0) or status byte (>0)
05389 ***************************************************************************/
05390 int FEDM_ISCReaderModule::ResetCompleteConfiguration(bool bEEPROM)
05391 {
05392         if(bEEPROM)
05393         {
05394                 FEDM_TRACE_FNC(m_pLogger, FELOGMNG_DBG_FUNCTION_CALL | FELOGMNG_DBG_LF_COMM_HIGH_LEVEL, __FUNCTION__, FELOGMNG_DBG_FUNCTION_PARAMETER, "EEPROM");
05395         }
05396         else
05397         {
05398                 FEDM_TRACE_FNC(m_pLogger, FELOGMNG_DBG_FUNCTION_CALL | FELOGMNG_DBG_LF_COMM_HIGH_LEVEL, __FUNCTION__, FELOGMNG_DBG_FUNCTION_PARAMETER, "RAM");
05399         }
05400 
05401         int iErr = 0;
05402         int iBack = 0;
05403         __int64 t1, t2;
05404         bool bDetect = false;
05405         unsigned char ucOldBusAdr = 0;
05406         unsigned char ucOldBaudrate = 0;
05407         unsigned char ucOldParity = 0;
05408         unsigned char ucNewBusAdr = 0;
05409         unsigned char ucNewBaudrate = 0;
05410         unsigned char ucNewParity = 0;
05411 
05412         if(! IsConnected())
05413         {
05414                 FEDM_TRACE(m_pLogger, FELOGMNG_DBG_ERROR, __FUNCTION__ << " " << GetErrorText(FEDM_ERROR_NOT_CONNECTED));
05415                 FEDM_RETURN(FEDM_ERROR_NOT_CONNECTED);
05416         }
05417 
05418         GetConfigPara(CoreImpl::ReaderConfig::HostInterface::Serial::BusAddress, &ucOldBusAdr);
05419         GetConfigPara(CoreImpl::ReaderConfig::HostInterface::Serial::Baudrate, &ucOldBaudrate);
05420         GetConfigPara(CoreImpl::ReaderConfig::HostInterface::Serial::Parity, &ucOldParity);
05421 
05422         switch(m_uiReaderType)
05423         {
05424         case FEDM_ISC_TYPE_ISCLR2500_A:
05425         case FEDM_ISC_TYPE_ISCLR2500_B:
05426 #ifdef FEDM_NEW_LRU3000_ACC_CFG
05427         case FEDM_ISC_TYPE_ISCLRU3000:
05428 #endif
05429                 FEDM_CHK2(iErr, SetData(FEDM_ISC_TMP_0x8C_RESET_DEVICE,         (unsigned char)FEDM_CNTRL_TYPE_RFC));           // device: ACC
05430                 FEDM_CHK2(iErr, SetData(FEDM_ISC_TMP_0x8C_RESET_BANK,           (unsigned char)FEDM_MEM_BANK_TYPE_MAIN));       // bank: main
05431                 FEDM_CHK2(iErr, SetData(FEDM_ISC_TMP_0x8C_RESET_MODE,           (unsigned char)0x00));  // reset mode byte
05432                 FEDM_CHK2(iErr, SetData(FEDM_ISC_TMP_0x8C_RESET_MODE_LOC,       bEEPROM));                              // mode: reset in EEPROM and or RAM
05433                 FEDM_CHK2(iErr, SetData(FEDM_ISC_TMP_0x8C_RESET_MODE_ALL,       true)); // mode: reset all
05434                 FEDM_CHK2(iErr, SetData(FEDM_ISC_TMP_0x8C_RESET_CFG_N,          (unsigned char)0));             // number of block not necessary
05435                 FEDM_CHK2(iErr, SetData(FEDM_ISC_TMP_0x8C_RESET_CFG_ADR,        (unsigned char)0));             // first block address not necessary
05436                 FEDM_CHK2(iErr, SendProtocol(0x8C));
05437                 if(     iErr == 0x13 || // Login-Request
05438                         iErr == 0x19 ) // crypto processing error
05439                 {
05440                         FEDM_RETURN(iErr);
05441                 }
05442                 break;
05443 
05444 #ifndef FEDM_NEW_LRU3000_ACC_CFG
05445         case FEDM_ISC_TYPE_ISCLRU3000:
05446                 FEDM_CHK2(iErr, SetData(FEDM_ISC_TMP_0x8C_RESET_DEVICE,         (unsigned char)FEDM_CNTRL_TYPE_ACC));           // device: ACC
05447                 FEDM_CHK2(iErr, SetData(FEDM_ISC_TMP_0x8C_RESET_BANK,           (unsigned char)FEDM_MEM_BANK_TYPE_MAIN));       // bank: main
05448                 FEDM_CHK2(iErr, SetData(FEDM_ISC_TMP_0x8C_RESET_MODE,           (unsigned char)0x00));  // reset mode byte
05449                 FEDM_CHK2(iErr, SetData(FEDM_ISC_TMP_0x8C_RESET_MODE_LOC,       bEEPROM));                              // mode: reset in EEPROM and or RAM
05450                 FEDM_CHK2(iErr, SetData(FEDM_ISC_TMP_0x8C_RESET_MODE_ALL,       true)); // mode: reset all
05451                 FEDM_CHK2(iErr, SetData(FEDM_ISC_TMP_0x8C_RESET_CFG_N,          (unsigned char)0));             // number of block not necessary
05452                 FEDM_CHK2(iErr, SetData(FEDM_ISC_TMP_0x8C_RESET_CFG_ADR,        (unsigned char)0));             // first block address not necessary
05453                 FEDM_CHK2(iErr, SendProtocol(0x8C));
05454                 if(     iErr == 0x13 || // Login-Request
05455                         iErr == 0x19 ) // crypto processing error
05456                 {
05457                         FEDM_RETURN(iErr);
05458                 }
05459                 break;
05460 #endif
05461         default:
05462                 FEDM_CHK2(iErr, SetData( FEDM_ISC_TMP_RESET_CFG, (unsigned char)0));
05463                 FEDM_CHK2(iErr, SetData( FEDM_ISC_TMP_RESET_CFG_LOC, bEEPROM)); // RAM and EEPROM
05464                 FEDM_CHK2(iErr, SetData( FEDM_ISC_TMP_RESET_CFG_MODE, true));   // all configuration pages
05465                 FEDM_CHK2(iErr, SendProtocol(0x83));
05466                 if(     iErr == 0x13 || // Login-Request
05467                         iErr == 0x19 ) // crypto processing error
05468                 {
05469                         FEDM_RETURN(iErr);
05470                 }
05471                 break;
05472         }
05473 
05474         // CPU-Reset
05475         if(bEEPROM)
05476         {
05477                 if(FEDM_IS_COMPORT(GetPortHnd()))
05478                 {
05479                         switch(m_uiReaderType)
05480                         {
05481                         case FEDM_ISC_TYPE_ISCLR2500_B:
05482                                 FEDM_CHK2(iErr, SetData(FEDM_ISC_TMP_0x8A_READ_DEVICE,          (unsigned char)FEDM_CNTRL_TYPE_RFC));           // device: ACC
05483                                 FEDM_CHK2(iErr, SetData(FEDM_ISC_TMP_0x8A_READ_BANK,            (unsigned char)FEDM_MEM_BANK_TYPE_MAIN));       // bank: main
05484                                 FEDM_CHK2(iErr, SetData(FEDM_ISC_TMP_0x8A_READ_MODE,            (unsigned char)0x00));  // reset mode byte
05485                                 FEDM_CHK2(iErr, SetData(FEDM_ISC_TMP_0x8A_READ_MODE_LOC,        bEEPROM));                              // mode: reset in EEPROM and or RAM
05486                                 FEDM_CHK2(iErr, SetData(FEDM_ISC_TMP_0x8A_READ_REQ_CFG_N,       (unsigned char)1));             // 1 block
05487                                 FEDM_CHK2(iErr, SetData(FEDM_ISC_TMP_0x8A_READ_REQ_CFG_ADR,     (unsigned char)1));             // CFG1
05488                                 FEDM_CHK2(iErr, SendProtocol(0x8A));
05489                                 if(     iErr == 0x13 || // Login-Request
05490                                         iErr == 0x19 ) // crypto processing error
05491                                 {
05492                                         FEDM_RETURN(iErr);
05493                                 }
05494                                 break;
05495 
05496                         default:
05497                                 FEDM_CHK2(iErr, SetData( FEDM_ISC_TMP_READ_CFG, (unsigned char)1));
05498                                 FEDM_CHK2(iErr, SetData( FEDM_ISC_TMP_READ_CFG_LOC, bEEPROM));  // RAM and EEPROM
05499                                 FEDM_CHK2(iErr, SendProtocol(0x80));
05500                                 if(     iErr == 0x13 || // Login-Request
05501                                         iErr == 0x19 ) // crypto processing error
05502                                 {
05503                                         FEDM_RETURN(iErr);
05504                                 }
05505                                 break;
05506                         }
05507 
05508                         // check for new detection
05509                         GetConfigPara(CoreImpl::ReaderConfig::HostInterface::Serial::BusAddress, &ucNewBusAdr);
05510                         GetConfigPara(CoreImpl::ReaderConfig::HostInterface::Serial::Baudrate, &ucNewBaudrate);
05511                         GetConfigPara(CoreImpl::ReaderConfig::HostInterface::Serial::Parity, &ucNewParity);
05512                         if(ucOldBusAdr != ucNewBusAdr)
05513                         {
05514                                 SetBusAddress(ucNewBusAdr);
05515                                 bDetect = true;
05516                         }
05517 
05518                         if(ucOldBaudrate != ucNewBaudrate)
05519                                 bDetect = true;
05520 
05521                         if(ucOldParity != ucNewParity)
05522                                 bDetect = true;
05523                 }
05524 
05525                 FEDM_CHK2(iErr, SendProtocol(0x63));
05526 
05527                 // we must wait for Reader finishing CPU-Reset
05528 
05529                 t1 = FEDM_GetUTCTimestamp() / 1000;     // time in µs
05530                 t2 = t1 + (__int64)10000;
05531 
05532                 if(FEDM_IS_COMPORT(GetPortHnd()))
05533                 {
05534                         FEDM_SLEEP(FE_1000MS);
05535 
05536                         // detection method
05537                         if(bDetect)
05538                         {
05539                                 FindBaudRate();
05540                         }
05541                         else
05542                         {
05543                                 int iTimeout = 0;
05544                                 GetPortPara("Timeout", &iTimeout);
05545                                 SetPortPara("Timeout", "200");
05546                                 while(SendProtocol(0x52))
05547                                 {
05548                                         t1 = FEDM_GetUTCTimestamp() / 1000;     // time in µs
05549                                         if(t1 > t2)
05550                                         {
05551                                                 break;
05552                                         }
05553                                 }
05554                                 SetPortPara("Timeout", iTimeout);
05555                         }
05556                 }
05557                 else if(FEDM_IS_USBPORT(GetPortHnd()))
05558                 {
05559                         // handling internally
05560                 }
05561                 else  if(FEDM_IS_TCPPORT(GetPortHnd()))
05562                 {
05563                         char cConIPAdr[16];
05564                         int iConIPPort = 0;
05565 
05566                         this->GetPortPara("HostAdr", cConIPAdr);
05567                         this->GetPortPara("PortNr", &iConIPPort);
05568 
05569                         DisConnect();
05570                         FEDM_SLEEP(FE_1000MS);
05571 
05572                         while(ConnectTCP(cConIPAdr, iConIPPort))
05573                         {
05574                                 FEDM_SLEEP(FE_500MS);
05575 
05576                                 t1 = FEDM_GetUTCTimestamp() / 1000;     // time in µs
05577                                 if(t1 > t2)
05578                                 {
05579                                         // error
05580                                         break;
05581                                 }
05582                         }
05583                 }
05584         }
05585 
05586         FEDM_RETURN(FEDM_OK);
05587 }
05588 
05589 
05590 /***************************************************************************
05591   Begin                 :       13.08.2007 / M. Hultsch
05592   Version               :       03.00.02 / 14.01.2009 / M. Hultsch
05593 
05594   Function                      :       main-function for XML based reader profiling
05595 
05596   Parameters            :       bool bRead              -       if true : serialize from XML-File
05597                                                                                         if false: serialize into XML-File
05598                                                 char* sFileName -       pointer to file name with directory
05599 
05600   Return value          :       OK or error code
05601 
05602 ***************************************************************************/
05603 int FEDM_ISCReaderModule::SerializeProfile(bool bRead, char* sFileName)
05604 {
05605 #ifdef _FEDM_XML_SUPPORT
05606         int iBack = FEDM_DataBase::SerializeProfile(&m_ProfileModule, bRead, sFileName);
05607 
05608         FEDM_RETURN(iBack);
05609 #else
05610         FEDM_RETURN(FEDM_ERROR_UNSUPPORTED);
05611 #endif
05612 }
05613 
05614 
05615 /***************************************************************************
05616   Begin                 :       11.11.2003 / M. Hultsch
05617 
05618   Version               :       03.03.01 / 31.03.2011 / M. Hultsch
05619 
05620   Function                      :       transfer configuration from XML file to reader
05621 
05622   Parameters            :       char* sFileName -       pointer to file name with directory
05623 
05624   Return value          :       FEDM_OK or error code (<0) or status byte (>0)
05625 ***************************************************************************/
05626 int FEDM_ISCReaderModule::TransferXmlFileToReaderCfg(char* sFileName)
05627 {
05628 #ifdef _FEDM_XML_SUPPORT
05629         FEDM_TRACE(m_pLogger, FELOGMNG_DBG_FUNCTION_CALL | FELOGMNG_DBG_LF_COMM_HIGH_LEVEL, __FUNCTION__);
05630 
05631         int iBack = 0;
05632 
05633         if(! IsConnected())
05634         {
05635                 FEDM_TRACE(m_pLogger, FELOGMNG_DBG_ERROR, __FUNCTION__ << " " << GetErrorText(FEDM_ERROR_NOT_CONNECTED));
05636                 FEDM_RETURN(FEDM_ERROR_NOT_CONNECTED);
05637         }
05638 
05639         // get all information from reader
05640         if(NULL == ReadReaderInfo())
05641                 return this->GetLastError();
05642 
05643         // read from file
05644         FEDM_CHK2(iBack, Serialize(true, sFileName));
05645 
05646         // write to readers EEPROM and RAM
05647         FEDM_CHK4(iBack, WriteCompleteConfiguration(true));
05648 
05649         // execute CPU reset
05650         FEDM_CHK2(iBack, SendProtocol(0x63));
05651 
05652         // copy EEPROM content to RAM memory
05653         m_RFC_RAMData = m_RFC_EEData;
05654 
05655         if(m_ACC_EEData.size() > 0)
05656                 m_ACC_RAMData = m_ACC_EEData;
05657 
05658         FEDM_RETURN(FEDM_OK);
05659 #else
05660         FEDM_TRACE(m_pLogger, FELOGMNG_DBG_ERROR, __FUNCTION__ << " " << GetErrorText(FEDM_ERROR_UNSUPPORTED));
05661         FEDM_RETURN(FEDM_ERROR_UNSUPPORTED);
05662 #endif
05663 }
05664 
05665 /***************************************************************************
05666   Begin                 :       11.11.2003 / M. Hultsch
05667 
05668   Version               :       03.00.00 / 28.10.2008 / M. Hultsch
05669 
05670   Function                      :       transfer configuration from reader to XML file
05671 
05672   Parameters            :       char* sFileName -       pointer to file name with directory
05673 
05674   Return value          :       FEDM_OK or error code (<0) or status byte (>0)
05675 ***************************************************************************/
05676 int FEDM_ISCReaderModule::TransferReaderCfgToXmlFile(char* sFileName)
05677 {
05678 #ifdef _FEDM_XML_SUPPORT
05679         FEDM_TRACE(m_pLogger, FELOGMNG_DBG_FUNCTION_CALL | FELOGMNG_DBG_LF_COMM_HIGH_LEVEL, __FUNCTION__);
05680 
05681         int iBack = 0;
05682 
05683         if(! IsConnected())
05684         {
05685                 FEDM_TRACE(m_pLogger, FELOGMNG_DBG_ERROR, __FUNCTION__ << " " << GetErrorText(FEDM_ERROR_NOT_CONNECTED));
05686                 FEDM_RETURN(FEDM_ERROR_NOT_CONNECTED);
05687         }
05688 
05689         // get all information from reader
05690         if(NULL == ReadReaderInfo())
05691                 return this->GetLastError();
05692 
05693         // read from readers EEPROM and RAM
05694         FEDM_CHK4(iBack, ReadCompleteConfiguration(true));
05695         FEDM_CHK4(iBack, ReadCompleteConfiguration(false));
05696 
05697         // write to file
05698         FEDM_CHK2(iBack, Serialize(false, sFileName));
05699 
05700         FEDM_RETURN(FEDM_OK);
05701 #else
05702         FEDM_TRACE(m_pLogger, FELOGMNG_DBG_ERROR, __FUNCTION__ << " " << GetErrorText(FEDM_ERROR_UNSUPPORTED));
05703         FEDM_RETURN(FEDM_ERROR_UNSUPPORTED);
05704 #endif
05705 }
05706 
05707 /***************************************************************************
05708   Begin                 :       06.11.2003 / M. Hultsch
05709 
05710   Version               :       01.09.00 / 06.11.2003 / M. Hultsch
05711 
05712   Function                      :       gets readers software version
05713 
05714   Parameters            :       unsigned char* ucSWRev  -       pointer to software version (2 bytes)
05715                                                 unsigned char* ucDevRev -       pointer to reader developer revision (1 byte)
05716                                                 unsigned char* ucHWType -       pointer to hardware identifier (1 byte)
05717                                                 unsigned char* ucSWType -       pointer to reader type (1 byte)
05718                                                 unsigned char* ucTrp    -       poitner to transponder support (2 bytes)
05719 
05720   Return value          :       FEDM_OK or error code (<0) or status byte (>0)
05721 ***************************************************************************/
05722 int FEDM_ISCReaderModule::ReadSoftVersion(      unsigned char* ucSWRev, 
05723                                                                                         unsigned char* ucDevRev, 
05724                                                                                         unsigned char* ucHWType, 
05725                                                                                         unsigned char* ucSWType, 
05726                                                                                         unsigned char* ucTrp )
05727 {
05728         int iErr;
05729         FEDM_CHK3(ucSWRev);
05730         FEDM_CHK3(ucDevRev);
05731         FEDM_CHK3(ucHWType);
05732         FEDM_CHK3(ucSWType);
05733         FEDM_CHK3(ucTrp);
05734 
05735         FEDM_CHK4(iErr, SendProtocol(0x65));
05736 
05737         FEDM_CHK2(iErr, GetData(FEDM_ISC_TMP_SOFTVER_SW_REV, ucSWRev, 2));
05738         FEDM_CHK2(iErr, GetData(FEDM_ISC_TMP_SOFTVER_D_REV, ucDevRev));
05739         FEDM_CHK2(iErr, GetData(FEDM_ISC_TMP_SOFTVER_HW_TYPE, ucHWType));
05740         FEDM_CHK2(iErr, GetData(FEDM_ISC_TMP_SOFTVER_SW_TYPE, ucSWType));
05741         FEDM_CHK2(iErr, GetData(FEDM_ISC_TMP_SOFTVER_TR_TYPE, ucTrp, 2));
05742 
05743         FEDM_RETURN(FEDM_OK);
05744 }
05745 
05746 /***************************************************************************
05747   Begin                 :       19.06.2007 / M. Hultsch
05748 
05749   Version               :       04.05.05 / 29.11.2013 / M. Hultsch
05750                                                 - new mode: 0x09 for WLAN-Firmware
05751 
05752                                                 04.05.04 / 04.09.2013 / M. Hultsch
05753                                                 - new reader: ID ISC.LRU1002
05754 
05755                                                 04.02.06 / 25.07.2012 / M. Hultsch
05756                                                 - new mode 0x08 (with firmware supported tag drivers)
05757 
05758                                                 03.03.00 / 10.02.2011 / M. Hultsch
05759 
05760   Function                      :       gets readers complete information from reader
05761                                                 >> partial read is possible <<
05762 
05763   Parameters            :       unsigned int uiProtocolFrame    - frame to be used for communication
05764                                                                                                                   (FEDM_PRT_FRAME_STANDARD, FEDM_PRT_FRAME_ADVANCED)
05765 
05766   Return value          :       FEDM_ISC_READER_INFO*   - pointer to info structure
05767                                                 or
05768                                                 NULL in error case
05769 ***************************************************************************/
05770 FEDM_ISC_READER_INFO* FEDM_ISCReaderModule::ReadReaderInfo(unsigned int uiProtocolFrame)
05771 {
05772         FEDM_TRACE(m_pLogger, FELOGMNG_DBG_FUNCTION_CALL | FELOGMNG_DBG_LF_COMM_HIGH_LEVEL, __FUNCTION__);
05773 
05774         unsigned char ucData[32];
05775         int iBack = 0;
05776         int iMemAdr = 0;
05777         unsigned int uiPageCount = 0;
05778 
05779         m_ReaderInfo.Init();
05780 
05781         // for support of all readers: use standard protocol frame
05782         switch(this->m_uiReaderType)
05783         {
05784         case FEDM_ISC_TYPE_ISCLR2500_A:
05785         case FEDM_ISC_TYPE_ISCLRU3000:
05786                 SetProtocolFrameSupport(FEDM_PRT_FRAME_ADVANCED);
05787                 break;
05788         default:
05789                 SetProtocolFrameSupport(uiProtocolFrame);
05790                 break;
05791         }
05792 
05793         // ####################################################################################
05794         // try to get all
05795         // mode: 0xFF - all
05796         // ####################################################################################
05797         FEDM_CHK7(iBack, SetData(FEDM_ISC_TMP_READER_INFO_MODE, (unsigned char)0xFF));
05798         FEDM_CHK7(iBack, SendProtocol(0x66));
05799         if(iBack==0x19) // crypto processing error
05800         {
05801                 this->SetLastError(iBack);
05802                 return NULL;
05803         }
05804         
05805         if(iBack==0x00 || iBack==0x84 || iBack==0xF1)
05806         {
05807                 // ####################################################################################
05808                 // frequency information (EU, FCC) for older reader types
05809                 // ####################################################################################
05810                 switch(m_ReaderInfo.ucReaderType)       // reader type
05811                 {
05812                 // HF/UHF function unit types
05813                 case FEDM_ISC_TYPE_ANT_DAT:
05814                 case FEDM_ISC_TYPE_ANT_UMUX:
05815                 // classic-pro Reader
05816                 case FEDM_ISC_TYPE_CPRM02:
05817                 case FEDM_ISC_TYPE_CPR02:
05818                 case FEDM_ISC_TYPE_CPR04_U:
05819                 // i-scan HF Reader
05820                 case FEDM_ISC_TYPE_ISCLR200:
05821                 case FEDM_ISC_TYPE_ISCM02:
05822                         // standard frame
05823                         break;
05824 
05825                 // UHF-Reader
05826                 case FEDM_ISC_TYPE_ISCLRU1000:
05827                         FEDM_CHK7(iBack, FEISC_0x80_ReadConfBlock(      GetReaderHnd(),
05828                                                                                                                 GetBusAddress(), 
05829                                                                                                                 0x43,
05830                                                                                                                 ucData,
05831                                                                                                                 0 ));
05832 
05833                         if(iBack==0x00 || iBack==0x18 || iBack==0x84)
05834                         {
05835                                 m_ReaderInfo.ucRfcFrequency             = ucData[5];    // 1: EU; 2: FCC
05836                                 m_ReaderInfo.bIsRfcFrequency    = true;
05837                         }
05838                         SetProtocolFrameSupport(FEDM_PRT_FRAME_ADVANCED);
05839                         break;
05840 
05841                 case FEDM_ISC_TYPE_ISCLRU2000:
05842                         if(m_ReaderInfo.ucRfcSwVer[0] >= 2)
05843                         {
05844                                 m_ReaderInfo.bIsRfcFrequency = true; // beginning with Release 2.0.0
05845                                                                                                          // LRU2000 is compatible with standard
05846                         }
05847                         else
05848                         {
05849                                 FEDM_CHK7(iBack, FEISC_0x80_ReadConfBlock(      GetReaderHnd(),
05850                                                                                                                         GetBusAddress(), 
05851                                                                                                                         0x43,
05852                                                                                                                         ucData,
05853                                                                                                                         0 ));
05854 
05855                                 if(iBack==0x00 || iBack==0x18 || iBack==0x84)
05856                                 {
05857                                         m_ReaderInfo.ucRfcFrequency             = ucData[5];    // 1: EU; 2: FCC
05858                                         m_ReaderInfo.bIsRfcFrequency    = true;
05859                                 }
05860                         }
05861                         SetProtocolFrameSupport(FEDM_PRT_FRAME_ADVANCED);
05862                         break;
05863 
05864                 default:
05865                         SetProtocolFrameSupport(FEDM_PRT_FRAME_ADVANCED);
05866                         break;
05867                 }
05868 
05869                 SetLastError(FEDM_OK);
05870                 return &m_ReaderInfo;
05871         }
05872 
05873 
05874         // ####################################################################################
05875         // new standard protocol - must have all newer readers implemented
05876         // mode: 0x00 - RFC firmware version
05877         // ####################################################################################
05878         FEDM_CHK7(iBack, SetData(FEDM_ISC_TMP_READER_INFO_MODE, (unsigned char)0x00));
05879         FEDM_CHK7(iBack, SendProtocol(0x66));
05880         if(iBack==0x00 || iBack==0x84 || iBack==0xF1)
05881         {
05882                 FEDM_CHK7(iBack, GetData(FEDM_ISC_TMP_SOFTVER, &m_ReaderInfo.ucRfcSwVer[0], 16));
05883                 FEDM_CHK7(iBack, SetReaderType(m_ReaderInfo.ucReaderType));
05884                 m_ReaderInfo.bIsMode0x00Read = true;
05885         }
05886         else
05887         {
05888                 // ####################################################################################
05889                 // formerly standard protocol - must have all readers implemented
05890                 // same as [0x66] with mode 0x00
05891                 // ####################################################################################
05892                 FEDM_CHK7(iBack, SendProtocol(0x65));
05893                 if(iBack==0x00 || iBack==0x84 || iBack==0xF1)
05894                 {
05895                         FEDM_CHK7(iBack, GetData(FEDM_ISC_TMP_SOFTVER, &m_ReaderInfo.ucRfcSwVer[0], 11));
05896                         FEDM_CHK7(iBack, SetReaderType(m_ReaderInfo.ucReaderType));
05897                         m_ReaderInfo.bIsMode0x00Read = true;
05898                 }
05899         }
05900 
05901         switch(m_ReaderInfo.ucReaderType)       // reader type
05902         {
05903         // exceptions for Readers without advanced protocol frame support
05904         // HF/UHF function unit types
05905         case FEDM_ISC_TYPE_ANT_DAT:
05906         case FEDM_ISC_TYPE_ANT_UMUX:
05907         // classic-pro Reader
05908         case FEDM_ISC_TYPE_CPRM02:
05909         case FEDM_ISC_TYPE_CPR02:
05910         case FEDM_ISC_TYPE_CPR04_U:
05911         // i-scan HF Reader
05912         case FEDM_ISC_TYPE_ISCLR200:
05913         case FEDM_ISC_TYPE_ISCM02:
05914                 // standard frame
05915                 break;
05916 
05917         // exceptions for Readers with only advanced protocol frame support
05918         default:
05919                 SetProtocolFrameSupport(FEDM_PRT_FRAME_ADVANCED);
05920                 break;
05921         }
05922         
05923         // ReaderInfo is partial or completely read
05924         m_ReaderInfo.bIsInfoRead = true;
05925 
05926 
05927         // ####################################################################################
05928         // mode: 0x01 - ACC firmware version
05929         // ####################################################################################
05930         switch(m_ReaderInfo.ucReaderType)       // reader type
05931         {
05932         // HF-Reader
05933         case FEDM_ISC_TYPE_ISCLR2000:
05934         case FEDM_ISC_TYPE_ISCLR2500_A:
05935         // UHF-Reader
05936         case FEDM_ISC_TYPE_ISCLRU1000:
05937         case FEDM_ISC_TYPE_ISCLRU2000:
05938         case FEDM_ISC_TYPE_ISCLRU3000:
05939                 FEDM_CHK7(iBack, SetData(FEDM_ISC_TMP_READER_INFO_MODE, (unsigned char)0x01));
05940                 FEDM_CHK7(iBack, SendProtocol(0x66));
05941                 if(iBack==0x00 || iBack==0x84 || iBack==0xF1)
05942                 {
05943                         FEDM_CHK7(iBack, GetData(FEDM_ISC_TMP_READER_INFO, &m_ReaderInfo.ucAccSwVer[0], 4));
05944                         m_ReaderInfo.bIsMode0x01Read = true;
05945                 }
05946                 break;
05947         }
05948 
05949 
05950         // ####################################################################################
05951         // mode: 0x02 - USB-Controller firmware version
05952         // ####################################################################################
05953         switch(m_ReaderInfo.ucReaderType)       // reader type
05954         {
05955         case FEDM_ISC_TYPE_CPR04_U:
05956                 FEDM_CHK7(iBack, SetData(FEDM_ISC_TMP_READER_INFO_MODE, (unsigned char)0x02));
05957                 FEDM_CHK7(iBack, SendProtocol(0x66));
05958                 if(iBack==0x00 || iBack==0x84 || iBack==0xF1)
05959                 {
05960                         FEDM_CHK7(iBack, GetData(FEDM_ISC_TMP_READER_INFO, &m_ReaderInfo.ucUsbSwVer[0], 4));
05961                         m_ReaderInfo.bIsMode0x02Read = true;
05962                 }
05963                 break;
05964         }
05965 
05966 
05967         // ####################################################################################
05968         // mode: 0x03 - FPGA firmware version
05969         // ####################################################################################
05970         switch(m_ReaderInfo.ucReaderType)       // reader type
05971         {
05972         // megalock C
05973         case FEDM_ISC_TYPE_MLC_COM:
05974         // classic-pro
05975         case FEDM_ISC_TYPE_CPR20_XX:
05976         case FEDM_ISC_TYPE_CPR40_XX_U:
05977         case FEDM_ISC_TYPE_CPR40_XX:
05978         case FEDM_ISC_TYPE_CPR44_XX:
05979         case FEDM_ISC_TYPE_CPR46_XX:
05980         case FEDM_ISC_TYPE_CPR47_XX:
05981         // myAXXESS
05982         case FEDM_ISC_TYPE_MAX_ONTOP:
05983         case FEDM_ISC_TYPE_MAXU1002:
05984         // HF-Reader
05985         case FEDM_ISC_TYPE_ISCLR2000:
05986         case FEDM_ISC_TYPE_ISCLR2500_A:
05987         case FEDM_ISC_TYPE_ISCLR2500_B:
05988         // UHF-Reader
05989         case FEDM_ISC_TYPE_ISCMRU200:
05990         case FEDM_ISC_TYPE_ISCLRU1002:
05991         case FEDM_ISC_TYPE_ISCLRU2000:
05992         case FEDM_ISC_TYPE_ISCLRU3000:
05993                 FEDM_CHK7(iBack, SetData(FEDM_ISC_TMP_READER_INFO_MODE, (unsigned char)0x03));
05994                 FEDM_CHK7(iBack, SendProtocol(0x66));
05995                 if(iBack==0x00 || iBack==0x84 || iBack==0xF1)
05996                 {
05997                         switch(m_ReaderInfo.ucReaderType)       // reader type
05998                         {
05999                         // megalock C
06000                         case FEDM_ISC_TYPE_MLC_COM:
06001                         // classic-pro
06002                         case FEDM_ISC_TYPE_CPR20_XX:
06003                         case FEDM_ISC_TYPE_CPR40_XX_U:
06004                         case FEDM_ISC_TYPE_CPR40_XX:
06005                         case FEDM_ISC_TYPE_CPR44_XX:
06006                         case FEDM_ISC_TYPE_CPR46_XX:
06007                         case FEDM_ISC_TYPE_CPR47_XX:
06008                         // myAXXESS
06009                         //case FEDM_ISC_TYPE_MAX_ONTOP:
06010                                 FEDM_CHK7(iBack, GetData(FEDM_ISC_TMP_READER_INFO, &m_ReaderInfo.ucDecoderType[0], 6));
06011                                 m_ReaderInfo.bIsMode0x03Read = true;
06012                                 break;
06013 
06014                         // HF-Reader
06015                         case FEDM_ISC_TYPE_ISCLR2000:
06016                         // myAXXESS
06017                         case FEDM_ISC_TYPE_MAXU1002:
06018                         // UHF-Reader
06019                         case FEDM_ISC_TYPE_ISCMRU200:
06020                         case FEDM_ISC_TYPE_ISCLRU1002:
06021                         case FEDM_ISC_TYPE_ISCLRU2000:
06022                         case FEDM_ISC_TYPE_ISCLRU3000:
06023                                 FEDM_CHK7(iBack, GetData(FEDM_ISC_TMP_READER_INFO, &m_ReaderInfo.ucFpgaSwVer[0], 4));
06024                                 m_ReaderInfo.bIsMode0x03Read = true;
06025                                 break;
06026                         }
06027                 }
06028                 break;
06029         }
06030 
06031 
06032         // ####################################################################################
06033         // mode: 0x04 - special firmware information
06034         // ####################################################################################
06035         switch(m_ReaderInfo.ucReaderType)       // reader type
06036         {
06037         // LF classic types
06038         case 20: // ID RW40.30
06039         // megalock C
06040         case FEDM_ISC_TYPE_MLC_COM:
06041         // classic-pro
06042         case FEDM_ISC_TYPE_CPRM02:
06043         case FEDM_ISC_TYPE_CPR02:
06044         case FEDM_ISC_TYPE_CPR04_U:
06045                 FEDM_CHK7(iBack, SetData(FEDM_ISC_TMP_READER_INFO_MODE, (unsigned char)0x04));
06046                 FEDM_CHK7(iBack, SendProtocol(0x66));
06047                 if(iBack==0x00 || iBack==0x84 || iBack==0xF1)
06048                 {
06049                         FEDM_CHK7(iBack, GetData(FEDM_ISC_TMP_READER_INFO, &m_ReaderInfo.ucCprFctTemplate, 2));
06050                         m_ReaderInfo.bIsMode0x04Read = true;
06051                 }
06052                 break;
06053 
06054         case FEDM_ISC_TYPE_CPR20_XX:
06055         case FEDM_ISC_TYPE_CPR30_XX:
06056         case FEDM_ISC_TYPE_CPR40_XX_U:
06057         case FEDM_ISC_TYPE_CPR40_XX:
06058         case FEDM_ISC_TYPE_CPR44_XX:
06059         case FEDM_ISC_TYPE_CPR46_XX:
06060         case FEDM_ISC_TYPE_CPR47_XX:
06061         case FEDM_ISC_TYPE_CPR50_XX:
06062         case FEDM_ISC_TYPE_CPR52_XX:
06063         case FEDM_ISC_TYPE_CPR60_XX:
06064         // myAXXESS
06065         case FEDM_ISC_TYPE_MAX50_XX:
06066         case FEDM_ISC_TYPE_MAX_STANDARD:
06067         case FEDM_ISC_TYPE_MAX_COMFORT:
06068         case FEDM_ISC_TYPE_MAX_ONTOP:
06069                 FEDM_CHK7(iBack, SetData(FEDM_ISC_TMP_READER_INFO_MODE, (unsigned char)0x04));
06070                 FEDM_CHK7(iBack, SendProtocol(0x66));
06071                 if(iBack==0x00 || iBack==0x84 || iBack==0xF1)
06072                 {
06073                         FEDM_CHK7(iBack, GetData(FEDM_ISC_TMP_READER_INFO, &m_ReaderInfo.ucCprFctTemplate, 11));
06074                         m_ReaderInfo.bIsMode0x04Read = true;
06075                 }
06076                 break;
06077 
06078         // HF-Reader
06079         case FEDM_ISC_TYPE_ISCPRH200:
06080         case FEDM_ISC_TYPE_ISCLR2000:
06081         case FEDM_ISC_TYPE_ISCLR2500_A:
06082         case FEDM_ISC_TYPE_ISCLR2500_B:
06083         case FEDM_ISC_TYPE_ISCLR1002:
06084         // myAXXESS
06085         case FEDM_ISC_TYPE_MAXU1002:
06086         // UHF-Reader
06087         case FEDM_ISC_TYPE_ISCMU02:
06088         case FEDM_ISC_TYPE_ISCLRU1002:
06089         case FEDM_ISC_TYPE_ISCLRU2000:
06090         case FEDM_ISC_TYPE_ISCLRU3000:
06091                 FEDM_CHK7(iBack, SetData(FEDM_ISC_TMP_READER_INFO_MODE, (unsigned char)0x04));
06092                 FEDM_CHK7(iBack, SendProtocol(0x66));
06093                 if(iBack==0x00 || iBack==0x84 || iBack==0xF1)
06094                 {
06095                         FEDM_CHK7(iBack, GetData(FEDM_ISC_TMP_READER_INFO, &m_ReaderInfo.ucReserved1, 11));
06096                         m_ReaderInfo.bIsMode0x04Read = true;
06097                 }
06098                 break;
06099         }
06100 
06101 
06102         // ####################################################################################
06103         // mode: 0x05 - Bootloader firmware version
06104         // ####################################################################################
06105         switch(m_ReaderInfo.ucReaderType)       // reader type
06106         {
06107         // LF classic types
06108         case 20: // ID RW40.30
06109         // megalock C
06110         case FEDM_ISC_TYPE_MLC_COM:
06111         // classic-pro
06112         case FEDM_ISC_TYPE_CPR20_XX:
06113         case FEDM_ISC_TYPE_CPR30_XX:
06114         case FEDM_ISC_TYPE_CPR40_XX_U:
06115         case FEDM_ISC_TYPE_CPR40_XX:
06116         case FEDM_ISC_TYPE_CPR44_XX:
06117         case FEDM_ISC_TYPE_CPR46_XX:
06118         case FEDM_ISC_TYPE_CPR47_XX:
06119         case FEDM_ISC_TYPE_CPR52_XX:
06120         case FEDM_ISC_TYPE_CPR60_XX:
06121         // myAXXESS
06122         case FEDM_ISC_TYPE_MAX50_XX:
06123         case FEDM_ISC_TYPE_MAX_STANDARD:
06124         case FEDM_ISC_TYPE_MAX_COMFORT:
06125         case FEDM_ISC_TYPE_MAX_ONTOP:
06126         case FEDM_ISC_TYPE_MAXU1002:
06127         // Dual-Frequency Reader
06128         case FEDM_ISC_TYPE_ISCPRHD102:
06129         // HF-Reader
06130         case FEDM_ISC_TYPE_ISCMR102:
06131         case FEDM_ISC_TYPE_ISCMR10X:
06132         case FEDM_ISC_TYPE_ISCPRH102:
06133         case FEDM_ISC_TYPE_ISCPRH200:
06134         case FEDM_ISC_TYPE_ISCLR1002:
06135         case FEDM_ISC_TYPE_ISCLR2000:
06136         case FEDM_ISC_TYPE_ISCLR2500_B:
06137         // UHF-Reader
06138         case FEDM_ISC_TYPE_ISCMRU200:
06139         case FEDM_ISC_TYPE_ISCLRU1002:
06140         case FEDM_ISC_TYPE_ISCLRU1000:
06141         case FEDM_ISC_TYPE_ISCLRU2000:
06142                 FEDM_CHK7(iBack, SetData(FEDM_ISC_TMP_READER_INFO_MODE, (unsigned char)0x05));
06143                 FEDM_CHK7(iBack, SendProtocol(0x66));
06144                 if(iBack==0x00 || iBack==0x84 || iBack==0xF1)
06145                 {
06146                         FEDM_CHK7(iBack, GetData(FEDM_ISC_TMP_READER_INFO, &m_ReaderInfo.ucBootSwVer[0], 2));
06147                         m_ReaderInfo.bIsMode0x05Read = true;
06148                 }
06149                 break;
06150         }
06151 
06152 
06153         // ####################################################################################
06154         // mode: 0x06 - keyboard unit firmware version
06155         // ####################################################################################
06156         switch(m_ReaderInfo.ucReaderType)       // reader type
06157         {
06158         // classic-pro
06159         case FEDM_ISC_TYPE_CPR50_XX:
06160         // myAXXESS
06161         case FEDM_ISC_TYPE_MAX50_XX:
06162                 FEDM_CHK7(iBack, SetData(FEDM_ISC_TMP_READER_INFO_MODE, (unsigned char)0x06));
06163                 FEDM_CHK7(iBack, SendProtocol(0x66));
06164                 if(iBack==0x00)
06165                 {
06166                         FEDM_CHK7(iBack, GetData(FEDM_ISC_TMP_READER_INFO, &m_ReaderInfo.ucKeybStatus[0], 8));
06167                         m_ReaderInfo.bIsMode0x06Read = true;
06168                 }
06169                 break;
06170         }
06171 
06172 
06173         // ####################################################################################
06174         // mode: 0x07 - CPRIO unit firmware version and IO information
06175         // ####################################################################################
06176         switch(m_ReaderInfo.ucReaderType)       // reader type
06177         {
06178         // classic-pro
06179         case FEDM_ISC_TYPE_CPR50_XX:
06180         // myAXXESS
06181         case FEDM_ISC_TYPE_MAX50_XX:
06182                 FEDM_CHK7(iBack, SetData(FEDM_ISC_TMP_READER_INFO_MODE, (unsigned char)0x07));
06183                 FEDM_CHK7(iBack, SendProtocol(0x66));
06184                 if(iBack==0x00)
06185                 {
06186                         FEDM_CHK7(iBack, GetData(FEDM_ISC_TMP_READER_INFO, &m_ReaderInfo.ucCprioSwVer[0], 7));
06187                         m_ReaderInfo.bIsMode0x07Read = true;
06188                 }
06189                 break;
06190         }
06191 
06192 
06193         // ####################################################################################
06194         // mode: 0x08 - information with supported tag drivers
06195         // ####################################################################################
06196         switch(m_ReaderInfo.ucReaderType)       // reader type
06197         {
06198         // classic-pro
06199         case FEDM_ISC_TYPE_CPR46_XX:
06200         case FEDM_ISC_TYPE_CPR47_XX:
06201         // myAXXESS
06202         case FEDM_ISC_TYPE_MAX_ONTOP:
06203                 FEDM_CHK7(iBack, SetData(FEDM_ISC_TMP_READER_INFO_MODE, (unsigned char)0x08));
06204                 FEDM_CHK7(iBack, SendProtocol(0x66));
06205                 if(iBack==0x00)
06206                 {
06207                         FEDM_CHK7(iBack, GetData(FEDM_ISC_TMP_READER_INFO, &m_ReaderInfo.ucRfcSupportedTagDriver[0], 14));
06208                         m_ReaderInfo.bIsMode0x08Read = true;
06209                 }
06210                 break;
06211         }
06212 
06213 
06214         // ####################################################################################
06215         // mode: 0x09 - information with WLAN-Modul firmware
06216         // ####################################################################################
06217         switch(m_ReaderInfo.ucReaderType)       // reader type
06218         {
06219         // i-scan HF
06220         case FEDM_ISC_TYPE_ISCPRH200:
06221                 FEDM_CHK7(iBack, SetData(FEDM_ISC_TMP_READER_INFO_MODE, (unsigned char)0x09));
06222                 FEDM_CHK7(iBack, SendProtocol(0x66));
06223                 if(iBack==0x00)
06224                 {
06225                         FEDM_CHK7(iBack, GetData(FEDM_ISC_TMP_READER_INFO, &m_ReaderInfo.ucWlanVer[0], 14));
06226                         m_ReaderInfo.bIsMode0x09Read = true;
06227                 }
06228                 break;
06229         }
06230 
06231 
06232         // ####################################################################################
06233         // mode: 0x10 - additional hardware information
06234         // ####################################################################################
06235         switch(m_ReaderInfo.ucReaderType)       // reader type
06236         {
06237         // megalock C
06238         case FEDM_ISC_TYPE_MLC_COM:
06239         // classic-pro
06240         case FEDM_ISC_TYPE_CPR50_XX:
06241         case FEDM_ISC_TYPE_CPR52_XX:
06242         case FEDM_ISC_TYPE_CPR60_XX:
06243         // myAXXESS
06244         case FEDM_ISC_TYPE_MAX50_XX:
06245         case FEDM_ISC_TYPE_MAX_ONTOP:
06246         case FEDM_ISC_TYPE_MAXU1002:
06247         // UHF-Reader
06248         case FEDM_ISC_TYPE_ISCMU02:
06249         case FEDM_ISC_TYPE_ISCMRU102:
06250         case FEDM_ISC_TYPE_ISCLRU1002:
06251         case FEDM_ISC_TYPE_ISCLRU3000:
06252         // Dual-Frequency Reader
06253         case FEDM_ISC_TYPE_ISCPRHD102:
06254                 FEDM_CHK7(iBack, SetData(FEDM_ISC_TMP_READER_INFO_MODE, (unsigned char)0x10));
06255                 FEDM_CHK7(iBack, SendProtocol(0x66));
06256                 if(iBack==0x00 || iBack==0x84 || iBack==0xF1)
06257                 {
06258                         FEDM_CHK7(iBack, GetData(FEDM_ISC_TMP_READER_INFO, &m_ReaderInfo.ucRfcHwInfo[0], 11));
06259                         m_ReaderInfo.bIsMode0x10Read    = true;
06260 
06261                         m_ReaderInfo.bIsRfcFrequency    = true;
06262                 }
06263                 break;
06264 
06265         // HF-Reader
06266         case FEDM_ISC_TYPE_ISCMR102:
06267         case FEDM_ISC_TYPE_ISCPRH102:
06268         case FEDM_ISC_TYPE_ISCPRH200:
06269         case FEDM_ISC_TYPE_ISCMR10X:
06270         case FEDM_ISC_TYPE_ISCLR1002:
06271         case FEDM_ISC_TYPE_ISCLR2000:
06272         case FEDM_ISC_TYPE_ISCLR2500_A:
06273         case FEDM_ISC_TYPE_ISCLR2500_B:
06274                 FEDM_CHK7(iBack, SetData(FEDM_ISC_TMP_READER_INFO_MODE, (unsigned char)0x10));
06275                 FEDM_CHK7(iBack, SendProtocol(0x66));
06276                 if(iBack==0x00 || iBack==0x84 || iBack==0xF1)
06277                 {
06278                         FEDM_CHK7(iBack, GetData(FEDM_ISC_TMP_READER_INFO, &m_ReaderInfo.ucRfcHwInfo[0], 11));
06279                         m_ReaderInfo.bIsMode0x10Read = true;
06280                 }
06281                 break;
06282 
06283         // UHF-Reader
06284         case FEDM_ISC_TYPE_ISCMRU200:
06285                 FEDM_CHK7(iBack, SetData(FEDM_ISC_TMP_READER_INFO_MODE, (unsigned char)0x10));
06286                 FEDM_CHK7(iBack, SendProtocol(0x66));
06287                 if(iBack==0x00 || iBack==0x84 || iBack==0xF1)
06288                 {
06289                         FEDM_CHK7(iBack, GetData(FEDM_ISC_TMP_READER_INFO, &m_ReaderInfo.ucRfcHwInfo[0], 11));
06290                         m_ReaderInfo.bIsMode0x10Read = true;
06291 
06292                         m_ReaderInfo.ucRfcFrequency     = (m_ReaderInfo.ucRfcHwInfo[1] & 0x01) + 1;     // 0: EU; 1: FCC
06293                         m_ReaderInfo.bIsRfcFrequency    = true;
06294                 }
06295                 break;
06296         
06297         // UHF-Reader
06298         case FEDM_ISC_TYPE_ISCLRU1000:
06299                 FEDM_CHK7(iBack, SetData(FEDM_ISC_TMP_READER_INFO_MODE, (unsigned char)0x10));
06300                 FEDM_CHK7(iBack, SendProtocol(0x66));
06301                 if(iBack==0x00 || iBack==0x84 || iBack==0xF1)
06302                 {
06303                         FEDM_CHK7(iBack, GetData(FEDM_ISC_TMP_READER_INFO, &m_ReaderInfo.ucRfcHwInfo[0], 11));
06304                         m_ReaderInfo.bIsMode0x10Read = true;
06305                 }
06306                 break;
06307 
06308         // UHF-Reader
06309         case FEDM_ISC_TYPE_ISCLRU2000:
06310                 FEDM_CHK7(iBack, SetData(FEDM_ISC_TMP_READER_INFO_MODE, (unsigned char)0x10));
06311                 FEDM_CHK7(iBack, SendProtocol(0x66));
06312                 if(iBack==0x00 || iBack==0x84 || iBack==0xF1)
06313                 {
06314                         FEDM_CHK7(iBack, GetData(FEDM_ISC_TMP_READER_INFO, &m_ReaderInfo.ucRfcHwInfo[0], 11));
06315                         m_ReaderInfo.bIsMode0x10Read = true;
06316 
06317                         if(m_ReaderInfo.ucRfcSwVer[0] >= 2)
06318                                 m_ReaderInfo.bIsRfcFrequency = true; // beginning with Release 2.0.0
06319                                                                                                          // LRU2000 is compatible with standard
06320                 }
06321                 break;
06322 
06323         }
06324 
06325 
06326         // ####################################################################################
06327         // mode: 0x11 - SAM information
06328         // ####################################################################################
06329         switch(m_ReaderInfo.ucReaderType)       // reader type
06330         {
06331         // classic-pro
06332         case FEDM_ISC_TYPE_CPR40_XX_U:
06333         case FEDM_ISC_TYPE_CPR40_XX:
06334         case FEDM_ISC_TYPE_CPR44_XX:
06335         case FEDM_ISC_TYPE_CPR46_XX:
06336         case FEDM_ISC_TYPE_CPR47_XX:
06337         case FEDM_ISC_TYPE_CPR52_XX:
06338         case FEDM_ISC_TYPE_CPR60_XX:
06339         // myAXXESS
06340         case FEDM_ISC_TYPE_MAX_STANDARD:
06341         case FEDM_ISC_TYPE_MAX_COMFORT:
06342         case FEDM_ISC_TYPE_MAX_ONTOP:
06343                 FEDM_CHK7(iBack, SetData(FEDM_ISC_TMP_READER_INFO_MODE, (unsigned char)0x11));
06344                 FEDM_CHK7(iBack, SendProtocol(0x66));
06345                 if(iBack==0x00 || iBack==0x84 || iBack==0xF1)
06346                 {
06347                         FEDM_CHK7(iBack, GetData(FEDM_ISC_TMP_READER_INFO, &m_ReaderInfo.ucNoOfSlots, 5));
06348                         m_ReaderInfo.bIsMode0x11Read = true;
06349                 }
06350                 break;
06351         }
06352 
06353 
06354         // ####################################################################################
06355         // mode: 0x12 - CPU information
06356         // ####################################################################################
06357         FEDM_CHK7(iBack, SetData(FEDM_ISC_TMP_READER_INFO_MODE, (unsigned char)0x12));
06358         FEDM_CHK7(iBack, SendProtocol(0x66));
06359         if(iBack==0x00 || iBack==0x84 || iBack==0xF1)
06360         {
06361                 FEDM_CHK7(iBack, GetData(FEDM_ISC_TMP_READER_INFO, &m_ReaderInfo.ucRfcCpuManufacturer, 8));
06362                 m_ReaderInfo.bIsMode0x12Read = true;
06363         }
06364 
06365 
06366         // ####################################################################################
06367         // mode: 0x40 - CFG information with read permission
06368         // ####################################################################################
06369         FEDM_CHK7(iBack, SetData(FEDM_ISC_TMP_READER_INFO_MODE, (unsigned char)0x40));
06370         FEDM_CHK7(iBack, SendProtocol(0x66));
06371         if(iBack==0x00 || iBack==0xF1)
06372         {
06373                 iMemAdr = FEDM_GetAdrOfID(FEDM_ISC_TMP_READER_INFO, 32);        // start address in memory
06374                 FEDM_CHK7(iBack, GetData(iMemAdr, &m_ReaderInfo.ucNoOfCfgPages[0], 2, FEDM_TMPDATA_MEM));
06375                 uiPageCount = ((m_ReaderInfo.ucNoOfCfgPages[0]<<8) + m_ReaderInfo.ucNoOfCfgPages[1]) / 8;
06376                 if( ((m_ReaderInfo.ucNoOfCfgPages[0]<<8) + m_ReaderInfo.ucNoOfCfgPages[1]) % 8 )
06377                         uiPageCount++;
06378 
06379                 FEDM_CHK7(iBack, GetData(iMemAdr+2, &m_ReaderInfo.ucCfgReadPermissions[0], uiPageCount, FEDM_TMPDATA_MEM));
06380                 m_ReaderInfo.bIsMode0x40Read = true;
06381         }
06382 
06383 
06384         // ####################################################################################
06385         // mode: 0x41 - CFG information with write permission
06386         // ####################################################################################
06387         FEDM_CHK7(iBack, SetData(FEDM_ISC_TMP_READER_INFO_MODE, (unsigned char)0x41));
06388         FEDM_CHK7(iBack, SendProtocol(0x66));
06389         if(iBack==0x00 || iBack==0xF1)
06390         {
06391                 iMemAdr = FEDM_GetAdrOfID(FEDM_ISC_TMP_READER_INFO, 32);        // start address in memory
06392                 FEDM_CHK7(iBack, GetData(iMemAdr, &m_ReaderInfo.ucNoOfCfgPages[0], 2, FEDM_TMPDATA_MEM));
06393                 uiPageCount = (m_ReaderInfo.ucNoOfCfgPages[0]<<8) + m_ReaderInfo.ucNoOfCfgPages[1];
06394                 if( ((m_ReaderInfo.ucNoOfCfgPages[0]<<8) + m_ReaderInfo.ucNoOfCfgPages[1]) % 8 )
06395                         uiPageCount++;
06396 
06397                 FEDM_CHK7(iBack, GetData(iMemAdr+2, &m_ReaderInfo.ucCfgWritePermissions[0], uiPageCount, FEDM_TMPDATA_MEM));
06398                 m_ReaderInfo.bIsMode0x41Read = true;
06399         }
06400 
06401 
06402         // ####################################################################################
06403         // mode: 0x50 - information with MAC for LAN
06404         // ####################################################################################
06405         FEDM_CHK7(iBack, SetData(FEDM_ISC_TMP_READER_INFO_MODE, (unsigned char)0x50));
06406         FEDM_CHK7(iBack, SendProtocol(0x66));
06407         if(iBack==0x00 || iBack==0xF1)
06408         {
06409                 FEDM_CHK7(iBack, GetData(FEDM_ISC_TMP_READER_INFO, &m_ReaderInfo.ucLanFlags, 7));
06410                 m_ReaderInfo.bIsMode0x50Read = true;
06411         }
06412 
06413 
06414         // ####################################################################################
06415         // mode: 0x51 - information with IP Address for LAN
06416         // ####################################################################################
06417         FEDM_CHK7(iBack, SetData(FEDM_ISC_TMP_READER_INFO_MODE, (unsigned char)0x51));
06418         FEDM_CHK7(iBack, SendProtocol(0x66));
06419         if(iBack==0x00 || iBack==0xF1)
06420         {
06421                 FEDM_CHK7(iBack, GetData(FEDM_ISC_TMP_READER_INFO, ucData, 30));
06422                 m_ReaderInfo.ucLanFlags = ucData[0];
06423                 memcpy(&m_ReaderInfo.ucLanIpV4[0], &ucData[1], 20);
06424                 m_ReaderInfo.bIsMode0x51Read = true;
06425         }
06426 
06427 
06428         // ####################################################################################
06429         // mode: 0x52 - information with Netmask for LAN
06430         // ####################################################################################
06431         FEDM_CHK7(iBack, SetData(FEDM_ISC_TMP_READER_INFO_MODE, (unsigned char)0x52));
06432         FEDM_CHK7(iBack, SendProtocol(0x66));
06433         if(iBack==0x00 || iBack==0xF1)
06434         {
06435                 FEDM_CHK7(iBack, GetData(FEDM_ISC_TMP_READER_INFO, ucData, 30));
06436                 m_ReaderInfo.ucLanFlags = ucData[0];
06437                 memcpy(&m_ReaderInfo.ucLanNetmaskV4[0], &ucData[1], 20);
06438                 m_ReaderInfo.bIsMode0x52Read = true;
06439         }
06440 
06441 
06442         // ####################################################################################
06443         // mode: 0x53 - information with Gateway Address for LAN
06444         // ####################################################################################
06445         FEDM_CHK7(iBack, SetData(FEDM_ISC_TMP_READER_INFO_MODE, (unsigned char)0x53));
06446         FEDM_CHK7(iBack, SendProtocol(0x66));
06447         if(iBack==0x00 || iBack==0xF1)
06448         {
06449                 FEDM_CHK7(iBack, GetData(FEDM_ISC_TMP_READER_INFO, ucData, 30));
06450                 m_ReaderInfo.ucLanFlags = ucData[0];
06451                 memcpy(&m_ReaderInfo.ucLanGatewayV4[0], &ucData[1], 20);
06452                 m_ReaderInfo.bIsMode0x53Read = true;
06453         }
06454 
06455 
06456         // ####################################################################################
06457         // mode: 0x54 - information with MAC for WLAN
06458         // ####################################################################################
06459         FEDM_CHK7(iBack, SetData(FEDM_ISC_TMP_READER_INFO_MODE, (unsigned char)0x54));
06460         FEDM_CHK7(iBack, SendProtocol(0x66));
06461         if(iBack==0x00 || iBack==0xF1)
06462         {
06463                 FEDM_CHK7(iBack, GetData(FEDM_ISC_TMP_READER_INFO, &m_ReaderInfo.ucWlanFlags, 7));
06464                 m_ReaderInfo.bIsMode0x54Read = true;
06465         }
06466 
06467 
06468         // ####################################################################################
06469         // mode: 0x55 - information with IP Address for WLAN
06470         // ####################################################################################
06471         FEDM_CHK7(iBack, SetData(FEDM_ISC_TMP_READER_INFO_MODE, (unsigned char)0x55));
06472         FEDM_CHK7(iBack, SendProtocol(0x66));
06473         if(iBack==0x00 || iBack==0xF1)
06474         {
06475                 FEDM_CHK7(iBack, GetData(FEDM_ISC_TMP_READER_INFO, ucData, 30));
06476                 m_ReaderInfo.ucWlanFlags = ucData[0];
06477                 memcpy(&m_ReaderInfo.ucWlanIpV4[0], &ucData[1], 20);
06478                 m_ReaderInfo.bIsMode0x55Read = true;
06479         }
06480 
06481 
06482         // ####################################################################################
06483         // mode: 0x56 - information with Netmask for WLAN
06484         // ####################################################################################
06485         FEDM_CHK7(iBack, SetData(FEDM_ISC_TMP_READER_INFO_MODE, (unsigned char)0x56));
06486         FEDM_CHK7(iBack, SendProtocol(0x66));
06487         if(iBack==0x00 || iBack==0xF1)
06488         {
06489                 FEDM_CHK7(iBack, GetData(FEDM_ISC_TMP_READER_INFO, ucData, 30));
06490                 m_ReaderInfo.ucWlanFlags = ucData[0];
06491                 memcpy(&m_ReaderInfo.ucWlanNetmaskV4[0], &ucData[1], 20);
06492                 m_ReaderInfo.bIsMode0x56Read = true;
06493         }
06494 
06495 
06496         // ####################################################################################
06497         // mode: 0x57 - information with Gateway Address for WLAN
06498         // ####################################################################################
06499         FEDM_CHK7(iBack, SetData(FEDM_ISC_TMP_READER_INFO_MODE, (unsigned char)0x57));
06500         FEDM_CHK7(iBack, SendProtocol(0x66));
06501         if(iBack==0x00 || iBack==0xF1)
06502         {
06503                 FEDM_CHK7(iBack, GetData(FEDM_ISC_TMP_READER_INFO, ucData, 30));
06504                 m_ReaderInfo.ucWlanFlags = ucData[0];
06505                 memcpy(&m_ReaderInfo.ucWlanGatewayV4[0], &ucData[1], 20);
06506                 m_ReaderInfo.bIsMode0x57Read = true;
06507         }
06508 
06509 
06510         // ####################################################################################
06511         // mode: 0x60 - input/output capabilities information
06512         // ####################################################################################
06513         FEDM_CHK7(iBack, SetData(FEDM_ISC_TMP_READER_INFO_MODE, (unsigned char)0x60));
06514         FEDM_CHK7(iBack, SendProtocol(0x66));
06515         if(iBack==0x00 || iBack==0xF1)
06516         {
06517                 FEDM_CHK7(iBack, GetData(FEDM_ISC_TMP_READER_INFO, &m_ReaderInfo.ucNoOfInputs, 3));
06518                 m_ReaderInfo.bIsMode0x60Read = true;
06519         }
06520 
06521 
06522         // ####################################################################################
06523         // mode: 0x61 - external peripheral devices information
06524         // ####################################################################################
06525         switch(m_ReaderInfo.ucReaderType)       // reader type
06526         {
06527         // classic-pro
06528         case FEDM_ISC_TYPE_ISCLR2000:
06529         case FEDM_ISC_TYPE_ISCLR2500_A:
06530         case FEDM_ISC_TYPE_ISCLR2500_B:
06531                 FEDM_CHK7(iBack, SetData(FEDM_ISC_TMP_READER_INFO_MODE, (unsigned char)0x61));
06532                 FEDM_CHK7(iBack, SendProtocol(0x66));
06533                 if(iBack==0x00 || iBack==0xF1)
06534                 {
06535                         FEDM_CHK7(iBack, GetData(FEDM_ISC_TMP_READER_INFO, &m_ReaderInfo.ucNoOfPeripheralDevices, 7));
06536                         m_ReaderInfo.bIsMode0x61Read = true;
06537 #if !defined(_FEDM_NO_PD_SUPPORT)
06538                         FEDM_TRACE(m_pLogger, FELOGMNG_DBG_INFO, __FUNCTION__ << " - " << m_ReaderInfo.ucNoOfPeripheralDevices << " People-Counter detected");
06539                         BuildPDMap();
06540 #endif
06541                 }
06542                 break;
06543         }
06544 
06545 
06546         // ####################################################################################
06547         // mode: 0x80 - device information with serial number and licensed options
06548         // ####################################################################################
06549         FEDM_CHK7(iBack, SetData(FEDM_ISC_TMP_READER_INFO_MODE, (unsigned char)0x80));
06550         FEDM_CHK7(iBack, SendProtocol(0x66));
06551         if(iBack==0x00 || iBack==0x84 || iBack==0xF1)
06552         {
06553                 FEDM_CHK7(iBack, GetData(FEDM_ISC_TMP_READER_INFO, &m_ReaderInfo.ucRfcDevID[0], 18));
06554                 m_ReaderInfo.bIsMode0x80Read = true;
06555                 FEDM_SETPROP2(m_pLogger, FELOGMNG_PROP_DEVICED_ID, m_ReaderInfo.GetDeviceID());
06556         }
06557 
06558 
06559         // ####################################################################################
06560         // frequency information (EU, FCC) for older reader types
06561         // ####################################################################################
06562         switch(m_ReaderInfo.ucReaderType)       // reader type
06563         {
06564         // UHF-Reader
06565         case FEDM_ISC_TYPE_ISCLRU1000:
06566         case FEDM_ISC_TYPE_ISCLRU2000:
06567                 FEDM_CHK7(iBack, FEISC_0x80_ReadConfBlock(      GetReaderHnd(),
06568                                                                                                         GetBusAddress(), 
06569                                                                                                         0x43,
06570                                                                                                         ucData,
06571                                                                                                         0 ));
06572 
06573                 if(iBack==0x00 || iBack==0x18 || iBack==0x84)
06574                 {
06575                         m_ReaderInfo.ucRfcFrequency             = ucData[5];    // 1: EU; 2: FCC
06576                         m_ReaderInfo.bIsRfcFrequency    = true;
06577                 }
06578 
06579                 break;
06580         }
06581 
06582         SetLastError(FEDM_OK);
06583         return &m_ReaderInfo;
06584 }
06585 
06586 /***************************************************************************
06587   Begin                 :       09.12.2007 / M. Hultsch
06588 
06589   Version               :       04.06.01 / 03.03.2014 / M. Hultsch
06590                                                 - support for new mode 0x07
06591 
06592                                                 04.04.00 / 06.12.2012 / M. Hultsch
06593                                                 - support for new mode 0x21
06594 
06595                                                 03.03.00 / 25.01.2011 / M. Hultsch
06596 
06597   Function                      :       gets readers complete diagnostic information from reader
06598                                                 >> partial read is possible <<
06599 
06600   Parameters            :       -
06601 
06602   Return value          :       FEDM_ISC_READER_DIAGNOSTIC*     - pointer to diagnostic structure
06603                                                 or
06604                                                 NULL in error case
06605 ***************************************************************************/
06606 FEDM_ISC_READER_DIAGNOSTIC* FEDM_ISCReaderModule::ReadReaderDiagnostic()
06607 {
06608         FEDM_TRACE(m_pLogger, FELOGMNG_DBG_FUNCTION_CALL | FELOGMNG_DBG_LF_COMM_HIGH_LEVEL, __FUNCTION__);
06609 
06610         unsigned char ucTmp = 0;
06611         int iBack = 0;
06612 
06613         m_ReaderDiagnostic.Init();
06614 
06615         switch(this->m_uiReaderType)
06616         {
06617         // reader having not [0x6E] command
06618         case FEDM_ISC_TYPE_ANT_DAT:
06619         case FEDM_ISC_TYPE_ANT_UMUX:
06620         case FEDM_ISC_TYPE_CPRM02:
06621         case FEDM_ISC_TYPE_CPR02:
06622         case FEDM_ISC_TYPE_CPR20_XX:
06623         case FEDM_ISC_TYPE_CPR40_XX_U:
06624         case FEDM_ISC_TYPE_CPR40_XX:
06625         case FEDM_ISC_TYPE_CPR50_XX:
06626         case FEDM_ISC_TYPE_CPR44_XX:
06627         case FEDM_ISC_TYPE_CPR46_XX:
06628         case FEDM_ISC_TYPE_CPR47_XX:
06629         case FEDM_ISC_TYPE_CPR30_XX:
06630         case FEDM_ISC_TYPE_CPR52_XX:
06631         case FEDM_ISC_TYPE_CPR60_XX:
06632         case FEDM_ISC_TYPE_CPR04_U:
06633         case FEDM_ISC_TYPE_MAX_STANDARD:
06634         case FEDM_ISC_TYPE_MAX_COMFORT:
06635                 SetLastError(FEDM_ERROR_UNSUPPORTED);
06636                 return &m_ReaderDiagnostic;
06637         }
06638 
06639 
06640         // ####################################################################################
06641         // try to get all
06642         // mode: 0xFF - all
06643         // ####################################################################################
06644         FEDM_CHK7(iBack, SetData(FEDM_ISC_TMP_DIAG_MODE, (unsigned char)0xFF));
06645         FEDM_CHK7(iBack, SendProtocol(0x6E));
06646         if(iBack==0x00 || iBack==0x84 || iBack==0xF1)
06647         {
06648                 if(m_uiReaderType == FEDM_ISC_TYPE_ISCLR2500_B)
06649                 {
06650                         if(!m_ReaderDiagnostic.bIsMode0x08Read)
06651                         {
06652                                 // this case is applied, if the Reader returns NOT the diagnostic data for mode 0x08 when requested with mode 0xFF (all)
06653                                 SetData(FEDM_ISC_TMP_DIAG_MODE, (unsigned char)0x08);
06654                                 SendProtocol(0x6E);
06655                         }
06656                 }
06657                 SetLastError(FEDM_OK);
06658                 return &m_ReaderDiagnostic;
06659         }
06660 
06661 
06662         // ####################################################################################
06663         // mode: 0x01 - General RF Status
06664         // ####################################################################################
06665         FEDM_CHK7(iBack, SetData(FEDM_ISC_TMP_DIAG_MODE, (unsigned char)0x01));
06666         FEDM_CHK7(iBack, SendProtocol(0x6E));
06667         if(iBack==0x00 || iBack==0x84)
06668         {
06669                 FEDM_CHK7(iBack, GetData(FEDM_ISC_TMP_DIAG_DATA, &m_ReaderDiagnostic.ucFlagsA, 2));
06670                 m_ReaderDiagnostic.bIsMode0x01Read = true;
06671         }
06672 
06673 
06674         // ####################################################################################
06675         // mode: 0x02 - RF Power Amplifier Status
06676         // ####################################################################################
06677         FEDM_CHK7(iBack, SetData(FEDM_ISC_TMP_DIAG_MODE, (unsigned char)0x02));
06678         FEDM_CHK7(iBack, SendProtocol(0x6E));
06679         if(iBack==0x00 || iBack==0x84)
06680         {
06681                 FEDM_CHK7(iBack, GetData(FEDM_ISC_TMP_DIAG_DATA, &m_ReaderDiagnostic.ucRfPower, 3));
06682                 if(this->m_uiReaderType == FEDM_ISC_TYPE_ISCMR200)
06683                 {
06684                         // swap byte 0 and 1 to build Impedance value
06685                         ucTmp = m_ReaderDiagnostic.ucRfPower;
06686                         m_ReaderDiagnostic.ucRfPower = m_ReaderDiagnostic.ucRfModulation;
06687                         m_ReaderDiagnostic.ucRfModulation = ucTmp;
06688                 }
06689                 m_ReaderDiagnostic.bIsMode0x02Read = true;
06690         }
06691 
06692 
06693         // ####################################################################################
06694         // mode: 0x03 - Multiplexer Status
06695         // ####################################################################################
06696         FEDM_CHK7(iBack, SetData(FEDM_ISC_TMP_DIAG_MODE, (unsigned char)0x03));
06697         FEDM_CHK7(iBack, SendProtocol(0x6E));
06698         if(iBack==0x00 || iBack==0x84)
06699         {
06700                 FEDM_CHK7(iBack, GetData(FEDM_ISC_TMP_DIAG_DATA, &m_ReaderDiagnostic.ucMuxStatusCh1, 8));
06701                 m_ReaderDiagnostic.bIsMode0x03Read = true;
06702         }
06703 
06704 
06705         // ####################################################################################
06706         // mode: 0x04 - Hardware and Configuration Status
06707         // ####################################################################################
06708         FEDM_CHK7(iBack, SetData(FEDM_ISC_TMP_DIAG_MODE, (unsigned char)0x04));
06709         FEDM_CHK7(iBack, SendProtocol(0x6E));
06710         if(iBack==0x00 || iBack==0x84)
06711         {
06712                 FEDM_CHK7(iBack, GetData(FEDM_ISC_TMP_DIAG_DATA, &m_ReaderDiagnostic.ucIntErrorA, 2));
06713                 m_ReaderDiagnostic.bIsMode0x04Read = true;
06714         }
06715 
06716 
06717         // ####################################################################################
06718         // mode: 0x05 - Multiplexer Inpedance Status
06719         // ####################################################################################
06720         FEDM_CHK7(iBack, SetData(FEDM_ISC_TMP_DIAG_MODE, (unsigned char)0x05));
06721         FEDM_CHK7(iBack, SendProtocol(0x6E));
06722         if(iBack==0x00 || iBack==0x84)
06723         {
06724                 switch(m_uiReaderType)
06725                 {
06726                 case FEDM_ISC_TYPE_ISCLRU2000:
06727                         FEDM_CHK7(iBack, GetData(FEDM_ISC_TMP_DIAG_DATA, (unsigned char*)&m_ReaderDiagnostic.CNTRL_OUT1.ucMux_PowerAmp, 12));
06728                         m_ReaderDiagnostic.bIsMode0x05Read = true;
06729                         break;
06730 
06731                 case FEDM_ISC_TYPE_ISCLRU3000:
06732                         FEDM_CHK7(iBack, GetData(FEDM_ISC_TMP_DIAG_DATA, (unsigned char*)&m_ReaderDiagnostic.CNTRL_OUT1.ucMux_PowerAmp, 12));
06733                         m_ReaderDiagnostic.bIsMode0x05Read = true;
06734                         break;
06735 
06736                 default:
06737                         FEDM_CHK7(iBack, GetData(FEDM_ISC_TMP_DIAG_DATA, (unsigned char*)&m_ReaderDiagnostic.CNTRL_OUT1.ucMux_PowerAmp, 3));
06738                         m_ReaderDiagnostic.bIsMode0x05Read = true;
06739                         break;
06740                 }
06741         }
06742 
06743 
06744         // ####################################################################################
06745         // mode: 0x06 - MAX Status
06746         // ####################################################################################
06747         if(this->m_uiReaderType == FEDM_ISC_TYPE_MAX50_XX || 
06748                 this->m_uiReaderType == FEDM_ISC_TYPE_MAXU1002)
06749         {
06750                 FEDM_CHK7(iBack, SetData(FEDM_ISC_TMP_DIAG_MODE, (unsigned char)0x06));
06751                 FEDM_CHK7(iBack, SendProtocol(0x6E));
06752                 if(iBack==0x00 || iBack==0x84)
06753                 {
06754                         FEDM_CHK7(iBack, GetData(FEDM_ISC_TMP_DIAG_DATA, (unsigned char*)&m_ReaderDiagnostic.usErrorFlags, 6));
06755                         m_ReaderDiagnostic.bIsMode0x06Read = true;
06756                 }
06757         }
06758 
06759 
06760         // ####################################################################################
06761         // mode: 0x07 - LED Status
06762         // ####################################################################################
06763         if(this->m_uiReaderType == FEDM_ISC_TYPE_ISCPRH200)
06764         {
06765                 FEDM_CHK7(iBack, SetData(FEDM_ISC_TMP_DIAG_MODE, (unsigned char)0x07));
06766                 FEDM_CHK7(iBack, SendProtocol(0x6E));
06767                 if(iBack==0x00 || iBack==0x84)
06768                 {
06769                         FEDM_CHK7(iBack, GetData(FEDM_ISC_TMP_DIAG_DATA, (unsigned char*)&m_ReaderDiagnostic.ucNoOfLEDs, 30));
06770                         m_ReaderDiagnostic.bIsMode0x07Read = true;
06771                 }
06772         }
06773 
06774 
06775         // ####################################################################################
06776         // mode: 0x08 - ID ISC.LR2500-B Antenna Tuning Status
06777         // ####################################################################################
06778         if(this->m_uiReaderType == FEDM_ISC_TYPE_ISCLR2500_B)
06779         {
06780                 FEDM_CHK7(iBack, SetData(FEDM_ISC_TMP_DIAG_MODE, (unsigned char)0x08));
06781                 FEDM_CHK7(iBack, SendProtocol(0x6E));
06782                 if(iBack==0x00 || iBack==0x84)
06783                 {
06784                         FEDM_CHK7(iBack, GetData(FEDM_ISC_TMP_DIAG_DATA, (unsigned char*)&m_ReaderDiagnostic.usRes1, 15));
06785                         m_ReaderDiagnostic.bIsMode0x08Read = true;
06786                 }
06787         }
06788 
06789 
06790         // ####################################################################################
06791         // mode: 0x20 - Firmware Status
06792         // ####################################################################################
06793         FEDM_CHK7(iBack, SetData(FEDM_ISC_TMP_DIAG_MODE, (unsigned char)0x20));
06794         FEDM_CHK7(iBack, SendProtocol(0x6E));
06795         if(iBack==0x00 || iBack==0x84)
06796         {
06797                 FEDM_CHK7(iBack, GetData(FEDM_ISC_TMP_DIAG_DATA, &m_ReaderDiagnostic.ucFirmwareStatus[0], 30));
06798                 m_ReaderDiagnostic.bIsMode0x20Read = true;
06799         }
06800 
06801         // ####################################################################################
06802         // mode: 0x21 - Configuration change status after Firmware Update
06803         // ####################################################################################
06804         if(     this->m_uiReaderType == FEDM_ISC_TYPE_ISCLRU3000 || 
06805                 this->m_uiReaderType == FEDM_ISC_TYPE_ISCLR2500_A)
06806         {
06807                 FEDM_CHK7(iBack, SetData(FEDM_ISC_TMP_DIAG_MODE, (unsigned char)0x21));
06808                 FEDM_CHK7(iBack, SendProtocol(0x6E));
06809                 if(iBack==0x00 || iBack==0x84)
06810                 {
06811                         FEDM_CHK7(iBack, GetData(FEDM_ISC_TMP_DIAG_DATA, &m_ReaderDiagnostic.ucConfigParaChange, 1));
06812                         m_ReaderDiagnostic.bIsMode0x21Read = true;
06813                 }
06814         }
06815 
06816         if( !m_ReaderDiagnostic.bIsMode0x01Read &&
06817                 !m_ReaderDiagnostic.bIsMode0x02Read &&
06818                 !m_ReaderDiagnostic.bIsMode0x03Read &&
06819                 !m_ReaderDiagnostic.bIsMode0x04Read &&
06820                 !m_ReaderDiagnostic.bIsMode0x05Read &&
06821                 !m_ReaderDiagnostic.bIsMode0x06Read &&
06822                 !m_ReaderDiagnostic.bIsMode0x20Read &&
06823                 !m_ReaderDiagnostic.bIsMode0x21Read )
06824         {
06825                 SetLastError(FEDM_ERROR_NO_DATA);
06826         }
06827         else
06828         {
06829                 SetLastError(FEDM_OK);
06830         }
06831 
06832         return &m_ReaderDiagnostic;
06833 }
06834 
06836 // public callback functions
06838 
06839 /***************************************************************************
06840   Begin                 :       21.02.2006 / M. Hultsch
06841 
06842   Version               :       04.02.08 / 13.08.2012 / M. Hultsch
06843                                                 - support for events from People Counter
06844 
06845                                                 04.02.06 / 23.07.2012 / M. Hultsch
06846                                                 - for FEISC_TASKID_FIRST_NEW_TAG: set m_bActiveAsyncTask to false
06847 
06848                                                 02.04.04 / 25.08.2006 / M. Hultsch
06849 
06850   Function                      :       static callback function for invoke from DLL
06851 
06852   Parameters            :       void* pAny                                      - pointer to caller object
06853                                                 int iReaderHnd                          - reader handle (FEISC.DLL)
06854                                                 int iTaskID                                     - task identifier from FEISC_StartAsyncTask(..)
06855                                                 int iError                                      - error code
06856                                                 unsigned char ucCmd                     - reader command
06857                                                 unsigned char* ucRspData        - pointer to response data
06858                                                 int iRspLen                                     - length of response data
06859 
06860   Return value          :       -
06861 ***************************************************************************/
06862 void FEDM_ISCReaderModule::cbsTaskRsp1( void* pAny, 
06863                                                                                 int iReaderHnd, 
06864                                                                                 int iTaskID, 
06865                                                                                 int iError, 
06866                                                                                 unsigned char ucCmd,
06867                                                                                 unsigned char* ucRspData, 
06868                                                                                 int iRspLen )
06869 {
06870         if((FEDM_ISCReaderModule*)pAny == NULL)
06871                 return;
06872 
06873         switch(iTaskID)
06874         {
06875         case FEISC_TASKID_FIRST_NEW_TAG:
06876                 ((FEDM_ISCReaderModule*)pAny)->cbNewTag(iReaderHnd, iTaskID, iError, ucRspData, iRspLen);
06877                 ((FEDM_ISCReaderModule*)pAny)->m_bActiveAsyncTask = false;
06878                 break;
06879 
06880         case FEISC_TASKID_EVERY_NEW_TAG:
06881                 ((FEDM_ISCReaderModule*)pAny)->cbNewTag(iReaderHnd, iTaskID, iError, ucRspData, iRspLen);
06882                 break;
06883 
06884         case FEISC_TASKID_NOTIFICATION:
06885                 switch(ucCmd)
06886                 {
06887                 case 0x22:
06888                         ((FEDM_ISCReaderModule*)pAny)->cbNewNotify(iReaderHnd, iTaskID, iError, ucRspData, iRspLen, "", 0);
06889                         break;
06890                 case 0x6E:
06891                         ((FEDM_ISCReaderModule*)pAny)->cbNewReaderDiagnostic(iReaderHnd, iTaskID, iError, ucRspData, iRspLen, "", 0);
06892                         break;
06893                 case 0x74:
06894                         ((FEDM_ISCReaderModule*)pAny)->cbNewInputEvent(iReaderHnd, iTaskID, iError, ucRspData, iRspLen, "", 0);
06895                         break;
06896                 case 0x77:
06897                         ((FEDM_ISCReaderModule*)pAny)->cbNewNotifyFromPeopleCounter(iReaderHnd, iTaskID, iError, ucRspData, iRspLen, "", 0);
06898                         break;
06899                 }
06900                 break;
06901         }
06902 }
06903 
06904 /***************************************************************************
06905   Begin                 :       25.08.2006 / M. Hultsch
06906 
06907   Version               :       04.02.08 / 13.08.2012 / M. Hultsch
06908                                                 - support for events from People Counter
06909 
06910                                                 02.04.04 / 25.08.2006 / M. Hultsch
06911 
06912   Function                      :       static callback function for invoke from DLL
06913 
06914   Parameters            :       void* pAny                                      - pointer to caller object
06915                                                 int iReaderHnd                          - reader handle (FEISC.DLL)
06916                                                 int iTaskID                                     - task identifier from FEISC_StartAsyncTask(..)
06917                                                 int iError                                      - error code
06918                                                 unsigned char ucCmd             - reader command
06919                                                 unsigned char* ucRspData        - pointer to response data
06920                                                 int iRspLen                                     - length of response data
06921                                                 char* cIPAdr                            - pointer to ip address of reader
06922                                                 int iPortNr                                     - local or remote port number 
06923 
06924   Return value          :       -
06925 ***************************************************************************/
06926 void FEDM_ISCReaderModule::cbsTaskRsp2( void* pAny, 
06927                                                                                 int iReaderHnd, 
06928                                                                                 int iTaskID, 
06929                                                                                 int iError, 
06930                                                                                 unsigned char ucCmd,
06931                                                                                 unsigned char* ucRspData, 
06932                                                                                 int iRspLen,
06933                                                                                 char* cIPAdr,
06934                                                                                 int iPortNr )
06935 {
06936         if((FEDM_ISCReaderModule*)pAny == NULL)
06937                 return;
06938 
06939         switch(iTaskID)
06940         {
06941         case FEISC_TASKID_NOTIFICATION:
06942                 switch(ucCmd)
06943                 {
06944                 case 0x22:
06945                         ((FEDM_ISCReaderModule*)pAny)->cbNewNotify(iReaderHnd, iTaskID, iError, ucRspData, iRspLen, cIPAdr, iPortNr);
06946                         break;
06947                 case 0x6E:
06948                         ((FEDM_ISCReaderModule*)pAny)->cbNewReaderDiagnostic(iReaderHnd, iTaskID, iError, ucRspData, iRspLen, cIPAdr, iPortNr);
06949                         break;
06950                 case 0x74:
06951                         ((FEDM_ISCReaderModule*)pAny)->cbNewInputEvent(iReaderHnd, iTaskID, iError, ucRspData, iRspLen, cIPAdr, iPortNr);
06952                         break;
06953                 case 0x77:
06954                         ((FEDM_ISCReaderModule*)pAny)->cbNewNotifyFromPeopleCounter(iReaderHnd, iTaskID, iError, ucRspData, iRspLen, cIPAdr, iPortNr);
06955                         break;
06956                 }
06957                 break;
06958         }
06959 }
06960 
06961 
06962 
06964 // protected callback functions
06966 
06967 
06968 /***************************************************************************
06969   Begin                 :       21.02.2006 / M. Hultsch
06970 
06971   Version               :       03.09.12 / 24.08.2009 / M. Hultsch
06972                                                 - ResetTable if TaskID = FEDM_TASKID_EVERY_NEW_TAG
06973 
06974                                                 02.05.01 / 11.09.2006 / M. Hultsch
06975 
06976   Function                      :       non-static callback function for invoke from DLL
06977 
06978   Parameters            :       int iReaderHnd                          - reader handle (FEISC.DLL)
06979                                                 int iTaskID                                     - task identifier from FEISC_StartAsyncTask(..)
06980                                                 int iError                                      - error code
06981                                                 unsigned char* ucRspData        - pointer to response data
06982                                                 int iRspLen                                     - length of response data
06983 
06984   Return value          :       -
06985 ***************************************************************************/
06986 void FEDM_ISCReaderModule::cbNewTag(    int iReaderHnd, 
06987                                                                                 int iTaskID, 
06988                                                                                 int iError, 
06989                                                                                 unsigned char* ucRspData, 
06990                                                                                 int iRspLen )
06991 {
06992         unsigned char ucIsoMode = 0;
06993         int iIdx = 0;
06994         int iErr = 0;
06995 
06996 
06997         if(iReaderHnd != GetReaderHnd())
06998                 return;
06999 
07000         SetLastError(iError);
07001 
07002         // first step: save inventory data in table
07003         if( iError==0x00 || 
07004                 iError==0x01 || 
07005                 iError==0x02 || 
07006                 iError==0x03 || 
07007                 iError==0x83 || 
07008                 iError==0x84 || 
07009                 iError==0x90 || 
07010                 iError==0x93 || 
07011                 iError==0x94 || 
07012                 iError==0x95 )
07013         {       
07014                 if(iRspLen > 0)
07015                 {
07016                         FEDM_CHK6(iErr, SetData(FEDM_ISC_TMP_B0_CMD, (unsigned char)0x01));
07017         
07018                         if(iError == 0x01)
07019                         {
07020                                 // if command in selected mode and transponder doesn't respond
07021                                 // then remove selection flag
07022                                 FEDM_CHK6(iErr, GetData(FEDM_ISC_TMP_B0_MODE_ADR, &ucIsoMode));
07023 
07024                                 if(ucIsoMode == FEDM_ISC_ISO_MODE_SEL)
07025                                 {
07026                                         iIdx = FindTableIndex(0, FEDM_ISC_ISO_TABLE, FEDM_ISC_DATA_IS_SELECTED, true);
07027                                         if(iIdx >= 0)
07028                                                 m_ISOTable[iIdx]->m_bIsSelected = false;
07029                                 }
07030                         }
07031                         else if(iError == 0x02) // exception for Inventory
07032                         {
07033                                 if(iTaskID == FEDM_TASKID_EVERY_NEW_TAG)
07034                                         ResetTable(FEDM_ISC_ISO_TABLE);
07035 
07036                                 // save new transponder data in isc-table
07037                                 FEDM_CHK6(iErr, Set_0xB0_IsoTableData(ucRspData, iRspLen, iError));
07038                         }
07039                         else if(iError == 0x95)
07040                         {
07041                                 FEDM_CHK6(iErr, SetData(FEDM_ISC_TMP_LAST_STATE, (unsigned char)iError));
07042                                 FEDM_CHK6(iErr, SetData(FEDM_ISC_TMP_B0_ISO_ERROR, ucRspData[0]));
07043                         }
07044                         else
07045                         {
07046                                 if(iTaskID == FEDM_TASKID_EVERY_NEW_TAG)
07047                                         ResetTable(FEDM_ISC_ISO_TABLE);
07048 
07049                                 // save new transponder data in isc-table
07050                                 FEDM_CHK6(iErr, Set_0xB0_IsoTableData(ucRspData, iRspLen, iError));
07051                         }
07052                 }
07053         }
07054 
07055 
07056         // second step: invoke callback function of application
07057         switch(m_TaskInit.uiFlag)
07058         {
07059         case FEDM_TASKCB1:
07060                 if(m_TaskInit.cbFct1 != NULL)
07061                         m_TaskInit.cbFct1(m_TaskInit.pAny, iError, 0xB0);
07062                 break;
07063 
07064 #ifdef _FEDM_WINDOWS
07065         case FEDM_TASKCB_NET1:
07066                 if(m_TaskInit.cbFctNET1 != NULL)
07067                         m_TaskInit.cbFctNET1(iError, 0x0B);
07068                 break;
07069 #endif
07070         }
07071 }
07072 
07073 
07074 /***************************************************************************
07075   Begin                 :       24.03.2006 / M. Hultsch
07076 
07077   Version               :       02.04.05 / 28.08.2006 / M. Hultsch
07078 
07079   Function                      :       non-static callback function for invoke from DLL
07080 
07081   Parameters            :       int iReaderHnd                          - reader handle (FEISC.DLL)
07082                                                 int iTaskID                                     - task identifier from FEISC_StartAsyncTask(..)
07083                                                 int iError                                      - error code
07084                                                 unsigned char* ucRspData        - pointer to response data
07085                                                 int iRspLen                                     - length of response data
07086                                                 char* cIPAdr                            - pointer to ip address of reader
07087                                                 int iPortNr                                     - local or remote port number 
07088 
07089   Return value          :       -
07090 ***************************************************************************/
07091 void FEDM_ISCReaderModule::cbNewNotify( int iReaderHnd, 
07092                                                                                 int iTaskID, 
07093                                                                                 int iError, 
07094                                                                                 unsigned char* ucRspData, 
07095                                                                                 int iRspLen,
07096                                                                                 char* cIPAdr,
07097                                                                                 int iPortNr )
07098 {
07099         int iErr = 0;
07100         unsigned int uiRecSets = 0;
07101         int iFirstByte = 0;
07102         unsigned int uiIP[4];
07103         unsigned char ucIP[4];
07104 
07105         memset(uiIP, 0, 4*sizeof(unsigned int));
07106         memset (ucIP, 0, 4*sizeof(unsigned char));
07107 
07108         if(iReaderHnd != GetReaderHnd())
07109                 return;
07110 
07111         SetLastError(iError);
07112 
07113         // first step: save notification data in table
07114         if( iError==0x00 || 
07115                 iError==0x83 || 
07116                 iError==0x84 || 
07117                 iError==0x85 || 
07118                 iError==0x90 || 
07119                 iError==0x93 || 
07120                 iError==0x94 )
07121         {       
07122 
07123                 if(iRspLen <= 0)
07124                 {
07125                         // reset BRM-table
07126                         m_uiBRMTableLength = 0;
07127                 }
07128                 else
07129                 {
07130                         FEDM_CHK6(iErr, SetData(FEDM_ISC_TMP_ADV_BRM_TRDATA1,  ucRspData[0]));
07131 
07132                         if(ucRspData[0] & 0x80) // extension flag?
07133                         {
07134                                 FEDM_CHK6(iErr, SetData(FEDM_ISC_TMP_ADV_BRM_TRDATA2,  ucRspData[1]));
07135                                 uiRecSets = (ucRspData[2] << 8) + ucRspData[3];
07136                                 iFirstByte = 4;
07137                         }
07138                         else
07139                         {
07140                                 uiRecSets = (ucRspData[1] << 8) + ucRspData[2];
07141                                 iFirstByte = 3;
07142                         }
07143 
07144 
07145                         FEDM_CHK6(iErr, SetData(FEDM_ISC_TMP_ADV_BRM_RECSETS, uiRecSets));
07146 
07147                         if(uiRecSets == 0)      // no more data
07148                         {
07149                                 // reset BRM-table
07150                                 m_uiBRMTableLength = 0;
07151 
07152                                 return;
07153                         }
07154 
07155                         // save new buffered read mode data in brm-table
07156                         FEDM_CHK6(iErr, SetBrmTableData(0x22, &ucRspData[iFirstByte]));
07157                 }
07158         }
07159         else
07160         {
07161                 // reset BRM-table
07162                 m_uiBRMTableLength = 0;
07163 
07164                 //return;
07165         }
07166 
07167         // second step: invoke callback function of application
07168         switch(m_TaskInit.uiFlag)
07169         {
07170         case FEDM_TASKCB1:
07171                 if(m_TaskInit.cbFct1 != NULL)
07172                         m_TaskInit.cbFct1(m_TaskInit.pAny, iError, 0x22);
07173                 break;
07174 
07175         case FEDM_TASKCB2:
07176                 if(m_TaskInit.cbFct2 != NULL)
07177                 {
07178                         sscanf(cIPAdr, "%u.%u.%u.%u", &uiIP[0], &uiIP[1], &uiIP[2], &uiIP[3]);
07179                         ucIP[0] = (uiIP[0] & 0x000000FF);
07180                         ucIP[1] = (uiIP[1] & 0x000000FF);
07181                         ucIP[2] = (uiIP[2] & 0x000000FF);
07182                         ucIP[3] = (uiIP[3] & 0x000000FF);
07183                         SetData(FEDM_ISC_TMP_NTF_REMOTE_IP_ADR, ucIP, 4);
07184                         SetData(FEDM_ISC_TMP_NTF_IP_PORT_NR, (unsigned int)iPortNr);
07185                         m_TaskInit.cbFct2(m_TaskInit.pAny, iError, 0x22, cIPAdr, iPortNr);
07186                 }
07187                 break;
07188 
07189 #ifdef _FEDM_WINDOWS
07190         case FEDM_TASKCB_NET1:
07191                 if(m_TaskInit.cbFctNET1 != NULL)
07192                 {
07193                         sscanf(cIPAdr, "%u.%u.%u.%u", &uiIP[0], &uiIP[1], &uiIP[2], &uiIP[3]);
07194                         ucIP[0] = (uiIP[0] & 0x000000FF);
07195                         ucIP[1] = (uiIP[1] & 0x000000FF);
07196                         ucIP[2] = (uiIP[2] & 0x000000FF);
07197                         ucIP[3] = (uiIP[3] & 0x000000FF);
07198                         SetData(FEDM_ISC_TMP_NTF_REMOTE_IP_ADR, ucIP, 4);
07199                         SetData(FEDM_ISC_TMP_NTF_IP_PORT_NR, (unsigned int)iPortNr);
07200                         m_TaskInit.cbFctNET1(iError, 0x22);
07201                 }
07202                 break;
07203 #endif
07204         }
07205 }
07206 
07207 
07208 /***************************************************************************
07209   Begin                 :       28.03.2006 / M. Hultsch
07210 
07211   Version               :       04.06.01 / 03.03.2014 / M. Hultsch
07212                                                 - Extension for new response format: [rec_cnt][mode][30 byte data]
07213 
07214                                                 02.04.05 / 28.08.2006 / M. Hultsch
07215 
07216   Function                      :       non-static callback function for invoke from DLL
07217 
07218   Parameters            :       int iReaderHnd                          - reader handle (FEISC.DLL)
07219                                                 int iTaskID                                     - task identifier from FEISC_StartAsyncTask(..)
07220                                                 int iError                                      - error code
07221                                                 unsigned char* ucRspData        - pointer to response data
07222                                                 int iRspLen                                     - length of response data
07223                                                 char* cIPAdr                            - pointer to ip address of reader
07224                                                 int iPortNr                                     - local or remote port number 
07225 
07226   Return value          :       -
07227 ***************************************************************************/
07228 void FEDM_ISCReaderModule::cbNewReaderDiagnostic(       int iReaderHnd, 
07229                                                                                                         int iTaskID, 
07230                                                                                                         int iError, 
07231                                                                                                         unsigned char* ucRspData, 
07232                                                                                                         int iRspLen,
07233                                                                                                         char* cIPAdr,
07234                                                                                                         int iPortNr )
07235 {
07236         unsigned char ucRecCount = 0;
07237         unsigned char ucData[31];
07238         int iErr = 0;
07239         int iAddr = 0;
07240         int iToRead = 0;
07241         unsigned int uiReaderType = 0;
07242         unsigned int uiRecCount = 0;
07243         unsigned int uiIP[4];
07244         unsigned char ucIP[4];
07245 
07246         memset(uiIP, 0, 4*sizeof(unsigned int));
07247         memset (ucIP, 0, 4*sizeof(unsigned char));
07248 
07249 
07250         if(iReaderHnd != GetReaderHnd())
07251                 return;
07252 
07253         SetLastError(iError);
07254 
07255         
07256         // first step: save reader diagnostic data in FEDM_TMPDATA_MEM
07257         if( iError==0x00 || 
07258                 iError==0x84 )
07259         {       
07260                 FEDM_CHK6(iErr, SetData(FEDM_ISC_TMP_0x6E_NTF_RSP_REC_COUNT, (unsigned char)0x00));
07261                 FEDM_CHK6(iErr, SetData(FEDM_ISC_TMP_DIAG_MODE, (unsigned char)0x00));
07262 
07263                 if(iRspLen > 0 && iRspLen < 32)
07264                 {
07265                         memset(ucData, 0, 31);
07266 
07267                         if(iRspLen == 2)
07268                         {
07269                                 // with mode 0x01, we receive 2 bytes
07270                                 memcpy(ucData, ucRspData, 2);
07271 
07272                                 // set reader diagnostic mode 0x01
07273                                 FEDM_CHK6(iErr, SetData(FEDM_ISC_TMP_DIAG_MODE, (unsigned char)0x01));
07274                         }
07275                         else if(iRspLen == 6)
07276                         {
07277                                 // with mode 0x06, we receive 6 bytes
07278                                 memcpy(ucData, ucRspData, 6);
07279 
07280                                 // set reader diagnostic mode 0x06
07281                                 FEDM_CHK6(iErr, SetData(FEDM_ISC_TMP_DIAG_MODE, (unsigned char)0x06));
07282                         }
07283                         else
07284                         {
07285                                 // all other modes
07286 
07287                                 memcpy(ucData, &ucRspData[1], iRspLen-1);
07288 
07289                                 // set reader diagnostic mode from receive protocol
07290                                 FEDM_CHK6(iErr, SetData(FEDM_ISC_TMP_DIAG_MODE, ucRspData[0]));
07291                         }
07292 
07293                         // FEDM_ISC_TMP_DIAG_DATA addresses always 31 bytes
07294                         FEDM_CHK6(iErr, SetData(FEDM_ISC_TMP_DIAG_DATA, ucData, 31));
07295                 }
07296                 else if(iRspLen >= 36)
07297                 {
07298                         // new response format
07299                         FEDM_CHK6(iErr, SetData(FEDM_ISC_TMP_0x6E_NTF_RSP_READER_TYPE, &ucRspData[0], 4));
07300                         FEDM_CHK6(iErr, SetData(FEDM_ISC_TMP_DIAG_MODE, (unsigned char)0xFF));
07301 
07302                         ucRecCount = ucRspData[4];
07303 
07304                         iAddr = FEDM_GetAdrOfID(FEDM_ISC_TMP_0x6E_NTF_RSP_DATA, 32);
07305                         iToRead = iRspLen;
07306 
07307                         for(unsigned char ucCnt=0; ucCnt<ucRecCount; ucCnt++)
07308                         {
07309                                 if(iToRead < 31)
07310                                         break;
07311 
07312                                 memset(ucData, 0, 31);
07313                                 memcpy(ucData, &ucRspData[5+ucCnt*31], 31);
07314 
07315                                 if(iAddr >= FEDM_ISC_MAX_TMPDATA_MEM-31)
07316                                         break;
07317 
07318                                 SetData( iAddr, ucData, 31, FEDM_TMPDATA_MEM );
07319 
07320                                 iAddr += 31;
07321                                 iToRead -= 31;
07322                                 uiRecCount++;
07323                         }
07324                         FEDM_CHK6(iErr, SetData(FEDM_ISC_TMP_0x6E_NTF_RSP_REC_COUNT, uiRecCount));
07325                 }
07326         }
07327 
07328         // second step: invoke callback function of application
07329         switch(m_TaskInit.uiFlag)
07330         {
07331         case FEDM_TASKCB1:
07332                 if(m_TaskInit.cbFct1 != NULL)
07333                         m_TaskInit.cbFct1(m_TaskInit.pAny, iError, 0x6E);
07334                 break;
07335 
07336         case FEDM_TASKCB2:
07337                 if(m_TaskInit.cbFct2 != NULL)
07338                 {
07339                         sscanf(cIPAdr, "%u.%u.%u.%u", &uiIP[0], &uiIP[1], &uiIP[2], &uiIP[3]);
07340                         ucIP[0] = (uiIP[0] & 0x000000FF);
07341                         ucIP[1] = (uiIP[1] & 0x000000FF);
07342                         ucIP[2] = (uiIP[2] & 0x000000FF);
07343                         ucIP[3] = (uiIP[3] & 0x000000FF);
07344                         SetData(FEDM_ISC_TMP_NTF_REMOTE_IP_ADR, ucIP, 4);
07345                         SetData(FEDM_ISC_TMP_NTF_IP_PORT_NR, (unsigned int)iPortNr);
07346                         m_TaskInit.cbFct2(m_TaskInit.pAny, iError, 0x6E, cIPAdr, iPortNr);
07347                 }
07348                 break;
07349 
07350 #ifdef _FEDM_WINDOWS
07351         case FEDM_TASKCB_NET1:
07352                 if(m_TaskInit.cbFctNET1 != NULL)
07353                 {
07354                         sscanf(cIPAdr, "%u.%u.%u.%u", &uiIP[0], &uiIP[1], &uiIP[2], &uiIP[3]);
07355                         ucIP[0] = (uiIP[0] & 0x000000FF);
07356                         ucIP[1] = (uiIP[1] & 0x000000FF);
07357                         ucIP[2] = (uiIP[2] & 0x000000FF);
07358                         ucIP[3] = (uiIP[3] & 0x000000FF);
07359                         SetData(FEDM_ISC_TMP_NTF_REMOTE_IP_ADR, ucIP, 4);
07360                         SetData(FEDM_ISC_TMP_NTF_IP_PORT_NR, (unsigned int)iPortNr);
07361                         m_TaskInit.cbFctNET1(iError, 0x6E);
07362                 }
07363                 break;
07364 #endif
07365         }
07366 }
07367 
07368 
07369 /***************************************************************************
07370   Begin                 :       04.07.2011 / M. Hultsch
07371 
07372   Version               :       03.03.04 / 04.07.2011 / M. Hultsch
07373 
07374   Function                      :       non-static callback function for invoke from DLL
07375 
07376   Parameters            :       int iReaderHnd                          - reader handle (FEISC.DLL)
07377                                                 int iTaskID                                     - task identifier from FEISC_StartAsyncTask(..)
07378                                                 int iError                                      - error code
07379                                                 unsigned char* ucRspData        - pointer to response data
07380                                                 int iRspLen                                     - length of response data
07381                                                 char* cIPAdr                            - pointer to ip address of reader
07382                                                 int iPortNr                                     - local or remote port number 
07383 
07384   Return value          :       -
07385 ***************************************************************************/
07386 void FEDM_ISCReaderModule::cbNewInputEvent(     int iReaderHnd, 
07387                                                                                         int iTaskID, 
07388                                                                                         int iError, 
07389                                                                                         unsigned char* ucRspData, 
07390                                                                                         int iRspLen,
07391                                                                                         char* cIPAdr,
07392                                                                                         int iPortNr )
07393 {
07394         int iErr = 0;
07395         unsigned int uiIP[4];
07396         unsigned char ucIP[4];
07397 
07398         memset(uiIP, 0, 4*sizeof(unsigned int));
07399         memset (ucIP, 0, 4*sizeof(unsigned char));
07400 
07401         if(iReaderHnd != GetReaderHnd())
07402                 return;
07403 
07404         SetLastError(iError);
07405 
07406         // first step: save notification data in table
07407         if( iError==0x00 )
07408         {       
07409 
07410                 if(iRspLen <= 0)
07411                 {
07412                         // reset BRM-table
07413                         m_uiBRMTableLength = 0;
07414                 }
07415                 else
07416                 {
07417                         FEDM_CHK6(iErr, SetData(FEDM_ISC_TMP_ADV_BRM_TRDATA1,  (unsigned char)0x80));
07418                         FEDM_CHK6(iErr, SetData(FEDM_ISC_TMP_ADV_BRM_TRDATA2,  (unsigned char)0x01));
07419                         FEDM_CHK6(iErr, SetData(FEDM_ISC_TMP_ADV_BRM_RECSETS, (unsigned int)1));
07420 
07421                         // save new buffered read mode data in brm-table
07422                         FEDM_CHK6(iErr, SetBrmTableData(0x74, ucRspData));
07423                 }
07424         }
07425         else
07426         {
07427                 // reset BRM-table
07428                 m_uiBRMTableLength = 0;
07429 
07430                 //return;
07431         }
07432 
07433         // second step: invoke callback function of application
07434         switch(m_TaskInit.uiFlag)
07435         {
07436         case FEDM_TASKCB1:
07437                 if(m_TaskInit.cbFct1 != NULL)
07438                         m_TaskInit.cbFct1(m_TaskInit.pAny, iError, 0x22);
07439                 break;
07440 
07441         case FEDM_TASKCB2:
07442                 if(m_TaskInit.cbFct2 != NULL)
07443                 {
07444                         sscanf(cIPAdr, "%u.%u.%u.%u", &uiIP[0], &uiIP[1], &uiIP[2], &uiIP[3]);
07445                         ucIP[0] = (uiIP[0] & 0x000000FF);
07446                         ucIP[1] = (uiIP[1] & 0x000000FF);
07447                         ucIP[2] = (uiIP[2] & 0x000000FF);
07448                         ucIP[3] = (uiIP[3] & 0x000000FF);
07449                         SetData(FEDM_ISC_TMP_NTF_REMOTE_IP_ADR, ucIP, 4);
07450                         SetData(FEDM_ISC_TMP_NTF_IP_PORT_NR, (unsigned int)iPortNr);
07451                         m_TaskInit.cbFct2(m_TaskInit.pAny, iError, 0x22, cIPAdr, iPortNr);
07452                 }
07453                 break;
07454 
07455 #ifdef _FEDM_WINDOWS
07456         case FEDM_TASKCB_NET1:
07457                 if(m_TaskInit.cbFctNET1 != NULL)
07458                 {
07459                         sscanf(cIPAdr, "%u.%u.%u.%u", &uiIP[0], &uiIP[1], &uiIP[2], &uiIP[3]);
07460                         ucIP[0] = (uiIP[0] & 0x000000FF);
07461                         ucIP[1] = (uiIP[1] & 0x000000FF);
07462                         ucIP[2] = (uiIP[2] & 0x000000FF);
07463                         ucIP[3] = (uiIP[3] & 0x000000FF);
07464                         SetData(FEDM_ISC_TMP_NTF_REMOTE_IP_ADR, ucIP, 4);
07465                         SetData(FEDM_ISC_TMP_NTF_IP_PORT_NR, (unsigned int)iPortNr);
07466                         m_TaskInit.cbFctNET1(iError, 0x22);
07467                 }
07468                 break;
07469 #endif
07470         }
07471 }
07472 
07473 /***************************************************************************
07474   Begin                 :       13.08.2012 / M. Hultsch
07475 
07476   Version               :       04.02.08 / 13.08.2012 / M. Hultsch
07477 
07478   Function                      :       non-static callback function for invoke from DLL
07479 
07480   Parameters            :       int iReaderHnd                          - reader handle (FEISC.DLL)
07481                                                 int iTaskID                                     - task identifier from FEISC_StartAsyncTask(..)
07482                                                 int iError                                      - error code
07483                                                 unsigned char* ucRspData        - pointer to response data
07484                                                 int iRspLen                                     - length of response data
07485                                                 char* cIPAdr                            - pointer to ip address of reader
07486                                                 int iPortNr                                     - local or remote port number 
07487 
07488   Return value          :       -
07489 ***************************************************************************/
07490 void FEDM_ISCReaderModule::cbNewNotifyFromPeopleCounter(        int iReaderHnd, 
07491                                                                                                                         int iTaskID, 
07492                                                                                                                         int iError, 
07493                                                                                                                         unsigned char* ucRspData, 
07494                                                                                                                         int iRspLen,
07495                                                                                                                         char* cIPAdr,
07496                                                                                                                         int iPortNr )
07497 {
07498         //unsigned char ucData[13];
07499         //int iErr = 0;
07500         unsigned int uiIP[4];
07501         unsigned char ucIP[4];
07502 
07503         memset(uiIP, 0, 4*sizeof(unsigned int));
07504         memset (ucIP, 0, 4*sizeof(unsigned char));
07505 
07506 
07507         if(iReaderHnd != GetReaderHnd())
07508                 return;
07509 
07510         SetLastError(iError);
07511 
07512         if(iRspLen < 17)
07513                 return;
07514 
07515         
07516         // first step: build counter values
07517         if(iError == 0)
07518         {
07519                 unsigned int uiCnt1 = ucRspData[3] | ucRspData [2] << 8 | ucRspData[1] << 16 | ucRspData[0] << 24;
07520                 unsigned int uiCnt2 = ucRspData[7] | ucRspData [6] << 8 | ucRspData[5] << 16 | ucRspData[4] << 24;
07521                 unsigned int uiCnt3 = ucRspData[11] | ucRspData [10] << 8 | ucRspData[9] << 16 | ucRspData[8] << 24;
07522                 unsigned int uiCnt4 = ucRspData[15] | ucRspData [14] << 8 | ucRspData[13] << 16 | ucRspData[12] << 24;
07523 
07524                 SetData(FEDM_ISC_TMP_77_COUNTER1, uiCnt1);
07525                 SetData(FEDM_ISC_TMP_77_COUNTER2, uiCnt2);
07526                 SetData(FEDM_ISC_TMP_77_COUNTER3, uiCnt3);
07527                 SetData(FEDM_ISC_TMP_77_COUNTER4, uiCnt4);
07528                 SetData(FEDM_ISC_TMP_77_BUS_ADDR, ucRspData[16]);
07529         }
07530 
07531         // second step: invoke callback function of application
07532         switch(m_TaskInit.uiFlag)
07533         {
07534         case FEDM_TASKCB1:
07535                 if(m_TaskInit.cbFct1 != NULL)
07536                         m_TaskInit.cbFct1(m_TaskInit.pAny, iError, 0x77);
07537                 break;
07538 
07539         case FEDM_TASKCB2:
07540                 if(m_TaskInit.cbFct2 != NULL)
07541                 {
07542                         sscanf(cIPAdr, "%u.%u.%u.%u", &uiIP[0], &uiIP[1], &uiIP[2], &uiIP[3]);
07543                         ucIP[0] = (uiIP[0] & 0x000000FF);
07544                         ucIP[1] = (uiIP[1] & 0x000000FF);
07545                         ucIP[2] = (uiIP[2] & 0x000000FF);
07546                         ucIP[3] = (uiIP[3] & 0x000000FF);
07547                         SetData(FEDM_ISC_TMP_NTF_REMOTE_IP_ADR, ucIP, 4);
07548                         SetData(FEDM_ISC_TMP_NTF_IP_PORT_NR, (unsigned int)iPortNr);
07549                         m_TaskInit.cbFct2(m_TaskInit.pAny, iError, 0x77, cIPAdr, iPortNr);
07550                 }
07551                 break;
07552 
07553 #ifdef _FEDM_WINDOWS
07554         case FEDM_TASKCB_NET1:
07555                 if(m_TaskInit.cbFctNET1 != NULL)
07556                 {
07557                         sscanf(cIPAdr, "%u.%u.%u.%u", &uiIP[0], &uiIP[1], &uiIP[2], &uiIP[3]);
07558                         ucIP[0] = (uiIP[0] & 0x000000FF);
07559                         ucIP[1] = (uiIP[1] & 0x000000FF);
07560                         ucIP[2] = (uiIP[2] & 0x000000FF);
07561                         ucIP[3] = (uiIP[3] & 0x000000FF);
07562                         SetData(FEDM_ISC_TMP_NTF_REMOTE_IP_ADR, ucIP, 4);
07563                         SetData(FEDM_ISC_TMP_NTF_IP_PORT_NR, (unsigned int)iPortNr);
07564                         m_TaskInit.cbFctNET1(iError, 0x77);
07565                 }
07566                 break;
07567 #endif
07568         }
07569 }


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