Module_EvComm.c 90 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647
  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] = { 9500, 9500 }; // 限制最大充電電壓,如依照模塊則填上 0
  54. // 限制最大充電電流與能量透過 Web
  55. float maxChargingCur[2] = { 0, 0 }; // 限制最大充電電流,如依照模塊則填上 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.PilotFault = 0x00;
  365. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBatteryMalfun = 0x00;
  366. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoNoPermission = 0x00;
  367. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBatteryIncompatibility = 0x00;
  368. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBatteryOVP = 0x00;
  369. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBatteryUVP = 0x00;
  370. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBatteryOTP = 0x00;
  371. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBatteryCurrentDiff = 0x00;
  372. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBatteryVoltageDiff = 0x00;
  373. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoShiftPosition = 0x00;
  374. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBatteryOtherFault = 0x00;
  375. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoChargingSystemError = 0x00;
  376. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoEvNormalStop = 0x00;
  377. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoTempSensorBroken = 0x00;
  378. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoConnectorLockFail = 0x00;
  379. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoD1OnNoReceive = 0x00;
  380. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBmsKtoJTimeout = 0x00;
  381. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBmsChargeAllowTimeout = 0x00;
  382. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoWaitGfdTimeout = 0x00;
  383. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBmsEvRelayTimeout = 0x00;
  384. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBmsReqCurrentTimeout = 0x00;
  385. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBmsKtoJOffTimeout = 0x00;
  386. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBmsEvRelayOffTimeout = 0x00;
  387. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoAdcMoreThan10V = 0x00;
  388. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoAdcMoreThan20V = 0x00;
  389. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBmsChargeBeforeStop = 0x00;
  390. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoChargerGetNormalStop = 0x00;
  391. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoChargerGetEmergencyStop = 0x00;
  392. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoIsolationResultFail = 0x00;
  393. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoMissLinkWithMotherBoard = 0x00;
  394. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoOutputVolMoreThanLimit = 0x00;
  395. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoReqCurrentMoreThanLimit = 0x00;
  396. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoReCapBmsEqrCurrentExceed = 0x00;
  397. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoChargeRemainCountDown = 0x00;
  398. }
  399. void ClearAbnormalStatus_GB(byte gun_index)
  400. {
  401. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_LOS_CC1 = 0x00;
  402. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_CONNECTOR_LOCK_FAIL = 0x00;
  403. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_BATTERY_INCOMPATIBLE = 0x00;
  404. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_BMS_BROAA_TIMEOUT = 0x00;
  405. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_CSU_PRECHARGE_TIMEOUT = 0x00;
  406. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_BMS_PRESENT_VOLTAGE_FAULT = 0x00;
  407. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_BMS_VOLTAGE_OVER_RANGE = 0x00;
  408. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_BSM_CHARGE_ALLOW_00_10MIN_COUUNTDONE = 0x00;
  409. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_WAIT_GROUNDFAULT_TIMEOUT = 0x00;
  410. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_ADC_MORE_THAN_10V = 0x00;
  411. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_ADC_MORE_THAN_60V = 0x00;
  412. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_CHARGER_GET_NORMAL_STOP_CMD = 0x00;
  413. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_CHARGER_GET_EMERGENCY_STOP_CMD = 0x00;
  414. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_ISOLATION_RESULT_FAIL = 0x00;
  415. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_MOTHER_BOARD_MISS_LINK = 0x00;
  416. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_OUTPUT_VOLTAGE_MORE_THAN_LIMIT = 0x00;
  417. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_REQ_CURRENT_MORE_THAN_LIMIT = 0x00;
  418. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_OUTPUT_VOLTAGE_MORE_THAN_10_PERCENT = 0x00;
  419. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_OUTPUT_VOLTAGE_DIFF_BCS_5_PERCENT = 0x00;
  420. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_STOP_ADC_MORE_THAN_10V = 0x00;
  421. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_CEM_BHM_TIMEOUT = 0x00;
  422. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_CEM_BRM_TIMEOUT = 0x00;
  423. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_CEM_BCP_TIMEOUT = 0x00;
  424. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_CEM_BRO_TIMEOUT = 0x00;
  425. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_CEM_BCL_TIMEOUT = 0x00;
  426. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_CEM_BCS_TIMEOUT = 0x00;
  427. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_CEM_BSM_TIMEOUT = 0x00;
  428. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_CEM_BST_TIMEOUT = 0x00;
  429. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_CEM_BSD_TIMEOUT = 0x00;
  430. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_CEM_BEM_OTHER_TIMEOUT = 0x00;
  431. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BEM_CRM_TIMEOUT = 0x00;
  432. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BEM_CRMAA_TIMEOUT = 0x00;
  433. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BEM_CTS_CML_TIMEOUT = 0x00;
  434. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BEM_CRO_TIMEOUT = 0x00;
  435. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BEM_CCS_TIMEOUT = 0x00;
  436. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BEM_CST_TIMEOUT = 0x00;
  437. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BEM_CSD_TIMEOUT = 0x00;
  438. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BEM_BEM_OTHER_TIMEOUT = 0x00;
  439. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_SOC_GOAL = 0x00;
  440. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_TOTAL_VOLTAGE_GOAL = 0x00;
  441. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_CELL_VOLTAGE_GOAL = 0x00;
  442. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_GET_CST = 0x00;
  443. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_ISOLATION = 0x00;
  444. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_OUTPUT_CONNECTOR_OTP = 0x00;
  445. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_COMPONENT = 0x00;
  446. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_CHARGE_CONNECTOR = 0x00;
  447. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_OTP = 0x00;
  448. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_OTHER = 0x00;
  449. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_HIGH_V = 0x00;
  450. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_CC2 = 0x00;
  451. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_CURRENT = 0x00;
  452. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_VOLTAGE = 0x00;
  453. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GET_BST_NO_REASON = 0x00;
  454. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BSM_CELL_OVER_VOLTAGE = 0x00;
  455. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BSM_CELL_UNDER_VOLTAGE = 0x00;
  456. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BSM_OVER_SOC = 0x00;
  457. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BSM_UNDER_SOC = 0x00;
  458. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BSM_CURRENT = 0x00;
  459. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BSM_TEMPERATURE = 0x00;
  460. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BSM_ISOLATE = 0x00;
  461. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BSM_OUTPUT_CONNECTOR = 0x00;
  462. }
  463. void ClearAbnormalStatus_CCS(byte gun_index)
  464. {
  465. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsRESTemperatureInhibit = 0x00;
  466. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsEVShiftPosition = 0x00;
  467. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsChargerConnectorLockFault = 0x00;
  468. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsEVRESSMalfunction = 0x00;
  469. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsChargingCurrentdifferential = 0x00;
  470. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsChargingVoltageOutOfRange = 0x00;
  471. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsChargingSystemIncompatibility = 0x00;
  472. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsEmergencyEvent = 0x00;
  473. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsBreaker = 0x00;
  474. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsNoData = 0x00;
  475. ShmStatusCodeData->InfoCode.InfoEvents.bits.Ccsreserved_by_DIN_A = 0x00;
  476. ShmStatusCodeData->InfoCode.InfoEvents.bits.Ccsreserved_by_DIN_B = 0x00;
  477. ShmStatusCodeData->InfoCode.InfoEvents.bits.Ccsreserved_by_DIN_C = 0x00;
  478. ShmStatusCodeData->InfoCode.InfoEvents.bits.Ccsreserved_by_ISO_1 = 0x00;
  479. ShmStatusCodeData->InfoCode.InfoEvents.bits.Ccsreserved_by_ISO_2 = 0x00;
  480. ShmStatusCodeData->InfoCode.InfoEvents.bits.Ccsreserved_by_ISO_3 = 0x00;
  481. ShmStatusCodeData->InfoCode.InfoEvents.bits.Ccsreserved_by_OEM_1 = 0x00;
  482. ShmStatusCodeData->InfoCode.InfoEvents.bits.Ccsreserved_by_OEM_2 = 0x00;
  483. ShmStatusCodeData->InfoCode.InfoEvents.bits.Ccsreserved_by_OEM_3 = 0x00;
  484. ShmStatusCodeData->InfoCode.InfoEvents.bits.Ccsreserved_by_OEM_4 = 0x00;
  485. ShmStatusCodeData->InfoCode.InfoEvents.bits.Ccsreserved_by_OEM_5 = 0x00;
  486. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsSequenceError = 0x00;
  487. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsSignatureError = 0x00;
  488. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsUnknownSession = 0x00;
  489. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsServiceIDInvalid = 0x00;
  490. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsPaymentSelectionInvalid = 0x00;
  491. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsIdentificationSelectionInvalid = 0x00;
  492. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsServiceSelectionInvalid = 0x00;
  493. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCertificateExpired = 0x00;
  494. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCertificateNotYetValid = 0x00;
  495. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCertificateRevoked = 0x00;
  496. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsNoCertificateAvailable = 0x00;
  497. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCertChainError = 0x00;
  498. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCertValidationError = 0x00;
  499. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCertVerificationError = 0x00;
  500. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsContractCanceled = 0x00;
  501. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsChallengeInvalid = 0x00;
  502. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsWrongEnergyTransferMode = 0x00;
  503. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsWrongChargeParameter = 0x00;
  504. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsChargingProfileInvalid = 0x00;
  505. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTariffSelectionInvalid = 0x00;
  506. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsEVSEPresentVoltageToLow = 0x00;
  507. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsPowerDeliveryNotApplied = 0x00;
  508. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsMeteringSignatureNotValid = 0x00;
  509. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsNoChargeServiceSelected = 0x00;
  510. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsContactorError = 0x00;
  511. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCertificateNotAllowedAtThisEVSE = 0x00;
  512. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsGAChargeStop = 0x00;
  513. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsAlignmentError = 0x00;
  514. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsACDError = 0x00;
  515. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsAssociationError = 0x00;
  516. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsEVSEChargeAbort = 0x00;
  517. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsNoSupportedAppProtocol = 0x00;
  518. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsContractNotAccepted = 0x00;
  519. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsMOUnknown = 0x00;
  520. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsOEM_Prov_CertificateRevoke = 0x00;
  521. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsOEM_SubCA1_CertificateRevoked = 0x00;
  522. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsOEM_SubCA2_CertificateRevoked = 0x00;
  523. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsOEM_RootCA_CertificateRevoked = 0x00;
  524. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsMO_Prov_CertificateRevoked = 0x00;
  525. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsMO_SubCA1_CertificateRevoked = 0x00;
  526. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsMO_SubCA2_CertificateRevoked = 0x00;
  527. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsMO_RootCA_CertificateRevoked = 0x00;
  528. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCPS_Prov_CertificateRevoked = 0x00;
  529. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCPS_SubCA1_CertificateRevoked = 0x00;
  530. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCPS_SubCA2_CertificateRevoked = 0x00;
  531. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCPS_RootCA_CertificateRevoked = 0x00;
  532. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_EVSE_SLAC_init = 0x00;
  533. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_match_response = 0x00;
  534. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_match_sequence = 0x00;
  535. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_EVSE_match_MNBC = 0x00;
  536. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_EVSE_avg_atten_calc = 0x00;
  537. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_match_response = 0x00;
  538. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_EVSE_match_session = 0x00;
  539. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_EVSE_assoc_session = 0x00;
  540. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_EVSE_vald_toggle = 0x00;
  541. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsUDP_TT_match_join = 0x00;
  542. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTCP_TT_match_join = 0x00;
  543. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_amp_map_exchange = 0x00;
  544. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_link_ready_notification = 0x00;
  545. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsSupportedAppProtocolRes = 0x00;
  546. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsSessionSetupRes = 0x00;
  547. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsServiceDiscoveryRes = 0x00;
  548. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsServicePaymentSelectionRes = 0x00;
  549. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsContractAuthenticationRes = 0x00;
  550. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsChargeParameterDiscoveryRes = 0x00;
  551. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsPowerDeliveryRes = 0x00;
  552. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCableCheckRes = 0x00;
  553. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsPreChargeRes = 0x00;
  554. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCurrentDemandRes = 0x00;
  555. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsWeldingDetectionRes = 0x00;
  556. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsSessionStopRes = 0x00;
  557. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsSequence_Time = 0x00;
  558. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsReadyToCharge_Performance_Time = 0x00;
  559. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCommunicationSetup_Performance_Time = 0x00;
  560. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCableCheck_Performance_Time = 0x00;
  561. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCPState_Detection_Time = 0x00;
  562. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCPOscillator_Retain_Time = 0x00;
  563. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_GET_EV_TARGET_INFO = 0x00;
  564. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_GET_EV_TARGET_INFO = 0x00;
  565. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_GET_EV_BATTERY_INFO = 0x00;
  566. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_GET_EV_BATTERY_INFO = 0x00;
  567. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_EV_STOP_EVENT = 0x00;
  568. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_EV_STOP_EVENT = 0x00;
  569. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_EVSE_STOP_EVENT = 0x00;
  570. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_EVSE_STOP_EVENT = 0x00;
  571. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_GET_MISC_INFO = 0x00;
  572. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_GET_MISC_INFO = 0x00;
  573. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_DOWNLOAD_REQUEST = 0x00;
  574. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_DOWNLOAD_REQUEST = 0x00;
  575. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_START_BLOCK_TRANSFER = 0x00;
  576. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_START_BLOCK_TRANSFER = 0x00;
  577. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_DATA_TRANSFER = 0x00;
  578. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_DATA_TRANSFER = 0x00;
  579. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_DOWNLOAD_FINISH = 0x00;
  580. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_DOWNLOAD_FINISH = 0x00;
  581. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_ISOLATION_STATUS = 0x00;
  582. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_ISOLATION_STATUS = 0x00;
  583. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_CONNECTOR_INFO = 0x00;
  584. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_CONNECTOR_INFO = 0x00;
  585. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_RTC_INFO = 0x00;
  586. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_RTC_INFO = 0x00;
  587. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_EVSE_PRECHARGE_INFO = 0x00;
  588. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_EVSE_PRECHARGE_INFO = 0x00;
  589. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsMSG_Sequence = 0x00;
  590. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCAN_MSG_Unrecognized_CMD_ID = 0x00;
  591. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsDIN_Msg_Decode_Error = 0x00;
  592. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsDIN_Msg_Encode_Error = 0x00;
  593. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsISO1_Msg_Decode_Error = 0x00;
  594. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsISO1_Msg_Encode_Error = 0x00;
  595. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsISO2_Msg_Decode_Error = 0x00;
  596. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsISO2_Msg_Encode_Error = 0x00;
  597. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCpStatus_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, "023701") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsEvCommFail = 0x01;
  606. if (strcmp(string, "023702") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.GbEvCommFail = 0x01;
  607. if (strcmp(string, "023703") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.PilotFault = 0x01;
  608. if (strcmp(string, "023704") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBatteryMalfun = 0x01;
  609. if (strcmp(string, "023705") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoNoPermission = 0x01;
  610. if (strcmp(string, "023706") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBatteryIncompatibility = 0x01;
  611. if (strcmp(string, "023707") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBatteryOVP = 0x01;
  612. if (strcmp(string, "023708") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBatteryUVP = 0x01;
  613. if (strcmp(string, "023709") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBatteryOTP = 0x01;
  614. if (strcmp(string, "023710") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBatteryCurrentDiff = 0x01;
  615. if (strcmp(string, "023711") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBatteryVoltageDiff = 0x01;
  616. if (strcmp(string, "023712") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoShiftPosition = 0x01;
  617. if (strcmp(string, "023713") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBatteryOtherFault = 0x01;
  618. if (strcmp(string, "023714") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoChargingSystemError = 0x01;
  619. if (strcmp(string, "023715") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoEvNormalStop = 0x01;
  620. if (strcmp(string, "023716") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoTempSensorBroken = 0x01;
  621. if (strcmp(string, "023717") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoConnectorLockFail = 0x01;
  622. if (strcmp(string, "023718") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoD1OnNoReceive = 0x01;
  623. if (strcmp(string, "023719") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBmsKtoJTimeout = 0x01;
  624. if (strcmp(string, "023720") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBmsChargeAllowTimeout = 0x01;
  625. if (strcmp(string, "023721") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoWaitGfdTimeout = 0x01;
  626. if (strcmp(string, "023722") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBmsEvRelayTimeout = 0x01;
  627. if (strcmp(string, "023723") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBmsReqCurrentTimeout = 0x01;
  628. if (strcmp(string, "023724") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBmsKtoJOffTimeout = 0x01;
  629. if (strcmp(string, "023725") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBmsEvRelayOffTimeout = 0x01;
  630. if (strcmp(string, "023726") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoAdcMoreThan10V = 0x01;
  631. if (strcmp(string, "023727") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoAdcMoreThan20V = 0x01;
  632. if (strcmp(string, "023728") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBmsChargeBeforeStop = 0x01;
  633. if (strcmp(string, "023729") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoChargerGetNormalStop = 0x01;
  634. if (strcmp(string, "023730") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoChargerGetEmergencyStop = 0x01;
  635. if (strcmp(string, "023731") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoIsolationResultFail = 0x01;
  636. if (strcmp(string, "023732") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoMissLinkWithMotherBoard = 0x01;
  637. if (strcmp(string, "023733") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoOutputVolMoreThanLimit = 0x01;
  638. if (strcmp(string, "023734") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoReqCurrentMoreThanLimit = 0x01;
  639. if (strcmp(string, "023735") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoReCapBmsEqrCurrentExceed = 0x01;
  640. if (strcmp(string, "023736") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoChargeRemainCountDown = 0x01;
  641. if (strcmp(string, "023737") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsRESTemperatureInhibit = 0x01;
  642. if (strcmp(string, "023738") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsEVShiftPosition = 0x01;
  643. if (strcmp(string, "023739") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsChargerConnectorLockFault = 0x01;
  644. if (strcmp(string, "023740") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsEVRESSMalfunction = 0x01;
  645. if (strcmp(string, "023741") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsChargingCurrentdifferential = 0x01;
  646. if (strcmp(string, "023742") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsChargingVoltageOutOfRange = 0x01;
  647. if (strcmp(string, "023743") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsChargingSystemIncompatibility = 0x01;
  648. if (strcmp(string, "023744") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsEmergencyEvent = 0x01;
  649. if (strcmp(string, "023745") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsBreaker = 0x01;
  650. if (strcmp(string, "023746") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsNoData = 0x01;
  651. if (strcmp(string, "023747") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.Ccsreserved_by_DIN_A = 0x01;
  652. if (strcmp(string, "023748") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.Ccsreserved_by_DIN_B = 0x01;
  653. if (strcmp(string, "023749") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.Ccsreserved_by_DIN_C = 0x01;
  654. if (strcmp(string, "023750") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.Ccsreserved_by_ISO_1 = 0x01;
  655. if (strcmp(string, "023751") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.Ccsreserved_by_ISO_2 = 0x01;
  656. if (strcmp(string, "023752") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.Ccsreserved_by_ISO_3 = 0x01;
  657. if (strcmp(string, "023753") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.Ccsreserved_by_OEM_1 = 0x01;
  658. if (strcmp(string, "023754") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.Ccsreserved_by_OEM_2 = 0x01;
  659. if (strcmp(string, "023755") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.Ccsreserved_by_OEM_3 = 0x01;
  660. if (strcmp(string, "023756") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.Ccsreserved_by_OEM_4 = 0x01;
  661. if (strcmp(string, "023757") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.Ccsreserved_by_OEM_5 = 0x01;
  662. if (strcmp(string, "023758") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsSequenceError = 0x01;
  663. if (strcmp(string, "023759") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsSignatureError = 0x01;
  664. if (strcmp(string, "023760") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsUnknownSession = 0x01;
  665. if (strcmp(string, "023761") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsServiceIDInvalid = 0x01;
  666. if (strcmp(string, "023762") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsPaymentSelectionInvalid = 0x01;
  667. if (strcmp(string, "023763") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsIdentificationSelectionInvalid = 0x01;
  668. if (strcmp(string, "023764") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsServiceSelectionInvalid = 0x01;
  669. if (strcmp(string, "023765") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCertificateExpired = 0x01;
  670. if (strcmp(string, "023766") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCertificateNotYetValid = 0x01;
  671. if (strcmp(string, "023767") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCertificateRevoked = 0x01;
  672. if (strcmp(string, "023768") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsNoCertificateAvailable = 0x01;
  673. if (strcmp(string, "023769") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCertChainError = 0x01;
  674. if (strcmp(string, "023770") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCertValidationError = 0x01;
  675. if (strcmp(string, "023771") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCertVerificationError = 0x01;
  676. if (strcmp(string, "023772") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsContractCanceled = 0x01;
  677. if (strcmp(string, "023773") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsChallengeInvalid = 0x01;
  678. if (strcmp(string, "023774") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsWrongEnergyTransferMode = 0x01;
  679. if (strcmp(string, "023775") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsWrongChargeParameter = 0x01;
  680. if (strcmp(string, "023776") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsChargingProfileInvalid = 0x01;
  681. if (strcmp(string, "023777") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTariffSelectionInvalid = 0x01;
  682. if (strcmp(string, "023778") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsEVSEPresentVoltageToLow = 0x01;
  683. if (strcmp(string, "023779") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsPowerDeliveryNotApplied = 0x01;
  684. if (strcmp(string, "023780") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsMeteringSignatureNotValid = 0x01;
  685. if (strcmp(string, "023781") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsNoChargeServiceSelected = 0x01;
  686. if (strcmp(string, "023782") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsContactorError = 0x01;
  687. if (strcmp(string, "023783") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCertificateNotAllowedAtThisEVSE = 0x01;
  688. if (strcmp(string, "023784") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsGAChargeStop = 0x01;
  689. if (strcmp(string, "023785") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsAlignmentError = 0x01;
  690. if (strcmp(string, "023786") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsACDError = 0x01;
  691. if (strcmp(string, "023787") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsAssociationError = 0x01;
  692. if (strcmp(string, "023788") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsEVSEChargeAbort = 0x01;
  693. if (strcmp(string, "023789") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsNoSupportedAppProtocol = 0x01;
  694. if (strcmp(string, "023790") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsContractNotAccepted = 0x01;
  695. if (strcmp(string, "023791") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsMOUnknown = 0x01;
  696. if (strcmp(string, "023792") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsOEM_Prov_CertificateRevoke = 0x01;
  697. if (strcmp(string, "023793") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsOEM_SubCA1_CertificateRevoked = 0x01;
  698. if (strcmp(string, "023794") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsOEM_SubCA2_CertificateRevoked = 0x01;
  699. if (strcmp(string, "023795") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsOEM_RootCA_CertificateRevoked = 0x01;
  700. if (strcmp(string, "023796") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsMO_Prov_CertificateRevoked = 0x01;
  701. if (strcmp(string, "023797") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsMO_SubCA1_CertificateRevoked = 0x01;
  702. if (strcmp(string, "023798") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsMO_SubCA2_CertificateRevoked = 0x01;
  703. if (strcmp(string, "023799") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsMO_RootCA_CertificateRevoked = 0x01;
  704. if (strcmp(string, "023800") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCPS_Prov_CertificateRevoked = 0x01;
  705. if (strcmp(string, "023801") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCPS_SubCA1_CertificateRevoked = 0x01;
  706. if (strcmp(string, "023802") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCPS_SubCA2_CertificateRevoked = 0x01;
  707. if (strcmp(string, "023803") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCPS_RootCA_CertificateRevoked = 0x01;
  708. if (strcmp(string, "023809") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_EVSE_SLAC_init = 0x01;
  709. if (strcmp(string, "023810") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_match_response = 0x01;
  710. if (strcmp(string, "023811") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_match_sequence = 0x01;
  711. if (strcmp(string, "023812") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_EVSE_match_MNBC = 0x01;
  712. if (strcmp(string, "023813") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_EVSE_avg_atten_calc = 0x01;
  713. if (strcmp(string, "023814") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_match_response = 0x01;
  714. if (strcmp(string, "023815") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_EVSE_match_session = 0x01;
  715. if (strcmp(string, "023816") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_EVSE_assoc_session = 0x01;
  716. if (strcmp(string, "023817") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_EVSE_vald_toggle = 0x01;
  717. if (strcmp(string, "023823") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsUDP_TT_match_join = 0x01;
  718. if (strcmp(string, "023824") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTCP_TT_match_join = 0x01;
  719. if (strcmp(string, "023825") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_amp_map_exchange = 0x01;
  720. if (strcmp(string, "023826") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_link_ready_notification = 0x01;
  721. if (strcmp(string, "023832") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsSupportedAppProtocolRes = 0x01;
  722. if (strcmp(string, "023833") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsSessionSetupRes = 0x01;
  723. if (strcmp(string, "023834") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsServiceDiscoveryRes = 0x01;
  724. if (strcmp(string, "023835") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsServicePaymentSelectionRes = 0x01;
  725. if (strcmp(string, "023836") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsContractAuthenticationRes = 0x01;
  726. if (strcmp(string, "023837") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsChargeParameterDiscoveryRes = 0x01;
  727. if (strcmp(string, "023838") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsPowerDeliveryRes = 0x01;
  728. if (strcmp(string, "023839") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCableCheckRes = 0x01;
  729. if (strcmp(string, "023840") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsPreChargeRes = 0x01;
  730. if (strcmp(string, "023841") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCurrentDemandRes = 0x01;
  731. if (strcmp(string, "023842") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsWeldingDetectionRes = 0x01;
  732. if (strcmp(string, "023843") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsSessionStopRes = 0x01;
  733. if (strcmp(string, "023844") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsSequence_Time = 0x01;
  734. if (strcmp(string, "023845") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsReadyToCharge_Performance_Time = 0x01;
  735. if (strcmp(string, "023846") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCommunicationSetup_Performance_Time = 0x01;
  736. if (strcmp(string, "023847") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCableCheck_Performance_Time = 0x01;
  737. if (strcmp(string, "023848") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCPState_Detection_Time = 0x01;
  738. if (strcmp(string, "023849") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCPOscillator_Retain_Time = 0x01;
  739. if (strcmp(string, "023855") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_GET_EV_TARGET_INFO = 0x01;
  740. if (strcmp(string, "023856") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_GET_EV_TARGET_INFO = 0x01;
  741. if (strcmp(string, "023857") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_GET_EV_BATTERY_INFO = 0x01;
  742. if (strcmp(string, "023858") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_GET_EV_BATTERY_INFO = 0x01;
  743. if (strcmp(string, "023859") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_EV_STOP_EVENT = 0x01;
  744. if (strcmp(string, "023860") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_EV_STOP_EVENT = 0x01;
  745. if (strcmp(string, "023861") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_EVSE_STOP_EVENT = 0x01;
  746. if (strcmp(string, "023862") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_EVSE_STOP_EVENT = 0x01;
  747. if (strcmp(string, "023863") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_GET_MISC_INFO = 0x01;
  748. if (strcmp(string, "023864") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_GET_MISC_INFO = 0x01;
  749. if (strcmp(string, "023865") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_DOWNLOAD_REQUEST = 0x01;
  750. if (strcmp(string, "023866") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_DOWNLOAD_REQUEST = 0x01;
  751. if (strcmp(string, "023867") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_START_BLOCK_TRANSFER = 0x01;
  752. if (strcmp(string, "023868") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_START_BLOCK_TRANSFER = 0x01;
  753. if (strcmp(string, "023869") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_DATA_TRANSFER = 0x01;
  754. if (strcmp(string, "023870") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_DATA_TRANSFER = 0x01;
  755. if (strcmp(string, "023871") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_DOWNLOAD_FINISH = 0x01;
  756. if (strcmp(string, "023872") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_DOWNLOAD_FINISH = 0x01;
  757. if (strcmp(string, "023873") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_ISOLATION_STATUS = 0x01;
  758. if (strcmp(string, "023874") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_ISOLATION_STATUS = 0x01;
  759. if (strcmp(string, "023875") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_CONNECTOR_INFO = 0x01;
  760. if (strcmp(string, "023876") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_CONNECTOR_INFO = 0x01;
  761. if (strcmp(string, "023877") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_RTC_INFO = 0x01;
  762. if (strcmp(string, "023878") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_RTC_INFO = 0x01;
  763. if (strcmp(string, "023879") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_EVSE_PRECHARGE_INFO = 0x01;
  764. if (strcmp(string, "023880") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_EVSE_PRECHARGE_INFO = 0x01;
  765. if (strcmp(string, "023881") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsMSG_Sequence = 0x01;
  766. if (strcmp(string, "023882") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCAN_MSG_Unrecognized_CMD_ID = 0x01;
  767. if (strcmp(string, "023883") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsDIN_Msg_Decode_Error = 0x01;
  768. if (strcmp(string, "023884") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsDIN_Msg_Encode_Error = 0x01;
  769. if (strcmp(string, "023885") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsISO1_Msg_Decode_Error = 0x01;
  770. if (strcmp(string, "023886") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsISO1_Msg_Encode_Error = 0x01;
  771. if (strcmp(string, "023887") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsISO2_Msg_Decode_Error = 0x01;
  772. if (strcmp(string, "023888") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsISO2_Msg_Encode_Error = 0x01;
  773. if (strcmp(string, "023889") == 0) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCpStatus_Error = 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. _chargingData[targetGun]->ConnectorPlugIn = frame.data[0];
  912. _chargingData[targetGun]->PilotVoltage = frame.data[1];
  913. //PRINTF_FUNC("index = %d, ConnectorPlugIn = %x, data[0] = %x \n", targetGun, _chargingData[targetGun]->ConnectorPlugIn, frame.data[0]);
  914. //PRINTF_FUNC("ConnectorPlugIn = %x \n", (-120 + frame.data[1]) / 10);
  915. }
  916. break;
  917. case ACK_EV_FW_VERSION:
  918. {
  919. if (_chargingData[targetGun]->Type == _Type_Chademo)
  920. {
  921. memcpy(ShmCHAdeMOData->evse[_chargingData[targetGun]->type_index].version, frame.data, ARRAY_SIZE(frame.data));
  922. ShmCHAdeMOData->evse[_chargingData[targetGun]->type_index].SelfTest_Comp = PASS;
  923. PRINTF_FUNC("chademo ver. : %s\n", ShmCHAdeMOData->evse[_chargingData[targetGun]->type_index].version);
  924. }
  925. else if (_chargingData[targetGun]->Type == _Type_GB)
  926. {
  927. memcpy(ShmGBTData->evse[_chargingData[targetGun]->type_index].version, frame.data, ARRAY_SIZE(frame.data));
  928. ShmGBTData->evse[_chargingData[targetGun]->type_index].SelfTest_Comp = PASS;
  929. PRINTF_FUNC("gbt ver. : %s\n", ShmGBTData->evse[_chargingData[targetGun]->type_index].version);
  930. }
  931. else if (_chargingData[targetGun]->Type == _Type_CCS_2)
  932. {
  933. if (ShmCcsData->CommProtocol == 0x01)
  934. {
  935. memcpy(&ShmCcsData->V2GMessage_DIN70121[_chargingData[targetGun]->type_index].version, frame.data, ARRAY_SIZE(frame.data));
  936. ShmCcsData->V2GMessage_DIN70121[_chargingData[targetGun]->type_index].SelfTest_Comp = PASS;
  937. PRINTF_FUNC("CCS FW = %s \n", ShmCcsData->V2GMessage_DIN70121[_chargingData[targetGun]->type_index].version);
  938. }
  939. }
  940. }
  941. break;
  942. case ACK_EV_HW_VERSION:
  943. {
  944. //PRINTF_FUNC("Get EV HW = %s \n", frame.data);
  945. }
  946. break;
  947. case ACK_GET_OUTPUT_REQ:
  948. {
  949. _chargingData[targetGun]->EvBatterySoc = frame.data[1];
  950. _chargingData[targetGun]->EvBatterytargetVoltage = ((short) frame.data[3] << 8) + (short) frame.data[2];
  951. _chargingData[targetGun]->EvBatterytargetCurrent = ((short) frame.data[5] << 8) + (short) frame.data[4];
  952. _chargingData[targetGun]->PresentChargedDuration = ((short) frame.data[7] << 8) + (short) frame.data[6];
  953. if (_chargingData[targetGun]->Type == _Type_Chademo)
  954. {
  955. if (ShmCHAdeMOData->ev[_chargingData[targetGun]->type_index].EvDetection != frame.data[0])
  956. {
  957. ShmCHAdeMOData->ev[_chargingData[targetGun]->type_index].PresentMsgFlowStatus = frame.data[0];
  958. }
  959. ShmCHAdeMOData->ev[_chargingData[targetGun]->type_index].EvDetection = frame.data[0];
  960. ShmCHAdeMOData->ev[_chargingData[targetGun]->type_index].SOC = _chargingData[targetGun]->EvBatterySoc;
  961. ShmCHAdeMOData->ev[_chargingData[targetGun]->type_index].TargetBatteryVoltage = _chargingData[targetGun]->EvBatterytargetVoltage;
  962. ShmCHAdeMOData->ev[_chargingData[targetGun]->type_index].ChargingCurrentRequest = _chargingData[targetGun]->EvBatterytargetCurrent;
  963. }
  964. else if (_chargingData[targetGun]->Type == _Type_GB)
  965. {
  966. if (ShmGBTData->ev[_chargingData[targetGun]->type_index].EvDetection != frame.data[0])
  967. {
  968. ShmGBTData->ev[_chargingData[targetGun]->type_index].PresentMsgFlowStatus = frame.data[0];
  969. }
  970. ShmGBTData->ev[_chargingData[targetGun]->type_index].EvDetection = frame.data[0];
  971. ShmGBTData->ev[_chargingData[targetGun]->type_index].SOC = _chargingData[targetGun]->EvBatterySoc;
  972. ShmGBTData->ev[_chargingData[targetGun]->type_index].TargetBatteryVoltage = _chargingData[targetGun]->EvBatterytargetVoltage;
  973. ShmGBTData->ev[_chargingData[targetGun]->type_index].ChargingCurrentRequest = _chargingData[targetGun]->EvBatterytargetCurrent;
  974. }
  975. else if (_chargingData[targetGun]->Type == _Type_CCS_2)
  976. {
  977. if(ShmCcsData->CommProtocol == 0x01)
  978. {
  979. ShmCcsData->V2GMessage_DIN70121[_chargingData[targetGun]->type_index].PresentMsgFlowStatus = frame.data[0];
  980. }
  981. }
  982. //PRINTF_FUNC("EvBatterytargetVoltage = %f \n", _chargingData[targetGun]->EvBatterytargetVoltage);
  983. //PRINTF_FUNC("EvBatterytargetCurrent = %f \n", _chargingData[targetGun]->EvBatterytargetCurrent);
  984. //PRINTF_FUNC("BatteryVoltage = %d \n", ShmCHAdeMOData->ev[_chargingData[target]->type_index].TargetBatteryVoltage);
  985. //PRINTF_FUNC("CurrentRequest = %d \n", ShmCHAdeMOData->ev[_chargingData[target]->type_index].ChargingCurrentRequest);
  986. }
  987. break;
  988. case ACK_GET_EV_BATTERY_INFO:
  989. {
  990. //_chargingData[target].EvACorDCcharging = frame.data[0];
  991. //_chargingData[target]->TotalBatteryCap = ((float) frame.data[4] << 8) + (short) frame.data[3];
  992. _chargingData[targetGun]->EvBatteryMaxVoltage = ((short) frame.data[4] << 8) + (short) frame.data[3];
  993. //_chargingData[target]->EvBatteryMaxCurrent = ((float) frame.data[4] << 8) + (short) frame.data[3];
  994. //_chargingData[target].MaxiBatteryCurrent = ((short) frame.data[6] << 8) + (short) frame.data[5];
  995. if (_chargingData[targetGun]->Type == _Type_Chademo)
  996. {
  997. ShmCHAdeMOData->ev[_chargingData[targetGun]->type_index].TotalBatteryCapacity = ((short) frame.data[2] << 8) + (short) frame.data[1];
  998. ShmCHAdeMOData->ev[_chargingData[targetGun]->type_index].MaxiBatteryVoltage = _chargingData[targetGun]->EvBatteryMaxVoltage;
  999. //PRINTF_FUNC("EvBatteryMaxVoltage = %f \n", _chargingData[target]->EvBatteryMaxVoltage);
  1000. //PRINTF_FUNC("TotalBatteryCapacity = %d \n", ShmCHAdeMOData->ev[_chargingData[target]->type_index].TotalBatteryCapacity);
  1001. //PRINTF_FUNC("MaxiBatteryVoltage = %d \n", ShmCHAdeMOData->ev[_chargingData[target]->type_index].MaxiBatteryVoltage);
  1002. }
  1003. else if (_chargingData[targetGun]->Type == _Type_GB)
  1004. {
  1005. ShmGBTData->ev[_chargingData[targetGun]->type_index].TotalBatteryCapacity = ((short) frame.data[2] << 8) + (short) frame.data[1];
  1006. ShmGBTData->ev[_chargingData[targetGun]->type_index].MaxiBatteryVoltage = _chargingData[targetGun]->EvBatteryMaxVoltage;
  1007. }
  1008. else if (_chargingData[targetGun]->Type == _Type_CCS_2)
  1009. {
  1010. }
  1011. }
  1012. break;
  1013. case ACK_GET_MISCELLANEOUS_INFO:
  1014. {
  1015. if (_chargingData[targetGun]->Type == _Type_Chademo)
  1016. {
  1017. _chargingData[targetGun]->GunLocked = frame.data[0];
  1018. ShmCHAdeMOData->evse[_chargingData[targetGun]->type_index].ConnectorTemperatureP = frame.data[1];
  1019. ShmCHAdeMOData->evse[_chargingData[targetGun]->type_index].ConnectorTemperatureN = frame.data[2];
  1020. _chargingData[targetGun]->PilotVoltage = (float)(-120 + frame.data[3]) / 10;
  1021. ShmCHAdeMOData->evse[_chargingData[targetGun]->type_index].EvboardStatus = frame.data[7];
  1022. }
  1023. else if (_chargingData[targetGun]->Type == _Type_GB)
  1024. {
  1025. _chargingData[targetGun]->GunLocked = frame.data[0];
  1026. ShmGBTData->evse[_chargingData[targetGun]->type_index].ConnectorTemperatureP = frame.data[1];
  1027. ShmGBTData->evse[_chargingData[targetGun]->type_index].ConnectorTemperatureN = frame.data[2];
  1028. _chargingData[targetGun]->PilotVoltage = (float)(-120 + frame.data[3]) / 10;
  1029. ShmGBTData->evse[_chargingData[targetGun]->type_index].EvboardStatus = frame.data[7];
  1030. }
  1031. else if (_chargingData[targetGun]->Type == _Type_CCS_2)
  1032. {
  1033. if (ShmCcsData->CommProtocol == 0x01)
  1034. {
  1035. _chargingData[targetGun]->GunLocked = frame.data[0];
  1036. //ShmCcsData->V2GMessage_DIN70121[_chargingData[targetGun]->type_index]. .ConnectorTemperatureP = frame.data[1];
  1037. //ShmCcsData->V2GMessage_DIN70121[_chargingData[targetGun]->type_index]. .ConnectorTemperatureN = frame.data[2];
  1038. _chargingData[targetGun]->PilotVoltage = (float)(-120 + frame.data[3]) / 10;
  1039. }
  1040. }
  1041. //PRINTF_FUNC("EvboardStatus = %x \n", ShmCHAdeMOData->evse[_chargingData[target]->type_index].EvboardStatus);
  1042. //PRINTF_FUNC("ConnectorPlug locked = %x \n", frame.data[0]);
  1043. //PRINTF_FUNC("ConnectorTemp 0= %d \n", ShmCHAdeMOData->evse[_chargingData[target]->type_index].ConnectorTemperatureP);
  1044. //PRINTF_FUNC("ConnectorTemp 1= %d \n", ShmCHAdeMOData->evse[_chargingData[target]->type_index].ConnectorTemperatureN);
  1045. //PRINTF_FUNC("PilotVoltage = %x \n", (-120 + frame.data[3]) / 10);
  1046. }
  1047. break;
  1048. case ACK_EVSE_ISOLATION_STATUS: {}
  1049. break;
  1050. case ACK_EVSE_PRECHAGE_INFO:
  1051. {
  1052. _chargingData[targetGun]->PrechargeStatus = frame.data[0];
  1053. }
  1054. break;
  1055. case NOTIFICATION_EV_STOP:
  1056. {
  1057. // 車端要求停止
  1058. // frame.data[0] : 0x01 => normal stop, 0x02 => ev emergency stop
  1059. PRINTF_FUNC("NOTIFICATION_EV_STOP err level = %d-----------------------------\n", frame.data[0]);
  1060. if (frame.data[0] == 0x02)
  1061. {
  1062. AbnormalStopAnalysis(targetGun, frame.data + 1);
  1063. }
  1064. _chargingData[targetGun]->StopChargeFlag = YES;
  1065. }
  1066. break;
  1067. default:
  1068. PRINTF_FUNC("EV board = %d, Ack none defined. intCmd = %d \n", targetGun, intCmd);
  1069. break;
  1070. }
  1071. }
  1072. usleep(10000);
  1073. }
  1074. }
  1075. }
  1076. //================================================
  1077. // Main process
  1078. //================================================
  1079. // 檢查 Byte 中某個 Bit 的值
  1080. // _byte : 欲改變的 byte
  1081. // _bit : 該 byte 的第幾個 bit
  1082. unsigned char EvDetectionStatus(unsigned char _byte, unsigned char _bit)
  1083. {
  1084. return ( _byte & mask_table[_bit] ) != 0x00;
  1085. }
  1086. bool IsConnectorPlugIn(struct ChargingInfoData *chargingData)
  1087. {
  1088. return (chargingData->ConnectorPlugIn == 0x01) ? true : false;
  1089. }
  1090. void SetPresentChargingOutputPower(struct ChargingInfoData *chargingData_1, struct ChargingInfoData *chargingData_2)
  1091. {
  1092. float vol1 = 0, cur1 = 0;
  1093. float vol2 = 0, cur2 = 0;
  1094. //PRINTF_FUNC("f vol - 0 = %f \n", chargingData_1->FireChargingVoltage);
  1095. //PRINTF_FUNC("f cur - 0 = %f \n", chargingData_1->PresentChargingCurrent);
  1096. //PRINTF_FUNC("***********************f vol - 1 = %f \n", chargingData_2->FireChargingVoltage);
  1097. //PRINTF_FUNC("***********************f cur - 1 = %f \n", chargingData_2->PresentChargingCurrent);
  1098. vol1 = chargingData_1->FireChargingVoltage;
  1099. cur1 = chargingData_1->PresentChargingCurrent;
  1100. vol2 = chargingData_2->FireChargingVoltage;
  1101. cur2 = chargingData_2->PresentChargingCurrent;
  1102. SetPresentOutputPower(vol1, cur1, vol2, cur2);
  1103. }
  1104. void SetPresentChargingOutputCap(struct ChargingInfoData *chargingData_1, struct ChargingInfoData *chargingData_2)
  1105. {
  1106. float pow1 = 0, cur1 = 0;
  1107. float pow2 = 0, cur2 = 0;
  1108. float vol = 0;
  1109. pow1 = chargingData_1->AvailableChargingPower;
  1110. cur1 = chargingData_1->AvailableChargingCurrent;
  1111. vol = chargingData_1->MaximumChargingVoltage;
  1112. GetMaxVolAndCurMethod(chargingData_1->Index, &vol, &cur1);
  1113. GetMaxPowerMethod(&pow1);
  1114. pow2 = chargingData_2->AvailableChargingPower;
  1115. cur2 = chargingData_2->AvailableChargingCurrent;
  1116. vol = chargingData_2->MaximumChargingVoltage;
  1117. GetMaxVolAndCurMethod(chargingData_2->Index, &vol, &cur2);
  1118. GetMaxPowerMethod(&pow2);
  1119. if (_pow_1 != pow1 ||
  1120. _cur_1 != cur1 ||
  1121. _pow_2 != pow2 ||
  1122. _cur_2 != cur2)
  1123. {
  1124. PRINTF_FUNC("To EV Power_1 = %f, Cur_1 = %f, Power_2 = %f, Cur_2 = %f \n",
  1125. pow1, cur1, pow2, cur2);
  1126. _pow_1 = pow1; _cur_1 = cur1; _pow_2 = pow2; _cur_2 = cur2;
  1127. }
  1128. SetPresentOutputCapacity(pow1, cur1, pow2, cur2);
  1129. }
  1130. void Initialization()
  1131. {
  1132. bool isPass = false;
  1133. while(!isPass)
  1134. {
  1135. isPass = true;
  1136. for (byte _index = 0; _index < gun_count; _index++)
  1137. {
  1138. if (!FindChargingInfoData(_index, &_chargingData[0]))
  1139. {
  1140. DEBUG_ERROR("EvComm (main) : FindChargingInfoData false \n");
  1141. isPass = false;
  1142. break;
  1143. }
  1144. }
  1145. }
  1146. }
  1147. void GetMaxVolAndCurMethod(byte index, float *vol, float *cur)
  1148. {
  1149. if (maxChargingVol[index] != 0 && maxChargingVol[index] <= *vol)
  1150. *vol = maxChargingVol[index];
  1151. if (maxChargingCur[index] != 0 && maxChargingCur[index] <= *cur)
  1152. *cur = maxChargingCur[index];
  1153. }
  1154. void GetMaxPowerMethod(float *pow)
  1155. {
  1156. if (maxChargingPow != 0 && maxChargingPow <= *pow)
  1157. *pow = maxChargingPow;
  1158. }
  1159. time_t GetRtcInfoForEpoch()
  1160. {
  1161. struct timeb csuTime;
  1162. struct tm *tmCSU;
  1163. struct tm t;
  1164. time_t result;
  1165. ftime(&csuTime);
  1166. tmCSU = localtime(&csuTime.time);
  1167. t.tm_year = tmCSU->tm_year;
  1168. t.tm_mon = tmCSU->tm_mon;
  1169. t.tm_mday = tmCSU->tm_mday;
  1170. t.tm_hour = tmCSU->tm_hour;
  1171. t.tm_min = tmCSU->tm_min;
  1172. t.tm_sec = tmCSU->tm_sec;
  1173. t.tm_isdst = -1;
  1174. result = mktime(&t);
  1175. return result;
  1176. }
  1177. byte GetStopChargingReasonByEvse(byte gunIndex, byte *reason)
  1178. {
  1179. byte result = NO;
  1180. if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.EmergencyStopTrip == 0x01)
  1181. {
  1182. // 012251
  1183. *(reason + 5) = 0;
  1184. *(reason + 4) = 1;
  1185. *(reason + 3) = 2;
  1186. *(reason + 2) = 2;
  1187. *(reason + 1) = 5;
  1188. *(reason + 0) = 1;
  1189. result = YES;
  1190. }
  1191. if (_chargingData[gunIndex]->Type == _Type_Chademo)
  1192. {
  1193. if (ShmStatusCodeData->FaultCode.FaultEvents.bits.ChademoOutputRelayDrivingFault == YES)
  1194. {
  1195. // 011012
  1196. *(reason + 5) = 0;
  1197. *(reason + 4) = 1;
  1198. *(reason + 3) = 1;
  1199. *(reason + 2) = 0;
  1200. *(reason + 1) = 1;
  1201. *(reason + 0) = 2;
  1202. result = YES;
  1203. }
  1204. else if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.ChademoOutputUVPFail == YES)
  1205. {
  1206. // 012289
  1207. *(reason + 5) = 0;
  1208. *(reason + 4) = 1;
  1209. *(reason + 3) = 2;
  1210. *(reason + 2) = 2;
  1211. *(reason + 1) = 8;
  1212. *(reason + 0) = 9;
  1213. result = YES;
  1214. }
  1215. }
  1216. else if (_chargingData[gunIndex]->Type == _Type_GB)
  1217. {
  1218. if (ShmStatusCodeData->FaultCode.FaultEvents.bits.ChademoOutputRelayDrivingFault == YES)
  1219. {
  1220. // 012290
  1221. *(reason + 5) = 0;
  1222. *(reason + 4) = 1;
  1223. *(reason + 3) = 2;
  1224. *(reason + 2) = 2;
  1225. *(reason + 1) = 9;
  1226. *(reason + 0) = 0;
  1227. result = YES;
  1228. }
  1229. }
  1230. else if (_chargingData[gunIndex]->Type == _Type_CCS_2)
  1231. {
  1232. if (ShmStatusCodeData->FaultCode.FaultEvents.bits.CcsOutputRelayDrivingFault == YES)
  1233. {
  1234. // 011014
  1235. *(reason + 5) = 0;
  1236. *(reason + 4) = 1;
  1237. *(reason + 3) = 1;
  1238. *(reason + 2) = 0;
  1239. *(reason + 1) = 1;
  1240. *(reason + 0) = 4;
  1241. result = YES;
  1242. }
  1243. else if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CcsOutputUVPFail == YES)
  1244. {
  1245. // 012288
  1246. *(reason + 5) = 0;
  1247. *(reason + 4) = 1;
  1248. *(reason + 3) = 2;
  1249. *(reason + 2) = 2;
  1250. *(reason + 1) = 8;
  1251. *(reason + 0) = 8;
  1252. result = YES;
  1253. }
  1254. }
  1255. return result;
  1256. }
  1257. int main(int argc, char *argv[])
  1258. {
  1259. if(InitShareMemory() == FAIL)
  1260. {
  1261. #ifdef SystemLogMessage
  1262. DEBUG_ERROR("InitShareMemory NG\n");
  1263. #endif
  1264. if(ShmStatusCodeData != NULL)
  1265. {
  1266. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.FailToCreateShareMemory=1;
  1267. }
  1268. sleep(5);
  1269. return 0;
  1270. }
  1271. gun_count = ShmSysConfigAndInfo->SysConfig.TotalConnectorCount;
  1272. Initialization();
  1273. CanFd = InitCanBus();
  1274. CANReceiver();
  1275. byte priorityLow = 1;
  1276. time_t rtc = GetRtcInfoForEpoch();
  1277. while(CanFd)
  1278. {
  1279. for(byte _index = 0; _index < gun_count; _index++)
  1280. {
  1281. if (priorityLow == 1)
  1282. {
  1283. // 優先權較低 - 只要有回應即不會再詢問
  1284. if (_chargingData[_index]->Type == _Type_Chademo &&
  1285. ShmCHAdeMOData->evse[_chargingData[_index]->type_index].SelfTest_Comp != PASS)
  1286. {
  1287. SyncRtcInfo(_index, _chargingData[_index]->Evboard_id, (int)rtc);
  1288. GetFirmwareVersion(_index, _chargingData[_index]->Evboard_id);
  1289. }
  1290. else if (_chargingData[_index]->Type == _Type_GB &&
  1291. ShmGBTData->evse[_chargingData[_index]->type_index].SelfTest_Comp != PASS)
  1292. {
  1293. SyncRtcInfo(_index, _chargingData[_index]->Evboard_id, (int)rtc);
  1294. GetFirmwareVersion(_index, _chargingData[_index]->Evboard_id);
  1295. }
  1296. else if (_chargingData[_index]->Type == _Type_CCS_2)
  1297. {
  1298. if (ShmCcsData->CommProtocol == 0x01 &&
  1299. ShmCcsData->V2GMessage_DIN70121[_chargingData[_index]->type_index].SelfTest_Comp != PASS)
  1300. {
  1301. SyncRtcInfo(_index, _chargingData[_index]->Evboard_id, (int)rtc);
  1302. GetFirmwareVersion(_index, _chargingData[_index]->Evboard_id);
  1303. }
  1304. }
  1305. // 固定要取得的資訊 : 1.槍鎖狀態, 2."Connector 1" 溫度, 3."Connector 2" 溫度, 4.Pilot Voltage
  1306. //PRINTF_FUNC("GetMiscellaneousInfo. index = %d, Eid = %d \n", _index, _chargingData[_index]->Evboard_id);
  1307. GetMiscellaneousInfo(_index,
  1308. _chargingData[_index]->RelayK1K2Status,
  1309. _chargingData[_index]->PresentChargedEnergy,
  1310. (_chargingData[_index]->PresentChargingVoltage * 10),
  1311. _chargingData[_index]->Evboard_id);
  1312. }
  1313. switch (_chargingData[_index]->SystemStatus)
  1314. {
  1315. case S_IDLE:
  1316. case S_RESERVATION:
  1317. _chargingData[_index]->PresentChargedEnergy = 0;
  1318. _chargingData[_index]->PresentChargingPower = 0;
  1319. _chargingData[_index]->GroundFaultStatus = GFD_WAIT;
  1320. _chargingData[_index]->StopChargeFlag = NO;
  1321. chargingTime[_index] = 0;
  1322. if (_chargingData[_index]->Type == _Type_Chademo)
  1323. {
  1324. ClearAbnormalStatus_Chademo(_index);
  1325. }
  1326. else if (_chargingData[_index]->Type == _Type_GB)
  1327. {
  1328. ClearAbnormalStatus_GB(_index);
  1329. }
  1330. else if (_chargingData[_index]->Type == _Type_CCS_2)
  1331. {
  1332. ClearAbnormalStatus_CCS(_index);
  1333. }
  1334. if (priorityLow == 1)
  1335. {
  1336. maxChargingCur[_index] = ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent * 10;
  1337. maxChargingPow = (ShmSysConfigAndInfo->SysConfig.MaxChargingPower * 10);
  1338. }
  1339. break;
  1340. case S_PREPARNING:
  1341. {
  1342. // 設定當前輸出
  1343. if (gun_count == 1)
  1344. SetPresentChargingOutputPower(_chargingData[0], _chargingData[0]);
  1345. else if (gun_count == 2)
  1346. SetPresentChargingOutputPower(_chargingData[0], _chargingData[1]);
  1347. }
  1348. break;
  1349. case S_PREPARING_FOR_EV:
  1350. {
  1351. // 開始確認車端是否同意開始充電 : 1.SOC, 2.Target Vol, 3.Target Cur, 4.Charging remaining time
  1352. GetOutputReq(_index, _chargingData[_index]->Evboard_id);
  1353. // PRINTF_FUNC("PresentChargingVoltage = %f \n", _chargingData[_index]->PresentChargingVoltage);
  1354. // PRINTF_FUNC("PresentChargingCurrent = %f \n", _chargingData[_index]->PresentChargingCurrent);
  1355. // PRINTF_FUNC("AvailableChargingPower = %f \n", _chargingData[_index]->AvailableChargingPower);
  1356. // PRINTF_FUNC("AvailableChargingCurrent = %f \n", _chargingData[_index]->AvailableChargingCurrent);
  1357. // PRINTF_FUNC("MaximumChargingVoltage = %f \n", _chargingData[_index]->MaximumChargingVoltage);
  1358. // 設定當前輸出
  1359. if (gun_count == 1)
  1360. SetPresentChargingOutputPower(_chargingData[0], _chargingData[0]);
  1361. else if (gun_count == 2)
  1362. SetPresentChargingOutputPower(_chargingData[0], _chargingData[1]);
  1363. if (priorityLow == 1)
  1364. {
  1365. float maxVol, maxCur;
  1366. // 樁端輸出能力
  1367. maxVol = _chargingData[_index]->MaximumChargingVoltage;
  1368. maxCur = _chargingData[_index]->AvailableChargingCurrent;
  1369. GetMaxVolAndCurMethod(_index, &maxVol, &maxCur);
  1370. PRINTF_FUNC("To EV_%d Max_Vol = %f, Cap_Cur = %f, Cap_Pow = %f \n",
  1371. _index, maxVol, maxCur, _chargingData[_index]->AvailableChargingPower);
  1372. SetChargingPermission(_index, START,
  1373. _chargingData[_index]->AvailableChargingPower,
  1374. maxCur,
  1375. maxVol,
  1376. _chargingData[_index]->Evboard_id);
  1377. // 取得車端電池資訊 : 1.AC or DC ? 2.Total battery cap, 3.Max battery vol, 4.Max battery cur
  1378. GetEvBatteryInfo(_index, _chargingData[_index]->Evboard_id);
  1379. }
  1380. }
  1381. break;
  1382. case S_PREPARING_FOR_EVSE:
  1383. case S_CCS_PRECHARGE_ST0:
  1384. case S_CCS_PRECHARGE_ST1:
  1385. {
  1386. // 開始確認車端是否同意開始充電
  1387. GetOutputReq(_index, _chargingData[_index]->Evboard_id);
  1388. // 設定當前輸出
  1389. if (gun_count == 1)
  1390. SetPresentChargingOutputPower(_chargingData[0], _chargingData[0]);
  1391. else if (gun_count == 2)
  1392. SetPresentChargingOutputPower(_chargingData[0], _chargingData[1]);
  1393. if (priorityLow % 5 == 1)
  1394. {
  1395. // 樁端輸出能力改變
  1396. if (gun_count == 1)
  1397. SetPresentChargingOutputCap(_chargingData[0], _chargingData[0]);
  1398. else if (gun_count == 2)
  1399. SetPresentChargingOutputCap(_chargingData[0], _chargingData[1]);
  1400. }
  1401. // 持續通知 Isolation 測試狀態
  1402. if (priorityLow == 1)
  1403. {
  1404. // 拉 500 V 如果在一秒鐘內 GFD 都符合則 PASS
  1405. // if (_chargingData[_index]->FireChargingVoltage >= 3500)
  1406. // _chargingData[_index]->GroundFaultStatus = GFD_PASS;
  1407. //PRINTF_FUNC("To EV_%d GFD = %d \n", _index, _chargingData[_index]->GroundFaultStatus);
  1408. if(_chargingData[_index]->GroundFaultStatus != GFD_WAIT)
  1409. {
  1410. SetIsolationStatus(_index, _chargingData[_index]->GroundFaultStatus, _chargingData[_index]->Evboard_id);
  1411. }
  1412. if(_chargingData[_index]->SystemStatus == S_CCS_PRECHARGE_ST0 &&
  1413. _chargingData[_index]->PrechargeStatus == PRECHARGE_READY)
  1414. {
  1415. SetEvsePrechargeInfo(_index, PRECHARGE_PRERELAY_PASS, _chargingData[_index]->Evboard_id);
  1416. }
  1417. }
  1418. }
  1419. break;
  1420. case S_CHARGING:
  1421. {
  1422. // 計算 Power
  1423. _chargingData[_index]->PresentChargingPower = ((float)((_chargingData[_index]->PresentChargingVoltage) * (_chargingData[_index]->PresentChargingCurrent)) / 1000);
  1424. if (chargingTime[_index] == 0)
  1425. {
  1426. chargingTime[_index] = _chargingData[_index]->RemainChargingDuration;
  1427. }
  1428. else
  1429. {
  1430. int passTime = _chargingData[_index]->RemainChargingDuration - chargingTime[_index];
  1431. if (passTime > 0)
  1432. {
  1433. _chargingData[_index]->PresentChargedEnergy += (_chargingData[_index]->PresentChargingPower) * passTime / 3600;
  1434. chargingTime[_index] = _chargingData[_index]->RemainChargingDuration;
  1435. }
  1436. }
  1437. // 開始確認車端是否同意開始充電
  1438. GetOutputReq(_index, _chargingData[_index]->Evboard_id);
  1439. // 設定當前輸出
  1440. if (gun_count == 1)
  1441. SetPresentChargingOutputPower(_chargingData[0], _chargingData[0]);
  1442. else if (gun_count == 2)
  1443. SetPresentChargingOutputPower(_chargingData[0], _chargingData[1]);
  1444. // for test end
  1445. if (priorityLow % 5 == 0)
  1446. {
  1447. // 樁端輸出能力改變
  1448. if (gun_count == 1)
  1449. SetPresentChargingOutputCap(_chargingData[0], _chargingData[0]);
  1450. else if (gun_count == 2)
  1451. SetPresentChargingOutputCap(_chargingData[0], _chargingData[1]);
  1452. }
  1453. // GFD 失敗再通知
  1454. if (priorityLow == 1)
  1455. {
  1456. if(_chargingData[_index]->GroundFaultStatus == GFD_FAIL)
  1457. {
  1458. SetIsolationStatus(_index, _chargingData[_index]->GroundFaultStatus, _chargingData[_index]->Evboard_id);
  1459. }
  1460. if(_chargingData[_index]->Type == _Type_CCS_2 &&
  1461. _chargingData[_index]->PrechargeStatus == PRECHARGE_READY)
  1462. {
  1463. SetEvsePrechargeInfo(_index, PRECHARGE_CHARELAY_PASS, _chargingData[_index]->Evboard_id);
  1464. }
  1465. }
  1466. }
  1467. break;
  1468. case S_TERMINATING:
  1469. {
  1470. // 設定當前輸出
  1471. if (gun_count == 1)
  1472. SetPresentChargingOutputPower(_chargingData[0], _chargingData[0]);
  1473. else if (gun_count == 2)
  1474. SetPresentChargingOutputPower(_chargingData[0], _chargingData[1]);
  1475. // 槍鎖還在,則代表是樁端要求的停止
  1476. if (_chargingData[_index]->GunLocked == START ||
  1477. _chargingData[_index]->Type == _Type_CCS_2)
  1478. {
  1479. byte normalStop = 0x01;
  1480. byte stopReason[6] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
  1481. if (GetStopChargingReasonByEvse(_index, stopReason))
  1482. {
  1483. normalStop = 0x02;
  1484. }
  1485. EvseStopChargingEvent(normalStop, stopReason, _chargingData[_index]->Evboard_id);
  1486. }
  1487. GetOutputReq(_index, _chargingData[_index]->Evboard_id);
  1488. }
  1489. break;
  1490. case S_COMPLETE:
  1491. {
  1492. if (priorityLow == 1)
  1493. {
  1494. float maxVol, maxCur;
  1495. // 樁端輸出能力
  1496. maxVol = _chargingData[_index]->MaximumChargingVoltage;
  1497. maxCur = _chargingData[_index]->AvailableChargingCurrent;
  1498. GetMaxVolAndCurMethod(_index, &maxVol, &maxCur);
  1499. SetChargingPermission(_index, STOP,
  1500. _chargingData[_index]->AvailableChargingPower,
  1501. maxCur,
  1502. maxVol,
  1503. _chargingData[_index]->Evboard_id);
  1504. }
  1505. }
  1506. break;
  1507. }
  1508. }
  1509. priorityLow >= 20 ? priorityLow = 1 : priorityLow++;
  1510. usleep(45000); //EV 小板通訊 (50 ms)
  1511. }
  1512. DEBUG_INFO("Module_EvComm : Can-bus port = %d \n", CanFd);
  1513. return FAIL;
  1514. }