瀏覽代碼

Merge LED feature improve modify from alston.

2020.06.16 / TC Hsu

Actions: Change the check method in the Config_Led_Color() function. Modify the LED self test mechanism, if the LED self test failure, it will only rising the LedboardStestFail flag, the system still can be working without LED.

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_InternalComm.c
	modified:   EVSE/Projects/DM30/Apps/internalComm.c
	modified:   EVSE/Projects/DW30/Apps/Module_InternalComm.c
	modified:   EVSE/Projects/DW30/Apps/internalComm.c
TC_Hsu 4 年之前
父節點
當前提交
bfd9ce8a08

+ 17 - 1
EVSE/Projects/DM30/Apps/Module_InternalComm.c

@@ -114,6 +114,7 @@ struct timeb    _ac_startChargingTime;
 struct timeb    _ac_endChargingTime;
 
 unsigned short _setFanSpeed = 0;
+byte _checkLedChanged = 3;
 
 Ver ver;
 PresentInputVoltage inputVoltage;
@@ -1154,10 +1155,12 @@ void SetLedColor(struct ChargingInfoData *chargingData_1, struct ChargingInfoDat
         led_color.Connect_2_Red     = COLOR_MAX_LV;
     }
 
-    if (IsNoneMatchLedColor())
+    if (_checkLedChanged > 0)
     {
         if (Config_Led_Color(Uart5Fd, Addr.Led, &led_color) == PASS)
     {
+            _checkLedChanged--;
+
             cur_led_color.Connect_1_Red = led_color.Connect_1_Red;
             cur_led_color.Connect_1_Green = led_color.Connect_1_Green;
             cur_led_color.Connect_1_Blue = led_color.Connect_1_Blue;
@@ -1166,6 +1169,8 @@ void SetLedColor(struct ChargingInfoData *chargingData_1, struct ChargingInfoDat
             cur_led_color.Connect_2_Blue = led_color.Connect_2_Blue;
         }
     }
+    else if (IsNoneMatchLedColor())
+        _checkLedChanged = 3;
 }
 //==========================================
 // Init all share memory
@@ -1962,12 +1967,23 @@ int main(void)
             gettimeofday(&_priority_time, NULL);
         }
 
+        // 自檢階段處理,自檢階段如果讀不到版號則代表該系統沒有掛燈板
         if (ShmLedModuleData->SelfTest_Comp == NO)
         {
+            // 自檢階段
+            if (ShmSysConfigAndInfo->SysInfo.SelfTestSeq <= _STEST_PSU_CAP)
+            {
             GetFwAndHwVersion_Led();
             sleep(1);
             gettimeofday(&_led_priority_time, NULL);
         }
+            else
+            {
+                // 自檢階段沒有問到版號
+                if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.LedboardStestFail == NO)
+                    ShmStatusCodeData->AlarmCode.AlarmEvents.bits.LedboardStestFail = YES;
+            }
+        }
 
         AcChargeTypeProcess();
 

+ 7 - 3
EVSE/Projects/DM30/Apps/internalComm.c

@@ -1206,9 +1206,13 @@ unsigned char Config_Led_Color(unsigned char fd, unsigned char targetAddr, Led_C
         chksum ^= tx[6 + idx];
     tx[13] = chksum;
 
-    if (tranceive(fd, tx, sizeof(tx), rx) > 0)
+    unsigned char len = tranceive(fd, tx, sizeof(tx), rx);
+
+    if(len > 6)
     {
-        chksum = 0x00;
+        if (len < 6+(rx[4] | rx[5]<<8))
+            return result;
+
         for (int idx = 0; idx < (rx[4] | rx[5] << 8); idx++)
         {
             chksum ^= rx[6 + idx];
@@ -1218,7 +1222,7 @@ unsigned char Config_Led_Color(unsigned char fd, unsigned char targetAddr, Led_C
                 (rx[2] == tx[1]) &&
                 (rx[1] == tx[2]) &&
                 (rx[3] == tx[3]) &&
-                rx[6] == PASS)
+                (rx[6] == PASS))
         {
             result = PASS;
         }

+ 17 - 1
EVSE/Projects/DW30/Apps/Module_InternalComm.c

@@ -114,6 +114,7 @@ struct timeb    _ac_startChargingTime;
 struct timeb    _ac_endChargingTime;
 
 unsigned short _setFanSpeed = 0;
+byte _checkLedChanged = 3;
 
 Ver ver;
 PresentInputVoltage inputVoltage;
@@ -1154,10 +1155,12 @@ void SetLedColor(struct ChargingInfoData *chargingData_1, struct ChargingInfoDat
         led_color.Connect_2_Red     = COLOR_MAX_LV;
     }
 
-    if (IsNoneMatchLedColor())
+    if (_checkLedChanged > 0)
     {
         if (Config_Led_Color(Uart5Fd, Addr.Led, &led_color) == PASS)
     {
+            _checkLedChanged--;
+
             cur_led_color.Connect_1_Red = led_color.Connect_1_Red;
             cur_led_color.Connect_1_Green = led_color.Connect_1_Green;
             cur_led_color.Connect_1_Blue = led_color.Connect_1_Blue;
@@ -1166,6 +1169,8 @@ void SetLedColor(struct ChargingInfoData *chargingData_1, struct ChargingInfoDat
             cur_led_color.Connect_2_Blue = led_color.Connect_2_Blue;
         }
     }
+    else if (IsNoneMatchLedColor())
+        _checkLedChanged = 3;
 }
 //==========================================
 // Init all share memory
@@ -1962,12 +1967,23 @@ int main(void)
             gettimeofday(&_priority_time, NULL);
         }
 
+        // 自檢階段處理,自檢階段如果讀不到版號則代表該系統沒有掛燈板
         if (ShmLedModuleData->SelfTest_Comp == NO)
         {
+            // 自檢階段
+            if (ShmSysConfigAndInfo->SysInfo.SelfTestSeq <= _STEST_PSU_CAP)
+            {
             GetFwAndHwVersion_Led();
             sleep(1);
             gettimeofday(&_led_priority_time, NULL);
         }
+            else
+            {
+                // 自檢階段沒有問到版號
+                if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.LedboardStestFail == NO)
+                    ShmStatusCodeData->AlarmCode.AlarmEvents.bits.LedboardStestFail = YES;
+            }
+        }
 
         AcChargeTypeProcess();
 

+ 7 - 3
EVSE/Projects/DW30/Apps/internalComm.c

@@ -1206,9 +1206,13 @@ unsigned char Config_Led_Color(unsigned char fd, unsigned char targetAddr, Led_C
         chksum ^= tx[6 + idx];
     tx[13] = chksum;
 
-    if (tranceive(fd, tx, sizeof(tx), rx) > 0)
+    unsigned char len = tranceive(fd, tx, sizeof(tx), rx);
+
+    if(len > 6)
     {
-        chksum = 0x00;
+        if (len < 6+(rx[4] | rx[5]<<8))
+            return result;
+
         for (int idx = 0; idx < (rx[4] | rx[5] << 8); idx++)
         {
             chksum ^= rx[6 + idx];
@@ -1218,7 +1222,7 @@ unsigned char Config_Led_Color(unsigned char fd, unsigned char targetAddr, Led_C
                 (rx[2] == tx[1]) &&
                 (rx[1] == tx[2]) &&
                 (rx[3] == tx[3]) &&
-                rx[6] == PASS)
+                (rx[6] == PASS))
         {
             result = PASS;
         }