|
@@ -1178,7 +1178,7 @@ void get_firmware_version(unsigned char gun_index)
|
|
|
strcpy((char*)ShmSysConfigAndInfo->SysInfo.CsuPrimFwRev, ShmCharger->gun_info[gun_index].ver.Version_FW);
|
|
|
|
|
|
// Get CSU root file system version
|
|
|
- sprintf((char*)ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev, "D0.24.60.XXXX.B0");
|
|
|
+ sprintf((char*)ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev, "B0.25.00.0000.00");
|
|
|
|
|
|
// Get AC connector type from model name
|
|
|
for(uint8_t idx=0;idx<3;idx++)
|
|
@@ -1482,9 +1482,30 @@ int GetCardSerialNumber()
|
|
|
}
|
|
|
|
|
|
//===============================================
|
|
|
-// Check PH RFID
|
|
|
+// Calculation CRC32 function
|
|
|
//===============================================
|
|
|
+unsigned int CRC32(uint8_t const * p_data, uint32_t size)
|
|
|
+{
|
|
|
+ uint32_t crc;
|
|
|
+ crc = 0xFFFFFFFF;
|
|
|
+ for (uint32_t i = 0; i < size; i++)
|
|
|
+ {
|
|
|
+ if( (i<0x22) || (i>0x2f))
|
|
|
+ {
|
|
|
+ crc = crc ^ p_data[i];
|
|
|
+ for (uint32_t j = 8; j > 0; j--)
|
|
|
+ {
|
|
|
+ crc = (crc >> 1) ^ (0xEDB88320U & ((crc & 1) ? 0xFFFFFFFF : 0));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+ return ~crc;
|
|
|
+}
|
|
|
+
|
|
|
+//===============================================
|
|
|
+// Check PH RFID
|
|
|
+//===============================================
|
|
|
int isValidPHCard()
|
|
|
{
|
|
|
int isSuccess = FAIL;
|
|
@@ -1515,7 +1536,7 @@ int isValidPHCard()
|
|
|
buf = malloc(25 + sn_len);
|
|
|
memcpy(buf, ShmSysConfigAndInfo->SysConfig.SystemId, 25);
|
|
|
memcpy(&buf[25], rfid.currentCard, sn_len);
|
|
|
- crc_result = crc32(buf, 25 + sn_len);
|
|
|
+ crc_result = CRC32(buf, 25 + sn_len);
|
|
|
|
|
|
if(((data_read[0] << 8) | (data_read[1] << 0) | (data_read[2] << 24) | (data_read[3] << 16)) == ~crc_result)
|
|
|
{
|
|
@@ -1527,13 +1548,10 @@ int isValidPHCard()
|
|
|
DEBUG_INFO("PH logic checked fail.\r\n");
|
|
|
}
|
|
|
|
|
|
- free(buf);
|
|
|
-
|
|
|
+ free(buf);
|
|
|
}
|
|
|
else
|
|
|
- {
|
|
|
-
|
|
|
- }
|
|
|
+ {}
|
|
|
|
|
|
return isSuccess;
|
|
|
}
|
|
@@ -2461,6 +2479,7 @@ int main(void)
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
ShmCharger->gun_info[gun_index].mcuFlag.isSetCpPwmDuty = YES;
|
|
|
}
|
|
|
|
|
@@ -2502,10 +2521,10 @@ int main(void)
|
|
|
setChargerMode(gun_index, SYS_MODE_IDLE);
|
|
|
|
|
|
}
|
|
|
+
|
|
|
sethaltCard(rfidFd,MODULE_EWT);
|
|
|
ShmCharger->gun_info[gun_index].rfidReq = OFF;
|
|
|
ShmOCPP16Data->SpMsg.bits.AuthorizeConf = OFF;
|
|
|
-
|
|
|
}
|
|
|
break;
|
|
|
case START_METHOD_BACKEND:
|
|
@@ -2517,7 +2536,6 @@ int main(void)
|
|
|
ShmCharger->gun_info[gun_index].isHandshakeTimeOn = ON;
|
|
|
break;
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
else
|
|
@@ -2533,19 +2551,18 @@ int main(void)
|
|
|
{
|
|
|
setChargerMode(gun_index, SYS_MODE_PREPARING);
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
- // Use RFID card to stop handshaking
|
|
|
- if((ShmCharger->gun_info[gun_index].rfidReq == ON) && isMatchStartUser(gun_index))
|
|
|
- {
|
|
|
- DEBUG_INFO("Use RFID card to stop handshaking.\r\n");
|
|
|
- setChargerMode(gun_index, SYS_MODE_IDLE);
|
|
|
- sethaltCard(rfidFd,MODULE_EWT);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- ShmCharger->gun_info[gun_index].rfidReq = OFF;
|
|
|
- }
|
|
|
+
|
|
|
+ // Use RFID card to stop handshaking
|
|
|
+ if((ShmCharger->gun_info[gun_index].rfidReq == ON) && isMatchStartUser(gun_index))
|
|
|
+ {
|
|
|
+ DEBUG_INFO("Use RFID card to stop handshaking.\r\n");
|
|
|
+ setChargerMode(gun_index, SYS_MODE_IDLE);
|
|
|
+ sethaltCard(rfidFd,MODULE_EWT);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ShmCharger->gun_info[gun_index].rfidReq = OFF;
|
|
|
+ }
|
|
|
|
|
|
if(DiffTimebWithNow(startTime[gun_index][TMR_IDX_HANDSHAKING]) > ShmCharger->timeoutSpec.Present_Timeout_Spec)
|
|
|
{
|
|
@@ -2554,8 +2571,8 @@ int main(void)
|
|
|
DEBUG_INFO("Handshaking timeout...");
|
|
|
setChargerMode(gun_index, SYS_MODE_IDLE);
|
|
|
}
|
|
|
-
|
|
|
- }
|
|
|
+ }
|
|
|
+
|
|
|
break;
|
|
|
case SYS_MODE_PREPARING:
|
|
|
if(isModeChange(gun_index))
|
|
@@ -2589,8 +2606,8 @@ int main(void)
|
|
|
ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedEnergy = 0;
|
|
|
getDateTimeString((char*)ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartDateTime);
|
|
|
ShmCharger->gun_info[gun_index].powerConsumption.power_consumption_at_start = ShmCharger->gun_info[gun_index].powerConsumption.power_consumption;
|
|
|
- ShmOCPP16Data->StartTransaction[gun_index].MeterStart = (ShmCharger->gun_info[gun_index].powerConsumption.power_consumption/100);
|
|
|
- //memcpy((char*)ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartUserId, ShmSysConfigAndInfo->SysConfig.UserId, ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.UserId));
|
|
|
+ ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PowerConsumption = (ShmCharger->gun_info[gun_index].powerConsumption.power_consumption/100);
|
|
|
+ memcpy((char*)ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartUserId, ShmSysConfigAndInfo->SysConfig.UserId, ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.UserId));
|
|
|
|
|
|
memcpy((char*)ShmOCPP16Data->StartTransaction[gun_index].IdTag, (char*)ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartUserId, ARRAY_SIZE(ShmOCPP16Data->StartTransaction[gun_index].IdTag));
|
|
|
ShmOCPP16Data->CpMsg.bits[gun_index].StartTransactionReq = ON;
|
|
@@ -2620,7 +2637,7 @@ int main(void)
|
|
|
else
|
|
|
{
|
|
|
setLedMotion(gun_index,LED_ACTION_CHARGING);
|
|
|
- ShmOCPP16Data->StopTransaction[gun_index].MeterStop = (ShmCharger->gun_info[gun_index].powerConsumption.power_consumption/100);
|
|
|
+ ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PowerConsumption = (ShmCharger->gun_info[gun_index].powerConsumption.power_consumption/100);
|
|
|
ftime(&endChargingTime[gun_index]);
|
|
|
ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedDuration = DiffTimeb(startChargingTime[gun_index], endChargingTime[gun_index])/1000;
|
|
|
ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedEnergy = ((float)(ShmCharger->gun_info[gun_index].powerConsumption.power_consumption - ShmCharger->gun_info[gun_index].powerConsumption.power_consumption_at_start))/100;
|
|
@@ -2921,10 +2938,10 @@ int main(void)
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- if((ShmOCPP16Data->SpMsg.bits.AuthorizeConf ||
|
|
|
- (ShmSysConfigAndInfo->SysConfig.AuthorisationMode == AUTH_MODE_DISABLE) ||
|
|
|
- !ShmOCPP16Data->OcppConnStatus ) && (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartMethod != START_METHOD_BLE) ||
|
|
|
- (!ShmOCPP16Data->OcppConnStatus&&(ShmSysConfigAndInfo->SysConfig.OfflinePolicy == OFF_POLICY_FREE)))
|
|
|
+ if(((ShmOCPP16Data->SpMsg.bits.AuthorizeConf) ||
|
|
|
+ (ShmSysConfigAndInfo->SysConfig.AuthorisationMode == AUTH_MODE_DISABLE) ||
|
|
|
+ (!ShmOCPP16Data->OcppConnStatus&&(ShmSysConfigAndInfo->SysConfig.OfflinePolicy == OFF_POLICY_FREE))) &&
|
|
|
+ (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartMethod != START_METHOD_BLE))
|
|
|
{
|
|
|
if((strcmp((char*)ShmOCPP16Data->Authorize.ResponseIdTagInfo.Status, "Accepted")==0) ||
|
|
|
(ShmSysConfigAndInfo->SysConfig.AuthorisationMode == AUTH_MODE_DISABLE) ||
|
|
@@ -3029,7 +3046,7 @@ int main(void)
|
|
|
DEBUG_INFO("Gun-%d : StopReason [ %s ]...\r\n.",gun_index,ShmOCPP16Data->StopTransaction[gun_index].StopReason);
|
|
|
|
|
|
memcpy((char*)ShmOCPP16Data->StopTransaction[gun_index].IdTag, (char*)ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartUserId, ARRAY_SIZE(ShmOCPP16Data->StopTransaction[gun_index].IdTag));
|
|
|
- ShmOCPP16Data->StopTransaction[gun_index].MeterStop = (ShmCharger->gun_info[gun_index].powerConsumption.power_consumption/100);
|
|
|
+ ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PowerConsumption = (ShmCharger->gun_info[gun_index].powerConsumption.power_consumption/100);
|
|
|
ShmOCPP16Data->CpMsg.bits[gun_index].StopTransactionReq = ON;
|
|
|
|
|
|
ShmCharger->gun_info[gun_index].rfidReq = OFF;
|