|
@@ -1323,6 +1323,53 @@ unsigned char Config_AC_MCU_LEGACY_REQUEST(unsigned char fd, unsigned char targe
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+unsigned char Config_AC_MCU_RELAY(unsigned char fd, unsigned char targetAddr, Legacy_Request *Set_Buf)
|
|
|
+{
|
|
|
+ unsigned char result = FAIL;
|
|
|
+ unsigned char tx[9];
|
|
|
+ unsigned char rx[512];
|
|
|
+ unsigned char chksum = 0x00;
|
|
|
+
|
|
|
+ tx[0] = 0xaa;
|
|
|
+ tx[1] = 0x00;
|
|
|
+ tx[2] = targetAddr;
|
|
|
+ tx[3] = CMD_CONFIG_MCU_MODE;
|
|
|
+ tx[4] = 0x02;
|
|
|
+ tx[5] = 0x00;
|
|
|
+ tx[6] = Set_Buf->isLegacyRequest;
|
|
|
+ tx[7] = 0x00;
|
|
|
+
|
|
|
+ for(int idx=0;idx<(tx[4] | tx[5]<<8);idx++)
|
|
|
+ chksum ^= tx[6+idx];
|
|
|
+ tx[8] = chksum;
|
|
|
+
|
|
|
+ unsigned char len = tranceive(fd, tx, sizeof(tx), rx);
|
|
|
+
|
|
|
+ if(len > 6)
|
|
|
+ {
|
|
|
+ if (len < 6+(rx[4] | rx[5]<<8))
|
|
|
+ return result;
|
|
|
+
|
|
|
+ chksum = 0x00;
|
|
|
+ for(int idx=0;idx<(rx[4] | rx[5]<<8);idx++)
|
|
|
+ {
|
|
|
+ chksum ^= rx[6+idx];
|
|
|
+ }
|
|
|
+
|
|
|
+ if((chksum == rx[6+(rx[4] | rx[5]<<8)]) &&
|
|
|
+ (rx[2] == tx[1]) &&
|
|
|
+ (rx[1] == tx[2]) &&
|
|
|
+ (rx[3] == tx[3]) &&
|
|
|
+ (rx[6] == 0x01))
|
|
|
+ {
|
|
|
+ result = PASS;
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+}
|
|
|
+
|
|
|
unsigned char Config_AC_MCU_RESET_REQUEST(unsigned char fd, unsigned char targetAddr, Mcu_Reset_Request *Set_Buf)
|
|
|
{
|
|
|
unsigned char result = FAIL;
|
|
@@ -1797,12 +1844,28 @@ int main(void)
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- DEBUG_WARN("MCU-%d set relay request fail...%d\r\n", gun_index, failCount[gun_index]);
|
|
|
+ DEBUG_WARN("MCU-%d set request fail...%d\r\n", gun_index, failCount[gun_index]);
|
|
|
if(failCount[gun_index]<1000)
|
|
|
{
|
|
|
failCount[gun_index]++;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ //===============================
|
|
|
+ // Case 2-X : Config primary Relay
|
|
|
+ //===============================
|
|
|
+ if(Config_AC_MCU_RELAY(Uart1Fd, (gun_index>0?ADDR_AC_PRIMARY_2:ADDR_AC_PRIMARY_1),&ShmCharger->gun_info[gun_index].legacyRequest))
|
|
|
+ {
|
|
|
+ failCount[gun_index] = 0;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ DEBUG_WARN("MCU-%d set relay fail...%d\r\n", gun_index, failCount[gun_index]);
|
|
|
+ if(failCount[gun_index]<1000)
|
|
|
+ {
|
|
|
+ failCount[gun_index]++;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
//===============================
|
|
|
// Case 3 : Query primary MCU status
|
|
@@ -2242,8 +2305,6 @@ int main(void)
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- ShmCharger->gun_info[gun_index].mcuFlag.isSetCpPwmDuty = OFF;
|
|
|
-
|
|
|
DEBUG_WARN("MCU-%d set cp pwn duty fail...%d\r\n", gun_index, failCount[gun_index]);
|
|
|
if(failCount[gun_index]<1000)
|
|
|
{
|