Prechádzať zdrojové kódy

2020.04.02 / TC Hsu

Actions: Update Module_EventLogging.c to fixed the bug for error code
redundent display.

Image version    : N/A
Image checksum   : N/A

Hardware PWB P/N : N/A
Hardware Version : N/A

Files:

	modified:   EVSE/Projects/DM30/Apps/Module_EventLogging.c
TC_Hsu 5 rokov pred
rodič
commit
6cc03ee004
1 zmenil súbory, kde vykonal 34 pridanie a 30 odobranie
  1. 34 30
      EVSE/Projects/DM30/Apps/Module_EventLogging.c

+ 34 - 30
EVSE/Projects/DM30/Apps/Module_EventLogging.c

@@ -31,6 +31,8 @@
 #define ARRAY_SIZE(A)       (sizeof(A) / sizeof(A[0]))
 #define PASS                1
 #define FAIL                -1
+#define YES                 1
+#define NO                  0
 
 struct SysConfigAndInfo         *ShmSysConfigAndInfo;
 struct StatusCodeData           *ShmStatusCodeData;
@@ -84,7 +86,7 @@ void PRINTF_FUNC(char *string, ...)
     vsnprintf(buffer, sizeof(buffer), string, args);
     va_end(args);
 
-    if (DEBUG)
+    if (ShmSysConfigAndInfo->SysConfig.SwitchDebugFlag == YES)
         printf("%s \n", buffer);
     else
         DEBUG_INFO("%s \n", buffer);
@@ -167,38 +169,40 @@ void AddFaultCodeToBuf(unsigned char *Code)
 
 void RemoveFaultCodeToBuf(unsigned char *Code)
 {
-    unsigned char find = 0x00;
+    unsigned char find = 0x01;
     char _code[7];
     sprintf(_code,"%s", Code);
 
-	// 把相關的錯誤碼一次移除,避免重複顯示
-	while(!find)
-	{
-		for(unsigned char i = 0; i < ShmSysConfigAndInfo->SysWarningInfo.WarningCount; i++)
-		{
-			if (find == 0x00)
-			{
-				if(memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][0], _code, 7) != 0)
-				{
-					find = 0x01;
-				}
-			}
-			else
-			{
-				if(i == ShmSysConfigAndInfo->SysWarningInfo.WarningCount - 1)
-				{
-					memcpy(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][0], "", 7);
-				}
-				else
-				{
-					memcpy(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][0],
-							&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + 1][0], 7);
-				}
-			}
-		}
+    // 把相關的錯誤碼一次移除,避免重複顯示
+    while(find)
+    {
+        find = 0x00;
+        for(unsigned char i = 0; i < ShmSysConfigAndInfo->SysWarningInfo.WarningCount; i++)
+        {
+            if (find == 0x00)
+            {
+                if(memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][0], _code, 7) == 0)
+                {
+                    find = 0x01;
+                }
+            }
+            else
+            {
+                if(i == ShmSysConfigAndInfo->SysWarningInfo.WarningCount - 1)
+                {
+                    memcpy(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][0], "", 7);
+                }
+                else
+                {
+                    memcpy(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][0],
+                            &ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + 1][0], 7);
+                }
+            }
+        }
 
-		ShmSysConfigAndInfo->SysWarningInfo.WarningCount--;
-	}
+        if (find)
+            ShmSysConfigAndInfo->SysWarningInfo.WarningCount--;
+    }
 }
 
 int main(void)
@@ -282,7 +286,7 @@ int main(void)
         }
 
         //check Info Status
-        for(ByteCount=0;ByteCount<30;ByteCount++)
+        for(ByteCount=0;ByteCount<40;ByteCount++)
         {
             if(ShmStatusCodeData->InfoCode.InfoEvents.InfoVal[ByteCount] != ShmStatusCodeData->InfoCode.PreviousInfoVal[ByteCount])
             {