RFID.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531
  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 2000
  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 && pDcChargingInfo->SystemStatus == S_IDLE) {
  208. log_info("// LCM => Authorizing");
  209. confirmSelGun(pSysInfo->CurGunSelected);
  210. setSelGunWaitToAuthor(pSysInfo->CurGunSelected);
  211. StartSystemTimeoutDet(Timeout_Authorizing);
  212. if (ShmDcCommonData->PreAuth_Config == _CREDITCARD_PREAUTH) {
  213. if (ShmDcCommonData->PreAuth_Result > 0) {
  214. pDcChargingInfo->SystemStatus = S_AUTHORIZING;
  215. AuthorizingStart();
  216. ShmDcCommonData->PreAuth_Config = _CREDITCARD_IDLE;
  217. } else if (ShmDcCommonData->PreAuth_Result < 0) {
  218. pSysInfo->SystemPage = _PAGE_AUTHORIZE_FAIL;
  219. ShmDcCommonData->PreAuth_Config = _CREDITCARD_CANCEL;
  220. ShmDcCommonData->PreAuth_Result = 0;
  221. }
  222. }
  223. // LCM => Authorizing
  224. //pSysInfo->SystemPage = _PAGE_AUTHORIZE;
  225. // 進入確認卡號狀態
  226. } else {
  227. //strcpy((char *)pSysConfig->UserId, "");
  228. }
  229. return;
  230. }
  231. bool GetIsCardScan(void)
  232. {
  233. return isCardScan;
  234. }
  235. void SetIsCardScan(bool value)
  236. {
  237. isCardScan = value;
  238. }
  239. void AuthorizeToCharge()
  240. {
  241. struct SysConfigData *pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
  242. struct SysInfoData *pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
  243. SelectGunInfo *ShmSelectGunInfo = (SelectGunInfo *)GetShmSelectGunInfo();
  244. struct ChargingInfoData *pDcChargingInfo = NULL;
  245. pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
  246. if(isAuthorizedComplete())
  247. {
  248. // StopSystemTimeoutDet();
  249. StartSystemTimeoutDet(Timeout_WaitBalance);
  250. if (ShmSelectGunInfo->PricesInfo[pSysInfo->CurGunSelected].Balance != FAIL_BALANCE_PRICES) {
  251. StopSystemTimeoutDet();
  252. // 判斷後台回覆狀態
  253. if (canStartCharging()) {
  254. // LCM => Authorize complete
  255. pDcChargingInfo->SystemStatus = S_AUTHORIZING;
  256. pSysInfo->SystemPage = _PAGE_PLUGIN;
  257. log_info("Wait Gun(%d) plugin",pSysInfo->CurGunSelected);
  258. DetectPluginStart();
  259. log_info("Gun(%d) Balance: %f",pSysInfo->CurGunSelected,
  260. ShmSelectGunInfo->PricesInfo[pSysInfo->CurGunSelected].Balance);
  261. } else {
  262. log_info("LCM => Authorize fail");
  263. //pSysInfo->SystemPage = _PAGE_AUTHORIZE_FAIL;
  264. strcpy((char *)pSysConfig->UserId, "");
  265. }
  266. }
  267. ClearAuthorizedFlag();
  268. }
  269. }
  270. void ScannerCardProcess(void)
  271. {
  272. struct SysConfigData *pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
  273. struct SysInfoData *pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
  274. struct WARNING_CODE_INFO *pSysWarning = (struct WARNING_CODE_INFO *)GetShmSysWarningInfo();
  275. struct ChargingInfoData *pDcChargingInfo = NULL;
  276. pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
  277. if (!isDetectPlugin() && pSysInfo->SystemPage == _PAGE_AUTHORIZE &&
  278. pDcChargingInfo->SystemStatus == S_IDLE &&
  279. pSysWarning->Level != WARN_LV_ER /*&&
  280. pSysConfig->AuthorisationMode == AUTH_MODE_ENABLE*/) {
  281. //setSelGunWaitToAuthor(pSysInfo->CurGunSelected);
  282. isCardScan = true;
  283. // 處理刷卡及驗證卡號的動作
  284. UserScanFunction();
  285. }
  286. if (pDcChargingInfo->SystemStatus == S_AUTHORIZING && pSysInfo->SystemPage == _PAGE_AUTHORIZE ) {
  287. AuthorizeToCharge();
  288. } else if (pSysInfo->SystemPage == _PAGE_AUTHORIZE_FAIL) {
  289. StartSystemTimeoutDet(Timeout_VerifyFail);
  290. isCardScan = false;
  291. } else if ( pSysInfo->SystemPage == _PAGE_PLUGIN) {
  292. StartSystemTimeoutDet(Timeout_WaitPlug);
  293. } else {
  294. isCardScan = false;
  295. }
  296. }
  297. static int InitialRfidPort(void)
  298. {
  299. int fd = open(rfidPortName, O_RDWR);
  300. struct termios tios;
  301. struct AlarmCodeData *pAlarmCode = (struct AlarmCodeData *)GetShmAlarmCodeData();
  302. if (fd != FAIL) {
  303. ioctl (fd, TCGETS, &tios);
  304. tios.c_cflag = B19200 | CS8 | CLOCAL | CREAD;
  305. tios.c_lflag = 0;
  306. tios.c_iflag = 0;
  307. tios.c_oflag = 0;
  308. tios.c_cc[VMIN] = 0;
  309. tios.c_cc[VTIME] = (uint8_t) 1;
  310. tios.c_lflag = 0;
  311. tcflush(fd, TCIFLUSH);
  312. ioctl(fd, TCSETS, &tios);
  313. }
  314. if (fd < 0) {
  315. pAlarmCode->AlarmEvents.bits.RfidModuleCommFail = 1;
  316. }
  317. return fd;
  318. }
  319. void CreateRfidFork(void)
  320. {
  321. pid_t rfidRecPid;
  322. rfidRecPid = fork();
  323. if (rfidRecPid == 0) {
  324. char localTime[128] = {0};
  325. struct timeb SeqEndTime;
  326. struct tm *tm;
  327. pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
  328. int fd = -1;
  329. int isContinue = 1;
  330. RFID rfid = {0};
  331. fd = InitialRfidPort();
  332. struct SysConfigData *pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
  333. ShmDcCommonData = (DcCommonInfo *)GetShmDcCommonData();
  334. //log_info("RFID fork Child's PID is %d", getpid());
  335. int result = 0;
  336. while (isContinue) {
  337. usleep(500000);
  338. ftime(&SeqEndTime);
  339. SeqEndTime.time = time(NULL);
  340. tm = localtime(&SeqEndTime.time);
  341. if (tm->tm_hour == 23 && tm->tm_min == 00 && result == 0) {
  342. result = CreditCardUnionSettlement(fd,"TCC Test",&ShmDcCommonData->pCreditCard[0]);
  343. if (result > 0) {
  344. log_info("CreditCardUnionSettlement OK");
  345. log_info("Get Money:%s",ShmDcCommonData->pCreditCard[0].TransAmount);
  346. } else
  347. log_info("CreditCardUnionSettlement FAIL");
  348. }
  349. if (ShmDcCommonData->PreAuth_Result != 0 && ShmDcCommonData->PreAuth_Config != _CREDITCARD_IDLE)
  350. continue;
  351. switch(ShmDcCommonData->PreAuth_Config) {
  352. case _CREDITCARD_IDLE:
  353. ShmDcCommonData->PreAuth_Result = 0;
  354. break;
  355. case _CREDITCARD_PREAUTH:
  356. ShmDcCommonData->PreAuth_Result = CreditCardPreAuth(fd, PREAUTHMONEY,"TCC Test", &ShmDcCommonData->pCreditCard[pSysInfo->CurGunSelected]);
  357. ShmDcCommonData->PreAuth_Result = 1;
  358. if (ShmDcCommonData->PreAuth_Result > 0 ) {
  359. //strncpy((char *)pSysConfig->UserId, (char *)ShmDcCommonData->pCreditCard[pSysInfo->CurGunSelected].CardNo,20);
  360. strcpy((char *)pSysConfig->UserId,"Ph Test");
  361. log_info("Credit Card Pass card number:%s",ShmDcCommonData->pCreditCard[pSysInfo->CurGunSelected].CardNo);
  362. } else if (ShmDcCommonData->PreAuth_Result < 0) {
  363. log_info("Credit Card Fail");
  364. pSysInfo->SystemPage = _PAGE_AUTHORIZE_FAIL;
  365. }
  366. break;
  367. case _CREDITCARD_PREAUTHCOMPLETE:
  368. ShmDcCommonData->PreAuth_Result = CreditCardPreAuthComplete(fd, ShmDcCommonData->finalcost[pSysInfo->CurGunSelected] ,"TCC Test",
  369. &ShmDcCommonData->pCreditCard[pSysInfo->CurGunSelected].VemData[0],
  370. &ShmDcCommonData->pCreditCard[pSysInfo->CurGunSelected]);
  371. if (ShmDcCommonData->PreAuth_Result > 0 ) {
  372. log_info("Credit Card Spend Money:%d",ShmDcCommonData->finalcost[pSysInfo->CurGunSelected]);
  373. } else {
  374. log_info("PAYING FAIL");
  375. }
  376. pSysInfo->SystemPage = _PAGE_COMPLETE;
  377. break;
  378. case _CREDITCARD_CANCEL:
  379. ShmDcCommonData->PreAuth_Result = CreditCardPreAuthCancel(fd,PREAUTHMONEY,"TCC Test",
  380. &ShmDcCommonData->pCreditCard[pSysInfo->CurGunSelected].ApprovalNo[0],
  381. &ShmDcCommonData->pCreditCard[pSysInfo->CurGunSelected].CardNo[0],
  382. &ShmDcCommonData->pCreditCard[pSysInfo->CurGunSelected].VemData[0]);
  383. if (ShmDcCommonData->PreAuth_Result > 0 ) {
  384. strcpy((char *)pSysConfig->UserId,"");
  385. log_info("Card Reader Stop");
  386. } else if (ShmDcCommonData->PreAuth_Result < 0) {
  387. log_info("Car Reader Stop Fail");
  388. }
  389. break;
  390. }
  391. /*
  392. // 刷卡判斷
  393. if (pSysConfig->OfflinePolicy == _OFFLINE_POLICY_NO_CHARGING ||
  394. !pSysConfig->isRFID) {
  395. continue;
  396. }
  397. if (getRequestCardSN(fd, 0, &rfid) == false) {
  398. continue;
  399. }
  400. //log_info("Get Card..-%s- ", pSysConfig->UserId);
  401. if (strlen((char *)pSysConfig->UserId) != 0) {
  402. continue;
  403. }
  404. if (pSysConfig->RfidCardNumEndian == RFID_ENDIAN_LITTLE) {
  405. switch (rfid.snType) {
  406. case RFID_SN_TYPE_6BYTE:
  407. sprintf((char *) pSysConfig->UserId,
  408. "%02X%02X%02X%02X%02X%02X",
  409. rfid.currentCard[0], rfid.currentCard[1],
  410. rfid.currentCard[2], rfid.currentCard[3],
  411. rfid.currentCard[4], rfid.currentCard[5]);
  412. break;
  413. case RFID_SN_TYPE_7BYTE:
  414. sprintf((char *) pSysConfig->UserId,
  415. "%02X%02X%02X%02X%02X%02X%02X",
  416. rfid.currentCard[0], rfid.currentCard[1],
  417. rfid.currentCard[2], rfid.currentCard[3],
  418. rfid.currentCard[4], rfid.currentCard[5],
  419. rfid.currentCard[6]);
  420. break;
  421. case RFID_SN_TYPE_10BYTE:
  422. sprintf((char *) pSysConfig->UserId,
  423. "%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X",
  424. rfid.currentCard[0], rfid.currentCard[1],
  425. rfid.currentCard[2], rfid.currentCard[3],
  426. rfid.currentCard[4], rfid.currentCard[5],
  427. rfid.currentCard[6], rfid.currentCard[7],
  428. rfid.currentCard[8], rfid.currentCard[9]);
  429. break;
  430. case RFID_SN_TYPE_4BYTE:
  431. sprintf((char *) pSysConfig->UserId,
  432. "%02X%02X%02X%02X",
  433. rfid.currentCard[0], rfid.currentCard[1],
  434. rfid.currentCard[2], rfid.currentCard[3]);
  435. break;
  436. }
  437. } else if (pSysConfig->RfidCardNumEndian == RFID_ENDIAN_BIG) {
  438. switch (rfid.snType) {
  439. case RFID_SN_TYPE_6BYTE:
  440. sprintf((char *) pSysConfig->UserId,
  441. "%02X%02X%02X%02X%02X%02X",
  442. rfid.currentCard[5], rfid.currentCard[4],
  443. rfid.currentCard[3], rfid.currentCard[2],
  444. rfid.currentCard[1], rfid.currentCard[0]);
  445. break;
  446. case RFID_SN_TYPE_7BYTE:
  447. sprintf((char *) pSysConfig->UserId,
  448. "%02X%02X%02X%02X%02X%02X%02X",
  449. rfid.currentCard[6], rfid.currentCard[5],
  450. rfid.currentCard[4], rfid.currentCard[3],
  451. rfid.currentCard[2], rfid.currentCard[1],
  452. rfid.currentCard[0]);
  453. break;
  454. case RFID_SN_TYPE_10BYTE:
  455. sprintf((char *) pSysConfig->UserId,
  456. "%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X",
  457. rfid.currentCard[9], rfid.currentCard[8],
  458. rfid.currentCard[7], rfid.currentCard[6],
  459. rfid.currentCard[5], rfid.currentCard[4],
  460. rfid.currentCard[3], rfid.currentCard[2],
  461. rfid.currentCard[1], rfid.currentCard[0]);
  462. break;
  463. case RFID_SN_TYPE_4BYTE:
  464. sprintf((char *) pSysConfig->UserId,
  465. "%02X%02X%02X%02X",
  466. rfid.currentCard[3], rfid.currentCard[2],
  467. rfid.currentCard[1], rfid.currentCard[0]);
  468. break;
  469. }
  470. }
  471. log_info("card number = %s", pSysConfig->UserId);
  472. */
  473. }
  474. }
  475. }