Module_EvRxComm.c 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551
  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. */
  58. static uint8_t getMaxConnectTemp(uint8_t headTemp1, uint8_t headTemp2)
  59. {
  60. uint8_t maxTemp = 0;
  61. if (headTemp1 == UNDEFINED_TEMP &&
  62. headTemp2 == UNDEFINED_TEMP) {
  63. return UNDEFINED_TEMP;
  64. }
  65. if (headTemp1 != UNDEFINED_TEMP) {
  66. maxTemp = headTemp1;
  67. } else {
  68. headTemp1 = 0;
  69. }
  70. if (headTemp2 != UNDEFINED_TEMP) {
  71. if (headTemp2 > headTemp1) {
  72. maxTemp = headTemp2;
  73. }
  74. }
  75. return maxTemp;
  76. }
  77. static float ReadAdcVolt(uint8_t AdcChannel)
  78. {
  79. //AIN0=CCS GUN Temp 1
  80. //AIN1=CCS GUN Temp 2
  81. //AIN2=CCS_Proximity/2
  82. //AIN3=pilot voltage
  83. int fd = -1;
  84. uint8_t str[64] = {0};
  85. uint8_t AdcValue[8] = {'\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. log_error("Create CAN Bus receive task failed\r\n");
  160. return;
  161. }
  162. if (canRecPid == 0) {
  163. int isContinue = 1;
  164. int nbytes;
  165. int intCmd;
  166. uint8_t _index = 0;
  167. uint8_t recvID = 0;
  168. uint8_t targetGun = 0x00;
  169. uint8_t gunTypeIndex = 0;
  170. uint8_t ver[16] = {0};
  171. struct can_frame frame;
  172. ChillerTemp chiilerTemp = {0};
  173. struct ChargingInfoData *pDcChargingInfo = NULL;
  174. pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
  175. pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
  176. pSysWarning = (struct WARNING_CODE_INFO *)GetShmSysWarningInfo();
  177. pAlarmCode = (struct AlarmCodeData *)GetShmAlarmCodeData();
  178. ShmCHAdeMOData = (struct CHAdeMOData *)GetShmCHAdeMOData();
  179. ShmGBTData = (struct GBTData *)GetShmGBTData();
  180. ShmCcsData = (struct CcsData *)GetShmCcsData();
  181. ShmDcCommonData = (DcCommonInfo *)GetShmDcCommonData();
  182. log_info("Child's PID is %d\r\n", getpid());
  183. while (isContinue) {
  184. memset(&frame, 0, sizeof(struct can_frame));
  185. nbytes = read(fd, &frame, sizeof(struct can_frame));
  186. if (nbytes <= 0) {
  187. usleep(10000);
  188. continue;
  189. }
  190. recvID = 0;
  191. targetGun = 0x00;
  192. intCmd = (int) (frame.can_id & CAN_EFF_MASK);
  193. if (intCmd == ADDRESS_REQ) {
  194. //ShmDcCommonData->CcsVersion = _CCS_VERSION_CHECK_TAG_V013S0;
  195. AddrAssignment(frame.data);
  196. continue;
  197. }
  198. intCmd = (int) (frame.can_id & CAN_EFF_MASK & 0xFFFFFF00);
  199. recvID = ((uint8_t) (frame.can_id & 0x000000FF)); // 0x01 or 0x02
  200. for (_index = 0; _index < pSysConfig->TotalConnectorCount; _index++) { // 假設有找到回應的 Index
  201. pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(_index);
  202. //if (gun_count == 1 &&
  203. // _chargingData[_index]->Type == _Type_CCS_2 &&
  204. // ShmDcCommonData->CcsVersion == _CCS_VERSION_CHECK_TAG_V015S0) {
  205. // target -= 1;
  206. //}
  207. if (pDcChargingInfo->Evboard_id == recvID) {
  208. targetGun = _index;
  209. break;
  210. }
  211. }
  212. if (targetGun < 0 || targetGun >= CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY) {
  213. log_info("EvComm (CANReceiver) : Target index = %x is < 0 or > QUANTITY \n", targetGun);
  214. usleep(10000);
  215. continue;
  216. }
  217. //else if (gun_count == 1 && targetGun == 0 && findIndex == 1 &&
  218. // ShmDcCommonData->CcsVersion == _CCS_VERSION_CHECK_TAG_V015S0) {
  219. // // 這樣的條件下~ 也是單槍 CCS 舊版本的狀況 : 因為舊版 CCS 不會 timeout, then send request id
  220. // ShmDcCommonData->CcsVersion = _CCS_VERSION_CHECK_TAG_V013S0;
  221. //}
  222. if (intCmd == 256) {
  223. log_info("EvComm command = 256");
  224. usleep(10000);
  225. continue;
  226. }
  227. pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(targetGun);
  228. gunTypeIndex = pDcChargingInfo->type_index;
  229. //log_info("intCmd = %x\r\n", intCmd);
  230. switch (intCmd) {
  231. case NOTIFICATION_EV_STATUS:
  232. if (pDcChargingInfo->ConnectorPlugIn != frame.data[0]) {
  233. if (frame.data[0] == PLUG) {
  234. log_info("Conn %d, Plugin. \n", targetGun);
  235. } else if (frame.data[0] == UNPLUG) {
  236. log_info("Conn %d, Unplug. \n", targetGun);
  237. } else {
  238. log_info("Conn %d, None Check. (%d) \n", targetGun, frame.data[0]);
  239. }
  240. }
  241. pDcChargingInfo->ConnectorPlugIn = frame.data[0];
  242. pDcChargingInfo->PilotVoltage = frame.data[1];
  243. //log_info("index = %d, ConnectorPlugIn = %x, data[0] = %x \n",
  244. // targetGun,
  245. // pDcChargingInfo->ConnectorPlugIn,
  246. // frame.data[0]);
  247. //log_info("ConnectorPlugIn = %x \n", (-120 + frame.data[1]) / 10);
  248. break;
  249. case ACK_EV_FW_VERSION:
  250. memset(ver, 0, sizeof(ver));
  251. if (pDcChargingInfo->Type == _Type_Chademo) {
  252. memcpy(ver, frame.data, frame.can_dlc);
  253. memcpy(ShmCHAdeMOData->evse[gunTypeIndex].version, ver, ARRAY_SIZE(ver));
  254. ShmCHAdeMOData->evse[gunTypeIndex].SelfTest_Comp = PASS;
  255. //log_info("chademo ver. : %s\n", ShmCHAdeMOData->evse[gunTypeIndex].version);
  256. } else if (pDcChargingInfo->Type == _Type_GB) {
  257. memcpy(ver, frame.data, frame.can_dlc);
  258. memcpy(ShmGBTData->evse[gunTypeIndex].version, ver, ARRAY_SIZE(ver));
  259. ShmGBTData->evse[gunTypeIndex].SelfTest_Comp = PASS;
  260. //log_info("gbt ver. : %s\n", ShmGBTData->evse[gunTypeIndex].version);
  261. } else if (pDcChargingInfo->Type == _Type_CCS_2) {
  262. if (ShmCcsData->CommProtocol == _CCS_COMM_V2GMessage_DIN70121) {
  263. memcpy(ver, frame.data, frame.can_dlc); //DS60-120 add
  264. //for (uint8_t _vCount = 0, _vPoint = 0; _vCount < frame.can_dlc; _vCount++) {//DS60-120 remove
  265. /*if (_vCount % 2 == 0 && _vCount != 0)
  266. {
  267. ver[_vCount + _vPoint] = 0x2E;
  268. _vPoint++;
  269. }*/
  270. //ver[_vCount + _vPoint] = frame.data[_vCount];
  271. //}
  272. memcpy(&ShmCcsData->V2GMessage_DIN70121[gunTypeIndex].version, ver, ARRAY_SIZE(ver));
  273. ShmCcsData->V2GMessage_DIN70121[gunTypeIndex].SelfTest_Comp = PASS;
  274. //log_info("CCS FW = %s \n", ShmCcsData->V2GMessage_DIN70121[gunTypeIndex].version);
  275. }
  276. }
  277. if (targetGun == 0) {
  278. memset(pSysInfo->Connector1FwRev,
  279. 0,
  280. sizeof(pSysInfo->Connector1FwRev));
  281. memcpy(pSysInfo->Connector1FwRev, ver, ARRAY_SIZE(ver));
  282. } else if (targetGun == 1) {
  283. memset(pSysInfo->Connector2FwRev,
  284. 0,
  285. sizeof(pSysInfo->Connector2FwRev));
  286. memcpy(pSysInfo->Connector2FwRev, ver, ARRAY_SIZE(ver));
  287. }
  288. break;
  289. case ACK_EV_HW_VERSION:
  290. //log_info("Get EV HW = %s \n", frame.data);
  291. break;
  292. case ACK_GET_OUTPUT_REQ:
  293. //DS60-120 add
  294. if ((pDcChargingInfo->SystemStatus >= S_PREPARING_FOR_EV &&
  295. pDcChargingInfo->SystemStatus <= S_CHARGING) ||
  296. (pDcChargingInfo->SystemStatus >= S_CCS_PRECHARGE_ST0 &&
  297. pDcChargingInfo->SystemStatus <= S_CCS_PRECHARGE_ST1)) {
  298. if (pDcChargingInfo->EvBatteryStartSoc <= 0) {
  299. pDcChargingInfo->EvBatteryStartSoc = frame.data[1];
  300. }
  301. if (frame.data[1] > pDcChargingInfo->EvBatterySoc) {
  302. pDcChargingInfo->EvBatterySoc = frame.data[1];
  303. }
  304. }
  305. //pDcChargingInfo->EvBatterySoc = frame.data[1]; //DS60-120 remove
  306. //Jerry add set voltage limit
  307. pDcChargingInfo->EvBatterytargetVoltage = (float)((frame.data[3] << 8) + frame.data[2]) / 10;
  308. if (pDcChargingInfo->EvBatterytargetVoltage > (GetMaxChargingVol(targetGun) * 0.1)) {
  309. pDcChargingInfo->EvBatterytargetVoltage = (GetMaxChargingVol(targetGun) * 0.1);
  310. }
  311. //printf("id = %d, EvBatterytargetVoltage = %.2f\r\n", targetGun, pDcChargingInfo->EvBatterytargetVoltage);
  312. //Jerry add set currency limit
  313. pDcChargingInfo->EvBatterytargetCurrent = (float)((frame.data[5] << 8) + frame.data[4]) / 10;
  314. if (pDcChargingInfo->EvBatterytargetCurrent > (GetMaxCharginigCur(targetGun) * 0.1)) {
  315. pDcChargingInfo->EvBatterytargetCurrent = (GetMaxCharginigCur(targetGun) * 0.1);
  316. }
  317. //printf("id = %d, EvBatterytargetCurrent = %.2f\r\n", targetGun, pDcChargingInfo->EvBatterytargetCurrent);
  318. pDcChargingInfo->RemainChargingDuration = ((short) frame.data[7] << 8) + (short) frame.data[6];
  319. //printf("RemainChargingDuration = %d\r\n", pDcChargingInfo->RemainChargingDuration);
  320. if (pDcChargingInfo->Type == _Type_Chademo) {
  321. //if (ShmCHAdeMOData->ev[gunTypeIndex].EvDetection != frame.data[0])
  322. {
  323. ShmCHAdeMOData->ev[gunTypeIndex].PresentMsgFlowStatus = frame.data[0];
  324. }
  325. ShmCHAdeMOData->ev[gunTypeIndex].EvDetection = frame.data[0];
  326. ShmCHAdeMOData->ev[gunTypeIndex].SOC = pDcChargingInfo->EvBatterySoc;
  327. ShmCHAdeMOData->ev[gunTypeIndex].TargetBatteryVoltage = (pDcChargingInfo->EvBatterytargetVoltage * 10);
  328. ShmCHAdeMOData->ev[gunTypeIndex].ChargingCurrentRequest = (pDcChargingInfo->EvBatterytargetCurrent * 10);
  329. } else if (pDcChargingInfo->Type == _Type_GB) {
  330. //if (ShmGBTData->ev[gunTypeIndex].EvDetection != frame.data[0])
  331. {
  332. ShmGBTData->ev[gunTypeIndex].PresentMsgFlowStatus = frame.data[0];
  333. }
  334. ShmGBTData->ev[gunTypeIndex].EvDetection = frame.data[0];
  335. ShmGBTData->ev[gunTypeIndex].SOC = pDcChargingInfo->EvBatterySoc;
  336. ShmGBTData->ev[gunTypeIndex].TargetBatteryVoltage = (pDcChargingInfo->EvBatterytargetVoltage * 10);
  337. ShmGBTData->ev[gunTypeIndex].ChargingCurrentRequest = (pDcChargingInfo->EvBatterytargetCurrent * 10);
  338. } else if (pDcChargingInfo->Type == _Type_CCS_2) {
  339. if (ShmCcsData->CommProtocol == _CCS_COMM_V2GMessage_DIN70121) {
  340. ShmCcsData->V2GMessage_DIN70121[gunTypeIndex].PresentMsgFlowStatus = frame.data[0];
  341. }
  342. }
  343. //log_info("EvBatterytargetVoltage = %f \n", pDcChargingInfo->EvBatterytargetVoltage);
  344. //log_info("EvBatterytargetCurrent = %f \n", pDcChargingInfo->EvBatterytargetCurrent);
  345. //log_info("BatteryVoltage = %d \n",
  346. // ShmCHAdeMOData->ev[_chargingData[target]->type_index].TargetBatteryVoltage);
  347. //log_info("CurrentRequest = %d \n",
  348. // ShmCHAdeMOData->ev[_chargingData[target]->type_index].ChargingCurrentRequest);
  349. break;
  350. case ACK_GET_EV_BATTERY_INFO:
  351. //_chargingData[target].EvACorDCcharging = frame.data[0];
  352. //_chargingData[target]->TotalBatteryCap = ((float) frame.data[4] << 8) + (short) frame.data[3];
  353. pDcChargingInfo->EvBatteryMaxVoltage = (((short) frame.data[4] << 8) + (short) frame.data[3]) / 10;
  354. //_chargingData[target]->EvBatteryMaxCurrent = ((float) frame.data[4] << 8) + (short) frame.data[3];
  355. //_chargingData[target].MaxiBatteryCurrent = ((short) frame.data[6] << 8) + (short) frame.data[5];
  356. if (pDcChargingInfo->Type == _Type_Chademo) {
  357. ShmCHAdeMOData->ev[gunTypeIndex].TotalBatteryCapacity = ((short) frame.data[2] << 8) + (short) frame.data[1];
  358. ShmCHAdeMOData->ev[gunTypeIndex].MaxiBatteryVoltage = pDcChargingInfo->EvBatteryMaxVoltage;
  359. //log_info("EvBatteryMaxVoltage = %f \n", _chargingData[target]->EvBatteryMaxVoltage);
  360. //log_info("TotalBatteryCapacity = %d \n", ShmCHAdeMOData->ev[_chargingData[target]->type_index].TotalBatteryCapacity);
  361. //log_info("MaxiBatteryVoltage = %d \n", ShmCHAdeMOData->ev[_chargingData[target]->type_index].MaxiBatteryVoltage);
  362. } else if (pDcChargingInfo->Type == _Type_GB) {
  363. ShmGBTData->ev[gunTypeIndex].TotalBatteryCapacity = ((short) frame.data[2] << 8) + (short) frame.data[1];
  364. ShmGBTData->ev[gunTypeIndex].MaxiBatteryVoltage = pDcChargingInfo->EvBatteryMaxVoltage;
  365. }
  366. //else if (pDcChargingInfo->Type == _Type_CCS_2) {
  367. //}
  368. break;
  369. case ACK_GET_MISCELLANEOUS_INFO:
  370. pDcChargingInfo->GunLocked = frame.data[0];
  371. pDcChargingInfo->PilotVoltage = (float)(-120 + frame.data[3]) / 10;
  372. if (pDcChargingInfo->Type == _Type_Chademo) {
  373. ShmCHAdeMOData->evse[gunTypeIndex].ConnectorTemperatureP = frame.data[1];
  374. ShmCHAdeMOData->evse[gunTypeIndex].ConnectorTemperatureN = frame.data[2];
  375. ShmCHAdeMOData->evse[gunTypeIndex].EvboardStatus = frame.data[7];
  376. } else if (pDcChargingInfo->Type == _Type_GB) {
  377. ShmGBTData->evse[gunTypeIndex].ConnectorTemperatureP = frame.data[1];
  378. ShmGBTData->evse[gunTypeIndex].ConnectorTemperatureN = frame.data[2];
  379. ShmGBTData->evse[gunTypeIndex].EvboardStatus = frame.data[7];
  380. }
  381. /*else if (pDcChargingInfo->Type == _Type_CCS_2) {
  382. if (ShmCcsData->CommProtocol == _CCS_COMM_V2GMessage_DIN70121) {
  383. //ShmCcsData->V2GMessage_DIN70121[gunTypeIndex]. .ConnectorTemperatureP = frame.data[1];
  384. //ShmCcsData->V2GMessage_DIN70121[gunTypeIndex]. .ConnectorTemperatureN = frame.data[2];
  385. }
  386. }*/
  387. //memset((uint8_t)&chiilerTemp, 0, sizeof(ChillerTemp));
  388. //if (targetGun == 0 &&
  389. // ((strncmp((char *)&pSysConfig->ModelName[7], "V", 1) == 0) ||
  390. // (strncmp((char *)&pSysConfig->ModelName[7], "F", 1) == 0))
  391. // ) {
  392. // getChillerTemperature(&chiilerTemp);
  393. // pDcChargingInfo->ChillerTemp = getMaxConnectTemp(chiilerTemp.Temp[0], chiilerTemp.Temp[1]);
  394. // //pDcChargingInfo->ConnectorTemp = getMaxConnectTempAndChiller(
  395. // // frame.data[1],
  396. // // frame.data[2],
  397. // // chiilerTemp.Temp[0],
  398. // // chiilerTemp.Temp[1]);
  399. //} else if (targetGun == 1 &&
  400. // ((strncmp((char *)&pSysConfig->ModelName[9], "V", 1) == 0) ||
  401. // (strncmp((char *)&pSysConfig->ModelName[9], "F", 1) == 0))
  402. // ) {
  403. // getChillerTemperature(&chiilerTemp);
  404. // pDcChargingInfo->ChillerTemp = getMaxConnectTemp(chiilerTemp.Temp[0], chiilerTemp.Temp[1]);
  405. //}
  406. #if 1
  407. if ((strncmp((char *)&pSysConfig->ModelName[7], "V", 1) == 0) ||
  408. (strncmp((char *)&pSysConfig->ModelName[7], "F", 1) == 0) ||
  409. (strncmp((char *)&pSysConfig->ModelName[9], "V", 1) == 0) ||
  410. (strncmp((char *)&pSysConfig->ModelName[9], "F", 1) == 0)
  411. ) {
  412. getChillerTemperature(&chiilerTemp);
  413. pDcChargingInfo->ChillerTemp = getMaxConnectTemp(chiilerTemp.Temp[0], chiilerTemp.Temp[1]);
  414. }
  415. pDcChargingInfo->ConnectorTemp = getMaxConnectTemp(frame.data[1], frame.data[2]);
  416. if ((ShmDcCommonData->SystemModeChange == YES) ||
  417. (((pDcChargingInfo->ConnectorTemp >= GUN_OTP_VALUE) &&
  418. (pDcChargingInfo->ConnectorTemp != UNDEFINED_TEMP)) ||
  419. ((pDcChargingInfo->ChillerTemp >= GUN_OTP_VALUE) &&
  420. (pDcChargingInfo->ChillerTemp != UNDEFINED_TEMP)))
  421. ) {
  422. ShmDcCommonData->SystemModeChange = NO;
  423. log_info("Conn %d Temp 0= %d, Temp 1 = %d, chillerTemp1 = %d, chillerTemp2 = %d\r\n",
  424. targetGun,
  425. frame.data[1],
  426. frame.data[2],
  427. chiilerTemp.Temp[0],
  428. chiilerTemp.Temp[1]);
  429. }
  430. #endif //0
  431. //log_info("EvboardStatus = %x \n",
  432. // ShmCHAdeMOData->evse[gunTypeIndex].EvboardStatus);
  433. //log_info("ConnectorPlug locked = %x \n",
  434. // frame.data[0]);
  435. //log_info("PilotVoltage = %x \n", (-120 + frame.data[3]) / 10);
  436. break;
  437. case ACK_EVSE_ISOLATION_STATUS:
  438. break;
  439. case ACK_EVSE_PRECHAGE_INFO:
  440. pDcChargingInfo->PrechargeStatus = frame.data[0];
  441. break;
  442. case NOTIFICATION_EV_STOP:
  443. // 車端要求停止
  444. if ((pDcChargingInfo->SystemStatus >= S_REASSIGN_CHECK && //DS60-120 add
  445. pDcChargingInfo->SystemStatus <= S_TERMINATING) ||
  446. (pDcChargingInfo->SystemStatus >= S_CCS_PRECHARGE_ST0 &&
  447. pDcChargingInfo->SystemStatus <= S_CCS_PRECHARGE_ST1)) {
  448. // frame.data[0] : 0x01 => normal stop, 0x02 => ev emergency stop
  449. log_info("(%d) NOTIFICATION_EV_STOP err level = %d-----------------------------\n",
  450. targetGun,
  451. frame.data[0]);
  452. if (frame.data[0] == 0x02) {
  453. if (AbnormalStopAnalysis(targetGun, frame.data + 1) == true) {
  454. pDcChargingInfo->StopChargeFlag = YES;
  455. } else {
  456. pDcChargingInfo->NormalStopChargeFlag = YES;
  457. }
  458. } else {
  459. AbnormalStopAnalysis(targetGun, frame.data + 1);
  460. pDcChargingInfo->NormalStopChargeFlag = YES;
  461. }
  462. }
  463. break;
  464. default:
  465. log_info("EV board = %d, Ack none defined. intCmd = %d \n", targetGun, intCmd);
  466. break;
  467. }//switch
  468. usleep(10000);
  469. }//while
  470. }
  471. }