Browse Source

[Improve][Modularization][Module_RatedCurrent / Module_OcppBackend]

2021.11.16 / Folus Wen

Actions:
1. Module_RatedCurrent add parsing rated power by model name formular.
2. ModuleOcppBackend reject SetChargingProfile if period limit is invalid.

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 years ago
parent
commit
8f46931b10

+ 5 - 5
EVSE/Modularization/Makefile

@@ -3,11 +3,11 @@ export PATH=/bin:/sbin:/usr/bin:$(SDK_PATH_TARGET)/usr/bin:$PATH
 
 #define library variable
 Lib_SQLite3 = "-L../../../Modularization/ocppfiles" -lsqlite3
-Lib_RatedCurrentLib = "-L./" -lModule_RatedCurrent
+Lib_RatedCurrentLib = "-L./" -lm -lModule_RatedCurrent
 
 all: clean Module_RFIDLib Module_RatedCurrentLib Module_UpgradeLib Module_Wifi \
      WebServiceLib Ocpp16 Phihong_PsuCommObj Module_4g Infypwr_PsuCommObj \
-     Module_EventLogging Module_ProduceUtils Module_PhBackend \
+     Module_EventLogging Module_ProduceUtils \
      Ocpp20 Module_InitUpgrade Module_Payment Module_DcMeter Ocppph
 
 clean:
@@ -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 -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 -lrt -luuid -lpthread -lc -lsqlite3 -ljson-c -lModule_RatedCurrent -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 -lrt -luuid -lpthread -lc -lsqlite3 -ljson-c ${Lib_RatedCurrentLib} -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 -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 -lrt -luuid -lpthread -lc -lsqlite3 -ljson-c -lModule_RatedCurrent -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 -lrt -luuid -lpthread -lc -lsqlite3 -ljson-c ${Lib_RatedCurrentLib} -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 -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 -lrt -luuid -lpthread -lc -lsqlite3 -ljson-c -lModule_RatedCurrent -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 -lrt -luuid -lpthread -lc -lsqlite3 -ljson-c ${Lib_RatedCurrentLib} -o OcppBackend20
 	mv -f OcppBackend20 ../rootfs/root/
 
 

+ 7 - 3
EVSE/Modularization/Module_RatedCurrent.c

@@ -5,7 +5,7 @@
 #include <string.h>
 #include <stdarg.h>
 #include <time.h>
-
+#include <math.h>
 #include <sys/timeb.h>
 
 #include "Module_RatedCurrent.h"
@@ -631,6 +631,9 @@ int RatedCurrentParsing(char *pModuleName, void *pDestStruct)
         //         pGunRateCurInfo->Power);
     }
 
+    // Rated power convert
+    pParsingInfo->ratedPower = (((pModuleName[4]-0x30)*10)+((pModuleName[5]-0x30)*1))*pow(10, (pModuleName[6]-0x30)-1)*1000;
+
     return PASS;
 }
 
@@ -645,12 +648,13 @@ void TestParsingRatingCurrent(void)
     RatedCurrentParsing("DDYC362V0UE2AD", &fParsingRateCur);
     log_info("Get gun = %d\r\n", fParsingRateCur.GetGunCount);
     for (i = 0; i < fParsingRateCur.GetGunCount; i++) {
-        log_info("%d GunType = %d, Rating current = %d, Vol = %d, Power = %d\r\n",
+        log_info("%d GunType = %d, Rating current = %d, Vol = %d, Power = %d, Rated power: %d\r\n",
                  i,
                  fParsingRateCur.ParsingInfo[i].GunType,
                  fParsingRateCur.ParsingInfo[i].Current,
                  fParsingRateCur.ParsingInfo[i].Voltage,
-                 fParsingRateCur.Power);
+                 fParsingRateCur.Power,
+				 fParsingRateCur.ratedPower);
     }
     //log_info("%d GunType = %d, Rating current = %d, Vol = %d, Power = %d\r\n",
     //         0,

+ 4 - 3
EVSE/Modularization/Module_RatedCurrent.h

@@ -18,7 +18,7 @@
 #define MODEL_DS                                (0x06) //Dc EVse Standalone
 #define MODEL_DM                                (0x07) //Dc EVse Moveable (Battery equipped)
 #define MODEL_DR                                (0x08) //Dc EVse Power Rack (without cabinet)
-//#define MODEL_DM                                (0x09) //Dc EVse Moveable (移動)
+//#define MODEL_DM                                (0x09) //Dc EVse Moveable (Movable)
 #define MODEL_DD                                (0x0A) //Dc EVse Dispenser
 #define MODEL_DO                                (0x0B) //Dc EVse Output power cabinet
 #define MODEL_DQ								(0x0C) //DC EVSE Infy 30KW GB
@@ -82,8 +82,8 @@
 #define GUN_TYPE_K                              (0x11) //CHAdeMO 200A/500V
 #define GUN_TYPE_M                              (0x12) //CCS2 80A
 #define GUN_TYPE_N                              (0x13) //CCS1 80A
-#define GUN_TYPE_P                              (0x14) //Phoenix CCS2 500A 水冷
-#define GUN_TYPE_R                              (0x15) //Phoenix CCS1 500A 水冷
+#define GUN_TYPE_P                              (0x14) //Phoenix CCS2 500A Liquid cooling
+#define GUN_TYPE_R                              (0x15) //Phoenix CCS1 500A Liquid cooling
 #define GUN_TYPE_C                              (0x16) //Reserved for ChaoJi
 #define GUN_TYPE_W                              (0x17) //Reserved for Wireless
 #define GUN_TYPE_B                              (0x18) //GBT YG PT1000
@@ -331,6 +331,7 @@ typedef struct StRateCurInfo {
 typedef struct StParsingRatingCur {
     uint8_t GetGunCount;
     uint16_t Power;
+    uint32_t ratedPower;			// unit: W
     RateCurInfo ParsingInfo[3];
     uint8_t Reserved;
 } ParsingRatedCur;

+ 2 - 1
EVSE/Modularization/ocpp20/MessageHandler.c

@@ -777,6 +777,7 @@ char queuedata[QUEUE_MESSAGE_LENGTH]	= {0};
 //===============================
 // Gun Total  Numbers
 //===============================
+static ParsingRatedCur modelnameInfo	= {0};
 static int gunTotalNumber				= 0;
 static uint8_t gunType[4] 				= {0};
 
@@ -6020,7 +6021,6 @@ int InitShareMemory()
 int ProcessShareMemory()
 {
 	int result = PASS;
-	ParsingRatedCur modelnameInfo={0};
 
 	if(InitShareMemory() == FAIL)
 	{
@@ -6036,6 +6036,7 @@ int ProcessShareMemory()
 
 	if(RatedCurrentParsing((char*)ShmSysConfigAndInfo->SysConfig.ModelName, &modelnameInfo) != -1)
 	{
+		DEBUG_INFO("Model name rated power: %d\n", modelnameInfo.ratedPower);
 	 	if((ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') &&
 	 	   ((ShmSysConfigAndInfo->SysConfig.ModelName[1]=='B') ||
 		    (ShmSysConfigAndInfo->SysConfig.ModelName[1]=='K') ||

+ 10 - 6
EVSE/Modularization/ocpp20/Module_OcppBackend20.c

@@ -1058,14 +1058,18 @@ int removeMessageSentFile(void)
 		system(rmFileCmd);
 	}
 
-	memset(rmFileCmd, 0, ARRAY_SIZE(rmFileCmd));
-	if((access("/Storage/OCPP/MessageSent",F_OK))!=-1)
+	stat("/Storage/OCPP/TransactionRelatedQueue20", &stats);
+	if(stats.st_size < 10)
 	{
-		DEBUG_INFO("MessageSent file exist.\n");
-		sprintf(rmFileCmd,"rm -f %s","/Storage/OCPP/MessageSent");
-		system(rmFileCmd);
+		memset(rmFileCmd, 0, ARRAY_SIZE(rmFileCmd));
+		if((access("/Storage/OCPP/MessageSent",F_OK))!=-1)
+		{
+			DEBUG_INFO("MessageSent file exist.\n");
+			sprintf(rmFileCmd,"rm -f %s","/Storage/OCPP/MessageSent");
+			system(rmFileCmd);
+		}
+		memset(rmFileCmd, 0, ARRAY_SIZE(rmFileCmd));
 	}
-	memset(rmFileCmd, 0, ARRAY_SIZE(rmFileCmd));
 
 	return 0;
 }

+ 42 - 4
EVSE/Modularization/ocppfiles/MessageHandler.c

@@ -32,8 +32,9 @@ static int UnknownKeynum 			= 0;
 //===============================
 // Gun Total  Numbers
 //===============================
-static int gunTotalNumber			= 0;
-static uint8_t gunType[4] 			= {0};
+static ParsingRatedCur modelnameInfo	= {0};
+static int gunTotalNumber				= 0;
+static uint8_t gunType[4] 				= {0};
 
 //===============================
 // Local List Version
@@ -3839,7 +3840,6 @@ int InitShareMemory()
 int ProcessShareMemory()
 {
 	int result = PASS;
-	ParsingRatedCur modelnameInfo={0};
 
 	if(InitShareMemory() == FAIL)
 	{
@@ -3856,6 +3856,7 @@ int ProcessShareMemory()
 	// Model name parsing
 	if(RatedCurrentParsing((char*)ShmSysConfigAndInfo->SysConfig.ModelName, &modelnameInfo) != -1)
 	{
+		DEBUG_INFO("Model name rated power: %d\n", modelnameInfo.ratedPower);
 	 	if((ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') &&
 	 	   ((ShmSysConfigAndInfo->SysConfig.ModelName[1]=='B') ||
 		    (ShmSysConfigAndInfo->SysConfig.ModelName[1]=='K') ||
@@ -7871,7 +7872,7 @@ int sendMeterValuesRequest(int gun_index, ReadingContext dataType)
 
 	if((dataType != ReadingContext_Trigger) &&
 	   (dataType != ReadingContext_Sample_Clock) &&
-	   ((ShmOCPP16Data->MeterValues[gun_index].TransactionId != -1) || (strstr((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[QueueOffLineMeterValues].ItemData, "TRUE"))))
+	   ((ShmOCPP16Data->MeterValues[gun_index].TransactionId > 0) || (strstr((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[QueueOffLineMeterValues].ItemData, "TRUE"))))
 		queue_operation(QUEUE_OPERATION_ADD, guid, queuedata );
 	else
 	{
@@ -13118,6 +13119,43 @@ int handleSetChargingProfileRequest(char *uuid, char *payload)
 		goto end;
 	}
 
+	// Check invalid limit
+	if(ShmSysConfigAndInfo->SysConfig.ModelName[0] == 'A')
+	{
+		for(uint8_t idxPeriod=0;idxPeriod<chargingSchedulePeriodCount;idxPeriod++)
+		{
+
+			if(((0 < SetProfileReq.ChargingProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].Limit) && (SetProfileReq.ChargingProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].Limit < (SetProfileReq.ChargingProfile.ChargingSchedule.ChargingRateUnit[0]=='A'?6:6*220*(SetProfileReq.ChargingProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].NumberPhases==0?3:SetProfileReq.ChargingProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].NumberPhases)))) ||
+			   (SetProfileReq.ChargingProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].Limit > (SetProfileReq.ChargingProfile.ChargingSchedule.ChargingRateUnit[0]=='W'?modelnameInfo.ratedPower:ShmSysConfigAndInfo->SysConfig.RatingCurrent)))
+			{
+				sprintf(comfirmstr, "%s", ChargingProfileStatusStr[ChargingProfileStatus_Rejected] );
+				DEBUG_WARN("Profile period-%02d is invalid limit: %.2f %s with phase %d.\n", idxPeriod,
+						 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	     SetProfileReq.ChargingProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].Limit,
+																			                 SetProfileReq.ChargingProfile.ChargingSchedule.ChargingRateUnit,
+																						     (SetProfileReq.ChargingProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].NumberPhases==0?3:SetProfileReq.ChargingProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].NumberPhases));
+
+				goto end;
+			}
+		}
+	}
+	else
+	{
+		for(uint8_t idxPeriod=0;idxPeriod<chargingSchedulePeriodCount;idxPeriod++)
+		{
+
+			if((SetProfileReq.ChargingProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].Limit > (SetProfileReq.ChargingProfile.ChargingSchedule.ChargingRateUnit[0]=='W'?modelnameInfo.ratedPower:modelnameInfo.ParsingInfo[0].Current)))
+			{
+				sprintf(comfirmstr, "%s", ChargingProfileStatusStr[ChargingProfileStatus_Rejected] );
+				DEBUG_WARN("Profile period-%02d is invalid limit: %.2f %s with phase %d.\n", idxPeriod,
+																							 SetProfileReq.ChargingProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].Limit,
+																							 SetProfileReq.ChargingProfile.ChargingSchedule.ChargingRateUnit,
+																							 (SetProfileReq.ChargingProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].NumberPhases==0?3:SetProfileReq.ChargingProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].NumberPhases));
+
+				goto end;
+			}
+		}
+	}
+
 	// Profile purpose info check
 	if(strcmp((char*)SetProfileReq.ChargingProfile.ChargingProfilePurpose, ChargingProfilePurposeTypeStr[ChargePointMaxProfile]) == 0)
 	{

+ 10 - 6
EVSE/Modularization/ocppfiles/Module_OcppBackend.c

@@ -1343,14 +1343,18 @@ int removeMessageSentFile(void)
 		system(rmFileCmd);
 	}
 
-	memset(rmFileCmd, 0, ARRAY_SIZE(rmFileCmd));
-	if((access("/Storage/OCPP/MessageSent",F_OK))!=-1)
+	stat("/Storage/OCPP/TransactionRelatedQueue", &stats);
+	if(stats.st_size < 10)
 	{
-		DEBUG_INFO("MessageSent file exist.\n");
-		sprintf(rmFileCmd,"rm -f %s","/Storage/OCPP/MessageSent");
-		system(rmFileCmd);
+		memset(rmFileCmd, 0, ARRAY_SIZE(rmFileCmd));
+		if((access("/Storage/OCPP/MessageSent",F_OK))!=-1)
+		{
+			DEBUG_INFO("MessageSent file exist.\n");
+			sprintf(rmFileCmd,"rm -f %s","/Storage/OCPP/MessageSent");
+			system(rmFileCmd);
+		}
+		memset(rmFileCmd, 0, ARRAY_SIZE(rmFileCmd));
 	}
-	memset(rmFileCmd, 0, ARRAY_SIZE(rmFileCmd));
 
 	return 0;
 }

+ 42 - 4
EVSE/Modularization/ocppph/MessageHandler.c

@@ -33,8 +33,9 @@ static int UnknownKeynum 			= 0;
 //===============================
 // Gun Total  Numbers
 //===============================
-static int gunTotalNumber			= 0;
-static uint8_t gunType[4] 			= {0};
+static ParsingRatedCur modelnameInfo	= {0};
+static int gunTotalNumber				= 0;
+static uint8_t gunType[4] 				= {0};
 
 //===============================
 // Local List Version
@@ -3556,7 +3557,6 @@ int InitShareMemory()
 int ProcessShareMemory()
 {
 	int result = PASS;
-	ParsingRatedCur modelnameInfo={0};
 
 	if(InitShareMemory() == FAIL)
 	{
@@ -3573,6 +3573,7 @@ int ProcessShareMemory()
 	// Model name parsing
 	if(RatedCurrentParsing((char*)ShmSysConfigAndInfo->SysConfig.ModelName, &modelnameInfo) != -1)
 	{
+		DEBUG_INFO("Model name rated power: %d\n", modelnameInfo.ratedPower);
 	 	if((ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') &&
 	 	   ((ShmSysConfigAndInfo->SysConfig.ModelName[1]=='B') ||
 		    (ShmSysConfigAndInfo->SysConfig.ModelName[1]=='K') ||
@@ -7604,7 +7605,7 @@ int sendMeterValuesRequest(int gun_index, ReadingContext dataType)
 
 	if((dataType != ReadingContext_Trigger) &&
 	   (dataType != ReadingContext_Sample_Clock) &&
-	   ((ShmOCPP16DataPH->MeterValues[gun_index].TransactionId != -1) || (strstr((char *)ShmOCPP16DataPH->ConfigurationTable.CoreProfile[QueueOffLineMeterValues].ItemData, "TRUE"))))
+	   ((ShmOCPP16DataPH->MeterValues[gun_index].TransactionId > 0) || (strstr((char *)ShmOCPP16DataPH->ConfigurationTable.CoreProfile[QueueOffLineMeterValues].ItemData, "TRUE"))))
 		queue_operation(QUEUE_OPERATION_ADD, guid, queuedata );
 	else
 	{
@@ -12858,6 +12859,43 @@ int handleSetChargingProfileRequest(char *uuid, char *payload)
 		goto end;
 	}
 
+	// Check invalid limit
+	if(ShmSysConfigAndInfo->SysConfig.ModelName[0] == 'A')
+	{
+		for(uint8_t idxPeriod=0;idxPeriod<chargingSchedulePeriodCount;idxPeriod++)
+		{
+
+			if(((0 < SetProfileReq.ChargingProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].Limit) && (SetProfileReq.ChargingProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].Limit < (SetProfileReq.ChargingProfile.ChargingSchedule.ChargingRateUnit[0]=='A'?6:6*220*(SetProfileReq.ChargingProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].NumberPhases==0?3:SetProfileReq.ChargingProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].NumberPhases)))) ||
+			   (SetProfileReq.ChargingProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].Limit > (SetProfileReq.ChargingProfile.ChargingSchedule.ChargingRateUnit[0]=='W'?modelnameInfo.ratedPower:ShmSysConfigAndInfo->SysConfig.RatingCurrent)))
+			{
+				sprintf(comfirmstr, "%s", ChargingProfileStatusStr[ChargingProfileStatus_Rejected] );
+				DEBUG_WARN("Profile period-%02d is invalid limit: %.2f %s with phase %d.\n", idxPeriod,
+						 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	     SetProfileReq.ChargingProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].Limit,
+																			                 SetProfileReq.ChargingProfile.ChargingSchedule.ChargingRateUnit,
+																						     (SetProfileReq.ChargingProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].NumberPhases==0?3:SetProfileReq.ChargingProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].NumberPhases));
+
+				goto end;
+			}
+		}
+	}
+	else
+	{
+		for(uint8_t idxPeriod=0;idxPeriod<chargingSchedulePeriodCount;idxPeriod++)
+		{
+
+			if((SetProfileReq.ChargingProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].Limit > (SetProfileReq.ChargingProfile.ChargingSchedule.ChargingRateUnit[0]=='W'?modelnameInfo.ratedPower:modelnameInfo.ParsingInfo[0].Current)))
+			{
+				sprintf(comfirmstr, "%s", ChargingProfileStatusStr[ChargingProfileStatus_Rejected] );
+				DEBUG_WARN("Profile period-%02d is invalid limit: %.2f %s with phase %d.\n", idxPeriod,
+																							 SetProfileReq.ChargingProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].Limit,
+																							 SetProfileReq.ChargingProfile.ChargingSchedule.ChargingRateUnit,
+																							 (SetProfileReq.ChargingProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].NumberPhases==0?3:SetProfileReq.ChargingProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].NumberPhases));
+
+				goto end;
+			}
+		}
+	}
+
 	// Profile purpose info check
 	if(strcmp((char*)SetProfileReq.ChargingProfile.ChargingProfilePurpose, ChargingProfilePurposeTypeStr[ChargePointMaxProfile]) == 0)
 	{

+ 12 - 8
EVSE/Modularization/ocppph/Module_OcppBackend.c

@@ -1344,14 +1344,18 @@ int removeMessageSentFile(void)
 		system(rmFileCmd);
 	}
 
-	memset(rmFileCmd, 0, ARRAY_SIZE(rmFileCmd));
-	if((access("/Storage/OCPP_PH/MessageSent",F_OK))!=-1)
-	{
-		DEBUG_INFO("MessageSent file exist.\n");
-		sprintf(rmFileCmd,"rm -f %s","/Storage/OCPP_PH/MessageSent");
-		system(rmFileCmd);
-	}
-	memset(rmFileCmd, 0, ARRAY_SIZE(rmFileCmd));
+	stat("/Storage/OCPP_PH/TransactionRelatedQueue", &stats);
+    if(stats.st_size < 10)
+    {
+    	memset(rmFileCmd, 0, ARRAY_SIZE(rmFileCmd));
+    	if((access("/Storage/OCPP_PH/MessageSent",F_OK))!=-1)
+    	{
+    		DEBUG_INFO("MessageSent file exist.\n");
+    		sprintf(rmFileCmd,"rm -f %s","/Storage/OCPP_PH/MessageSent");
+    		system(rmFileCmd);
+    	}
+    	memset(rmFileCmd, 0, ARRAY_SIZE(rmFileCmd));
+    }
 
 	return 0;
 }

+ 1 - 1
EVSE/Projects/AW-CCS/Apps/Makefile

@@ -4,7 +4,7 @@ export PATH=/bin:/sbin:/usr/bin:$(SDK_PATH_TARGET)/usr/bin:$PATH
 #define library variable
 Lib_Module_RFID = "-L../../../Modularization" -lModule_RFID
 Lib_Module_Upgrade = "-L../../../Modularization" -lModule_Upgrade
-Lib_Module_RatedCurrent = "-L../../../Modularization" -lModule_RatedCurrent
+Lib_Module_RatedCurrent = "-L../../../Modularization" -lm -lModule_RatedCurrent
 Lib_SQLite3 = "-L../../../Modularization/ocppfiles" -lsqlite3
 Lib_JSONC = "-L../../../GPL/json-c-json-c-0.13.1-20180305/release/lib" -ljson-c
 

+ 1 - 1
EVSE/Projects/AX80/Apps/Makefile

@@ -4,7 +4,7 @@ export PATH=/bin:/sbin:/usr/bin:$(SDK_PATH_TARGET)/usr/bin:$PATH
 #define library variable
 Lib_Module_RFID = "-L../../../Modularization" -lModule_RFID
 Lib_Module_Upgrade = "-L../../../Modularization" -lModule_Upgrade
-Lib_Module_RatedCurrent = "-L../../../Modularization" -lModule_RatedCurrent
+Lib_Module_RatedCurrent = "-L../../../Modularization" -lm -lModule_RatedCurrent
 Lib_SQLite3 = "-L../../../Modularization/ocppfiles" -lsqlite3
 Lib_JSONC = "-L../../../GPL/json-c-json-c-0.13.1-20180305/release/lib" -ljson-c