瀏覽代碼

[Improve][Modularization][Modudle_OcppBackend]

2021.02.18 / Folus Wen

Actions:
1. If OCPPConfiguration file size small than 3100 restore default value to OCPPConfiguration.

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 4 年之前
父節點
當前提交
35217a6f6e

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

@@ -2179,12 +2179,12 @@ int InitShareMemory()
    	//creat ShmOCPP16Data
    	if ((MeterSMId = shmget(ShmOcppModuleKey, sizeof(struct OCPP16Data),  0777)) < 0)
 	{
-		DEBUG_ERROR("shmget ShmOCPP16Data NG");
+		DEBUG_ERROR("shmget ShmOCPP16Data NG\n");
 		result = FAIL;
 	}
 	else if ((ShmOCPP16Data = shmat(MeterSMId, NULL, 0)) == (void *) -1)
 	{
-		DEBUG_ERROR("shmat ShmOCPP16Data NG");
+		DEBUG_ERROR("shmat ShmOCPP16Data NG\n");
 		result = FAIL;
 	}
 	else
@@ -11283,6 +11283,18 @@ int initialConfigurationTable(void)
 	//printf("Starting of the program, start_t = %ld\n", start_t);
 	memset(&(ShmOCPP16Data->ConfigurationTable), 0, sizeof(struct OCPP16ConfigurationTable) );
 
+	// Check configuration file size is correct
+	if((access("/Storage/OCPP/OCPPConfiguration",F_OK))!=-1)
+	{
+		struct stat st;
+		stat("/Storage/OCPP/OCPPConfiguration", &st);
+
+		if(st.st_size < 3100)
+		{
+			system("rm -f /Storage/OCPP/OCPPConfiguration");
+			DEBUG_INFO("OCPPConfiguration file size: %d is too small, restore to default value.\n", st.st_size);
+		}
+	}
 
 	if((access("/Storage/OCPP/OCPPConfiguration",F_OK))==-1)
 	{
@@ -12059,7 +12071,6 @@ int initialConfigurationTable(void)
 	return 0;
 }
 
-
 void StoreConfigurationTable(void)
 {
 	FILE *outfile;
@@ -12531,7 +12542,6 @@ void StoreConfigurationTable(void)
 
 }
 
-
 void getKeyValue(char *keyReq)
 {
 	 int isEmpty = FALSE;

+ 1 - 1
EVSE/Projects/AW-CCS/Apps/main.c

@@ -3302,7 +3302,7 @@ void checkChargingProfileLimit(uint8_t gun_index)
 					(mystrcmp((char*)ShmOCPP20Data->SmartChargingProfile[gun_index].chargingProfilePurpose, "TxProfile") == FAIL))
 				{
 					// Checking limitation
-					for(uint8_t idx_period=0;idx_period<ARRAY_SIZE(ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod);idx_period++)
+					for(uint8_t idx_period=0;idx_period<ARRAY_SIZE(ShmOCPP20Data->SmartChargingProfile[gun_index].chargingSchedule[0].chargingSchedulePeriod);idx_period++)
 					{
 						if((getScheduleStart(gun_index) > ShmOCPP20Data->SmartChargingProfile[gun_index].chargingSchedule[0].chargingSchedulePeriod[idx_period].startPeriod) &&
 						   ((idx_period == 0) || (ShmOCPP20Data->SmartChargingProfile[gun_index].chargingSchedule[0].chargingSchedulePeriod[idx_period].startPeriod > 0))

+ 1 - 1
EVSE/Projects/AW-Regular/Apps/main.c

@@ -3171,7 +3171,7 @@ void checkChargingProfileLimit(uint8_t gun_index)
 					(mystrcmp((char*)ShmOCPP20Data->SmartChargingProfile[gun_index].chargingProfilePurpose, "TxProfile") == FAIL))
 				{
 					// Checking limitation
-					for(uint8_t idx_period=0;idx_period<ARRAY_SIZE(ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod);idx_period++)
+					for(uint8_t idx_period=0;idx_period<ARRAY_SIZE(ShmOCPP20Data->SmartChargingProfile[gun_index].chargingSchedule[0].chargingSchedulePeriod);idx_period++)
 					{
 						if((getScheduleStart(gun_index) > ShmOCPP20Data->SmartChargingProfile[gun_index].chargingSchedule[0].chargingSchedulePeriod[idx_period].startPeriod) &&
 						   ((idx_period == 0) || (ShmOCPP20Data->SmartChargingProfile[gun_index].chargingSchedule[0].chargingSchedulePeriod[idx_period].startPeriod > 0))