Module_EvRxComm.c 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <stdint.h>
  4. #include <string.h>
  5. #include <fcntl.h>
  6. #include <unistd.h>
  7. #include <sys/stat.h>
  8. #include <linux/can.h>
  9. #include <linux/can/raw.h>
  10. #include "../Config.h"
  11. #include "../Log/log.h"
  12. #include "../Define/define.h"
  13. #include "../ShareMemory/shmMem.h"
  14. #include "Ev_Comm.h"
  15. #include "Module_EvComm.h"
  16. //------------------------------------------------------------------------------
  17. static struct SysConfigData *pSysConfig = NULL;
  18. static struct SysInfoData *pSysInfo = NULL;
  19. static struct WARNING_CODE_INFO *pSysWarning = NULL;
  20. static struct AlarmCodeData *pAlarmCode = NULL;
  21. static struct CHAdeMOData *ShmCHAdeMOData = NULL;
  22. static struct GBTData *ShmGBTData = NULL;
  23. static struct CcsData *ShmCcsData = NULL;
  24. static DcCommonInfo *ShmDcCommonData = NULL;
  25. //------------------------------------------------------------------------------
  26. extern bool AbnormalStopAnalysis(uint8_t gun_index, uint8_t *errCode);
  27. //------------------------------------------------------------------------------
  28. static uint8_t getMaxConnectTempAndChiller(uint8_t headTemp1, uint8_t headTemp2,
  29. uint8_t chillerTemp1, uint8_t chillerTemp2)
  30. {
  31. uint8_t i = 0;
  32. uint8_t tempSource[4] = {headTemp1, headTemp2, chillerTemp1, chillerTemp2};
  33. uint8_t maxTemp = 0;
  34. if (headTemp1 == UNDEFINED_TEMP &&
  35. headTemp2 == UNDEFINED_TEMP &&
  36. chillerTemp1 == UNDEFINED_TEMP &&
  37. chillerTemp2 == UNDEFINED_TEMP) {
  38. return UNDEFINED_TEMP;
  39. }
  40. //先取得第一個非UNDEFINED_TEMP的值
  41. for (i = 0; i < (sizeof(tempSource) / sizeof(uint8_t)); i++) {
  42. if (tempSource[i] != UNDEFINED_TEMP) {
  43. maxTemp = tempSource[i];
  44. break;
  45. }
  46. }
  47. //找最大的溫度值
  48. for (i = 0; i < (sizeof(tempSource) / sizeof(uint8_t)); i++) {
  49. if (tempSource[i] != UNDEFINED_TEMP) {
  50. if (maxTemp < tempSource[i]) {
  51. maxTemp = tempSource[i];
  52. }
  53. }
  54. }
  55. return maxTemp;
  56. }
  57. static uint8_t getMaxConnectTemp(uint8_t headTemp1, uint8_t headTemp2)
  58. {
  59. uint8_t maxTemp = 0;
  60. if (headTemp1 == UNDEFINED_TEMP &&
  61. headTemp2 == UNDEFINED_TEMP) {
  62. return UNDEFINED_TEMP;
  63. }
  64. if (headTemp1 != UNDEFINED_TEMP) {
  65. maxTemp = headTemp1;
  66. } else {
  67. headTemp1 = 0;
  68. }
  69. if (headTemp2 != UNDEFINED_TEMP) {
  70. if (headTemp2 > headTemp1) {
  71. maxTemp = headTemp2;
  72. }
  73. }
  74. return maxTemp;
  75. }
  76. static float ReadAdcVolt(uint8_t AdcChannel)
  77. {
  78. //AIN0=CCS GUN Temp 1
  79. //AIN1=CCS GUN Temp 2
  80. //AIN2=CCS_Proximity/2
  81. //AIN3=pilot voltage
  82. int fd = -1;
  83. uint8_t str[64] = {0};
  84. uint8_t AdcValue[8] = {'\0'};
  85. //uint32_t AdcValue = 0;
  86. if (AdcChannel > 7) {
  87. return -1;
  88. }
  89. sprintf((char *)str, "/sys/bus/iio/devices/iio\:device0/in_voltage%d_raw", AdcChannel);
  90. fd = open((char *)str, O_RDONLY);
  91. read(fd, AdcValue, 4);
  92. close(fd);
  93. return (1.8 * atoi((char *)&AdcValue[0])) / 4095;
  94. //return (1.8 * atoi((char *)&AdcValue)) / 4095;
  95. }
  96. static void getChillerTemperature(ChillerTemp *chillerTemp)
  97. {
  98. uint8_t i = 0;
  99. float adcVoltage = 0.0;
  100. ChillerTemp *pChillerTemp = (ChillerTemp *)chillerTemp;
  101. for (i = 0; i < 2; i++) {
  102. adcVoltage = 0.0;
  103. adcVoltage = ReadAdcVolt(i);
  104. if ((adcVoltage <= 0.9) && (adcVoltage >= 0.8)) { //0 ~ -40
  105. pChillerTemp->Temp[i] = ((adcVoltage - 0.908) * 500) + 60;
  106. //log_info("1 adcVoltage = %f", (adcVoltage - 0.9) * 500);
  107. } else if ((adcVoltage <= 1.07) && (adcVoltage > 0.9)) {
  108. pChillerTemp->Temp[i] = ((adcVoltage - 0.91) * 705.88) + 60;
  109. //log_info("2 adcVoltage = %f", (adcVoltage - 0.9) * 500);
  110. } else {
  111. pChillerTemp->Temp[i] = 195;
  112. }
  113. //CcsConnectorTemp1 = ReadAdcVolt(i);
  114. //if ((CcsConnectorTemp1 <= 0.9) && (CcsConnectorTemp1 >= 0.8)) { //0 ~ -40
  115. // CcsConnectorTemp1 = (CcsConnectorTemp1 - 0.9) * 500;
  116. //} else if ((CcsConnectorTemp1 <= 1.07) && (CcsConnectorTemp1 > 0.9)) {
  117. // CcsConnectorTemp1 = (CcsConnectorTemp1 - 0.9) * 705.88;
  118. //} else {
  119. // CcsConnectorTemp1 = 195; //not available
  120. //}
  121. //CcsConnectorTemp |= ((unsigned int)(CcsConnectorTemp1 + 60) & 0xFF) << (i * 8); //0x00(-60)~0xFE(194)
  122. }
  123. }
  124. static void AddrAssignment(uint8_t *data)
  125. {
  126. uint8_t target_number[8];
  127. uint8_t index = 0x00;
  128. struct ChargingInfoData *pDcChargingInfo = NULL;
  129. memcpy(target_number, data, sizeof(target_number));
  130. index = *(data + 4);
  131. if (pSysConfig->TotalConnectorCount == 1) {
  132. index = 0x01;
  133. }
  134. //if (CheckUniqNumber(index)) {
  135. pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(index - 1);
  136. //DS60-120 add
  137. if (pDcChargingInfo->Type == _Type_Chademo) {
  138. log_info("Set EV board info : (Chademo) TargetAddr = %d \n", index);
  139. } else if (pDcChargingInfo->Type == _Type_CCS_2) {
  140. log_info("Set EV board info : (CCS) TargetAddr = %d \n", index);
  141. } else if (pDcChargingInfo->Type == _Type_GB) {
  142. log_info("Set EV board info : (GB) TargetAddr = %d \n", index);
  143. }
  144. //log_info("EV board id = %x \n", index); //DS60-120 remove
  145. //log_info("target_number[0] = %x \n", target_number[0]);
  146. //log_info("target_number[1] = %x \n", target_number[1]);
  147. //log_info("target_number[2] = %x \n", target_number[2]);
  148. //log_info("target_number[3] = %x \n", target_number[3]);
  149. //log_info("target_number[4] = %x \n", target_number[4]);
  150. log_info("SetTargetAddr = %d, type = %d \n", index, pDcChargingInfo->Type);
  151. SetTargetAddr(target_number, index);
  152. //}
  153. }
  154. void CANReceiver(int fd)
  155. {
  156. pid_t canRecPid;
  157. canRecPid = fork();
  158. if (canRecPid == 0) {
  159. int isContinue = 1;
  160. int nbytes;
  161. int intCmd;
  162. uint8_t _index = 0;
  163. uint8_t recvID = 0;
  164. uint8_t targetGun = 0x00;
  165. uint8_t gunTypeIndex = 0;
  166. uint8_t ver[16] = {0};
  167. struct can_frame frame;
  168. ChillerTemp chiilerTemp = {0};
  169. struct ChargingInfoData *pDcChargingInfo = NULL;
  170. pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
  171. pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
  172. pSysWarning = (struct WARNING_CODE_INFO *)GetShmSysWarningInfo();
  173. pAlarmCode = (struct AlarmCodeData *)GetShmAlarmCodeData();
  174. ShmCHAdeMOData = (struct CHAdeMOData *)GetShmCHAdeMOData();
  175. ShmGBTData = (struct GBTData *)GetShmGBTData();
  176. ShmCcsData = (struct CcsData *)GetShmCcsData();
  177. ShmDcCommonData = (DcCommonInfo *)GetShmDcCommonData();
  178. while (isContinue) {
  179. memset(&frame, 0, sizeof(struct can_frame));
  180. nbytes = read(fd, &frame, sizeof(struct can_frame));
  181. if (nbytes <= 0) {
  182. usleep(10000);
  183. continue;
  184. }
  185. recvID = 0;
  186. targetGun = 0x00;
  187. intCmd = (int) (frame.can_id & CAN_EFF_MASK);
  188. if (intCmd == ADDRESS_REQ) {
  189. //ShmDcCommonData->CcsVersion = _CCS_VERSION_CHECK_TAG_V013S0;
  190. AddrAssignment(frame.data);
  191. continue;
  192. }
  193. intCmd = (int) (frame.can_id & CAN_EFF_MASK & 0xFFFFFF00);
  194. recvID = ((uint8_t) (frame.can_id & 0x000000FF)); // 0x01 or 0x02
  195. for (_index = 0; _index < pSysConfig->TotalConnectorCount; _index++) { // 假設有找到回應的 Index
  196. pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(_index);
  197. //if (gun_count == 1 &&
  198. // _chargingData[_index]->Type == _Type_CCS_2 &&
  199. // ShmDcCommonData->CcsVersion == _CCS_VERSION_CHECK_TAG_V015S0) {
  200. // target -= 1;
  201. //}
  202. if (pDcChargingInfo->Evboard_id == recvID) {
  203. targetGun = _index;
  204. break;
  205. }
  206. }
  207. if (targetGun < 0 || targetGun >= CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY) {
  208. log_info("EvComm (CANReceiver) : Target index = %x is < 0 or > QUANTITY \n", targetGun);
  209. usleep(10000);
  210. continue;
  211. }
  212. //else if (gun_count == 1 && targetGun == 0 && findIndex == 1 &&
  213. // ShmDcCommonData->CcsVersion == _CCS_VERSION_CHECK_TAG_V015S0) {
  214. // // 這樣的條件下~ 也是單槍 CCS 舊版本的狀況 : 因為舊版 CCS 不會 timeout, then send request id
  215. // ShmDcCommonData->CcsVersion = _CCS_VERSION_CHECK_TAG_V013S0;
  216. //}
  217. if (intCmd == 256) {
  218. log_info("EvComm command = 256");
  219. usleep(10000);
  220. continue;
  221. }
  222. pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(targetGun);
  223. gunTypeIndex = pDcChargingInfo->type_index;
  224. //log_info("intCmd = %x\r\n", intCmd);
  225. switch (intCmd) {
  226. case NOTIFICATION_EV_STATUS:
  227. if (pDcChargingInfo->ConnectorPlugIn != frame.data[0]) {
  228. if (frame.data[0] == PLUG) {
  229. log_info("Conn %d, Plugin. \n", targetGun);
  230. } else if (frame.data[0] == UNPLUG) {
  231. log_info("Conn %d, Unplug. \n", targetGun);
  232. } else {
  233. log_info("Conn %d, None Check. (%d) \n", targetGun, frame.data[0]);
  234. }
  235. }
  236. pDcChargingInfo->ConnectorPlugIn = frame.data[0];
  237. pDcChargingInfo->PilotVoltage = frame.data[1];
  238. //log_info("index = %d, ConnectorPlugIn = %x, data[0] = %x \n",
  239. // targetGun,
  240. // pDcChargingInfo->ConnectorPlugIn,
  241. // frame.data[0]);
  242. //log_info("ConnectorPlugIn = %x \n", (-120 + frame.data[1]) / 10);
  243. break;
  244. case ACK_EV_FW_VERSION:
  245. memset(ver, 0, sizeof(ver));
  246. if (pDcChargingInfo->Type == _Type_Chademo) {
  247. memcpy(ver, frame.data, frame.can_dlc);
  248. memcpy(ShmCHAdeMOData->evse[gunTypeIndex].version, ver, ARRAY_SIZE(ver));
  249. ShmCHAdeMOData->evse[gunTypeIndex].SelfTest_Comp = PASS;
  250. //log_info("chademo ver. : %s\n", ShmCHAdeMOData->evse[gunTypeIndex].version);
  251. } else if (pDcChargingInfo->Type == _Type_GB) {
  252. memcpy(ver, frame.data, frame.can_dlc);
  253. memcpy(ShmGBTData->evse[gunTypeIndex].version, ver, ARRAY_SIZE(ver));
  254. ShmGBTData->evse[gunTypeIndex].SelfTest_Comp = PASS;
  255. //log_info("gbt ver. : %s\n", ShmGBTData->evse[gunTypeIndex].version);
  256. } else if (pDcChargingInfo->Type == _Type_CCS_2) {
  257. if (ShmCcsData->CommProtocol == _CCS_COMM_V2GMessage_DIN70121) {
  258. memcpy(ver, frame.data, frame.can_dlc); //DS60-120 add
  259. //for (uint8_t _vCount = 0, _vPoint = 0; _vCount < frame.can_dlc; _vCount++) {//DS60-120 remove
  260. /*if (_vCount % 2 == 0 && _vCount != 0)
  261. {
  262. ver[_vCount + _vPoint] = 0x2E;
  263. _vPoint++;
  264. }*/
  265. //ver[_vCount + _vPoint] = frame.data[_vCount];
  266. //}
  267. memcpy(&ShmCcsData->V2GMessage_DIN70121[gunTypeIndex].version, ver, ARRAY_SIZE(ver));
  268. ShmCcsData->V2GMessage_DIN70121[gunTypeIndex].SelfTest_Comp = PASS;
  269. //log_info("CCS FW = %s \n", ShmCcsData->V2GMessage_DIN70121[gunTypeIndex].version);
  270. }
  271. }
  272. if (targetGun == 0) {
  273. memset(pSysInfo->Connector1FwRev,
  274. 0,
  275. sizeof(pSysInfo->Connector1FwRev));
  276. memcpy(pSysInfo->Connector1FwRev, ver, ARRAY_SIZE(ver));
  277. } else if (targetGun == 1) {
  278. memset(pSysInfo->Connector2FwRev,
  279. 0,
  280. sizeof(pSysInfo->Connector2FwRev));
  281. memcpy(pSysInfo->Connector2FwRev, ver, ARRAY_SIZE(ver));
  282. }
  283. break;
  284. case ACK_EV_HW_VERSION:
  285. //log_info("Get EV HW = %s \n", frame.data);
  286. break;
  287. case ACK_GET_OUTPUT_REQ:
  288. //DS60-120 add
  289. if ((pDcChargingInfo->SystemStatus >= S_PREPARING_FOR_EV &&
  290. pDcChargingInfo->SystemStatus <= S_CHARGING) ||
  291. (pDcChargingInfo->SystemStatus >= S_CCS_PRECHARGE_ST0 &&
  292. pDcChargingInfo->SystemStatus <= S_CCS_PRECHARGE_ST1)) {
  293. if (pDcChargingInfo->EvBatteryStartSoc <= 0) {
  294. pDcChargingInfo->EvBatteryStartSoc = frame.data[1];
  295. }
  296. if (frame.data[1] > pDcChargingInfo->EvBatterySoc) {
  297. pDcChargingInfo->EvBatterySoc = frame.data[1];
  298. }
  299. }
  300. //pDcChargingInfo->EvBatterySoc = frame.data[1]; //DS60-120 remove
  301. //Jerry add set voltage limit
  302. pDcChargingInfo->EvBatterytargetVoltage = (float)((frame.data[3] << 8) + frame.data[2]) / 10;
  303. if (pDcChargingInfo->EvBatterytargetVoltage > (GetMaxChargingVol(targetGun) * 0.1)) {
  304. pDcChargingInfo->EvBatterytargetVoltage = (GetMaxChargingVol(targetGun) * 0.1);
  305. }
  306. //printf("id = %d, EvBatterytargetVoltage = %.2f\r\n", targetGun, pDcChargingInfo->EvBatterytargetVoltage);
  307. //Jerry add set currency limit
  308. pDcChargingInfo->EvBatterytargetCurrent = (float)((frame.data[5] << 8) + frame.data[4]) / 10;
  309. if (pDcChargingInfo->EvBatterytargetCurrent > (GetMaxCharginigCur(targetGun) * 0.1)) {
  310. pDcChargingInfo->EvBatterytargetCurrent = (GetMaxCharginigCur(targetGun) * 0.1);
  311. }
  312. //printf("id = %d, EvBatterytargetCurrent = %.2f\r\n", targetGun, pDcChargingInfo->EvBatterytargetCurrent);
  313. pDcChargingInfo->RemainChargingDuration = ((short) frame.data[7] << 8) + (short) frame.data[6];
  314. //printf("RemainChargingDuration = %d\r\n", pDcChargingInfo->RemainChargingDuration);
  315. if (pDcChargingInfo->Type == _Type_Chademo) {
  316. //if (ShmCHAdeMOData->ev[gunTypeIndex].EvDetection != frame.data[0])
  317. {
  318. ShmCHAdeMOData->ev[gunTypeIndex].PresentMsgFlowStatus = frame.data[0];
  319. }
  320. ShmCHAdeMOData->ev[gunTypeIndex].EvDetection = frame.data[0];
  321. ShmCHAdeMOData->ev[gunTypeIndex].SOC = pDcChargingInfo->EvBatterySoc;
  322. ShmCHAdeMOData->ev[gunTypeIndex].TargetBatteryVoltage = (pDcChargingInfo->EvBatterytargetVoltage * 10);
  323. ShmCHAdeMOData->ev[gunTypeIndex].ChargingCurrentRequest = (pDcChargingInfo->EvBatterytargetCurrent * 10);
  324. } else if (pDcChargingInfo->Type == _Type_GB) {
  325. //if (ShmGBTData->ev[gunTypeIndex].EvDetection != frame.data[0])
  326. {
  327. ShmGBTData->ev[gunTypeIndex].PresentMsgFlowStatus = frame.data[0];
  328. }
  329. ShmGBTData->ev[gunTypeIndex].EvDetection = frame.data[0];
  330. ShmGBTData->ev[gunTypeIndex].SOC = pDcChargingInfo->EvBatterySoc;
  331. ShmGBTData->ev[gunTypeIndex].TargetBatteryVoltage = (pDcChargingInfo->EvBatterytargetVoltage * 10);
  332. ShmGBTData->ev[gunTypeIndex].ChargingCurrentRequest = (pDcChargingInfo->EvBatterytargetCurrent * 10);
  333. } else if (pDcChargingInfo->Type == _Type_CCS_2) {
  334. if (ShmCcsData->CommProtocol == _CCS_COMM_V2GMessage_DIN70121) {
  335. ShmCcsData->V2GMessage_DIN70121[gunTypeIndex].PresentMsgFlowStatus = frame.data[0];
  336. }
  337. }
  338. //log_info("EvBatterytargetVoltage = %f \n", pDcChargingInfo->EvBatterytargetVoltage);
  339. //log_info("EvBatterytargetCurrent = %f \n", pDcChargingInfo->EvBatterytargetCurrent);
  340. //log_info("BatteryVoltage = %d \n",
  341. // ShmCHAdeMOData->ev[_chargingData[target]->type_index].TargetBatteryVoltage);
  342. //log_info("CurrentRequest = %d \n",
  343. // ShmCHAdeMOData->ev[_chargingData[target]->type_index].ChargingCurrentRequest);
  344. break;
  345. case ACK_GET_EV_BATTERY_INFO:
  346. //_chargingData[target].EvACorDCcharging = frame.data[0];
  347. //_chargingData[target]->TotalBatteryCap = ((float) frame.data[4] << 8) + (short) frame.data[3];
  348. pDcChargingInfo->EvBatteryMaxVoltage = (((short) frame.data[4] << 8) + (short) frame.data[3]) / 10;
  349. //_chargingData[target]->EvBatteryMaxCurrent = ((float) frame.data[4] << 8) + (short) frame.data[3];
  350. //_chargingData[target].MaxiBatteryCurrent = ((short) frame.data[6] << 8) + (short) frame.data[5];
  351. if (pDcChargingInfo->Type == _Type_Chademo) {
  352. ShmCHAdeMOData->ev[gunTypeIndex].TotalBatteryCapacity = ((short) frame.data[2] << 8) + (short) frame.data[1];
  353. ShmCHAdeMOData->ev[gunTypeIndex].MaxiBatteryVoltage = pDcChargingInfo->EvBatteryMaxVoltage;
  354. //log_info("EvBatteryMaxVoltage = %f \n", _chargingData[target]->EvBatteryMaxVoltage);
  355. //log_info("TotalBatteryCapacity = %d \n", ShmCHAdeMOData->ev[_chargingData[target]->type_index].TotalBatteryCapacity);
  356. //log_info("MaxiBatteryVoltage = %d \n", ShmCHAdeMOData->ev[_chargingData[target]->type_index].MaxiBatteryVoltage);
  357. } else if (pDcChargingInfo->Type == _Type_GB) {
  358. ShmGBTData->ev[gunTypeIndex].TotalBatteryCapacity = ((short) frame.data[2] << 8) + (short) frame.data[1];
  359. ShmGBTData->ev[gunTypeIndex].MaxiBatteryVoltage = pDcChargingInfo->EvBatteryMaxVoltage;
  360. }
  361. //else if (pDcChargingInfo->Type == _Type_CCS_2) {
  362. //}
  363. break;
  364. case ACK_GET_MISCELLANEOUS_INFO:
  365. pDcChargingInfo->GunLocked = frame.data[0];
  366. pDcChargingInfo->PilotVoltage = (float)(-120 + frame.data[3]) / 10;
  367. if (pDcChargingInfo->Type == _Type_Chademo) {
  368. ShmCHAdeMOData->evse[gunTypeIndex].ConnectorTemperatureP = frame.data[1];
  369. ShmCHAdeMOData->evse[gunTypeIndex].ConnectorTemperatureN = frame.data[2];
  370. ShmCHAdeMOData->evse[gunTypeIndex].EvboardStatus = frame.data[7];
  371. } else if (pDcChargingInfo->Type == _Type_GB) {
  372. ShmGBTData->evse[gunTypeIndex].ConnectorTemperatureP = frame.data[1];
  373. ShmGBTData->evse[gunTypeIndex].ConnectorTemperatureN = frame.data[2];
  374. ShmGBTData->evse[gunTypeIndex].EvboardStatus = frame.data[7];
  375. }
  376. /*else if (pDcChargingInfo->Type == _Type_CCS_2) {
  377. if (ShmCcsData->CommProtocol == _CCS_COMM_V2GMessage_DIN70121) {
  378. //ShmCcsData->V2GMessage_DIN70121[gunTypeIndex]. .ConnectorTemperatureP = frame.data[1];
  379. //ShmCcsData->V2GMessage_DIN70121[gunTypeIndex]. .ConnectorTemperatureN = frame.data[2];
  380. }
  381. }*/
  382. #if 1
  383. //memset((uint8_t)&chiilerTemp, 0, sizeof(ChillerTemp));
  384. if (targetGun == 0 &&
  385. ((strncmp((char *)&pSysConfig->ModelName[7], "V", 1) == 0) ||
  386. (strncmp((char *)&pSysConfig->ModelName[7], "F", 1) == 0))
  387. ) {
  388. getChillerTemperature(&chiilerTemp);
  389. pDcChargingInfo->ConnectorTemp = getMaxConnectTempAndChiller(
  390. frame.data[1],
  391. frame.data[2],
  392. chiilerTemp.Temp[0],
  393. chiilerTemp.Temp[1]);
  394. //log_info("%d chiller Temp1 = %d, temp2 = %d, head Temp1 = %d, Temp2 = %d\r\n",
  395. // targetGun,
  396. // chiilerTemp.Temp[0],
  397. // chiilerTemp.Temp[1],
  398. // frame.data[1],
  399. // frame.data[2]);
  400. } else if (targetGun == 1 &&
  401. ((strncmp((char *)&pSysConfig->ModelName[9], "V", 1) == 0) ||
  402. (strncmp((char *)&pSysConfig->ModelName[9], "F", 1) == 0))
  403. ) {
  404. getChillerTemperature(&chiilerTemp);
  405. pDcChargingInfo->ConnectorTemp = getMaxConnectTempAndChiller(
  406. frame.data[1],
  407. frame.data[2],
  408. chiilerTemp.Temp[0],
  409. chiilerTemp.Temp[1]);
  410. //log_info("%d chillerTemp1 = %d, temp2 = %d, head Temp1 = %d, Temp2 = %d\r\n",
  411. // targetGun,
  412. // chiilerTemp.Temp[0],
  413. // chiilerTemp.Temp[1],
  414. // frame.data[1],
  415. // frame.data[2]);
  416. } else {
  417. pDcChargingInfo->ConnectorTemp = getMaxConnectTemp(frame.data[1], frame.data[2]);
  418. //log_info("connector temperature = %d\r\n",
  419. // pDcChargingInfo->ConnectorTemp);
  420. }
  421. #endif //0
  422. if (ShmDcCommonData->SystemModeChange == YES) {
  423. ShmDcCommonData->SystemModeChange = NO;
  424. //log_info("EvboardStatus = %x \n",
  425. // ShmCHAdeMOData->evse[gunTypeIndex].EvboardStatus);
  426. //log_info("ConnectorPlug locked = %x \n",
  427. // frame.data[0]);
  428. //if (frame.data[1] >= GUN_OTP_VALUE ||
  429. // frame.data[2] >= GUN_OTP_VALUE ||
  430. // chiilerTemp.Temp[0] >= GUN_OTP_VALUE ||
  431. // chiilerTemp.Temp[1] >= GUN_OTP_VALUE) {
  432. log_info("Conn %d Temp 0= %d, Temp 1 = %d, chillerTemp1 = %d, chillerTemp2 = %d\r\n",
  433. targetGun,
  434. frame.data[1],
  435. frame.data[2],
  436. chiilerTemp.Temp[0],
  437. chiilerTemp.Temp[1]);
  438. //}
  439. //log_info("PilotVoltage = %x \n", (-120 + frame.data[3]) / 10);
  440. }
  441. break;
  442. case ACK_EVSE_ISOLATION_STATUS:
  443. break;
  444. case ACK_EVSE_PRECHAGE_INFO:
  445. pDcChargingInfo->PrechargeStatus = frame.data[0];
  446. break;
  447. case NOTIFICATION_EV_STOP:
  448. // 車端要求停止
  449. if ((pDcChargingInfo->SystemStatus >= S_REASSIGN_CHECK && //DS60-120 add
  450. pDcChargingInfo->SystemStatus <= S_TERMINATING) ||
  451. (pDcChargingInfo->SystemStatus >= S_CCS_PRECHARGE_ST0 &&
  452. pDcChargingInfo->SystemStatus <= S_CCS_PRECHARGE_ST1)) {
  453. // frame.data[0] : 0x01 => normal stop, 0x02 => ev emergency stop
  454. log_info("(%d) NOTIFICATION_EV_STOP err level = %d-----------------------------\n",
  455. targetGun,
  456. frame.data[0]);
  457. if (frame.data[0] == 0x02) {
  458. if (AbnormalStopAnalysis(targetGun, frame.data + 1) == true) {
  459. pDcChargingInfo->StopChargeFlag = YES;
  460. } else {
  461. pDcChargingInfo->NormalStopChargeFlag = YES;
  462. }
  463. } else {
  464. AbnormalStopAnalysis(targetGun, frame.data + 1);
  465. pDcChargingInfo->NormalStopChargeFlag = YES;
  466. }
  467. }
  468. break;
  469. default:
  470. log_info("EV board = %d, Ack none defined. intCmd = %d \n", targetGun, intCmd);
  471. break;
  472. }//switch
  473. usleep(10000);
  474. }//while
  475. }
  476. }