Parcourir la source

2022-10-03 /Yuanda Tsai / action : 1. fixed OCMF string lenght issue (string lenght to 2048 2.log record /Files: Module_DcMeter.c Module_DcMeter.h curlApi.c meterComm.h

Yuanda_Tsai il y a 2 ans
Parent
commit
5226cc6dce

+ 45 - 15
EVSE/Modularization/DcMeter/Module_DcMeter.c

@@ -8,7 +8,7 @@
 #include "meterComm.h"
 #include "Module_RatedCurrent.h"
 
-#define _DEBUG_ 1
+#define _DEBUG_ 0
 
 #if _DEBUG_
 #define PR(...) printf(__VA_ARGS__)
@@ -89,6 +89,12 @@ int main(void)
 	Meter_transaction_Action meter_read_transaction_record[4];
 	Meter_transaction_Action meter_transaction_Action[4];
 	Meter_transaction_Result meter_transaction_Result[4];
+	//log use
+	Meter_Info before_meter_info[4];
+	uint8_t before_failCount[4];
+	Meter_transaction_Action before_meter_transaction_Action[4];
+	Meter_transaction_Action before_meter_read_transaction_record[4];
+	
 	uint8_t failCount[4];
 	uint8_t startTransactionFailCount[4];
 	uint8_t stopTransactionFailCount[4];
@@ -153,8 +159,8 @@ int main(void)
 	DEBUG_INFO("shm ");
 	#endif
 	
-	printf("modelnameInfo.GetGunCount : %d \n", modelnameInfo.GetGunCount);
-	DEBUG_INFO("modelnameInfo.GetGunCount : %d \n", modelnameInfo.GetGunCount);
+	printf("modelnameInfo.GetGunCount : %d \n\n\n", modelnameInfo.GetGunCount);
+	DEBUG_INFO("modelnameInfo.GetGunCount : %d \n\n\n", modelnameInfo.GetGunCount);
 	
 
 	
@@ -178,6 +184,28 @@ int main(void)
 					meter_read_transaction_record[gun_index].ActionCmd = ShmSysConfigAndInfo->SysInfo.DcMeterReadTransactionRecord[gun_index].ActionCmd;
 					meter_read_transaction_record[gun_index].OcmfInfoReady = ShmSysConfigAndInfo->SysInfo.DcMeterReadTransactionRecord[gun_index].OcmfInfoReady;
 					meter_transaction_Action[gun_index].OcmfInfoReady = ShmSysConfigAndInfo->SysInfo.DcMeterTransactionAction[gun_index].OcmfInfoReady;
+					
+					if(before_meter_transaction_Action[gun_index].ActionCmd != ShmSysConfigAndInfo->SysInfo.DcMeterTransactionAction[gun_index].ActionCmd || 
+					before_meter_transaction_Action[gun_index].OcmfInfoReady != ShmSysConfigAndInfo->SysInfo.DcMeterTransactionAction[gun_index].OcmfInfoReady ||
+					before_meter_read_transaction_record[gun_index].ActionCmd != ShmSysConfigAndInfo->SysInfo.DcMeterReadTransactionRecord[gun_index].ActionCmd || 
+					before_meter_read_transaction_record[gun_index].OcmfInfoReady != ShmSysConfigAndInfo->SysInfo.DcMeterReadTransactionRecord[gun_index].OcmfInfoReady ||
+					before_meter_info[gun_index].LinkStatus != meter_info[gun_index].LinkStatus || 
+					before_failCount[gun_index] != failCount[gun_index])
+					{
+						DEBUG_INFO("shm Meter %d - LinkStatus %d :  failCount: %d   ActionCmd: %d  OcmpInfoReady: %d RecordActionCmd: %d RecordOcmpInfoReady: %d \n", gun_index, 
+						meter_info[gun_index].LinkStatus,failCount[gun_index] ,
+						ShmSysConfigAndInfo->SysInfo.DcMeterTransactionAction[gun_index].ActionCmd ,
+						ShmSysConfigAndInfo->SysInfo.DcMeterTransactionAction[gun_index].OcmfInfoReady,
+						ShmSysConfigAndInfo->SysInfo.DcMeterReadTransactionRecord[gun_index].ActionCmd ,
+						ShmSysConfigAndInfo->SysInfo.DcMeterReadTransactionRecord[gun_index].OcmfInfoReady);
+						
+						before_meter_transaction_Action[gun_index].ActionCmd = ShmSysConfigAndInfo->SysInfo.DcMeterTransactionAction[gun_index].ActionCmd;
+						before_meter_transaction_Action[gun_index].OcmfInfoReady = ShmSysConfigAndInfo->SysInfo.DcMeterTransactionAction[gun_index].OcmfInfoReady;
+						before_meter_read_transaction_record[gun_index].ActionCmd = ShmSysConfigAndInfo->SysInfo.DcMeterReadTransactionRecord[gun_index].ActionCmd;
+						before_meter_read_transaction_record[gun_index].OcmfInfoReady = ShmSysConfigAndInfo->SysInfo.DcMeterReadTransactionRecord[gun_index].OcmfInfoReady;
+						before_meter_info[gun_index].LinkStatus = meter_info[gun_index].LinkStatus;
+						before_failCount[gun_index] = failCount[gun_index];
+					}
 					#endif
 					
 					
@@ -386,7 +414,8 @@ int main(void)
 														DEBUG_INFO(" %-26s : %s\n\n\n\n\n\n", "signature", ShmSysConfigAndInfo->SysInfo.DcMeterTransactionResult[gun_index].signature);												
 														#endif
 												 
-												#else
+												#else	//DEBUG_STANDALONG
+												
 														#ifdef DEBUG_STANDALONE_TRANSACTION_RESULT_LOG
 														DEBUG_INFO(" ================================= Standalone Transaction Result : %d ================================= \n",gun_index);
 														DEBUG_INFO(" %-26s : %d\n", "paginationCounter", meter_transaction_Result[gun_index].paginationCounter);										
@@ -409,7 +438,8 @@ int main(void)
 														DEBUG_INFO(" %-26s : %.3f\n", "energyExportTotalStop", gun_index, meter_transaction_Result[gun_index].energyExportTotalStop);
 														DEBUG_INFO(" %-26s : %s\n\n\n\n\n\n", "signature", meter_transaction_Result[gun_index].signature);
 														#endif
-												#endif//DEBUG_STANDALONG
+														
+												#endif	//DEBUG_STANDALONG
 					
 												failCount[gun_index] = 0;
 												stopTransactionFailCount[gun_index] = 0;
@@ -436,15 +466,17 @@ int main(void)
 															
 																	#ifdef DEBUG_SHAREMEM_TRANSACTION_RESULT_LOG
 																	DEBUG_INFO("shm transactionOCMF %d : %s\n", gun_index, ShmSysConfigAndInfo->SysInfo.DcMeterTransactionAction[gun_index].transactionOCMF);															
+																	DEBUG_INFO("shm publicKeyOCMF   %d : %s\n\n\n", gun_index, ShmSysConfigAndInfo->SysInfo.DcMeterStatusInfo[gun_index].publicKeyOcmf);
 																	#endif
 															 
-															#else
+															#else	//DEBUG_STANDALONG
 															
 																PR("OCMF : %s\n",meter_transaction_Action[gun_index].transactionOCMF);
 																				   
 																	#ifdef DEBUG_STANDALONE_TRANSACTION_RESULT_LOG
 																	DEBUG_INFO("transactionOCMF %d : %s\n", gun_index, meter_transaction_Action[gun_index].transactionOCMF);
-																	#endif													
+																	#endif	
+																													
 															#endif//DEBUG_STANDALONG	
 															
 															meter_transaction_Action[gun_index].OcmfInfoReady = 1;
@@ -522,7 +554,8 @@ int main(void)
 
 															
 																	#ifdef DEBUG_SHAREMEM_TRANSACTION_RESULT_LOG
-																	DEBUG_INFO("shm transactionOCMF %d : %s\n", gun_index, ShmSysConfigAndInfo->SysInfo.DcMeterReadTransactionRecord[gun_index].transactionOCMF);															
+																	DEBUG_INFO("shm record transactionOCMF %d : %s\n", gun_index, ShmSysConfigAndInfo->SysInfo.DcMeterReadTransactionRecord[gun_index].transactionOCMF);															
+																	DEBUG_INFO("shm record publicKeyOCMF   %d : %s\n\n\n", gun_index, ShmSysConfigAndInfo->SysInfo.DcMeterStatusInfo[gun_index].publicKeyOcmf);
 																	#endif
 																	 
 																	#else
@@ -865,12 +898,7 @@ int main(void)
 			}
 				
 			#ifndef DEBUG_STANDALONG
-			DEBUG_INFO("shm Meter %d - LinkStatus %d :  failCount: %d   ActionCmd: %d  OcmpInfoReady: %d\n RecordActionCmd: %d RecordOcmpInfoReady: %d", gun_index, 
-			meter_info[gun_index].LinkStatus,failCount[gun_index] ,
-			ShmSysConfigAndInfo->SysInfo.DcMeterTransactionAction[gun_index].ActionCmd ,
-			ShmSysConfigAndInfo->SysInfo.DcMeterTransactionAction[gun_index].OcmfInfoReady,
-			ShmSysConfigAndInfo->SysInfo.DcMeterReadTransactionRecord[gun_index].ActionCmd ,
-			ShmSysConfigAndInfo->SysInfo.DcMeterReadTransactionRecord[gun_index].OcmfInfoReady);
+			
 			PR ("===================   ModelName %s\n", ShmSysConfigAndInfo->SysConfig.ModelName);
 			PR("end : %d  ActionCmd : %d OcmfInfoReady : %d RecordActionCmd: %d RecordOcmpInfoReady: %d \n", gun_index,ShmSysConfigAndInfo->SysInfo.DcMeterTransactionAction[gun_index].ActionCmd, 
 			ShmSysConfigAndInfo->SysInfo.DcMeterTransactionAction[gun_index].OcmfInfoReady,
@@ -882,12 +910,14 @@ int main(void)
 			
 			
 			#else
-			DEBUG_INFO("Meter %d - LinkStatus %d :  failCount: %d  ActionCmd: %d  OcmpInfoReady: %d RecordActionCmd: %d RecordOcmpInfoReady: %d\n", gun_index,
+			/*
+			DEBUG_INFO("Meter %d - LinkStatus %d :  failCount: %d  ActionCmd: %d  OcmpInfoReady: %d RecordActionCmd: %d RecordOcmpInfoReady: %d \n", gun_index,
 			meter_info[gun_index].LinkStatus,failCount[gun_index] ,
 			meter_transaction_Action[gun_index].ActionCmd ,
 			meter_transaction_Action[gun_index].OcmfInfoReady,
 			meter_read_transaction_record[gun_index].ActionCmd ,
 			meter_read_transaction_record[gun_index].OcmfInfoReady);
+			*/
 			
 			PR ("===================   STAND ALONE\n");
 			PR("end : %d  ActionCmd : %d OcmfInfoReady : %d RecordActionCmd: %d RecordOcmpInfoReady: %d \n", gun_index,meter_transaction_Action[gun_index].ActionCmd, 

+ 5 - 5
EVSE/Modularization/DcMeter/Module_DcMeter.h

@@ -42,16 +42,16 @@
 //#define	DEBUG_STANDALONG
 //#define ConsloePrintLog
 #ifndef DEBUG_STANDALONG
-//#define DEBUG_STANDALONG_STATUS_INFO_LOG
-//#define DEBUG_STANDALONG_LIVEMEASURE_LOG
-//#define DEBUG_STANDALONG_TRANSACTION_START_LOG
-//#define DEBUG_STANDALONG_TRANSACTION_RESULT_LOG
-#else
 //#define DEBUG_SHAREMEM_LOG
 //#define DEBUG_SHAREMEM_STATUS_INFO_LOG
 //#define DEBUG_SHAREMEM_LIVEMEASURE_LOG
 //#define DEBUG_SHAREMEM_TRANSACTION_START_LOG
 #define DEBUG_SHAREMEM_TRANSACTION_RESULT_LOG
+#else
+//#define DEBUG_STANDALONG_STATUS_INFO_LOG
+//#define DEBUG_STANDALONG_LIVEMEASURE_LOG
+//#define DEBUG_STANDALONG_TRANSACTION_START_LOG
+#define DEBUG_STANDALONG_TRANSACTION_RESULT_LOG
 #endif
 
 #define ARRAY_SIZE(A)				(sizeof(A) / sizeof(A[0]))

+ 3 - 1
EVSE/Modularization/DcMeter/curlApi.c

@@ -200,6 +200,8 @@ int httpPut(uint8_t *url, uint8_t *postData, uint8_t *responseData)
 
 	curl_global_init(CURL_GLOBAL_ALL);
 	curl = curl_easy_init();
+	
+	memset(&chunk, 0x00, sizeof(struct MemoryStruct));
 
 	if(curl)
 	{	struct curl_slist*        headerlist    = NULL;
@@ -237,7 +239,7 @@ int httpPut(uint8_t *url, uint8_t *postData, uint8_t *responseData)
 		 {
 			 if(chunk.size > 0)
 			 {
-				 DEBUG_INFO("Response content: %s\n", chunk.memory);
+				 //DEBUG_INFO("Response content: %s\n", chunk.memory);
 				 memcpy(responseData, chunk.memory, ARRAY_SIZE(chunk.memory));
 			 }
 

+ 1 - 1
EVSE/Modularization/DcMeter/meterComm.h

@@ -127,7 +127,7 @@ typedef struct METER_TRANSACTION_HEAD
 typedef struct METER_TRANSACTION_ACTION
 {
 		Meter_transaction_Head head;
-		unsigned char transactionOCMF[512];
+		unsigned char transactionOCMF[2048];
 		unsigned char OcmfInfoReady;               // 0 = nothing, 1 = ocmp info ready
     unsigned char ActionCmd;                   //  0 = nothing ,1 = transaction Start , 2 transaction Stop , sync time