|
@@ -32,17 +32,75 @@ static bool canStartCharging(void)
|
|
|
// 因為無法得知實際的長度,所以只能用搜尋的方式
|
|
|
if (strcmp(buf2, "Accepted") == EQUAL) {
|
|
|
return true;
|
|
|
- } else {
|
|
|
-
|
|
|
}
|
|
|
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+static void isAutorCompleteHandle(uint8_t *authorizeIndex)
|
|
|
+{
|
|
|
+ uint8_t i = 0;
|
|
|
+ struct SysConfigData *pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
|
|
|
+ struct ChargingInfoData *pDcChargingInfo = NULL;
|
|
|
+
|
|
|
+ // 透過後臺停止充電的判斷
|
|
|
+ if (isAuthorizedComplete()
|
|
|
+#if !defined DD360 && !defined DD360Audi && !defined DD360ComBox
|
|
|
+ || (pSysInfo->OcppConnStatus == NO &&
|
|
|
+ pSysConfig->OfflinePolicy == _OFFLINE_POLICY_FREE_CHARGING)
|
|
|
+#endif //!defined DD360 && !defined DD360Audi
|
|
|
+ ) {
|
|
|
+
|
|
|
+ // 判斷後台回覆狀態
|
|
|
+ if (canStartCharging() == false) {
|
|
|
+ strcpy((char *)pSysConfig->UserId, "");
|
|
|
+ ClearAuthorizedFlag();
|
|
|
+
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
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();
|
|
@@ -51,164 +109,138 @@ static void UserScanFunction(void)
|
|
|
GunIndexInfo *pGunIndexInfo = (GunIndexInfo *)GetGunIndexInfo();
|
|
|
|
|
|
// 當前非驗證的狀態
|
|
|
- if (!IsAuthorizingMode()) {
|
|
|
-#if defined DD360Audi
|
|
|
- //當前沒有選槍
|
|
|
- if (getConfirmSelectedGun(pSysInfo->CurGunSelected) == FAIL) { //Jerry add
|
|
|
- strcpy((char *)pSysConfig->UserId, "");
|
|
|
- return;
|
|
|
+ if (IsAuthorizingMode()) {
|
|
|
+ isAutorCompleteHandle(&_authorizeIndex);
|
|
|
+ }
|
|
|
+
|
|
|
+ //當前沒有選槍
|
|
|
+ if (getConfirmSelectedGun(pSysInfo->CurGunSelected) == FAIL) {
|
|
|
+ strcpy((char *)pSysConfig->UserId, "");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 先判斷現在是否可以提供刷卡
|
|
|
+ // 1. 如果當前沒有槍是閒置狀態,則無提供刷卡功能
|
|
|
+ // 2. 停止充電
|
|
|
+ if (pSysInfo->PageIndex == _LCM_FIX) {
|
|
|
+ strcpy((char *)pSysConfig->UserId, "");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ for (i = 0; i < pSysConfig->TotalConnectorCount; i++) {
|
|
|
+ pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(i);
|
|
|
+
|
|
|
+ if (pDcChargingInfo->SystemStatus == S_CHARGING) {
|
|
|
+ stopReq = i;
|
|
|
}
|
|
|
-#endif //defined DD360Audi
|
|
|
|
|
|
- // 先判斷現在是否可以提供刷卡
|
|
|
- // 1. 如果當前沒有槍是閒置狀態,則無提供刷卡功能
|
|
|
- // 2. 停止充電
|
|
|
- if (pSysInfo->PageIndex == _LCM_FIX) {
|
|
|
- strcpy((char *)pSysConfig->UserId, "");
|
|
|
- return;
|
|
|
+ if ((pDcChargingInfo->SystemStatus == S_IDLE &&
|
|
|
+ pDcChargingInfo->IsAvailable == YES) ||
|
|
|
+ (pGunIndexInfo->AcGunIndex > 0 &&
|
|
|
+ pAcChargingInfo->SystemStatus == S_IDLE &&
|
|
|
+ pAcChargingInfo->IsAvailable)
|
|
|
+ ) {
|
|
|
+ idleReq = true;
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- for (uint8_t i = 0; i < pSysConfig->TotalConnectorCount; i++) {
|
|
|
- pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(i);
|
|
|
+ if (pGunIndexInfo->AcGunIndex > 0 &&
|
|
|
+ pSysInfo->CurGunSelectedByAc == DEFAULT_AC_INDEX &&
|
|
|
+ pAcChargingInfo->SystemStatus == S_CHARGING) {
|
|
|
+ stopReq = DEFAULT_AC_INDEX;
|
|
|
+ }
|
|
|
|
|
|
- if (pDcChargingInfo->SystemStatus == S_CHARGING) {
|
|
|
- stopReq = i;
|
|
|
- }
|
|
|
- if ((pDcChargingInfo->SystemStatus == S_IDLE &&
|
|
|
- pDcChargingInfo->IsAvailable) == YES ||
|
|
|
- (pGunIndexInfo->AcGunIndex > 0 && pAcChargingInfo->SystemStatus ==
|
|
|
- S_IDLE && pAcChargingInfo->IsAvailable)
|
|
|
- ) {
|
|
|
- idleReq = true;
|
|
|
- }
|
|
|
+ if (strlen((char *)pSysConfig->UserId) <= 0) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
|
|
|
+
|
|
|
+ if (pGunIndexInfo->AcGunIndex > 0 &&
|
|
|
+ stopReq == DEFAULT_AC_INDEX &&
|
|
|
+ pSysInfo->CurGunSelectedByAc == DEFAULT_AC_INDEX) {
|
|
|
+ log_info("ac stop charging \n");
|
|
|
+ log_info("index = %d, card number = %s, UserId = %s \n",
|
|
|
+ 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))
|
|
|
+ ) {
|
|
|
+ log_info("stop charging \n");
|
|
|
+ log_info("index = %d, card number = %s, UserId = %s \n",
|
|
|
+ pSysInfo->CurGunSelected,
|
|
|
+ pDcChargingInfo->StartUserId,
|
|
|
+ pSysConfig->UserId);
|
|
|
+
|
|
|
+ memset(value, 0, sizeof(value));
|
|
|
+ memcpy(value,
|
|
|
+ (uint8_t *)pDcChargingInfo->StartUserId,
|
|
|
+ ARRAY_SIZE(pDcChargingInfo->StartUserId));
|
|
|
+
|
|
|
+ // 同一張卡直接停掉
|
|
|
+ if (strcmp((char *)pSysConfig->UserId, value) == EQUAL) {
|
|
|
+ ChargingTerminalProcess(pSysInfo->CurGunSelected);
|
|
|
+ strcpy((char *)pSysConfig->UserId, "");
|
|
|
|
|
|
- if (pGunIndexInfo->AcGunIndex > 0 && pSysInfo->CurGunSelectedByAc == DEFAULT_AC_INDEX &&
|
|
|
- pAcChargingInfo->SystemStatus == S_CHARGING) {
|
|
|
- stopReq = DEFAULT_AC_INDEX;
|
|
|
+ return;
|
|
|
}
|
|
|
|
|
|
- if (strlen((char *)pSysConfig->UserId) > 0) {
|
|
|
- pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
|
|
|
+ // 進驗證
|
|
|
+ if (pGunIndexInfo->AcGunIndex > 0 &&
|
|
|
+ pSysInfo->CurGunSelectedByAc == DEFAULT_AC_INDEX) {
|
|
|
+ _authorizeIndex = pSysInfo->CurGunSelectedByAc;
|
|
|
+ } else {
|
|
|
+ _authorizeIndex = pSysInfo->CurGunSelected;
|
|
|
+ }
|
|
|
|
|
|
- if (pGunIndexInfo->AcGunIndex > 0 && stopReq == DEFAULT_AC_INDEX &&
|
|
|
- pSysInfo->CurGunSelectedByAc == DEFAULT_AC_INDEX) {
|
|
|
- char value[32];
|
|
|
+#if defined DD360 || defined DD360Audi || defined DD360ComBox
|
|
|
+ strcpy((char *)pSysConfig->UserId, "");
|
|
|
|
|
|
- log_info("ac stop charging \n");
|
|
|
- log_info("index = %d, card number = %s, UserId = %s \n", pSysInfo->CurGunSelectedByAc,
|
|
|
- pAcChargingInfo->StartUserId, pSysConfig->UserId);
|
|
|
- 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))) {
|
|
|
- char value[32];
|
|
|
-
|
|
|
- log_info("stop charging \n");
|
|
|
- log_info("index = %d, card number = %s, UserId = %s \n",
|
|
|
- pSysInfo->CurGunSelected,
|
|
|
- pDcChargingInfo->StartUserId,
|
|
|
- pSysConfig->UserId);
|
|
|
- memcpy(value, (uint8_t *)pDcChargingInfo->StartUserId,
|
|
|
- ARRAY_SIZE(pDcChargingInfo->StartUserId));
|
|
|
-
|
|
|
- // 同一張卡直接停掉
|
|
|
- if (strcmp((char *)pSysConfig->UserId, value) == EQUAL) {
|
|
|
- ChargingTerminalProcess(pSysInfo->CurGunSelected);
|
|
|
- strcpy((char *)pSysConfig->UserId, "");
|
|
|
- } else {
|
|
|
- // 進驗證
|
|
|
- if (pGunIndexInfo->AcGunIndex > 0 && pSysInfo->CurGunSelectedByAc == DEFAULT_AC_INDEX) {
|
|
|
- _authorizeIndex = pSysInfo->CurGunSelectedByAc;
|
|
|
- } else {
|
|
|
- _authorizeIndex = pSysInfo->CurGunSelected;
|
|
|
- }
|
|
|
-#if !defined DD360 && !defined DD360Audi && !defined DD360ComBox
|
|
|
- StartSystemTimeoutDet(Timeout_AuthorizingForStop);
|
|
|
- AuthorizingStart();
|
|
|
-#else
|
|
|
- strcpy((char *)pSysConfig->UserId, "");
|
|
|
-#endif //!defined DD360 && !defined DD360Audi
|
|
|
- }
|
|
|
- } 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_IDLE) {
|
|
|
- log_info("// LCM => Authorizing \n");
|
|
|
-#if defined DD360Audi
|
|
|
- setSelGunWaitToAuthor(pSysInfo->CurGunSelected); //Jerry add
|
|
|
-#endif //defined DD360Audi
|
|
|
- // LCM => Authorizing
|
|
|
- pSysInfo->SystemPage = _LCM_AUTHORIZING;
|
|
|
- // 進入確認卡號狀態
|
|
|
- AuthorizingStart();
|
|
|
- } else {
|
|
|
- strcpy((char *)pSysConfig->UserId, "");
|
|
|
- }
|
|
|
- } else {
|
|
|
- strcpy((char *)pSysConfig->UserId, "");
|
|
|
- }
|
|
|
+ return;
|
|
|
+#endif //defined DD360 || defined DD360Audi || defined DD360ComBox
|
|
|
+
|
|
|
+ StartSystemTimeoutDet(Timeout_AuthorizingForStop);
|
|
|
+
|
|
|
+ AuthorizingStart();
|
|
|
+ } 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_IDLE) {
|
|
|
+ log_info("// LCM => Authorizing\r\n");
|
|
|
+
|
|
|
+ setSelGunWaitToAuthor(pSysInfo->CurGunSelected);
|
|
|
+
|
|
|
+ // LCM => Authorizing
|
|
|
+ pSysInfo->SystemPage = _LCM_AUTHORIZING;
|
|
|
+
|
|
|
+ // 進入確認卡號狀態
|
|
|
+ AuthorizingStart();
|
|
|
+ } else {
|
|
|
+ strcpy((char *)pSysConfig->UserId, "");
|
|
|
}
|
|
|
} else {
|
|
|
- // 透過後臺停止充電的判斷
|
|
|
- if (isAuthorizedComplete()
|
|
|
-#if !defined DD360 && !defined DD360Audi && !defined DD360ComBox
|
|
|
- || (pSysInfo->OcppConnStatus == NO &&
|
|
|
- pSysConfig->OfflinePolicy == _OFFLINE_POLICY_FREE_CHARGING)
|
|
|
-#endif //!defined DD360 && !defined DD360Audi
|
|
|
- ) {
|
|
|
- // 判斷後台回覆狀態
|
|
|
- if (canStartCharging()
|
|
|
-#if !defined DD360 && !defined DD360Audi && !defined DD360ComBox
|
|
|
- || (pSysInfo->OcppConnStatus == NO &&
|
|
|
- pSysConfig->OfflinePolicy == _OFFLINE_POLICY_FREE_CHARGING)
|
|
|
-#endif //!defined DD360 && !defined DD360Audi
|
|
|
- ) {
|
|
|
- if (_authorizeIndex != NO_DEFINE) {
|
|
|
- pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(_authorizeIndex);
|
|
|
-
|
|
|
- // 先找 AC
|
|
|
- if (_authorizeIndex == DEFAULT_AC_INDEX) {
|
|
|
- if (pSysConfig->OfflinePolicy == _OFFLINE_POLICY_LOCAL_LIST &&
|
|
|
- strcmp((char *)pDcChargingInfo->StartUserId, "") != EQUAL) {
|
|
|
- AcChargingTerminalProcess();
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (pSysConfig->OfflinePolicy == _OFFLINE_POLICY_LOCAL_LIST &&
|
|
|
- strcmp((char *)pDcChargingInfo->StartUserId, "") != EQUAL) {
|
|
|
- ChargingTerminalProcess(_authorizeIndex);
|
|
|
- }
|
|
|
- }
|
|
|
- strcpy((char *)pSysConfig->UserId, "");
|
|
|
- _authorizeIndex = NO_DEFINE;
|
|
|
- }
|
|
|
- } else {
|
|
|
- strcpy((char *)pSysConfig->UserId, "");
|
|
|
- }
|
|
|
- ClearAuthorizedFlag();
|
|
|
- } else if (pSysConfig->OfflinePolicy == _OFFLINE_POLICY_LOCAL_LIST) {
|
|
|
- // 白名單驗證
|
|
|
- for (int i = 0; i < 10; i++) {
|
|
|
- if (strcmp((char *)pSysConfig->LocalWhiteCard[i], "") != EQUAL) {
|
|
|
- if (strcmp((char *)pSysConfig->LocalWhiteCard[i], (char *)pSysConfig->UserId) == EQUAL) {
|
|
|
- ChargingTerminalProcess(_authorizeIndex);
|
|
|
- strcpy((char *)pSysConfig->UserId, "");
|
|
|
- ClearAuthorizedFlag();
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ strcpy((char *)pSysConfig->UserId, "");
|
|
|
}
|
|
|
+
|
|
|
+ return;
|
|
|
}
|
|
|
|
|
|
bool GetIsCardScan(void)
|
|
@@ -223,12 +255,15 @@ void SetIsCardScan(bool value)
|
|
|
|
|
|
void ScannerCardProcess(void)
|
|
|
{
|
|
|
+ int i = 0;
|
|
|
struct SysConfigData *pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
|
|
|
struct SysInfoData *pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
|
|
|
struct WARNING_CODE_INFO *pSysWarning = (struct WARNING_CODE_INFO *)GetShmSysWarningInfo();
|
|
|
SelectGunInfo *ShmSelectGunInfo = (SelectGunInfo *)GetShmSelectGunInfo();
|
|
|
|
|
|
- if (!isDetectPlugin() && !isCardScan && pSysWarning->Level != 2 &&
|
|
|
+ if (!isDetectPlugin() &&
|
|
|
+ !isCardScan &&
|
|
|
+ pSysWarning->Level != WARN_LV_ER &&
|
|
|
pSysConfig->AuthorisationMode == AUTH_MODE_ENABLE) {
|
|
|
isCardScan = true;
|
|
|
// 處理刷卡及驗證卡號的動作
|
|
@@ -238,21 +273,18 @@ void ScannerCardProcess(void)
|
|
|
if (pSysInfo->PageIndex == _LCM_AUTHORIZING) {
|
|
|
StartSystemTimeoutDet(Timeout_Authorizing);
|
|
|
|
|
|
+ //printf("isAuthorizedComplete = %d, %f\r\n", isAuthorizedComplete(), ShmSelectGunInfo->PricesInfo[pSysInfo->CurGunSelected].Balance);
|
|
|
// 確認驗證卡號完成沒
|
|
|
if (isAuthorizedComplete()
|
|
|
#if !defined DD360 && !defined DD360Audi && !defined DD360ComBox
|
|
|
|| pSysConfig->OfflinePolicy == _OFFLINE_POLICY_FREE_CHARGING
|
|
|
-#else
|
|
|
+#endif //!defined DD360 && !defined DD360Audi && !defined DD360ComBox
|
|
|
&& ShmSelectGunInfo->PricesInfo[pSysInfo->CurGunSelected].Balance != FAIL_BALANCE_PRICES
|
|
|
-#endif //!defined DD360 && !defined DD360Audi
|
|
|
) {
|
|
|
StopSystemTimeoutDet();
|
|
|
+
|
|
|
// 判斷後台回覆狀態
|
|
|
- if (canStartCharging()
|
|
|
-#if !defined DD360 && !defined DD360Audi && !defined DD360ComBox
|
|
|
- || pSysConfig->OfflinePolicy == _OFFLINE_POLICY_FREE_CHARGING
|
|
|
-#endif //!defined DD360 && !defined DD360Audi
|
|
|
- ) {
|
|
|
+ if (canStartCharging()) {
|
|
|
// LCM => Authorize complete
|
|
|
pSysInfo->SystemPage = _LCM_AUTHORIZ_COMP;
|
|
|
} else {
|
|
@@ -260,16 +292,19 @@ void ScannerCardProcess(void)
|
|
|
pSysInfo->SystemPage = _LCM_AUTHORIZ_FAIL;
|
|
|
strcpy((char *)pSysConfig->UserId, "");
|
|
|
}
|
|
|
+
|
|
|
ClearAuthorizedFlag();
|
|
|
} else if (pSysConfig->OfflinePolicy == _OFFLINE_POLICY_LOCAL_LIST) {
|
|
|
// 白名單驗證
|
|
|
- for (int i = 0; i < 10; i++) {
|
|
|
- if (strcmp((char *)pSysConfig->LocalWhiteCard[i], "") != EQUAL) {
|
|
|
- if (strcmp((char *)pSysConfig->LocalWhiteCard[i], (char *)pSysConfig->UserId) == EQUAL) {
|
|
|
- pSysInfo->SystemPage = _LCM_AUTHORIZ_COMP;
|
|
|
- ClearAuthorizedFlag();
|
|
|
- break;
|
|
|
- }
|
|
|
+ for (i = 0; i < 10; i++) {
|
|
|
+ if (strcmp((char *)pSysConfig->LocalWhiteCard[i], "") == EQUAL) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (strcmp((char *)pSysConfig->LocalWhiteCard[i], (char *)pSysConfig->UserId) == EQUAL) {
|
|
|
+ pSysInfo->SystemPage = _LCM_AUTHORIZ_COMP;
|
|
|
+ ClearAuthorizedFlag();
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -317,98 +352,101 @@ void CreateRfidFork(void)
|
|
|
pid_t rfidRecPid;
|
|
|
|
|
|
rfidRecPid = fork();
|
|
|
- log_info("CreateRfidFork = %d\r\n", rfidRecPid);
|
|
|
if (rfidRecPid == 0) {
|
|
|
int fd = -1;
|
|
|
+ int isContinue = 1;
|
|
|
RFID rfid = {0};
|
|
|
fd = InitialRfidPort();
|
|
|
struct SysConfigData *pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
|
|
|
|
|
|
- while (true) {
|
|
|
+ log_info("RFID fork Child's PID is %d\r\n", getpid());
|
|
|
+
|
|
|
+ while (isContinue) {
|
|
|
+ usleep(500000);
|
|
|
+
|
|
|
// 刷卡判斷
|
|
|
if (pSysConfig->OfflinePolicy == _OFFLINE_POLICY_NO_CHARGING ||
|
|
|
!pSysConfig->isRFID) {
|
|
|
- usleep(500000);
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
if (getRequestCardSN(fd, 0, &rfid) == false) {
|
|
|
- usleep(500000);
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
//log_info("Get Card..-%s- \n", pSysConfig->UserId);
|
|
|
- if (strlen((char *)pSysConfig->UserId) == 0) {
|
|
|
- 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;
|
|
|
- }
|
|
|
+ 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\n", pSysConfig->UserId);
|
|
|
}
|
|
|
- usleep(500000);
|
|
|
+ log_info("card number = %s\n", pSysConfig->UserId);
|
|
|
}
|
|
|
}
|
|
|
}
|