|
@@ -1011,6 +1011,68 @@ unsigned char Query_Power_Consumption(unsigned char fd, unsigned char targetAddr
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+unsigned char Query_MeterIc_CorrectionPara(unsigned char fd, unsigned char targetAddr, MeterIcCorrection *Ret_Buf)
|
|
|
+{
|
|
|
+ unsigned char result = FAIL;
|
|
|
+ unsigned char tx[8] = {0xaa, 0x00, targetAddr, CMD_QUERY_METER_IC_CORRECTION_PARA, 0x01, 0x00, 0xb0, 0xb0};
|
|
|
+ unsigned char rx[512];
|
|
|
+ unsigned char chksum = 0x00;
|
|
|
+
|
|
|
+ for(int idx=0;idx<(tx[4] | tx[5]<<8);idx++)
|
|
|
+ chksum ^= tx[6+idx];
|
|
|
+ tx[7] = chksum;
|
|
|
+
|
|
|
+ unsigned char len = tranceive(fd, tx, sizeof(tx), rx);
|
|
|
+
|
|
|
+ if(len > 0)
|
|
|
+ {
|
|
|
+ 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]) == 0xb0)
|
|
|
+ {
|
|
|
+ uint32_t cali_flag = (rx[7] | (rx[8]<<8) | (rx[9]<<16) | (rx[10]<<24));
|
|
|
+
|
|
|
+ if(!(cali_flag & 0x80000000))
|
|
|
+ {
|
|
|
+ Ret_Buf->bits.isCalibratedVaGain = cali_flag & (1 << 0) ? 1 : 0;
|
|
|
+ Ret_Buf->bits.isCalibratedVbGain = cali_flag & (1 << 1) ? 1 : 0;
|
|
|
+ Ret_Buf->bits.isCalibratedVcGain = cali_flag & (1 << 2) ? 1 : 0;
|
|
|
+ Ret_Buf->bits.isCalibratedVaOffset = cali_flag & (1 << 3) ? 1 : 0;
|
|
|
+ Ret_Buf->bits.isCalibratedVbOffset = cali_flag & (1 << 4) ? 1 : 0;
|
|
|
+ Ret_Buf->bits.isCalibratedVcOffset = cali_flag & (1 << 5) ? 1 : 0;
|
|
|
+ Ret_Buf->bits.isCalibratedCaGain = cali_flag & (1 << 6) ? 1 : 0;
|
|
|
+ Ret_Buf->bits.isCalibratedCbGain = cali_flag & (1 << 7) ? 1 : 0;
|
|
|
+ Ret_Buf->bits.isCalibratedCcGain = cali_flag & (1 << 8) ? 1 : 0;
|
|
|
+ Ret_Buf->bits.isCalibratedCaOffset = cali_flag & (1 << 9) ? 1 : 0;
|
|
|
+ Ret_Buf->bits.isCalibratedCbOffset = cali_flag & (1 << 10) ? 1 : 0;
|
|
|
+ Ret_Buf->bits.isCalibratedCcOffset = cali_flag & (1 << 11) ? 1 : 0;
|
|
|
+ Ret_Buf->bits.isCalibratedPa = cali_flag & (1 << 12) ? 1 : 0;
|
|
|
+ Ret_Buf->bits.isCalibratedPb = cali_flag & (1 << 13) ? 1 : 0;
|
|
|
+ Ret_Buf->bits.isCalibratedPc = cali_flag & (1 << 14) ? 1 : 0;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Ret_Buf->value = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ result = PASS;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+}
|
|
|
+
|
|
|
unsigned char Config_Fan_Speed(unsigned char fd, unsigned char targetAddr, FanSpeed *Set_Buf)
|
|
|
{
|
|
|
unsigned char result = FAIL;
|
|
@@ -1201,7 +1263,7 @@ unsigned char Config_Gpio_Output(unsigned char fd, unsigned char targetAddr, Gpi
|
|
|
|
|
|
for(int idx=0;idx<(tx[4] | tx[5]<<8);idx++)
|
|
|
chksum ^= tx[6+idx];
|
|
|
- tx[14] = chksum;
|
|
|
+ tx[8] = chksum;
|
|
|
|
|
|
unsigned char len = tranceive(fd, tx, sizeof(tx), rx);
|
|
|
|
|
@@ -1496,7 +1558,7 @@ unsigned char Config_AC_MaxCurrent_And_CpPwmDuty(unsigned char fd, unsigned char
|
|
|
(rx[2] == tx[1]) &&
|
|
|
(rx[1] == tx[2]) &&
|
|
|
(rx[3] == tx[3]) &&
|
|
|
- (rx[6] == 0x01))
|
|
|
+ ((rx[6] == 0x00) || (rx[6] == 0x01)))
|
|
|
{
|
|
|
result = PASS;
|
|
|
}
|
|
@@ -1763,7 +1825,7 @@ unsigned char Update_Transfer(unsigned char fd, unsigned char targetAddr, unsign
|
|
|
|
|
|
for(int idx=0;idx<(tx[4] | tx[5]<<8);idx++)
|
|
|
chksum ^= tx[6+idx];
|
|
|
- tx[sizeof(tx)-1] = chksum;
|
|
|
+ tx[ARRAY_SIZE(tx)-1] = chksum;
|
|
|
|
|
|
unsigned char len = tranceive(fd, tx, sizeof(tx), rx);
|
|
|
|
|
@@ -2758,7 +2820,7 @@ int main(void)
|
|
|
if(ShmCharger->gun_info[gun_index].mcuFlag.isReadFwVerPass != PASS)
|
|
|
{
|
|
|
DEBUG_INFO("===========================================\n");
|
|
|
- DEBUG_INFO("==== Normal priority polling : Case 21-1===\n");
|
|
|
+ DEBUG_INFO("==== Normal priority polling : Case 19-1===\n");
|
|
|
DEBUG_INFO("===========================================\n");
|
|
|
if(Query_FW_Ver(Uart1Fd, (gun_index>0?ADDR_AC_PRIMARY_2:ADDR_AC_PRIMARY_1), &ShmCharger->gun_info[gun_index].ver) == PASS)
|
|
|
{
|
|
@@ -2778,13 +2840,55 @@ int main(void)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //===============================
|
|
|
+ // Query meter ic correction status
|
|
|
+ //===============================
|
|
|
+ if(ShmCharger->gun_info[gun_index].mcuFlag.isReadMeterIcCorrectionStatus != PASS)
|
|
|
+ {
|
|
|
+ DEBUG_INFO("===========================================\n");
|
|
|
+ DEBUG_INFO("==== Normal priority polling : Case 19-2===\n");
|
|
|
+ DEBUG_INFO("===========================================\n");
|
|
|
+ if(Query_MeterIc_CorrectionPara(Uart1Fd, (gun_index>0?ADDR_AC_PRIMARY_2:ADDR_AC_PRIMARY_1), &ShmCharger->gun_info[gun_index].meterIcCorrectionStatus) == PASS)
|
|
|
+ {
|
|
|
+ DEBUG_INFO("MCU-%d get meter ic correction status: 0x%08X\n", gun_index, ShmCharger->gun_info[gun_index].meterIcCorrectionStatus.value);
|
|
|
+
|
|
|
+ ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].meterIcCalInfo.isCalibratedVaGain = ShmCharger->gun_info[gun_index].meterIcCorrectionStatus.bits.isCalibratedVaGain;
|
|
|
+ ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].meterIcCalInfo.isCalibratedVbGain = ShmCharger->gun_info[gun_index].meterIcCorrectionStatus.bits.isCalibratedVbGain;
|
|
|
+ ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].meterIcCalInfo.isCalibratedVcGain = ShmCharger->gun_info[gun_index].meterIcCorrectionStatus.bits.isCalibratedVcGain;
|
|
|
+ ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].meterIcCalInfo.isCalibratedVaOffset = ShmCharger->gun_info[gun_index].meterIcCorrectionStatus.bits.isCalibratedVaOffset;
|
|
|
+ ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].meterIcCalInfo.isCalibratedVbOffset = ShmCharger->gun_info[gun_index].meterIcCorrectionStatus.bits.isCalibratedVbOffset;
|
|
|
+ ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].meterIcCalInfo.isCalibratedVcOffset = ShmCharger->gun_info[gun_index].meterIcCorrectionStatus.bits.isCalibratedVcOffset;
|
|
|
+ ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].meterIcCalInfo.isCalibratedCaGain = ShmCharger->gun_info[gun_index].meterIcCorrectionStatus.bits.isCalibratedCaGain;
|
|
|
+ ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].meterIcCalInfo.isCalibratedCbGain = ShmCharger->gun_info[gun_index].meterIcCorrectionStatus.bits.isCalibratedCbGain;
|
|
|
+ ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].meterIcCalInfo.isCalibratedCcGain = ShmCharger->gun_info[gun_index].meterIcCorrectionStatus.bits.isCalibratedCcGain;
|
|
|
+ ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].meterIcCalInfo.isCalibratedCaOffset = ShmCharger->gun_info[gun_index].meterIcCorrectionStatus.bits.isCalibratedCaOffset;
|
|
|
+ ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].meterIcCalInfo.isCalibratedCbOffset = ShmCharger->gun_info[gun_index].meterIcCorrectionStatus.bits.isCalibratedCbOffset;
|
|
|
+ ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].meterIcCalInfo.isCalibratedCcOffset = ShmCharger->gun_info[gun_index].meterIcCorrectionStatus.bits.isCalibratedCcOffset;
|
|
|
+ ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].meterIcCalInfo.isCalibratedPa = ShmCharger->gun_info[gun_index].meterIcCorrectionStatus.bits.isCalibratedPa;
|
|
|
+ ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].meterIcCalInfo.isCalibratedPb = ShmCharger->gun_info[gun_index].meterIcCorrectionStatus.bits.isCalibratedPb;
|
|
|
+ ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].meterIcCalInfo.isCalibratedPc = ShmCharger->gun_info[gun_index].meterIcCorrectionStatus.bits.isCalibratedPc;
|
|
|
+
|
|
|
+ ShmCharger->gun_info[gun_index].mcuFlag.isReadMeterIcCorrectionStatus = PASS;
|
|
|
+
|
|
|
+ failCount[gun_index] = 0;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ DEBUG_WARN("MCU-%d get meter ic correction status fail...%d\n", gun_index, failCount[gun_index]);
|
|
|
+ if(failCount[gun_index]<USHRT_MAX)
|
|
|
+ failCount[gun_index]++;
|
|
|
+ else
|
|
|
+ failCount[gun_index] = FAIL_SPEC_COMM;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//===============================
|
|
|
// Config primary MCU serial number
|
|
|
//===============================
|
|
|
if(ShmCharger->gun_info[gun_index].mcuFlag.isSetSerialNumberPass != PASS)
|
|
|
{
|
|
|
DEBUG_INFO("===========================================\n");
|
|
|
- DEBUG_INFO("==== Normal priority polling : Case 21-2===\n");
|
|
|
+ DEBUG_INFO("==== Normal priority polling : Case 19-3===\n");
|
|
|
DEBUG_INFO("===========================================\n");
|
|
|
memcpy(ShmCharger->evseId.serial_number, ShmSysConfigAndInfo->SysConfig.SerialNumber, ARRAY_SIZE(ShmCharger->evseId.serial_number));
|
|
|
if(Config_Serial_Number(Uart1Fd, (gun_index>0?ADDR_AC_PRIMARY_2:ADDR_AC_PRIMARY_1), &ShmCharger->evseId))
|
|
@@ -2810,7 +2914,7 @@ int main(void)
|
|
|
if(ShmCharger->gun_info[gun_index].mcuFlag.isSetModelNamePass != PASS)
|
|
|
{
|
|
|
DEBUG_INFO("===========================================\n");
|
|
|
- DEBUG_INFO("==== Normal priority polling : Case 21-3===\n");
|
|
|
+ DEBUG_INFO("==== Normal priority polling : Case 19-4===\n");
|
|
|
DEBUG_INFO("===========================================\n");
|
|
|
memcpy(ShmCharger->evseId.model_name, ShmSysConfigAndInfo->SysConfig.ModelName, ARRAY_SIZE(ShmCharger->evseId.model_name));
|
|
|
if(Config_Model_Name(Uart1Fd, (gun_index>0?ADDR_AC_PRIMARY_2:ADDR_AC_PRIMARY_1), &ShmCharger->evseId))
|