Browse Source

[Bug fix][Modularization][Module_OcppBackend]

2020.10.27 / Folus Wen

Actions:
1. EVSE/Projects/define.h element array size modify from 0 to 1 in struct StructMeterValues.
2. EVSE/Modularization/ocppfiles/MessageHandler.c SOC data in MeterValue chaneg location attribute to Location_EV.

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 years ago
parent
commit
96937458d6
2 changed files with 4 additions and 6 deletions
  1. 3 5
      EVSE/Modularization/ocppfiles/MessageHandler.c
  2. 1 1
      EVSE/Projects/define.h

+ 3 - 5
EVSE/Modularization/ocppfiles/MessageHandler.c

@@ -5479,7 +5479,7 @@ int sendMeterValuesRequest(int gun_index, ReadingContext dataType)
 		strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[5].Format, ValueFormatStr[Raw]);
 		strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[5].Measurand, MeasurandStr[SoC]);
 		strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[5].Phase, PhaseStr[L3_N]);
-		strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[5].Location, LocationStr[Location_Outlet]);
+		strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[5].Location, LocationStr[Location_EV]);
 		strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[0].SampledValue[5].Unit,UnitOfMeasureStr[UnitOfMeasure_Percent]);
 	}
 
@@ -5609,8 +5609,7 @@ int sendMeterValuesRequest(int gun_index, ReadingContext dataType)
 		if(ShmOCPP16Data->MeterValues[gun_index].TransactionId != -1)
 			json_object_object_add(MeterValueReq, "transactionId", json_object_new_int(ShmOCPP16Data->MeterValues[gun_index].TransactionId));
 
-		uint8_t idxMeter = 0;
-		while(strlen((char*)ShmOCPP16Data->MeterValues[gun_index].MeterValue[idxMeter].TimeStamp) > 0)
+		for(uint8_t idxMeter=0;idxMeter<ARRAY_SIZE(ShmOCPP16Data->MeterValues[gun_index].MeterValue);idxMeter++)
 		{
 			json_object *MeterValue = json_object_new_object();
 
@@ -5646,7 +5645,6 @@ int sendMeterValuesRequest(int gun_index, ReadingContext dataType)
 			json_object_object_add(MeterValue, "timestamp", json_object_new_string((char*)ShmOCPP16Data->MeterValues[gun_index].MeterValue[idxMeter].TimeStamp));
 			json_object_object_add(MeterValue, "sampledValue", sampledValues);
 			json_object_array_add(MeterValues, MeterValue);
-			idxMeter++;
 		}
 		json_object_object_add(MeterValueReq, "meterValue", MeterValues);
 
@@ -5657,7 +5655,7 @@ int sendMeterValuesRequest(int gun_index, ReadingContext dataType)
 		 	 			 ,json_object_to_json_string_ext(MeterValueReq, JSON_C_TO_STRING_PLAIN));
 
 		json_object_put(MeterValueReq);
-	 }
+	}
 
 	// Put request guid to hash map
 	sprintf(tempdata, "MeterValues,%d", (gun_index));

+ 1 - 1
EVSE/Projects/define.h

@@ -3911,7 +3911,7 @@ struct StructMeterValues
 {
 	int					 			ConnectorId;
 	int 							TransactionId;
-	struct StructMeterValue			MeterValue[0];
+	struct StructMeterValue			MeterValue[1];
 };
 struct StructRemoteStartTransaction
 {