Ver código fonte

[Improve][Modularization][Module_OcppBackend / Module_OcppBackend20]

2021.09.25 / Folus Wen

Actions:
1. checkChargePointMaxProfile() query profile by stack logic improve.
2. OCPP reconnect server logic improve.

Files:
1. As follow commit history

Image version: D0.00.XX.XXXX.XX
Image checksum: XXXXXXXX

Hardware PWB P/N : XXXXXXX
Hardware Version : XXXXXXX
FolusWen 3 anos atrás
pai
commit
a545fbc951

+ 76 - 38
EVSE/Modularization/ocpp20/MessageHandler.c

@@ -3605,15 +3605,6 @@ void checkChargePointMaxProfile(uint32_t durationReq, struct ChargingProfileType
 	{
 		fp = fopen(profileFileName, "r");
 
-		for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
-		{
-			maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
-			maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = -1;
-			maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
-		}
-		maxProfile.id = -1;
-		maxProfile.stackLevel = -1;
-
 		while(getline(&line, &len, fp) != -1)
 		{
 			json_object *obj = NULL;
@@ -3649,6 +3640,15 @@ void checkChargePointMaxProfile(uint32_t durationReq, struct ChargingProfileType
 
 							if((DiffTimebWithNowSec(tbFrom)>=0) && (DiffTimebWithNowSec(tbTo)<=0))
 							{
+								for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
+								{
+									maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
+									maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = -1;
+									maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
+								}
+								maxProfile.id = -1;
+								maxProfile.stackLevel = -1;
+
 								if(maxProfile.id == -1)
 									DEBUG_INFO("MaxProfile found.\n");
 								else
@@ -3754,6 +3754,15 @@ void checkChargePointMaxProfile(uint32_t durationReq, struct ChargingProfileType
 					}
 					else
 					{
+						for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
+						{
+							maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
+							maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = -1;
+							maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
+						}
+						maxProfile.id = -1;
+						maxProfile.stackLevel = -1;
+
 						if(maxProfile.id == -1)
 							DEBUG_INFO("MaxProfile found.\n");
 						else
@@ -4138,16 +4147,6 @@ void checkCompositeSchedule(uint8_t connectorId, uint32_t durationReq, struct Ch
 	{
 		fp = fopen(profileFileName, "r");
 
-		for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
-		{
-			txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
-			txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = -1;
-			txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
-			txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].phaseToUse = 0;
-		}
-		txProfile.id = -1;
-		txProfile.stackLevel = -1;
-
 		while(getline(&line, &len, fp) != -1)
 		{
 			json_object *obj = NULL;
@@ -4183,6 +4182,16 @@ void checkCompositeSchedule(uint8_t connectorId, uint32_t durationReq, struct Ch
 
 							if((DiffTimebWithNowSec(tbFrom)>=0) && (DiffTimebWithNowSec(tbTo)<=0))
 							{
+								for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
+								{
+									txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
+									txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = -1;
+									txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
+									txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].phaseToUse = 0;
+								}
+								txProfile.id = -1;
+								txProfile.stackLevel = -1;
+
 								if(txProfile.id == -1)
 									DEBUG_INFO("TxProfile found.\n");
 								else
@@ -4287,6 +4296,16 @@ void checkCompositeSchedule(uint8_t connectorId, uint32_t durationReq, struct Ch
 					}
 					else
 					{
+						for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
+						{
+							txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
+							txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = -1;
+							txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
+							txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].phaseToUse = 0;
+						}
+						txProfile.id = -1;
+						txProfile.stackLevel = -1;
+
 						if(txProfile.id == -1)
 							DEBUG_INFO("TxProfile found.\n");
 						else
@@ -4432,16 +4451,6 @@ void checkCompositeSchedule(uint8_t connectorId, uint32_t durationReq, struct Ch
 	{
 		fp = fopen(profileFileName, "r");
 
-		for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
-		{
-			defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
-			defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = -1;
-			defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
-			defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].phaseToUse = 0;
-		}
-		defaultTxProfile.id = -1;
-		defaultTxProfile.stackLevel = -1;
-
 		while(getline(&line, &len, fp) != -1)
 		{
 			json_object *obj = NULL;
@@ -4477,6 +4486,16 @@ void checkCompositeSchedule(uint8_t connectorId, uint32_t durationReq, struct Ch
 
 							if((DiffTimebWithNowSec(tbFrom)>=0) && (DiffTimebWithNowSec(tbTo)<=0))
 							{
+								for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
+								{
+									defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
+									defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = -1;
+									defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
+									defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].phaseToUse = 0;
+								}
+								defaultTxProfile.id = -1;
+								defaultTxProfile.stackLevel = -1;
+
 								if(defaultTxProfile.id == -1)
 									DEBUG_INFO("TxDefaultProfile found.\n");
 								else
@@ -4581,6 +4600,16 @@ void checkCompositeSchedule(uint8_t connectorId, uint32_t durationReq, struct Ch
 					}
 					else
 					{
+						for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
+						{
+							defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
+							defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = -1;
+							defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
+							defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].phaseToUse = 0;
+						}
+						defaultTxProfile.id = -1;
+						defaultTxProfile.stackLevel = -1;
+
 						if(defaultTxProfile.id == -1)
 							DEBUG_INFO("TxDefaultProfile found.\n");
 						else
@@ -4724,15 +4753,6 @@ void checkCompositeSchedule(uint8_t connectorId, uint32_t durationReq, struct Ch
 	{
 		fp = fopen(profileFileName, "r");
 
-		for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
-		{
-			maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
-			maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = -1;
-			maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
-		}
-		maxProfile.id = -1;
-		maxProfile.stackLevel = -1;
-
 		while(getline(&line, &len, fp) != -1)
 		{
 			json_object *obj = NULL;
@@ -4768,6 +4788,15 @@ void checkCompositeSchedule(uint8_t connectorId, uint32_t durationReq, struct Ch
 
 							if((DiffTimebWithNowSec(tbFrom)>=0) && (DiffTimebWithNowSec(tbTo)<=0))
 							{
+								for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
+								{
+									maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
+									maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = -1;
+									maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
+								}
+								maxProfile.id = -1;
+								maxProfile.stackLevel = -1;
+
 								if(maxProfile.id == -1)
 									DEBUG_INFO("MaxProfile found.\n");
 								else
@@ -4873,6 +4902,15 @@ void checkCompositeSchedule(uint8_t connectorId, uint32_t durationReq, struct Ch
 					}
 					else
 					{
+						for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
+						{
+							maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
+							maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = -1;
+							maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
+						}
+						maxProfile.id = -1;
+						maxProfile.stackLevel = -1;
+
 						if(maxProfile.id == -1)
 							DEBUG_INFO("MaxProfile found.\n");
 						else

+ 13 - 5
EVSE/Modularization/ocpp20/Module_OcppBackend20.c

@@ -13,6 +13,7 @@ struct StartTime
 {
 	unsigned int connect;
 	unsigned int bootNotification;
+	unsigned int reConnect;
 }startTime;
 
 //==========================================
@@ -1201,11 +1202,18 @@ int main(void)
 
 				if((changeChageWebSocketPingInterval == TRUE) || (GetOcppConnStatus() == 0))
 				{
-					DEBUG_INFO("GetOcppConnStatus() = %d\n", GetOcppConnStatus());
-					changeChageWebSocketPingInterval = FALSE;
-					lws_context_destroy(context);
-					ConnectionEstablished = 0;
-					context = NULL;
+					if(((time((time_t*)NULL)-startTime.reConnect) >= 3) || (((time((time_t*)NULL)-startTime.reConnect) < 0)))
+					{
+						DEBUG_INFO("GetOcppConnStatus() = %d\n", GetOcppConnStatus());
+						changeChageWebSocketPingInterval = FALSE;
+						lws_context_destroy(context);
+						ConnectionEstablished = 0;
+						context = NULL;
+					}
+				}
+				else
+				{
+					startTime.reConnect = time((time_t*)NULL);
 				}
 			}
 		}

+ 74 - 40
EVSE/Modularization/ocppfiles/MessageHandler.c

@@ -1497,15 +1497,6 @@ void checkChargePointMaxProfile(uint32_t durationReq, struct StructChargingProfi
 	{
 		fp = fopen(profileFileName, "r");
 
-		for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.ChargingSchedule.ChargingSchedulePeriod);idxPeriod++)
-		{
-			maxProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].StartPeriod = -1;
-			maxProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].Limit = -1;
-			maxProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].NumberPhases = 3;
-		}
-		maxProfile.ChargingProfileId = -1;
-		maxProfile.StackLevel = -1;
-
 		while(getline(&line, &len, fp) != -1)
 		{
 			json_object *obj = NULL;
@@ -1541,6 +1532,15 @@ void checkChargePointMaxProfile(uint32_t durationReq, struct StructChargingProfi
 
 							if((DiffTimebWithNowSec(tbFrom)>=0) && (DiffTimebWithNowSec(tbTo)<=0))
 							{
+								for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.ChargingSchedule.ChargingSchedulePeriod);idxPeriod++)
+								{
+									maxProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].StartPeriod = -1;
+									maxProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].Limit = -1;
+									maxProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].NumberPhases = 3;
+								}
+								maxProfile.ChargingProfileId = -1;
+								maxProfile.StackLevel = -1;
+
 								if(maxProfile.ChargingProfileId == -1)
 									DEBUG_INFO("MaxProfile found.\n");
 								else
@@ -1647,6 +1647,15 @@ void checkChargePointMaxProfile(uint32_t durationReq, struct StructChargingProfi
 					}
 					else
 					{
+						for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.ChargingSchedule.ChargingSchedulePeriod);idxPeriod++)
+						{
+							maxProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].StartPeriod = -1;
+							maxProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].Limit = -1;
+							maxProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].NumberPhases = 3;
+						}
+						maxProfile.ChargingProfileId = -1;
+						maxProfile.StackLevel = -1;
+
 						if(maxProfile.ChargingProfileId == -1)
 							DEBUG_INFO("MaxProfile found.\n");
 						else
@@ -2031,15 +2040,6 @@ void checkCompositeSchedule(uint8_t connectorId, uint32_t durationReq, struct St
 	{
 		fp = fopen(profileFileName, "r");
 
-		for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.ChargingSchedule.ChargingSchedulePeriod);idxPeriod++)
-		{
-			txProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].StartPeriod = -1;
-			txProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].Limit = -1;
-			txProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].NumberPhases = 3;
-		}
-		txProfile.ChargingProfileId = -1;
-		txProfile.StackLevel = -1;
-
 		while(getline(&line, &len, fp) != -1)
 		{
 			json_object *obj = NULL;
@@ -2075,6 +2075,15 @@ void checkCompositeSchedule(uint8_t connectorId, uint32_t durationReq, struct St
 
 							if((DiffTimebWithNowSec(tbFrom)>=0) && (DiffTimebWithNowSec(tbTo)<=0))
 							{
+								for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.ChargingSchedule.ChargingSchedulePeriod);idxPeriod++)
+								{
+									txProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].StartPeriod = -1;
+									txProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].Limit = -1;
+									txProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].NumberPhases = 3;
+								}
+								txProfile.ChargingProfileId = -1;
+								txProfile.StackLevel = -1;
+
 								if(txProfile.ChargingProfileId == -1)
 									DEBUG_INFO("TxProfile found.\n");
 								else
@@ -2180,6 +2189,15 @@ void checkCompositeSchedule(uint8_t connectorId, uint32_t durationReq, struct St
 					}
 					else
 					{
+						for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.ChargingSchedule.ChargingSchedulePeriod);idxPeriod++)
+						{
+							txProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].StartPeriod = -1;
+							txProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].Limit = -1;
+							txProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].NumberPhases = 3;
+						}
+						txProfile.ChargingProfileId = -1;
+						txProfile.StackLevel = -1;
+
 						if(txProfile.ChargingProfileId == -1)
 							DEBUG_INFO("TxProfile found.\n");
 						else
@@ -2325,15 +2343,6 @@ void checkCompositeSchedule(uint8_t connectorId, uint32_t durationReq, struct St
 	{
 		fp = fopen(profileFileName, "r");
 
-		for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.ChargingSchedule.ChargingSchedulePeriod);idxPeriod++)
-		{
-			defaultTxProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].StartPeriod = -1;
-			defaultTxProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].Limit = -1;
-			defaultTxProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].NumberPhases = 3;
-		}
-		defaultTxProfile.ChargingProfileId = -1;
-		defaultTxProfile.StackLevel = -1;
-
 		while(getline(&line, &len, fp) != -1)
 		{
 			json_object *obj = NULL;
@@ -2369,6 +2378,15 @@ void checkCompositeSchedule(uint8_t connectorId, uint32_t durationReq, struct St
 
 							if((DiffTimebWithNowSec(tbFrom)>=0) && (DiffTimebWithNowSec(tbTo)<=0))
 							{
+								for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.ChargingSchedule.ChargingSchedulePeriod);idxPeriod++)
+								{
+									defaultTxProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].StartPeriod = -1;
+									defaultTxProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].Limit = -1;
+									defaultTxProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].NumberPhases = 3;
+								}
+								defaultTxProfile.ChargingProfileId = -1;
+								defaultTxProfile.StackLevel = -1;
+
 								if(defaultTxProfile.ChargingProfileId == -1)
 									DEBUG_INFO("TxDefaultProfile found.\n");
 								else
@@ -2475,6 +2493,15 @@ void checkCompositeSchedule(uint8_t connectorId, uint32_t durationReq, struct St
 					}
 					else
 					{
+						for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.ChargingSchedule.ChargingSchedulePeriod);idxPeriod++)
+						{
+							defaultTxProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].StartPeriod = -1;
+							defaultTxProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].Limit = -1;
+							defaultTxProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].NumberPhases = 3;
+						}
+						defaultTxProfile.ChargingProfileId = -1;
+						defaultTxProfile.StackLevel = -1;
+
 						if(defaultTxProfile.ChargingProfileId == -1)
 							DEBUG_INFO("TxDefaultProfile found.\n");
 						else
@@ -2619,15 +2646,6 @@ void checkCompositeSchedule(uint8_t connectorId, uint32_t durationReq, struct St
 	{
 		fp = fopen(profileFileName, "r");
 
-		for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.ChargingSchedule.ChargingSchedulePeriod);idxPeriod++)
-		{
-			maxProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].StartPeriod = -1;
-			maxProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].Limit = -1;
-			maxProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].NumberPhases = 3;
-		}
-		maxProfile.ChargingProfileId = -1;
-		maxProfile.StackLevel = -1;
-
 		while(getline(&line, &len, fp) != -1)
 		{
 			json_object *obj = NULL;
@@ -2663,6 +2681,15 @@ void checkCompositeSchedule(uint8_t connectorId, uint32_t durationReq, struct St
 
 							if((DiffTimebWithNowSec(tbFrom)>=0) && (DiffTimebWithNowSec(tbTo)<=0))
 							{
+								for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.ChargingSchedule.ChargingSchedulePeriod);idxPeriod++)
+								{
+									maxProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].StartPeriod = -1;
+									maxProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].Limit = -1;
+									maxProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].NumberPhases = 3;
+								}
+								maxProfile.ChargingProfileId = -1;
+								maxProfile.StackLevel = -1;
+
 								if(maxProfile.ChargingProfileId == -1)
 									DEBUG_INFO("MaxProfile found.\n");
 								else
@@ -2769,6 +2796,15 @@ void checkCompositeSchedule(uint8_t connectorId, uint32_t durationReq, struct St
 					}
 					else
 					{
+						for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.ChargingSchedule.ChargingSchedulePeriod);idxPeriod++)
+						{
+							maxProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].StartPeriod = -1;
+							maxProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].Limit = -1;
+							maxProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].NumberPhases = 3;
+						}
+						maxProfile.ChargingProfileId = -1;
+						maxProfile.StackLevel = -1;
+
 						if(maxProfile.ChargingProfileId == -1)
 							DEBUG_INFO("MaxProfile found.\n");
 						else
@@ -8934,13 +8970,12 @@ int handleChangeConfigurationRequest(char *uuid, char *payload)
     sendChangeConfigurationConfirmation(uuid, comfirmstr);
 	ShmOCPP16Data->MsMsg.bits.ChangeConfigurationConf = 1;
 
-	if((strcmp(keystr,"WebSocketPingInterval")==0)&&(strcmp(comfirmstr,"Accepted")==0))
+	if((strcmp(keystr,"WebSocketPingInterval")==0) && (strcmp(comfirmstr,"Accepted")==0))
 	{
 		ChageWebSocketPingInterval(atoi(valuestr));
 	}
 
-	if(((strcmp(keystr,"AuthorizationKey")==0) || ((strcmp(keystr,"SecurityProfile")==0))) &&
-	   (strcmp(keystr,"SecurityProfile")==0)&&(strcmp(comfirmstr,"Accepted")==0))
+	if(((strcmp(keystr,"AuthorizationKey")==0) || (strcmp(keystr,"SecurityProfile")==0)) && (strcmp(comfirmstr,"Accepted")==0))
 	{
 		StoreUsrConfigData(&ShmSysConfigAndInfo->SysConfig);
 		SetOcppConnStatus(FALSE);
@@ -10225,7 +10260,6 @@ int handleGetConfigurationRequest(char *uuid, char *payload)
 	int MaxKeySupported = 0;
 	int n_keys = 0;
 	char requestKey[GetConfigurationMaxKeysNUM][50]={0};
-
 	DEBUG_INFO("handleGetConfigurationRequest...\n");
 	json_object *GetConfiguration;
 	GetConfiguration = json_tokener_parse(payload);

+ 17 - 9
EVSE/Modularization/ocppfiles/Module_OcppBackend.c

@@ -13,6 +13,7 @@ struct StartTime
 {
 	unsigned int connect;
 	unsigned int bootNotification;
+	unsigned int reConnect;
 }startTime;
 
 //==========================================
@@ -1542,17 +1543,24 @@ int main(void)
 
 				if((changeChageWebSocketPingInterval == TRUE) || (GetOcppConnStatus() == 0))
 				{
-					DEBUG_INFO("GetOcppConnStatus() = %d\n", GetOcppConnStatus());
-
-					if(changeChageWebSocketPingInterval)
+					if(((time((time_t*)NULL)-startTime.reConnect) >= 3) || ((time((time_t*)NULL)-startTime.reConnect) < 0))
 					{
-						DEBUG_INFO("Websocket ping interval changed request.\n");
-						changeChageWebSocketPingInterval = FALSE;
-					}
+						DEBUG_INFO("GetOcppConnStatus() = %d\n", GetOcppConnStatus());
 
-					lws_context_destroy(context);
-					ConnectionEstablished = 0;
-					context = NULL;
+						if(changeChageWebSocketPingInterval)
+						{
+							DEBUG_INFO("Websocket ping interval changed request.\n");
+							changeChageWebSocketPingInterval = FALSE;
+						}
+
+						lws_context_destroy(context);
+						ConnectionEstablished = 0;
+						context = NULL;
+					}
+				}
+				else
+				{
+					startTime.reConnect = time((time_t*)NULL);
 				}
 			}
 		}

+ 75 - 39
EVSE/Modularization/ocppph/MessageHandler.c

@@ -1202,15 +1202,6 @@ void checkChargePointMaxProfile(uint32_t durationReq, struct StructChargingProfi
 	{
 		fp = fopen(profileFileName, "r");
 
-		for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.ChargingSchedule.ChargingSchedulePeriod);idxPeriod++)
-		{
-			maxProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].StartPeriod = -1;
-			maxProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].Limit = -1;
-			maxProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].NumberPhases = 3;
-		}
-		maxProfile.ChargingProfileId = -1;
-		maxProfile.StackLevel = -1;
-
 		while(getline(&line, &len, fp) != -1)
 		{
 			json_object *obj = NULL;
@@ -1246,6 +1237,15 @@ void checkChargePointMaxProfile(uint32_t durationReq, struct StructChargingProfi
 
 							if((DiffTimebWithNowSec(tbFrom)>=0) && (DiffTimebWithNowSec(tbTo)<=0))
 							{
+								for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.ChargingSchedule.ChargingSchedulePeriod);idxPeriod++)
+								{
+									maxProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].StartPeriod = -1;
+									maxProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].Limit = -1;
+									maxProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].NumberPhases = 3;
+								}
+								maxProfile.ChargingProfileId = -1;
+								maxProfile.StackLevel = -1;
+
 								if(maxProfile.ChargingProfileId == -1)
 									DEBUG_INFO("MaxProfile found.\n");
 								else
@@ -1352,6 +1352,15 @@ void checkChargePointMaxProfile(uint32_t durationReq, struct StructChargingProfi
 					}
 					else
 					{
+						for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.ChargingSchedule.ChargingSchedulePeriod);idxPeriod++)
+						{
+							maxProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].StartPeriod = -1;
+							maxProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].Limit = -1;
+							maxProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].NumberPhases = 3;
+						}
+						maxProfile.ChargingProfileId = -1;
+						maxProfile.StackLevel = -1;
+
 						if(maxProfile.ChargingProfileId == -1)
 							DEBUG_INFO("MaxProfile found.\n");
 						else
@@ -1736,15 +1745,6 @@ void checkCompositeSchedule(uint8_t connectorId, uint32_t durationReq, struct St
 	{
 		fp = fopen(profileFileName, "r");
 
-		for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.ChargingSchedule.ChargingSchedulePeriod);idxPeriod++)
-		{
-			txProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].StartPeriod = -1;
-			txProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].Limit = -1;
-			txProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].NumberPhases = 3;
-		}
-		txProfile.ChargingProfileId = -1;
-		txProfile.StackLevel = -1;
-
 		while(getline(&line, &len, fp) != -1)
 		{
 			json_object *obj = NULL;
@@ -1780,6 +1780,15 @@ void checkCompositeSchedule(uint8_t connectorId, uint32_t durationReq, struct St
 
 							if((DiffTimebWithNowSec(tbFrom)>=0) && (DiffTimebWithNowSec(tbTo)<=0))
 							{
+								for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.ChargingSchedule.ChargingSchedulePeriod);idxPeriod++)
+								{
+									txProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].StartPeriod = -1;
+									txProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].Limit = -1;
+									txProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].NumberPhases = 3;
+								}
+								txProfile.ChargingProfileId = -1;
+								txProfile.StackLevel = -1;
+
 								if(txProfile.ChargingProfileId == -1)
 									DEBUG_INFO("TxProfile found.\n");
 								else
@@ -1885,6 +1894,15 @@ void checkCompositeSchedule(uint8_t connectorId, uint32_t durationReq, struct St
 					}
 					else
 					{
+						for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.ChargingSchedule.ChargingSchedulePeriod);idxPeriod++)
+						{
+							txProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].StartPeriod = -1;
+							txProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].Limit = -1;
+							txProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].NumberPhases = 3;
+						}
+						txProfile.ChargingProfileId = -1;
+						txProfile.StackLevel = -1;
+
 						if(txProfile.ChargingProfileId == -1)
 							DEBUG_INFO("TxProfile found.\n");
 						else
@@ -2030,15 +2048,6 @@ void checkCompositeSchedule(uint8_t connectorId, uint32_t durationReq, struct St
 	{
 		fp = fopen(profileFileName, "r");
 
-		for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.ChargingSchedule.ChargingSchedulePeriod);idxPeriod++)
-		{
-			defaultTxProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].StartPeriod = -1;
-			defaultTxProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].Limit = -1;
-			defaultTxProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].NumberPhases = 3;
-		}
-		defaultTxProfile.ChargingProfileId = -1;
-		defaultTxProfile.StackLevel = -1;
-
 		while(getline(&line, &len, fp) != -1)
 		{
 			json_object *obj = NULL;
@@ -2074,6 +2083,15 @@ void checkCompositeSchedule(uint8_t connectorId, uint32_t durationReq, struct St
 
 							if((DiffTimebWithNowSec(tbFrom)>=0) && (DiffTimebWithNowSec(tbTo)<=0))
 							{
+								for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.ChargingSchedule.ChargingSchedulePeriod);idxPeriod++)
+								{
+									defaultTxProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].StartPeriod = -1;
+									defaultTxProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].Limit = -1;
+									defaultTxProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].NumberPhases = 3;
+								}
+								defaultTxProfile.ChargingProfileId = -1;
+								defaultTxProfile.StackLevel = -1;
+
 								if(defaultTxProfile.ChargingProfileId == -1)
 									DEBUG_INFO("TxDefaultProfile found.\n");
 								else
@@ -2180,6 +2198,15 @@ void checkCompositeSchedule(uint8_t connectorId, uint32_t durationReq, struct St
 					}
 					else
 					{
+						for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.ChargingSchedule.ChargingSchedulePeriod);idxPeriod++)
+						{
+							defaultTxProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].StartPeriod = -1;
+							defaultTxProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].Limit = -1;
+							defaultTxProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].NumberPhases = 3;
+						}
+						defaultTxProfile.ChargingProfileId = -1;
+						defaultTxProfile.StackLevel = -1;
+
 						if(defaultTxProfile.ChargingProfileId == -1)
 							DEBUG_INFO("TxDefaultProfile found.\n");
 						else
@@ -2324,15 +2351,6 @@ void checkCompositeSchedule(uint8_t connectorId, uint32_t durationReq, struct St
 	{
 		fp = fopen(profileFileName, "r");
 
-		for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.ChargingSchedule.ChargingSchedulePeriod);idxPeriod++)
-		{
-			maxProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].StartPeriod = -1;
-			maxProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].Limit = -1;
-			maxProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].NumberPhases = 3;
-		}
-		maxProfile.ChargingProfileId = -1;
-		maxProfile.StackLevel = -1;
-
 		while(getline(&line, &len, fp) != -1)
 		{
 			json_object *obj = NULL;
@@ -2368,6 +2386,15 @@ void checkCompositeSchedule(uint8_t connectorId, uint32_t durationReq, struct St
 
 							if((DiffTimebWithNowSec(tbFrom)>=0) && (DiffTimebWithNowSec(tbTo)<=0))
 							{
+								for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.ChargingSchedule.ChargingSchedulePeriod);idxPeriod++)
+								{
+									maxProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].StartPeriod = -1;
+									maxProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].Limit = -1;
+									maxProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].NumberPhases = 3;
+								}
+								maxProfile.ChargingProfileId = -1;
+								maxProfile.StackLevel = -1;
+
 								if(maxProfile.ChargingProfileId == -1)
 									DEBUG_INFO("MaxProfile found.\n");
 								else
@@ -2474,6 +2501,15 @@ void checkCompositeSchedule(uint8_t connectorId, uint32_t durationReq, struct St
 					}
 					else
 					{
+						for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.ChargingSchedule.ChargingSchedulePeriod);idxPeriod++)
+						{
+							maxProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].StartPeriod = -1;
+							maxProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].Limit = -1;
+							maxProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].NumberPhases = 3;
+						}
+						maxProfile.ChargingProfileId = -1;
+						maxProfile.StackLevel = -1;
+
 						if(maxProfile.ChargingProfileId == -1)
 							DEBUG_INFO("MaxProfile found.\n");
 						else
@@ -8669,13 +8705,13 @@ int handleChangeConfigurationRequest(char *uuid, char *payload)
 
     sendChangeConfigurationConfirmation(uuid, comfirmstr);
 	ShmOCPP16DataPH->MsMsg.bits.ChangeConfigurationConf = 1;
-	if((strcmp(keystr,"WebSocketPingInterval")==0)&&(strcmp(comfirmstr,"Accepted")==0))
+
+	if((strcmp(keystr,"WebSocketPingInterval")==0) && (strcmp(comfirmstr,"Accepted")==0))
 	{
 		ChageWebSocketPingInterval(atoi(valuestr));
 	}
 
-	if(((strcmp(keystr,"AuthorizationKey")==0) || ((strcmp(keystr,"SecurityProfile")==0))) &&
-	   (strcmp(keystr,"SecurityProfile")==0)&&(strcmp(comfirmstr,"Accepted")==0))
+	if(((strcmp(keystr,"AuthorizationKey")==0) || (strcmp(keystr,"SecurityProfile")==0)) && (strcmp(comfirmstr,"Accepted")==0))
 	{
 		StoreUsrConfigData(&ShmSysConfigAndInfo->SysConfig);
 		SetOcppConnStatus(FALSE);

+ 17 - 9
EVSE/Modularization/ocppph/Module_OcppBackend.c

@@ -13,6 +13,7 @@ struct StartTime
 {
 	unsigned int connect;
 	unsigned int bootNotification;
+	unsigned int reConnect;
 }startTime;
 
 //==========================================
@@ -1542,17 +1543,24 @@ int main(void)
 
 				if((changeChageWebSocketPingInterval == TRUE) || (GetOcppConnStatus() == 0))
 				{
-					DEBUG_INFO("GetOcppConnStatus() = %d\n", GetOcppConnStatus());
-
-					if(changeChageWebSocketPingInterval)
+					if(((time((time_t*)NULL)-startTime.reConnect) >= 3) || ((time((time_t*)NULL)-startTime.reConnect) < 0))
 					{
-						DEBUG_INFO("Websocket ping interval changed request.\n");
-						changeChageWebSocketPingInterval = FALSE;
-					}
+						DEBUG_INFO("GetOcppConnStatus() = %d\n", GetOcppConnStatus());
 
-					lws_context_destroy(context);
-					ConnectionEstablished = 0;
-					context = NULL;
+						if(changeChageWebSocketPingInterval)
+						{
+							DEBUG_INFO("Websocket ping interval changed request.\n");
+							changeChageWebSocketPingInterval = FALSE;
+						}
+
+						lws_context_destroy(context);
+						ConnectionEstablished = 0;
+						context = NULL;
+					}
+				}
+				else
+				{
+					startTime.reConnect = time((time_t*)NULL);
 				}
 			}
 		}

+ 23 - 0
EVSE/Projects/AW-CCS/Apps/Module_ConfigTools.c

@@ -699,6 +699,7 @@ int main(void)
 			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 **************************************************");
 			printf("\n  Please input operation item: ");
@@ -792,6 +793,28 @@ int main(void)
 					printf("\n  Invalid input gun_index.");
 				}
 			}
+			else if(strcmp(cmd, "alarm") == 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))
+				{
+					ShmSysConfigAndInfo->SysInfo.AcChargingData[atoi(cmd)-1].schedule.isTriggerStart = ON;
+					DEBUG_INFO("Alarm simulate gun-%d, OVP.\n", atoi(cmd));
+				}
+				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;
+				}
+			}
 			else if(strcmp(cmd, "cancel") == 0)
 			{}
 		}

+ 246 - 84
EVSE/Projects/AW-Regular/Apps/Module_ConfigTools.c

@@ -22,12 +22,12 @@
 
 #include 	<unistd.h>
 #include 	<stdarg.h>
-#include    <stdio.h>      /*標準輸入輸出定義*/
-#include    <stdlib.h>     /*標準函數庫定義*/
-#include    <unistd.h>     /*Unix 標準函數定義*/
-#include    <fcntl.h>      /*檔控制定義*/
-#include    <termios.h>    /*PPSIX 終端控制定義*/
-#include    <errno.h>      /*錯誤號定義*/
+#include    <stdio.h>
+#include    <stdlib.h>
+#include    <unistd.h>
+#include    <fcntl.h>
+#include    <termios.h>
+#include    <errno.h>
 #include 	<errno.h>
 #include 	<string.h>
 #include	<time.h>
@@ -37,14 +37,11 @@
 #include	<stddef.h>
 #include	<stdint.h>
 #include 	"define.h"
+#include 	"main.h"
 
 //=================================
 // System basic sample constant
 //=================================
-#define DEBUG_INFO(format, args...) StoreLogMsg("[%s:%d][%s][Info] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
-#define DEBUG_WARN(format, args...) StoreLogMsg("[%s:%d][%s][Warn] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
-#define DEBUG_ERROR(format, args...) StoreLogMsg("[%s:%d][%s][Error] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
-
 #define ARRAY_SIZE(A)					(sizeof(A) / sizeof(A[0]))
 #define PASS							1
 #define FAIL							-1
@@ -56,6 +53,8 @@
 
 struct SysConfigAndInfo			*ShmSysConfigAndInfo;
 struct StatusCodeData			*ShmStatusCodeData;
+struct OCPP16Data 				*ShmOCPP16Data;
+struct Charger					*ShmCharger;
 
 int StoreLogMsg(const char *fmt, ...)
 {
@@ -152,12 +151,12 @@ int StoreUsrConfigData(struct SysConfigData *UsrData)
 
 
 		DEBUG_INFO("Erase /dev/mtd10.\n");
-		runShellCmd("flash_erase /dev/mtd10 0 12");
+		runShellCmd("flash_erase /dev/mtd10 0 0");
 		DEBUG_INFO("Write /dev/mtd10.\n");
 		runShellCmd("nandwrite -p /dev/mtd10 /mnt/EvseConfig.bin");
 
 		DEBUG_INFO("Erase /dev/mtd11.\n");
-		runShellCmd("flash_erase /dev/mtd11 0 12");
+		runShellCmd("flash_erase /dev/mtd11 0 0");
 		DEBUG_INFO("Write /dev/mtd11.\n");
 		runShellCmd("nandwrite -p /dev/mtd11 /mnt/EvseConfig.bin");
 
@@ -185,36 +184,60 @@ int InitShareMemory()
 	//Initial ShmSysConfigAndInfo
 	if ((MeterSMId = shmget(ShmSysConfigAndInfoKey, sizeof(struct SysConfigAndInfo), 0777)) < 0)
 	{
-		#ifdef SystemLogMessage
 		DEBUG_ERROR("shmget ShmSysConfigAndInfo NG\n");
-		#endif
 		result = FAIL;
 	}
 	else if ((ShmSysConfigAndInfo = shmat(MeterSMId, NULL, 0)) == (void *) -1)
 	{
-		#ifdef SystemLogMessage
 		DEBUG_ERROR("[shmat ShmSysConfigAndInfo NG\n");
-		#endif
 		result = FAIL;
 	}
+	else
+	{}
 
 	//Initial ShmStatusCodeData
 	if ((MeterSMId = shmget(ShmStatusCodeKey, sizeof(struct StatusCodeData), 0777)) < 0)
 	{
-		#ifdef SystemLogMessage
 		DEBUG_ERROR("shmget ShmStatusCodeData NG\n");
-		#endif
 		result = FAIL;
 	}
 	else if ((ShmStatusCodeData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
 	{
-		#ifdef SystemLogMessage
 		DEBUG_ERROR("shmat ShmStatusCodeData NG\n");
-		#endif
 		result = FAIL;
 	}
+	else
+	{}
 
-	return result;
+	//Initial ShmOCPP16Data
+   	if ((MeterSMId = shmget(ShmOcppModuleKey, sizeof(struct OCPP16Data), 0777)) < 0)
+	{
+		DEBUG_ERROR("shmget ShmOCPP16Data NG\n");
+		result = FAIL;
+	}
+	else if ((ShmOCPP16Data = shmat(MeterSMId, NULL, 0)) == (void *) -1)
+	{
+		DEBUG_ERROR("shmat ShmOCPP16Data NG\n");
+		result = FAIL;
+	}
+	else
+	{}
+
+	//Initial ShmCharger
+   	if ((MeterSMId = shmget(ShmChargerKey, sizeof(struct Charger), 0777)) < 0)
+    {
+   		DEBUG_ERROR("shmget ShmCharger NG\n");
+   		result = FAIL;
+	}
+    else if ((ShmCharger = shmat(MeterSMId, NULL, 0)) == (void *) -1)
+    {
+    	DEBUG_ERROR("shmat ShmCharger NG\n");
+    	result = FAIL;
+   	}
+    else
+    {}
+
+   	return result;
 }
 
 int main(void)
@@ -235,7 +258,7 @@ int main(void)
 	}
 	else
 	{
-		DEBUG_INFO("InitShareMemory OK.\r\n");
+		DEBUG_INFO("InitShareMemory OK.\n");
 	}
 
 
@@ -243,7 +266,7 @@ int main(void)
 	{
 		system("clear");
 		memset(cmd, 0x00, ARRAY_SIZE(cmd));
-		printf("\n ===== main menu ===================================");
+		printf("\n ===== main menu ==================================");
 		printf("\n  system: system configuration menu.");
 		printf("\n  ocpp: ocpp configuration menu.");
 		printf("\n  network: netwok configuration menu.");
@@ -251,7 +274,7 @@ int main(void)
 		printf("\n  upgrade: trigger firmware upgrade.");
 		printf("\n  save: Save config.");
 		printf("\n  exit: Exit config tools.");
-		printf("\n =================================================");
+		printf("\n ==================================================");
 		printf("\n  Please input item name to config: ");
 		scanf("%s", &cmd[0]);
 
@@ -264,18 +287,18 @@ int main(void)
 			printf("\n  serialnumber: EVSE serial number.");
 			printf("\n  authentication: Authentication function.");
 			printf("\n  rfidendian: RFID read endian.");
-			printf("\n *************************************************");
+			printf("\n **************************************************");
 			printf("\n  Please input operation item: ");
 			scanf("%s", &cmd[0]);
 
 			if(strcmp(cmd, "modelname") == 0)
 			{
 				memset(cmd, 0x00, ARRAY_SIZE(cmd));
-				printf("\n *************************************************");
+				printf("\n ***** modelname **********************************");
 				printf("\n  Current model name: %s", ShmSysConfigAndInfo->SysConfig.ModelName);
 				printf("\n  0: Keep current config.");
 				printf("\n  1: Input new model name.");
-				printf("\n *************************************************");
+				printf("\n **************************************************");
 				printf("\n  Please input operation item: ");
 				scanf("%s", &cmd[0]);
 
@@ -286,16 +309,17 @@ int main(void)
 
 					memset(&ShmSysConfigAndInfo->SysConfig.ModelName[0], 0x00, ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.ModelName));
 					strcpy((char*)&ShmSysConfigAndInfo->SysConfig.ModelName[0], (char*)&cmd[0]);
+					DEBUG_INFO("Input model name: %s\n", ShmSysConfigAndInfo->SysConfig.ModelName);
 				}
 			}
 			else if(strcmp(cmd, "serialnumber") == 0)
 			{
 				memset(cmd, 0x00, ARRAY_SIZE(cmd));
-				printf("\n *************************************************");
+				printf("\n ***** serialnumber *******************************");
 				printf("\n  Current serial number: %s", ShmSysConfigAndInfo->SysConfig.SerialNumber);
 				printf("\n  0: Keep current config.");
 				printf("\n  1: Input new serial number.");
-				printf("\n *************************************************");
+				printf("\n **************************************************");
 				printf("\n  Please input operation item: ");
 				scanf("%s", &cmd[0]);
 
@@ -306,58 +330,65 @@ int main(void)
 
 					memset(&ShmSysConfigAndInfo->SysConfig.SerialNumber[0], 0x00, ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.SerialNumber));
 					strcpy((char*)&ShmSysConfigAndInfo->SysConfig.SerialNumber[0], (char*)&cmd[0]);
+					DEBUG_INFO("Input serial number: %s\n", ShmSysConfigAndInfo->SysConfig.SerialNumber);
 				}
 			}
 			else if(strcmp(cmd, "authentication") == 0)
 			{
 				memset(cmd, 0x00, ARRAY_SIZE(cmd));
-				printf("\n *************************************************");
+				printf("\n ***** authentication *****************************");
+				printf("\n  Current mode: %d", ShmSysConfigAndInfo->SysConfig.AuthorisationMode);
 				printf("\n  0: Enable.");
 				printf("\n  1: Disable.");
-				printf("\n *************************************************");
-
-				printf("\n  Current mode: %d", ShmSysConfigAndInfo->SysConfig.AuthorisationMode);
+				printf("\n **************************************************");
 				printf("\n  Please input authentication mode: ");
 				scanf("%s", &cmd[0]);
 
 				ShmSysConfigAndInfo->SysConfig.AuthorisationMode = ((0<=atoi(cmd))&&(atoi(cmd)<=1)?atoi(cmd):0);
+				if(ShmSysConfigAndInfo->SysConfig.AuthorisationMode)
+					DEBUG_INFO("Authentication: Disable\n");
+				else
+					DEBUG_INFO("Authentication: Enable\n");
 			}
 			else if(strcmp(cmd, "rfidendian") == 0)
 			{
 				memset(cmd, 0x00, ARRAY_SIZE(cmd));
-				printf("\n *************************************************");
+				printf("\n ***** rfidendian *********************************");
+				printf("\n  Current mode: %d", ShmSysConfigAndInfo->SysConfig.RfidCardNumEndian);
 				printf("\n  0: Little endian.");
 				printf("\n  1: Big endian.");
-				printf("\n *************************************************");
-
-				printf("\n  Current mode: %d", ShmSysConfigAndInfo->SysConfig.RfidCardNumEndian);
+				printf("\n **************************************************");
 				printf("\n  Please input rfid endian mode: ");
 				scanf("%s", &cmd[0]);
 
 				ShmSysConfigAndInfo->SysConfig.RfidCardNumEndian = ((0<=atoi(cmd))&&(atoi(cmd)<=1)?atoi(cmd):0);
+				if(ShmSysConfigAndInfo->SysConfig.RfidCardNumEndian)
+					DEBUG_INFO("Authentication: Little endian\n");
+				else
+					DEBUG_INFO("Authentication: Big endian\n");
 			}
 		}
 		else if(strcmp(cmd, "ocpp") == 0)
 		{
 			memset(cmd, 0x00, ARRAY_SIZE(cmd));
-			printf("\n *************************************************");
+			printf("\n ***** ocpp ***************************************");
 			printf("\n  ocppurl: OCPP backend server url.");
 			printf("\n  cboxid: Charger box id.");
 			printf("\n  vender: Charger point vender.");
 			printf("\n  offlinepolicy: Charger off line policy.");
 			printf("\n  localloadbalance: Charger local load balance.");
-			printf("\n *************************************************");
+			printf("\n **************************************************");
 			printf("\n  Please input operation item: ");
 			scanf("%s", &cmd[0]);
 
 			if(strcmp(cmd, "ocppurl") == 0)
 			{
 				memset(cmd, 0x00, ARRAY_SIZE(cmd));
-				printf("\n *************************************************");
+				printf("\n ***** ocppurl ************************************");
 				printf("\n  Current OCPP url: %s", ShmSysConfigAndInfo->SysConfig.OcppServerURL);
 				printf("\n  0: Keep current config.");
 				printf("\n  1: Input new ocpp url.");
-				printf("\n *************************************************");
+				printf("\n **************************************************");
 				printf("\n  Please input operation item: ");
 				scanf("%s", &cmd[0]);
 
@@ -368,16 +399,17 @@ int main(void)
 
 					memset(&ShmSysConfigAndInfo->SysConfig.OcppServerURL[0], 0x00, ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.OcppServerURL));
 					strcpy((char*)&ShmSysConfigAndInfo->SysConfig.OcppServerURL[0], (char*)&cmd[0]);
+					DEBUG_INFO("Input ocpp url: %s\n", ShmSysConfigAndInfo->SysConfig.OcppServerURL);
 				}
 			}
 			else if(strcmp(cmd, "cboxid") == 0)
 			{
 				memset(cmd, 0x00, ARRAY_SIZE(cmd));
-				printf("\n *************************************************");
+				printf("\n ***** cboxid *************************************");
 				printf("\n  Current OCPP charger box id: %s", ShmSysConfigAndInfo->SysConfig.ChargeBoxId);
 				printf("\n  0: Keep current config.");
 				printf("\n  1: Input new charger box id.");
-				printf("\n *************************************************");
+				printf("\n **************************************************");
 				printf("\n  Please input operation item: ");
 				scanf("%s", &cmd[0]);
 
@@ -388,16 +420,17 @@ int main(void)
 
 					memset(&ShmSysConfigAndInfo->SysConfig.ChargeBoxId[0], 0x00, ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.ChargeBoxId));
 					strcpy((char*)&ShmSysConfigAndInfo->SysConfig.ChargeBoxId[0], (char*)&cmd[0]);
+					DEBUG_INFO("Input ocpp charger box id: %s\n", ShmSysConfigAndInfo->SysConfig.ChargeBoxId);
 				}
 			}
 			else if(strcmp(cmd, "vender") == 0)
 			{
 				memset(cmd, 0x00, ARRAY_SIZE(cmd));
-				printf("\n *************************************************");
+				printf("\n ***** vender *************************************");
 				printf("\n  Current OCPP vender: %s", ShmSysConfigAndInfo->SysConfig.chargePointVendor);
 				printf("\n  0: Keep current config.");
 				printf("\n  1: Input new charger box id.");
-				printf("\n *************************************************");
+				printf("\n **************************************************");
 				printf("\n  Please input operation item: ");
 				scanf("%s", &cmd[0]);
 
@@ -408,42 +441,58 @@ int main(void)
 
 					memset(&ShmSysConfigAndInfo->SysConfig.chargePointVendor[0], 0x00, ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.chargePointVendor));
 					strcpy((char*)&ShmSysConfigAndInfo->SysConfig.chargePointVendor[0], (char*)&cmd[0]);
+					DEBUG_INFO("Input ocpp vender: %s\n", ShmSysConfigAndInfo->SysConfig.chargePointVendor);
 				}
 			}
 			else if(strcmp(cmd, "offlinepolicy") == 0)
 			{
 				memset(cmd, 0x00, ARRAY_SIZE(cmd));
-				printf("\n *************************************************");
+				printf("\n ***** offlinepolicy ******************************");
+				printf("\n  Current off line policy: %d", ShmSysConfigAndInfo->SysConfig.OfflinePolicy);
 				printf("\n  0: Local list.");
 				printf("\n  2: Free charging.");
 				printf("\n  3: Deny charging.");
-				printf("\n *************************************************");
-
-				printf("\n  Current mode: %d", ShmSysConfigAndInfo->SysConfig.OfflinePolicy);
+				printf("\n **************************************************");
 				printf("\n  Please input off line policy mode: ");
 				scanf("%s", &cmd[0]);
 
 				ShmSysConfigAndInfo->SysConfig.OfflinePolicy = ((0<=atoi(cmd))&&(atoi(cmd)<=3)&&(atoi(cmd)!=1)?atoi(cmd):0);
+
+				switch(ShmSysConfigAndInfo->SysConfig.OfflinePolicy)
+				{
+					case 0:
+						DEBUG_INFO("Off line policy: Local list.\n");
+						break;
+					case 2:
+						DEBUG_INFO("Off line policy: Free charging.\n");
+						break;
+					case 3:
+						DEBUG_INFO("Off line policy: Deny charging.\n");
+						break;
+				}
 			}
 			else if(strcmp(cmd, "localloadbalance") == 0)
 			{
 				memset(cmd, 0x00, ARRAY_SIZE(cmd));
-				printf("\n *************************************************");
+				printf("\n ***** localloadbalance ***************************");
+				printf("\n  Current local loading balance: %d", ShmSysConfigAndInfo->SysConfig.isEnableLocalPowerSharging);
 				printf("\n  0: Disable.");
 				printf("\n  1: Enable.");
-				printf("\n *************************************************");
-
-				printf("\n  Current mode: %d", ShmSysConfigAndInfo->SysConfig.isEnableLocalPowerSharging);
+				printf("\n **************************************************");
 				printf("\n  Please input local load balance mode: ");
 				scanf("%s", &cmd[0]);
 
 				ShmSysConfigAndInfo->SysConfig.isEnableLocalPowerSharging = ((0<=atoi(cmd))&&(atoi(cmd)<=1)?atoi(cmd):0);
+				if(ShmSysConfigAndInfo->SysConfig.RfidCardNumEndian)
+					DEBUG_INFO("Local loading balance: Enable\n");
+				else
+					DEBUG_INFO("Local loading balance: Disable\n");
 			}
-		}
+}
 		else if(strcmp(cmd, "network") == 0)
 		{
 			memset(cmd, 0x00, ARRAY_SIZE(cmd));
-			printf("\n *************************************************");
+			printf("\n ***** network *************************************");
 			printf("\n  ethdhcp: Ethernet DHCP client.");
 			printf("\n  wifimode: WiFi mode.");
 			printf("\n  wifidhcp: WiFi DHCP client.");
@@ -453,61 +502,79 @@ int main(void)
 			printf("\n  teleapn: Telecomm APN.");
 			printf("\n  teleid: Telecomm login id.");
 			printf("\n  telepwd: Telecomm login password.");
-			printf("\n *************************************************");
+			printf("\n **************************************************");
 			printf("\n  Please input operation item: ");
 			scanf("%s", &cmd[0]);
 
 			if(strcmp(cmd, "ethdhcp") == 0)
 			{
 				memset(cmd, 0x00, ARRAY_SIZE(cmd));
-				printf("\n *************************************************");
+				printf("\n ***** ethdhcp ************************************");
+				printf("\n  Current ethernet dhcp mode: %d", ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthDhcpClient^1);
 				printf("\n  0: Disable.");
 				printf("\n  1: Enable.");
-				printf("\n *************************************************");
-
-				printf("\n  Current ethernet dhcp mode: %d", ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthDhcpClient^1);
+				printf("\n **************************************************");
 				printf("\n  Please input dhcp mode: ");
 				scanf("%s", &cmd[0]);
 
 				ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthDhcpClient = ((0<=atoi(cmd))&&(atoi(cmd)<=1)?atoi(cmd)^1:0);
+				if(ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthDhcpClient)
+					DEBUG_INFO("Ethernet dhcp client: Disable\n");
+				else
+					DEBUG_INFO("Ethernet dhcp client: Enable\n");
+
 			}
 			else if(strcmp(cmd, "wifimode") == 0)
 			{
 				memset(cmd, 0x00, ARRAY_SIZE(cmd));
-				printf("\n *************************************************");
+				printf("\n ***** wifimode ***********************************");
+				printf("\n  Current WiFi mode: %d", ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMode);
 				printf("\n  0: Disable.");
 				printf("\n  1: Station.");
 				printf("\n  2: Access point.");
-				printf("\n *************************************************");
-
-				printf("\n  Current WiFi mode: %d", ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMode);
+				printf("\n **************************************************");
 				printf("\n  Please input WiFi mode: ");
 				scanf("%s", &cmd[0]);
 
 				ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMode = ((0<=atoi(cmd))&&(atoi(cmd)<=2)?atoi(cmd):0);
+				switch(ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMode)
+				{
+					case 0:
+						DEBUG_INFO("Wifi mode: Disable.\n");
+						break;
+					case 1:
+						DEBUG_INFO("Wifi mode: Station.\n");
+						break;
+					case 2:
+						DEBUG_INFO("Wifi mode: AP.\n");
+						break;
+				}
 			}
 			else if(strcmp(cmd, "wifidhcp") == 0)
 			{
 				memset(cmd, 0x00, ARRAY_SIZE(cmd));
-				printf("\n *************************************************");
+				printf("\n ***** wifidhcp ***********************************");
+				printf("\n  Current WiFi dhcp client mode: %d", ShmSysConfigAndInfo->SysConfig.AthInterface.WifiDhcpClient^1);
 				printf("\n  0: Disable.");
 				printf("\n  1: Enable.");
-				printf("\n *************************************************");
-
-				printf("\n  Current WiFi dhcp client mode: %d", ShmSysConfigAndInfo->SysConfig.AthInterface.WifiDhcpClient^1);
+				printf("\n **************************************************");
 				printf("\n  Please input WiFi mode: ");
 				scanf("%s", &cmd[0]);
 
 				ShmSysConfigAndInfo->SysConfig.AthInterface.WifiDhcpClient = ((0<=atoi(cmd))&&(atoi(cmd)<=1)?atoi(cmd)^1:0);
+				if(ShmSysConfigAndInfo->SysConfig.AthInterface.WifiDhcpClient)
+					DEBUG_INFO("Wifi dhcp client: Disable\n");
+				else
+					DEBUG_INFO("Wifi dhcp client: Enable\n");
 			}
 			else if(strcmp(cmd, "wificssid") == 0)
 			{
 				memset(cmd, 0x00, ARRAY_SIZE(cmd));
-				printf("\n *************************************************");
+				printf("\n ***** wificssid **********************************");
 				printf("\n  Current WiFi client SSID: %s", ShmSysConfigAndInfo->SysConfig.AthInterface.WifiSsid);
 				printf("\n  0: Keep current config.");
 				printf("\n  1: Input new WiFi client SSID.");
-				printf("\n *************************************************");
+				printf("\n **************************************************");
 				printf("\n  Please input operation item: ");
 				scanf("%s", &cmd[0]);
 
@@ -518,16 +585,17 @@ int main(void)
 
 					memset(&ShmSysConfigAndInfo->SysConfig.AthInterface.WifiSsid[0], 0x00, ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.AthInterface.WifiSsid));
 					strcpy((char*)&ShmSysConfigAndInfo->SysConfig.AthInterface.WifiSsid[0], (char*)&cmd[0]);
+					DEBUG_INFO("Wifi client SSID: %s\n", ShmSysConfigAndInfo->SysConfig.AthInterface.WifiSsid);
 				}
 			}
 			else if(strcmp(cmd, "wificpasswd") == 0)
 			{
 				memset(cmd, 0x00, ARRAY_SIZE(cmd));
-				printf("\n *************************************************");
+				printf("\n ***** wificpasswd ********************************");
 				printf("\n  Current WiFi client password: %s", ShmSysConfigAndInfo->SysConfig.AthInterface.WifiPassword);
 				printf("\n  0: Keep current config.");
 				printf("\n  1: Input new WiFi client password.");
-				printf("\n *************************************************");
+				printf("\n **************************************************");
 				printf("\n  Please input operation item: ");
 				scanf("%s", &cmd[0]);
 
@@ -538,30 +606,35 @@ int main(void)
 
 					memset(&ShmSysConfigAndInfo->SysConfig.AthInterface.WifiPassword[0], 0x00, ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.AthInterface.WifiPassword));
 					strcpy((char*)&ShmSysConfigAndInfo->SysConfig.AthInterface.WifiPassword[0], (char*)&cmd[0]);
+					DEBUG_INFO("Wifi client password: %s\n", ShmSysConfigAndInfo->SysConfig.AthInterface.WifiPassword);
 				}
 			}
 			else if(strcmp(cmd, "telemode") == 0)
 			{
 				memset(cmd, 0x00, ARRAY_SIZE(cmd));
-				printf("\n *************************************************");
+				printf("\n ***** telemode ***********************************");
 				printf("\n  0: Disable.");
 				printf("\n  1: Enable.");
-				printf("\n *************************************************");
+				printf("\n **************************************************");
 
 				printf("\n  Current telecomm mode: %d", ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomModemMode^1);
 				printf("\n  Please input telecomm mode: ");
 				scanf("%s", &cmd[0]);
 
 				ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomModemMode = ((0<=atoi(cmd))&&(atoi(cmd)<=1)?atoi(cmd)^1:0);
+				if(ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomModemMode)
+					DEBUG_INFO("Wifi dhcp client: Disable\n");
+				else
+					DEBUG_INFO("Wifi dhcp client: Enable\n");
 			}
 			else if(strcmp(cmd, "teleapn") == 0)
 			{
 				memset(cmd, 0x00, ARRAY_SIZE(cmd));
-				printf("\n *************************************************");
+				printf("\n ***** teleapn ************************************");
 				printf("\n  Current telecomm APN: %s", ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomApn);
 				printf("\n  0: Keep current config.");
 				printf("\n  1: Input new telecomm APN.");
-				printf("\n *************************************************");
+				printf("\n **************************************************");
 				printf("\n  Please input operation item: ");
 				scanf("%s", &cmd[0]);
 
@@ -572,16 +645,17 @@ int main(void)
 
 					memset(&ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomApn[0], 0x00, ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomApn));
 					strcpy((char*)&ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomApn[0], (char*)&cmd[0]);
+					DEBUG_INFO("Telecomm APN: %s\n", ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomApn);
 				}
 			}
 			else if(strcmp(cmd, "teleid") == 0)
 			{
 				memset(cmd, 0x00, ARRAY_SIZE(cmd));
-				printf("\n *************************************************");
+				printf("\n ***** teleid *************************************");
 				printf("\n  Current telecomm login id: %s", ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomChapPapId);
 				printf("\n  0: Keep current config.");
 				printf("\n  1: Input new telecomm login id.");
-				printf("\n *************************************************");
+				printf("\n **************************************************");
 				printf("\n  Please input operation item: ");
 				scanf("%s", &cmd[0]);
 
@@ -592,16 +666,17 @@ int main(void)
 
 					memset(&ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomChapPapId[0], 0x00, ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomChapPapId));
 					strcpy((char*)&ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomChapPapId[0], (char*)&cmd[0]);
+					DEBUG_INFO("Telecomm CHAP id: %s\n", ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomChapPapId);
 				}
 			}
 			else if(strcmp(cmd, "telepwd") == 0)
 			{
 				memset(cmd, 0x00, ARRAY_SIZE(cmd));
-				printf("\n *************************************************");
+				printf("\n ***** telepwd ************************************");
 				printf("\n  Current telecomm login password: %s", ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomChapPapPwd);
 				printf("\n  0: Keep current config.");
 				printf("\n  1: Input new telecomm login password.");
-				printf("\n *************************************************");
+				printf("\n **************************************************");
 				printf("\n  Please input operation item: ");
 				scanf("%s", &cmd[0]);
 
@@ -612,17 +687,21 @@ int main(void)
 
 					memset(&ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomChapPapPwd[0], 0x00, ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomChapPapPwd));
 					strcpy((char*)&ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomChapPapPwd[0], (char*)&cmd[0]);
+					DEBUG_INFO("Telecomm CHAP password: %s\n", ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomChapPapPwd);
 				}
 			}
 		}
 		else if(strcmp(cmd, "test") == 0)
 		{
 			memset(cmd, 0x00, ARRAY_SIZE(cmd));
-			printf("\n ***** test menu ******************");
+			printf("\n ***** test menu **********************************");
 			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 *************************************************");
+			printf("\n **************************************************");
 			printf("\n  Please input operation item: ");
 			scanf("%s", &cmd[0]);
 
@@ -635,6 +714,7 @@ int main(void)
 				if((0 < atoi(cmd)) && (atoi(cmd) < 3))
 				{
 					ShmSysConfigAndInfo->SysInfo.AcChargingData[atoi(cmd)-1].schedule.isTriggerStart = ON;
+					DEBUG_INFO("Test start gun-%d, start charging session.\n", atoi(cmd));
 				}
 				else
 				{
@@ -650,12 +730,91 @@ int main(void)
 				if((0 < atoi(cmd)) && (atoi(cmd) < 3))
 				{
 					ShmSysConfigAndInfo->SysInfo.AcChargingData[atoi(cmd)-1].schedule.isTriggerStop = ON;
+					DEBUG_INFO("Test start gun-%d, stop charging session.\n", atoi(cmd));
+				}
+				else
+				{
+					printf("\n  Invalid input gun_index.");
+				}
+			}
+			else if(strcmp(cmd, "auth") == 0)
+			{
+				memset(cmd, 0x00, ARRAY_SIZE(cmd));
+				printf("\n  Please input idtag: ");
+				scanf("%s", &cmd[0]);
+
+				sprintf((char*)ShmSysConfigAndInfo->SysConfig.UserId, "%s", cmd);
+				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));
+				printf("\n  Please input gun index(1~2): ");
+				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));
+				}
+				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;
+				}
+			}
 			else if(strcmp(cmd, "cancel") == 0)
 			{}
 		}
@@ -664,7 +823,7 @@ int main(void)
 			printf("\n  Firmware upgrade trigger.");
 
 			ShmSysConfigAndInfo->SysInfo.FirmwareUpdate = ON;
-
+			DEBUG_INFO("Trigger firmware upgrade.\n");
 			sleep(2);
 		}
 		else if(strcmp(cmd, "save") == 0)
@@ -674,13 +833,16 @@ int main(void)
 				printf("\n  Write configuration fail.\r\n");
 			}
 			else
+			{
 				printf("\n  Write configuration OK.\r\n");
-
+				DEBUG_INFO("Save configuration.\n");
+			}
 			sleep(2);
 		}
 		else if(strcmp(cmd, "exit") == 0)
 		{
 			printf("\n  exit program.\n\n");
+			DEBUG_INFO("Exit configuration tools.\n");
 			return FAIL;
 		}
 	}