فهرست منبع

[Improve][DM30][DW30][UART tranceive]: Replace some tranceive() function to tranceiveRelDelayTime() function for improve.

2020.06.16 / TC Hsu

Actions: For some UART config function, replace tranceive() function to tranceiveRelDelayTime() function to improve.

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

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

Files:

	modified:   EVSE/Projects/DM30/Apps/internalComm.c
	modified:   EVSE/Projects/DW30/Apps/internalComm.c
TC_Hsu 4 سال پیش
والد
کامیت
6b7d813794
2فایلهای تغییر یافته به همراه52 افزوده شده و 36 حذف شده
  1. 26 18
      EVSE/Projects/DM30/Apps/internalComm.c
  2. 26 18
      EVSE/Projects/DW30/Apps/internalComm.c

+ 26 - 18
EVSE/Projects/DM30/Apps/internalComm.c

@@ -518,7 +518,8 @@ unsigned char Config_Fan_Speed(unsigned char fd, unsigned char targetAddr, FanSp
         if((chksum == rx[6+(rx[4] | rx[5]<<8)]) &&
            (rx[2] == tx[1]) &&
            (rx[1] == tx[2]) &&
-           (rx[3] == tx[3]))
+           (rx[3] == tx[3]) &&
+           rx[6] == PASS)
         {
             result = PASS;
         }
@@ -561,7 +562,7 @@ unsigned char Config_Relay_Output(unsigned char fd, unsigned char targetAddr, Re
            (rx[2] == tx[1]) &&
            (rx[1] == tx[2]) &&
            (rx[3] == tx[3]) &&
-           (rx[6] == 0x01))
+           rx[6] == PASS)
         {
             result = PASS;
         }
@@ -686,7 +687,8 @@ unsigned char Config_Model_Name(unsigned char fd, unsigned char targetAddr, unsi
         if((chksum == rx[6+(rx[4] | rx[5]<<8)]) &&
               (rx[2] == tx[1]) &&
               (rx[1] == tx[2]) &&
-              (rx[3] == tx[3]))
+              (rx[3] == tx[3]) &&
+              rx[6] == PASS)
         {
             result = PASS;
         }
@@ -719,7 +721,8 @@ unsigned char Config_Rtc_Data(unsigned char fd, unsigned char targetAddr, Rtc *S
         if((chksum == rx[6+(rx[4] | rx[5]<<8)]) &&
                 (rx[2] == tx[1]) &&
                 (rx[1] == tx[2]) &&
-                (rx[3] == tx[3]))
+                (rx[3] == tx[3]) &&
+                rx[6] == PASS)
         {
             result = PASS;
         }
@@ -880,7 +883,7 @@ unsigned char Query_AC_Status(unsigned char fd, unsigned char targetAddr, Ac_Sta
     unsigned char tx[7] = {0xaa, 0x00, targetAddr, Cmd.query_ac_status, 0x00, 0x00, 0x00};
     unsigned char rx[512];
     unsigned char chksum = 0x00;
-    unsigned char len = tranceive(fd, tx, sizeof(tx), rx);
+    unsigned char len = tranceiveRelDelayTime(fd, tx, sizeof(tx), rx, 100);
 
     if(len > 6)
     {
@@ -940,7 +943,7 @@ unsigned char Query_AC_Alarm_Code(unsigned char fd, unsigned char targetAddr, Ac
     unsigned char tx[7] = {0xaa, 0x00, targetAddr, Cmd.query_ac_alarm_code, 0x00, 0x00};
     unsigned char rx[512];
     unsigned char chksum = 0x00;
-    unsigned char len = tranceive(fd, tx, sizeof(tx), rx);
+    unsigned char len = tranceiveRelDelayTime(fd, tx, sizeof(tx), rx, 100);
 
     if(len > 6)
     {
@@ -971,7 +974,7 @@ unsigned char Query_Charging_Energy(unsigned char fd, unsigned char targetAddr,
     unsigned char tx[7] = {0xaa, 0x00, targetAddr, Cmd.query_ac_output_energy, 0x00, 0x00,0x00};
     unsigned char rx[512];
     unsigned char chksum = 0x00;
-    unsigned char len = tranceive(fd, tx, sizeof(tx), rx);
+    unsigned char len = tranceiveRelDelayTime(fd, tx, sizeof(tx), rx, 100);
 
     if(len > 6)
     {
@@ -1002,7 +1005,7 @@ unsigned char Query_Charging_Current(unsigned char fd, unsigned char targetAddr,
     unsigned char tx[7] = {0xaa, 0x00, targetAddr, Cmd.query_ac_output_current, 0x00, 0x00, 0x00};
     unsigned char rx[512];
     unsigned char chksum = 0x00;
-    unsigned char len = tranceive(fd, tx, sizeof(tx), rx);
+    unsigned char len = tranceiveRelDelayTime(fd, tx, sizeof(tx), rx, 100);
 
     if(len > 6)
     {
@@ -1041,7 +1044,7 @@ unsigned char Config_LED_Status(unsigned char fd, unsigned char targetAddr, Ac_L
         chksum ^= tx[6 + idx];
     tx[11] = chksum;
 
-    if (tranceive(fd, tx, sizeof(tx), rx) > 0)
+    if (tranceiveRelDelayTime(fd, tx, sizeof(tx), rx, 100) > 0)
     {
         chksum = 0x00;
         for (int idx = 0; idx < (rx[4] | rx[5] << 8); idx++)
@@ -1052,7 +1055,8 @@ unsigned char Config_LED_Status(unsigned char fd, unsigned char targetAddr, Ac_L
         if((chksum == rx[6+(rx[4] | rx[5]<<8)]) &&
             (rx[2] == tx[1]) &&
             (rx[1] == tx[2]) &&
-            (rx[3] == tx[3]))
+            (rx[3] == tx[3]) &&
+            rx[6] == PASS)
         {
             result = PASS;
         }
@@ -1072,7 +1076,7 @@ unsigned char Config_Legacy_Req(unsigned char fd, unsigned char targetAddr, unsi
         chksum ^= tx[6 + idx];
     tx[8] = chksum;
 
-    if (tranceive(fd, tx, sizeof(tx), rx) > 0)
+    if (tranceiveRelDelayTime(fd, tx, sizeof(tx), rx, 100) > 0)
     {
         chksum = 0x00;
         for (int idx = 0; idx < (rx[4] | rx[5] << 8); idx++)
@@ -1083,7 +1087,8 @@ unsigned char Config_Legacy_Req(unsigned char fd, unsigned char targetAddr, unsi
         if((chksum == rx[6+(rx[4] | rx[5]<<8)]) &&
            (rx[2] == tx[1]) &&
            (rx[1] == tx[2]) &&
-           (rx[3] == tx[3]))
+           (rx[3] == tx[3]) &&
+           rx[6] == PASS)
         {
             result = PASS;
         }
@@ -1103,7 +1108,7 @@ unsigned char Config_Ac_Duty(unsigned char fd, unsigned char targetAddr, unsigne
         chksum ^= tx[6 + idx];
     tx[7] = chksum;
 
-    if (tranceive(fd, tx, sizeof(tx), rx) > 0)
+    if (tranceiveRelDelayTime(fd, tx, sizeof(tx), rx, 100) > 0)
     {
         chksum = 0x00;
         for (int idx = 0; idx < (rx[4] | rx[5] << 8); idx++)
@@ -1114,7 +1119,8 @@ unsigned char Config_Ac_Duty(unsigned char fd, unsigned char targetAddr, unsigne
         if((chksum == rx[6+(rx[4] | rx[5]<<8)]) &&
            (rx[2] == tx[1]) &&
            (rx[1] == tx[2]) &&
-           (rx[3] == tx[3]))
+           (rx[3] == tx[3]) &&
+           rx[6] == PASS)
         {
             result = PASS;
         }
@@ -1134,7 +1140,7 @@ unsigned char Config_CSU_Mode(unsigned char fd, unsigned char targetAddr)
         chksum ^= tx[6 + idx];
     tx[7] = chksum;
 
-    if (tranceive(fd, tx, sizeof(tx), rx) > 0)
+    if (tranceiveRelDelayTime(fd, tx, sizeof(tx), rx, 100) > 0)
     {
         chksum = 0x00;
         for (int idx = 0; idx < (rx[4] | rx[5] << 8); idx++)
@@ -1145,7 +1151,8 @@ unsigned char Config_CSU_Mode(unsigned char fd, unsigned char targetAddr)
         if((chksum == rx[6+(rx[4] | rx[5]<<8)]) &&
            (rx[2] == tx[1]) &&
            (rx[1] == tx[2]) &&
-           (rx[3] == tx[3]))
+           (rx[3] == tx[3]) &&
+           rx[6] == PASS)
         {
             result = PASS;
         }
@@ -1165,7 +1172,7 @@ unsigned char Config_Reset_MCU(unsigned char fd, unsigned char targetAddr)
         chksum ^= tx[6 + idx];
     tx[7] = chksum;
 
-    if (tranceive(fd, tx, sizeof(tx), rx) > 0)
+    if (tranceiveRelDelayTime(fd, tx, sizeof(tx), rx, 100) > 0)
     {
         chksum = 0x00;
         for (int idx = 0; idx < (rx[4] | rx[5] << 8); idx++)
@@ -1176,7 +1183,8 @@ unsigned char Config_Reset_MCU(unsigned char fd, unsigned char targetAddr)
         if((chksum == rx[6+(rx[4] | rx[5]<<8)]) &&
            (rx[2] == tx[1]) &&
            (rx[1] == tx[2]) &&
-           (rx[3] == tx[3]))
+           (rx[3] == tx[3]) &&
+           rx[6] == PASS)
         {
             result = PASS;
         }

+ 26 - 18
EVSE/Projects/DW30/Apps/internalComm.c

@@ -518,7 +518,8 @@ unsigned char Config_Fan_Speed(unsigned char fd, unsigned char targetAddr, FanSp
         if((chksum == rx[6+(rx[4] | rx[5]<<8)]) &&
            (rx[2] == tx[1]) &&
            (rx[1] == tx[2]) &&
-           (rx[3] == tx[3]))
+           (rx[3] == tx[3]) &&
+           rx[6] == PASS)
         {
             result = PASS;
         }
@@ -561,7 +562,7 @@ unsigned char Config_Relay_Output(unsigned char fd, unsigned char targetAddr, Re
            (rx[2] == tx[1]) &&
            (rx[1] == tx[2]) &&
            (rx[3] == tx[3]) &&
-           (rx[6] == 0x01))
+           rx[6] == PASS)
         {
             result = PASS;
         }
@@ -686,7 +687,8 @@ unsigned char Config_Model_Name(unsigned char fd, unsigned char targetAddr, unsi
         if((chksum == rx[6+(rx[4] | rx[5]<<8)]) &&
               (rx[2] == tx[1]) &&
               (rx[1] == tx[2]) &&
-              (rx[3] == tx[3]))
+              (rx[3] == tx[3]) &&
+              rx[6] == PASS)
         {
             result = PASS;
         }
@@ -719,7 +721,8 @@ unsigned char Config_Rtc_Data(unsigned char fd, unsigned char targetAddr, Rtc *S
         if((chksum == rx[6+(rx[4] | rx[5]<<8)]) &&
                 (rx[2] == tx[1]) &&
                 (rx[1] == tx[2]) &&
-                (rx[3] == tx[3]))
+                (rx[3] == tx[3]) &&
+                rx[6] == PASS)
         {
             result = PASS;
         }
@@ -880,7 +883,7 @@ unsigned char Query_AC_Status(unsigned char fd, unsigned char targetAddr, Ac_Sta
     unsigned char tx[7] = {0xaa, 0x00, targetAddr, Cmd.query_ac_status, 0x00, 0x00, 0x00};
     unsigned char rx[512];
     unsigned char chksum = 0x00;
-    unsigned char len = tranceive(fd, tx, sizeof(tx), rx);
+    unsigned char len = tranceiveRelDelayTime(fd, tx, sizeof(tx), rx, 100);
 
     if(len > 6)
     {
@@ -940,7 +943,7 @@ unsigned char Query_AC_Alarm_Code(unsigned char fd, unsigned char targetAddr, Ac
     unsigned char tx[7] = {0xaa, 0x00, targetAddr, Cmd.query_ac_alarm_code, 0x00, 0x00};
     unsigned char rx[512];
     unsigned char chksum = 0x00;
-    unsigned char len = tranceive(fd, tx, sizeof(tx), rx);
+    unsigned char len = tranceiveRelDelayTime(fd, tx, sizeof(tx), rx, 100);
 
     if(len > 6)
     {
@@ -971,7 +974,7 @@ unsigned char Query_Charging_Energy(unsigned char fd, unsigned char targetAddr,
     unsigned char tx[7] = {0xaa, 0x00, targetAddr, Cmd.query_ac_output_energy, 0x00, 0x00,0x00};
     unsigned char rx[512];
     unsigned char chksum = 0x00;
-    unsigned char len = tranceive(fd, tx, sizeof(tx), rx);
+    unsigned char len = tranceiveRelDelayTime(fd, tx, sizeof(tx), rx, 100);
 
     if(len > 6)
     {
@@ -1002,7 +1005,7 @@ unsigned char Query_Charging_Current(unsigned char fd, unsigned char targetAddr,
     unsigned char tx[7] = {0xaa, 0x00, targetAddr, Cmd.query_ac_output_current, 0x00, 0x00, 0x00};
     unsigned char rx[512];
     unsigned char chksum = 0x00;
-    unsigned char len = tranceive(fd, tx, sizeof(tx), rx);
+    unsigned char len = tranceiveRelDelayTime(fd, tx, sizeof(tx), rx, 100);
 
     if(len > 6)
     {
@@ -1041,7 +1044,7 @@ unsigned char Config_LED_Status(unsigned char fd, unsigned char targetAddr, Ac_L
         chksum ^= tx[6 + idx];
     tx[11] = chksum;
 
-    if (tranceive(fd, tx, sizeof(tx), rx) > 0)
+    if (tranceiveRelDelayTime(fd, tx, sizeof(tx), rx, 100) > 0)
     {
         chksum = 0x00;
         for (int idx = 0; idx < (rx[4] | rx[5] << 8); idx++)
@@ -1052,7 +1055,8 @@ unsigned char Config_LED_Status(unsigned char fd, unsigned char targetAddr, Ac_L
         if((chksum == rx[6+(rx[4] | rx[5]<<8)]) &&
             (rx[2] == tx[1]) &&
             (rx[1] == tx[2]) &&
-            (rx[3] == tx[3]))
+            (rx[3] == tx[3]) &&
+            rx[6] == PASS)
         {
             result = PASS;
         }
@@ -1072,7 +1076,7 @@ unsigned char Config_Legacy_Req(unsigned char fd, unsigned char targetAddr, unsi
         chksum ^= tx[6 + idx];
     tx[8] = chksum;
 
-    if (tranceive(fd, tx, sizeof(tx), rx) > 0)
+    if (tranceiveRelDelayTime(fd, tx, sizeof(tx), rx, 100) > 0)
     {
         chksum = 0x00;
         for (int idx = 0; idx < (rx[4] | rx[5] << 8); idx++)
@@ -1083,7 +1087,8 @@ unsigned char Config_Legacy_Req(unsigned char fd, unsigned char targetAddr, unsi
         if((chksum == rx[6+(rx[4] | rx[5]<<8)]) &&
            (rx[2] == tx[1]) &&
            (rx[1] == tx[2]) &&
-           (rx[3] == tx[3]))
+           (rx[3] == tx[3]) &&
+           rx[6] == PASS)
         {
             result = PASS;
         }
@@ -1103,7 +1108,7 @@ unsigned char Config_Ac_Duty(unsigned char fd, unsigned char targetAddr, unsigne
         chksum ^= tx[6 + idx];
     tx[7] = chksum;
 
-    if (tranceive(fd, tx, sizeof(tx), rx) > 0)
+    if (tranceiveRelDelayTime(fd, tx, sizeof(tx), rx, 100) > 0)
     {
         chksum = 0x00;
         for (int idx = 0; idx < (rx[4] | rx[5] << 8); idx++)
@@ -1114,7 +1119,8 @@ unsigned char Config_Ac_Duty(unsigned char fd, unsigned char targetAddr, unsigne
         if((chksum == rx[6+(rx[4] | rx[5]<<8)]) &&
            (rx[2] == tx[1]) &&
            (rx[1] == tx[2]) &&
-           (rx[3] == tx[3]))
+           (rx[3] == tx[3]) &&
+           rx[6] == PASS)
         {
             result = PASS;
         }
@@ -1134,7 +1140,7 @@ unsigned char Config_CSU_Mode(unsigned char fd, unsigned char targetAddr)
         chksum ^= tx[6 + idx];
     tx[7] = chksum;
 
-    if (tranceive(fd, tx, sizeof(tx), rx) > 0)
+    if (tranceiveRelDelayTime(fd, tx, sizeof(tx), rx, 100) > 0)
     {
         chksum = 0x00;
         for (int idx = 0; idx < (rx[4] | rx[5] << 8); idx++)
@@ -1145,7 +1151,8 @@ unsigned char Config_CSU_Mode(unsigned char fd, unsigned char targetAddr)
         if((chksum == rx[6+(rx[4] | rx[5]<<8)]) &&
            (rx[2] == tx[1]) &&
            (rx[1] == tx[2]) &&
-           (rx[3] == tx[3]))
+           (rx[3] == tx[3]) &&
+           rx[6] == PASS)
         {
             result = PASS;
         }
@@ -1165,7 +1172,7 @@ unsigned char Config_Reset_MCU(unsigned char fd, unsigned char targetAddr)
         chksum ^= tx[6 + idx];
     tx[7] = chksum;
 
-    if (tranceive(fd, tx, sizeof(tx), rx) > 0)
+    if (tranceiveRelDelayTime(fd, tx, sizeof(tx), rx, 100) > 0)
     {
         chksum = 0x00;
         for (int idx = 0; idx < (rx[4] | rx[5] << 8); idx++)
@@ -1176,7 +1183,8 @@ unsigned char Config_Reset_MCU(unsigned char fd, unsigned char targetAddr)
         if((chksum == rx[6+(rx[4] | rx[5]<<8)]) &&
            (rx[2] == tx[1]) &&
            (rx[1] == tx[2]) &&
-           (rx[3] == tx[3]))
+           (rx[3] == tx[3]) &&
+           rx[6] == PASS)
         {
             result = PASS;
         }