Module_EvComm.c 73 KB

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