浏览代码

Merge branch 'master' of https://git.phihong.com.tw:30000/System_Integration/CSU3_AM335x

Liwei 3 年之前
父节点
当前提交
2ad6ee2ec2
共有 30 个文件被更改,包括 843 次插入712 次删除
  1. 104 0
      EVSE/Modularization/Infypwr_PsuCommObj.c
  2. 7 1
      EVSE/Modularization/Infypwr_PsuCommObj.h
  3. 3 3
      EVSE/Modularization/Makefile
  4. 82 99
      EVSE/Modularization/ocpp20/MessageHandler.c
  5. 83 99
      EVSE/Modularization/ocppfiles/MessageHandler.c
  6. 83 99
      EVSE/Modularization/ocppph/MessageHandler.c
  7. 86 81
      EVSE/Projects/AW-CCS/Apps/CCS/Module_CCS.c
  8. 1 0
      EVSE/Projects/AW-CCS/Apps/CCS/Module_CCS.h
  9. 4 4
      EVSE/Projects/AW-CCS/Apps/LCM/Module_LcmControl.c
  10. 4 0
      EVSE/Projects/AW-CCS/Apps/LCM/lcmComm_dgus.h
  11. 161 58
      EVSE/Projects/AW-CCS/Apps/Module_AlarmDetect.c
  12. 7 7
      EVSE/Projects/AW-CCS/Apps/Module_ConfigTools.c
  13. 2 165
      EVSE/Projects/AW-CCS/Apps/Module_InternalComm.c
  14. 18 6
      EVSE/Projects/AW-CCS/Apps/Module_PowerSharing.c
  15. 2 0
      EVSE/Projects/AW-CCS/Apps/Module_PowerSharing.h
  16. 43 8
      EVSE/Projects/AW-CCS/Apps/main.c
  17. 3 1
      EVSE/Projects/AW-CCS/Apps/main.h
  18. 二进制
      EVSE/Projects/AW-CCS/Images/FactoryDefaultConfig.bin
  19. 二进制
      EVSE/Projects/AW-CCS/Images/ramdisk.gz
  20. 8 56
      EVSE/Projects/AW-Regular/Apps/Module_ConfigTools.c
  21. 12 0
      EVSE/Projects/DD360/Apps/CSU/Primary.c
  22. 11 4
      EVSE/Projects/DD360/Apps/ModulePrimary/Module_PrimaryComm.c
  23. 12 0
      EVSE/Projects/DD360Audi/Apps/CSU/Primary.c
  24. 11 4
      EVSE/Projects/DD360Audi/Apps/ModulePrimary/Module_PrimaryComm.c
  25. 12 6
      EVSE/Projects/DD360ComBox/Apps/CSU/Primary.c
  26. 11 4
      EVSE/Projects/DD360ComBox/Apps/ModulePrimary/Module_PrimaryComm.c
  27. 44 2
      EVSE/Projects/define.h
  28. 24 0
      EVSE/rootfs/usr/bin/run_ddr_reg_set.sh
  29. 2 2
      board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/board/ti/am335x/board.c
  30. 3 3
      board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/common/autoboot.c

+ 104 - 0
EVSE/Modularization/Infypwr_PsuCommObj.c

@@ -492,6 +492,25 @@ void ReceiveDataFromCanBus()
                         //PRINTF_LIB_FUNC("address = %d, abVol = %d, bcVol = %d, caVol = %d \n", address, abVol, bcVol, caVol);
                     }
                         break;
+                    case PSU_RCmd_ModuleOutputVolCur_F:
+                    {
+                    	if (!colFinished)
+							break;
+
+						byte vol[4], cur[4];
+
+						memcpy(vol, frame.data, 4);
+						memcpy(cur, frame.data + 4, 4);
+
+						if (!GetRealIndexByGroup(&address))
+							break;
+
+						float _Vol = IEEE_754_to_float(vol);
+						float _Cur = IEEE_754_to_float(cur);
+
+                    	return_get_output(address, _Vol, _Cur);
+                    }
+                    	break;
                     default:
                         break;
                 }
@@ -833,6 +852,91 @@ void SetDipSwitchMode()
 
     SendCmdToPsu(PwrFrameMsg.PwrMessage, data, sizeof(data));
 }
+
+void PresentSingleOutput(byte moduleIndex, int voltage, int current)
+{
+	byte data[8];
+    PwrFrame PwrFrameMsg;
+    PwrFrameMsg.PwrMessage = 0;
+    PwrFrameMsg.InfyBits.CmdValue = PSU_WCmd_ModuleSetOutput;
+
+	int Vol = voltage * 100;
+	int Cur = current * 100;
+
+	memset(data, 0x00, ARRAY_SIZE(data));
+
+	// 輸出電壓
+	data[0] = (Vol >> 24) & 0xFF;
+	data[1] = (Vol >> 16) & 0xFF;
+	data[2] = (Vol >> 8) & 0xFF;
+	data[3] = Vol & 0xFF;
+	// 輸出電流
+	data[4] = (Cur >> 24) & 0xFF;
+	data[5] = (Cur >> 16) & 0xFF;
+	data[6] = (Cur >> 8) & 0xFF;
+	data[7] = Cur & 0xFF;
+
+	PwrFrameMsg.InfyBits.DeviceValue = DEVICE_NO_SINGLE_MODULE;
+    PwrFrameMsg.InfyBits.DestinationAddress = moduleIndex;
+    PwrFrameMsg.InfyBits.SourceAddress = INFY_ADD_CSU;
+
+	SendCmdToPsu(PwrFrameMsg.PwrMessage, data, sizeof(data));
+}
+
+void SwitchSinglePower(byte moduleIndex, byte value)
+{
+	byte data[8];
+    PwrFrame PwrFrameMsg;
+    PwrFrameMsg.PwrMessage = 0;
+    PwrFrameMsg.InfyBits.CmdValue = PSU_WCmd_ModulePowerOnOff;
+
+	memset(data, 0x00, ARRAY_SIZE(data));
+	// 1 : 關機
+	// 0 : 開機
+	data[0] = value;
+
+	PwrFrameMsg.InfyBits.DeviceValue = DEVICE_NO_SINGLE_MODULE;
+    PwrFrameMsg.InfyBits.DestinationAddress = moduleIndex;
+    PwrFrameMsg.InfyBits.SourceAddress = INFY_ADD_CSU;
+
+	SendCmdToPsu(PwrFrameMsg.PwrMessage, data, sizeof(data));
+}
+
+void FlashSingleLed(byte moduleIndex, byte value)
+{
+	byte data[8];
+    PwrFrame PwrFrameMsg;
+    PwrFrameMsg.PwrMessage = 0;
+    PwrFrameMsg.InfyBits.CmdValue = PSU_WCmd_ModuleFlashLed;
+
+	memset(data, 0x00, ARRAY_SIZE(data));
+	// 1 : 閃爍
+	// 0 : 正常
+	data[0] = value;
+
+	PwrFrameMsg.InfyBits.DeviceValue = DEVICE_NO_SINGLE_MODULE;
+    PwrFrameMsg.InfyBits.DestinationAddress = moduleIndex;
+    PwrFrameMsg.InfyBits.SourceAddress = INFY_ADD_CSU;
+
+	SendCmdToPsu(PwrFrameMsg.PwrMessage, data, sizeof(data));
+}
+
+void GetSingleModuleOutputF(byte moduleIndex)
+{
+	byte data[8];
+	PwrFrame PwrFrameMsg;
+	PwrFrameMsg.PwrMessage = 0;
+	PwrFrameMsg.InfyBits.CmdValue = PSU_RCmd_ModuleOutputVolCur_F;
+
+	memset(data, 0x00, ARRAY_SIZE(data));
+
+	PwrFrameMsg.InfyBits.DeviceValue = DEVICE_NO_SINGLE_MODULE;
+	PwrFrameMsg.InfyBits.DestinationAddress = moduleIndex;
+	PwrFrameMsg.InfyBits.SourceAddress = INFY_ADD_CSU;
+
+	SendCmdToPsu(PwrFrameMsg.PwrMessage, data, sizeof(data));
+}
+
 /**********************************************************************************/
 /***                                                                            ***/
 /***                                   Get                                      ***/

+ 7 - 1
EVSE/Modularization/Infypwr_PsuCommObj.h

@@ -236,6 +236,12 @@ void FanNoiseInfo(byte group, byte value);
 void SetWalkInConfig(byte group, byte enable, byte sec);
 void SetDipSwitchMode();
 
+// set only one powermodule to output
+void PresentSingleOutput(byte moduleIndex, int voltage, int current);
+void SwitchSinglePower(byte moduleIndex, byte value);
+void FlashSingleLed(byte moduleIndex, byte value);
+void GetSingleModuleOutputF(byte moduleIndex);
+
 /*Ver : 9.06 used*/
 void SetDirModulePresentOutput(byte group, int voltage, int current, byte _switch, byte _interRelay);
 /*Get Cmd*/
@@ -273,7 +279,7 @@ void RefreshInputVol(void *func);
 void (*return_input_vol)(byte address, unsigned short vol1, unsigned short vol2, unsigned short vol3);
 
 void RefreshGetOutput(void *func);
-void (*return_get_output)(byte address, unsigned short outVol, unsigned short outCur);
+void (*return_get_output)(byte address, float outVol, float outCur);
 
 void RefreshGetOutputF(void *func);
 void (*return_get_output_float)(byte group, float outVol, float outCur);

+ 3 - 3
EVSE/Modularization/Makefile

@@ -72,17 +72,17 @@ WebServiceLib:
 
 Ocppph:
 	rm -f OcppBackendPH;
-	$(CC) -D $(TLS_EXPIRED) -D $(Project) -D__USE_XOPEN -D_GNU_SOURCE ./ocppph/Module_OcppBackend.c ./ocppph/MessageHandler.c ./ocppph/JsonParser.c ./ocppph/SystemLogMessage.c ./ocppph/hashmap.c ./ocppph/common.c -I ../Projects -I ../GPL/libwebsockets-2.2.2-stable/release/include -I ../GPL/json-c-json-c-0.13.1-20180305/release/include -L ../GPL/libwebsockets-2.2.2-stable/release/lib -L ../GPL/openssl-1.0.2g/release/lib -L ../GPL/json-c-json-c-0.13.1-20180305/release/lib -lwebsockets -luuid -lpthread -lc -lsqlite3 -ljson-c -o OcppBackendPH
+	$(CC) -D $(TLS_EXPIRED) -D $(Project) -D__USE_XOPEN -D_GNU_SOURCE ./ocppph/Module_OcppBackend.c ./ocppph/MessageHandler.c ./ocppph/JsonParser.c ./ocppph/SystemLogMessage.c ./ocppph/hashmap.c ./ocppph/common.c -I ../Projects -I ../GPL/libwebsockets-2.2.2-stable/release/include -I ../GPL/json-c-json-c-0.13.1-20180305/release/include -include ./Module_RatedCurrent.h  -L ../GPL/libwebsockets-2.2.2-stable/release/lib -L ../GPL/openssl-1.0.2g/release/lib -L ../GPL/json-c-json-c-0.13.1-20180305/release/lib -L ./ -lwebsockets -luuid -lpthread -lc -lsqlite3 -ljson-c -lModule_RatedCurrent -o OcppBackendPH
 	mv -f OcppBackendPH ../rootfs/root/
 
 Ocpp16:
 	rm -f OcppBackend;
-	$(CC) -D $(TLS_EXPIRED) -D $(Project) -D__USE_XOPEN -D_GNU_SOURCE ./ocppfiles/Module_OcppBackend.c ./ocppfiles/MessageHandler.c ./ocppfiles/JsonParser.c ./ocppfiles/SystemLogMessage.c ./ocppfiles/hashmap.c ./ocppfiles/common.c -I ../Projects -I ../GPL/libwebsockets-2.2.2-stable/release/include -I ../GPL/json-c-json-c-0.13.1-20180305/release/include -L ../GPL/libwebsockets-2.2.2-stable/release/lib -L ../GPL/openssl-1.0.2g/release/lib -L ../GPL/json-c-json-c-0.13.1-20180305/release/lib -lwebsockets -luuid -lpthread -lc -lsqlite3 -ljson-c -o OcppBackend
+	$(CC) -D $(TLS_EXPIRED) -D $(Project) -D__USE_XOPEN -D_GNU_SOURCE ./ocppfiles/Module_OcppBackend.c ./ocppfiles/MessageHandler.c ./ocppfiles/JsonParser.c ./ocppfiles/SystemLogMessage.c ./ocppfiles/hashmap.c ./ocppfiles/common.c -I ../Projects -I ../GPL/libwebsockets-2.2.2-stable/release/include -I ../GPL/json-c-json-c-0.13.1-20180305/release/include -include ./Module_RatedCurrent.h -L ../GPL/libwebsockets-2.2.2-stable/release/lib -L ../GPL/openssl-1.0.2g/release/lib -L ../GPL/json-c-json-c-0.13.1-20180305/release/lib -L ./ -lwebsockets -luuid -lpthread -lc -lsqlite3 -ljson-c -lModule_RatedCurrent -o OcppBackend
 	mv -f OcppBackend ../rootfs/root/
 
 Ocpp20:
 	rm -f OcppBackend20;
-	$(CC) -D $(TLS_EXPIRED) -D $(Project) -D__USE_XOPEN -D_GNU_SOURCE ./ocpp20/Module_OcppBackend20.c ./ocpp20/MessageHandler.c ./ocpp20/JsonParser.c ./ocpp20/SystemLogMessage.c ./ocpp20/hashmap.c ./ocpp20/common.c -I ../Projects -I ../GPL/libwebsockets-2.2.2-stable/release/include -I ../GPL/json-c-json-c-0.13.1-20180305/release/include -L ../GPL/libwebsockets-2.2.2-stable/release/lib -L ../GPL/openssl-1.0.2g/release/lib -L ../GPL/json-c-json-c-0.13.1-20180305/release/lib -lwebsockets -luuid -lpthread -lc -lsqlite3 -ljson-c -o OcppBackend20
+	$(CC) -D $(TLS_EXPIRED) -D $(Project) -D__USE_XOPEN -D_GNU_SOURCE ./ocpp20/Module_OcppBackend20.c ./ocpp20/MessageHandler.c ./ocpp20/JsonParser.c ./ocpp20/SystemLogMessage.c ./ocpp20/hashmap.c ./ocpp20/common.c -I ../Projects -I ../GPL/libwebsockets-2.2.2-stable/release/include -I ../GPL/json-c-json-c-0.13.1-20180305/release/include -include ./Module_RatedCurrent.h  -L ../GPL/libwebsockets-2.2.2-stable/release/lib -L ../GPL/openssl-1.0.2g/release/lib -L ../GPL/json-c-json-c-0.13.1-20180305/release/lib -L ./ -lwebsockets -luuid -lpthread -lc -lsqlite3 -ljson-c -lModule_RatedCurrent -o OcppBackend20
 	mv -f OcppBackend20 ../rootfs/root/
 
 

+ 82 - 99
EVSE/Modularization/ocpp20/MessageHandler.c

@@ -6005,6 +6005,9 @@ int InitShareMemory()
 
 int ProcessShareMemory()
 {
+	int result = PASS;
+	ParsingRatedCur modelnameInfo={0};
+
 	if(InitShareMemory() == FAIL)
 	{
 		DEBUG_ERROR("InitShareMemory NG\n");
@@ -6013,10 +6016,86 @@ int ProcessShareMemory()
 		{
 			ShmStatusCodeData->AlarmCode.AlarmEvents.bits.FailToCreateShareMemory=1;
 		}
-		sleep(5);
-		return FAIL;
+
+		result = FAIL;
 	}
-	return PASS;
+
+	if(RatedCurrentParsing((char*)ShmSysConfigAndInfo->SysConfig.ModelName, &modelnameInfo) != -1)
+	{
+	 	if((ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') &&
+	 	   ((ShmSysConfigAndInfo->SysConfig.ModelName[1]=='B') ||
+		    (ShmSysConfigAndInfo->SysConfig.ModelName[1]=='K') ||
+			(ShmSysConfigAndInfo->SysConfig.ModelName[1]=='O'))
+		   ) // 'D' means DC
+		{
+			// DO series
+			for(int gun_index=0; gun_index<GENERAL_GUN_QUANTITY ; gun_index++)
+			{
+				SystemInitial += 1;
+				gunTotalNumber += 1;
+				gunType[gun_index] = GUN_TYPE_DO;
+
+ 				switch(modelnameInfo.ParsingInfo[gun_index].GunType)
+ 				{
+ 					case Gun_Type_Chademo:
+ 						DEBUG_INFO("Gun-%02d type: Cabinet CHAdeMO\n", gun_index);
+ 						break;
+ 					case Gun_Type_CCS_2:
+ 						DEBUG_INFO("Gun-%02d type: Cabinet CCS\n", gun_index);
+						break;
+ 					case Gun_Type_GB:
+ 						DEBUG_INFO("Gun-%02d type: Cabinet GBT\n", gun_index);
+						break;
+ 					case Gun_Type_AC:
+ 						DEBUG_INFO("Gun-%02d type: Cabinet AC\n", gun_index);
+						break;
+ 					default:
+ 						DEBUG_WARN("Gun-%02d type: Cabinet unknown\n", gun_index);
+ 						break;
+ 				}
+			}
+		}
+		else
+		{
+ 			for(int gun_index=0;gun_index<modelnameInfo.GetGunCount;gun_index++)
+ 			{
+				SystemInitial += 1;
+				gunTotalNumber += 1;
+
+ 				switch(modelnameInfo.ParsingInfo[gun_index].GunType)
+ 				{
+ 					case Gun_Type_Chademo:
+ 						gunType[gun_index] = GUN_TYPE_CHAdeMO;
+ 						DEBUG_INFO("Gun-%02d type: CHAdeMO\n", gun_index);
+ 						break;
+ 					case Gun_Type_CCS_2:
+ 						gunType[gun_index] = GUN_TYPE_CCS;
+ 						DEBUG_INFO("Gun-%02d type: CCS\n", gun_index);
+						break;
+ 					case Gun_Type_GB:
+ 						gunType[gun_index] = GUN_TYPE_GBT;
+ 						DEBUG_INFO("Gun-%02d type: GBT\n", gun_index);
+						break;
+ 					case Gun_Type_AC:
+ 						gunType[gun_index] = GUN_TYPE_AC;
+ 						DEBUG_INFO("Gun-%02d type: AC\n", gun_index);
+						break;
+ 					default:
+ 						DEBUG_WARN("Gun-%02d type: Unknown\n", gun_index);
+ 						break;
+ 				}
+ 			}
+		}
+	}
+	else
+	{
+		DEBUG_ERROR("Model name parsing fail.\n");
+		result = FAIL;
+	}
+
+	if(result != PASS)sleep(5);
+
+	return result;
 }
 
 //---------------------common routine---------------------------//
@@ -18270,7 +18349,6 @@ int GetBackendConnectionTimeout(void)
 	return ShmSysConfigAndInfo->SysConfig.BackendConnTimeout>=0?ShmSysConfigAndInfo->SysConfig.BackendConnTimeout:300;
 }
 
-
 int isConnectorInitMode(int gun_index)
 {
 	int tempIndex = 0;
@@ -18378,9 +18456,6 @@ void refreshProcDogTimer()
 
 void InitialSystemValue(void)
 {
-	int connectorIndex = 0;
-	gunTotalNumber=0;
-	SystemInitial = 0;
 	localversion=0;
 	BootNotificationInterval = 10;
 	authorizeRetryTimes = 0;
@@ -18406,98 +18481,6 @@ void InitialSystemValue(void)
 	memset(CcsPreviousConnectorPlugIn, 0, ARRAY_SIZE(CcsPreviousConnectorPlugIn));
 	memset(GbPreviousConnectorPlugIn, 0, ARRAY_SIZE(GbPreviousConnectorPlugIn));
 	memset(AcPreviousConnectorPlugIn, 0, ARRAY_SIZE(AcPreviousConnectorPlugIn));
-	memset(gunType, 0, ARRAY_SIZE(gunType));
-
-	if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
-	{
- 		if((ShmSysConfigAndInfo->SysConfig.ModelName[1]=='B') ||
-		   (ShmSysConfigAndInfo->SysConfig.ModelName[1]=='K') ||
-		   (ShmSysConfigAndInfo->SysConfig.ModelName[1]=='O'))
-		{
-			// DO series
-			for(int index=0; index<GENERAL_GUN_QUANTITY ; index++)
-			{
-				SystemInitial = SystemInitial + 1;
-				gunTotalNumber = gunTotalNumber + 1;
-				gunType[connectorIndex] = GUN_TYPE_DO;
-				connectorIndex = connectorIndex + 1;
-			}
-		}
-		else
-		{
-			// DM, DW, DS series
-			//check connector / socket type (index: 8, 9, 10)
-			for(int index=7; index <10 ; index++)
-			{
-				if(index != 8)
-				{
-					// DC Connector
-					if ((ShmSysConfigAndInfo->SysConfig.ModelName[index] == 'J'))
-					{
-						SystemInitial = SystemInitial + 1;
-						gunTotalNumber = gunTotalNumber + 1;
-						gunType[connectorIndex] = GUN_TYPE_CHAdeMO;
-						connectorIndex = connectorIndex + 1;
-					}
-					else if ((ShmSysConfigAndInfo->SysConfig.ModelName[index] == 'D') ||
-							 (ShmSysConfigAndInfo->SysConfig.ModelName[index] == 'E') ||
-							 (ShmSysConfigAndInfo->SysConfig.ModelName[index] == 'F') ||
-							 (ShmSysConfigAndInfo->SysConfig.ModelName[index] == 'U') ||
-							 (ShmSysConfigAndInfo->SysConfig.ModelName[index] == 'T') ||
-							 (ShmSysConfigAndInfo->SysConfig.ModelName[index] == 'V'))
-					{
-						SystemInitial = SystemInitial + 1;
-						gunTotalNumber = gunTotalNumber + 1;
-						gunType[connectorIndex] = GUN_TYPE_CCS;
-						connectorIndex = connectorIndex + 1;
-					}
-					else if ((ShmSysConfigAndInfo->SysConfig.ModelName[index] == 'G'))
-					{
-						SystemInitial = SystemInitial + 1;
-						gunTotalNumber = gunTotalNumber + 1;
-						gunType[connectorIndex] = GUN_TYPE_GBT;
-						connectorIndex = connectorIndex + 1;
-					}
-					else if ((ShmSysConfigAndInfo->SysConfig.ModelName[index] == 'O'))
-					{
-						SystemInitial = SystemInitial + 1;
-						gunTotalNumber = gunTotalNumber + 1;
-						gunType[connectorIndex] = GUN_TYPE_DO;
-						connectorIndex = connectorIndex + 1;
-					}
-				}
-				else
-				{
-					// AC Connector
-					if ((ShmSysConfigAndInfo->SysConfig.ModelName[index] > '0') && (ShmSysConfigAndInfo->SysConfig.ModelName[index] <= '9'))
-					{
-						SystemInitial = SystemInitial + 1;
-						gunTotalNumber = gunTotalNumber + 1;
-						gunType[connectorIndex] = GUN_TYPE_AC;
-						connectorIndex = connectorIndex + 1;
-					}
-				}
-			}
-		}
-
-		//DEBUG_INFO("DC ...\n");
-	}
-	else if (ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A') //'A' means AC
-	{
-		//check connector / socket type (index: 8, 9, 10)
-		for(int index=7; index <10 ; index++)
-		{
-			if ((ShmSysConfigAndInfo->SysConfig.ModelName[index] > '0') && (ShmSysConfigAndInfo->SysConfig.ModelName[index] <= '9'))
-			{
-				SystemInitial = SystemInitial + 1;
-				gunTotalNumber = gunTotalNumber + 1;
-				gunType[connectorIndex] = GUN_TYPE_AC;
-				connectorIndex = connectorIndex + 1;
-
-				//DEBUG_INFO("AC: %d, %c\n", index, ShmSysConfigAndInfo->SysConfig.ModelName[index]);
-			}
-		}
-	}
 
 	//Status &&  ConnectorPlugIn Setting
 	for (int index = 0; index < CHAdeMO_QUANTITY; index++)

+ 83 - 99
EVSE/Modularization/ocppfiles/MessageHandler.c

@@ -3838,6 +3838,9 @@ int InitShareMemory()
 
 int ProcessShareMemory()
 {
+	int result = PASS;
+	ParsingRatedCur modelnameInfo={0};
+
 	if(InitShareMemory() == FAIL)
 	{
 		DEBUG_ERROR("InitShareMemory NG\n");
@@ -3846,10 +3849,87 @@ int ProcessShareMemory()
 		{
 			ShmStatusCodeData->AlarmCode.AlarmEvents.bits.FailToCreateShareMemory=1;
 		}
-		sleep(5);
-		return FAIL;
+
+		result = FAIL;
+	}
+
+	// Model name parsing
+	if(RatedCurrentParsing((char*)ShmSysConfigAndInfo->SysConfig.ModelName, &modelnameInfo) != -1)
+	{
+	 	if((ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') &&
+	 	   ((ShmSysConfigAndInfo->SysConfig.ModelName[1]=='B') ||
+		    (ShmSysConfigAndInfo->SysConfig.ModelName[1]=='K') ||
+			(ShmSysConfigAndInfo->SysConfig.ModelName[1]=='O'))
+		   ) // 'D' means DC
+		{
+			// DO series
+			for(int gun_index=0; gun_index<GENERAL_GUN_QUANTITY ; gun_index++)
+			{
+				SystemInitial += 1;
+				gunTotalNumber += 1;
+				gunType[gun_index] = GUN_TYPE_DO;
+
+ 				switch(modelnameInfo.ParsingInfo[gun_index].GunType)
+ 				{
+ 					case Gun_Type_Chademo:
+ 						DEBUG_INFO("Gun-%02d type: Cabinet CHAdeMO\n", gun_index);
+ 						break;
+ 					case Gun_Type_CCS_2:
+ 						DEBUG_INFO("Gun-%02d type: Cabinet CCS\n", gun_index);
+						break;
+ 					case Gun_Type_GB:
+ 						DEBUG_INFO("Gun-%02d type: Cabinet GBT\n", gun_index);
+						break;
+ 					case Gun_Type_AC:
+ 						DEBUG_INFO("Gun-%02d type: Cabinet AC\n", gun_index);
+						break;
+ 					default:
+ 						DEBUG_WARN("Gun-%02d type: Cabinet unknown\n", gun_index);
+ 						break;
+ 				}
+			}
+		}
+		else
+		{
+ 			for(int gun_index=0;gun_index<modelnameInfo.GetGunCount;gun_index++)
+ 			{
+				SystemInitial += 1;
+				gunTotalNumber += 1;
+
+ 				switch(modelnameInfo.ParsingInfo[gun_index].GunType)
+ 				{
+ 					case Gun_Type_Chademo:
+ 						gunType[gun_index] = GUN_TYPE_CHAdeMO;
+ 						DEBUG_INFO("Gun-%02d type: CHAdeMO\n", gun_index);
+ 						break;
+ 					case Gun_Type_CCS_2:
+ 						gunType[gun_index] = GUN_TYPE_CCS;
+ 						DEBUG_INFO("Gun-%02d type: CCS\n", gun_index);
+						break;
+ 					case Gun_Type_GB:
+ 						gunType[gun_index] = GUN_TYPE_GBT;
+ 						DEBUG_INFO("Gun-%02d type: GBT\n", gun_index);
+						break;
+ 					case Gun_Type_AC:
+ 						gunType[gun_index] = GUN_TYPE_AC;
+ 						DEBUG_INFO("Gun-%02d type: AC\n", gun_index);
+						break;
+ 					default:
+ 						DEBUG_WARN("Gun-%02d type: Unknown\n", gun_index);
+ 						break;
+ 				}
+ 			}
+		}
 	}
-	return PASS;
+	else
+	{
+		DEBUG_ERROR("Model name parsing fail.\n");
+		result = FAIL;
+	}
+
+	if(result != PASS)sleep(5);
+
+	return result;
 }
 
 void CheckSystemValue(void)
@@ -19241,11 +19321,7 @@ void refreshProcDogTimer()
 
 void InitialSystemValue(void)
 {
-	int connectorIndex = 0;
-	//int valueASCII = 0;
 	server_cycle_Status = atoi((char*)ShmOCPP16Data->ConfigurationTable.CoreProfile[MinimumStatusDuration].ItemData);
-	gunTotalNumber=0;
-	SystemInitial = 0;
 	locallistVersion=0;
 	BootNotificationInterval = 0;
 	authorizeRetryTimes = 0;
@@ -19270,98 +19346,6 @@ void InitialSystemValue(void)
 	memset(CcsPreviousConnectorPlugIn, 0, ARRAY_SIZE(CcsPreviousConnectorPlugIn));
 	memset(GbPreviousConnectorPlugIn, 0, ARRAY_SIZE(GbPreviousConnectorPlugIn));
 	memset(AcPreviousConnectorPlugIn, 0, ARRAY_SIZE(AcPreviousConnectorPlugIn));
-	memset(gunType, 0, ARRAY_SIZE(gunType));
-
- 	if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
-	{
- 		if((ShmSysConfigAndInfo->SysConfig.ModelName[1]=='B') ||
-		   (ShmSysConfigAndInfo->SysConfig.ModelName[1]=='K') ||
-		   (ShmSysConfigAndInfo->SysConfig.ModelName[1]=='O'))
- 		{
- 			// DO series
- 			for(int index=0; index<GENERAL_GUN_QUANTITY ; index++)
- 			{
-				SystemInitial = SystemInitial + 1;
-				gunTotalNumber = gunTotalNumber + 1;
-				gunType[connectorIndex] = GUN_TYPE_DO;
-				connectorIndex = connectorIndex + 1;
- 			}
- 		}
- 		else
- 		{
- 			// DM, DW, DS series
- 			//check connector / socket type (index: 8, 9, 10)
-			for(int index=7; index <10 ; index++)
-			{
-				if(index != 8)
-				{
-					// DC Connector
-					if ((ShmSysConfigAndInfo->SysConfig.ModelName[index] == 'J'))
-					{
-						SystemInitial = SystemInitial + 1;
-						gunTotalNumber = gunTotalNumber + 1;
-						gunType[connectorIndex] = GUN_TYPE_CHAdeMO;
-						connectorIndex = connectorIndex + 1;
-					}
-					else if ((ShmSysConfigAndInfo->SysConfig.ModelName[index] == 'D') ||
-							 (ShmSysConfigAndInfo->SysConfig.ModelName[index] == 'E') ||
-							 (ShmSysConfigAndInfo->SysConfig.ModelName[index] == 'F') ||
-							 (ShmSysConfigAndInfo->SysConfig.ModelName[index] == 'U') ||
-							 (ShmSysConfigAndInfo->SysConfig.ModelName[index] == 'T') ||
-							 (ShmSysConfigAndInfo->SysConfig.ModelName[index] == 'V'))
-					{
-						SystemInitial = SystemInitial + 1;
-						gunTotalNumber = gunTotalNumber + 1;
-						gunType[connectorIndex] = GUN_TYPE_CCS;
-						connectorIndex = connectorIndex + 1;
-					}
-					else if ((ShmSysConfigAndInfo->SysConfig.ModelName[index] == 'G'))
-					{
-						SystemInitial = SystemInitial + 1;
-						gunTotalNumber = gunTotalNumber + 1;
-						gunType[connectorIndex] = GUN_TYPE_GBT;
-						connectorIndex = connectorIndex + 1;
-					}
-					else if ((ShmSysConfigAndInfo->SysConfig.ModelName[index] == 'O'))
-					{
-						SystemInitial = SystemInitial + 1;
-						gunTotalNumber = gunTotalNumber + 1;
-						gunType[connectorIndex] = GUN_TYPE_DO;
-						connectorIndex = connectorIndex + 1;
-					}
-				}
-				else
-				{
-					// AC Connector
-					if ((ShmSysConfigAndInfo->SysConfig.ModelName[index] > '0') && (ShmSysConfigAndInfo->SysConfig.ModelName[index] <= '9'))
-					{
-						SystemInitial = SystemInitial + 1;
-						gunTotalNumber = gunTotalNumber + 1;
-						gunType[connectorIndex] = GUN_TYPE_AC;
-						connectorIndex = connectorIndex + 1;
-					}
-				}
-			}
- 		}
-
-		//DEBUG_INFO("DC ...\n");
-	}
-	else if (ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A') //'A' means AC
-	{
-		//check connector / socket type (index: 8, 9, 10)
-		for(int index=7; index <10 ; index++)
-		{
-			if ((ShmSysConfigAndInfo->SysConfig.ModelName[index] > '0') && (ShmSysConfigAndInfo->SysConfig.ModelName[index] <= '9'))
-			{
-				SystemInitial = SystemInitial + 1;
-				gunTotalNumber = gunTotalNumber + 1;
-				gunType[connectorIndex] = GUN_TYPE_AC;
-				connectorIndex = connectorIndex + 1;
-
-				//DEBUG_INFO("AC: %d, %c\n", index, ShmSysConfigAndInfo->SysConfig.ModelName[index]);
-			}
-		}
-	}
 
 	//Status &&  ConnectorPlugIn Setting
 	for (int index = 0; index < CHAdeMO_QUANTITY; index++)

+ 83 - 99
EVSE/Modularization/ocppph/MessageHandler.c

@@ -3555,6 +3555,9 @@ int InitShareMemory()
 
 int ProcessShareMemory()
 {
+	int result = PASS;
+	ParsingRatedCur modelnameInfo={0};
+
 	if(InitShareMemory() == FAIL)
 	{
 		DEBUG_ERROR("InitShareMemory NG\n");
@@ -3563,10 +3566,87 @@ int ProcessShareMemory()
 		{
 			ShmStatusCodeData->AlarmCode.AlarmEvents.bits.FailToCreateShareMemory=1;
 		}
-		sleep(5);
-		return FAIL;
+
+		result = FAIL;
+	}
+
+	// Model name parsing
+	if(RatedCurrentParsing((char*)ShmSysConfigAndInfo->SysConfig.ModelName, &modelnameInfo) != -1)
+	{
+	 	if((ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') &&
+	 	   ((ShmSysConfigAndInfo->SysConfig.ModelName[1]=='B') ||
+		    (ShmSysConfigAndInfo->SysConfig.ModelName[1]=='K') ||
+			(ShmSysConfigAndInfo->SysConfig.ModelName[1]=='O'))
+		   ) // 'D' means DC
+		{
+			// DO series
+			for(int gun_index=0; gun_index<GENERAL_GUN_QUANTITY ; gun_index++)
+			{
+				SystemInitial += 1;
+				gunTotalNumber += 1;
+				gunType[gun_index] = GUN_TYPE_DO;
+
+ 				switch(modelnameInfo.ParsingInfo[gun_index].GunType)
+ 				{
+ 					case Gun_Type_Chademo:
+ 						DEBUG_INFO("Gun-%02d type: Cabinet CHAdeMO\n", gun_index);
+ 						break;
+ 					case Gun_Type_CCS_2:
+ 						DEBUG_INFO("Gun-%02d type: Cabinet CCS\n", gun_index);
+						break;
+ 					case Gun_Type_GB:
+ 						DEBUG_INFO("Gun-%02d type: Cabinet GBT\n", gun_index);
+						break;
+ 					case Gun_Type_AC:
+ 						DEBUG_INFO("Gun-%02d type: Cabinet AC\n", gun_index);
+						break;
+ 					default:
+ 						DEBUG_WARN("Gun-%02d type: Cabinet unknown\n", gun_index);
+ 						break;
+ 				}
+			}
+		}
+		else
+		{
+ 			for(int gun_index=0;gun_index<modelnameInfo.GetGunCount;gun_index++)
+ 			{
+				SystemInitial += 1;
+				gunTotalNumber += 1;
+
+ 				switch(modelnameInfo.ParsingInfo[gun_index].GunType)
+ 				{
+ 					case Gun_Type_Chademo:
+ 						gunType[gun_index] = GUN_TYPE_CHAdeMO;
+ 						DEBUG_INFO("Gun-%02d type: CHAdeMO\n", gun_index);
+ 						break;
+ 					case Gun_Type_CCS_2:
+ 						gunType[gun_index] = GUN_TYPE_CCS;
+ 						DEBUG_INFO("Gun-%02d type: CCS\n", gun_index);
+						break;
+ 					case Gun_Type_GB:
+ 						gunType[gun_index] = GUN_TYPE_GBT;
+ 						DEBUG_INFO("Gun-%02d type: GBT\n", gun_index);
+						break;
+ 					case Gun_Type_AC:
+ 						gunType[gun_index] = GUN_TYPE_AC;
+ 						DEBUG_INFO("Gun-%02d type: AC\n", gun_index);
+						break;
+ 					default:
+ 						DEBUG_WARN("Gun-%02d type: Unknown\n", gun_index);
+ 						break;
+ 				}
+ 			}
+		}
 	}
-	return PASS;
+	else
+	{
+		DEBUG_ERROR("Model name parsing fail.\n");
+		result = FAIL;
+	}
+
+	if(result != PASS)sleep(5);
+
+	return result;
 }
 
 void CheckSystemValue(void)
@@ -18771,11 +18851,7 @@ void refreshProcDogTimer()
 
 void InitialSystemValue(void)
 {
-	int connectorIndex = 0;
-	//int valueASCII = 0;
 	server_cycle_Status = atoi((char*)ShmOCPP16DataPH->ConfigurationTable.CoreProfile[MinimumStatusDuration].ItemData);
-	gunTotalNumber=0;
-	SystemInitial = 0;
 	locallistVersion=0;
 	BootNotificationInterval = 0;
 	authorizeRetryTimes = 0;
@@ -18800,98 +18876,6 @@ void InitialSystemValue(void)
 	memset(CcsPreviousConnectorPlugIn, 0, ARRAY_SIZE(CcsPreviousConnectorPlugIn));
 	memset(GbPreviousConnectorPlugIn, 0, ARRAY_SIZE(GbPreviousConnectorPlugIn));
 	memset(AcPreviousConnectorPlugIn, 0, ARRAY_SIZE(AcPreviousConnectorPlugIn));
-	memset(gunType, 0, ARRAY_SIZE(gunType));
-
- 	if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
-	{
- 		if((ShmSysConfigAndInfo->SysConfig.ModelName[1]=='B') ||
-		   (ShmSysConfigAndInfo->SysConfig.ModelName[1]=='K') ||
-		   (ShmSysConfigAndInfo->SysConfig.ModelName[1]=='O'))
- 		{
- 			// DO series
- 			for(int index=0; index<GENERAL_GUN_QUANTITY ; index++)
- 			{
-				SystemInitial = SystemInitial + 1;
-				gunTotalNumber = gunTotalNumber + 1;
-				gunType[connectorIndex] = GUN_TYPE_DO;
-				connectorIndex = connectorIndex + 1;
- 			}
- 		}
- 		else
- 		{
- 			// DM, DW, DS series
- 			//check connector / socket type (index: 8, 9, 10)
-			for(int index=7; index <10 ; index++)
-			{
-				if(index != 8)
-				{
-					// DC Connector
-					if ((ShmSysConfigAndInfo->SysConfig.ModelName[index] == 'J'))
-					{
-						SystemInitial = SystemInitial + 1;
-						gunTotalNumber = gunTotalNumber + 1;
-						gunType[connectorIndex] = GUN_TYPE_CHAdeMO;
-						connectorIndex = connectorIndex + 1;
-					}
-					else if ((ShmSysConfigAndInfo->SysConfig.ModelName[index] == 'D') ||
-							 (ShmSysConfigAndInfo->SysConfig.ModelName[index] == 'E') ||
-							 (ShmSysConfigAndInfo->SysConfig.ModelName[index] == 'F') ||
-							 (ShmSysConfigAndInfo->SysConfig.ModelName[index] == 'U') ||
-							 (ShmSysConfigAndInfo->SysConfig.ModelName[index] == 'T') ||
-							 (ShmSysConfigAndInfo->SysConfig.ModelName[index] == 'V'))
-					{
-						SystemInitial = SystemInitial + 1;
-						gunTotalNumber = gunTotalNumber + 1;
-						gunType[connectorIndex] = GUN_TYPE_CCS;
-						connectorIndex = connectorIndex + 1;
-					}
-					else if ((ShmSysConfigAndInfo->SysConfig.ModelName[index] == 'G'))
-					{
-						SystemInitial = SystemInitial + 1;
-						gunTotalNumber = gunTotalNumber + 1;
-						gunType[connectorIndex] = GUN_TYPE_GBT;
-						connectorIndex = connectorIndex + 1;
-					}
-					else if ((ShmSysConfigAndInfo->SysConfig.ModelName[index] == 'O'))
-					{
-						SystemInitial = SystemInitial + 1;
-						gunTotalNumber = gunTotalNumber + 1;
-						gunType[connectorIndex] = GUN_TYPE_DO;
-						connectorIndex = connectorIndex + 1;
-					}
-				}
-				else
-				{
-					// AC Connector
-					if ((ShmSysConfigAndInfo->SysConfig.ModelName[index] > '0') && (ShmSysConfigAndInfo->SysConfig.ModelName[index] <= '9'))
-					{
-						SystemInitial = SystemInitial + 1;
-						gunTotalNumber = gunTotalNumber + 1;
-						gunType[connectorIndex] = GUN_TYPE_AC;
-						connectorIndex = connectorIndex + 1;
-					}
-				}
-			}
- 		}
-
-		//DEBUG_INFO("DC ...\n");
-	}
-	else if (ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A') //'A' means AC
-	{
-		//check connector / socket type (index: 8, 9, 10)
-		for(int index=7; index <10 ; index++)
-		{
-			if ((ShmSysConfigAndInfo->SysConfig.ModelName[index] > '0') && (ShmSysConfigAndInfo->SysConfig.ModelName[index] <= '9'))
-			{
-				SystemInitial = SystemInitial + 1;
-				gunTotalNumber = gunTotalNumber + 1;
-				gunType[connectorIndex] = GUN_TYPE_AC;
-				connectorIndex = connectorIndex + 1;
-
-				//DEBUG_INFO("AC: %d, %c\n", index, ShmSysConfigAndInfo->SysConfig.ModelName[index]);
-			}
-		}
-	}
 
 	//Status &&  ConnectorPlugIn Setting
 	for (int index = 0; index < CHAdeMO_QUANTITY; index++)

+ 86 - 81
EVSE/Projects/AW-CCS/Apps/CCS/Module_CCS.c

@@ -8,7 +8,6 @@
 #include "define_ccs.h"
 #include "main.h"
 
-
 struct SysConfigAndInfo *ShmSysConfigAndInfo;
 struct StatusCodeData *ShmStatusCodeData;
 struct CcsData *ShmCcsData;
@@ -19,7 +18,7 @@ struct appHandEXIDocument ccs_handshake;
 struct dinEXIDocument ccs_exi_doc_DIN;
 struct iso1EXIDocument ccs_exi_doc_ISO1;
 struct iso2EXIDocument ccs_exi_doc_ISO2;
-unsigned char V2GTP_Tx_buf[V2GTP_MSG_TX_BUFFER_SIZE];   //64*1024  65,536 = 65.5KB
+unsigned char V2GTP_Tx_buf[V2GTP_MSG_TX_BUFFER_SIZE];   //64*1024 = 65,536 = 65.5KB
 unsigned char buf_log_evcomm[SIZE_OF_LOG_BUFFER];
 unsigned char buf_log_evcomm_fork1[SIZE_OF_LOG_BUFFER];
 unsigned char buf_log_evcomm_fork2[SIZE_OF_LOG_BUFFER];
@@ -37,7 +36,7 @@ unsigned char V2gtpMsgTxBuf[V2GTP_MSG_TX_BUFFER_SIZE] = {0};
 unsigned short Aag[64];
 struct MmeHeader SendMmePacket;
 int SendMmePacketSize;
-unsigned char CsuMac[6],QcaMac[6],EvMac[6],SlacRunId[8];
+unsigned char CsuMac[6],QcaMac[6],EvMac[6],SlacRunId[8],eth0Mac[6];
 struct sockaddr_ll DestSocketAddress;
 struct ifreq Req;
 unsigned int PwmStartTime=0;
@@ -777,8 +776,8 @@ int GetEthMac(unsigned char *Eth, unsigned char *mac)
     close(fd);
     system("rm -f /mnt/GetEthInfo");
     sscanf((char*)addr, "%02x:%02x:%02x:%02x:%02x:%02x", (uint32_t *)&mac[0], (uint32_t *)&mac[1], (uint32_t *)&mac[2], (uint32_t *)&mac[3], (uint32_t *)&mac[4], (uint32_t *)&mac[5]);    //CsuMac (Eth = eth1)
-    SAVE_SYS_LOG_MSG_EVCOMM("EVSE MACAddr(CsuMac): %02x:%02x:%02x:%02x:%02x:%02x\n",
-    						mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
+    SAVE_SYS_LOG_MSG_EVCOMM("EVSE MAC address(%s): %02X:%02X:%02X:%02X:%02X:%02X\n",
+    						Eth, mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
     return 1;
 }
 
@@ -1146,7 +1145,11 @@ int Check_CP_State_Error_fork1(struct ChargingInfoData *ccs)
     {
         #if (SLAC_FIRST_RESPONSE_METHOD == SET_5_PWM_ONCE_GET_PERMISSION_IN_AUTHORIZATIONRES)
         {
+#ifdef TEST_WITH_ETH0
+        	if((ShmCcsData->EnergyTransferMode == MODE_DC_EXTENDED) && ((ccs->CpState != 2) && (ccs->CpState != 3)))
+#else
             if((ccs->CpState != 2) && (ccs->CpState != 3))
+#endif
             {
                 if (ccs->CpState_err == FALSE)
                 {
@@ -1177,7 +1180,11 @@ int Check_CP_State_Error_fork1(struct ChargingInfoData *ccs)
         if(state >= ChargeParameterDiscoveryRequest &&        //35
            state <= ChargeParameterDiscoveryResponse)         //36
         {
+#ifdef TEST_WITH_ETH0
+        	if((ccs->CpState != 3) && ((ShmCcsData->EnergyTransferMode != MODE_DC_EXTENDED) && (ccs->CpState != 4)))
+#else
             if(ccs->CpState != 3)
+#endif
             {
                 if (ccs->CpState_err == FALSE)
                 {
@@ -3737,14 +3744,24 @@ int MmeProcess(unsigned char *Buffer, int DataLength)
 
 	    case MMTYPE_VENDOR_VS_NW_INFO_CNF:
 		{
-            memcpy(QcaMac, MmePacket->OSA, 6);
+			// Only Set key for local QCA7000
+			if((MmePacket->OSA[0] == MmePacket->MMENTRY[12]) &&
+			   (MmePacket->OSA[1] == MmePacket->MMENTRY[13]) &&
+			   (MmePacket->OSA[2] == MmePacket->MMENTRY[14]) &&
+			   (MmePacket->OSA[3] == MmePacket->MMENTRY[15]) &&
+			   (MmePacket->OSA[4] == MmePacket->MMENTRY[16]) &&
+			   (MmePacket->OSA[5] == MmePacket->MMENTRY[17]))
+			{
+				memcpy(QcaMac, MmePacket->OSA, 6);
 
-	        DEBUG_PRINTF_EVCOMM_DETAIL("--- MMTYPE_VENDOR_VS_NW_INFO_CNF ---\n");
-            SAVE_SYS_LOG_MSG_EVCOMM("Got QCA7K MacAddr:%02X:%02X:%02X:%02X:%02X:%02X (comm:OK)\n",
-                    				QcaMac[0],  QcaMac[1],  QcaMac[2],  QcaMac[3],  QcaMac[4],  QcaMac[5]);
+				DEBUG_PRINTF_EVCOMM_DETAIL("--- MMTYPE_VENDOR_VS_NW_INFO_CNF ---\n");
+				SAVE_SYS_LOG_MSG_EVCOMM("EVSE MAC address(QCA7K): %02X:%02X:%02X:%02X:%02X:%02X (comm:OK)\n",
+	                    				QcaMac[0],  QcaMac[1],  QcaMac[2],  QcaMac[3],  QcaMac[4],  QcaMac[5]);
+
+				Update_V2G_Flow_Status(CM_SET_KEY_REQ);
+				ftime(&SeqStartTime);
+			}
 
-	        Update_V2G_Flow_Status(CM_SET_KEY_REQ);
-            ftime(&SeqStartTime);
             break;
 		}
 
@@ -3893,9 +3910,7 @@ int SlacComm()
                         break;
                     }
                     else
-                    {
-                        //null
-                    }
+                    {}
 
                     //Retry by 3 times
                     if (qca7k_comm_retry >= 3)
@@ -3933,6 +3948,9 @@ int SlacComm()
                             SwitchCpStateE(DISABLE);
                             OutputCpPwmDuty(5);
                             PwmStartTime = time(NULL);
+#ifdef TEST_WITH_ETH0
+                            Update_V2G_Flow_Status(SLACC_SDP_UDP_Connection);
+#endif
                         }
                         else
                         {
@@ -7760,12 +7778,13 @@ int Proc_iso1_ChargeParameterDiscoveryRes(int AcceptFd)
 
     //[TC_SECC_VTB_ChargeParameterDiscovery_005]
     /*+++ 20200808, vern, should check the voltage and current to see if the range of battery parameter is accepted by charger ---*/
+#ifdef TEST_WITH_ETH0
+    if((ShmCcsData->EnergyTransferMode == MODE_DC_EXTENDED) && ((sys->EvBatteryMaxCurrent < 0) || (sys->EvBatteryMaxVoltage<150)))
+#else
     if ((sys->EvBatteryMaxCurrent < 0) ||(sys->EvBatteryMaxVoltage<150))
+#endif
     {
-        sprintf((char*)buf_log_evcomm,
-                "[ERROR]EvBatteryMaxCurrent is negative(%.02f) => End_Process",
-                sys->EvBatteryMaxCurrent);
-        SAVE_SYS_LOG_MSG_EVCOMM("%s\n", buf_log_evcomm);
+        SAVE_SYS_LOG_MSG_EVCOMM("[ERROR]EvBatteryMaxCurrent is negative(%.02f) or  EvBatteryMaxVoltage is under 150(%.02f)=> End_Process\n", sys->EvBatteryMaxCurrent, sys->EvBatteryMaxVoltage);
 
         res->ResponseCode = iso1responseCodeType_FAILED_WrongChargeParameter;   //16
         res->EVSEProcessing = Finished_ISO15118_2014;
@@ -13935,7 +13954,7 @@ int V2gMsg_Process_iso1_AC(int AcceptFd)
                     }
                     else
                     {
-                        SAVE_SYS_LOG_MSG_EVCOMM("%s\n", "[Error]supportedAppProtocolResReq: fail");
+                        SAVE_SYS_LOG_MSG_EVCOMM("[Error]supportedAppProtocolResReq: fail\n");
                         Update_V2G_Flow_Status(Other_Fault);
                     }
                 }
@@ -13961,9 +13980,7 @@ int V2gMsg_Process_iso1_AC(int AcceptFd)
                     EVCOMM_SYS_INFO.V2G_Rx_Msg = 0;
                 }
                 else
-                {
-
-                }
+                {}
 
                 break;
             }
@@ -13977,7 +13994,7 @@ int V2gMsg_Process_iso1_AC(int AcceptFd)
                 }
                 else
                 {
-                    SAVE_SYS_LOG_MSG_EVCOMM("%s\n", "[Error]SessionSetupReqRes: fail");
+                    SAVE_SYS_LOG_MSG_EVCOMM("[Error]SessionSetupReqRes: fail\n");
                     Update_V2G_Flow_Status(Other_Fault);
                 }
                 req_is_responsed = TRUE;
@@ -14002,9 +14019,7 @@ int V2gMsg_Process_iso1_AC(int AcceptFd)
                     EVCOMM_SYS_INFO.V2G_Rx_Msg = 0;
                 }
                 else
-                {
-
-                }
+                {}
 
                 break;
             }
@@ -14018,7 +14033,7 @@ int V2gMsg_Process_iso1_AC(int AcceptFd)
                 }
                 else
                 {
-                    SAVE_SYS_LOG_MSG_EVCOMM("%s\n", "[Error]ServiceDiscoveryReqRes: fail");
+                    SAVE_SYS_LOG_MSG_EVCOMM("[Error]ServiceDiscoveryReqRes: fail\n");
                     Update_V2G_Flow_Status(Other_Fault);
                 }
                 req_is_responsed = TRUE;
@@ -14043,9 +14058,7 @@ int V2gMsg_Process_iso1_AC(int AcceptFd)
                     EVCOMM_SYS_INFO.V2G_Rx_Msg = 0;
                 }
                 else
-                {
-
-                }
+                {}
 
                 break;
             }
@@ -14059,7 +14072,7 @@ int V2gMsg_Process_iso1_AC(int AcceptFd)
                 }
                 else
                 {
-                    SAVE_SYS_LOG_MSG_EVCOMM("%s\n", "[Error]ServiceAndPaymentSelectionReqRes: fail");
+                    SAVE_SYS_LOG_MSG_EVCOMM("[Error]ServiceAndPaymentSelectionReqRes: fail\n");
                     Update_V2G_Flow_Status(Other_Fault);
                 }
                 req_is_responsed = TRUE;
@@ -14084,9 +14097,7 @@ int V2gMsg_Process_iso1_AC(int AcceptFd)
                     EVCOMM_SYS_INFO.V2G_Rx_Msg = 0;
                 }
                 else
-                {
-
-                }
+                {}
 
                 break;
             }
@@ -14160,7 +14171,7 @@ int V2gMsg_Process_iso1_AC(int AcceptFd)
                 }
                 else
                 {
-                    SAVE_SYS_LOG_MSG_EVCOMM("%s\n", "[Error]ChargeParameterDiscoveryReqRes: fail");
+                    SAVE_SYS_LOG_MSG_EVCOMM("[Error]ChargeParameterDiscoveryReqRes: fail\n");
                     Update_V2G_Flow_Status(Other_Fault);
                 }
                 req_is_responsed = TRUE;
@@ -14173,11 +14184,7 @@ int V2gMsg_Process_iso1_AC(int AcceptFd)
     	        ftime(&SeqEndTime);
     	        if(DiffTimeb(SeqStartTime, SeqEndTime) > V2G_SECC_ChargingParameter_Performance_Time)  //60 seconds
     	        {
-    	            sprintf((char*)buf_log_evcomm,
-                            "ChargingParameter Timeout - (%.02lf of %d ms)\n",
-    	                    DiffTimeb(SeqStartTime, SeqEndTime),
-    	                    V2G_SECC_ChargingParameter_Performance_Time);
-                    SAVE_SYS_LOG_MSG_EVCOMM("%s\n", buf_log_evcomm);
+                    SAVE_SYS_LOG_MSG_EVCOMM("ChargingParameter Timeout - (%.02lf of %d ms)\n", DiffTimeb(SeqStartTime, SeqEndTime), V2G_SECC_ChargingParameter_Performance_Time);
     	            Update_V2G_Flow_Status(Sequence_Timeout);
                     break;
     	        }
@@ -14193,7 +14200,7 @@ int V2gMsg_Process_iso1_AC(int AcceptFd)
                     }
                     else
                     {
-                        SAVE_SYS_LOG_MSG_EVCOMM("%s\n", "[Error]ChargeParameterDiscoveryReqRes: fail");
+                        SAVE_SYS_LOG_MSG_EVCOMM("[Error]ChargeParameterDiscoveryReqRes: fail\n");
                         Update_V2G_Flow_Status(Other_Fault);
                     }
                     req_is_responsed = TRUE;
@@ -14208,9 +14215,9 @@ int V2gMsg_Process_iso1_AC(int AcceptFd)
 
                     //ftime(&EVCOMM_SYS_INFO.V2G_SECC_ChargeParameterDiscovery_Timer_End);
 
-                    #if V2G_SECC_TIMEOUT_PROTECTION == ENABLE
+			#if V2G_SECC_TIMEOUT_PROTECTION == ENABLE
                     ftime(&SeqStartTime);
-                    #endif
+			#endif
 
                     if (Proc_iso1_PowerDeliveryStopReq(AcceptFd) == 0)
                     {
@@ -14219,7 +14226,7 @@ int V2gMsg_Process_iso1_AC(int AcceptFd)
                     }
                     else
                     {
-                        SAVE_SYS_LOG_MSG_EVCOMM("%s\n", "[Error]PowerDeliveryStopReqRes: fail");
+                        SAVE_SYS_LOG_MSG_EVCOMM("[Error]PowerDeliveryStopReqRes: fail\n");
                         Update_V2G_Flow_Status(Other_Fault);
                     }
     		#if V2G_SECC_TIMEOUT_PROTECTION == ENABLE
@@ -14253,7 +14260,7 @@ int V2gMsg_Process_iso1_AC(int AcceptFd)
                 }
                 else
                 {
-                    SAVE_SYS_LOG_MSG_EVCOMM("%s\n", "[Error]PowerDeliveryStartReqRes: fail");
+                    SAVE_SYS_LOG_MSG_EVCOMM("[Error]PowerDeliveryStartReqRes: fail\n");
                     Update_V2G_Flow_Status(Other_Fault);
                 }
                 req_is_responsed = TRUE;
@@ -14262,36 +14269,30 @@ int V2gMsg_Process_iso1_AC(int AcceptFd)
             case PowerDeliveryResponsetStart:       //42
             {
                 //STEP 1: Check for Process Timeout
-                #if V2G_SECC_TIMEOUT_PROTECTION == ENABLE
+			#if V2G_SECC_TIMEOUT_PROTECTION == ENABLE
                 if (ccs_exi_doc_ISO1.V2G_Message.Body.PowerDeliveryReq_isUsed == 1u)
                 {
                     ftime(&SeqEndTime);
                     if(DiffTimeb(SeqStartTime, SeqEndTime) > 2000)  //5 seconds
                     {
-                        sprintf((char*)buf_log_evcomm,
-                                "Wait for ChargingStatusReq Timeout - (%.02lf of %d ms)\n",
-                                DiffTimeb(SeqStartTime, SeqEndTime),
-                                2000);
-                        SAVE_SYS_LOG_MSG_EVCOMM("%s\n", buf_log_evcomm);
+                        SAVE_SYS_LOG_MSG_EVCOMM("Wait for ChargingStatusReq Timeout - (%.02lf of %d ms)\n", DiffTimeb(SeqStartTime, SeqEndTime), 2000);
                         Update_V2G_Flow_Status(Sequence_Timeout);
                     }
                     break;
                 }
-                #endif
+			#endif
 
                 //STEP 2: Wait for ChargingStatusReq Message
                 if (EVCOMM_SYS_INFO.V2G_Rx_Msg == ChargingStatusRequest)
                 {
     	            EVCOMM_SYS_INFO.V2G_Rx_Msg = 0;
                     Update_V2G_Flow_Status(ChargingStatusRequest);
-                    SAVE_SYS_LOG_MSG_EVCOMM("%s\n", "[V2G][RX]ChargingStatusReq: energy transfering...");
+                    SAVE_SYS_LOG_MSG_EVCOMM("[V2G][RX]ChargingStatusReq: energy transfering...\n");
 
                     ftime(&EVCOMM_SYS_INFO.V2G_SECC_ChargingStatus_Timer_Start);
                 }
                 else
-                {
-
-                }
+                {}
 
                 break;
             }
@@ -14305,7 +14306,7 @@ int V2gMsg_Process_iso1_AC(int AcceptFd)
                 }
                 else
                 {
-                    SAVE_SYS_LOG_MSG_EVCOMM("%s\n", "[Error]ChargingStatusRes: fail");
+                    SAVE_SYS_LOG_MSG_EVCOMM("[Error]ChargingStatusRes: fail\n");
                     Update_V2G_Flow_Status(Other_Fault);
                 }
                 req_is_responsed = TRUE;
@@ -14323,7 +14324,7 @@ int V2gMsg_Process_iso1_AC(int AcceptFd)
                     }
                     else
                     {
-                        SAVE_SYS_LOG_MSG_EVCOMM("%s\n", "[Error]ChargingStatusRes: fail");
+                        SAVE_SYS_LOG_MSG_EVCOMM("[Error]ChargingStatusRes: fail\n");
                         Update_V2G_Flow_Status(Other_Fault);
                     }
                     req_is_responsed = TRUE;
@@ -14337,9 +14338,9 @@ int V2gMsg_Process_iso1_AC(int AcceptFd)
 
                     ftime(&EVCOMM_SYS_INFO.V2G_SECC_ChargingStatus_Timer_End);
 
-                    #if V2G_SECC_TIMEOUT_PROTECTION == ENABLE
+				#if V2G_SECC_TIMEOUT_PROTECTION == ENABLE
                     ftime(&SeqStartTime);
-                    #endif
+				#endif
                 }
                 else if (EVCOMM_SYS_INFO.V2G_Rx_Msg >= SupportedAppProtocolRequest &&
                          EVCOMM_SYS_INFO.V2G_Rx_Msg <= SessionStopRequest)
@@ -14353,9 +14354,7 @@ int V2gMsg_Process_iso1_AC(int AcceptFd)
                     EVCOMM_SYS_INFO.V2G_Rx_Msg = 0;
                 }
                 else
-                {
-
-                }
+                {}
 
                 break;
             }
@@ -14367,13 +14366,13 @@ int V2gMsg_Process_iso1_AC(int AcceptFd)
                     Update_V2G_Flow_Status(PowerDeliveryResponseStop);
                     ftime(&EVCOMM_SYS_INFO.V2G_SECC_Sequence_Timer_Start);
 
-                    #if V2G_SECC_TIMEOUT_PROTECTION == ENABLE
+				#if V2G_SECC_TIMEOUT_PROTECTION == ENABLE
                     ftime(&SeqStartTime);
-                    #endif
+				#endif
                 }
                 else
                 {
-                    SAVE_SYS_LOG_MSG_EVCOMM("%s\n", "[Error]PowerDeliveryStopReqRes: fail");
+                    SAVE_SYS_LOG_MSG_EVCOMM("[Error]PowerDeliveryStopReqRes: fail\n");
                     Update_V2G_Flow_Status(Other_Fault);
                 }
                 req_is_responsed = TRUE;
@@ -14382,19 +14381,15 @@ int V2gMsg_Process_iso1_AC(int AcceptFd)
             case PowerDeliveryResponseStop:         //50
             {
                 //STEP 1: Check for Process Timeout
-                #if V2G_SECC_TIMEOUT_PROTECTION == ENABLE
+			#if V2G_SECC_TIMEOUT_PROTECTION == ENABLE
                 ftime(&SeqEndTime);
                 if(DiffTimeb(SeqStartTime, SeqEndTime) > 2000)  //2 seconds
                 {
-                    sprintf((char*)buf_log_evcomm,
-                            "Wait for SessionStopReq Timeout - (%.02lf of %d ms)\n",
-                            DiffTimeb(SeqStartTime, SeqEndTime),
-                            2000);
-                    SAVE_SYS_LOG_MSG_EVCOMM("%s\n", buf_log_evcomm);
+                    SAVE_SYS_LOG_MSG_EVCOMM("Wait for SessionStopReq Timeout - (%.02lf of %d ms)\n", DiffTimeb(SeqStartTime, SeqEndTime), 2000);
                     Update_V2G_Flow_Status(Sequence_Timeout);
                     break;
                 }
-                #endif
+			#endif
 
                 //STEP 3: Check for SessionStopReq Message
                 else if(EVCOMM_SYS_INFO.V2G_Rx_Msg == SessionStopRequest)
@@ -14414,13 +14409,10 @@ int V2gMsg_Process_iso1_AC(int AcceptFd)
                     EVCOMM_SYS_INFO.V2G_Rx_Msg = 0;
                 }
                 else
-                {
-
-                }
+                {}
 
                 break;
             }
-            //-------------------------------------------
             case SessionStopRequest:                //53
             {
                 if (Proc_iso1_SessionStopReq(AcceptFd) == 0)
@@ -14430,7 +14422,7 @@ int V2gMsg_Process_iso1_AC(int AcceptFd)
                 }
                 else
                 {
-                    SAVE_SYS_LOG_MSG_EVCOMM("%s\n", "[Error]SessionStopReqRes: fail");
+                    SAVE_SYS_LOG_MSG_EVCOMM("[Error]SessionStopReqRes: fail\n");
                     Update_V2G_Flow_Status(Other_Fault);
                 }
                 req_is_responsed = TRUE;
@@ -14440,7 +14432,6 @@ int V2gMsg_Process_iso1_AC(int AcceptFd)
             {
                 break;
             }
-            //-------------------------------------------
             default:
             {
                 break;
@@ -15639,7 +15630,19 @@ int SdpUdpConnected()
             // MAC address[0:2] + FFFE + MAC address[3:5]
             payload[0] = (IPV6_LINK_LOCAL_PREFIX>>8) & 0xFF;
             payload[1] = IPV6_LINK_LOCAL_PREFIX & 0xFF;
-            payload[8 ]= CsuMac[0];
+#ifdef TEST_WITH_ETH0
+            payload[8] = eth0Mac[0];
+			payload[8] ^= 0x02;// bit 1 should complemented.
+			payload[9] = eth0Mac[1];
+			payload[10] = eth0Mac[2];
+			payload[11] = 0xFF;
+			payload[12] = 0xFE;
+			payload[13] = eth0Mac[3];
+			payload[14] = eth0Mac[4];
+			payload[15] = eth0Mac[5];
+#else
+
+            payload[8] = CsuMac[0];
             payload[8] ^= 0x02;// bit 1 should complemented.
             payload[9] = CsuMac[1];
             payload[10] = CsuMac[2];
@@ -15648,6 +15651,7 @@ int SdpUdpConnected()
             payload[13] = CsuMac[3];
             payload[14] = CsuMac[4];
             payload[15] = CsuMac[5];
+#endif
             //TCP port
             payload[16] = (EVCOMM_SYS_INFO.SDP_TCP_Server_Port_active>>8) & 0xFF;
             payload[17] = EVCOMM_SYS_INFO.SDP_TCP_Server_Port_active & 0xFF;
@@ -16024,7 +16028,7 @@ GLOBAL VARIABLES:
 =============================================================================*/
 int SyncAcShreaMemory()
 {
-#if (CCS_ENERGY_TRANSFER_MODE == MODE_AC_THREE_PHASE_CORE)
+#if ((CCS_ENERGY_TRANSFER_MODE == MODE_AC_SINGLE_PHASE_CORE) || (CCS_ENERGY_TRANSFER_MODE == MODE_AC_THREE_PHASE_CORE))
 	pid_t pid;
 
 	pid = fork();
@@ -16155,6 +16159,7 @@ int main(int argc, char *argv[])
 
     //Init communication parameters
     GetEthMac((uint8_t*)QcaInterface, CsuMac);
+    GetEthMac((uint8_t*)"eth0", eth0Mac);
 
     AttenProfileCnt = 0;
     init_appHandEXIDocument(&ccs_handshake);

+ 1 - 0
EVSE/Projects/AW-CCS/Apps/CCS/Module_CCS.h

@@ -38,6 +38,7 @@
 #include	"v2g/api/api.h"
 #include	"v2g/transport/v2gtp.h"
 
+//#define TEST_WITH_ETH0
 
 #define SAVE_SYS_LOG_MSG_EVCOMM_SWITCH		ENABLE
 #define DEBUG_PRINTF_EVCOMM_SHOW			ENABLE

+ 4 - 4
EVSE/Projects/AW-CCS/Apps/LCM/Module_LcmControl.c

@@ -1371,9 +1371,9 @@ void setRfidIcon()
 	*/
 
 	if(ShmSysConfigAndInfo->SysConfig.isRFID == ON)
-		setDisplayValue(ICON_NEW_RFID, 0x02);
+		setDisplayValue(ICON_NEW_RFID, NEW_RFID_ENABLE);
 	else
-		setDisplayValue(ICON_NEW_RFID, 0x01);
+		setDisplayValue(ICON_NEW_RFID, NEW_RFID_DISABLE);
 
 }
 
@@ -1409,7 +1409,7 @@ void setQRCodeIcon()
 
 	if(ShmSysConfigAndInfo->SysConfig.isQRCode == ON)
 	{
-		setDisplayValue(ICON_NEW_QR_CODE,0x02);
+		setDisplayValue(ICON_NEW_QR_CODE,NEW_QRCODE_ENABLE);
 		if(ShmSysConfigAndInfo->SysConfig.QRCodeMadeMode == NO)
 		{
 			length = strlen((char *)ShmSysConfigAndInfo->SysConfig.SystemId);
@@ -1424,7 +1424,7 @@ void setQRCodeIcon()
 	else
 	{
 		setDisplayValue(TEXT_QRCODE_CONTENT, DISAPPEAR);
-		setDisplayValue(ICON_NEW_QR_CODE,0x01);
+		setDisplayValue(ICON_NEW_QR_CODE,NEW_QRCODE_DISABLE);
 	}
 }
 

+ 4 - 0
EVSE/Projects/AW-CCS/Apps/LCM/lcmComm_dgus.h

@@ -149,6 +149,10 @@
 #define QRCODE_BANDED						0x01
 #define QRCODE_ENABLE 						0x02
 #define QRCODE_DISABLE						0x03
+#define NEW_QRCODE_DISABLE					0x01
+#define NEW_QRCODE_ENABLE					0x02
+#define NEW_RFID_DISABLE					0x01
+#define NEW_RFID_ENABLE						0x02
 
 //=======================================
 // Icon variable address start from 1000

+ 161 - 58
EVSE/Projects/AW-CCS/Apps/Module_AlarmDetect.c

@@ -289,7 +289,7 @@ int main(void)
 			//=====================================
 			// Over voltage detection
 			//=====================================
-			if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode & ALARM_L1_OVER_VOLTAGE)
+			if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.OVP_L1 == ON)
 			{
 				if(Alarm_Counter[gun_index].OV[0] > FILTER_SPEC)
 				{
@@ -305,7 +305,7 @@ int main(void)
 					Alarm_Counter[gun_index].OV[0]++;
 				}
 			}
-			else if((!(ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode & ALARM_L1_OVER_VOLTAGE)))
+			else
 			{
 				Alarm_Counter[gun_index].OV[0] = 0;
 				if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputOVP == ON)
@@ -318,7 +318,7 @@ int main(void)
 
 			if(ShmSysConfigAndInfo->SysConfig.AcPhaseCount == 3)
 			{
-				if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode & ALARM_L2_OVER_VOLTAGE)
+				if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.OVP_L2 == ON)
 				{
 					if(Alarm_Counter[gun_index].OV[1] > FILTER_SPEC)
 					{
@@ -334,7 +334,7 @@ int main(void)
 						Alarm_Counter[gun_index].OV[1]++;
 					}
 				}
-				else if((!(ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode & ALARM_L2_OVER_VOLTAGE)))
+				else
 				{
 					Alarm_Counter[gun_index].OV[1] = 0;
 					if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputOVP == ON)
@@ -345,7 +345,7 @@ int main(void)
 					}
 				}
 
-				if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode & ALARM_L3_OVER_VOLTAGE)
+				if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.OVP_L3 == ON)
 				{
 					if(Alarm_Counter[gun_index].OV[2] > FILTER_SPEC)
 					{
@@ -361,7 +361,7 @@ int main(void)
 						Alarm_Counter[gun_index].OV[2]++;
 					}
 				}
-				else if((!(ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode & ALARM_L3_OVER_VOLTAGE)))
+				else
 				{
 					Alarm_Counter[gun_index].OV[2] = 0;
 					if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputOVP == ON)
@@ -376,7 +376,7 @@ int main(void)
 			//=====================================
 			// Under voltage detection
 			//=====================================
-			if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode & ALARM_L1_UNDER_VOLTAGE)
+			if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.UVP_L1 == ON)
 			{
 				if(Alarm_Counter[gun_index].UV[0] > FILTER_SPEC)
 				{
@@ -392,7 +392,7 @@ int main(void)
 					Alarm_Counter[gun_index].UV[0]++;
 				}
 			}
-			else if((!(ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode & ALARM_L1_UNDER_VOLTAGE)))
+			else
 			{
 				Alarm_Counter[gun_index].UV[0] = 0;
 				if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputUVP == ON)
@@ -405,7 +405,7 @@ int main(void)
 
 			if(ShmSysConfigAndInfo->SysConfig.AcPhaseCount == 3)
 			{
-				if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode & ALARM_L2_UNDER_VOLTAGE)
+				if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.UVP_L2 == ON)
 				{
 					if(Alarm_Counter[gun_index].UV[1] > FILTER_SPEC)
 					{
@@ -421,7 +421,7 @@ int main(void)
 						Alarm_Counter[gun_index].UV[1]++;
 					}
 				}
-				else if((!(ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode & ALARM_L2_UNDER_VOLTAGE)))
+				else
 				{
 					Alarm_Counter[gun_index].UV[1] = 0;
 					if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputUVP == ON)
@@ -432,7 +432,7 @@ int main(void)
 					}
 				}
 
-				if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode & ALARM_L3_UNDER_VOLTAGE)
+				if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.UVP_L3 == ON)
 				{
 					if(Alarm_Counter[gun_index].UV[2] > FILTER_SPEC)
 					{
@@ -448,7 +448,7 @@ int main(void)
 						Alarm_Counter[gun_index].UV[2]++;
 					}
 				}
-				else if((!(ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode & ALARM_L3_UNDER_VOLTAGE)))
+				else
 				{
 					Alarm_Counter[gun_index].UV[2] = 0;
 					if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputUVP == ON)
@@ -464,7 +464,7 @@ int main(void)
 			//=====================================
 			// Over current detection
 			//=====================================
-			if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode & ALARM_L1_OVER_CURRENT)
+			if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.OCP_L1 == ON)
 			{
 				if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAcOutputOCP == OFF)
 				{
@@ -473,7 +473,7 @@ int main(void)
 					DEBUG_INFO("ALARM_L1_OVER_CURRENT : alarm \n");
 				}
 			}
-			else if ((!(ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode & ALARM_L1_OVER_CURRENT)))
+			else
 			{
 				if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAcOutputOCP == ON)
 				{
@@ -485,7 +485,7 @@ int main(void)
 
 			if(ShmSysConfigAndInfo->SysConfig.AcPhaseCount == 3)
 			{
-				if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode & ALARM_L2_OVER_CURRENT)
+				if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.OCP_L2 == ON)
 				{
 					if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAcOutputOCPL2 == OFF)
 					{
@@ -494,7 +494,7 @@ int main(void)
 						DEBUG_INFO("ALARM_L2_OVER_CURRENT : alarm \n");
 					}
 				}
-				else if ((!(ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode & ALARM_L2_OVER_CURRENT)))
+				else
 				{
 					if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAcOutputOCPL2 == ON)
 					{
@@ -504,7 +504,7 @@ int main(void)
 					}
 				}
 
-				if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode & ALARM_L3_OVER_CURRENT)
+				if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.OCP_L3 == ON)
 				{
 					if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAcOutputOCPL3 == OFF)
 					{
@@ -513,7 +513,7 @@ int main(void)
 						DEBUG_INFO("ALARM_L3_OVER_CURRENT : alarm \n");
 					}
 				}
-				else if ((!(ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode & ALARM_L3_OVER_CURRENT)))
+				else
 				{
 					if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAcOutputOCPL3 == ON)
 					{
@@ -527,7 +527,7 @@ int main(void)
 			//=====================================
 			// Over temperature detection
 			//=====================================
-			if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode & ALARM_OVER_TEMPERATURE)
+			if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.OTP == ON)
 			{
 				if(Alarm_Counter[gun_index].OT_AMB > FILTER_SPEC)
 				{
@@ -543,7 +543,7 @@ int main(void)
 					Alarm_Counter[gun_index].OT_AMB++;
 				}
 			}
-			else if((!(ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode & ALARM_OVER_TEMPERATURE)))
+			else
 			{
 				Alarm_Counter[gun_index].OT_AMB = 0;
 				if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAmbientOTP == ON)
@@ -557,7 +557,7 @@ int main(void)
 			//=====================================
 			// Ground fault detection
 			//=====================================
-			if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode & ALARM_GROUND_FAIL)
+			if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.gmi_fault == ON)
 			{
 				if(Alarm_Counter[gun_index].GMI > FILTER_SPEC)
 				{
@@ -573,7 +573,7 @@ int main(void)
 					Alarm_Counter[gun_index].GMI++;
 				}
 			}
-			else if (!(ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode & ALARM_GROUND_FAIL))
+			else
 			{
 				Alarm_Counter[gun_index].GMI = 0;
 				if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.AcGroundfaultFail == ON)
@@ -587,7 +587,7 @@ int main(void)
 			//=====================================
 			// CP level fail detection
 			//=====================================
-			if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode & ALARM_CP_ERROR)
+			if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.cp_fault == ON)
 			{
 				if(Alarm_Counter[gun_index].CP_LevelFail > FILTER_SPEC)
 				{
@@ -603,7 +603,7 @@ int main(void)
 					Alarm_Counter[gun_index].CP_LevelFail++;
 				}
 			}
-			else if(!(ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode & ALARM_CP_ERROR))
+			else
 			{
 				Alarm_Counter[gun_index].CP_LevelFail= 0;
 				if(ShmStatusCodeData->InfoCode.InfoEvents.bits.PilotFault == ON)
@@ -617,21 +617,21 @@ int main(void)
 			//=====================================
 			// Current AC/DC leak detection
 			//=====================================
-			if((ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode & ALARM_CURRENT_LEAK_AC) ||
-			   (ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode & ALARM_CURRENT_LEAK_DC))
+			if((ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.ac_leak == ON) ||
+			   (ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.dc_leak == ON))
 			{
 				if(Alarm_Counter[gun_index].Leakage > FILTER_SPEC)
 				{
 					if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.RcdTrip == OFF)
 					{
 						ShmStatusCodeData->AlarmCode.AlarmEvents.bits.RcdTrip = ON;
-						if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode & ALARM_CURRENT_LEAK_AC)
+						if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.ac_leak == ON)
 						{
 							ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode |= ALARM_CURRENT_LEAK_AC;
 							ShmCharger->gun_info[gun_index].otherAlarmCode.isACLeakage = ON;
 							DEBUG_INFO("ALARM_CURRENT_LEAK_AC : alarm \n");
 						}
-						else if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode & ALARM_CURRENT_LEAK_DC)
+						else if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.dc_leak == ON)
 						{
 							ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode |= ALARM_CURRENT_LEAK_DC;
 							ShmCharger->gun_info[gun_index].otherAlarmCode.isDcLeakage = ON;
@@ -644,8 +644,7 @@ int main(void)
 					Alarm_Counter[gun_index].Leakage++;
 				}
 			}
-			else if((!(ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode & ALARM_CURRENT_LEAK_AC)) ||
-					(!(ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode & ALARM_CURRENT_LEAK_DC)))
+			else
 			{
 				Alarm_Counter[gun_index].Leakage = 0;
 				if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.RcdTrip == ON)
@@ -669,7 +668,7 @@ int main(void)
 			//=====================================
 			// MCU self test fail detection
 			//=====================================
-			if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode & ALARM_MCU_TESTFAIL)
+			if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.mcu_selftest_fail == ON)
 			{
 				if(Alarm_Counter[gun_index].MCU_SelfTestFail > FILTER_SPEC)
 				{
@@ -685,7 +684,7 @@ int main(void)
 					Alarm_Counter[gun_index].MCU_SelfTestFail++;
 				}
 			}
-			else if(!(ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode & ALARM_MCU_TESTFAIL))
+			else
 			{
 				Alarm_Counter[gun_index].MCU_SelfTestFail = 0;
 				if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.McuSelftestFail == ON)
@@ -699,7 +698,7 @@ int main(void)
 			//=====================================
 			// Hand shaking timeout detection
 			//=====================================
-			if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode & ALARM_HANDSHAKE_TIMEOUT)
+			if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.handshaking_timeout == ON)
 			{
 				if(ShmCharger->gun_info[gun_index].otherAlarmCode.isHandshakingTimeOut == OFF)
 				{
@@ -709,7 +708,7 @@ int main(void)
 				}
 
 			}
-			else if(!(ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode & ALARM_HANDSHAKE_TIMEOUT))
+			else
 			{
 				if(ShmCharger->gun_info[gun_index].otherAlarmCode.isHandshakingTimeOut == ON)
 				{
@@ -722,7 +721,7 @@ int main(void)
 			//=====================================
 			// Emergency stop detection
 			//=====================================
-			if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode & ALARM_EMERGENCY_STOP)
+			if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.emergency_stop == ON)
 			{
 				if(Alarm_Counter[gun_index].EmrgencyBTN > FILTER_SPEC)
 				{
@@ -738,7 +737,7 @@ int main(void)
 					Alarm_Counter[gun_index].EmrgencyBTN++;
 				}
 			}
-			else if(!(ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode & ALARM_EMERGENCY_STOP))
+			else
 			{
 				Alarm_Counter[gun_index].EmrgencyBTN = 0;
 				if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.EmergencyStopTrip == ON)
@@ -752,7 +751,7 @@ int main(void)
 			//=====================================
 			// Relay welding detection
 			//=====================================
-			if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode & ALARM_RELAY_WELDING)
+			if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.relay_welding == ON)
 			{
 				if(Alarm_Counter[gun_index].Relay_Welding > FILTER_SPEC)
 				{
@@ -768,7 +767,7 @@ int main(void)
 					Alarm_Counter[gun_index].Relay_Welding++;
 				}
 			}
-			else if(!(ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode & ALARM_RELAY_WELDING))
+			else
 			{
 				Alarm_Counter[gun_index].Relay_Welding = 0;
 				if(ShmStatusCodeData->FaultCode.FaultEvents.bits.AcOutputRelayWelding == ON)
@@ -782,7 +781,7 @@ int main(void)
 			//=====================================
 			// Relay driving fault detection
 			//=====================================
-			if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode & ALARM_RELAY_DRIVE_FAULT)
+			if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.relay_drive_fault == ON)
 			{
 				if(Alarm_Counter[gun_index].Relay_DrivingFault > FILTER_SPEC)
 				{
@@ -798,7 +797,7 @@ int main(void)
 					Alarm_Counter[gun_index].Relay_DrivingFault++;
 				}
 			}
-			else if(!(ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode & ALARM_RELAY_DRIVE_FAULT))
+			else
 			{
 				Alarm_Counter[gun_index].Relay_DrivingFault = 0;
 				if(ShmStatusCodeData->FaultCode.FaultEvents.bits.AcOutputRelayDrivingFault == ON)
@@ -812,7 +811,7 @@ int main(void)
 			//=====================================
 			// Current short detection
 			//=====================================
-			if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode & ALARM_L1_CIRCUIT_SHORT)
+			if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.short_circuit_L1 == ON)
 			{
 				if(Alarm_Counter[gun_index].Short[0] > FILTER_SPEC)
 				{
@@ -828,7 +827,7 @@ int main(void)
 					Alarm_Counter[gun_index].Short[0]++;
 				}
 			}
-			else if(!(ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode & ALARM_L1_CIRCUIT_SHORT))
+			else
 			{
 				Alarm_Counter[gun_index].Short[0] = 0;
 				if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CircuitShort == ON)
@@ -841,7 +840,7 @@ int main(void)
 			
 			if(ShmSysConfigAndInfo->SysConfig.AcPhaseCount == 3)
 			{
-				if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode & ALARM_L2_CIRCUIT_SHORT)
+				if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.short_circuit_L2 == ON)
 				{
 					if(Alarm_Counter[gun_index].Short[1] > FILTER_SPEC)
 					{
@@ -857,7 +856,7 @@ int main(void)
 						Alarm_Counter[gun_index].Short[1]++;
 					}
 				}
-				else if(!(ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode & ALARM_L2_CIRCUIT_SHORT))
+				else
 				{
 					Alarm_Counter[gun_index].Short[1] = 0;
 					if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CircuitShortL2 == ON)
@@ -868,7 +867,7 @@ int main(void)
 					}
 				}
 
-				if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode & ALARM_L3_CIRCUIT_SHORT)
+				if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.short_circuit_L3 == ON)
 				{
 					if(Alarm_Counter[gun_index].Short[2] > FILTER_SPEC)
 					{
@@ -884,7 +883,7 @@ int main(void)
 						Alarm_Counter[gun_index].Short[2]++;
 					}
 				}
-				else if(!(ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode & ALARM_L3_CIRCUIT_SHORT))
+				else
 				{
 					Alarm_Counter[gun_index].Short[2] = 0;
 					if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CircuitShortL3 == ON)
@@ -899,7 +898,7 @@ int main(void)
 			//=====================================
 			// Rotatory switch detection
 			//=====================================
-			if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode & ALARM_ROTATORY_SWITCH_FAULT)
+			if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.rotate_switch_fault == ON)
 			{
 				if(ShmStatusCodeData->FaultCode.FaultEvents.bits.RotarySwitchFault == OFF)
 				{
@@ -908,7 +907,7 @@ int main(void)
 					DEBUG_INFO("ALARM_ROTATORY_SWITCH_FAULT : alarm \n");
 				}
 			}
-			else if(!(ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode & ALARM_ROTATORY_SWITCH_FAULT))
+			else
 			{
 				if(ShmStatusCodeData->FaultCode.FaultEvents.bits.RotarySwitchFault == ON)
 				{
@@ -921,7 +920,7 @@ int main(void)
 			//=====================================
 			// Leakage module detection
 			//=====================================
-			if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode & ALARM_LEAK_MODULE_FAIL)
+			if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.leak_module_fail == ON)
 			{
 				if(ShmStatusCodeData->FaultCode.FaultEvents.bits.RcdSelfTestFail == OFF)
 				{
@@ -930,7 +929,7 @@ int main(void)
 					DEBUG_INFO("ALARM_LEAK_MODULE_FAIL : alarm \n");
 				}
 			}
-			else if(!(ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode & ALARM_LEAK_MODULE_FAIL))
+			else
 			{
 				if(ShmStatusCodeData->FaultCode.FaultEvents.bits.RcdSelfTestFail == ON)
 				{
@@ -943,7 +942,7 @@ int main(void)
 			//=====================================
 			// Shutter detection
 			//=====================================
-			if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode & ALARM_SHUTTER_FAULT)
+			if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.shutter_fault == ON)
 			{
 				if(ShmStatusCodeData->FaultCode.FaultEvents.bits.ShutterFault == OFF)
 				{
@@ -952,7 +951,7 @@ int main(void)
 					DEBUG_INFO("ALARM_SHUTTER_FAULT : alarm \n");
 				}
 			}
-			else if(!(ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode & ALARM_SHUTTER_FAULT))
+			else
 			{
 				if(ShmStatusCodeData->FaultCode.FaultEvents.bits.ShutterFault == ON)
 				{
@@ -965,7 +964,7 @@ int main(void)
 			//=====================================
 			// Locker detection
 			//=====================================
-			if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode & ALARM_LOCKER_FAULT)
+			if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.locker_fault == ON)
 			{
 				if(ShmStatusCodeData->FaultCode.FaultEvents.bits.AcConnectorLockFail == OFF)
 				{
@@ -974,7 +973,7 @@ int main(void)
 					DEBUG_INFO("ALARM_LOCKER_FAULT : alarm \n");
 				}
 			}
-			else if(!(ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode & ALARM_LOCKER_FAULT))
+			else
 			{
 				if(ShmStatusCodeData->FaultCode.FaultEvents.bits.AcConnectorLockFail == ON)
 				{
@@ -987,7 +986,7 @@ int main(void)
 			//=====================================
 			// Power drop detection
 			//=====================================
-			if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode & ALARM_POWER_DROP)
+			if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.power_drop == ON)
 			{
 				if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputDrop == OFF)
 				{
@@ -996,7 +995,7 @@ int main(void)
 					DEBUG_INFO("ALARM_POWER_DROP : alarm \n");
 				}
 			}
-			else if(!(ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode & ALARM_POWER_DROP))
+			else
 			{
 				if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputDrop == ON)
 				{
@@ -1009,7 +1008,7 @@ int main(void)
 			//=====================================
 			// Meter communication timeout detection
 			//=====================================
-			if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode & ALARM_METER_TIMEOUT)
+			if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.meter_comm_timeout == ON)
 			{
 				if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.MeterCommTimeout == OFF)
 				{
@@ -1018,7 +1017,7 @@ int main(void)
 					DEBUG_INFO("ALARM_METER_TIMEOUT : alarm \n");
 				}
 			}
-			else if(!(ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode & ALARM_METER_TIMEOUT))
+			else
 			{
 				if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.MeterCommTimeout == ON)
 				{
@@ -1028,6 +1027,50 @@ int main(void)
 				}
 			}
 
+			//=====================================
+			// Meter ic communication timeout detection
+			//=====================================
+			if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.meter_ic_comm_timeout == ON)
+			{
+				if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.MeterIcCommTimeout == OFF)
+				{
+					ShmStatusCodeData->AlarmCode.AlarmEvents.bits.MeterIcCommTimeout = ON;
+					ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode |= ALARM_METER_IC_TIMEOUT;
+					DEBUG_INFO("ALARM_METER_IC_TIMEOUT : alarm \n");
+				}
+			}
+			else
+			{
+				if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.MeterIcCommTimeout == ON)
+				{
+					ShmStatusCodeData->AlarmCode.AlarmEvents.bits.MeterIcCommTimeout = OFF;
+					ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_METER_IC_TIMEOUT;
+					DEBUG_INFO("ALARM_METER_IC_TIMEOUT : recover \n");
+				}
+			}
+
+			//=====================================
+			// Pilot negative error detection
+			//=====================================
+			if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.pilot_negative_error == ON)
+			{
+				if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PilotNegativeError == OFF)
+				{
+					ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PilotNegativeError = ON;
+					ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode |= ALARM_CP_NEG_ERROR;
+					DEBUG_INFO("ALARM_PILOT_NEGATIVE_ERROR : alarm \n");
+				}
+			}
+			else
+			{
+				if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PilotNegativeError == ON)
+				{
+					ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PilotNegativeError = OFF;
+					ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_CP_NEG_ERROR;
+					DEBUG_INFO("ALARM_PILOT_NEGATIVE_ERROR : recover \n");
+				}
+			}
+
 			//=====================================
 			// OCPP error code message
 			//=====================================
@@ -1185,6 +1228,18 @@ int main(void)
 					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "012305");
 					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].Info , "MeterCommunicationTimeout");
 				}
+				else if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_METER_IC_TIMEOUT)
+				{
+					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].ErrorCode , "OtherError");
+					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "012344");
+					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].Info , "MeterIcCommunicationTimeout");
+				}
+				else if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_CP_NEG_ERROR)
+				{
+					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].ErrorCode , "OtherError");
+					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "012345");
+					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].Info , "PilotNegativeError");
+				}
 				else
 				{
 					sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].ErrorCode , "NoError");
@@ -1882,6 +1937,54 @@ int main(void)
 						previousAlarmCode[gun_index] &= ~ALARM_METER_TIMEOUT;
 				}
 
+				if((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_METER_IC_TIMEOUT) != (previousAlarmCode[gun_index] & ALARM_METER_IC_TIMEOUT))
+				{
+					getNowDatetime(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].timestamp);
+					ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventId = idxEvent;
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].trigger, "Alerting");
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].actualValue, ((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_METER_IC_TIMEOUT)?"true":"false"));
+					ShmOCPP20Data->NotifyEvent.eventData[idxEvent].cleared = ((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_METER_IC_TIMEOUT)?OFF:ON);
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventNotificationType, "HardWiredNotification");
+					
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techcode, "012344");
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techInfo, "Meter ic communication timeout");
+					
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.name, "Meter");
+					ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.evse.connectorId = (gun_index+1);
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variable.name, "Problem");
+					
+					idxEvent += ((idxEvent<ARRAY_SIZE(ShmOCPP20Data->NotifyEvent.eventData)-1)?1:0);
+					
+					if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_METER_IC_TIMEOUT)
+						previousAlarmCode[gun_index] |= ALARM_METER_IC_TIMEOUT;
+					else
+						previousAlarmCode[gun_index] &= ~ALARM_METER_IC_TIMEOUT;
+				}
+
+				if((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_CP_NEG_ERROR) != (previousAlarmCode[gun_index] & ALARM_CP_NEG_ERROR))
+				{
+					getNowDatetime(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].timestamp);
+					ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventId = idxEvent;
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].trigger, "Alerting");
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].actualValue, ((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_CP_NEG_ERROR)?"true":"false"));
+					ShmOCPP20Data->NotifyEvent.eventData[idxEvent].cleared = ((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_CP_NEG_ERROR)?OFF:ON);
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventNotificationType, "HardWiredNotification");
+					
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techcode, "012345");
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techInfo, "Pilot negative error");
+					
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.name, "PCBA");
+					ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.evse.connectorId = (gun_index+1);
+					sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variable.name, "Problem");
+					
+					idxEvent += ((idxEvent<ARRAY_SIZE(ShmOCPP20Data->NotifyEvent.eventData)-1)?1:0);
+					
+					if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_CP_NEG_ERROR)
+						previousAlarmCode[gun_index] |= ALARM_CP_NEG_ERROR;
+					else
+						previousAlarmCode[gun_index] &= ~ALARM_CP_NEG_ERROR;
+				}
+
 				if(idxEvent > 0)
 					ShmOCPP20Data->SpMsg.bits.NotifyEventReq = ON;
 			}

+ 7 - 7
EVSE/Projects/AW-CCS/Apps/Module_ConfigTools.c

@@ -801,18 +801,18 @@ int main(void)
 
 				if((0 < atoi(cmd)) && (atoi(cmd) < 3))
 				{
-					ShmSysConfigAndInfo->SysInfo.AcChargingData[atoi(cmd)-1].schedule.isTriggerStart = ON;
 					DEBUG_INFO("Alarm simulate gun-%d, OVP.\n", atoi(cmd));
+
+					while(1)
+					{
+						ShmCharger->gun_info[atoi(cmd)-1].systemAlarmCode.SystemAlarmCode |= ALARM_L1_OVER_VOLTAGE;
+						ShmCharger->gun_info[atoi(cmd)-1].primaryMcuAlarm.InputAlarmCode |= ALARM_L1_OVER_VOLTAGE;
+					}
 				}
 				else
 				{
 					printf("\n  Invalid input gun_index.");
-				}
-
-				while(1)
-				{
-					ShmCharger->gun_info[atoi(cmd)-1].systemAlarmCode.SystemAlarmCode |= ALARM_L1_OVER_VOLTAGE;
-					ShmCharger->gun_info[atoi(cmd)-1].primaryMcuAlarm.InputAlarmCode |= ALARM_L1_OVER_VOLTAGE;
+					sleep(1);
 				}
 			}
 			else if(strcmp(cmd, "cancel") == 0)

+ 2 - 165
EVSE/Projects/AW-CCS/Apps/Module_InternalComm.c

@@ -847,6 +847,7 @@ unsigned char Query_AC_MCU_Alarm(unsigned char fd, unsigned char targetAddr, Ac_
 			}
 			Ret_Buf->bits.meter_comm_timeout = (((rx[9]>>4)&0x01)?1:0);
 			Ret_Buf->bits.meter_ic_comm_timeout = (((rx[9]>>5)&0x01)?1:0);
+			Ret_Buf->bits.pilot_negative_error = (((rx[9]>>6)&0x01)?1:0);
 
 			result = PASS;
 		}
@@ -2074,172 +2075,7 @@ int main(void)
 				{
 					//DEBUG_INFO("MCU-%d get alarm code success.\n",gun_index);
 
-					//================================================
-					// Byte[6]
-					// Byte[7]
-					// Byte[8] bits 3 Reserved
-					// Byte[9] bits 6 & 7 Reserved
-					//================================================
-
-					//================================================
-					// Byte[6]
-					//================================================
-					if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.OVP_L1 == 0x01)
-						ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode |= 1<<0;
-					else
-						ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode &= ~(1<<0);
-
-					if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.UVP_L1 == 0x01)
-						ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode |= 1<<1;
-					else
-						ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode &= ~(1<<1);
-
-					if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.OCP_L1 == 0x01)
-						ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode |= 1<<2;
-					else
-						ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode &= ~(1<<2);
-
-					if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.OTP == 0x01)
-						ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode |= 1<<3;
-					else
-						ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode &= ~(1<<3);
-
-					if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.gmi_fault == 0x01)
-						ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode |= 1<<4;
-					else
-						ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode &= ~(1<<4);
-
-					if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.cp_fault == 0x01)
-						ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode |= 1<<5;
-					else
-						ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode &= ~(1<<5);
-
-					if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.ac_leak == 0x01)
-						ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode |= 1<<6;
-					else
-						ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode &= ~(1<<6);
-
-					if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.dc_leak == 0x01)
-						ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode |= 1<<7;
-					else
-						ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode &= ~(1<<7);
-
-					//================================================
-					// Byte[7]
-					//================================================
-					if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.mcu_selftest_fail == 0x01)
-						ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode |= 1<<8;
-					else
-						ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode &= ~(1<<8);
-
-					if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.handshaking_timeout == 0x01)
-						ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode |= 1<<9;
-					else
-						ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode &= ~(1<<9);
-
-					if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.emergency_stop == 0x01)
-						ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode |= 1<<10;
-					else
-						ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode &= ~(1<<10);
-
-					if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.relay_welding == 0x01)
-						ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode |= 1<<11;
-					else
-						ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode &= ~(1<<11);
-
-					if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.leak_module_fail == 0x01)
-						ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode |= 1<<12;
-					else
-						ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode &= ~(1<<12);
-
-					if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.shutter_fault == 0x01)
-						ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode |= 1<<13;
-					else
-						ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode &= ~(1<<13);
-
-					if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.locker_fault == 0x01)
-						ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode |= 1<<14;
-					else
-						ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode &= ~(1<<14);
-
-					if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.power_drop == 0x01)
-						ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode |= 1<<15;
-					else
-						ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode &= ~(1<<15);
-
-					//================================================
-					// Byte[8]
-					//================================================
-					if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.short_circuit_L1 == 0x01)
-						ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode |= 1<<16;
-					else
-						ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode &= ~(1<<16);
-
-					if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.rotate_switch_fault == 0x01)
-						ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode |= 1<<17;
-					else
-						ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode &= ~(1<<17);
-
-					if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.relay_drive_fault == 0x01)
-						ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode |= 1<<18;
-					else
-						ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode &= ~(1<<18);
-					
-					if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.OVP_L2 == 0x01)
-						ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode |= 1<<20;
-					else
-						ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode &= ~(1<<20);
-
-					if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.OVP_L3 == 0x01)
-						ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode |= 1<<21;
-					else
-						ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode &= ~(1<<21);
-
-					if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.UVP_L2 == 0x01)
-						ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode |= 1<<22;
-					else
-						ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode &= ~(1<<22);
-
-					if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.UVP_L3 == 0x01)
-						ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode |= 1<<23;
-					else
-						ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode &= ~(1<<23);					
-
-					//================================================
-					// Byte[9] 
-					//================================================
-					if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.OCP_L2 == 0x01)
-						ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode |= 1<<24;
-					else
-						ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode &= ~(1<<24);
-
-					if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.OCP_L3 == 0x01)
-						ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode |= 1<<25;
-					else
-						ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode &= ~(1<<25);			
-
-					if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.short_circuit_L2 == 0x01)
-						ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode |= 1<<26;
-					else
-						ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode &= ~(1<<26);
-
-					if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.short_circuit_L3 == 0x01)
-						ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode |= 1<<27;
-					else
-						ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode &= ~(1<<27);
-
-					if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.meter_comm_timeout == 0x01)
-						ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode |= 1<<28;
-					else
-						ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode &= ~(1<<28);
-
-					if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.meter_ic_comm_timeout == 0x01)
-						ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode |= 1<<29;
-					else
-						ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode &= ~(1<<29);
-
 					failCount[gun_index] = 0;
-					
 					ShmCharger->gun_info[gun_index].acCcsInfo.CSUAlarmStatusCode = ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode;
 				}
 				else
@@ -2508,6 +2344,7 @@ int main(void)
 							DEBUG_INFO("MCU-%d get relay_drive_fault : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.relay_drive_fault);
 							DEBUG_INFO("MCU-%d get meter_comm_timeout : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.meter_comm_timeout);
 							DEBUG_INFO("MCU-%d get meter_ic_comm_timeout : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.meter_ic_comm_timeout);
+							DEBUG_INFO("MCU-%d get pilot_negative_error : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.pilot_negative_error);
 							DEBUG_INFO("MCU-%d get InputAlarmCode : %x\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode);
 						}
 

+ 18 - 6
EVSE/Projects/AW-CCS/Apps/Module_PowerSharing.c

@@ -555,7 +555,7 @@ int tcpSocketServerStart(void)
 							switch(idxStep)
 							{
 								case 0:
-									if(difftime(time((time_t*)NULL), conn_getStatusStarttime(dupFd)) >= 3)
+									if((difftime(time((time_t*)NULL), conn_getStatusStarttime(dupFd)) >= 3) || (difftime(time((time_t*)NULL), conn_getStatusStarttime(dupFd)) < 0))
 									{
 										create_cmd_getStatus(&output);
 										conn_getStatusStarttimeUpdate(dupFd);
@@ -565,7 +565,7 @@ int tcpSocketServerStart(void)
 									idxStep++;
 									break;
 								default:
-									if((difftime(time((time_t*)NULL), conn_setCapacityStarttime(dupFd)) >= 1))
+									if((difftime(time((time_t*)NULL), conn_setCapacityStarttime(dupFd)) >= 1) || (difftime(time((time_t*)NULL), conn_setCapacityStarttime(dupFd)) < 0))
 									{
 										create_cmd_SetAvailableCurrent(&output, dupFd);
 										conn_setCapacityStarttimeUpdate(dupFd);
@@ -616,6 +616,7 @@ int tcpSocketClientStart(void)
 	struct hostent 		*ghbn;
 	struct timeval 		tv;
 	uint8_t 			socketEnable;
+	uint8_t				cntSocketErr;
 
 	struct Message		input;
 	struct Message		output;
@@ -648,6 +649,7 @@ int tcpSocketClientStart(void)
 		tv.tv_usec = 500000;
 		setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO, (const char*)&tv, sizeof tv);
 		socketEnable = ON;
+		cntSocketErr = 0;
 		ShmSysConfigAndInfo->SysInfo.localSharingInfo.isConnectedSharingServer = ON;
 	}
 
@@ -722,7 +724,17 @@ int tcpSocketClientStart(void)
 			ShmSysConfigAndInfo->SysInfo.localSharingInfo.isConnectedSharingServer = OFF;
 		}
 		else if(input.size == -1)
-		{}
+		{
+			if(cntSocketErr > 5)
+			{
+				socketEnable = OFF;
+				DEBUG_ERROR("Socket error occur\n");
+			}
+			else
+			{
+				cntSocketErr++;
+			}
+		}
 		usleep(1000000);
 	}
 	close(sockfd);
@@ -741,9 +753,9 @@ int balance_check_loop(void)
 		for(uint8_t idx=0;idx<CONNECTION_LIMIT;idx++)
 		{
 			if(ShmPowerSharing->Connection_Info[idx].isSocketConnected &&
-			   (difftime(time((time_t*)NULL), ShmPowerSharing->Connection_Info[idx].lastHeartBeatTime) > 300))
+			   ((difftime(time((time_t*)NULL), ShmPowerSharing->Connection_Info[idx].lastHeartBeatTime) > TIMEOUT_SPEC_HEARTBEAT) || (difftime(time((time_t*)NULL), ShmPowerSharing->Connection_Info[idx].lastHeartBeatTime) < 0)))
 			{
-				DEBUG_INFO("SocketFd-%d heart beat is over 300 seconds.\n", ShmPowerSharing->Connection_Info[idx].socketFd);
+				DEBUG_INFO("SocketFd-%d heart beat is over %d seconds.\n", ShmPowerSharing->Connection_Info[idx].socketFd, TIMEOUT_SPEC_HEARTBEAT);
 				ShmPowerSharing->Connection_Info[idx].isGunConnected = FALSE;
 				ShmPowerSharing->Connection_Info[idx].isSocketConnected = FALSE;
 			}
@@ -775,7 +787,7 @@ int balance_check_loop(void)
 			if(ShmPowerSharing->Connection_Info[idx].isSocketConnected &&
 			   ShmPowerSharing->Connection_Info[idx].isGunConnected)
 			{
-				if((difftime(time((time_t*)NULL), ShmPowerSharing->Connection_Info[idx].lastCheckCapacityTime) > 10))
+				if((difftime(time((time_t*)NULL), ShmPowerSharing->Connection_Info[idx].lastCheckCapacityTime) > TIMEOUT_SPEC_CHECK_CAPACITY) || (difftime(time((time_t*)NULL), ShmPowerSharing->Connection_Info[idx].lastCheckCapacityTime) < 0))
 				{
 					if(ShmPowerSharing->Connection_Info[idx].availableSharingCurrent >= (ShmPowerSharing->Connection_Info[idx].presentOutputCurrent+2))
 					{

+ 2 - 0
EVSE/Projects/AW-CCS/Apps/Module_PowerSharing.h

@@ -59,6 +59,8 @@
 
 #define LISTEN_PORT_TCP				118
 #define	CONNECTION_LIMIT			5
+#define TIMEOUT_SPEC_HEARTBEAT		180
+#define TIMEOUT_SPEC_CHECK_CAPACITY	10
 
 #define ShmPowerShargingKey			LISTEN_PORT_TCP+8000
 

+ 43 - 8
EVSE/Projects/AW-CCS/Apps/main.c

@@ -33,7 +33,7 @@
 #define TIMEOUT_SPEC_POWERSAVING_RFID			120000
 #define TIMEOUT_SPEC_POWERSAVING_METER			120000
 #define TIMEOUT_SPEC_POWERSAVING_LED_STATUS		120000
-#define TIMEOUT_SPEC_CEHCK_POWER_CONSUMPTION	10000
+#define TIMEOUT_SPEC_CEHCK_POWER_CONSUMPTION	15000
 
 //==========================
 // GPIO constant define
@@ -2984,7 +2984,6 @@ int upgrade_check()
 
 					ShmCharger->fwUpgradeInfo.fwType = ((ptr[0x13]<<0) | (ptr[0x12]<<8) | (ptr[0x11]<<16) | (ptr[0x10]<<24));
 					substr(ShmCharger->fwUpgradeInfo.modelName, (char *)ptr, 0, 0x10);
-					free(ptr);
 					DEBUG_INFO("New firmware type: %X\n", ShmCharger->fwUpgradeInfo.fwType);
 					DEBUG_INFO("New firmware model name: %s, %s\n", ShmCharger->fwUpgradeInfo.modelName, ShmSysConfigAndInfo->SysConfig.ModelName);
 
@@ -3093,6 +3092,7 @@ int upgrade_check()
 						sprintf(cmd, "yes|rm %s", ShmCharger->fwUpgradeInfo.location);
 						system(cmd);
 					}
+					free(ptr);
 				}
 				else
 				{
@@ -4800,7 +4800,8 @@ int main(void)
 			   (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus == SYS_MODE_UPDATE) ||
 			   (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus == SYS_MODE_MAINTAIN) ||
 			   (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus == SYS_MODE_CHARGING) ||
-			   (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus == SYS_MODE_TERMINATING))
+			   (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus == SYS_MODE_TERMINATING) || 
+			   (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus == SYS_MODE_COMPLETE))
 			{
 				ftime(&startTime[gun_index][TMR_IDX_POWERSAVING_LCD]);
 				ftime(&startTime[gun_index][TMR_IDX_POWERSAVING_RFID]);
@@ -4826,12 +4827,16 @@ int main(void)
 					   (DiffTimebWithNow(startTime[ShmCharger->gun_selectd][TMR_IDX_CHECK_POWER_CONSUMPTION]) > TIMEOUT_SPEC_CEHCK_POWER_CONSUMPTION))
 					{
 						ShmCharger->gun_info[gun_index].isCheckPowerConsumption = YES;
+						ftime(&startTime[gun_index][TMR_IDX_LCM_POWER_CONSUMPTION]);
 					}
 				}
 				else
 				{
 					ftime(&startTime[gun_index][TMR_IDX_CHECK_POWER_CONSUMPTION]);
-					ShmCharger->gun_info[gun_index].isCheckPowerConsumption = NO;
+					if((DiffTimebWithNow(startTime[ShmCharger->gun_selectd][TMR_IDX_LCM_POWER_CONSUMPTION]) > TIMEOUT_SPEC_CEHCK_POWER_CONSUMPTION))
+					{
+						ShmCharger->gun_info[gun_index].isCheckPowerConsumption = NO;
+					}
 				}
 			}
 
@@ -5009,6 +5014,7 @@ int main(void)
 						ftime(&startTime[gun_index][TMR_IDX_POWERSAVING_METER]);
 						ftime(&startTime[gun_index][TMR_IDX_POWERSAVING_STATE_B]);
 						ftime(&startTime[gun_index][TMR_IDX_POWERSAVING_LED_STATUS]);
+						ftime(&startTime[gun_index][TMR_IDX_LCM_POWER_CONSUMPTION]);
 					}
 
 					if(ShmCharger->gun_info[gun_index].mcuFlag.isReadFwVerPass &&
@@ -5300,8 +5306,18 @@ int main(void)
 											DEBUG_INFO("Authorize pass.\n");
 											setSpeaker(ON,SPEAKER_SHORT);
 											setLedMotion(gun_index,LED_ACTION_RFID_PASS);
-											sleep(3);
-											if(ShmCharger->isCcsEnable)system("/root/Module_CCS &");
+											if(ShmCharger->isCcsEnable)
+											{
+												ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty.max_current = CCS_PWM_DUTY_CP_STATE_F;
+												ShmCharger->gun_info[gun_index].mcuFlag.isSetCpPwmDuty = ON;
+												sleep(4);
+												ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty.max_current = CCS_PWM_DUTY_100;
+												ShmCharger->gun_info[gun_index].mcuFlag.isSetCpPwmDuty = ON;
+												system("/root/Module_CCS &");
+											}
+											else
+												sleep(4);
+
 											setChargerMode(gun_index, SYS_MODE_PREPARING);
 										}
 										else
@@ -5318,7 +5334,16 @@ int main(void)
 								}
 								else
 								{
-									if(ShmCharger->isCcsEnable)system("/root/Module_CCS &");
+									if(ShmCharger->isCcsEnable)
+									{
+										ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty.max_current = CCS_PWM_DUTY_CP_STATE_F;
+										ShmCharger->gun_info[gun_index].mcuFlag.isSetCpPwmDuty = ON;
+										sleep(4);
+										ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty.max_current = CCS_PWM_DUTY_100;
+										ShmCharger->gun_info[gun_index].mcuFlag.isSetCpPwmDuty = ON;
+										system("/root/Module_CCS &");
+									}
+
 									setChargerMode(gun_index, SYS_MODE_PREPARING);
 								}
 								break;
@@ -5326,7 +5351,15 @@ int main(void)
 							case START_METHOD_BLE:
 							case START_METHOD_FREE:
 							default:
-								if(ShmCharger->isCcsEnable)system("/root/Module_CCS &");
+								if(ShmCharger->isCcsEnable)
+								{
+									ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty.max_current = CCS_PWM_DUTY_CP_STATE_F;
+									ShmCharger->gun_info[gun_index].mcuFlag.isSetCpPwmDuty = ON;
+									sleep(4);
+									ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty.max_current = CCS_PWM_DUTY_100;
+									ShmCharger->gun_info[gun_index].mcuFlag.isSetCpPwmDuty = ON;
+									system("/root/Module_CCS &");
+								}
 								setChargerMode(gun_index, SYS_MODE_PREPARING);
 								break;
 						}
@@ -5341,7 +5374,9 @@ int main(void)
 						ShmCharger->gun_info[gun_index].resultAuthorization = DEFAULT_RFID;												 
 
 						if(ShmCharger->isCcsEnable)
+						{
 							ShmCharger->gun_info[gun_index].ccsHandshakeState = HANDSHAKE_DUTY_5;
+						}
 						else
 						{
 							ShmCharger->gun_info[gun_index].ccsHandshakeState = HANDSHAKE_CP_STATE_E;

+ 3 - 1
EVSE/Projects/AW-CCS/Apps/main.h

@@ -77,6 +77,7 @@
 #define ALARM_L3_CIRCUIT_SHORT                  0x08000000
 #define ALARM_METER_TIMEOUT						0x10000000
 #define ALARM_METER_IC_TIMEOUT					0x20000000
+#define ALARM_CP_NEG_ERROR 						0x40000000
 
 //=================================
 //CCS related define
@@ -230,7 +231,7 @@ enum TIMER_IDX
 	TMR_IDX_CHECK_TASK,
 	TMR_IDX_POWERSAVING_LED_STATUS,
 	TMR_IDX_CHECK_POWER_CONSUMPTION,
-	TMR_IDX_14,
+	TMR_IDX_LCM_POWER_CONSUMPTION,
 	TMR_IDX_15,
 	TMR_IDX_16,
 	TMR_IDX_17,
@@ -426,6 +427,7 @@ typedef struct AC_PRIMARY_MCU_ALARM
 			unsigned long short_circuit_L3:1;
 			unsigned long meter_comm_timeout:1;
 			unsigned long meter_ic_comm_timeout:1;
+			unsigned long pilot_negative_error:1;
 		}bits;
 	};
 }Ac_Primary_Mcu_Alarm;

二进制
EVSE/Projects/AW-CCS/Images/FactoryDefaultConfig.bin


二进制
EVSE/Projects/AW-CCS/Images/ramdisk.gz


+ 8 - 56
EVSE/Projects/AW-Regular/Apps/Module_ConfigTools.c

@@ -698,7 +698,6 @@ int main(void)
 			printf("\n  start: EVSE start charging request.");
 			printf("\n  stop: EVSE stop charging request.");
 			printf("\n  auth: Authorize request.");
-			printf("\n  ccs: CCS flow status.");
 			printf("\n  alarm: Simulate alarm status.");
 			printf("\n  cancel: return to main menu.");
 			printf("\n **************************************************");
@@ -747,52 +746,6 @@ int main(void)
 				ShmOCPP16Data->SpMsg.bits.AuthorizeReq = ON;
 				DEBUG_INFO("Test authentication by %s.\n", ShmSysConfigAndInfo->SysConfig.UserId);
 			}
-			else if(strcmp(cmd, "ccs") == 0)
-			{
-				memset(cmd, 0x00, ARRAY_SIZE(cmd));
-				printf("\n  Please input gun index(1~2): ");
-				scanf("%s", &cmd[0]);
-
-				if((0 < atoi(cmd)) && (atoi(cmd) < 3))
-				{
-					uint8_t gun_index = atoi(cmd)-1;
-					memset(cmd, 0x00, ARRAY_SIZE(cmd));
-					printf("\n ***** ccs ****************************************");
-					printf("\n  ccs_hs_status: CCS hand shake status.");
-					printf("\n  cancel: return to main menu.");
-					printf("\n **************************************************");
-					printf("\n  Please input operation item: ");
-					scanf("%s", &cmd[0]);
-
-					if(strcmp(cmd, "ccs_hs_status") == 0)
-					{
-						printf("\n ***** ccs_hs_status *******************************");
-						printf("\n  Current ccs_hs_status: %d", ShmCharger->gun_info[gun_index].ccsHandshakeState);
-						printf("\n  1: HANDSHAKE_DUTY_5.");
-						printf("\n  2: HANDSHAKE_DUTY_5_CHECK.");
-						printf("\n  3: HANDSHAKE_CCS.");
-						printf("\n  4: HANDSHAKE_CP_STATE_E.");
-						printf("\n  5: HANDSHAKE_SET_MAX_CURRENT.");
-						printf("\n  6: HANDSHAKE_BS_MODE.");
-						printf("\n  7: HANDSHAKE_HLC_MODE.");
-						printf("\n **************************************************");
-						printf("\n  Please input operation item: ");
-						scanf("%s", &cmd[0]);
-
-						if((0 < atoi(cmd)) && (atoi(cmd) < 9))
-						{
-							ShmCharger->gun_info[gun_index].ccsHandshakeState = atoi(cmd);
-							DEBUG_INFO("Gun-%d CCS hand shake state: %d.\n", gun_index, ShmCharger->gun_info[gun_index].ccsHandshakeState);
-						}
-						else
-							printf("\n  Invalid hand shake state.");
-					}
-				}
-				else
-				{
-					printf("\n  Invalid input gun_index.");
-				}
-			}
 			else if(strcmp(cmd, "alarm") == 0)
 			{
 				memset(cmd, 0x00, ARRAY_SIZE(cmd));
@@ -800,20 +753,19 @@ int main(void)
 				scanf("%s", &cmd[0]);
 
 				if((0 < atoi(cmd)) && (atoi(cmd) < 3))
-				{
-					ShmSysConfigAndInfo->SysInfo.AcChargingData[atoi(cmd)-1].schedule.isTriggerStart = ON;
+				{					
 					DEBUG_INFO("Alarm simulate gun-%d, OVP.\n", atoi(cmd));
+					while(1)
+					{
+						ShmCharger->gun_info[atoi(cmd)-1].systemAlarmCode.SystemAlarmCode |= ALARM_OVER_VOLTAGE;
+						ShmCharger->gun_info[atoi(cmd)-1].primaryMcuAlarm.InputAlarmCode |= ALARM_OVER_VOLTAGE;
+					}
 				}
 				else
 				{
 					printf("\n  Invalid input gun_index.");
-				}
-
-				while(1)
-				{
-					ShmCharger->gun_info[atoi(cmd)-1].systemAlarmCode.SystemAlarmCode |= ALARM_L1_OVER_VOLTAGE;
-					ShmCharger->gun_info[atoi(cmd)-1].primaryMcuAlarm.InputAlarmCode |= ALARM_L1_OVER_VOLTAGE;
-				}
+					sleep(1);
+				}				
 			}
 			else if(strcmp(cmd, "cancel") == 0)
 			{}

+ 12 - 0
EVSE/Projects/DD360/Apps/CSU/Primary.c

@@ -136,11 +136,15 @@ void PrimaryLedIndicatorCtrlFork(void)
 
                 case S_CHARGING:
                     pLedConfig->RedLED = NO;
+#ifdef DD360ComBox
                     if (pLedConfig->YellowLED == YES) {
                         pLedConfig->YellowLED = NO;
                     } else {
                         pLedConfig->YellowLED = YES;
                     }
+#else
+                        pLedConfig->YellowLED = YES;
+#endif
                     pLedConfig->GreenLED = NO;
                     break;
 
@@ -166,7 +170,15 @@ void PrimaryLedIndicatorCtrlFork(void)
                     //    pLedConfig->RedLED = YES;
                     //} else {
                     pLedConfig->RedLED = NO;
+#ifdef DD360ComBox
                     pLedConfig->YellowLED = YES;
+#else
+                    if (pLedConfig->YellowLED == YES) {
+                        pLedConfig->YellowLED = NO;
+                    } else {
+                        pLedConfig->YellowLED = YES;
+                    }
+#endif
                     pLedConfig->GreenLED = NO;
                     //}
                     break;

+ 11 - 4
EVSE/Projects/DD360/Apps/ModulePrimary/Module_PrimaryComm.c

@@ -185,9 +185,8 @@ void GetInputGpioStatus(int fd)
     }
 
     ShmPrimaryMcuData->InputDet.bits.SpdDetec = gpio_in.SPD;
-
 #if defined DD360ComBox
-    if (~gpio_in.Emergency_Btn)
+    if (gpio_in.Emergency_Btn == 0 && (EmgBtn_flag == gpio_in.Emergency_Btn))
 #else
     if (gpio_in.Emergency_Btn && (EmgBtn_flag != gpio_in.Emergency_Btn))
 #endif //defined DD360ComBox
@@ -197,7 +196,11 @@ void GetInputGpioStatus(int fd)
            EmgBtn_flag = 1;
            EmgBtn_count = 0; // Avoid Overflow
        }
-    } else if (EmgBtn_flag != gpio_in.Emergency_Btn) {
+#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;
@@ -239,7 +242,7 @@ void GetInputGpioStatus(int fd)
     }
 
 #if defined DD360ComBox
-    if (gpio_in.Door_Open)
+    if (gpio_in.Door_Open && (Door_flag != gpio_in.Door_Open))
 #else
     if (gpio_in.Door_Open == 0 && (Door_flag == gpio_in.Door_Open))
 #endif //defined DD360ComBox
@@ -249,7 +252,11 @@ void GetInputGpioStatus(int fd)
             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;

+ 12 - 0
EVSE/Projects/DD360Audi/Apps/CSU/Primary.c

@@ -136,11 +136,15 @@ void PrimaryLedIndicatorCtrlFork(void)
 
                 case S_CHARGING:
                     pLedConfig->RedLED = NO;
+#ifdef DD360ComBox
                     if (pLedConfig->YellowLED == YES) {
                         pLedConfig->YellowLED = NO;
                     } else {
                         pLedConfig->YellowLED = YES;
                     }
+#else
+                        pLedConfig->YellowLED = YES;
+#endif
                     pLedConfig->GreenLED = NO;
                     break;
 
@@ -166,7 +170,15 @@ void PrimaryLedIndicatorCtrlFork(void)
                     //    pLedConfig->RedLED = YES;
                     //} else {
                     pLedConfig->RedLED = NO;
+#ifdef DD360ComBox
                     pLedConfig->YellowLED = YES;
+#else
+                    if (pLedConfig->YellowLED == YES) {
+                        pLedConfig->YellowLED = NO;
+                    } else {
+                        pLedConfig->YellowLED = YES;
+                    }
+#endif
                     pLedConfig->GreenLED = NO;
                     //}
                     break;

+ 11 - 4
EVSE/Projects/DD360Audi/Apps/ModulePrimary/Module_PrimaryComm.c

@@ -185,9 +185,8 @@ void GetInputGpioStatus(int fd)
     }
 
     ShmPrimaryMcuData->InputDet.bits.SpdDetec = gpio_in.SPD;
-
 #if defined DD360ComBox
-    if (~gpio_in.Emergency_Btn)
+    if (gpio_in.Emergency_Btn == 0 && (EmgBtn_flag == gpio_in.Emergency_Btn))
 #else
     if (gpio_in.Emergency_Btn && (EmgBtn_flag != gpio_in.Emergency_Btn))
 #endif //defined DD360ComBox
@@ -197,7 +196,11 @@ void GetInputGpioStatus(int fd)
            EmgBtn_flag = 1;
            EmgBtn_count = 0; // Avoid Overflow
        }
-    } else if (EmgBtn_flag != gpio_in.Emergency_Btn) {
+#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;
@@ -239,7 +242,7 @@ void GetInputGpioStatus(int fd)
     }
 
 #if defined DD360ComBox
-    if (gpio_in.Door_Open)
+    if (gpio_in.Door_Open && (Door_flag != gpio_in.Door_Open))
 #else
     if (gpio_in.Door_Open == 0 && (Door_flag == gpio_in.Door_Open))
 #endif //defined DD360ComBox
@@ -249,7 +252,11 @@ void GetInputGpioStatus(int fd)
             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;

+ 12 - 6
EVSE/Projects/DD360ComBox/Apps/CSU/Primary.c

@@ -136,11 +136,15 @@ void PrimaryLedIndicatorCtrlFork(void)
 
                 case S_CHARGING:
                     pLedConfig->RedLED = NO;
-                    //if (pLedConfig->YellowLED == YES) {
-                    //    pLedConfig->YellowLED = NO;
-                    //} else {
+#ifdef DD360ComBox
+                    if (pLedConfig->YellowLED == YES) {
+                        pLedConfig->YellowLED = NO;
+                    } else {
                         pLedConfig->YellowLED = YES;
-                    //}
+                    }
+#else
+                        pLedConfig->YellowLED = YES;
+#endif
                     pLedConfig->GreenLED = NO;
                     break;
 
@@ -166,13 +170,15 @@ void PrimaryLedIndicatorCtrlFork(void)
                     //    pLedConfig->RedLED = YES;
                     //} else {
                     pLedConfig->RedLED = NO;
-                    //pLedConfig->YellowLED = YES;
+#ifdef DD360ComBox
+                    pLedConfig->YellowLED = YES;
+#else
                     if (pLedConfig->YellowLED == YES) {
                         pLedConfig->YellowLED = NO;
                     } else {
                         pLedConfig->YellowLED = YES;
                     }
-
+#endif
                     pLedConfig->GreenLED = NO;
                     //}
                     break;

+ 11 - 4
EVSE/Projects/DD360ComBox/Apps/ModulePrimary/Module_PrimaryComm.c

@@ -185,9 +185,8 @@ void GetInputGpioStatus(int fd)
     }
 
     ShmPrimaryMcuData->InputDet.bits.SpdDetec = gpio_in.SPD;
-
 #if defined DD360ComBox
-    if (~gpio_in.Emergency_Btn)
+    if (gpio_in.Emergency_Btn == 0 && (EmgBtn_flag == gpio_in.Emergency_Btn))
 #else
     if (gpio_in.Emergency_Btn && (EmgBtn_flag != gpio_in.Emergency_Btn))
 #endif //defined DD360ComBox
@@ -197,7 +196,11 @@ void GetInputGpioStatus(int fd)
            EmgBtn_flag = 1;
            EmgBtn_count = 0; // Avoid Overflow
        }
-    } else if (EmgBtn_flag != gpio_in.Emergency_Btn) {
+#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;
@@ -239,7 +242,7 @@ void GetInputGpioStatus(int fd)
     }
 
 #if defined DD360ComBox
-    if (gpio_in.Door_Open)
+    if (gpio_in.Door_Open && (Door_flag != gpio_in.Door_Open))
 #else
     if (gpio_in.Door_Open == 0 && (Door_flag == gpio_in.Door_Open))
 #endif //defined DD360ComBox
@@ -249,7 +252,11 @@ void GetInputGpioStatus(int fd)
             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;

+ 44 - 2
EVSE/Projects/define.h

@@ -170,7 +170,7 @@ Storage							0x0A200000-0x7FFFFFFF		1886 MB
 #define ShmRelay2BdKey			1013
 
 #define FaultCodeLength         5
-#define AlarmCodeLength         16
+#define AlarmCodeLength         20
 #define InfoCodeLength          41
 
 /**************************************************************************************/
@@ -1146,7 +1146,7 @@ struct FaultCodeData
 	}FaultEvents;
 };
 
-char AlarmStatusCode[128][6]=
+char AlarmStatusCode[160][6]=
 {
 	"012200",	//System L1 input OVP
 	"012201",	//System L2 input OVP
@@ -1276,6 +1276,38 @@ char AlarmStatusCode[128][6]=
     "012325",   // Connector 2 detects abnormal voltage on the output line
     "012326",   // System task is lost
     "012327",   // reserved
+	"012328",   // reserved
+    "012329",   // reserved
+    "012330",   // reserved
+    "012331",   // reserved
+    "012332",   // reserved
+    "012333",   // reserved
+    "012334",   // reserved
+    "012335",   // reserved
+    "012336",   // reserved
+    "012337",   // reserved
+    "012338",   // reserved
+    "012339",   // reserved
+    "012340",   // reserved
+    "012341",   // reserved
+    "012342",   // reserved
+    "012343",   // reserved
+    "012344",   // AC: Meter IC communication timeout
+    "012345",   // AC: Pilot negative error
+    "012346",   // reserved
+    "012347",   // reserved
+    "012348",   // reserved
+    "012349",   // reserved
+    "012350",   // reserved
+	"012351",   // reserved
+    "012352",   // reserved
+    "012353",   // reserved
+    "012354",   // reserved
+    "012355",   // reserved
+    "012356",   // reserved
+    "012357",   // reserved
+    "012358",   // reserved
+    "012359",   // reserved
 };
 struct AlarmCodeData
 {
@@ -1429,6 +1461,16 @@ struct AlarmCodeData
             unsigned char AbnormalVoltageOnOutputLine_2:1;          //bit 5
             unsigned char SystemTaskLost:1;                         //bit 6
             unsigned char Reserved:1;                               //bit 7
+			//AlarmVal[16]
+            unsigned char :8;										//reserved bit 0 ~ bit 7
+            //AlarmVal[17]
+            unsigned char :8;										//reserved bit 0 ~ bit 7
+            //AlarmVal[18]
+            unsigned char MeterIcCommTimeout:1;						//bit 0
+            unsigned char PilotNegativeError:1;						//bit 1
+            unsigned char :6;										//reserved bit 2 ~ bit 7
+            //AlarmVal[19]
+            unsigned char :8;										//reserved bit 0 ~ bit 7
 		}bits;
 	}AlarmEvents;
 };

+ 24 - 0
EVSE/rootfs/usr/bin/run_ddr_reg_set.sh

@@ -0,0 +1,24 @@
+#!/bin/sh
+
+if [ $# -lt 3 ]; then
+	echo "Usage sample:  run_ddr_reg_set.sh [RD_DQS] [FIFO_WE] [WR_DQS] [WR_DATA]"
+	echo ""
+	echo "   RD_DQS: DDR PHY Data Macro-0 Read DQS Slave Ratio Register"
+	echo "  FIFO_WE: DDR PHY Data Macro-0 DQS Gate Slave Ratio Register"
+	echo "   WR_DQS: DDR PHY Data Macro-0 Write DQS Slave Ratio Register"
+	echo "  WR_DATA: DDR PHY Data Macro-0 Write Data Slave Ratio Register"
+	echo ""
+	echo "  run_ddr_reg_set.sh 0x3c 0x9f 0x54 0x8c"
+	echo ""
+        exit 0;
+else
+	`devmem 0x44e120c8 w $1`
+	`devmem 0x44e12108 w $2`
+	`devmem 0x44e120dc w $3`
+	`devmem 0x44e12120 w $4`
+	echo "RD_DQS configure as $1"
+	echo "FIFO_WE configure as $2"
+	echo "WR_DQS configure as $3"
+	echo "WR_DATA configure as $4"
+fi
+

+ 2 - 2
board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/board/ti/am335x/board.c

@@ -319,7 +319,7 @@ const struct dpll_params *get_dpll_ddr_params(void)
 	else
 	{
 		/*+++ vern,20161126, for 512 DDR+++*/
-		return &dpll_ddr3_303MHz[ind];
+		return &dpll_ddr3_400MHz[ind];
 		//return &dpll_ddr2_266MHz[ind];
 		/*--- vern,20161126, for 512 DDR ---*/
 	}
@@ -638,7 +638,7 @@ void sdram_init(void)
 			   &ddr2_cmd_ctrl_data, &ddr2_emif_reg_data, 0);
 	*/
 	else
-		config_ddr(303, &ioregs_evm15, &ddr3_evm_data,
+		config_ddr(400, &ioregs_evm15, &ddr3_evm_data,
 			   &ddr3_evm_cmd_ctrl_data, &ddr3_evm_emif_reg_data, 0);	
 	/*--- vern,20161126, for 512 DDR ---*/
 }

+ 3 - 3
board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/common/autoboot.c

@@ -18,11 +18,11 @@
 DECLARE_GLOBAL_DATA_PTR;
 
 #if defined(MT29F16G08_BCH16)
-	#define uboot_version "02.02"
+	#define uboot_version "02.03"
 #elif defined(MT29F8G08_BCH16)
-	#define uboot_version "03.02"
+	#define uboot_version "03.03"
 #else
-	#define uboot_version "01.02"
+	#define uboot_version "01.03"
 #endif
 
 #define MAX_DELAY_STOP_STR 32