Эх сурвалжийг харах

2021-10-12 / Simon Xue

Action:
	1. Fix Timeout bug in DD360 and DD360Combox
	2. Add function: Using EVCCID to verify when gun plugin.
	3. Remove Door sensor and Emgercy Buttion trigger in DD360Combox.
Simon Xue 3 жил өмнө
parent
commit
8be42f04ca

+ 50 - 22
EVSE/Projects/DD360Audi/Apps/CSU/main.c

@@ -1637,10 +1637,13 @@ void _DetectPlugInTimeout(void)
     ClearDetectPluginFlag();
 
     sleep(1); //等待DoComm回報插槍訊號給主櫃
-#if defined DD360Audi || DD360 || DD360Combox
+#if defined DD360Audi
 	    //pSysInfo->SystemPage = _LCM_COMPLETE;
 		setChargerMode(pSysInfo->CurGunSelected, S_TERMINATING);
-	    return;
+#elif DD360 || DD360Combox
+	setChargerMode(pSysInfo->CurGunSelected, S_COMPLETE);
+	pSysInfo->SystemPage = _LCM_COMPLETE;
+	return;
 #endif
     systemPageRestoreInit();
 }
@@ -1671,11 +1674,13 @@ void _DetectEvseChargingEnableTimeout(uint8_t gunIndex)
     log_info("*********** _DetectEvseChargingEnableTimeout (GFD timeout) ***********\n");
     //if (chargingInfo[gunIndex]->GroundFaultStatus != GFD_PASS)
     {
-#if defined DD360Audi || DD360 || DD360Combox
-        pSysInfo->SystemPage = _LCM_COMPLETE;
-        setChargerMode(gunIndex, S_TERMINATING);
-#else
-        setChargerMode(gunIndex, MODE_IDLE);
+#if defined DD360Audi
+	    //pSysInfo->SystemPage = _LCM_COMPLETE;
+		setChargerMode(pSysInfo->CurGunSelected, S_TERMINATING);
+#elif DD360 || DD360Combox
+	setChargerMode(pSysInfo->CurGunSelected, S_COMPLETE);
+	pSysInfo->SystemPage = _LCM_COMPLETE;
+	return;
 #endif
         _AutoReturnTimeout();
     }
@@ -1684,11 +1689,13 @@ void _DetectEvseChargingEnableTimeout(uint8_t gunIndex)
 void _PrepareTimeout(uint8_t gunIndex)
 {
     log_info("*********** _PrepareTimeout ***********\n");
-#if defined DD360Audi || DD360 || DD360Combox
-        pSysInfo->SystemPage = _LCM_COMPLETE;
-        setChargerMode(gunIndex, S_TERMINATING);
-#else
-     setChargerMode(gunIndex, MODE_IDLE);
+#if defined DD360Audi
+	    //pSysInfo->SystemPage = _LCM_COMPLETE;
+		setChargerMode(pSysInfo->CurGunSelected, S_TERMINATING);
+#elif DD360 || DD360Combox
+	setChargerMode(pSysInfo->CurGunSelected, S_COMPLETE);
+	pSysInfo->SystemPage = _LCM_COMPLETE;
+	return;
 #endif
     pAlarmCode->AlarmEvents.bits.PsuNoResource = YES;
     _AutoReturnTimeout();
@@ -1697,11 +1704,13 @@ void _PrepareTimeout(uint8_t gunIndex)
 void _CcsPrechargeTimeout(uint8_t gunIndex)
 {
     log_info("*********** _CcsPrechargeTimeout ***********\n");
-#if defined DD360Audi || DD360 || DD360Combox
-        pSysInfo->SystemPage = _LCM_COMPLETE;
-        setChargerMode(gunIndex, S_TERMINATING);
-#else
-     setChargerMode(gunIndex, MODE_IDLE);
+#if defined DD360Audi
+	    //pSysInfo->SystemPage = _LCM_COMPLETE;
+		setChargerMode(pSysInfo->CurGunSelected, S_TERMINATING);
+#elif DD360 || DD360Combox
+	setChargerMode(pSysInfo->CurGunSelected, S_COMPLETE);
+	pSysInfo->SystemPage = _LCM_COMPLETE;
+	return;
 #endif
 }
 
@@ -2849,8 +2858,8 @@ void CreateTimeoutFork(void)
                         pAlarmCode->AlarmEvents.bits.DisconnectedFromDo = ABNORMAL;
                         log_error("Author timeout restart DoComm\r\n");
                         system("killall Module_DoComm");
-                        sleep(1);
-                        system("/root/Module_DoComm &");
+                        //sleep(1);
+                        //system("/root/Module_DoComm &");
                     }
                 }
                 break;
@@ -2865,8 +2874,8 @@ void CreateTimeoutFork(void)
                         pAlarmCode->AlarmEvents.bits.DisconnectedFromDo = ABNORMAL;
                         log_error("Author timeout restart DoComm\r\n");
                         system("killall Module_DoComm");
-                        sleep(1);
-                        system("/root/Module_DoComm &");
+                        //sleep(1);
+                        //system("/root/Module_DoComm &");
                     }
                 }
                 break;
@@ -3792,13 +3801,29 @@ static void autoStartChargingForComBox(uint8_t gunIndex)
     return ;
 #endif //!defined DD360ComBox
 
+    if ( (pSysInfo->SystemPage >= _LCM_AUTHORIZING && pSysInfo->SystemPage <= _LCM_AUTHORIZ_FAIL) ||
+        pDcChargingInfo->isVerify ) {
+        return;
+    }
     pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(gunIndex);
 
     if ((pDcChargingInfo->ConnectorPlugIn == YES) &&
             (pDcChargingInfo->SystemStatus == S_IDLE)
        ) {
-        pSysInfo->CurGunSelected = gunIndex;
+
+#if VERIFY_EVCCID
+        if (!pDcChargingInfo->isVerify ) {
+            strcpy((char *)pSysConfig->UserId, (char *)pDcChargingInfo->EVCCID);
+            if( strcmp( (char *)pSysConfig->UserId , "" ) != EQUAL ) {
+                pDcChargingInfo->isVerify = true;
+                log_info("Get User(%d) ID:%s\n",gunIndex,pSysConfig->UserId);
+                pSysInfo->CurGunSelected = gunIndex;
+                pSysInfo->SystemPage = _LCM_AUTHORIZING;
+            }
+        }
+#else
         strcpy((char *)&pSysConfig->UserId, "AutoStartCharging");
+#endif
     }
 }
 
@@ -5094,6 +5119,9 @@ int main(void)
                         GetTimeoutValue(pDcChargingInfo->TimeoutTimer) >= 10000000) {
                     setChargerMode(gunIndex, MODE_IDLE);
                     destroySelGun(gunIndex); //Jerry add
+#ifdef DD360 || DD3660ComBox
+					pSysInfo->SystemPage = _LCM_IDLE;
+#endif
                 }
 
                 if (pSysInfo->CurGunSelected == gunIndex) {

+ 1 - 0
EVSE/Projects/DD360Audi/Apps/CSU/main.h

@@ -43,6 +43,7 @@
 #define GUN_PRECHARGING_TIMEOUT                 (60)
 
 #define WHILE_LOOP_TIME                         (10000)
+#define VERIFY_EVCCID                           0   // 0:Not verify 1:for verify
 
 //#define log_info(format, args...) StoreLogMsg_1("[%s:%d][%s][Info] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
 //#define log_warn(format, args...) StoreLogMsg_1("[%s:%d][%s][Warn] "format, __FILE__, __LINE__, __FUNCTION__, ##args)

+ 1 - 0
EVSE/Projects/DD360Audi/Apps/Define/define.h

@@ -638,6 +638,7 @@ struct ChargingInfoData
     struct timespec     ConnectorTimeout;
     unsigned char       PantographFlag;                 // 0: normal gun type,  1: pantograph gun type
 	unsigned char 		Replug_flag;
+    unsigned char       isVerify;
 };
 
 typedef union

+ 205 - 198
EVSE/Projects/DD360Audi/Apps/ModuleEvComm/Ev_Comm.c

@@ -1,198 +1,205 @@
-#include <stdio.h>      /*標準輸入輸出定義*/
-#include <stdlib.h>     /*標準函數庫定義*/
-#include <stdint.h>
-#include <string.h>
-
-#include <linux/can.h>
-#include <linux/can/raw.h>
-
-#include <unistd.h>     /*Unix 標準函數定義*/
-#include <fcntl.h>      /*檔控制定義*/
-#include <termios.h>    /*PPSIX 終端控制定義*/
-#include <errno.h>      /*錯誤號定義*/
-
-#include "Ev_Comm.h"
-#include "Module_EvComm.h"
-
-//------------------------------------------------------------------------------
-int PackageIdCmd(int cmd)
-{
-    return cmd | 0x80000000;
-}
-
-void SendCmdToEvboard(int cmd, uint8_t *data, uint8_t dataLen)
-{
-    int fd = GetCanFd();
-    struct can_frame frame;
-
-    frame.can_id = cmd;
-    frame.can_dlc = dataLen;
-    memcpy(frame.data, data, sizeof(frame.data));
-
-    write(fd, &frame, sizeof(struct can_frame));
-}
-
-//------------------------------------------------------------------------------
-void SetTargetAddr(uint8_t *target_number, uint8_t index)
-{
-    int id = PackageIdCmd(CMD_ADDR_ASSIGNMENT + index);
-    //printf("intCmd = %x \n", cmd & CAN_EFF_MASK);
-    //cmd = cmd & CAN_EFF_MASK;
-
-    uint8_t data[8];
-
-    data[0] = *target_number;
-    data[1] = *(target_number + 1);
-    data[2] = *(target_number + 2);
-    data[3] = *(target_number + 3);
-    data[4] = index;
-
-    SendCmdToEvboard(id, data, 5);
-}
-
-void GetFirmwareVersion(uint8_t gunIndex, uint8_t toId)
-{
-    int id = PackageIdCmd(CMD_GET_FW_VER + toId);
-    uint8_t data[8];
-
-    SendCmdToEvboard(id, data, 0);
-}
-
-void GetHardwareVersion(uint8_t gunIndex, uint8_t toId)
-{
-    int id = PackageIdCmd(CMD_GET_HW_VER + toId);
-    uint8_t data[8];
-
-    SendCmdToEvboard(id, data, 0);
-}
-
-void SyncRtcInfo(uint8_t gunIndex, uint8_t toId, int epoch)
-{
-    int id = PackageIdCmd(CMD_SYNC_RTC + toId);
-    uint8_t data[8];
-
-    data[0] = epoch & 0xff;
-    data[1] = (epoch >> 8) & 0xff;
-    data[2] = (epoch >> 16) & 0xff;
-    data[3] = (epoch >> 24) & 0xff;
-
-    SendCmdToEvboard(id, data, 4);
-}
-
-void SetChargingPermission(uint8_t gunIndex, uint8_t permissionStatus, uint16_t aOutputPw, uint16_t aOutputCur, uint16_t aOutputVol, uint8_t toId)
-{
-    int id = PackageIdCmd(CMD_CHARGING_PERMISSION + toId);
-    uint8_t data[8];
-
-    data[0] = permissionStatus;
-    data[1] = aOutputPw & 0xff;
-    data[2] = (aOutputPw >> 8) & 0xff;
-    data[3] = aOutputCur & 0xff;
-    data[4] = (aOutputCur >> 8) & 0xff;
-    data[5] = aOutputVol & 0xff;
-    data[6] = (aOutputVol >> 8) & 0xff;
-    data[7] = 0xf0;
-
-    SendCmdToEvboard(id, data, sizeof(data));
-}
-
-void SetPresentOutputPower(uint16_t outputVol_b1, uint16_t outputCur_b1, uint16_t outputVol_b2, uint16_t outputCur_b2)
-{
-    int id = PackageIdCmd(CMD_PRESENT_OUTPUT_POWER);
-    uint8_t data[8];
-
-    data[0] = outputVol_b1 & 0xff;
-    data[1] = (outputVol_b1 >> 8) & 0xff;
-    data[2] = outputCur_b1 & 0xff;
-    data[3] = (outputCur_b1 >> 8) & 0xff;
-    data[4] = outputVol_b2 & 0xff;
-    data[5] = (outputVol_b2 >> 8) & 0xff;
-    data[6] = outputCur_b2 & 0xff;
-    data[7] = (outputCur_b2 >> 8) & 0xff;
-
-    SendCmdToEvboard(id, data, 8);
-}
-
-void SetPresentOutputCapacity(uint16_t aOutputPw_b1, uint16_t aOutputCur_b1, uint16_t aOutputPw_b2, uint16_t aOutputCur_b2)
-{
-    int id = PackageIdCmd(CMD_PRESENT_OUTPUT_CAPABILITIES);
-    uint8_t data[8];
-
-    data[0] = aOutputPw_b1 & 0xff;
-    data[1] = (aOutputPw_b1 >> 8) & 0xff;
-    data[2] = aOutputCur_b1 & 0xff;
-    data[3] = (aOutputCur_b1 >> 8) & 0xff;
-    data[4] = aOutputPw_b2 & 0xff;
-    data[5] = (aOutputPw_b2 >> 8) & 0xff;
-    data[6] = aOutputCur_b2 & 0xff;
-    data[7] = (aOutputCur_b2 >> 8) & 0xff;
-
-    SendCmdToEvboard(id, data, 8);
-}
-
-void GetOutputReq(uint8_t gunIndex, uint8_t toId)
-{
-    int id = PackageIdCmd(CMD_GET_OUTPUT_REQ + toId);
-    uint8_t data[8];
-
-    SendCmdToEvboard(id, data, 0);
-}
-
-void GetEvBatteryInfo(uint8_t gunIndex, uint8_t toId)
-{
-    int id = PackageIdCmd(CMD_GET_BATTERY_INFO + toId);
-    uint8_t data[8];
-
-    SendCmdToEvboard(id, data, 0);
-}
-
-void EvseStopChargingEvent(uint8_t stopResult, uint8_t *stopReason, uint8_t toId)
-{
-    int id = PackageIdCmd(CMD_EVSE_STOP_CHARGING + toId);
-    uint8_t data[8];
-
-    data[0] = stopResult;
-    data[1] = *stopReason;
-    data[2] = *(stopReason + 1);
-    data[3] = *(stopReason + 2);
-    data[4] = *(stopReason + 3);
-    data[5] = *(stopReason + 4);
-    data[6] = *(stopReason + 5);
-
-    SendCmdToEvboard(id, data, 7);
-}
-
-void GetMiscellaneousInfo(uint8_t gunIndex, uint8_t relayStatus, float power, float voltage, uint8_t toId)
-{
-    int id = PackageIdCmd(CMD_GET_MISC_INFO + toId);
-    uint8_t data[8];
-
-    int _power = power * 10;
-
-    data[0] = relayStatus;
-    data[1] = (int)_power & 0xff;
-    data[2] = ((int)_power >> 8) & 0xff;
-    data[3] = (int)voltage & 0xff;
-    data[4] = ((int)voltage >> 8) & 0xff;
-
-    SendCmdToEvboard(id, data, 5);
-}
-
-void SetIsolationStatus(uint8_t gunIndex, uint8_t result, uint8_t toId)
-{
-    int id = PackageIdCmd(CMD_ISOLATION_STATUS + toId);
-    uint8_t data[8];
-
-    data[0] = result;
-    SendCmdToEvboard(id, data, 1);
-}
-
-void SetEvsePrechargeInfo(uint8_t gunIndex, uint8_t result, uint8_t toId)
-{
-    int id = PackageIdCmd(CMD_EVSE_PRECHARGE + toId);
-    uint8_t data[8];
-
-    data[0] = result;
-    SendCmdToEvboard(id, data, 1);
-}
-
+#include <stdio.h>      /*標準輸入輸出定義*/
+#include <stdlib.h>     /*標準函數庫定義*/
+#include <stdint.h>
+#include <string.h>
+
+#include <linux/can.h>
+#include <linux/can/raw.h>
+
+#include <unistd.h>     /*Unix 標準函數定義*/
+#include <fcntl.h>      /*檔控制定義*/
+#include <termios.h>    /*PPSIX 終端控制定義*/
+#include <errno.h>      /*錯誤號定義*/
+
+#include "Ev_Comm.h"
+#include "Module_EvComm.h"
+
+//------------------------------------------------------------------------------
+int PackageIdCmd(int cmd)
+{
+    return cmd | 0x80000000;
+}
+
+void SendCmdToEvboard(int cmd, uint8_t *data, uint8_t dataLen)
+{
+    int fd = GetCanFd();
+    struct can_frame frame;
+
+    frame.can_id = cmd;
+    frame.can_dlc = dataLen;
+    memcpy(frame.data, data, sizeof(frame.data));
+
+    write(fd, &frame, sizeof(struct can_frame));
+}
+
+//------------------------------------------------------------------------------
+void SetTargetAddr(uint8_t *target_number, uint8_t index)
+{
+    int id = PackageIdCmd(CMD_ADDR_ASSIGNMENT + index);
+    //printf("intCmd = %x \n", cmd & CAN_EFF_MASK);
+    //cmd = cmd & CAN_EFF_MASK;
+
+    uint8_t data[8];
+
+    data[0] = *target_number;
+    data[1] = *(target_number + 1);
+    data[2] = *(target_number + 2);
+    data[3] = *(target_number + 3);
+    data[4] = index;
+
+    SendCmdToEvboard(id, data, 5);
+}
+
+void GetFirmwareVersion(uint8_t gunIndex, uint8_t toId)
+{
+    int id = PackageIdCmd(CMD_GET_FW_VER + toId);
+    uint8_t data[8];
+
+    SendCmdToEvboard(id, data, 0);
+}
+
+void GetHardwareVersion(uint8_t gunIndex, uint8_t toId)
+{
+    int id = PackageIdCmd(CMD_GET_HW_VER + toId);
+    uint8_t data[8];
+
+    SendCmdToEvboard(id, data, 0);
+}
+
+void SyncRtcInfo(uint8_t gunIndex, uint8_t toId, int epoch)
+{
+    int id = PackageIdCmd(CMD_SYNC_RTC + toId);
+    uint8_t data[8];
+
+    data[0] = epoch & 0xff;
+    data[1] = (epoch >> 8) & 0xff;
+    data[2] = (epoch >> 16) & 0xff;
+    data[3] = (epoch >> 24) & 0xff;
+
+    SendCmdToEvboard(id, data, 4);
+}
+
+void SetChargingPermission(uint8_t gunIndex, uint8_t permissionStatus, uint16_t aOutputPw, uint16_t aOutputCur, uint16_t aOutputVol, uint8_t toId)
+{
+    int id = PackageIdCmd(CMD_CHARGING_PERMISSION + toId);
+    uint8_t data[8];
+
+    data[0] = permissionStatus;
+    data[1] = aOutputPw & 0xff;
+    data[2] = (aOutputPw >> 8) & 0xff;
+    data[3] = aOutputCur & 0xff;
+    data[4] = (aOutputCur >> 8) & 0xff;
+    data[5] = aOutputVol & 0xff;
+    data[6] = (aOutputVol >> 8) & 0xff;
+    data[7] = 0xf0;
+
+    SendCmdToEvboard(id, data, sizeof(data));
+}
+
+void SetPresentOutputPower(uint16_t outputVol_b1, uint16_t outputCur_b1, uint16_t outputVol_b2, uint16_t outputCur_b2)
+{
+    int id = PackageIdCmd(CMD_PRESENT_OUTPUT_POWER);
+    uint8_t data[8];
+
+    data[0] = outputVol_b1 & 0xff;
+    data[1] = (outputVol_b1 >> 8) & 0xff;
+    data[2] = outputCur_b1 & 0xff;
+    data[3] = (outputCur_b1 >> 8) & 0xff;
+    data[4] = outputVol_b2 & 0xff;
+    data[5] = (outputVol_b2 >> 8) & 0xff;
+    data[6] = outputCur_b2 & 0xff;
+    data[7] = (outputCur_b2 >> 8) & 0xff;
+
+    SendCmdToEvboard(id, data, 8);
+}
+
+void SetPresentOutputCapacity(uint16_t aOutputPw_b1, uint16_t aOutputCur_b1, uint16_t aOutputPw_b2, uint16_t aOutputCur_b2)
+{
+    int id = PackageIdCmd(CMD_PRESENT_OUTPUT_CAPABILITIES);
+    uint8_t data[8];
+
+    data[0] = aOutputPw_b1 & 0xff;
+    data[1] = (aOutputPw_b1 >> 8) & 0xff;
+    data[2] = aOutputCur_b1 & 0xff;
+    data[3] = (aOutputCur_b1 >> 8) & 0xff;
+    data[4] = aOutputPw_b2 & 0xff;
+    data[5] = (aOutputPw_b2 >> 8) & 0xff;
+    data[6] = aOutputCur_b2 & 0xff;
+    data[7] = (aOutputCur_b2 >> 8) & 0xff;
+
+    SendCmdToEvboard(id, data, 8);
+}
+
+void GetOutputReq(uint8_t gunIndex, uint8_t toId)
+{
+    int id = PackageIdCmd(CMD_GET_OUTPUT_REQ + toId);
+    uint8_t data[8];
+
+    SendCmdToEvboard(id, data, 0);
+}
+
+void GetEvBatteryInfo(uint8_t gunIndex, uint8_t toId)
+{
+    int id = PackageIdCmd(CMD_GET_BATTERY_INFO + toId);
+    uint8_t data[8];
+
+    SendCmdToEvboard(id, data, 0);
+}
+
+void EvseStopChargingEvent(uint8_t stopResult, uint8_t *stopReason, uint8_t toId)
+{
+    int id = PackageIdCmd(CMD_EVSE_STOP_CHARGING + toId);
+    uint8_t data[8];
+
+    data[0] = stopResult;
+    data[1] = *stopReason;
+    data[2] = *(stopReason + 1);
+    data[3] = *(stopReason + 2);
+    data[4] = *(stopReason + 3);
+    data[5] = *(stopReason + 4);
+    data[6] = *(stopReason + 5);
+
+    SendCmdToEvboard(id, data, 7);
+}
+
+void GetMiscellaneousInfo(uint8_t gunIndex, uint8_t relayStatus, float power, float voltage, uint8_t toId)
+{
+    int id = PackageIdCmd(CMD_GET_MISC_INFO + toId);
+    uint8_t data[8];
+
+    int _power = power * 10;
+
+    data[0] = relayStatus;
+    data[1] = (int)_power & 0xff;
+    data[2] = ((int)_power >> 8) & 0xff;
+    data[3] = (int)voltage & 0xff;
+    data[4] = ((int)voltage >> 8) & 0xff;
+
+    SendCmdToEvboard(id, data, 5);
+}
+
+void SetIsolationStatus(uint8_t gunIndex, uint8_t result, uint8_t toId)
+{
+    int id = PackageIdCmd(CMD_ISOLATION_STATUS + toId);
+    uint8_t data[8];
+
+    data[0] = result;
+    SendCmdToEvboard(id, data, 1);
+}
+
+void SetEvsePrechargeInfo(uint8_t gunIndex, uint8_t result, uint8_t toId)
+{
+    int id = PackageIdCmd(CMD_EVSE_PRECHARGE + toId);
+    uint8_t data[8];
+
+    data[0] = result;
+    SendCmdToEvboard(id, data, 1);
+}
+
+void GetEVCCIDReq(uint8_t gunIndex, uint8_t toId)
+{
+    int id = PackageIdCmd(CMD_EVCCID_REQ + toId);
+    uint8_t data[8];
+
+    SendCmdToEvboard(id, data, 0);
+}

+ 3 - 0
EVSE/Projects/DD360Audi/Apps/ModuleEvComm/Ev_Comm.h

@@ -27,6 +27,7 @@
 #define CMD_ISOLATION_STATUS                    (0x00001200)
 #define CMD_SYNC_RTC                            (0x00001400)
 #define CMD_EVSE_PRECHARGE                      (0x00001500)
+#define CMD_EVCCID_REQ                          (0x00001600)
 
 // 車端主動
 #define ADDRESS_REQ                             (0x080001FF)
@@ -41,6 +42,7 @@
 #define ACK_GET_MISCELLANEOUS_INFO              (0x08000D00)
 #define ACK_EVSE_ISOLATION_STATUS               (0x08001200)
 #define ACK_EVSE_PRECHAGE_INFO                  (0x08001500)
+#define ACK_EVCCID_REQ                          (0x08001600)
 
 //------------------------------------------------------------------------------
 // Send msg to can-bus
@@ -59,5 +61,6 @@ void SetIsolationStatus(uint8_t gunIndex, uint8_t result, uint8_t toId);
 void SetEvsePrechargeInfo(uint8_t gunIndex, uint8_t result, uint8_t toId);
 // 發送電樁主動停止充電結果及原因
 void EvseStopChargingEvent(uint8_t stopResult, uint8_t *stopReason, uint8_t toId);
+void GetEVCCIDReq(uint8_t gunIndex, uint8_t toId);
 
 #endif /* _EV_COMM_H_ */

+ 24 - 0
EVSE/Projects/DD360Audi/Apps/ModuleEvComm/Module_EvRxComm.c

@@ -286,13 +286,16 @@ void CANReceiver(int fd)
             pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(targetGun);
             gunTypeIndex = pDcChargingInfo->type_index;
 
+
             switch (intCmd) {
             case NOTIFICATION_EV_STATUS:
                 if (pDcChargingInfo->ConnectorPlugIn != frame.data[0]) {
                     if (frame.data[0] == PLUG) {
                         log_info("Conn %d, Plugin. \n", targetGun);
+                        pDcChargingInfo->isVerify = false;
                     } else if (frame.data[0] == UNPLUG) {
                         log_info("Conn %d, Unplug. \n", targetGun);
+                        strcpy( (char *) pDcChargingInfo->EVCCID, "");
                     } else {
                         log_info("Conn %d, None Check. (%d) \n", targetGun, frame.data[0]);
                     }
@@ -591,7 +594,28 @@ void CANReceiver(int fd)
                     }
                 }
                 break;
+            case ACK_EVCCID_REQ:
 
+                        if (frame.can_dlc > 0 && strcmp ( pDcChargingInfo->EVCCID, "" ) == EQUAL)
+                        {
+                            if (pDcChargingInfo->Type == _Type_CCS_2)
+                            {
+                                memset (
+                                        ShmCcsData->V2GMessage_DIN70121 [pDcChargingInfo->type_index].SessionSetupRequest.EVCCID,
+                                        0,
+                                        sizeof(ShmCcsData->V2GMessage_DIN70121 [pDcChargingInfo->type_index].SessionSetupRequest.EVCCID) );
+                                memcpy (
+                                        ShmCcsData->V2GMessage_DIN70121 [pDcChargingInfo->type_index].SessionSetupRequest.EVCCID,
+                                        frame.data, frame.can_dlc );
+                            }
+
+                            sprintf ( (char *) pDcChargingInfo->EVCCID, "%.2x%.2x%.2x%.2x%.2x%.2x", frame.data [0],
+                                    frame.data [1], frame.data [2], frame.data [3], frame.data [4], frame.data [5] );
+
+                            pDcChargingInfo->EVCCID [17] = '\0';
+                            log_info( "******* Gun %d->EVCCID = %s ************* \n", targetGun, pDcChargingInfo->EVCCID );
+                        }
+                break;
             default:
                 log_info("EV board = %d, Ack none defined. intCmd = %d  \n", targetGun, intCmd);
                 break;

+ 11 - 0
EVSE/Projects/DD360Audi/Apps/ModuleEvComm/Module_EvTxComm.c

@@ -24,6 +24,7 @@
 #include "../SelectGun/SelectGun.h"
 #include "Ev_Comm.h"
 #include "Module_EvComm.h"
+#include "../CSU/main.h"
 
 //------------------------------------------------------------------------------
 static struct SysConfigData *pSysConfig = NULL;
@@ -801,6 +802,16 @@ int main(int argc, char *argv[])
                     }
                 }
 
+#ifdef DD360ComBox
+                    // Set Ev board in communication mode
+                    // Get EVCCID for authorize when gun plug-in only for CCS
+                    if(pDcChargingInfo->Type == _Type_CCS_2 && priorityLow == 5) {
+                       if (pDcChargingInfo->ConnectorPlugIn && strcmp(pDcChargingInfo->EVCCID,"") == EQUAL) {
+                           GetEVCCIDReq(gunIndex,pDcChargingInfo->Evboard_id);
+                           SendCommunicationOnly(gunIndex);
+                        }
+                    }
+#endif 
                 if (priorityLow == 1) {
                     pDcChargingInfo->PresentChargedEnergy   = 0;
                     pDcChargingInfo->PresentChargingPower   = 0;

+ 6 - 16
EVSE/Projects/DD360Audi/Apps/ModulePrimary/Module_PrimaryComm.c

@@ -185,31 +185,26 @@ void GetInputGpioStatus(int fd)
     }
 
     ShmPrimaryMcuData->InputDet.bits.SpdDetec = gpio_in.SPD;
-#if defined DD360ComBox
-    if (gpio_in.Emergency_Btn == 0 && (EmgBtn_flag == gpio_in.Emergency_Btn))
+#ifdef DD360ComBox
+    EmgBtn_flag = 0;
 #else
     if (gpio_in.Emergency_Btn && (EmgBtn_flag != gpio_in.Emergency_Btn))
-#endif //defined DD360ComBox
     {
             EmgBtn_count++;
         if (EmgBtn_count > SensorTrigCount) {
            EmgBtn_flag = 1;
            EmgBtn_count = 0; // Avoid Overflow
        }
-#ifdef DD360ComBox
-    } else if ( gpio_in.Emergency_Btn && EmgBtn_flag ) {
-#else
     } else if (EmgBtn_flag != gpio_in.Emergency_Btn ) {
-#endif    
         EmgBtn_count++;
         if (EmgBtn_count > SensorTrigCount) {
             EmgBtn_flag = 0;
             EmgBtn_count = 0;
         }
     }
- 
+#endif
     ShmPrimaryMcuData->InputDet.bits.EmergencyButton = EmgBtn_flag;
- 
+
     dispenserSwTmp |= (ShmPrimaryMcuData->InputDet.bits.Key0);
     dispenserSwTmp |= (ShmPrimaryMcuData->InputDet.bits.Key1 << 1);
     dispenserSwTmp |= (ShmPrimaryMcuData->InputDet.bits.Key2 << 2);
@@ -242,28 +237,23 @@ void GetInputGpioStatus(int fd)
     }
 
 #if defined DD360ComBox
-    if (gpio_in.Door_Open && (Door_flag != gpio_in.Door_Open))
+    Door_flag = 0;
 #else
     if (gpio_in.Door_Open == 0 && (Door_flag == gpio_in.Door_Open))
-#endif //defined DD360ComBox
     {
         Door_count++;
         if (Door_count > SensorTrigCount) {
             Door_flag = 1;
             Door_count = 0; // Avoid Overflow
        }
-#ifdef DD360ComBox
-    } else if (gpio_in.Door_Open == 0 && Door_flag) {
-#else
     } else if (gpio_in.Door_Open && Door_flag) {
-#endif
         Door_count++;
         if (Door_count > SensorTrigCount) {
             Door_flag = 0;
             Door_count = 0;
         }
     }
- 
+#endif 
     ShmPrimaryMcuData->InputDet.bits.DoorOpen = Door_flag;
 /*
     log_info("Emergency Button Count = %d , Emergency flag = %d\n",

BIN
EVSE/Projects/DD360Audi/Images/ramdisk.gz


BIN
EVSE/Projects/DD360Audi/output/FactoryConfig


BIN
EVSE/Projects/DD360Audi/output/Module_DoComm


BIN
EVSE/Projects/DD360Audi/output/Module_EvComm


BIN
EVSE/Projects/DD360Audi/output/Module_EventLogging


BIN
EVSE/Projects/DD360Audi/output/Module_InternalComm


BIN
EVSE/Projects/DD360Audi/output/Module_LcmControl


BIN
EVSE/Projects/DD360Audi/output/Module_PrimaryComm


BIN
EVSE/Projects/DD360Audi/output/ReadCmdline


+ 4 - 0
EVSE/Projects/DD360Audi/output/kill.sh

@@ -12,6 +12,10 @@ pkill Module_ProduceUtils;
 pkill Module_DoComm;
 pkill main;
 
+sleep 1
+
+echo V > /dev/watchdog
+
 ipcrm -M 0x000003e9;
 ipcrm -M 0x000003ed;
 ipcrm -M 0x000003ea;

BIN
EVSE/Projects/DD360Audi/output/main


+ 2 - 1
EVSE/Projects/define.h

@@ -637,7 +637,8 @@ struct ChargingInfoData
     float               CurrentOffered;                 //0~6553.5 amp
     struct timespec     ConnectorTimeout;
     unsigned char       PantographFlag;                 // 0: normal gun type,  1: pantograph gun type
-	unsigned char 		Replug_flag;
+    unsigned char	Replug_flag;
+    unsigned char	isVerify;
 };
 
 typedef union