RFID.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546
  1. #include <stdio.h> /*標準輸入輸出定義*/
  2. #include <stdlib.h> /*標準函數庫定義*/
  3. #include <string.h>
  4. #include <stdint.h>
  5. #include "../Config.h"
  6. #include "../Log/log.h"
  7. #include "../Define/define.h"
  8. #include "../ShareMemory/shmMem.h"
  9. #include "../SelectGun/SelectGun.h"
  10. #include "main.h"
  11. #include "../timeout.h"
  12. static DcCommonInfo *ShmDcCommonData = NULL;
  13. static struct SysInfoData *pSysInfo = NULL;
  14. #define PREAUTHMONEY 2
  15. //------------------------------------------------------------------------------
  16. static char *rfidPortName = "/dev/ttyS2";
  17. static bool isCardScan = false;
  18. //------------------------------------------------------------------------------
  19. static bool canStartCharging(void)
  20. {
  21. uint8_t index = 0;
  22. char buf2[16] = "";
  23. memset(buf2, 0, ARRAY_SIZE(buf2));
  24. struct OCPP16Data *ShmOCPP16Data = (struct OCPP16Data *)GetShmOCPP16Data();
  25. for (index = 0; index < strlen((char *)ShmOCPP16Data->Authorize.ResponseIdTagInfo.Status); index++) {
  26. sprintf(buf2 + (index - 1) * 2, "%02X", ShmOCPP16Data->Authorize.ResponseIdTagInfo.Status[index]);
  27. }
  28. sprintf(buf2, "%s", ShmOCPP16Data->Authorize.ResponseIdTagInfo.Status);
  29. // 因為無法得知實際的長度,所以只能用搜尋的方式
  30. if (strcmp(buf2, "Accepted") == EQUAL) {
  31. return true;
  32. }
  33. return false;
  34. }
  35. bool isAutorCompleteHandle(/*uint8_t *authorizeIndex*/)
  36. {
  37. // uint8_t i = 0;
  38. struct SysConfigData *pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
  39. //struct ChargingInfoData *pDcChargingInfo = NULL;
  40. //struct SysInfoData *pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
  41. // 透過後臺停止充電的判斷
  42. if (isAuthorizedComplete()) {
  43. // 判斷後台回覆狀態
  44. if (canStartCharging() == false) {
  45. strcpy((char *)pSysConfig->UserId, "");
  46. ClearAuthorizedFlag();
  47. }
  48. return true;
  49. }
  50. return false;
  51. /*
  52. if (*(authorizeIndex) != NO_DEFINE) {
  53. pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(*(authorizeIndex));
  54. if (pSysConfig->OfflinePolicy == _OFFLINE_POLICY_LOCAL_LIST &&
  55. strcmp((char *)pDcChargingInfo->StartUserId, "") != EQUAL) {
  56. // 先找 AC
  57. if (*(authorizeIndex) == DEFAULT_AC_INDEX) {
  58. AcChargingTerminalProcess();
  59. } else {
  60. ChargingTerminalProcess(*(authorizeIndex));
  61. }
  62. }
  63. strcpy((char *)pSysConfig->UserId, "");
  64. *(authorizeIndex) = NO_DEFINE;
  65. }
  66. ClearAuthorizedFlag();
  67. } /*else if (pSysConfig->OfflinePolicy == _OFFLINE_POLICY_LOCAL_LIST) {
  68. // 白名單驗證
  69. for (i = 0; i < 10; i++) {
  70. if (strcmp((char *)pSysConfig->LocalWhiteCard[i], "") == EQUAL) {
  71. continue;
  72. }
  73. if (strcmp((char *)pSysConfig->LocalWhiteCard[i], (char *)pSysConfig->UserId) == EQUAL) {
  74. ChargingTerminalProcess(*(authorizeIndex));
  75. strcpy((char *)pSysConfig->UserId, "");
  76. ClearAuthorizedFlag();
  77. break;
  78. }
  79. }
  80. }*/
  81. }
  82. bool RfidStopCharging(void)
  83. {
  84. //當前沒有選槍
  85. struct SysConfigData *pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
  86. struct SysInfoData *pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
  87. if (getConfirmSelectedGun(pSysInfo->CurGunSelected) == FAIL ) {
  88. strcpy((char *)pSysConfig->UserId, "");
  89. return false;
  90. }
  91. struct ChargingInfoData *pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
  92. if (pDcChargingInfo->isRemoteStart) {
  93. } else {
  94. if (strcmp((char *)pSysConfig->UserId, (char *)pDcChargingInfo->StartUserId) == EQUAL) {
  95. ChargingTerminalProcess(pSysInfo->CurGunSelected);
  96. strcpy((char *)pSysConfig->UserId, "");
  97. log_info("index = %d, card number = %s, UserId = %s ",
  98. pSysInfo->CurGunSelected,
  99. pDcChargingInfo->StartUserId,
  100. pSysConfig->UserId);
  101. return true;
  102. } else {
  103. strcpy((char *)pSysConfig->UserId, "");
  104. return false;
  105. }
  106. }
  107. return false;
  108. }
  109. static void UserScanFunction(void)
  110. {
  111. bool idleReq = false;
  112. uint8_t i = 0;
  113. uint8_t stopReq = NO_DEFINE;
  114. char value[32] = {0};
  115. static uint8_t _authorizeIndex = NO_DEFINE;
  116. struct SysConfigData *pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
  117. struct SysInfoData *pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
  118. struct ChargingInfoData *pAcChargingInfo = (struct ChargingInfoData *)GetAcChargingInfoData(0);
  119. struct ChargingInfoData *pDcChargingInfo = NULL;
  120. GunIndexInfo *pGunIndexInfo = (GunIndexInfo *)GetGunIndexInfo();
  121. // 當前非驗證的狀態
  122. if (IsAuthorizingMode()) {
  123. isAutorCompleteHandle(/*&_authorizeIndex*/);
  124. }
  125. //當前沒有選槍
  126. /*
  127. if (getConfirmSelectedGun(pSysInfo->CurGunSelected) == FAIL) {
  128. strcpy((char *)pSysConfig->UserId, "");
  129. return;
  130. }*/
  131. // 先判斷現在是否可以提供刷卡
  132. // 1. 如果當前沒有槍是閒置狀態,則無提供刷卡功能
  133. // 2. 停止充電
  134. //if (pSysInfo->PageIndex == _LCM_ERROR) {
  135. if (pSysInfo->SystemPage == _PAGE_MAINTAIN) {
  136. strcpy((char *)pSysConfig->UserId, "");
  137. return;
  138. }
  139. /*
  140. for (i = 0; i < pSysConfig->TotalConnectorCount; i++) {
  141. pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(i);
  142. if (pDcChargingInfo->SystemStatus == S_CHARGING) {
  143. stopReq = i;
  144. }
  145. if ((pDcChargingInfo->SystemStatus == S_AUTHORIZING &&
  146. pDcChargingInfo->IsAvailable == YES) ||
  147. (pGunIndexInfo->AcGunIndex > 0 &&
  148. pAcChargingInfo->SystemStatus == S_AUTHORIZING &&
  149. pAcChargingInfo->IsAvailable)
  150. ) {
  151. idleReq = true;
  152. }
  153. }
  154. if (pGunIndexInfo->AcGunIndex > 0 &&
  155. pSysInfo->CurGunSelectedByAc == DEFAULT_AC_INDEX &&
  156. pAcChargingInfo->SystemStatus == S_CHARGING) {
  157. stopReq = DEFAULT_AC_INDEX;
  158. }
  159. */
  160. if (strlen((char *)pSysConfig->UserId) <= 0) {
  161. return;
  162. }
  163. pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
  164. // Stop Charging For AC
  165. /*if (pGunIndexInfo->AcGunIndex > 0 &&
  166. stopReq == DEFAULT_AC_INDEX &&
  167. pSysInfo->CurGunSelectedByAc == DEFAULT_AC_INDEX) {
  168. log_info("ac stop charging ");
  169. log_info("index = %d, card number = %s, UserId = %s ",
  170. pSysInfo->CurGunSelectedByAc,
  171. pAcChargingInfo->StartUserId,
  172. pSysConfig->UserId);
  173. memset(value, 0, sizeof(value));
  174. memcpy(value,
  175. (uint8_t *)pAcChargingInfo->StartUserId,
  176. ARRAY_SIZE(pAcChargingInfo->StartUserId));
  177. if (strcmp((char *)pSysConfig->UserId, value) == EQUAL) {
  178. AcChargingTerminalProcess();
  179. }
  180. strcpy((char *)pSysConfig->UserId, "");
  181. } else if (stopReq < pSysConfig->TotalConnectorCount &&
  182. pDcChargingInfo->SystemStatus == S_CHARGING &&
  183. (pGunIndexInfo->AcGunIndex <= 0 ||
  184. (pGunIndexInfo->AcGunIndex > 0 &&
  185. pSysInfo->CurGunSelectedByAc == NO_DEFINE))
  186. ) {
  187. // Stop Charging
  188. if (RfidStopCharging())
  189. return;
  190. if (pGunIndexInfo->AcGunIndex > 0 &&
  191. pSysInfo->CurGunSelectedByAc == DEFAULT_AC_INDEX) {
  192. _authorizeIndex = pSysInfo->CurGunSelectedByAc;
  193. } else {
  194. _authorizeIndex = pSysInfo->CurGunSelected;
  195. }
  196. strcpy((char *)pSysConfig->UserId, "");
  197. return;
  198. } else if (idleReq) {
  199. if (pSysConfig->TotalConnectorCount > 1 &&
  200. stopReq != 255 &&
  201. pSysInfo->IsAlternatvieConf == YES) {
  202. idleReq = false;
  203. strcpy((char *)pSysConfig->UserId, "");
  204. } else if ((pGunIndexInfo->AcGunIndex > 0 &&
  205. pSysInfo->CurGunSelectedByAc == DEFAULT_AC_INDEX) ||
  206. pDcChargingInfo->SystemStatus == S_AUTHORIZING) {*/
  207. if ( (pSysInfo->SystemPage == _PAGE_AUTHORIZE ||
  208. pSysInfo->SystemPage == _PAGE_SENSING) &&
  209. pDcChargingInfo->SystemStatus == S_IDLE) {
  210. log_info("// LCM => Authorizing");
  211. confirmSelGun(pSysInfo->CurGunSelected);
  212. setSelGunWaitToAuthor(pSysInfo->CurGunSelected);
  213. StartSystemTimeoutDet(Timeout_Authorizing);
  214. pDcChargingInfo->SystemStatus = S_AUTHORIZING;
  215. AuthorizingStart();
  216. // LCM => Authorizing
  217. //pSysInfo->SystemPage = _PAGE_AUTHORIZE;
  218. // 進入確認卡號狀態
  219. } else {
  220. //strcpy((char *)pSysConfig->UserId, "");
  221. }
  222. return;
  223. }
  224. bool GetIsCardScan(void)
  225. {
  226. return isCardScan;
  227. }
  228. void SetIsCardScan(bool value)
  229. {
  230. isCardScan = value;
  231. }
  232. void AuthorizeToCharge()
  233. {
  234. struct SysConfigData *pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
  235. struct SysInfoData *pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
  236. SelectGunInfo *ShmSelectGunInfo = (SelectGunInfo *)GetShmSelectGunInfo();
  237. struct ChargingInfoData *pDcChargingInfo = NULL;
  238. pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
  239. if(isAuthorizedComplete())
  240. {
  241. // StopSystemTimeoutDet();
  242. StartSystemTimeoutDet(Timeout_WaitBalance);
  243. if (ShmSelectGunInfo->PricesInfo[pSysInfo->CurGunSelected].Balance != FAIL_BALANCE_PRICES) {
  244. StopSystemTimeoutDet();
  245. // 判斷後台回覆狀態
  246. if (canStartCharging()) {
  247. // LCM => Authorize complete
  248. //pDcChargingInfo->SystemStatus = S_AUTHORIZING;
  249. //pSysInfo->SystemPage = _PAGE_PLUGIN;
  250. //log_info("Wait Gun(%d) plugin",pSysInfo->CurGunSelected);
  251. DetectPluginStart();
  252. //log_info("Gun(%d) Balance: %f",pSysInfo->CurGunSelected,
  253. // ShmSelectGunInfo->PricesInfo[pSysInfo->CurGunSelected].Balance);
  254. } else {
  255. log_info("LCM => Authorize fail");
  256. //pSysInfo->SystemPage = _PAGE_AUTHORIZE_FAIL;
  257. strcpy((char *)pSysConfig->UserId, "");
  258. }
  259. }
  260. ClearAuthorizedFlag();
  261. }
  262. }
  263. void ScannerCardProcess(void)
  264. {
  265. struct SysConfigData *pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
  266. struct SysInfoData *pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
  267. struct WARNING_CODE_INFO *pSysWarning = (struct WARNING_CODE_INFO *)GetShmSysWarningInfo();
  268. struct ChargingInfoData *pDcChargingInfo = NULL;
  269. pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
  270. if (!isDetectPlugin() && pSysInfo->SystemPage == _PAGE_SENSING &&
  271. pDcChargingInfo->SystemStatus == S_IDLE &&
  272. pSysWarning->Level != WARN_LV_ER /*&&
  273. pSysConfig->AuthorisationMode == AUTH_MODE_ENABLE*/) {
  274. //setSelGunWaitToAuthor(pSysInfo->CurGunSelected);
  275. isCardScan = true;
  276. // 處理刷卡及驗證卡號的動作
  277. UserScanFunction();
  278. }
  279. if (pDcChargingInfo->SystemStatus == S_AUTHORIZING && pSysInfo->SystemPage == _PAGE_SENSING ) {
  280. AuthorizeToCharge();
  281. } else if (pSysInfo->SystemPage == _PAGE_AUTHORIZE_FAIL) {
  282. StartSystemTimeoutDet(Timeout_VerifyFail);
  283. isCardScan = false;
  284. } else if ( pSysInfo->SystemPage == _PAGE_PLUGIN) {
  285. StartSystemTimeoutDet(Timeout_WaitPlug);
  286. } else {
  287. isCardScan = false;
  288. }
  289. }
  290. static int InitialRfidPort(void)
  291. {
  292. int fd = open(rfidPortName, O_RDWR);
  293. struct termios tios;
  294. struct AlarmCodeData *pAlarmCode = (struct AlarmCodeData *)GetShmAlarmCodeData();
  295. if (fd != FAIL) {
  296. ioctl (fd, TCGETS, &tios);
  297. tios.c_cflag = B115200 | CS8 | CLOCAL | CREAD;
  298. tios.c_lflag = 0;
  299. tios.c_iflag = 0;
  300. tios.c_oflag = 0;
  301. tios.c_cc[VMIN] = 0;
  302. tios.c_cc[VTIME] = (uint8_t) 1;
  303. tios.c_lflag = 0;
  304. tcflush(fd, TCIFLUSH);
  305. ioctl(fd, TCSETS, &tios);
  306. }
  307. if (fd < 0) {
  308. pAlarmCode->AlarmEvents.bits.RfidModuleCommFail = 1;
  309. }
  310. return fd;
  311. }
  312. void CreateRfidFork(void)
  313. {
  314. pid_t rfidRecPid;
  315. rfidRecPid = fork();
  316. if (rfidRecPid == 0) {
  317. char localTime[128] = {0};
  318. struct timeb SeqEndTime;
  319. struct tm *tm;
  320. pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
  321. int fd = -1;
  322. int isContinue = 1;
  323. RFID rfid = {0};
  324. fd = InitialRfidPort();
  325. struct SysConfigData *pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
  326. ShmDcCommonData = (DcCommonInfo *)GetShmDcCommonData();
  327. //log_info("RFID fork Child's PID is %d", getpid());
  328. int result;
  329. while (isContinue) {
  330. result = 0;
  331. usleep(500000);
  332. ftime(&SeqEndTime);
  333. SeqEndTime.time = time(NULL);
  334. tm = localtime(&SeqEndTime.time);
  335. if (tm->tm_hour == 23 && tm->tm_min == 00 && tm->tm_sec == 0) {
  336. result = CreditCardUnionSettlement(fd,"TCC Test",&ShmDcCommonData->pCreditCard[0]);
  337. if (result > 0) {
  338. log_info("CreditCardUnionSettlement OK");
  339. log_info("Get Money:%s",ShmDcCommonData->pCreditCard[0].TransAmount);
  340. } else
  341. log_info("CreditCardUnionSettlement FAIL");
  342. }
  343. if (pSysInfo->SystemPage == _PAGE_AUTHORIZE) {
  344. //result = CreditCardSearch(fd,"TCC Test",&ShmDcCommonData->pCreditCard[pSysInfo->CurGunSelected]);
  345. result = 1;
  346. StartSystemTimeoutDet(Timeout_ScanCard);
  347. if (result > 0) {
  348. pSysInfo->SystemPage = _PAGE_SENSING;
  349. strcpy((char *)pSysConfig->UserId,"AutoStartCharging");
  350. //strncpy((char *)pSysConfig->UserId,ShmDcCommonData->pCreditCard[pSysInfo->CurGunSelected].CardNo,20);
  351. } else if (result < 0) {
  352. //pSysInfo->SystemPage = _PAGE_AUTHORIZE_FAIL;
  353. log_info("No Card Scanning...");
  354. }
  355. } else if (pSysInfo->SystemPage == _PAGE_SENSING) {
  356. result = CreditCardPreAuth(fd, PREAUTHMONEY,"TCC Test", &ShmDcCommonData->pCreditCard[pSysInfo->CurGunSelected]);
  357. //result = 1;
  358. if (result > 0) {
  359. ShmDcCommonData->AuthPass_flag[pSysInfo->CurGunSelected] = TRUE;
  360. pSysInfo->SystemPage = _PAGE_PLUGIN;
  361. //strncpy((char *)pSysConfig->UserId,ShmDcCommonData->pCreditCard[pSysInfo->CurGunSelected].CardNo,20);
  362. } else if (result < 0) {
  363. pSysInfo->SystemPage = _PAGE_AUTHORIZE_FAIL;
  364. ShmDcCommonData->AuthPass_flag[pSysInfo->CurGunSelected] = FALSE;
  365. memset(&ShmDcCommonData->pCreditCard[pSysInfo->CurGunSelected], 0, sizeof(TransInfo));
  366. }
  367. } else if (pSysInfo->SystemPage == _PAGE_PAYING) {
  368. result = CreditCardPreAuthComplete(fd, 1/*ShmDcCommonData->finalcost[pSysInfo->CurGunSelected]*/ ,"TCC Test",
  369. &ShmDcCommonData->pCreditCard[pSysInfo->CurGunSelected].VemData[0],
  370. &ShmDcCommonData->pCreditCard[pSysInfo->CurGunSelected]);
  371. //result = 1;
  372. if (result > 0 ) {
  373. log_info("Credit Card Spend Money:%d",ShmDcCommonData->finalcost[pSysInfo->CurGunSelected]);
  374. ShmDcCommonData->PayPass_flag[pSysInfo->CurGunSelected] = TRUE;
  375. pSysInfo->SystemPage = _PAGE_COMPLETE;
  376. /*
  377. result = CreditCardUnionSettlement(fd,"TCC Test",&ShmDcCommonData->pCreditCard[0]);
  378. if (result > 0) {
  379. log_info("CreditCardUnionSettlement OK");
  380. log_info("Get Money:%s",ShmDcCommonData->pCreditCard[0].TransAmount);
  381. } else
  382. log_info("CreditCardUnionSettlement FAIL");
  383. */
  384. } else {
  385. log_info("PAYING FAIL");
  386. ShmDcCommonData->PayPass_flag[pSysInfo->CurGunSelected] = FALSE;
  387. pSysInfo->SystemPage = _PAGE_PAYFAIL;
  388. }
  389. }
  390. if(ShmDcCommonData->PreAuth_Config == _CREDITCARD_CANCEL) {
  391. ShmDcCommonData->PreAuth_Result = CreditCardPreAuthCancel(fd,PREAUTHMONEY,"TCC Test",
  392. &ShmDcCommonData->pCreditCard[pSysInfo->CurGunSelected].ApprovalNo[0],
  393. &ShmDcCommonData->pCreditCard[pSysInfo->CurGunSelected].CardNo[0],
  394. &ShmDcCommonData->pCreditCard[pSysInfo->CurGunSelected].VemData[0]);
  395. if (ShmDcCommonData->PreAuth_Result > 0 ) {
  396. strcpy((char *)pSysConfig->UserId,"");
  397. log_info("Card Reader Stop");
  398. memset(&ShmDcCommonData->pCreditCard[pSysInfo->CurGunSelected], 0, sizeof(TransInfo));
  399. } else if (ShmDcCommonData->PreAuth_Result < 0) {
  400. log_info("Car Reader Stop Fail");
  401. }
  402. ShmDcCommonData->PreAuth_Config = _CREDITCARD_IDLE;
  403. }
  404. /*
  405. // 刷卡判斷
  406. if (pSysConfig->OfflinePolicy == _OFFLINE_POLICY_NO_CHARGING ||
  407. !pSysConfig->isRFID) {
  408. continue;
  409. }
  410. if (getRequestCardSN(fd, 0, &rfid) == false) {
  411. continue;
  412. }
  413. //log_info("Get Card..-%s- ", pSysConfig->UserId);
  414. if (strlen((char *)pSysConfig->UserId) != 0) {
  415. continue;
  416. }
  417. if (pSysConfig->RfidCardNumEndian == RFID_ENDIAN_LITTLE) {
  418. switch (rfid.snType) {
  419. case RFID_SN_TYPE_6BYTE:
  420. sprintf((char *) pSysConfig->UserId,
  421. "%02X%02X%02X%02X%02X%02X",
  422. rfid.currentCard[0], rfid.currentCard[1],
  423. rfid.currentCard[2], rfid.currentCard[3],
  424. rfid.currentCard[4], rfid.currentCard[5]);
  425. break;
  426. case RFID_SN_TYPE_7BYTE:
  427. sprintf((char *) pSysConfig->UserId,
  428. "%02X%02X%02X%02X%02X%02X%02X",
  429. rfid.currentCard[0], rfid.currentCard[1],
  430. rfid.currentCard[2], rfid.currentCard[3],
  431. rfid.currentCard[4], rfid.currentCard[5],
  432. rfid.currentCard[6]);
  433. break;
  434. case RFID_SN_TYPE_10BYTE:
  435. sprintf((char *) pSysConfig->UserId,
  436. "%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X",
  437. rfid.currentCard[0], rfid.currentCard[1],
  438. rfid.currentCard[2], rfid.currentCard[3],
  439. rfid.currentCard[4], rfid.currentCard[5],
  440. rfid.currentCard[6], rfid.currentCard[7],
  441. rfid.currentCard[8], rfid.currentCard[9]);
  442. break;
  443. case RFID_SN_TYPE_4BYTE:
  444. sprintf((char *) pSysConfig->UserId,
  445. "%02X%02X%02X%02X",
  446. rfid.currentCard[0], rfid.currentCard[1],
  447. rfid.currentCard[2], rfid.currentCard[3]);
  448. break;
  449. }
  450. } else if (pSysConfig->RfidCardNumEndian == RFID_ENDIAN_BIG) {
  451. switch (rfid.snType) {
  452. case RFID_SN_TYPE_6BYTE:
  453. sprintf((char *) pSysConfig->UserId,
  454. "%02X%02X%02X%02X%02X%02X",
  455. rfid.currentCard[5], rfid.currentCard[4],
  456. rfid.currentCard[3], rfid.currentCard[2],
  457. rfid.currentCard[1], rfid.currentCard[0]);
  458. break;
  459. case RFID_SN_TYPE_7BYTE:
  460. sprintf((char *) pSysConfig->UserId,
  461. "%02X%02X%02X%02X%02X%02X%02X",
  462. rfid.currentCard[6], rfid.currentCard[5],
  463. rfid.currentCard[4], rfid.currentCard[3],
  464. rfid.currentCard[2], rfid.currentCard[1],
  465. rfid.currentCard[0]);
  466. break;
  467. case RFID_SN_TYPE_10BYTE:
  468. sprintf((char *) pSysConfig->UserId,
  469. "%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X",
  470. rfid.currentCard[9], rfid.currentCard[8],
  471. rfid.currentCard[7], rfid.currentCard[6],
  472. rfid.currentCard[5], rfid.currentCard[4],
  473. rfid.currentCard[3], rfid.currentCard[2],
  474. rfid.currentCard[1], rfid.currentCard[0]);
  475. break;
  476. case RFID_SN_TYPE_4BYTE:
  477. sprintf((char *) pSysConfig->UserId,
  478. "%02X%02X%02X%02X",
  479. rfid.currentCard[3], rfid.currentCard[2],
  480. rfid.currentCard[1], rfid.currentCard[0]);
  481. break;
  482. }
  483. }
  484. log_info("card number = %s", pSysConfig->UserId);
  485. */
  486. }
  487. }
  488. }