|
@@ -29,7 +29,7 @@
|
|
|
#define TMR_IDX_9 9
|
|
|
|
|
|
#define TIMEOUT_SPEC_HANDSHAKING 180000
|
|
|
-#define TIMEOUT_SPEC_AUTH 30000
|
|
|
+#define TIMEOUT_SPEC_AUTH 10000//30000
|
|
|
#define TIMEOUT_SPEC_HANDSHAKING_LED 185000
|
|
|
#define TIMEOUT_SPEC_LOGPPRINTOUT 20000
|
|
|
|
|
@@ -80,6 +80,8 @@ struct timeb startChargingTime[AC_QUANTITY];
|
|
|
struct timeb endChargingTime[AC_QUANTITY];
|
|
|
sqlite3 *localDb;
|
|
|
|
|
|
+struct SysConfigData *SysConfigOrg;
|
|
|
+
|
|
|
//=================================
|
|
|
// Common routine
|
|
|
//=================================
|
|
@@ -515,6 +517,7 @@ int DB_Insert_Record(sqlite3 *db, int gun_index)
|
|
|
int InitWatchDog()
|
|
|
{
|
|
|
int fd;
|
|
|
+ int timeout = 120;
|
|
|
|
|
|
system("/usr/bin/fuser -k /dev/watchdog");
|
|
|
sleep(1);
|
|
@@ -525,6 +528,7 @@ int InitWatchDog()
|
|
|
{
|
|
|
DEBUG_ERROR("System watch dog initial fail.\r\n");
|
|
|
}
|
|
|
+ ioctl(fd, _IOWR('W', 6, int), &timeout);
|
|
|
|
|
|
return fd;
|
|
|
}
|
|
@@ -748,7 +752,69 @@ int LoadSysConfigAndInfo(struct SysConfigData *ptr)
|
|
|
DEBUG_INFO("Load SysConfigData OK\r\n");
|
|
|
|
|
|
return PASS;
|
|
|
+}
|
|
|
+
|
|
|
+int StoreUsrConfigData(struct SysConfigData *UsrData)
|
|
|
+{
|
|
|
+ int result = PASS;
|
|
|
+ int fd,wrd;
|
|
|
+ unsigned int i,Chk;
|
|
|
+ unsigned char *ptr, *BufTmp;
|
|
|
+
|
|
|
+ Chk=0;
|
|
|
+ ptr=(unsigned char *)UsrData;
|
|
|
+ if((BufTmp=malloc(MtdBlockSize))!=NULL)
|
|
|
+ {
|
|
|
+ memset(BufTmp,0,MtdBlockSize);
|
|
|
+ memcpy(BufTmp,ptr,sizeof(struct SysConfigData));
|
|
|
+ for(i=0;i<MtdBlockSize-4;i++)
|
|
|
+ Chk+=*(BufTmp+i);
|
|
|
+ memcpy( BufTmp+MtdBlockSize-4,&Chk,4);
|
|
|
+ fd = open("/dev/mtdblock10", O_RDWR);
|
|
|
+ if (fd>0)
|
|
|
+ {
|
|
|
+ wrd=write(fd, BufTmp, MtdBlockSize);
|
|
|
+ close(fd);
|
|
|
+ if(wrd>=MtdBlockSize)
|
|
|
+ {
|
|
|
+ fd = open("/dev/mtdblock11", O_RDWR);
|
|
|
+ if (fd>0)
|
|
|
+ {
|
|
|
+ wrd=write(fd, BufTmp, MtdBlockSize);
|
|
|
+ close(fd);
|
|
|
+ if(wrd<MtdBlockSize)
|
|
|
+ {
|
|
|
+ DEBUG_ERROR("write /dev/mtdblock11(backup) NG\r\n");
|
|
|
+ result = FAIL;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ DEBUG_ERROR("open /dev/mtdblock11(backup) NG\r\n");
|
|
|
+ result = FAIL;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ DEBUG_ERROR("write /dev/mtdblock10 NG\r\n");
|
|
|
+ result = FAIL;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ DEBUG_ERROR("open /dev/mtdblock10 NG\r\n");
|
|
|
+ result = FAIL;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ DEBUG_ERROR("alloc BlockSize NG\r\n");
|
|
|
+ result = FAIL;
|
|
|
+ }
|
|
|
+ if(BufTmp!=NULL)
|
|
|
+ free(BufTmp);
|
|
|
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
void InitEthernet()
|
|
@@ -793,13 +859,13 @@ void InitEthernet()
|
|
|
if(ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthDhcpClient==0)
|
|
|
system("/sbin/udhcpc -i eth0 -s /root/dhcp_script/eth0.script > /dev/null &");
|
|
|
|
|
|
- //check internet status
|
|
|
- pid = fork();
|
|
|
-
|
|
|
// Upgrade system id to /etc/hostname
|
|
|
sprintf(tmpbuf, "echo %s > /etc/hostname", ShmSysConfigAndInfo->SysConfig.SystemId);
|
|
|
system(tmpbuf);
|
|
|
|
|
|
+ //check internet status
|
|
|
+ pid = fork();
|
|
|
+
|
|
|
if(pid == 0)
|
|
|
{
|
|
|
for(;;)
|
|
@@ -859,69 +925,6 @@ int SpawnTask()
|
|
|
return PASS;
|
|
|
}
|
|
|
|
|
|
-int StoreUsrConfigData(struct SysConfigData *UsrData)
|
|
|
-{
|
|
|
- int result = PASS;
|
|
|
- int fd,wrd;
|
|
|
- unsigned int i,Chk;
|
|
|
- unsigned char *ptr, *BufTmp;
|
|
|
-
|
|
|
- Chk=0;
|
|
|
- ptr=(unsigned char *)UsrData;
|
|
|
- if((BufTmp=malloc(MtdBlockSize))!=NULL)
|
|
|
- {
|
|
|
- memset(BufTmp,0,MtdBlockSize);
|
|
|
- memcpy(BufTmp,ptr,sizeof(struct SysConfigData));
|
|
|
- for(i=0;i<MtdBlockSize-4;i++)
|
|
|
- Chk+=*(BufTmp+i);
|
|
|
- memcpy( BufTmp+MtdBlockSize-4,&Chk,4);
|
|
|
- fd = open("/dev/mtdblock10", O_RDWR);
|
|
|
- if (fd>0)
|
|
|
- {
|
|
|
- wrd=write(fd, BufTmp, MtdBlockSize);
|
|
|
- close(fd);
|
|
|
- if(wrd>=MtdBlockSize)
|
|
|
- {
|
|
|
- fd = open("/dev/mtdblock11", O_RDWR);
|
|
|
- if (fd>0)
|
|
|
- {
|
|
|
- wrd=write(fd, BufTmp, MtdBlockSize);
|
|
|
- close(fd);
|
|
|
- if(wrd<MtdBlockSize)
|
|
|
- {
|
|
|
- DEBUG_ERROR("write /dev/mtdblock11(backup) NG\r\n");
|
|
|
- result = FAIL;
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- DEBUG_ERROR("open /dev/mtdblock11(backup) NG\r\n");
|
|
|
- result = FAIL;
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- DEBUG_ERROR("write /dev/mtdblock10 NG\r\n");
|
|
|
- result = FAIL;
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- DEBUG_ERROR("open /dev/mtdblock10 NG\r\n");
|
|
|
- result = FAIL;
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- DEBUG_ERROR("alloc BlockSize NG\r\n");
|
|
|
- result = FAIL;
|
|
|
- }
|
|
|
- if(BufTmp!=NULL)
|
|
|
- free(BufTmp);
|
|
|
-
|
|
|
- return result;
|
|
|
-}
|
|
|
-
|
|
|
int Initialization()
|
|
|
{
|
|
|
int result = PASS;
|
|
@@ -1065,7 +1068,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.13.60.6007.BT");
|
|
|
+ sprintf((char*)ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev, "D0.14.60.6007.BT");
|
|
|
|
|
|
// Get AC connector type from model name
|
|
|
for(uint8_t idx=0;idx<3;idx++)
|
|
@@ -1195,8 +1198,31 @@ int upgrade_check()
|
|
|
case CSU_USER_CONFIGURATION:
|
|
|
case CSU_PRIMARY_CONTROLLER:
|
|
|
if(Upgrade_Flash(ShmCharger->fwUpgradeInfo.fwType, ShmCharger->fwUpgradeInfo.location, ShmCharger->fwUpgradeInfo.modelName) != PASS)
|
|
|
+ {
|
|
|
result = FAIL;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if(ShmCharger->fwUpgradeInfo.fwType == CSU_USER_CONFIGURATION)
|
|
|
+ {
|
|
|
+ memcpy(&SysConfigOrg, &ShmSysConfigAndInfo->SysConfig, ARRAY_SIZE(SysConfigOrg));
|
|
|
+ if(LoadSysConfigAndInfo(&ShmSysConfigAndInfo->SysConfig) != PASS)
|
|
|
+ {
|
|
|
+ result = FAIL;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ memcpy(ShmSysConfigAndInfo->SysConfig.ModelName, SysConfigOrg->ModelName, ARRAY_SIZE(SysConfigOrg->ModelName));
|
|
|
+ memcpy(ShmSysConfigAndInfo->SysConfig.SerialNumber, SysConfigOrg->SerialNumber, ARRAY_SIZE(SysConfigOrg->SerialNumber));
|
|
|
+ memcpy(ShmSysConfigAndInfo->SysConfig.SystemId, SysConfigOrg->SystemId, ARRAY_SIZE(SysConfigOrg->SystemId));
|
|
|
|
|
|
+ if(StoreUsrConfigData(&ShmSysConfigAndInfo->SysConfig) != PASS)
|
|
|
+ {
|
|
|
+ result = FAIL;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
sprintf(cmd, "yes|rm %s", ShmCharger->fwUpgradeInfo.location);
|
|
|
system(cmd);
|
|
|
break;
|
|
@@ -1228,8 +1254,15 @@ int upgrade_check()
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- result = FAIL;
|
|
|
- DEBUG_ERROR("File name error.\r\n");
|
|
|
+ if(strlen(file->d_name) >= 3)
|
|
|
+ {
|
|
|
+ result = FAIL;
|
|
|
+ DEBUG_ERROR("File name error.\r\n");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ DEBUG_ERROR("Searching file.\r\n");
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
closedir (dir);
|
|
@@ -1691,8 +1724,9 @@ int getStartSinceWeek()
|
|
|
|
|
|
t=time(NULL);
|
|
|
tmStartWeek=localtime(&t);
|
|
|
+ t-=86400*tmStartWeek->tm_wday;
|
|
|
+ tmStartWeek=localtime(&t);
|
|
|
|
|
|
- tmStartWeek->tm_wday = 0;
|
|
|
tmStartWeek->tm_hour = 0;
|
|
|
tmStartWeek->tm_min = 0;
|
|
|
tmStartWeek->tm_sec = 0;
|
|
@@ -1857,6 +1891,37 @@ void checkConnectionTimeout()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+int isStopTransactionOnInvalidId(uint8_t gun_index)
|
|
|
+{
|
|
|
+ int result = NO;
|
|
|
+
|
|
|
+ if((strcmp((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[AllowOfflineTxForUnknownId].ItemData, "TRUE") == 0) && ShmOCPP16Data->OcppConnStatus)
|
|
|
+ {
|
|
|
+ if((strcmp((char *)ShmOCPP16Data->StartTransaction[gun_index].ResponseIdTagInfo.Status ,"Accepted") == 0))
|
|
|
+ {
|
|
|
+ ShmCharger->gun_info[gun_index].isDeAuthorized = OFF;
|
|
|
+ result = NO;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ShmCharger->gun_info[gun_index].isDeAuthorized = ON;
|
|
|
+ result = YES;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ShmCharger->gun_info[gun_index].isDeAuthorized = OFF;
|
|
|
+ result = NO;
|
|
|
+ }
|
|
|
+
|
|
|
+ DEBUG_INFO("AllowOfflineTxForUnknownId: %s...\r\n",ShmOCPP16Data->ConfigurationTable.CoreProfile[AllowOfflineTxForUnknownId].ItemData);
|
|
|
+ DEBUG_INFO("ShmOCPP16Data->OcppConnStatus: %d...\r\n",ShmOCPP16Data->OcppConnStatus);
|
|
|
+ DEBUG_INFO("isDeAuthorized : %d\r\n",ShmCharger->gun_info[gun_index].isDeAuthorized);
|
|
|
+ DEBUG_INFO("ResponseIdTagInfo : %s\r\n",(char *)ShmOCPP16Data->StartTransaction[gun_index].ResponseIdTagInfo.Status);
|
|
|
+
|
|
|
+ return result;
|
|
|
+}
|
|
|
+
|
|
|
//===============================================
|
|
|
// Main process
|
|
|
//===============================================
|
|
@@ -1925,6 +1990,12 @@ int main(void)
|
|
|
//======================================
|
|
|
if(ShmSysConfigAndInfo->SysInfo.FactoryConfiguration)
|
|
|
{
|
|
|
+ // Set led to initial
|
|
|
+ for(int gun_index = 0;gun_index<AC_QUANTITY;gun_index++)
|
|
|
+ {
|
|
|
+ setLedMotion(gun_index,LED_ACTION_INIT);
|
|
|
+ }
|
|
|
+
|
|
|
system("cd /root;./Module_FactoryConfig -m");
|
|
|
system("sync");
|
|
|
sleep(5);
|
|
@@ -1939,7 +2010,7 @@ int main(void)
|
|
|
if(ShmSysConfigAndInfo->SysInfo.FirmwareUpdate ||
|
|
|
ShmOCPP16Data->MsMsg.bits.UpdateFirmwareReq)
|
|
|
{
|
|
|
- ShmCharger->isUpdateSuccess = FAIL;
|
|
|
+ ShmCharger->isUpdateSuccess = NO;
|
|
|
for(int gun_index = 0;gun_index<AC_QUANTITY;gun_index++)
|
|
|
{
|
|
|
setLedMotion(gun_index,LED_ACTION_MAINTAIN);
|
|
@@ -1968,6 +2039,7 @@ int main(void)
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
+ close(wtdFd);
|
|
|
system("/usr/bin/run_evse_restart.sh");
|
|
|
}
|
|
|
}
|
|
@@ -2015,7 +2087,14 @@ int main(void)
|
|
|
{
|
|
|
if(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus != SYS_MODE_ALARM)
|
|
|
{
|
|
|
- setChargerMode(gun_index, SYS_MODE_ALARM);
|
|
|
+ if(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus == SYS_MODE_UPDATE)
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ setChargerMode(gun_index, SYS_MODE_ALARM);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
else
|
|
@@ -2061,14 +2140,12 @@ int main(void)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // Charging profile preparation
|
|
|
- if(!ShmOCPP16Data->CSUMsg.bits[gun_index].ChargingProfileConf)
|
|
|
+ // Unlock Connector signal check
|
|
|
+ if(ShmOCPP16Data->CsMsg.bits[gun_index].UnlockConnectorReq == ON)
|
|
|
{
|
|
|
- ShmOCPP16Data->CSUMsg.bits[gun_index].ChargingProfileReq = ON;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- ShmOCPP16Data->CSUMsg.bits[gun_index].ChargingProfileConf = OFF;
|
|
|
+ ShmOCPP16Data->CsMsg.bits[gun_index].UnlockConnectorReq = OFF;
|
|
|
+
|
|
|
+ ShmCharger->gun_info[ShmOCPP16Data->UnlockConnector[gun_index].ConnectorId-1].isUnlockerConnetor = ON;
|
|
|
}
|
|
|
|
|
|
// Connector process
|
|
@@ -2141,6 +2218,7 @@ int main(void)
|
|
|
{
|
|
|
setLedMotion(gun_index,LED_ACTION_IDLE);
|
|
|
setRelay(gun_index,OFF);
|
|
|
+ ShmCharger->gun_info[gun_index].isDeAuthorized = OFF;
|
|
|
ShmCharger->gun_info[gun_index].isGunPlugged = NO;
|
|
|
ShmCharger->gun_info[gun_index].rfidReq = OFF;
|
|
|
ShmCharger->gun_info[gun_index].bleConfigData.isRequestStart = OFF;
|
|
@@ -2152,6 +2230,8 @@ int main(void)
|
|
|
ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedEnergy = 0;
|
|
|
ShmCharger->gun_info[gun_index].targetCurrent = 0xFF;
|
|
|
ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty.max_current = ShmCharger->gun_info[gun_index].primaryMcuState.rating_current;
|
|
|
+ memset(ShmOCPP16Data->UnlockConnector[gun_index].ResponseStatus, 0x00, ARRAY_SIZE(ShmOCPP16Data->UnlockConnector[gun_index].ResponseStatus));
|
|
|
+ ShmCharger->gun_info[ShmOCPP16Data->UnlockConnector[gun_index].ConnectorId-1].isUnlockerConnetor = OFF;
|
|
|
|
|
|
// Response StopTransactionConf
|
|
|
if(ShmOCPP16Data->CpMsg.bits[gun_index].StopTransactionConf == ON)
|
|
@@ -2173,7 +2253,6 @@ int main(void)
|
|
|
{
|
|
|
ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartMethod = START_METHOD_RFID;
|
|
|
DEBUG_INFO("Start Method : RFID...\r\n");
|
|
|
-
|
|
|
if(ShmSysConfigAndInfo->SysConfig.RfidCardNumEndian)
|
|
|
{
|
|
|
// Big endian
|
|
@@ -2250,8 +2329,6 @@ int main(void)
|
|
|
if(isModeChange(gun_index))
|
|
|
{
|
|
|
ftime(&startTime[gun_index][TMR_IDX_AUTH]);
|
|
|
- ShmCharger->gun_info[gun_index].isGunPlugged = NO;
|
|
|
-
|
|
|
if(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartMethod == START_METHOD_RFID)
|
|
|
{
|
|
|
switch(ShmSysConfigAndInfo->SysConfig.AuthorisationMode)
|
|
@@ -2391,7 +2468,6 @@ int main(void)
|
|
|
if((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_A) && (ShmCharger->gun_info[gun_index].isGunPlugged == YES))
|
|
|
{
|
|
|
DEBUG_INFO("Charging gun is plugged before.\r\n");
|
|
|
- //setRelay(gun_index, OFF);
|
|
|
setChargerMode(gun_index, SYS_MODE_IDLE);
|
|
|
}
|
|
|
|
|
@@ -2401,12 +2477,13 @@ int main(void)
|
|
|
|
|
|
if(DiffTimebWithNow(startTime[gun_index][TMR_IDX_HANDSHAKING]) > (ShmCharger->timeoutSpec.Present_Timeout_Spec+5000))
|
|
|
{
|
|
|
- DEBUG_INFO("Handshaking timeout...");
|
|
|
+ DEBUG_INFO("Handshaking timeout...\r\n");
|
|
|
setChargerMode(gun_index, SYS_MODE_IDLE);
|
|
|
}
|
|
|
}
|
|
|
else*/ if((ShmCharger->gun_info[gun_index].primaryMcuState.relay_state == ON))
|
|
|
{
|
|
|
+ ShmCharger->gun_info[ShmOCPP16Data->UnlockConnector[gun_index].ConnectorId-1].isUnlockerConnetor = OFF;
|
|
|
ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].OutputEnergy = 0;
|
|
|
ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedEnergy = 0;
|
|
|
getDateTimeString((char*)ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartDateTime);
|
|
@@ -2429,11 +2506,23 @@ int main(void)
|
|
|
ftime(&startTime[gun_index][TMR_IDX_LOGPPRINTOUT]);
|
|
|
}
|
|
|
|
|
|
+ // Charging profile preparation
|
|
|
+ if(!ShmOCPP16Data->CSUMsg.bits[gun_index].ChargingProfileConf)
|
|
|
+ {
|
|
|
+ ShmOCPP16Data->CSUMsg.bits[gun_index].ChargingProfileReq = ON;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ShmOCPP16Data->CSUMsg.bits[gun_index].ChargingProfileConf = OFF;
|
|
|
+ }
|
|
|
+
|
|
|
if((ShmCharger->gun_info[gun_index].rfidReq == ON) ||
|
|
|
(ShmCharger->gun_info[gun_index].bleConfigData.isRequestStop == ON) ||
|
|
|
(ShmOCPP16Data->CsMsg.bits[gun_index].RemoteStopTransactionReq == ON)||
|
|
|
(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState != CP_STATE_C) ||
|
|
|
- ShmOCPP16Data->MsMsg.bits.ResetReq)
|
|
|
+ (ShmOCPP16Data->MsMsg.bits.ResetReq) ||
|
|
|
+ (ShmCharger->gun_info[ShmOCPP16Data->UnlockConnector[gun_index].ConnectorId-1].isUnlockerConnetor == ON) ||
|
|
|
+ (isStopTransactionOnInvalidId(gun_index) == YES))
|
|
|
{
|
|
|
setChargerMode(gun_index, SYS_MODE_TERMINATING);
|
|
|
}
|
|
@@ -2560,9 +2649,11 @@ int main(void)
|
|
|
// Debug information
|
|
|
if(DiffTimebWithNow(startTime[gun_index][TMR_IDX_LOGPPRINTOUT]) > TIMEOUT_SPEC_LOGPPRINTOUT)
|
|
|
{
|
|
|
+ DEBUG_INFO("=======================================================================\r\n");
|
|
|
DEBUG_INFO("ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent: %d \r\n", ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent);
|
|
|
DEBUG_INFO("ShmCharger->gun_info[%d].primaryMcuCp_Pwn_Duty.max_current: %d\r\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty.max_current);
|
|
|
DEBUG_INFO("ShmCharger->gun_info[%d].targetCurrent: %d\r\n", gun_index, ShmCharger->gun_info[gun_index].targetCurrent);
|
|
|
+ DEBUG_INFO("=======================================================================\r\n");
|
|
|
ftime(&startTime[gun_index][TMR_IDX_LOGPPRINTOUT]);
|
|
|
}
|
|
|
|
|
@@ -2586,8 +2677,10 @@ int main(void)
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
+
|
|
|
// Off-line max condition check
|
|
|
- if(ShmSysConfigAndInfo->SysConfig.OfflinePolicy != OFF_POLICY_NOCHARGE)
|
|
|
+ if((ShmSysConfigAndInfo->SysConfig.AuthorisationMode == AUTH_MODE_DISABLE) ||
|
|
|
+ ((ShmSysConfigAndInfo->SysConfig.AuthorisationMode == AUTH_MODE_ENABLE) && (ShmSysConfigAndInfo->SysConfig.OfflinePolicy != OFF_POLICY_NOCHARGE)))
|
|
|
{
|
|
|
if(((ShmSysConfigAndInfo->SysConfig.OfflineMaxChargeDuration > 0) ? (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedDuration >= (ShmSysConfigAndInfo->SysConfig.OfflineMaxChargeDuration*60)) : (ShmSysConfigAndInfo->SysConfig.MaxChargingDuration > 0) && (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedDuration >= (ShmSysConfigAndInfo->SysConfig.MaxChargingDuration*60))))
|
|
|
{
|
|
@@ -2607,7 +2700,7 @@ int main(void)
|
|
|
else
|
|
|
{
|
|
|
setRelay(gun_index, OFF);
|
|
|
- DEBUG_INFO("Connector-%d can not charging in off line\r\n", gun_index);
|
|
|
+ DEBUG_INFO("Connector-%d can not charging in off line\r\n", gun_index);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -2619,11 +2712,16 @@ int main(void)
|
|
|
if(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedDuration != 0)
|
|
|
{
|
|
|
ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedDuration = DiffTimeb(startChargingTime[gun_index], endChargingTime[gun_index])/1000;
|
|
|
- }
|
|
|
+ }
|
|
|
+
|
|
|
if(!ShmCharger->gun_info[gun_index].primaryMcuState.relay_state)
|
|
|
+ {
|
|
|
setLedMotion(gun_index, LED_ACTION_STOP);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {}
|
|
|
+
|
|
|
getDateTimeString((char*)ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StopDateTime);
|
|
|
- ShmCharger->gun_info[gun_index].isGunPlugged = NO;
|
|
|
}
|
|
|
|
|
|
// If RFID SN different with start user, it need to authorize ID
|
|
@@ -2720,15 +2818,17 @@ int main(void)
|
|
|
if((strcmp((char*)ShmOCPP16Data->Authorize.ResponseIdTagInfo.Status, "Accepted")==0) ||
|
|
|
(ShmSysConfigAndInfo->SysConfig.AuthorisationMode == AUTH_MODE_DISABLE) ||
|
|
|
(!ShmOCPP16Data->OcppConnStatus&&(ShmSysConfigAndInfo->SysConfig.OfflinePolicy == OFF_POLICY_FREE)))
|
|
|
-
|
|
|
{
|
|
|
ShmCharger->gun_info[gun_index].isAuthPassEnd = ON;
|
|
|
}
|
|
|
else
|
|
|
- {
|
|
|
+ {
|
|
|
+ ShmCharger->gun_info[gun_index].rfidReq = OFF;
|
|
|
+
|
|
|
+ DEBUG_INFO("Authorize fail.\r\n");
|
|
|
+ //setSpeaker(ON,SPEAKER_INTERVAL_3COUNT);
|
|
|
setLedMotion(gun_index,LED_ACTION_RFID_FAIL);
|
|
|
sleep(3);
|
|
|
- ShmCharger->gun_info[gun_index].rfidReq = OFF;
|
|
|
}
|
|
|
|
|
|
ShmOCPP16Data->SpMsg.bits.AuthorizeConf = OFF;
|
|
@@ -2741,23 +2841,32 @@ int main(void)
|
|
|
(ShmCharger->gun_info[gun_index].isAuthPassEnd) ||
|
|
|
((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartMethod == START_METHOD_BLE) && (ShmCharger->gun_info[gun_index].bleConfigData.isRequestStop == ON)) ||
|
|
|
(ShmOCPP16Data->CsMsg.bits[gun_index].RemoteStopTransactionReq == ON) ||
|
|
|
- (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_A) ||
|
|
|
- ShmOCPP16Data->MsMsg.bits.ResetReq)
|
|
|
+ ((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_A) && (strcmp((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[StopTransactionOnEVSideDisconnect].ItemData, "TRUE") == 0)) ||
|
|
|
+ (ShmOCPP16Data->MsMsg.bits.ResetReq) ||
|
|
|
+ (ShmCharger->gun_info[ShmOCPP16Data->UnlockConnector[gun_index].ConnectorId-1].isUnlockerConnetor == ON) ||
|
|
|
+ (isStopTransactionOnInvalidId(gun_index) == YES))
|
|
|
{
|
|
|
//if(ShmCharger->gun_info[gun_index].legacyRequest.isLegacyRequest == ON)
|
|
|
//setSpeaker(ON,SPEAKER_SHORT);
|
|
|
-
|
|
|
+
|
|
|
+ if((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartMethod == START_METHOD_RFID) && (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState != CP_STATE_A) )
|
|
|
+ {
|
|
|
+ DEBUG_INFO("Authorize pass.\r\n");
|
|
|
+ //setSpeaker(ON,SPEAKER_SHORT);
|
|
|
+ setLedMotion(gun_index,LED_ACTION_RFID_PASS);
|
|
|
+ sleep(3);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {}
|
|
|
+
|
|
|
setRelay(gun_index, OFF);
|
|
|
|
|
|
|
|
|
|
|
|
if(!ShmCharger->gun_info[gun_index].primaryMcuState.relay_state)
|
|
|
{
|
|
|
- if((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartMethod == START_METHOD_RFID) && (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState != CP_STATE_A) )
|
|
|
- {
|
|
|
- setLedMotion(gun_index,LED_ACTION_RFID_PASS);
|
|
|
- sleep(3);
|
|
|
- }
|
|
|
+
|
|
|
+
|
|
|
if(ShmOCPP16Data->MsMsg.bits.ResetReq)
|
|
|
{
|
|
|
if(strcmp((char*)ShmOCPP16Data->Reset.Type, "Hard")==0)
|
|
@@ -2777,15 +2886,28 @@ int main(void)
|
|
|
{
|
|
|
sprintf((char*)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "EVDisconnected");
|
|
|
}
|
|
|
+ else if(ShmCharger->gun_info[ShmOCPP16Data->UnlockConnector[gun_index].ConnectorId-1].isUnlockerConnetor == ON)
|
|
|
+ {
|
|
|
+ sprintf((char*)ShmOCPP16Data->StopTransaction[ShmOCPP16Data->UnlockConnector[gun_index].ConnectorId-1].StopReason, "UnlockCommand");
|
|
|
+ sprintf((char*)ShmOCPP16Data->UnlockConnector[ShmOCPP16Data->UnlockConnector[gun_index].ConnectorId-1].ResponseStatus, "Unlocked");
|
|
|
+ ShmOCPP16Data->CsMsg.bits[ShmOCPP16Data->UnlockConnector[gun_index].ConnectorId-1].UnlockConnectorConf = ON;
|
|
|
+ }
|
|
|
+ else if(ShmCharger->gun_info[gun_index].isDeAuthorized == ON)
|
|
|
+ {
|
|
|
+ sprintf((char*)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "DeAuthorized");
|
|
|
+ }
|
|
|
else
|
|
|
{
|
|
|
sprintf((char*)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "Other");
|
|
|
}
|
|
|
|
|
|
+ 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);
|
|
|
ShmOCPP16Data->CpMsg.bits[gun_index].StopTransactionReq = ON;
|
|
|
|
|
|
+ ShmCharger->gun_info[gun_index].isDeAuthorized = OFF;
|
|
|
ShmCharger->gun_info[gun_index].rfidReq = OFF;
|
|
|
ShmCharger->gun_info[gun_index].isAuthPassEnd = OFF;
|
|
|
ShmCharger->gun_info[gun_index].bleConfigData.isRequestStop = OFF;
|
|
@@ -2798,15 +2920,15 @@ int main(void)
|
|
|
else
|
|
|
{
|
|
|
if((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_C) &&
|
|
|
+ (ShmCharger->gun_info[gun_index].rfidReq != ON) &&
|
|
|
(ShmCharger->gun_info[gun_index].bleConfigData.isRequestStop != ON) &&
|
|
|
(ShmOCPP16Data->CsMsg.bits[gun_index].RemoteStopTransactionReq != ON) &&
|
|
|
!ShmOCPP16Data->MsMsg.bits.ResetReq &&
|
|
|
- (ShmCharger->gun_info[gun_index].rfidReq != ON) &&
|
|
|
!(ShmOCPP16Data->OcppConnStatus && (ShmSysConfigAndInfo->SysConfig.MaxChargingDuration > 0) && (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedDuration >= (ShmSysConfigAndInfo->SysConfig.MaxChargingDuration*60))) &&
|
|
|
!(ShmOCPP16Data->OcppConnStatus && (ShmSysConfigAndInfo->SysConfig.MaxChargingEnergy > 0) && (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedEnergy >= ((float)ShmSysConfigAndInfo->SysConfig.MaxChargingEnergy))) &&
|
|
|
!(!ShmOCPP16Data->OcppConnStatus && (ShmSysConfigAndInfo->SysConfig.OfflinePolicy != OFF_POLICY_NOCHARGE) && ((ShmSysConfigAndInfo->SysConfig.OfflineMaxChargeDuration > 0) ? (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedDuration >= (ShmSysConfigAndInfo->SysConfig.OfflineMaxChargeDuration*60)) : (ShmSysConfigAndInfo->SysConfig.MaxChargingDuration > 0) && (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedDuration >= (ShmSysConfigAndInfo->SysConfig.MaxChargingDuration*60)))) &&
|
|
|
!(!ShmOCPP16Data->OcppConnStatus && (ShmSysConfigAndInfo->SysConfig.OfflinePolicy != OFF_POLICY_NOCHARGE) && ((ShmSysConfigAndInfo->SysConfig.OfflineMaxChargeEnergy > 0) ? (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedEnergy >= ((float)ShmSysConfigAndInfo->SysConfig.OfflineMaxChargeEnergy)) : (ShmSysConfigAndInfo->SysConfig.MaxChargingEnergy > 0) && (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedEnergy >= ((float)ShmSysConfigAndInfo->SysConfig.MaxChargingEnergy)))))
|
|
|
- {
|
|
|
+ {
|
|
|
setChargerMode(gun_index, SYS_MODE_CHARGING);
|
|
|
}
|
|
|
}
|
|
@@ -2852,14 +2974,18 @@ int main(void)
|
|
|
{
|
|
|
DEBUG_INFO("Firmware local upgrading...\r\n");
|
|
|
ShmSysConfigAndInfo->SysInfo.FirmwareUpdate = OFF;
|
|
|
+ int value = upgrade_check();
|
|
|
|
|
|
- if(upgrade_check())
|
|
|
+ DEBUG_INFO("Local update Value: %d...\r\n",value);
|
|
|
+ if(value == PASS)
|
|
|
{
|
|
|
- ShmCharger->isUpdateSuccess = PASS;
|
|
|
+ ShmCharger->isUpdateSuccess = YES;
|
|
|
+ DEBUG_INFO("Local update success...\r\n");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- ShmCharger->isUpdateSuccess = FAIL;
|
|
|
+ ShmCharger->isUpdateSuccess = NO;
|
|
|
+ DEBUG_INFO("Local update unsuccess...\r\n");
|
|
|
}
|
|
|
}
|
|
|
else if(ShmOCPP16Data->MsMsg.bits.UpdateFirmwareReq)
|
|
@@ -2871,7 +2997,7 @@ int main(void)
|
|
|
{
|
|
|
DEBUG_INFO("Firmware remote upgraded fail...\r\n");
|
|
|
ShmOCPP16Data->MsMsg.bits.UpdateFirmwareReq = OFF;
|
|
|
- ShmCharger->isUpdateSuccess = FAIL;
|
|
|
+ ShmCharger->isUpdateSuccess = NO;
|
|
|
}
|
|
|
else if(strcmp((char*)ShmOCPP16Data->FirmwareStatusNotification.Status, "Downloaded")==0)
|
|
|
{
|
|
@@ -2879,13 +3005,18 @@ int main(void)
|
|
|
sprintf((char*)ShmOCPP16Data->FirmwareStatusNotification.Status, "Installing");
|
|
|
ShmOCPP16Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
|
|
|
ShmOCPP16Data->MsMsg.bits.UpdateFirmwareReq = OFF;
|
|
|
- if(upgrade_check())
|
|
|
+ int result = upgrade_check();
|
|
|
+
|
|
|
+ DEBUG_INFO("Remote update Result: %d...\r\n",result);
|
|
|
+ if(result == PASS)
|
|
|
{
|
|
|
- ShmCharger->isUpdateSuccess = PASS;
|
|
|
+ ShmCharger->isUpdateSuccess = YES;
|
|
|
+ DEBUG_INFO("Remote update success...\r\n");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- ShmCharger->isUpdateSuccess = FAIL;
|
|
|
+ ShmCharger->isUpdateSuccess = NO;
|
|
|
+ DEBUG_INFO("Remote update unsuccess...\r\n");
|
|
|
}
|
|
|
}
|
|
|
else
|
|
@@ -2898,7 +3029,7 @@ int main(void)
|
|
|
//======================================
|
|
|
if(!ShmCharger->gun_info[gun_index].mcuFlag.isMcuUpgradeReq && ((AC_QUANTITY>1)?!ShmCharger->gun_info[gun_index^1].mcuFlag.isMcuUpgradeReq:YES))
|
|
|
{
|
|
|
- if(ShmCharger->isUpdateSuccess == PASS)
|
|
|
+ if(ShmCharger->isUpdateSuccess == YES)
|
|
|
{
|
|
|
sprintf((char*)ShmOCPP16Data->FirmwareStatusNotification.Status, "Installed");
|
|
|
ShmOCPP16Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
|
|
@@ -2915,6 +3046,7 @@ int main(void)
|
|
|
sprintf((char*)ShmOCPP16Data->FirmwareStatusNotification.Status, "InstallationFailed");
|
|
|
ShmOCPP16Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
|
|
|
DEBUG_WARN("Firmware upgrade fail.\r\n");
|
|
|
+ close(wtdFd);
|
|
|
system("/usr/bin/run_evse_restart.sh");
|
|
|
}
|
|
|
}
|