#include /*標準輸入輸出定義*/ #include /*標準函數庫定義*/ #include #include #include "../Config.h" #include "../Log/log.h" #include "../Define/define.h" #include "../ShareMemory/shmMem.h" #include "../SelectGun/SelectGun.h" #include "../DataBase/DataBase.h" #include "main.h" #include "../timeout.h" static DcCommonInfo *ShmDcCommonData = NULL; static SelectGunInfo *ShmSelectGunInfo = NULL; static struct SysInfoData *pSysInfo = NULL; #define PREAUTHMONEY 1000 bool isDeductDb_ready; //------------------------------------------------------------------------------ static char *rfidPortName = "/dev/ttyS2"; int fd = -1; static bool isCardScan = false; //------------------------------------------------------------------------------ static bool canStartCharging(void) { uint8_t index = 0; char buf2[16] = ""; memset(buf2, 0, ARRAY_SIZE(buf2)); struct OCPP16Data *ShmOCPP16Data = (struct OCPP16Data *)GetShmOCPP16Data(); for (index = 0; index < strlen((char *)ShmOCPP16Data->Authorize.ResponseIdTagInfo.Status); index++) { sprintf(buf2 + (index - 1) * 2, "%02X", ShmOCPP16Data->Authorize.ResponseIdTagInfo.Status[index]); } sprintf(buf2, "%s", ShmOCPP16Data->Authorize.ResponseIdTagInfo.Status); // 因為無法得知實際的長度,所以只能用搜尋的方式 if (strcmp(buf2, "Accepted") == EQUAL) { return true; } return false; } bool isAutorCompleteHandle(/*uint8_t *authorizeIndex*/) { // uint8_t i = 0; struct SysConfigData *pSysConfig = (struct SysConfigData *)GetShmSysConfigData(); //struct ChargingInfoData *pDcChargingInfo = NULL; //struct SysInfoData *pSysInfo = (struct SysInfoData *)GetShmSysInfoData(); // 透過後臺停止充電的判斷 if (isAuthorizedComplete()) { // 判斷後台回覆狀態 if (canStartCharging() == false) { strcpy((char *)pSysConfig->UserId, ""); ClearAuthorizedFlag(); } return true; } return false; /* if (*(authorizeIndex) != NO_DEFINE) { pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(*(authorizeIndex)); if (pSysConfig->OfflinePolicy == _OFFLINE_POLICY_LOCAL_LIST && strcmp((char *)pDcChargingInfo->StartUserId, "") != EQUAL) { // 先找 AC if (*(authorizeIndex) == DEFAULT_AC_INDEX) { AcChargingTerminalProcess(); } else { ChargingTerminalProcess(*(authorizeIndex)); } } strcpy((char *)pSysConfig->UserId, ""); *(authorizeIndex) = NO_DEFINE; } ClearAuthorizedFlag(); } /*else if (pSysConfig->OfflinePolicy == _OFFLINE_POLICY_LOCAL_LIST) { // 白名單驗證 for (i = 0; i < 10; i++) { if (strcmp((char *)pSysConfig->LocalWhiteCard[i], "") == EQUAL) { continue; } if (strcmp((char *)pSysConfig->LocalWhiteCard[i], (char *)pSysConfig->UserId) == EQUAL) { ChargingTerminalProcess(*(authorizeIndex)); strcpy((char *)pSysConfig->UserId, ""); ClearAuthorizedFlag(); break; } } }*/ } bool RfidStopCharging(void) { //當前沒有選槍 struct SysConfigData *pSysConfig = (struct SysConfigData *)GetShmSysConfigData(); struct SysInfoData *pSysInfo = (struct SysInfoData *)GetShmSysInfoData(); if (getConfirmSelectedGun(pSysInfo->CurGunSelected) == FAIL ) { strcpy((char *)pSysConfig->UserId, ""); return false; } struct ChargingInfoData *pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected); if (pDcChargingInfo->isRemoteStart) { } else { if (strcmp((char *)pSysConfig->UserId, (char *)pDcChargingInfo->StartUserId) == EQUAL) { ChargingTerminalProcess(pSysInfo->CurGunSelected); strcpy((char *)pSysConfig->UserId, ""); log_info("index = %d, card number = %s, UserId = %s ", pSysInfo->CurGunSelected, pDcChargingInfo->StartUserId, pSysConfig->UserId); return true; } else { strcpy((char *)pSysConfig->UserId, ""); return false; } } return false; } static void UserScanFunction(void) { bool idleReq = false; uint8_t i = 0; uint8_t stopReq = NO_DEFINE; char value[32] = {0}; static uint8_t _authorizeIndex = NO_DEFINE; struct SysConfigData *pSysConfig = (struct SysConfigData *)GetShmSysConfigData(); struct SysInfoData *pSysInfo = (struct SysInfoData *)GetShmSysInfoData(); struct ChargingInfoData *pAcChargingInfo = (struct ChargingInfoData *)GetAcChargingInfoData(0); struct ChargingInfoData *pDcChargingInfo = NULL; GunIndexInfo *pGunIndexInfo = (GunIndexInfo *)GetGunIndexInfo(); // 當前非驗證的狀態 if (IsAuthorizingMode()) { isAutorCompleteHandle(/*&_authorizeIndex*/); } //當前沒有選槍 /* if (getConfirmSelectedGun(pSysInfo->CurGunSelected) == FAIL) { strcpy((char *)pSysConfig->UserId, ""); return; }*/ // 先判斷現在是否可以提供刷卡 // 1. 如果當前沒有槍是閒置狀態,則無提供刷卡功能 // 2. 停止充電 //if (pSysInfo->PageIndex == _LCM_ERROR) { if (pSysInfo->SystemPage == _PAGE_MAINTAIN) { strcpy((char *)pSysConfig->UserId, ""); return; } /* for (i = 0; i < pSysConfig->TotalConnectorCount; i++) { pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(i); if (pDcChargingInfo->SystemStatus == S_CHARGING) { stopReq = i; } if ((pDcChargingInfo->SystemStatus == S_AUTHORIZING && pDcChargingInfo->IsAvailable == YES) || (pGunIndexInfo->AcGunIndex > 0 && pAcChargingInfo->SystemStatus == S_AUTHORIZING && pAcChargingInfo->IsAvailable) ) { idleReq = true; } } if (pGunIndexInfo->AcGunIndex > 0 && pSysInfo->CurGunSelectedByAc == DEFAULT_AC_INDEX && pAcChargingInfo->SystemStatus == S_CHARGING) { stopReq = DEFAULT_AC_INDEX; } */ if (strlen((char *)pSysConfig->UserId) <= 0) { return; } pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected); // Stop Charging For AC /*if (pGunIndexInfo->AcGunIndex > 0 && stopReq == DEFAULT_AC_INDEX && pSysInfo->CurGunSelectedByAc == DEFAULT_AC_INDEX) { log_info("ac stop charging "); log_info("index = %d, card number = %s, UserId = %s ", pSysInfo->CurGunSelectedByAc, pAcChargingInfo->StartUserId, pSysConfig->UserId); memset(value, 0, sizeof(value)); memcpy(value, (uint8_t *)pAcChargingInfo->StartUserId, ARRAY_SIZE(pAcChargingInfo->StartUserId)); if (strcmp((char *)pSysConfig->UserId, value) == EQUAL) { AcChargingTerminalProcess(); } strcpy((char *)pSysConfig->UserId, ""); } else if (stopReq < pSysConfig->TotalConnectorCount && pDcChargingInfo->SystemStatus == S_CHARGING && (pGunIndexInfo->AcGunIndex <= 0 || (pGunIndexInfo->AcGunIndex > 0 && pSysInfo->CurGunSelectedByAc == NO_DEFINE)) ) { // Stop Charging if (RfidStopCharging()) return; if (pGunIndexInfo->AcGunIndex > 0 && pSysInfo->CurGunSelectedByAc == DEFAULT_AC_INDEX) { _authorizeIndex = pSysInfo->CurGunSelectedByAc; } else { _authorizeIndex = pSysInfo->CurGunSelected; } strcpy((char *)pSysConfig->UserId, ""); return; } else if (idleReq) { if (pSysConfig->TotalConnectorCount > 1 && stopReq != 255 && pSysInfo->IsAlternatvieConf == YES) { idleReq = false; strcpy((char *)pSysConfig->UserId, ""); } else if ((pGunIndexInfo->AcGunIndex > 0 && pSysInfo->CurGunSelectedByAc == DEFAULT_AC_INDEX) || pDcChargingInfo->SystemStatus == S_AUTHORIZING) {*/ if ( (pSysInfo->SystemPage == _PAGE_AUTHORIZE || pSysInfo->SystemPage == _PAGE_SENSING) && pDcChargingInfo->SystemStatus == S_IDLE) { log_info("// LCM => Authorizing"); confirmSelGun(pSysInfo->CurGunSelected); setSelGunWaitToAuthor(pSysInfo->CurGunSelected); StartSystemTimeoutDet(Timeout_Authorizing); pDcChargingInfo->SystemStatus = S_AUTHORIZING; AuthorizingStart(); // LCM => Authorizing //pSysInfo->SystemPage = _PAGE_AUTHORIZE; // 進入確認卡號狀態 } else { //strcpy((char *)pSysConfig->UserId, ""); } return; } bool GetIsCardScan(void) { return isCardScan; } void SetIsCardScan(bool value) { isCardScan = value; } void AuthorizeToCharge() { struct SysConfigData *pSysConfig = (struct SysConfigData *)GetShmSysConfigData(); struct SysInfoData *pSysInfo = (struct SysInfoData *)GetShmSysInfoData(); SelectGunInfo *ShmSelectGunInfo = (SelectGunInfo *)GetShmSelectGunInfo(); struct ChargingInfoData *pDcChargingInfo = NULL; pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected); ShmDcCommonData = (DcCommonInfo *)GetShmDcCommonData(); if(isAuthorizedComplete()) { // StopSystemTimeoutDet(); StartSystemTimeoutDet(Timeout_WaitBalance); if (ShmSelectGunInfo->PricesInfo[pSysInfo->CurGunSelected].Balance != FAIL_BALANCE_PRICES) { StopSystemTimeoutDet(); // 判斷後台回覆狀態 if (canStartCharging() && ShmDcCommonData->AuthPass_flag[pSysInfo->CurGunSelected] == TRUE) { // LCM => Authorize complete //pDcChargingInfo->SystemStatus = S_AUTHORIZING; //pSysInfo->SystemPage = _PAGE_PLUGIN; //log_info("Wait Gun(%d) plugin",pSysInfo->CurGunSelected); DetectPluginStart(); pSysInfo->SystemPage = _PAGE_PLUGIN; //log_info("Gun(%d) Balance: %f",pSysInfo->CurGunSelected, // ShmSelectGunInfo->PricesInfo[pSysInfo->CurGunSelected].Balance); } else { //log_info("LCM => Authorize fail"); //pSysInfo->SystemPage = _PAGE_AUTHORIZE_FAIL; //strcpy((char *)pSysConfig->UserId, ""); } } ClearAuthorizedFlag(); } } void ScannerCardProcess(void) { struct SysConfigData *pSysConfig = (struct SysConfigData *)GetShmSysConfigData(); struct SysInfoData *pSysInfo = (struct SysInfoData *)GetShmSysInfoData(); struct WARNING_CODE_INFO *pSysWarning = (struct WARNING_CODE_INFO *)GetShmSysWarningInfo(); struct ChargingInfoData *pDcChargingInfo = NULL; pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected); if (!isDetectPlugin() && (pSysInfo->SystemPage == _PAGE_SENSING || pSysInfo->SystemPage == _PAGE_AUTHORIZE ) && pDcChargingInfo->SystemStatus == S_IDLE && pSysWarning->Level != WARN_LV_ER /*&& pSysConfig->AuthorisationMode == AUTH_MODE_ENABLE*/) { //setSelGunWaitToAuthor(pSysInfo->CurGunSelected); isCardScan = true; // 處理刷卡及驗證卡號的動作 UserScanFunction(); } if (pDcChargingInfo->SystemStatus == S_AUTHORIZING && pSysInfo->SystemPage == _PAGE_SENSING ) { AuthorizeToCharge(); } else if (pSysInfo->SystemPage == _PAGE_AUTHORIZE_FAIL) { StartSystemTimeoutDet(Timeout_VerifyFail); isCardScan = false; } else if ( pSysInfo->SystemPage == _PAGE_PLUGIN) { StartSystemTimeoutDet(Timeout_WaitPlug); } else { isCardScan = false; } } void WritePayResult(int result ,uint8_t gunIndex) { ShmDcCommonData->TransactionInfo[gunIndex].Amount = ShmDcCommonData->finalcost[gunIndex]; memcpy(ShmDcCommonData->TransactionInfo[gunIndex].ApprovalNo , ShmDcCommonData->pCreditCard[gunIndex].ApprovalNo,9); memcpy(ShmDcCommonData->TransactionInfo[gunIndex].CardNo , ShmDcCommonData->pCreditCard[gunIndex].CardNo,20); ShmDcCommonData->TransactionInfo[gunIndex].DeductResult = result; ShmDcCommonData->TransactionInfo[gunIndex].IsDonateInvoice = ShmDcCommonData->donate_flag[gunIndex]; ShmDcCommonData->TransactionInfo[gunIndex].TransactionId = ShmSelectGunInfo->PricesInfo[gunIndex].TransactionId; memcpy(&ShmDcCommonData->TransactionInfo[gunIndex].VemData,&ShmDcCommonData->pCreditCard[gunIndex].VemData,64); } void PreAuthCompleteToCardReader(int fd,uint8_t gunIndex) { int result = 0; result = CreditCardPreAuthComplete(fd,(int)ShmDcCommonData->finalcost[pSysInfo->CurGunSelected] ,"TCC Test", &ShmDcCommonData->pCreditCard[gunIndex].VemData[0], &ShmDcCommonData->pCreditCard[gunIndex]); //result = 1; if (result > 0 ) { log_info("Credit Card Spend Money:%.1f",ShmDcCommonData->finalcost[gunIndex]); pSysInfo->SystemPage = _PAGE_COMPLETE; WritePayResult(TRUE,gunIndex); ShmDcCommonData->PayPass_flag[gunIndex] = TRUE; } else { log_info("PAYING FAIL"); ShmDcCommonData->PayPass_flag[gunIndex] = FALSE; pSysInfo->SystemPage = _PAGE_PAYFAIL; WritePayResult(FALSE,gunIndex); } if (isDeductDb_ready == TRUE) { InsertDeductInfo(gunIndex,&ShmDcCommonData->TransactionInfo[gunIndex]); } } static int InitialRfidPort(void) { int fd = open(rfidPortName, O_RDWR); struct termios tios; struct AlarmCodeData *pAlarmCode = (struct AlarmCodeData *)GetShmAlarmCodeData(); if (fd != FAIL) { ioctl (fd, TCGETS, &tios); tios.c_cflag = B115200 | CS8 | CLOCAL | CREAD; tios.c_lflag = 0; tios.c_iflag = 0; tios.c_oflag = 0; tios.c_cc[VMIN] = 0; tios.c_cc[VTIME] = (uint8_t) 1; tios.c_lflag = 0; tcflush(fd, TCIFLUSH); ioctl(fd, TCSETS, &tios); } if (fd < 0) { pAlarmCode->AlarmEvents.bits.RfidModuleCommFail = 1; } return fd; } void CreateRfidFork(void) { pid_t rfidRecPid; rfidRecPid = fork(); if (rfidRecPid == 0) { char localTime[128] = {0}; struct timeb SeqEndTime; struct tm *tm; pSysInfo = (struct SysInfoData *)GetShmSysInfoData(); int isContinue = 1; RFID rfid = {0}; RecordTransactionInfo deduct; fd = InitialRfidPort(); struct SysConfigData *pSysConfig = (struct SysConfigData *)GetShmSysConfigData(); ShmDcCommonData = (DcCommonInfo *)GetShmDcCommonData(); ShmSelectGunInfo = (SelectGunInfo *)GetShmSelectGunInfo(); struct ChargingInfoData *pDcChargingInfo = NULL; ShmDcCommonData->reupload_deduct_status = 0; int gunIndex; int uploadIndex = 0; int ReAuthComplete_Index = 0; if(DeductDB_Open() != PASS) { isDeductDb_ready = false; } else { isDeductDb_ready = true; } //log_info("RFID fork Child's PID is %d", getpid()); int result; int is_idle = FALSE; while (isContinue) { result = 0; usleep(500000); ftime(&SeqEndTime); SeqEndTime.time = time(NULL); tm = localtime(&SeqEndTime.time); // 每日結帳 if (tm->tm_hour == 23 && tm->tm_min == 00 && tm->tm_sec == 0) { result = CreditCardUnionSettlement(fd,"TCC Test",&ShmDcCommonData->pCreditCard[0]); if (result > 0) { log_info("CreditCardUnionSettlement OK"); } else log_info("CreditCardUnionSettlement FAIL"); } if (tm->tm_min%2 == 0 && pSysInfo->SystemPage == _PAGE_IDLE) { if(ShmDcCommonData->reupload_deduct_status == 0) { // 嘗試傳送未上傳成功到後台ID if (DB_GetReUploadDeduct(&uploadIndex,&ShmDcCommonData->UploadRedectInfo) == PASS) { ShmDcCommonData->reupload_deduct_status = 1; //log_info("deduct uploading"); } else { //log_info("no deduct upload"); } } else if (ShmDcCommonData->reupload_deduct_status == 2) { UpdateDeductInfoStatus(&uploadIndex,&ShmDcCommonData->UploadRedectInfo); ShmDcCommonData->reupload_deduct_status = 0; } } if (pSysInfo->SystemPage == _PAGE_AUTHORIZE && ShmDcCommonData->GetCardNo[pSysInfo->CurGunSelected] == FALSE) { result = CreditCardSearch(fd,"TCC Test",&ShmDcCommonData->pCreditCard[pSysInfo->CurGunSelected]); //result = 1; StartSystemTimeoutDet(Timeout_ScanCard); if (result > 0) { //strcpy((char *)pSysConfig->UserId,"AutoStartCharging"); strncpy((char *)pSysConfig->UserId,ShmDcCommonData->pCreditCard[pSysInfo->CurGunSelected].CardNo,20); log_info("Authorize card:%s",pSysConfig->UserId); StopSystemTimeoutDet(); ShmDcCommonData->GetCardNo[pSysInfo->CurGunSelected] = TRUE; } else if (result < 0) { //pSysInfo->SystemPage = _PAGE_AUTHORIZE_FAIL; log_info("No Card Scanning..."); } } is_idle = FALSE; for (gunIndex = 0; gunIndex < pSysConfig->TotalConnectorCount; gunIndex++) { pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(gunIndex); if (pDcChargingInfo->SystemStatus == S_IDLE) { is_idle = TRUE; } if (ShmDcCommonData->StopCharge[gunIndex] == TRUE && ShmDcCommonData->finalcost_flag[gunIndex]) { if (ShmDcCommonData->finalcost[gunIndex] <= 0) { } else { ShmDcCommonData->StopCharge[gunIndex] = FALSE; StopGunInfoTimeoutDet(gunIndex); //Timeout_FinalCost PreAuthCompleteToCardReader(fd,gunIndex); ShmDcCommonData->PayFinish[gunIndex] = TRUE; } } } // for if (is_idle == TRUE && tm->tm_min%15 == 0 && pSysInfo->SystemPage == _PAGE_IDLE && ShmDcCommonData->reupload_deduct_status == 0) { sleep(1); if (DB_GetReDeductInfo(&ReAuthComplete_Index,&ShmDcCommonData->ReAuthComplete) == PASS ) { result = CreditCardPreAuthComplete(fd,(int)ShmDcCommonData->ReAuthComplete.Amount ,"TCC Test", &ShmDcCommonData->ReAuthComplete.VemData[0], &ShmDcCommonData->pCreditCard[0]); if (result > 0) { ShmDcCommonData->ReAuthComplete.DeductResult = YES; ShmDcCommonData->ReAuthComplete.IsUpload = NO; UpdateDeductInfoStatus(&ReAuthComplete_Index,&ShmDcCommonData->ReAuthComplete); log_info("PreAuthComplete OK"); } else if ( result < 0) { log_info("Backgroud ID:%d Amount:%d VemData:%s PreAuthComplete fail", ShmDcCommonData->ReAuthComplete.TransactionId, (int)ShmDcCommonData->ReAuthComplete.Amount, ShmDcCommonData->ReAuthComplete.VemData); } } else { log_info("DB_GetReDeductInfo Fail"); } } if(ShmDcCommonData->PreAuth_Config == _CREDITCARD_CANCEL) { ShmDcCommonData->PreAuth_Result = CreditCardPreAuthCancel(fd,PREAUTHMONEY,"TCC Test", &ShmDcCommonData->pCreditCard[pSysInfo->CurGunSelected].ApprovalNo[0], &ShmDcCommonData->pCreditCard[pSysInfo->CurGunSelected].CardNo[0], &ShmDcCommonData->pCreditCard[pSysInfo->CurGunSelected].VemData[0]); if (ShmDcCommonData->PreAuth_Result > 0 ) { strcpy((char *)pSysConfig->UserId,""); log_info("Credit Card Cancel Stop"); memset(&ShmDcCommonData->pCreditCard[pSysInfo->CurGunSelected], 0, sizeof(TransInfo)); } else if (ShmDcCommonData->PreAuth_Result < 0) { log_info("Credit Card Cancel Fail"); } ShmDcCommonData->PreAuth_Config = _CREDITCARD_IDLE; } else if (ShmDcCommonData->PreAuth_Config == _CREDITCARD_PREAUTH) { result = CreditCardPreAuth(fd, PREAUTHMONEY,"TCC Test", &ShmDcCommonData->pCreditCard[pSysInfo->CurGunSelected]); //result = 1; if (result > 0) { ShmDcCommonData->AuthPass_flag[pSysInfo->CurGunSelected] = TRUE; //pSysInfo->SystemPage = _PAGE_PLUGIN; //strncpy((char *)pSysConfig->UserId,ShmDcCommonData->pCreditCard[pSysInfo->CurGunSelected].CardNo,20); log_info("PreAuth OK"); } else if (result < 0) { struct ChargingInfoData *pDcChargingInfo = NULL; //pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected); pSysInfo->SystemPage = _PAGE_AUTHORIZE_FAIL; //pDcChargingInfo->SystemStatus = S_IDLE; ShmDcCommonData->AuthPass_flag[pSysInfo->CurGunSelected] = FALSE; memset(&ShmDcCommonData->pCreditCard[pSysInfo->CurGunSelected], 0, sizeof(TransInfo)); log_info("PreAuth Fail"); ShmDcCommonData->PreAuth_Config = _CREDITCARD_CANCEL; } ShmDcCommonData->PreAuth_Config = _CREDITCARD_IDLE; } /* // 刷卡判斷 if (pSysConfig->OfflinePolicy == _OFFLINE_POLICY_NO_CHARGING || !pSysConfig->isRFID) { continue; } if (getRequestCardSN(fd, 0, &rfid) == false) { continue; } //log_info("Get Card..-%s- ", pSysConfig->UserId); if (strlen((char *)pSysConfig->UserId) != 0) { continue; } if (pSysConfig->RfidCardNumEndian == RFID_ENDIAN_LITTLE) { switch (rfid.snType) { case RFID_SN_TYPE_6BYTE: sprintf((char *) pSysConfig->UserId, "%02X%02X%02X%02X%02X%02X", rfid.currentCard[0], rfid.currentCard[1], rfid.currentCard[2], rfid.currentCard[3], rfid.currentCard[4], rfid.currentCard[5]); break; case RFID_SN_TYPE_7BYTE: sprintf((char *) pSysConfig->UserId, "%02X%02X%02X%02X%02X%02X%02X", rfid.currentCard[0], rfid.currentCard[1], rfid.currentCard[2], rfid.currentCard[3], rfid.currentCard[4], rfid.currentCard[5], rfid.currentCard[6]); break; case RFID_SN_TYPE_10BYTE: sprintf((char *) pSysConfig->UserId, "%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X", rfid.currentCard[0], rfid.currentCard[1], rfid.currentCard[2], rfid.currentCard[3], rfid.currentCard[4], rfid.currentCard[5], rfid.currentCard[6], rfid.currentCard[7], rfid.currentCard[8], rfid.currentCard[9]); break; case RFID_SN_TYPE_4BYTE: sprintf((char *) pSysConfig->UserId, "%02X%02X%02X%02X", rfid.currentCard[0], rfid.currentCard[1], rfid.currentCard[2], rfid.currentCard[3]); break; } } else if (pSysConfig->RfidCardNumEndian == RFID_ENDIAN_BIG) { switch (rfid.snType) { case RFID_SN_TYPE_6BYTE: sprintf((char *) pSysConfig->UserId, "%02X%02X%02X%02X%02X%02X", rfid.currentCard[5], rfid.currentCard[4], rfid.currentCard[3], rfid.currentCard[2], rfid.currentCard[1], rfid.currentCard[0]); break; case RFID_SN_TYPE_7BYTE: sprintf((char *) pSysConfig->UserId, "%02X%02X%02X%02X%02X%02X%02X", rfid.currentCard[6], rfid.currentCard[5], rfid.currentCard[4], rfid.currentCard[3], rfid.currentCard[2], rfid.currentCard[1], rfid.currentCard[0]); break; case RFID_SN_TYPE_10BYTE: sprintf((char *) pSysConfig->UserId, "%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X", rfid.currentCard[9], rfid.currentCard[8], rfid.currentCard[7], rfid.currentCard[6], rfid.currentCard[5], rfid.currentCard[4], rfid.currentCard[3], rfid.currentCard[2], rfid.currentCard[1], rfid.currentCard[0]); break; case RFID_SN_TYPE_4BYTE: sprintf((char *) pSysConfig->UserId, "%02X%02X%02X%02X", rfid.currentCard[3], rfid.currentCard[2], rfid.currentCard[1], rfid.currentCard[0]); break; } } log_info("card number = %s", pSysConfig->UserId); */ } } }