Module_EvComm.c 81 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717
  1. #include <sys/time.h>
  2. #include <sys/timeb.h>
  3. #include <sys/types.h>
  4. #include <sys/stat.h>
  5. #include <sys/types.h>
  6. #include <sys/ioctl.h>
  7. #include <sys/socket.h>
  8. #include <sys/ipc.h>
  9. #include <sys/shm.h>
  10. #include <sys/shm.h>
  11. #include <sys/mman.h>
  12. #include <linux/can.h>
  13. #include <linux/can/raw.h>
  14. #include <linux/wireless.h>
  15. #include <arpa/inet.h>
  16. #include <netinet/in.h>
  17. #include <unistd.h>
  18. #include <stdarg.h>
  19. #include <stdio.h> /*標準輸入輸出定義*/
  20. #include <stdlib.h> /*標準函數庫定義*/
  21. #include <unistd.h> /*Unix 標準函數定義*/
  22. #include <fcntl.h> /*檔控制定義*/
  23. #include <termios.h> /*PPSIX 終端控制定義*/
  24. #include <errno.h> /*錯誤號定義*/
  25. #include <errno.h>
  26. #include <string.h>
  27. #include <time.h>
  28. #include <ctype.h>
  29. #include <ifaddrs.h>
  30. #include "../../define.h"
  31. #include "Module_EvComm.h"
  32. #define ARRAY_SIZE(A) (sizeof(A) / sizeof(A[0]))
  33. #define PASS 1
  34. #define FAIL -1
  35. #define START 1
  36. #define STOP 0
  37. #define YES 1
  38. #define NO 0
  39. struct SysConfigAndInfo *ShmSysConfigAndInfo;
  40. struct StatusCodeData *ShmStatusCodeData;
  41. struct FanModuleData *ShmFanModuleData;
  42. struct CHAdeMOData *ShmCHAdeMOData;
  43. struct GBTData *ShmGBTData;
  44. struct CcsData *ShmCcsData;
  45. byte gun_count;
  46. int chargingTime[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
  47. float _pow_1 = 0;
  48. float _cur_1 = 0;
  49. float _pow_2 = 0;
  50. float _cur_2 = 0;
  51. // 限制最大充電電壓,因應不同 type 槍線來限制
  52. // Chademo : 500V, GB : 750, CCS : 950V
  53. float maxChargingVol[2] = { 5000, 9500 }; // 限制最大充電電壓,如依照模塊則填上 0
  54. // 限制最大充電電流與能量透過 Web
  55. float maxChargingCur[2] = { 1200, 1200 }; // 限制最大充電電流,如依照模塊則填上 0
  56. float maxChargingPow = 0; // 限制最大充電能量,如依照模塊則填上 0
  57. // 槍資訊
  58. struct ChargingInfoData *_chargingData[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
  59. struct Ev_Board_Cmd Ev_Cmd={
  60. 0,
  61. 0x00000200,
  62. 0x00000400,
  63. 0x00000500,
  64. 0x00000600,
  65. 0x00000700,
  66. 0x00000800,
  67. 0x00000900,
  68. 0x00000A00,
  69. 0x00000C00,
  70. 0x00000D00,
  71. 0x00000E00,
  72. 0x00000F00,
  73. 0x00001000,
  74. 0x00001100,
  75. 0x00001200,
  76. 0x00001400,
  77. 0x00001500,
  78. };
  79. unsigned char mask_table[] = { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 };
  80. void PRINTF_FUNC(char *string, ...);
  81. void GetMaxVolAndCurMethod(byte index, float *vol, float *cur);
  82. void GetMaxPowerMethod(float *pow);
  83. unsigned long GetTimeoutValue(struct timeval _sour_time);
  84. #define DEBUG_INFO(format, args...) StoreLogMsg("[%s:%d][%s][Info] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
  85. #define DEBUG_WARN(format, args...) StoreLogMsg("[%s:%d][%s][Warn] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
  86. #define DEBUG_ERROR(format, args...) StoreLogMsg("[%s:%d][%s][Error] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
  87. unsigned long GetTimeoutValue(struct timeval _sour_time)
  88. {
  89. struct timeval _end_time;
  90. gettimeofday(&_end_time, NULL);
  91. return 1000000 * (_end_time.tv_sec - _sour_time.tv_sec) + _end_time.tv_usec - _sour_time.tv_usec;
  92. }
  93. int StoreLogMsg(const char *fmt, ...)
  94. {
  95. char Buf[4096+256];
  96. char buffer[4096];
  97. time_t CurrentTime;
  98. struct tm *tm;
  99. va_list args;
  100. va_start(args, fmt);
  101. int rc = vsnprintf(buffer, sizeof(buffer), fmt, args);
  102. va_end(args);
  103. memset(Buf,0,sizeof(Buf));
  104. CurrentTime = time(NULL);
  105. tm=localtime(&CurrentTime);
  106. sprintf(Buf,"echo \"%04d-%02d-%02d %02d:%02d:%02d - %s\" >> /Storage/SystemLog/[%04d.%02d]SystemLog",
  107. tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec,
  108. buffer,
  109. tm->tm_year+1900,tm->tm_mon+1);
  110. system(Buf);
  111. return rc;
  112. }
  113. int DiffTimeb(struct timeb ST, struct timeb ET)
  114. {
  115. //return milli-second
  116. unsigned int StartTime,StopTime;
  117. StartTime=(unsigned int)ST.time;
  118. StopTime=(unsigned int)ET.time;
  119. return (StopTime-StartTime)*1000+ET.millitm-ST.millitm;
  120. }
  121. void PRINTF_FUNC(char *string, ...)
  122. {
  123. va_list args;
  124. char buffer[4096];
  125. va_start(args, string);
  126. vsnprintf(buffer, sizeof(buffer), string, args);
  127. va_end(args);
  128. if (ShmSysConfigAndInfo->SysConfig.SwitchDebugFlag == YES)
  129. printf("%s \n", buffer);
  130. else
  131. DEBUG_INFO("%s \n", buffer);
  132. }
  133. //=================================
  134. // Common routine
  135. //=================================
  136. void getTimeString(char *buff)
  137. {
  138. time_t timep;
  139. struct tm *p;
  140. time(&timep);
  141. p=gmtime(&timep);
  142. sprintf(buff, "[%04d-%02d-%02d %02d:%02d:%02d]", (1900+p->tm_year), (1+p->tm_mon), p->tm_mday, p->tm_hour, p->tm_hour, p->tm_sec);
  143. }
  144. bool CheckUniqNumber(byte value)
  145. {
  146. for (byte index = 0; index < gun_count; index++)
  147. {
  148. if (_chargingData[index]->Evboard_id == value)
  149. {
  150. struct timeval _end_time;
  151. gettimeofday(&_end_time, NULL);
  152. unsigned long diff = 1000000 * (_end_time.tv_sec - _id_assign_time.tv_sec) + _end_time.tv_usec - _id_assign_time.tv_usec;
  153. if (diff >= 3000000)
  154. {
  155. gettimeofday(&_id_assign_time, NULL);
  156. return true;
  157. }
  158. else
  159. {
  160. return false;
  161. }
  162. }
  163. }
  164. gettimeofday(&_id_assign_time, NULL);
  165. return true;
  166. }
  167. //==========================================
  168. // Init all share memory
  169. //==========================================
  170. int InitShareMemory()
  171. {
  172. int result = PASS;
  173. int MeterSMId;
  174. //initial ShmSysConfigAndInfo
  175. if ((MeterSMId = shmget(ShmSysConfigAndInfoKey, sizeof(struct SysConfigAndInfo), 0777)) < 0)
  176. {
  177. #ifdef SystemLogMessage
  178. DEBUG_ERROR("shmget ShmSysConfigAndInfo NG\n");
  179. #endif
  180. result = FAIL;
  181. }
  182. else if ((ShmSysConfigAndInfo = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  183. {
  184. #ifdef SystemLogMessage
  185. DEBUG_ERROR("shmat ShmSysConfigAndInfo NG\n");
  186. #endif
  187. result = FAIL;
  188. }
  189. else
  190. {}
  191. //initial ShmStatusCodeData
  192. if ((MeterSMId = shmget(ShmStatusCodeKey, sizeof(struct StatusCodeData), 0777)) < 0)
  193. {
  194. #ifdef SystemLogMessage
  195. DEBUG_ERROR("shmget ShmStatusCodeData NG\n");
  196. #endif
  197. result = FAIL;
  198. }
  199. else if ((ShmStatusCodeData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  200. {
  201. #ifdef SystemLogMessage
  202. DEBUG_ERROR("shmat ShmStatusCodeData NG\n");
  203. #endif
  204. result = FAIL;
  205. }
  206. else
  207. {}
  208. if(CHAdeMO_QUANTITY > 0)
  209. {
  210. if ((MeterSMId = shmget(ShmCHAdeMOCommKey, sizeof(struct CHAdeMOData), IPC_CREAT | 0777)) < 0)
  211. {
  212. #ifdef SystemLogMessage
  213. DEBUG_ERROR("[shmget ShmCHAdeMOData NG \n");
  214. #endif
  215. return FAIL;
  216. }
  217. else if ((ShmCHAdeMOData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  218. {
  219. #ifdef SystemLogMessage
  220. DEBUG_ERROR("shmat ShmCHAdeMOData NG \n");
  221. #endif
  222. return FAIL;
  223. }
  224. else
  225. {}
  226. }
  227. if(GB_QUANTITY > 0)
  228. {
  229. if ((MeterSMId = shmget(ShmGBTCommKey, sizeof(struct GBTData), IPC_CREAT | 0777)) < 0)
  230. {
  231. #ifdef SystemLogMessage
  232. DEBUG_ERROR("[shmget ShmGBTData NG \n");
  233. #endif
  234. return FAIL;
  235. }
  236. else if ((ShmGBTData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  237. {
  238. #ifdef SystemLogMessage
  239. DEBUG_ERROR("shmat ShmGBTData NG \n");
  240. #endif
  241. return FAIL;
  242. }
  243. else
  244. {}
  245. }
  246. if(CCS_QUANTITY > 0)
  247. {
  248. if ((MeterSMId = shmget(ShmCcsCommKey, sizeof(struct CcsData), IPC_CREAT | 0777)) < 0)
  249. {
  250. #ifdef SystemLogMessage
  251. DEBUG_ERROR("shmget ShmCcsData NG \n");
  252. #endif
  253. return FAIL;
  254. }
  255. else if ((ShmCcsData = shmat(MeterSMId, NULL, 0)) == (void *) -1) {
  256. #ifdef SystemLogMessage
  257. DEBUG_ERROR("shmat ShmCcsData NG \n");
  258. #endif
  259. return FAIL;
  260. }
  261. else
  262. {}
  263. }
  264. return result;
  265. }
  266. //================================================
  267. // initial can-bus
  268. //================================================
  269. int InitCanBus()
  270. {
  271. int s0,nbytes;
  272. struct timeval tv;
  273. struct ifreq ifr0;
  274. struct sockaddr_can addr0;
  275. system("/sbin/ip link set can0 down");
  276. system("/sbin/ip link set can0 type can bitrate 500000 restart-ms 100");
  277. system("/sbin/ip link set can0 up");
  278. s0 = socket(PF_CAN, SOCK_RAW, CAN_RAW);
  279. tv.tv_sec = 0;
  280. tv.tv_usec = 10000;
  281. if (setsockopt(s0, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof(struct timeval)) < 0)
  282. {
  283. #ifdef SystemLogMessage
  284. DEBUG_ERROR("Set SO_RCVTIMEO NG");
  285. #endif
  286. }
  287. nbytes=40960;
  288. if (setsockopt(s0, SOL_SOCKET, SO_RCVBUF, &nbytes, sizeof(int)) < 0)
  289. {
  290. #ifdef SystemLogMessage
  291. DEBUG_ERROR("Set SO_RCVBUF NG");
  292. #endif
  293. }
  294. nbytes=40960;
  295. if (setsockopt(s0, SOL_SOCKET, SO_SNDBUF, &nbytes, sizeof(int)) < 0)
  296. {
  297. #ifdef SystemLogMessage
  298. DEBUG_ERROR("Set SO_SNDBUF NG");
  299. #endif
  300. }
  301. strcpy(ifr0.ifr_name, "can0" );
  302. ioctl(s0, SIOCGIFINDEX, &ifr0); /* ifr.ifr_ifindex gets filled with that device's index */
  303. addr0.can_family = AF_CAN;
  304. addr0.can_ifindex = ifr0.ifr_ifindex;
  305. bind(s0, (struct sockaddr *)&addr0, sizeof(addr0));
  306. return s0;
  307. }
  308. //================================================
  309. //================================================
  310. // CANBUS receive task
  311. //================================================
  312. //================================================
  313. bool FindChargingInfoData(byte target, struct ChargingInfoData **chargingData)
  314. {
  315. for (byte index = 0; index < CHAdeMO_QUANTITY; index++)
  316. {
  317. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == target)
  318. {
  319. chargingData[target] = &ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index];
  320. return true;
  321. }
  322. }
  323. for (byte index = 0; index < CCS_QUANTITY; index++)
  324. {
  325. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == target)
  326. {
  327. chargingData[target] = &ShmSysConfigAndInfo->SysInfo.CcsChargingData[index];
  328. return true;
  329. }
  330. }
  331. for (byte index = 0; index < GB_QUANTITY; index++)
  332. {
  333. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == target)
  334. {
  335. chargingData[target] = &ShmSysConfigAndInfo->SysInfo.GbChargingData[index];
  336. return true;
  337. }
  338. }
  339. return false;
  340. }
  341. void AddrAssignment(byte *data)
  342. {
  343. byte target_number[8];
  344. byte index = 0x00;
  345. memcpy(target_number, data, sizeof(target_number));
  346. index = *(data + 4);
  347. if (gun_count == 1)
  348. index = 0x01;
  349. // if (CheckUniqNumber(index))
  350. {
  351. PRINTF_FUNC("EV board id = %x \n", index);
  352. // PRINTF_FUNC("target_number[0] = %x \n", target_number[0]);
  353. // PRINTF_FUNC("target_number[1] = %x \n", target_number[1]);
  354. // PRINTF_FUNC("target_number[2] = %x \n", target_number[2]);
  355. // PRINTF_FUNC("target_number[3] = %x \n", target_number[3]);
  356. // PRINTF_FUNC("target_number[4] = %x \n", target_number[4]);
  357. PRINTF_FUNC("SetTargetAddr = %d, type = %d \n", index, _chargingData[index - 1]->Type);
  358. SetTargetAddr(target_number, index);
  359. }
  360. }
  361. void ClearAbnormalStatus_Chademo(byte gun_index)
  362. {
  363. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoEvCommFail = 0x00;
  364. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBatteryMalfun = 0x00;
  365. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoNoPermission = 0x00;
  366. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBatteryIncompatibility = 0x00;
  367. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBatteryOVP = 0x00;
  368. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBatteryUVP = 0x00;
  369. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBatteryOTP = 0x00;
  370. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBatteryCurrentDiff = 0x00;
  371. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBatteryVoltageDiff = 0x00;
  372. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoShiftPosition = 0x00;
  373. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBatteryOtherFault = 0x00;
  374. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoChargingSystemError = 0x00;
  375. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoEvNormalStop = 0x00;
  376. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoTempSensorBroken = 0x00;
  377. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoConnectorLockFail = 0x00;
  378. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoD1OnNoReceive = 0x00;
  379. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBmsKtoJTimeout = 0x00;
  380. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBmsChargeAllowTimeout = 0x00;
  381. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoWaitGfdTimeout = 0x00;
  382. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBmsEvRelayTimeout = 0x00;
  383. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBmsReqCurrentTimeout = 0x00;
  384. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBmsKtoJOffTimeout = 0x00;
  385. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBmsEvRelayOffTimeout = 0x00;
  386. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoAdcMoreThan10V = 0x00;
  387. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoAdcMoreThan20V = 0x00;
  388. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBmsChargeBeforeStop = 0x00;
  389. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoChargerGetNormalStop = 0x00;
  390. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoChargerGetEmergencyStop = 0x00;
  391. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoIsolationResultFail = 0x00;
  392. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoMissLinkWithMotherBoard = 0x00;
  393. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoOutputVolMoreThanLimit = 0x00;
  394. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoReqCurrentMoreThanLimit = 0x00;
  395. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoReCapBmsEqrCurrentExceed = 0x00;
  396. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoChargeRemainCountDown = 0x00;
  397. }
  398. void ClearAbnormalStatus_GB(byte gun_index)
  399. {
  400. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_LOS_CC1 = 0x00;
  401. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_CONNECTOR_LOCK_FAIL = 0x00;
  402. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_BATTERY_INCOMPATIBLE = 0x00;
  403. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_BMS_BROAA_TIMEOUT = 0x00;
  404. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_CSU_PRECHARGE_TIMEOUT = 0x00;
  405. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_BMS_PRESENT_VOLTAGE_FAULT = 0x00;
  406. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_BMS_VOLTAGE_OVER_RANGE = 0x00;
  407. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_BSM_CHARGE_ALLOW_00_10MIN_COUUNTDONE = 0x00;
  408. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_WAIT_GROUNDFAULT_TIMEOUT = 0x00;
  409. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_ADC_MORE_THAN_10V = 0x00;
  410. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_ADC_MORE_THAN_60V = 0x00;
  411. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_CHARGER_GET_NORMAL_STOP_CMD = 0x00;
  412. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_CHARGER_GET_EMERGENCY_STOP_CMD = 0x00;
  413. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_ISOLATION_RESULT_FAIL = 0x00;
  414. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_MOTHER_BOARD_MISS_LINK = 0x00;
  415. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_OUTPUT_VOLTAGE_MORE_THAN_LIMIT = 0x00;
  416. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_REQ_CURRENT_MORE_THAN_LIMIT = 0x00;
  417. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_OUTPUT_VOLTAGE_MORE_THAN_10_PERCENT = 0x00;
  418. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_OUTPUT_VOLTAGE_DIFF_BCS_5_PERCENT = 0x00;
  419. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_STOP_ADC_MORE_THAN_10V = 0x00;
  420. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_CEM_BHM_TIMEOUT = 0x00;
  421. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_CEM_BRM_TIMEOUT = 0x00;
  422. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_CEM_BCP_TIMEOUT = 0x00;
  423. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_CEM_BRO_TIMEOUT = 0x00;
  424. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_CEM_BCL_TIMEOUT = 0x00;
  425. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_CEM_BCS_TIMEOUT = 0x00;
  426. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_CEM_BSM_TIMEOUT = 0x00;
  427. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_CEM_BST_TIMEOUT = 0x00;
  428. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_CEM_BSD_TIMEOUT = 0x00;
  429. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_CEM_BEM_OTHER_TIMEOUT = 0x00;
  430. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BEM_CRM_TIMEOUT = 0x00;
  431. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BEM_CRMAA_TIMEOUT = 0x00;
  432. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BEM_CTS_CML_TIMEOUT = 0x00;
  433. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BEM_CRO_TIMEOUT = 0x00;
  434. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BEM_CCS_TIMEOUT = 0x00;
  435. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BEM_CST_TIMEOUT = 0x00;
  436. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BEM_CSD_TIMEOUT = 0x00;
  437. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BEM_BEM_OTHER_TIMEOUT = 0x00;
  438. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_SOC_GOAL = 0x00;
  439. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_TOTAL_VOLTAGE_GOAL = 0x00;
  440. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_CELL_VOLTAGE_GOAL = 0x00;
  441. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_GET_CST = 0x00;
  442. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_ISOLATION = 0x00;
  443. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_OUTPUT_CONNECTOR_OTP = 0x00;
  444. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_COMPONENT = 0x00;
  445. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_CHARGE_CONNECTOR = 0x00;
  446. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_OTP = 0x00;
  447. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_OTHER = 0x00;
  448. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_HIGH_V = 0x00;
  449. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_CC2 = 0x00;
  450. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_CURRENT = 0x00;
  451. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_VOLTAGE = 0x00;
  452. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GET_BST_NO_REASON = 0x00;
  453. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BSM_CELL_OVER_VOLTAGE = 0x00;
  454. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BSM_CELL_UNDER_VOLTAGE = 0x00;
  455. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BSM_OVER_SOC = 0x00;
  456. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BSM_UNDER_SOC = 0x00;
  457. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BSM_CURRENT = 0x00;
  458. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BSM_TEMPERATURE = 0x00;
  459. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BSM_ISOLATE = 0x00;
  460. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BSM_OUTPUT_CONNECTOR = 0x00;
  461. }
  462. void ClearAbnormalStatus_CCS(byte gun_index)
  463. {
  464. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsRESTemperatureInhibit = 0x00;
  465. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsEVShiftPosition = 0x00;
  466. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsChargerConnectorLockFault = 0x00;
  467. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsEVRESSMalfunction = 0x00;
  468. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsChargingCurrentdifferential = 0x00;
  469. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsChargingVoltageOutOfRange = 0x00;
  470. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsChargingSystemIncompatibility = 0x00;
  471. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsEmergencyEvent = 0x00;
  472. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsBreaker = 0x00;
  473. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsNoData = 0x00;
  474. ShmStatusCodeData->InfoCode.InfoEvents.bits.Ccsreserved_by_DIN_A = 0x00;
  475. ShmStatusCodeData->InfoCode.InfoEvents.bits.Ccsreserved_by_DIN_B = 0x00;
  476. ShmStatusCodeData->InfoCode.InfoEvents.bits.Ccsreserved_by_DIN_C = 0x00;
  477. ShmStatusCodeData->InfoCode.InfoEvents.bits.Ccsreserved_by_ISO_1 = 0x00;
  478. ShmStatusCodeData->InfoCode.InfoEvents.bits.Ccsreserved_by_ISO_2 = 0x00;
  479. ShmStatusCodeData->InfoCode.InfoEvents.bits.Ccsreserved_by_ISO_3 = 0x00;
  480. ShmStatusCodeData->InfoCode.InfoEvents.bits.Ccsreserved_by_OEM_1 = 0x00;
  481. ShmStatusCodeData->InfoCode.InfoEvents.bits.Ccsreserved_by_OEM_2 = 0x00;
  482. ShmStatusCodeData->InfoCode.InfoEvents.bits.Ccsreserved_by_OEM_3 = 0x00;
  483. ShmStatusCodeData->InfoCode.InfoEvents.bits.Ccsreserved_by_OEM_4 = 0x00;
  484. ShmStatusCodeData->InfoCode.InfoEvents.bits.Ccsreserved_by_OEM_5 = 0x00;
  485. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsSequenceError = 0x00;
  486. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsSignatureError = 0x00;
  487. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsUnknownSession = 0x00;
  488. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsServiceIDInvalid = 0x00;
  489. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsPaymentSelectionInvalid = 0x00;
  490. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsIdentificationSelectionInvalid = 0x00;
  491. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsServiceSelectionInvalid = 0x00;
  492. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCertificateExpired = 0x00;
  493. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCertificateNotYetValid = 0x00;
  494. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCertificateRevoked = 0x00;
  495. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsNoCertificateAvailable = 0x00;
  496. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCertChainError = 0x00;
  497. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCertValidationError = 0x00;
  498. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCertVerificationError = 0x00;
  499. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsContractCanceled = 0x00;
  500. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsChallengeInvalid = 0x00;
  501. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsWrongEnergyTransferMode = 0x00;
  502. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsWrongChargeParameter = 0x00;
  503. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsChargingProfileInvalid = 0x00;
  504. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTariffSelectionInvalid = 0x00;
  505. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsEVSEPresentVoltageToLow = 0x00;
  506. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsPowerDeliveryNotApplied = 0x00;
  507. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsMeteringSignatureNotValid = 0x00;
  508. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsNoChargeServiceSelected = 0x00;
  509. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsContactorError = 0x00;
  510. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCertificateNotAllowedAtThisEVSE = 0x00;
  511. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsGAChargeStop = 0x00;
  512. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsAlignmentError = 0x00;
  513. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsACDError = 0x00;
  514. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsAssociationError = 0x00;
  515. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsEVSEChargeAbort = 0x00;
  516. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsNoSupportedAppProtocol = 0x00;
  517. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsContractNotAccepted = 0x00;
  518. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsMOUnknown = 0x00;
  519. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsOEM_Prov_CertificateRevoke = 0x00;
  520. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsOEM_SubCA1_CertificateRevoked = 0x00;
  521. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsOEM_SubCA2_CertificateRevoked = 0x00;
  522. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsOEM_RootCA_CertificateRevoked = 0x00;
  523. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsMO_Prov_CertificateRevoked = 0x00;
  524. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsMO_SubCA1_CertificateRevoked = 0x00;
  525. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsMO_SubCA2_CertificateRevoked = 0x00;
  526. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsMO_RootCA_CertificateRevoked = 0x00;
  527. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCPS_Prov_CertificateRevoked = 0x00;
  528. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCPS_SubCA1_CertificateRevoked = 0x00;
  529. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCPS_SubCA2_CertificateRevoked = 0x00;
  530. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCPS_RootCA_CertificateRevoked = 0x00;
  531. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_EVSE_SLAC_init = 0x00;
  532. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_match_response = 0x00;
  533. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_match_sequence = 0x00;
  534. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_EVSE_match_MNBC = 0x00;
  535. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_EVSE_avg_atten_calc = 0x00;
  536. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_match_response = 0x00;
  537. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_EVSE_match_session = 0x00;
  538. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_EVSE_assoc_session = 0x00;
  539. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_EVSE_vald_toggle = 0x00;
  540. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsUDP_TT_match_join = 0x00;
  541. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTCP_TT_match_join = 0x00;
  542. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_amp_map_exchange = 0x00;
  543. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_link_ready_notification = 0x00;
  544. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsSupportedAppProtocolRes = 0x00;
  545. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsSessionSetupRes = 0x00;
  546. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsServiceDiscoveryRes = 0x00;
  547. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsServicePaymentSelectionRes = 0x00;
  548. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsContractAuthenticationRes = 0x00;
  549. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsChargeParameterDiscoveryRes = 0x00;
  550. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsPowerDeliveryRes = 0x00;
  551. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCableCheckRes = 0x00;
  552. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsPreChargeRes = 0x00;
  553. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCurrentDemandRes = 0x00;
  554. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsWeldingDetectionRes = 0x00;
  555. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsSessionStopRes = 0x00;
  556. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsSequence_Time = 0x00;
  557. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsReadyToCharge_Performance_Time = 0x00;
  558. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCommunicationSetup_Performance_Time = 0x00;
  559. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCableCheck_Performance_Time = 0x00;
  560. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCPState_Detection_Time = 0x00;
  561. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCPOscillator_Retain_Time = 0x00;
  562. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_GET_EV_TARGET_INFO = 0x00;
  563. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_GET_EV_TARGET_INFO = 0x00;
  564. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_GET_EV_BATTERY_INFO = 0x00;
  565. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_GET_EV_BATTERY_INFO = 0x00;
  566. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_EV_STOP_EVENT = 0x00;
  567. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_EV_STOP_EVENT = 0x00;
  568. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_EVSE_STOP_EVENT = 0x00;
  569. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_EVSE_STOP_EVENT = 0x00;
  570. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_GET_MISC_INFO = 0x00;
  571. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_GET_MISC_INFO = 0x00;
  572. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_DOWNLOAD_REQUEST = 0x00;
  573. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_DOWNLOAD_REQUEST = 0x00;
  574. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_START_BLOCK_TRANSFER = 0x00;
  575. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_START_BLOCK_TRANSFER = 0x00;
  576. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_DATA_TRANSFER = 0x00;
  577. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_DATA_TRANSFER = 0x00;
  578. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_DOWNLOAD_FINISH = 0x00;
  579. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_DOWNLOAD_FINISH = 0x00;
  580. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_ISOLATION_STATUS = 0x00;
  581. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_ISOLATION_STATUS = 0x00;
  582. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_CONNECTOR_INFO = 0x00;
  583. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_CONNECTOR_INFO = 0x00;
  584. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_RTC_INFO = 0x00;
  585. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_RTC_INFO = 0x00;
  586. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_EVSE_PRECHARGE_INFO = 0x00;
  587. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_EVSE_PRECHARGE_INFO = 0x00;
  588. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsMSG_Sequence = 0x00;
  589. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCAN_MSG_Unrecognized_CMD_ID = 0x00;
  590. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsDIN_Msg_Decode_Error = 0x00;
  591. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsDIN_Msg_Encode_Error = 0x00;
  592. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsISO1_Msg_Decode_Error = 0x00;
  593. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsISO1_Msg_Encode_Error = 0x00;
  594. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsISO2_Msg_Decode_Error = 0x00;
  595. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsISO2_Msg_Encode_Error = 0x00;
  596. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCpStatus_Error = 0x00;
  597. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsUnexpectVolBeforeCharing_Error = 0x00;
  598. }
  599. void AbnormalStopAnalysis(byte gun_index, byte *errCode)
  600. {
  601. char string[7];
  602. sprintf(string, "%d%d%d%d%d%d", *(errCode + 0), *(errCode + 1), *(errCode + 2), *(errCode + 3), *(errCode + 4), *(errCode + 5));
  603. PRINTF_FUNC("NOTIFICATION_EV_STOP : Err Code = %s \n", string);
  604. if (strcmp(string, "023700") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoEvCommFail = 0x01;
  605. if (strcmp(string, "023704") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBatteryMalfun = 0x01;
  606. if (strcmp(string, "023705") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoNoPermission = 0x01;
  607. if (strcmp(string, "023706") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBatteryIncompatibility = 0x01;
  608. if (strcmp(string, "023707") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBatteryOVP = 0x01;
  609. if (strcmp(string, "023708") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBatteryUVP = 0x01;
  610. if (strcmp(string, "023709") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBatteryOTP = 0x01;
  611. if (strcmp(string, "023710") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBatteryCurrentDiff = 0x01;
  612. if (strcmp(string, "023711") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBatteryVoltageDiff = 0x01;
  613. if (strcmp(string, "023712") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoShiftPosition = 0x01;
  614. if (strcmp(string, "023713") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBatteryOtherFault = 0x01;
  615. if (strcmp(string, "023714") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoChargingSystemError = 0x01;
  616. if (strcmp(string, "023715") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoEvNormalStop = 0x01;
  617. if (strcmp(string, "023716") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoTempSensorBroken = 0x01;
  618. if (strcmp(string, "023717") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoConnectorLockFail = 0x01;
  619. if (strcmp(string, "023718") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoD1OnNoReceive = 0x01;
  620. if (strcmp(string, "023719") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBmsKtoJTimeout = 0x01;
  621. if (strcmp(string, "023720") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBmsChargeAllowTimeout = 0x01;
  622. if (strcmp(string, "023721") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoWaitGfdTimeout = 0x01;
  623. if (strcmp(string, "023722") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBmsEvRelayTimeout = 0x01;
  624. if (strcmp(string, "023723") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBmsReqCurrentTimeout = 0x01;
  625. if (strcmp(string, "023724") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBmsKtoJOffTimeout = 0x01;
  626. if (strcmp(string, "023725") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBmsEvRelayOffTimeout = 0x01;
  627. if (strcmp(string, "023726") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoAdcMoreThan10V = 0x01;
  628. if (strcmp(string, "023727") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoAdcMoreThan20V = 0x01;
  629. if (strcmp(string, "023728") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBmsChargeBeforeStop = 0x01;
  630. if (strcmp(string, "023729") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoChargerGetNormalStop = 0x01;
  631. if (strcmp(string, "023730") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoChargerGetEmergencyStop = 0x01;
  632. if (strcmp(string, "023731") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoIsolationResultFail = 0x01;
  633. if (strcmp(string, "023732") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoMissLinkWithMotherBoard = 0x01;
  634. if (strcmp(string, "023733") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoOutputVolMoreThanLimit = 0x01;
  635. if (strcmp(string, "023734") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoReqCurrentMoreThanLimit = 0x01;
  636. if (strcmp(string, "023735") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoReCapBmsEqrCurrentExceed = 0x01;
  637. if (strcmp(string, "023736") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoChargeRemainCountDown = 0x01;
  638. if (strcmp(string, "023701") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsEvCommFail = 0x01;
  639. if (strcmp(string, "023737") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsRESTemperatureInhibit = 0x01;
  640. if (strcmp(string, "023738") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsEVShiftPosition = 0x01;
  641. if (strcmp(string, "023739") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsChargerConnectorLockFault = 0x01;
  642. if (strcmp(string, "023740") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsEVRESSMalfunction = 0x01;
  643. if (strcmp(string, "023741") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsChargingCurrentdifferential = 0x01;
  644. if (strcmp(string, "023742") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsChargingVoltageOutOfRange = 0x01;
  645. if (strcmp(string, "023743") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsChargingSystemIncompatibility = 0x01;
  646. if (strcmp(string, "023744") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsEmergencyEvent = 0x01;
  647. if (strcmp(string, "023745") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsBreaker = 0x01;
  648. if (strcmp(string, "023746") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsNoData = 0x01;
  649. if (strcmp(string, "023747") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.Ccsreserved_by_DIN_A = 0x01;
  650. if (strcmp(string, "023748") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.Ccsreserved_by_DIN_B = 0x01;
  651. if (strcmp(string, "023749") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.Ccsreserved_by_DIN_C = 0x01;
  652. if (strcmp(string, "023750") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.Ccsreserved_by_ISO_1 = 0x01;
  653. if (strcmp(string, "023751") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.Ccsreserved_by_ISO_2 = 0x01;
  654. if (strcmp(string, "023752") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.Ccsreserved_by_ISO_3 = 0x01;
  655. if (strcmp(string, "023753") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.Ccsreserved_by_OEM_1 = 0x01;
  656. if (strcmp(string, "023754") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.Ccsreserved_by_OEM_2 = 0x01;
  657. if (strcmp(string, "023755") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.Ccsreserved_by_OEM_3 = 0x01;
  658. if (strcmp(string, "023756") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.Ccsreserved_by_OEM_4 = 0x01;
  659. if (strcmp(string, "023757") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.Ccsreserved_by_OEM_5 = 0x01;
  660. if (strcmp(string, "023758") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsSequenceError = 0x01;
  661. if (strcmp(string, "023759") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsSignatureError = 0x01;
  662. if (strcmp(string, "023760") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsUnknownSession = 0x01;
  663. if (strcmp(string, "023761") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsServiceIDInvalid = 0x01;
  664. if (strcmp(string, "023762") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsPaymentSelectionInvalid = 0x01;
  665. if (strcmp(string, "023763") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsIdentificationSelectionInvalid = 0x01;
  666. if (strcmp(string, "023764") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsServiceSelectionInvalid = 0x01;
  667. if (strcmp(string, "023765") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCertificateExpired = 0x01;
  668. if (strcmp(string, "023766") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCertificateNotYetValid = 0x01;
  669. if (strcmp(string, "023767") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCertificateRevoked = 0x01;
  670. if (strcmp(string, "023768") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsNoCertificateAvailable = 0x01;
  671. if (strcmp(string, "023769") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCertChainError = 0x01;
  672. if (strcmp(string, "023770") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCertValidationError = 0x01;
  673. if (strcmp(string, "023771") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCertVerificationError = 0x01;
  674. if (strcmp(string, "023772") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsContractCanceled = 0x01;
  675. if (strcmp(string, "023773") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsChallengeInvalid = 0x01;
  676. if (strcmp(string, "023774") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsWrongEnergyTransferMode = 0x01;
  677. if (strcmp(string, "023775") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsWrongChargeParameter = 0x01;
  678. if (strcmp(string, "023776") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsChargingProfileInvalid = 0x01;
  679. if (strcmp(string, "023777") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTariffSelectionInvalid = 0x01;
  680. if (strcmp(string, "023778") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsEVSEPresentVoltageToLow = 0x01;
  681. if (strcmp(string, "023779") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsPowerDeliveryNotApplied = 0x01;
  682. if (strcmp(string, "023780") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsMeteringSignatureNotValid = 0x01;
  683. if (strcmp(string, "023781") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsNoChargeServiceSelected = 0x01;
  684. if (strcmp(string, "023782") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsContactorError = 0x01;
  685. if (strcmp(string, "023783") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCertificateNotAllowedAtThisEVSE = 0x01;
  686. if (strcmp(string, "023784") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsGAChargeStop = 0x01;
  687. if (strcmp(string, "023785") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsAlignmentError = 0x01;
  688. if (strcmp(string, "023786") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsACDError = 0x01;
  689. if (strcmp(string, "023787") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsAssociationError = 0x01;
  690. if (strcmp(string, "023788") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsEVSEChargeAbort = 0x01;
  691. if (strcmp(string, "023789") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsNoSupportedAppProtocol = 0x01;
  692. if (strcmp(string, "023790") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsContractNotAccepted = 0x01;
  693. if (strcmp(string, "023791") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsMOUnknown = 0x01;
  694. if (strcmp(string, "023792") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsOEM_Prov_CertificateRevoke = 0x01;
  695. if (strcmp(string, "023793") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsOEM_SubCA1_CertificateRevoked = 0x01;
  696. if (strcmp(string, "023794") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsOEM_SubCA2_CertificateRevoked = 0x01;
  697. if (strcmp(string, "023795") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsOEM_RootCA_CertificateRevoked = 0x01;
  698. if (strcmp(string, "023796") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsMO_Prov_CertificateRevoked = 0x01;
  699. if (strcmp(string, "023797") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsMO_SubCA1_CertificateRevoked = 0x01;
  700. if (strcmp(string, "023798") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsMO_SubCA2_CertificateRevoked = 0x01;
  701. if (strcmp(string, "023799") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsMO_RootCA_CertificateRevoked = 0x01;
  702. if (strcmp(string, "023800") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCPS_Prov_CertificateRevoked = 0x01;
  703. if (strcmp(string, "023801") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCPS_SubCA1_CertificateRevoked = 0x01;
  704. if (strcmp(string, "023802") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCPS_SubCA2_CertificateRevoked = 0x01;
  705. if (strcmp(string, "023803") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCPS_RootCA_CertificateRevoked = 0x01;
  706. if (strcmp(string, "023809") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_EVSE_SLAC_init = 0x01;
  707. if (strcmp(string, "023810") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_match_response = 0x01;
  708. if (strcmp(string, "023811") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_match_sequence = 0x01;
  709. if (strcmp(string, "023812") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_EVSE_match_MNBC = 0x01;
  710. if (strcmp(string, "023813") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_EVSE_avg_atten_calc = 0x01;
  711. if (strcmp(string, "023814") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_match_response = 0x01;
  712. if (strcmp(string, "023815") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_EVSE_match_session = 0x01;
  713. if (strcmp(string, "023816") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_EVSE_assoc_session = 0x01;
  714. if (strcmp(string, "023817") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_EVSE_vald_toggle = 0x01;
  715. if (strcmp(string, "023823") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsUDP_TT_match_join = 0x01;
  716. if (strcmp(string, "023824") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTCP_TT_match_join = 0x01;
  717. if (strcmp(string, "023825") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_amp_map_exchange = 0x01;
  718. if (strcmp(string, "023826") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_link_ready_notification = 0x01;
  719. if (strcmp(string, "023832") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsSupportedAppProtocolRes = 0x01;
  720. if (strcmp(string, "023833") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsSessionSetupRes = 0x01;
  721. if (strcmp(string, "023834") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsServiceDiscoveryRes = 0x01;
  722. if (strcmp(string, "023835") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsServicePaymentSelectionRes = 0x01;
  723. if (strcmp(string, "023836") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsContractAuthenticationRes = 0x01;
  724. if (strcmp(string, "023837") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsChargeParameterDiscoveryRes = 0x01;
  725. if (strcmp(string, "023838") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsPowerDeliveryRes = 0x01;
  726. if (strcmp(string, "023839") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCableCheckRes = 0x01;
  727. if (strcmp(string, "023840") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsPreChargeRes = 0x01;
  728. if (strcmp(string, "023841") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCurrentDemandRes = 0x01;
  729. if (strcmp(string, "023842") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsWeldingDetectionRes = 0x01;
  730. if (strcmp(string, "023843") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsSessionStopRes = 0x01;
  731. if (strcmp(string, "023844") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsSequence_Time = 0x01;
  732. if (strcmp(string, "023845") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsReadyToCharge_Performance_Time = 0x01;
  733. if (strcmp(string, "023846") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCommunicationSetup_Performance_Time = 0x01;
  734. if (strcmp(string, "023847") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCableCheck_Performance_Time = 0x01;
  735. if (strcmp(string, "023848") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCPState_Detection_Time = 0x01;
  736. if (strcmp(string, "023849") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCPOscillator_Retain_Time = 0x01;
  737. if (strcmp(string, "023855") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_GET_EV_TARGET_INFO = 0x01;
  738. if (strcmp(string, "023856") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_GET_EV_TARGET_INFO = 0x01;
  739. if (strcmp(string, "023857") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_GET_EV_BATTERY_INFO = 0x01;
  740. if (strcmp(string, "023858") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_GET_EV_BATTERY_INFO = 0x01;
  741. if (strcmp(string, "023859") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_EV_STOP_EVENT = 0x01;
  742. if (strcmp(string, "023860") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_EV_STOP_EVENT = 0x01;
  743. if (strcmp(string, "023861") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_EVSE_STOP_EVENT = 0x01;
  744. if (strcmp(string, "023862") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_EVSE_STOP_EVENT = 0x01;
  745. if (strcmp(string, "023863") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_GET_MISC_INFO = 0x01;
  746. if (strcmp(string, "023864") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_GET_MISC_INFO = 0x01;
  747. if (strcmp(string, "023865") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_DOWNLOAD_REQUEST = 0x01;
  748. if (strcmp(string, "023866") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_DOWNLOAD_REQUEST = 0x01;
  749. if (strcmp(string, "023867") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_START_BLOCK_TRANSFER = 0x01;
  750. if (strcmp(string, "023868") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_START_BLOCK_TRANSFER = 0x01;
  751. if (strcmp(string, "023869") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_DATA_TRANSFER = 0x01;
  752. if (strcmp(string, "023870") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_DATA_TRANSFER = 0x01;
  753. if (strcmp(string, "023871") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_DOWNLOAD_FINISH = 0x01;
  754. if (strcmp(string, "023872") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_DOWNLOAD_FINISH = 0x01;
  755. if (strcmp(string, "023873") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_ISOLATION_STATUS = 0x01;
  756. if (strcmp(string, "023874") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_ISOLATION_STATUS = 0x01;
  757. if (strcmp(string, "023875") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_CONNECTOR_INFO = 0x01;
  758. if (strcmp(string, "023876") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_CONNECTOR_INFO = 0x01;
  759. if (strcmp(string, "023877") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_RTC_INFO = 0x01;
  760. if (strcmp(string, "023878") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_RTC_INFO = 0x01;
  761. if (strcmp(string, "023879") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_EVSE_PRECHARGE_INFO = 0x01;
  762. if (strcmp(string, "023880") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_EVSE_PRECHARGE_INFO = 0x01;
  763. if (strcmp(string, "023881") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsMSG_Sequence = 0x01;
  764. if (strcmp(string, "023882") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCAN_MSG_Unrecognized_CMD_ID = 0x01;
  765. if (strcmp(string, "023883") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsDIN_Msg_Decode_Error = 0x01;
  766. if (strcmp(string, "023884") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsDIN_Msg_Encode_Error = 0x01;
  767. if (strcmp(string, "023885") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsISO1_Msg_Decode_Error = 0x01;
  768. if (strcmp(string, "023886") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsISO1_Msg_Encode_Error = 0x01;
  769. if (strcmp(string, "023887") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsISO2_Msg_Decode_Error = 0x01;
  770. if (strcmp(string, "023888") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsISO2_Msg_Encode_Error = 0x01;
  771. if (strcmp(string, "023889") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCpStatus_Error = 0x01;
  772. if (strcmp(string, "023890") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsUnexpectVolBeforeCharing_Error = 0x01;
  773. if (strcmp(string, "023702") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.GbEvCommFail = 0x01;
  774. if (strcmp(string, "023900") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_LOS_CC1 = 0x01;
  775. if (strcmp(string, "023901") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_CONNECTOR_LOCK_FAIL = 0x01;
  776. if (strcmp(string, "023902") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_BATTERY_INCOMPATIBLE = 0x01;
  777. if (strcmp(string, "023903") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_BMS_BROAA_TIMEOUT = 0x01;
  778. if (strcmp(string, "023904") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_CSU_PRECHARGE_TIMEOUT = 0x01;
  779. if (strcmp(string, "023905") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_BMS_PRESENT_VOLTAGE_FAULT = 0x01;
  780. if (strcmp(string, "023906") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_BMS_VOLTAGE_OVER_RANGE = 0x01;
  781. if (strcmp(string, "023907") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_BSM_CHARGE_ALLOW_00_10MIN_COUUNTDONE = 0x01;
  782. if (strcmp(string, "023908") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_WAIT_GROUNDFAULT_TIMEOUT = 0x01;
  783. if (strcmp(string, "023909") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_ADC_MORE_THAN_10V = 0x01;
  784. if (strcmp(string, "023910") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_ADC_MORE_THAN_60V = 0x01;
  785. if (strcmp(string, "023911") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_CHARGER_GET_NORMAL_STOP_CMD = 0x01;
  786. if (strcmp(string, "023912") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_CHARGER_GET_EMERGENCY_STOP_CMD = 0x01;
  787. if (strcmp(string, "023913") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_ISOLATION_RESULT_FAIL = 0x01;
  788. if (strcmp(string, "023914") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_MOTHER_BOARD_MISS_LINK = 0x01;
  789. if (strcmp(string, "023915") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_OUTPUT_VOLTAGE_MORE_THAN_LIMIT = 0x01;
  790. if (strcmp(string, "023916") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_REQ_CURRENT_MORE_THAN_LIMIT = 0x01;
  791. if (strcmp(string, "023917") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_OUTPUT_VOLTAGE_MORE_THAN_10_PERCENT = 0x01;
  792. if (strcmp(string, "023918") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_OUTPUT_VOLTAGE_DIFF_BCS_5_PERCENT = 0x01;
  793. if (strcmp(string, "023919") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_STOP_ADC_MORE_THAN_10V = 0x01;
  794. if (strcmp(string, "023930") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_CEM_BHM_TIMEOUT = 0x01;
  795. if (strcmp(string, "023931") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_CEM_BRM_TIMEOUT = 0x01;
  796. if (strcmp(string, "023932") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_CEM_BCP_TIMEOUT = 0x01;
  797. if (strcmp(string, "023933") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_CEM_BRO_TIMEOUT = 0x01;
  798. if (strcmp(string, "023934") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_CEM_BCL_TIMEOUT = 0x01;
  799. if (strcmp(string, "023935") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_CEM_BCS_TIMEOUT = 0x01;
  800. if (strcmp(string, "023936") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_CEM_BSM_TIMEOUT = 0x01;
  801. if (strcmp(string, "023937") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_CEM_BST_TIMEOUT = 0x01;
  802. if (strcmp(string, "023938") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_CEM_BSD_TIMEOUT = 0x01;
  803. if (strcmp(string, "023939") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_CEM_BEM_OTHER_TIMEOUT = 0x01;
  804. if (strcmp(string, "023940") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BEM_CRM_TIMEOUT = 0x01;
  805. if (strcmp(string, "023941") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BEM_CRMAA_TIMEOUT = 0x01;
  806. if (strcmp(string, "023942") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BEM_CTS_CML_TIMEOUT = 0x01;
  807. if (strcmp(string, "023943") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BEM_CRO_TIMEOUT = 0x01;
  808. if (strcmp(string, "023944") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BEM_CCS_TIMEOUT = 0x01;
  809. if (strcmp(string, "023945") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BEM_CST_TIMEOUT = 0x01;
  810. if (strcmp(string, "023946") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BEM_CSD_TIMEOUT = 0x01;
  811. if (strcmp(string, "023947") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BEM_BEM_OTHER_TIMEOUT = 0x01;
  812. if (strcmp(string, "023950") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_SOC_GOAL = 0x01;
  813. if (strcmp(string, "023951") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_TOTAL_VOLTAGE_GOAL = 0x01;
  814. if (strcmp(string, "023952") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_CELL_VOLTAGE_GOAL = 0x01;
  815. if (strcmp(string, "023953") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_GET_CST = 0x01;
  816. if (strcmp(string, "023954") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_ISOLATION = 0x01;
  817. if (strcmp(string, "023955") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_OUTPUT_CONNECTOR_OTP = 0x01;
  818. if (strcmp(string, "023956") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_COMPONENT = 0x01;
  819. if (strcmp(string, "023957") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_CHARGE_CONNECTOR = 0x01;
  820. if (strcmp(string, "023958") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_OTP = 0x01;
  821. if (strcmp(string, "023959") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_OTHER = 0x01;
  822. if (strcmp(string, "023960") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_HIGH_V = 0x01;
  823. if (strcmp(string, "023961") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_CC2 = 0x01;
  824. if (strcmp(string, "023962") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_CURRENT = 0x01;
  825. if (strcmp(string, "023963") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_VOLTAGE = 0x01;
  826. if (strcmp(string, "023964") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GET_BST_NO_REASON = 0x01;
  827. if (strcmp(string, "023970") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BSM_CELL_OVER_VOLTAGE = 0x01;
  828. if (strcmp(string, "023971") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BSM_CELL_UNDER_VOLTAGE = 0x01;
  829. if (strcmp(string, "023972") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BSM_OVER_SOC = 0x01;
  830. if (strcmp(string, "023973") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BSM_UNDER_SOC = 0x01;
  831. if (strcmp(string, "023974") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BSM_CURRENT = 0x01;
  832. if (strcmp(string, "023975") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BSM_TEMPERATURE = 0x01;
  833. if (strcmp(string, "023976") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BSM_ISOLATE = 0x01;
  834. if (strcmp(string, "023977") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BSM_OUTPUT_CONNECTOR = 0x01;
  835. }
  836. void CANReceiver()
  837. {
  838. pid_t canRecPid;
  839. canRecPid = fork();
  840. if(canRecPid > 0)
  841. {
  842. int nbytes;
  843. struct can_frame frame;
  844. int intCmd;
  845. // 槍資訊
  846. struct ChargingInfoData *_chargingData[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
  847. struct timeval _cmd_ack_timeout[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
  848. bool isPass = false;
  849. gun_count = ShmSysConfigAndInfo->SysConfig.TotalConnectorCount;
  850. while(!isPass)
  851. {
  852. isPass = true;
  853. for (byte _index = 0; _index < gun_count; _index++)
  854. {
  855. if (!FindChargingInfoData(_index, &_chargingData[0]))
  856. {
  857. DEBUG_ERROR("EvComm (main) : FindChargingInfoData false \n");
  858. isPass = false;
  859. break;
  860. }
  861. }
  862. }
  863. for (byte _index = 0; _index < gun_count; _index++)
  864. gettimeofday(&_cmd_ack_timeout[_index], NULL);
  865. while (1)
  866. {
  867. memset(&frame, 0, sizeof(struct can_frame));
  868. nbytes = read(CanFd, &frame, sizeof(struct can_frame));
  869. for (byte _index = 0; _index < gun_count; _index++)
  870. {
  871. if (GetTimeoutValue(_cmd_ack_timeout[_index]) >= 5000000)
  872. {
  873. // ACK timeout
  874. //PRINTF_FUNC("gun = %x, ack timeout \n", _index);
  875. }
  876. }
  877. if (nbytes > 0)
  878. {
  879. byte target;
  880. byte targetGun = 0x00;
  881. intCmd = (int) (frame.can_id & CAN_EFF_MASK);
  882. if (intCmd == ADDRESS_REQ)
  883. {
  884. AddrAssignment(frame.data);
  885. continue;
  886. }
  887. intCmd = (int) (frame.can_id & CAN_EFF_MASK & 0xFFFFFF00);
  888. target = ((byte) (frame.can_id & 0x000000FF)); // 0x01 or 0x02
  889. for (byte _index = 0; _index < gun_count; _index++)
  890. {
  891. if (_chargingData[_index]->Evboard_id == target)
  892. {
  893. targetGun = _index;
  894. break;
  895. }
  896. }
  897. if(targetGun < 0 || targetGun >= CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY)
  898. {
  899. PRINTF_FUNC("EvComm (CANReceiver) : Target index = %x is < 0 or > QUANTITY \n", targetGun);
  900. continue;
  901. }
  902. if(intCmd == 256)
  903. {
  904. continue;
  905. }
  906. gettimeofday(&_cmd_ack_timeout[targetGun], NULL);
  907. switch (intCmd)
  908. {
  909. case NOTIFICATION_EV_STATUS:
  910. {
  911. if (_chargingData[targetGun]->ConnectorPlugIn != frame.data[0])
  912. PRINTF_FUNC("index = %d, ConnectorPlugIn = %x, data[0] = %x \n", targetGun, _chargingData[targetGun]->ConnectorPlugIn, frame.data[0]);
  913. _chargingData[targetGun]->ConnectorPlugIn = frame.data[0];
  914. _chargingData[targetGun]->PilotVoltage = frame.data[1];
  915. //PRINTF_FUNC("index = %d, ConnectorPlugIn = %x, data[0] = %x \n", targetGun, _chargingData[targetGun]->ConnectorPlugIn, frame.data[0]);
  916. //PRINTF_FUNC("ConnectorPlugIn = %x \n", (-120 + frame.data[1]) / 10);
  917. }
  918. break;
  919. case ACK_EV_FW_VERSION:
  920. {
  921. if (_chargingData[targetGun]->Type == _Type_Chademo)
  922. {
  923. memcpy(ShmCHAdeMOData->evse[_chargingData[targetGun]->type_index].version, frame.data, frame.can_dlc);
  924. ShmCHAdeMOData->evse[_chargingData[targetGun]->type_index].SelfTest_Comp = PASS;
  925. PRINTF_FUNC("chademo ver. : %s\n", ShmCHAdeMOData->evse[_chargingData[targetGun]->type_index].version);
  926. }
  927. else if (_chargingData[targetGun]->Type == _Type_GB)
  928. {
  929. memcpy(ShmGBTData->evse[_chargingData[targetGun]->type_index].version, frame.data, ARRAY_SIZE(frame.data));
  930. ShmGBTData->evse[_chargingData[targetGun]->type_index].SelfTest_Comp = PASS;
  931. PRINTF_FUNC("gbt ver. : %s\n", ShmGBTData->evse[_chargingData[targetGun]->type_index].version);
  932. }
  933. else if (_chargingData[targetGun]->Type == _Type_CCS_2)
  934. {
  935. if (ShmCcsData->CommProtocol == 0x01)
  936. {
  937. memcpy(&ShmCcsData->V2GMessage_DIN70121[_chargingData[targetGun]->type_index].version, frame.data, frame.can_dlc);
  938. ShmCcsData->V2GMessage_DIN70121[_chargingData[targetGun]->type_index].SelfTest_Comp = PASS;
  939. PRINTF_FUNC("CCS FW = %s \n", ShmCcsData->V2GMessage_DIN70121[_chargingData[targetGun]->type_index].version);
  940. }
  941. }
  942. if (targetGun == 0)
  943. {
  944. memset(ShmSysConfigAndInfo->SysInfo.Connector1FwRev, 0, sizeof(ShmSysConfigAndInfo->SysInfo.Connector1FwRev));
  945. memcpy(ShmSysConfigAndInfo->SysInfo.Connector1FwRev, frame.data, frame.can_dlc);
  946. }
  947. else
  948. {
  949. memset(ShmSysConfigAndInfo->SysInfo.Connector2FwRev, 0, sizeof(ShmSysConfigAndInfo->SysInfo.Connector2FwRev));
  950. memcpy(ShmSysConfigAndInfo->SysInfo.Connector2FwRev, frame.data, frame.can_dlc);
  951. }
  952. }
  953. break;
  954. case ACK_EV_HW_VERSION:
  955. {
  956. //PRINTF_FUNC("Get EV HW = %s \n", frame.data);
  957. }
  958. break;
  959. case ACK_GET_OUTPUT_REQ:
  960. {
  961. _chargingData[targetGun]->EvBatterySoc = frame.data[1];
  962. _chargingData[targetGun]->EvBatterytargetVoltage = ((short) frame.data[3] << 8) + (short) frame.data[2];
  963. _chargingData[targetGun]->EvBatterytargetCurrent = ((short) frame.data[5] << 8) + (short) frame.data[4];
  964. _chargingData[targetGun]->PresentChargedDuration = ((short) frame.data[7] << 8) + (short) frame.data[6];
  965. if (_chargingData[targetGun]->Type == _Type_Chademo)
  966. {
  967. if (ShmCHAdeMOData->ev[_chargingData[targetGun]->type_index].EvDetection != frame.data[0])
  968. {
  969. ShmCHAdeMOData->ev[_chargingData[targetGun]->type_index].PresentMsgFlowStatus = frame.data[0];
  970. }
  971. ShmCHAdeMOData->ev[_chargingData[targetGun]->type_index].EvDetection = frame.data[0];
  972. ShmCHAdeMOData->ev[_chargingData[targetGun]->type_index].SOC = _chargingData[targetGun]->EvBatterySoc;
  973. ShmCHAdeMOData->ev[_chargingData[targetGun]->type_index].TargetBatteryVoltage = _chargingData[targetGun]->EvBatterytargetVoltage;
  974. ShmCHAdeMOData->ev[_chargingData[targetGun]->type_index].ChargingCurrentRequest = _chargingData[targetGun]->EvBatterytargetCurrent;
  975. }
  976. else if (_chargingData[targetGun]->Type == _Type_GB)
  977. {
  978. if (ShmGBTData->ev[_chargingData[targetGun]->type_index].EvDetection != frame.data[0])
  979. {
  980. ShmGBTData->ev[_chargingData[targetGun]->type_index].PresentMsgFlowStatus = frame.data[0];
  981. }
  982. ShmGBTData->ev[_chargingData[targetGun]->type_index].EvDetection = frame.data[0];
  983. ShmGBTData->ev[_chargingData[targetGun]->type_index].SOC = _chargingData[targetGun]->EvBatterySoc;
  984. ShmGBTData->ev[_chargingData[targetGun]->type_index].TargetBatteryVoltage = _chargingData[targetGun]->EvBatterytargetVoltage;
  985. ShmGBTData->ev[_chargingData[targetGun]->type_index].ChargingCurrentRequest = _chargingData[targetGun]->EvBatterytargetCurrent;
  986. }
  987. else if (_chargingData[targetGun]->Type == _Type_CCS_2)
  988. {
  989. if(ShmCcsData->CommProtocol == 0x01)
  990. {
  991. ShmCcsData->V2GMessage_DIN70121[_chargingData[targetGun]->type_index].PresentMsgFlowStatus = frame.data[0];
  992. }
  993. }
  994. //PRINTF_FUNC("EvBatterytargetVoltage = %f \n", _chargingData[targetGun]->EvBatterytargetVoltage);
  995. //PRINTF_FUNC("EvBatterytargetCurrent = %f \n", _chargingData[targetGun]->EvBatterytargetCurrent);
  996. //PRINTF_FUNC("BatteryVoltage = %d \n", ShmCHAdeMOData->ev[_chargingData[target]->type_index].TargetBatteryVoltage);
  997. //PRINTF_FUNC("CurrentRequest = %d \n", ShmCHAdeMOData->ev[_chargingData[target]->type_index].ChargingCurrentRequest);
  998. }
  999. break;
  1000. case ACK_GET_EV_BATTERY_INFO:
  1001. {
  1002. //_chargingData[target].EvACorDCcharging = frame.data[0];
  1003. //_chargingData[target]->TotalBatteryCap = ((float) frame.data[4] << 8) + (short) frame.data[3];
  1004. _chargingData[targetGun]->EvBatteryMaxVoltage = ((short) frame.data[4] << 8) + (short) frame.data[3];
  1005. //_chargingData[target]->EvBatteryMaxCurrent = ((float) frame.data[4] << 8) + (short) frame.data[3];
  1006. //_chargingData[target].MaxiBatteryCurrent = ((short) frame.data[6] << 8) + (short) frame.data[5];
  1007. if (_chargingData[targetGun]->Type == _Type_Chademo)
  1008. {
  1009. ShmCHAdeMOData->ev[_chargingData[targetGun]->type_index].TotalBatteryCapacity = ((short) frame.data[2] << 8) + (short) frame.data[1];
  1010. ShmCHAdeMOData->ev[_chargingData[targetGun]->type_index].MaxiBatteryVoltage = _chargingData[targetGun]->EvBatteryMaxVoltage;
  1011. //PRINTF_FUNC("EvBatteryMaxVoltage = %f \n", _chargingData[target]->EvBatteryMaxVoltage);
  1012. //PRINTF_FUNC("TotalBatteryCapacity = %d \n", ShmCHAdeMOData->ev[_chargingData[target]->type_index].TotalBatteryCapacity);
  1013. //PRINTF_FUNC("MaxiBatteryVoltage = %d \n", ShmCHAdeMOData->ev[_chargingData[target]->type_index].MaxiBatteryVoltage);
  1014. }
  1015. else if (_chargingData[targetGun]->Type == _Type_GB)
  1016. {
  1017. ShmGBTData->ev[_chargingData[targetGun]->type_index].TotalBatteryCapacity = ((short) frame.data[2] << 8) + (short) frame.data[1];
  1018. ShmGBTData->ev[_chargingData[targetGun]->type_index].MaxiBatteryVoltage = _chargingData[targetGun]->EvBatteryMaxVoltage;
  1019. }
  1020. else if (_chargingData[targetGun]->Type == _Type_CCS_2)
  1021. {
  1022. }
  1023. }
  1024. break;
  1025. case ACK_GET_MISCELLANEOUS_INFO:
  1026. {
  1027. if (_chargingData[targetGun]->Type == _Type_Chademo)
  1028. {
  1029. _chargingData[targetGun]->GunLocked = frame.data[0];
  1030. ShmCHAdeMOData->evse[_chargingData[targetGun]->type_index].ConnectorTemperatureP = frame.data[1];
  1031. ShmCHAdeMOData->evse[_chargingData[targetGun]->type_index].ConnectorTemperatureN = frame.data[2];
  1032. _chargingData[targetGun]->PilotVoltage = (float)(-120 + frame.data[3]) / 10;
  1033. ShmCHAdeMOData->evse[_chargingData[targetGun]->type_index].EvboardStatus = frame.data[7];
  1034. }
  1035. else if (_chargingData[targetGun]->Type == _Type_GB)
  1036. {
  1037. _chargingData[targetGun]->GunLocked = frame.data[0];
  1038. ShmGBTData->evse[_chargingData[targetGun]->type_index].ConnectorTemperatureP = frame.data[1];
  1039. ShmGBTData->evse[_chargingData[targetGun]->type_index].ConnectorTemperatureN = frame.data[2];
  1040. _chargingData[targetGun]->PilotVoltage = (float)(-120 + frame.data[3]) / 10;
  1041. ShmGBTData->evse[_chargingData[targetGun]->type_index].EvboardStatus = frame.data[7];
  1042. }
  1043. else if (_chargingData[targetGun]->Type == _Type_CCS_2)
  1044. {
  1045. if (ShmCcsData->CommProtocol == 0x01)
  1046. {
  1047. _chargingData[targetGun]->GunLocked = frame.data[0];
  1048. //ShmCcsData->V2GMessage_DIN70121[_chargingData[targetGun]->type_index]. .ConnectorTemperatureP = frame.data[1];
  1049. //ShmCcsData->V2GMessage_DIN70121[_chargingData[targetGun]->type_index]. .ConnectorTemperatureN = frame.data[2];
  1050. _chargingData[targetGun]->PilotVoltage = (float)(-120 + frame.data[3]) / 10;
  1051. }
  1052. }
  1053. //PRINTF_FUNC("EvboardStatus = %x \n", ShmCHAdeMOData->evse[_chargingData[target]->type_index].EvboardStatus);
  1054. //PRINTF_FUNC("ConnectorPlug locked = %x \n", frame.data[0]);
  1055. //PRINTF_FUNC("ConnectorTemp 0= %d \n", ShmCHAdeMOData->evse[_chargingData[target]->type_index].ConnectorTemperatureP);
  1056. //PRINTF_FUNC("ConnectorTemp 1= %d \n", ShmCHAdeMOData->evse[_chargingData[target]->type_index].ConnectorTemperatureN);
  1057. //PRINTF_FUNC("PilotVoltage = %x \n", (-120 + frame.data[3]) / 10);
  1058. }
  1059. break;
  1060. case ACK_EVSE_ISOLATION_STATUS: {}
  1061. break;
  1062. case ACK_EVSE_PRECHAGE_INFO:
  1063. {
  1064. _chargingData[targetGun]->PrechargeStatus = frame.data[0];
  1065. }
  1066. break;
  1067. case NOTIFICATION_EV_STOP:
  1068. {
  1069. // 車端要求停止
  1070. // frame.data[0] : 0x01 => normal stop, 0x02 => ev emergency stop
  1071. PRINTF_FUNC("(%d) NOTIFICATION_EV_STOP err level = %d-----------------------------\n", targetGun, frame.data[0]);
  1072. //if (frame.data[0] == 0x02)
  1073. {
  1074. AbnormalStopAnalysis(targetGun, frame.data + 1);
  1075. }
  1076. _chargingData[targetGun]->StopChargeFlag = YES;
  1077. }
  1078. break;
  1079. default:
  1080. PRINTF_FUNC("EV board = %d, Ack none defined. intCmd = %d \n", targetGun, intCmd);
  1081. break;
  1082. }
  1083. }
  1084. usleep(10000);
  1085. }
  1086. }
  1087. }
  1088. //================================================
  1089. // Main process
  1090. //================================================
  1091. // 檢查 Byte 中某個 Bit 的值
  1092. // _byte : 欲改變的 byte
  1093. // _bit : 該 byte 的第幾個 bit
  1094. unsigned char EvDetectionStatus(unsigned char _byte, unsigned char _bit)
  1095. {
  1096. return ( _byte & mask_table[_bit] ) != 0x00;
  1097. }
  1098. bool IsConnectorPlugIn(struct ChargingInfoData *chargingData)
  1099. {
  1100. return (chargingData->ConnectorPlugIn == 0x01) ? true : false;
  1101. }
  1102. void SetPresentChargingOutputPower(struct ChargingInfoData *chargingData_1, struct ChargingInfoData *chargingData_2)
  1103. {
  1104. float vol1 = 0, cur1 = 0;
  1105. float vol2 = 0, cur2 = 0;
  1106. //PRINTF_FUNC("f vol - 0 = %f \n", chargingData_1->FireChargingVoltage);
  1107. //PRINTF_FUNC("f cur - 0 = %f \n", chargingData_1->PresentChargingCurrent);
  1108. //PRINTF_FUNC("***********************f vol - 1 = %f \n", chargingData_2->FireChargingVoltage);
  1109. //PRINTF_FUNC("***********************f cur - 1 = %f \n", chargingData_2->PresentChargingCurrent);
  1110. vol1 = chargingData_1->FireChargingVoltage;
  1111. cur1 = (chargingData_1->PresentChargingCurrent * 10);
  1112. vol2 = chargingData_2->FireChargingVoltage;
  1113. cur2 = (chargingData_2->PresentChargingCurrent * 10);
  1114. SetPresentOutputPower(vol1, cur1, vol2, cur2);
  1115. }
  1116. void SetPresentChargingOutputCap(struct ChargingInfoData *chargingData_1, struct ChargingInfoData *chargingData_2)
  1117. {
  1118. float pow1 = 0, cur1 = 0;
  1119. float pow2 = 0, cur2 = 0;
  1120. float vol = 0;
  1121. pow1 = chargingData_1->AvailableChargingPower;
  1122. cur1 = chargingData_1->AvailableChargingCurrent;
  1123. vol = chargingData_1->MaximumChargingVoltage;
  1124. GetMaxVolAndCurMethod(chargingData_1->Index, &vol, &cur1);
  1125. GetMaxPowerMethod(&pow1);
  1126. pow2 = chargingData_2->AvailableChargingPower;
  1127. cur2 = chargingData_2->AvailableChargingCurrent;
  1128. vol = chargingData_2->MaximumChargingVoltage;
  1129. GetMaxVolAndCurMethod(chargingData_2->Index, &vol, &cur2);
  1130. GetMaxPowerMethod(&pow2);
  1131. if (_pow_1 != pow1 ||
  1132. _cur_1 != cur1 ||
  1133. _pow_2 != pow2 ||
  1134. _cur_2 != cur2)
  1135. {
  1136. PRINTF_FUNC("To EV (Real) Power_1 = %f, Cur_1 = %f, Power_2 = %f, Cur_2 = %f \n",
  1137. pow1, cur1, pow2, cur2);
  1138. _pow_1 = pow1; _cur_1 = cur1; _pow_2 = pow2; _cur_2 = cur2;
  1139. chargingData_1->RealMaxCurrent = _cur_1;
  1140. chargingData_1->RealMaxPower = pow1;
  1141. if (gun_count == 2)
  1142. {
  1143. chargingData_2->RealMaxCurrent = cur2;
  1144. chargingData_2->RealMaxPower = pow2;
  1145. }
  1146. }
  1147. SetPresentOutputCapacity(pow1, cur1, pow2, cur2);
  1148. }
  1149. void Initialization()
  1150. {
  1151. bool isPass = false;
  1152. while(!isPass)
  1153. {
  1154. isPass = true;
  1155. for (byte _index = 0; _index < gun_count; _index++)
  1156. {
  1157. if (!FindChargingInfoData(_index, &_chargingData[0]))
  1158. {
  1159. DEBUG_ERROR("EvComm (main) : FindChargingInfoData false \n");
  1160. isPass = false;
  1161. break;
  1162. }
  1163. }
  1164. }
  1165. }
  1166. void GetMaxVolAndCurMethod(byte index, float *vol, float *cur)
  1167. {
  1168. if (maxChargingVol[index] != 0 && maxChargingVol[index] <= *vol)
  1169. *vol = maxChargingVol[index];
  1170. if (maxChargingCur[index] != 0 && maxChargingCur[index] <= *cur)
  1171. *cur = maxChargingCur[index];
  1172. }
  1173. void GetMaxPowerMethod(float *pow)
  1174. {
  1175. if (maxChargingPow != 0 && maxChargingPow <= *pow)
  1176. *pow = maxChargingPow;
  1177. }
  1178. time_t GetRtcInfoForEpoch()
  1179. {
  1180. struct timeb csuTime;
  1181. struct tm *tmCSU;
  1182. struct tm t;
  1183. time_t result;
  1184. ftime(&csuTime);
  1185. tmCSU = localtime(&csuTime.time);
  1186. t.tm_year = tmCSU->tm_year;
  1187. t.tm_mon = tmCSU->tm_mon;
  1188. t.tm_mday = tmCSU->tm_mday;
  1189. t.tm_hour = tmCSU->tm_hour;
  1190. t.tm_min = tmCSU->tm_min;
  1191. t.tm_sec = tmCSU->tm_sec;
  1192. t.tm_isdst = -1;
  1193. result = mktime(&t);
  1194. return result;
  1195. }
  1196. byte GetStopChargingReasonByEvse(byte gunIndex, byte *reason)
  1197. {
  1198. byte result = NO;
  1199. if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.EmergencyStopTrip == 0x01)
  1200. {
  1201. // 012251
  1202. *(reason + 5) = 0;
  1203. *(reason + 4) = 1;
  1204. *(reason + 3) = 2;
  1205. *(reason + 2) = 2;
  1206. *(reason + 1) = 5;
  1207. *(reason + 0) = 1;
  1208. result = YES;
  1209. }
  1210. if (_chargingData[gunIndex]->Type == _Type_Chademo)
  1211. {
  1212. if (ShmStatusCodeData->FaultCode.FaultEvents.bits.ChademoOutputRelayDrivingFault == YES)
  1213. {
  1214. // 011012
  1215. *(reason + 5) = 0;
  1216. *(reason + 4) = 1;
  1217. *(reason + 3) = 1;
  1218. *(reason + 2) = 0;
  1219. *(reason + 1) = 1;
  1220. *(reason + 0) = 2;
  1221. result = YES;
  1222. }
  1223. else if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.ChademoOutputUVPFail == YES)
  1224. {
  1225. // 012289
  1226. *(reason + 5) = 0;
  1227. *(reason + 4) = 1;
  1228. *(reason + 3) = 2;
  1229. *(reason + 2) = 2;
  1230. *(reason + 1) = 8;
  1231. *(reason + 0) = 9;
  1232. result = YES;
  1233. }
  1234. else if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.ChademoGfdTrip == YES)
  1235. {
  1236. // 012234
  1237. *(reason + 5) = 0;
  1238. *(reason + 4) = 1;
  1239. *(reason + 3) = 2;
  1240. *(reason + 2) = 2;
  1241. *(reason + 1) = 3;
  1242. *(reason + 0) = 4;
  1243. result = YES;
  1244. }
  1245. }
  1246. else if (_chargingData[gunIndex]->Type == _Type_GB)
  1247. {
  1248. if (ShmStatusCodeData->FaultCode.FaultEvents.bits.ChademoOutputRelayDrivingFault == YES)
  1249. {
  1250. // 012290
  1251. *(reason + 5) = 0;
  1252. *(reason + 4) = 1;
  1253. *(reason + 3) = 2;
  1254. *(reason + 2) = 2;
  1255. *(reason + 1) = 9;
  1256. *(reason + 0) = 0;
  1257. result = YES;
  1258. }
  1259. else if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.GbGfdTrip == YES)
  1260. {
  1261. // 012236
  1262. *(reason + 5) = 0;
  1263. *(reason + 4) = 1;
  1264. *(reason + 3) = 2;
  1265. *(reason + 2) = 2;
  1266. *(reason + 1) = 3;
  1267. *(reason + 0) = 6;
  1268. result = YES;
  1269. }
  1270. }
  1271. else if (_chargingData[gunIndex]->Type == _Type_CCS_2)
  1272. {
  1273. if (ShmStatusCodeData->FaultCode.FaultEvents.bits.CcsOutputRelayDrivingFault == YES)
  1274. {
  1275. // 011014
  1276. *(reason + 5) = 0;
  1277. *(reason + 4) = 1;
  1278. *(reason + 3) = 1;
  1279. *(reason + 2) = 0;
  1280. *(reason + 1) = 1;
  1281. *(reason + 0) = 4;
  1282. result = YES;
  1283. }
  1284. else if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CcsOutputUVPFail == YES)
  1285. {
  1286. // 012288
  1287. *(reason + 5) = 0;
  1288. *(reason + 4) = 1;
  1289. *(reason + 3) = 2;
  1290. *(reason + 2) = 2;
  1291. *(reason + 1) = 8;
  1292. *(reason + 0) = 8;
  1293. result = YES;
  1294. }
  1295. else if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CcsGfdTrip == YES)
  1296. {
  1297. // 012236
  1298. *(reason + 5) = 0;
  1299. *(reason + 4) = 1;
  1300. *(reason + 3) = 2;
  1301. *(reason + 2) = 2;
  1302. *(reason + 1) = 3;
  1303. *(reason + 0) = 5;
  1304. result = YES;
  1305. }
  1306. }
  1307. return result;
  1308. }
  1309. int main(int argc, char *argv[])
  1310. {
  1311. if(InitShareMemory() == FAIL)
  1312. {
  1313. #ifdef SystemLogMessage
  1314. DEBUG_ERROR("InitShareMemory NG\n");
  1315. #endif
  1316. if(ShmStatusCodeData != NULL)
  1317. {
  1318. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.FailToCreateShareMemory=1;
  1319. }
  1320. sleep(5);
  1321. return 0;
  1322. }
  1323. gun_count = ShmSysConfigAndInfo->SysConfig.TotalConnectorCount;
  1324. Initialization();
  1325. CanFd = InitCanBus();
  1326. CANReceiver();
  1327. byte priorityLow = 1;
  1328. time_t rtc = GetRtcInfoForEpoch();
  1329. while(CanFd)
  1330. {
  1331. for(byte _index = 0; _index < gun_count; _index++)
  1332. {
  1333. if (priorityLow == 1)
  1334. {
  1335. // 優先權較低 - 只要有回應即不會再詢問
  1336. if (_chargingData[_index]->Type == _Type_Chademo &&
  1337. ShmCHAdeMOData->evse[_chargingData[_index]->type_index].SelfTest_Comp != PASS)
  1338. {
  1339. SyncRtcInfo(_index, _chargingData[_index]->Evboard_id, (int)rtc);
  1340. GetFirmwareVersion(_index, _chargingData[_index]->Evboard_id);
  1341. }
  1342. else if (_chargingData[_index]->Type == _Type_GB &&
  1343. ShmGBTData->evse[_chargingData[_index]->type_index].SelfTest_Comp != PASS)
  1344. {
  1345. SyncRtcInfo(_index, _chargingData[_index]->Evboard_id, (int)rtc);
  1346. GetFirmwareVersion(_index, _chargingData[_index]->Evboard_id);
  1347. }
  1348. else if (_chargingData[_index]->Type == _Type_CCS_2)
  1349. {
  1350. if (ShmCcsData->CommProtocol == 0x01 &&
  1351. ShmCcsData->V2GMessage_DIN70121[_chargingData[_index]->type_index].SelfTest_Comp != PASS)
  1352. {
  1353. SyncRtcInfo(_index, _chargingData[_index]->Evboard_id, (int)rtc);
  1354. GetFirmwareVersion(_index, _chargingData[_index]->Evboard_id);
  1355. }
  1356. }
  1357. // 固定要取得的資訊 : 1.槍鎖狀態, 2."Connector 1" 溫度, 3."Connector 2" 溫度, 4.Pilot Voltage
  1358. //PRINTF_FUNC("GetMiscellaneousInfo. index = %d, Eid = %d \n", _index, _chargingData[_index]->Evboard_id);
  1359. GetMiscellaneousInfo(_index,
  1360. _chargingData[_index]->RelayK1K2Status,
  1361. _chargingData[_index]->PresentChargedEnergy,
  1362. (_chargingData[_index]->PresentChargingVoltage * 10),
  1363. _chargingData[_index]->Evboard_id);
  1364. }
  1365. switch (_chargingData[_index]->SystemStatus)
  1366. {
  1367. case S_IDLE:
  1368. case S_RESERVATION:
  1369. _chargingData[_index]->PresentChargedEnergy = 0;
  1370. _chargingData[_index]->PresentChargingPower = 0;
  1371. _chargingData[_index]->GroundFaultStatus = GFD_WAIT;
  1372. _chargingData[_index]->StopChargeFlag = NO;
  1373. _chargingData[_index]->ChargingFee = 0.0;
  1374. chargingTime[_index] = 0;
  1375. if (_chargingData[_index]->Type == _Type_Chademo)
  1376. {
  1377. ClearAbnormalStatus_Chademo(_index);
  1378. }
  1379. else if (_chargingData[_index]->Type == _Type_GB)
  1380. {
  1381. ClearAbnormalStatus_GB(_index);
  1382. }
  1383. else if (_chargingData[_index]->Type == _Type_CCS_2)
  1384. {
  1385. ClearAbnormalStatus_CCS(_index);
  1386. }
  1387. if (priorityLow == 1)
  1388. {
  1389. //maxChargingCur[_index] = ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent * 10;
  1390. maxChargingPow = (ShmSysConfigAndInfo->SysConfig.MaxChargingPower * 10);
  1391. }
  1392. break;
  1393. case S_PREPARNING:
  1394. {
  1395. // 設定當前輸出
  1396. if (gun_count == 1)
  1397. SetPresentChargingOutputPower(_chargingData[0], _chargingData[0]);
  1398. else if (gun_count == 2)
  1399. SetPresentChargingOutputPower(_chargingData[0], _chargingData[1]);
  1400. }
  1401. break;
  1402. case S_PREPARING_FOR_EV:
  1403. {
  1404. // 開始確認車端是否同意開始充電 : 1.SOC, 2.Target Vol, 3.Target Cur, 4.Charging remaining time
  1405. GetOutputReq(_index, _chargingData[_index]->Evboard_id);
  1406. // PRINTF_FUNC("PresentChargingVoltage = %f \n", _chargingData[_index]->PresentChargingVoltage);
  1407. // PRINTF_FUNC("PresentChargingCurrent = %f \n", _chargingData[_index]->PresentChargingCurrent);
  1408. // PRINTF_FUNC("AvailableChargingPower = %f \n", _chargingData[_index]->AvailableChargingPower);
  1409. // PRINTF_FUNC("AvailableChargingCurrent = %f \n", _chargingData[_index]->AvailableChargingCurrent);
  1410. // PRINTF_FUNC("MaximumChargingVoltage = %f \n", _chargingData[_index]->MaximumChargingVoltage);
  1411. // 設定當前輸出
  1412. if (gun_count == 1)
  1413. SetPresentChargingOutputPower(_chargingData[0], _chargingData[0]);
  1414. else if (gun_count == 2)
  1415. SetPresentChargingOutputPower(_chargingData[0], _chargingData[1]);
  1416. if (priorityLow == 1)
  1417. {
  1418. float maxVol, maxCur;
  1419. // 樁端輸出能力
  1420. maxVol = _chargingData[_index]->MaximumChargingVoltage;
  1421. maxCur = _chargingData[_index]->AvailableChargingCurrent;
  1422. GetMaxVolAndCurMethod(_index, &maxVol, &maxCur);
  1423. PRINTF_FUNC("To EV_%d Max_Vol = %f, Cap_Cur = %f, Cap_Pow = %f \n",
  1424. _index, maxVol, maxCur, _chargingData[_index]->AvailableChargingPower);
  1425. _chargingData[_index]->RealMaxVoltage = maxVol;
  1426. SetChargingPermission(_index, START,
  1427. _chargingData[_index]->AvailableChargingPower,
  1428. maxCur,
  1429. maxVol,
  1430. _chargingData[_index]->Evboard_id);
  1431. // 取得車端電池資訊 : 1.AC or DC ? 2.Total battery cap, 3.Max battery vol, 4.Max battery cur
  1432. GetEvBatteryInfo(_index, _chargingData[_index]->Evboard_id);
  1433. }
  1434. }
  1435. break;
  1436. case S_PREPARING_FOR_EVSE:
  1437. case S_CCS_PRECHARGE_ST0:
  1438. case S_CCS_PRECHARGE_ST1:
  1439. {
  1440. // 開始確認車端是否同意開始充電
  1441. GetOutputReq(_index, _chargingData[_index]->Evboard_id);
  1442. // 設定當前輸出
  1443. if (gun_count == 1)
  1444. SetPresentChargingOutputPower(_chargingData[0], _chargingData[0]);
  1445. else if (gun_count == 2)
  1446. SetPresentChargingOutputPower(_chargingData[0], _chargingData[1]);
  1447. if (priorityLow % 5 == 1)
  1448. {
  1449. // 樁端輸出能力改變
  1450. if (gun_count == 1)
  1451. SetPresentChargingOutputCap(_chargingData[0], _chargingData[0]);
  1452. else if (gun_count == 2)
  1453. SetPresentChargingOutputCap(_chargingData[0], _chargingData[1]);
  1454. }
  1455. // 持續通知 Isolation 測試狀態
  1456. if (priorityLow == 1)
  1457. {
  1458. // 拉 500 V 如果在一秒鐘內 GFD 都符合則 PASS
  1459. // if (_chargingData[_index]->FireChargingVoltage >= 3500)
  1460. // _chargingData[_index]->GroundFaultStatus = GFD_PASS;
  1461. //PRINTF_FUNC("To EV_%d GFD = %d \n", _index, _chargingData[_index]->GroundFaultStatus);
  1462. if(_chargingData[_index]->GroundFaultStatus != GFD_WAIT)
  1463. {
  1464. unsigned char _result = _chargingData[_index]->GroundFaultStatus;
  1465. if (_result == GFD_WARNING)
  1466. _result = GFD_PASS;
  1467. SetIsolationStatus(_index, _result, _chargingData[_index]->Evboard_id);
  1468. }
  1469. if(_chargingData[_index]->SystemStatus == S_CCS_PRECHARGE_ST0 &&
  1470. _chargingData[_index]->PrechargeStatus == PRECHARGE_READY)
  1471. {
  1472. SetEvsePrechargeInfo(_index, PRECHARGE_PRERELAY_PASS, _chargingData[_index]->Evboard_id);
  1473. }
  1474. }
  1475. }
  1476. break;
  1477. case S_CHARGING:
  1478. {
  1479. // 計算 Power
  1480. _chargingData[_index]->PresentChargingPower = ((float)((_chargingData[_index]->PresentChargingVoltage) * (_chargingData[_index]->PresentChargingCurrent)) / 1000);
  1481. if (chargingTime[_index] == 0)
  1482. {
  1483. chargingTime[_index] = _chargingData[_index]->RemainChargingDuration;
  1484. }
  1485. else
  1486. {
  1487. int passTime = _chargingData[_index]->RemainChargingDuration - chargingTime[_index];
  1488. if (passTime > 0)
  1489. {
  1490. float changingPow = (_chargingData[_index]->PresentChargingPower) * passTime / 3600;
  1491. if (ShmSysConfigAndInfo->SysConfig.BillingData.isBilling)
  1492. {
  1493. _chargingData[_index]->ChargingFee += changingPow * ShmSysConfigAndInfo->SysConfig.BillingData.Cur_fee;
  1494. }
  1495. _chargingData[_index]->PresentChargedEnergy += changingPow;
  1496. chargingTime[_index] = _chargingData[_index]->RemainChargingDuration;
  1497. }
  1498. }
  1499. // 開始確認車端是否同意開始充電
  1500. GetOutputReq(_index, _chargingData[_index]->Evboard_id);
  1501. // 設定當前輸出
  1502. if (gun_count == 1)
  1503. SetPresentChargingOutputPower(_chargingData[0], _chargingData[0]);
  1504. else if (gun_count == 2)
  1505. SetPresentChargingOutputPower(_chargingData[0], _chargingData[1]);
  1506. // for test end
  1507. if (priorityLow % 5 == 0)
  1508. {
  1509. // 樁端輸出能力改變
  1510. if (gun_count == 1)
  1511. SetPresentChargingOutputCap(_chargingData[0], _chargingData[0]);
  1512. else if (gun_count == 2)
  1513. SetPresentChargingOutputCap(_chargingData[0], _chargingData[1]);
  1514. }
  1515. // GFD 失敗再通知
  1516. if (priorityLow == 1)
  1517. {
  1518. if(_chargingData[_index]->GroundFaultStatus == GFD_FAIL)
  1519. {
  1520. SetIsolationStatus(_index, _chargingData[_index]->GroundFaultStatus, _chargingData[_index]->Evboard_id);
  1521. }
  1522. if(_chargingData[_index]->Type == _Type_CCS_2 &&
  1523. _chargingData[_index]->PrechargeStatus == PRECHARGE_READY)
  1524. {
  1525. SetEvsePrechargeInfo(_index, PRECHARGE_CHARELAY_PASS, _chargingData[_index]->Evboard_id);
  1526. }
  1527. }
  1528. }
  1529. break;
  1530. case S_TERMINATING:
  1531. {
  1532. // 設定當前輸出
  1533. if (gun_count == 1)
  1534. SetPresentChargingOutputPower(_chargingData[0], _chargingData[0]);
  1535. else if (gun_count == 2)
  1536. SetPresentChargingOutputPower(_chargingData[0], _chargingData[1]);
  1537. // 槍鎖還在,則代表是樁端要求的停止
  1538. if (_chargingData[_index]->GunLocked == START ||
  1539. _chargingData[_index]->Type == _Type_CCS_2)
  1540. {
  1541. byte normalStop = 0x01;
  1542. byte stopReason[6] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
  1543. if (GetStopChargingReasonByEvse(_index, stopReason))
  1544. {
  1545. normalStop = 0x02;
  1546. }
  1547. EvseStopChargingEvent(normalStop, stopReason, _chargingData[_index]->Evboard_id);
  1548. }
  1549. GetOutputReq(_index, _chargingData[_index]->Evboard_id);
  1550. }
  1551. break;
  1552. case S_COMPLETE:
  1553. {
  1554. if (priorityLow == 1)
  1555. {
  1556. float maxVol, maxCur;
  1557. // 樁端輸出能力
  1558. maxVol = _chargingData[_index]->MaximumChargingVoltage;
  1559. maxCur = _chargingData[_index]->AvailableChargingCurrent;
  1560. GetMaxVolAndCurMethod(_index, &maxVol, &maxCur);
  1561. SetChargingPermission(_index, STOP,
  1562. _chargingData[_index]->AvailableChargingPower,
  1563. maxCur,
  1564. maxVol,
  1565. _chargingData[_index]->Evboard_id);
  1566. }
  1567. }
  1568. break;
  1569. }
  1570. }
  1571. priorityLow >= 20 ? priorityLow = 1 : priorityLow++;
  1572. usleep(45000); //EV 小板通訊 (50 ms)
  1573. }
  1574. DEBUG_INFO("Module_EvComm : Can-bus port = %d \n", CanFd);
  1575. return FAIL;
  1576. }