|
@@ -29,9 +29,9 @@
|
|
|
#define TMR_IDX_9 9
|
|
|
|
|
|
#define TIMEOUT_SPEC_HANDSHAKING 180000
|
|
|
-#define TIMEOUT_SPEC_AUTH 30000
|
|
|
+#define TIMEOUT_SPEC_AUTH 15000
|
|
|
#define TIMEOUT_SPEC_HANDSHAKING_LED 185000
|
|
|
-#define TIMEOUT_SPEC_LOGPPRINTOUT 20000
|
|
|
+#define TIMEOUT_SPEC_LOGPPRINTOUT 30000
|
|
|
|
|
|
#define MtdBlockSize 0x600000
|
|
|
|
|
@@ -80,6 +80,8 @@ struct timeb startChargingTime[AC_QUANTITY];
|
|
|
struct timeb endChargingTime[AC_QUANTITY];
|
|
|
sqlite3 *localDb;
|
|
|
|
|
|
+struct SysConfigData SysConfigOrg;
|
|
|
+
|
|
|
//=================================
|
|
|
// Common routine
|
|
|
//=================================
|
|
@@ -247,7 +249,6 @@ int CreatShareMemory()
|
|
|
int result = PASS;
|
|
|
int MeterSMId;
|
|
|
|
|
|
-
|
|
|
//creat ShmSysConfigAndInfo
|
|
|
if ((MeterSMId = shmget(ShmSysConfigAndInfoKey, sizeof(struct SysConfigAndInfo), IPC_CREAT | 0777)) < 0)
|
|
|
{
|
|
@@ -515,6 +516,7 @@ int DB_Insert_Record(sqlite3 *db, int gun_index)
|
|
|
int InitWatchDog()
|
|
|
{
|
|
|
int fd;
|
|
|
+ int timeout = 180;
|
|
|
|
|
|
system("/usr/bin/fuser -k /dev/watchdog");
|
|
|
sleep(1);
|
|
@@ -525,6 +527,7 @@ int InitWatchDog()
|
|
|
{
|
|
|
DEBUG_ERROR("System watch dog initial fail.\r\n");
|
|
|
}
|
|
|
+ ioctl(fd, _IOWR('W', 6, int), &timeout);
|
|
|
|
|
|
return fd;
|
|
|
}
|
|
@@ -748,7 +751,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,6 +858,10 @@ void InitEthernet()
|
|
|
if(ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthDhcpClient==0)
|
|
|
system("/sbin/udhcpc -i eth0 -s /root/dhcp_script/eth0.script > /dev/null &");
|
|
|
|
|
|
+ // Upgrade system id to /etc/hostname
|
|
|
+ sprintf(tmpbuf, "echo %s > /etc/hostname", ShmSysConfigAndInfo->SysConfig.SystemId);
|
|
|
+ system(tmpbuf);
|
|
|
+
|
|
|
//check internet status
|
|
|
pid = fork();
|
|
|
|
|
@@ -847,6 +916,11 @@ int SpawnTask()
|
|
|
{
|
|
|
system("/root/OcppBackend &");
|
|
|
}
|
|
|
+ else
|
|
|
+ {
|
|
|
+ DEBUG_INFO("OCPP URL is empty, need to create a configuration table !!!\r\n");
|
|
|
+ system("/root/OcppBackend &");
|
|
|
+ }
|
|
|
system ("/root/Module_AlarmDetect &");
|
|
|
system ("/root/Module_InternalComm &");
|
|
|
system ("/root/Module_Speaker &");
|
|
@@ -855,69 +929,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;
|
|
@@ -973,6 +984,9 @@ char* getSystemModeName(unsigned char mode)
|
|
|
case SYS_MODE_TERMINATING:
|
|
|
result = "terminating";
|
|
|
break;
|
|
|
+ case SYS_MODE_COMPLETE:
|
|
|
+ result = "complete";
|
|
|
+ break;
|
|
|
case SYS_MODE_ALARM:
|
|
|
result = "alarm";
|
|
|
break;
|
|
@@ -1061,7 +1075,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.23.00.0000.00");
|
|
|
+ sprintf((char*)ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev, "B0.24.00.0000.00");
|
|
|
|
|
|
// Get AC connector type from model name
|
|
|
for(uint8_t idx=0;idx<3;idx++)
|
|
@@ -1191,8 +1205,37 @@ 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)
|
|
|
+ {
|
|
|
+ DEBUG_INFO("Restore model name & serial number.\r\n");
|
|
|
+ memcpy(&SysConfigOrg, &ShmSysConfigAndInfo->SysConfig, sizeof(struct SysConfigData));
|
|
|
|
|
|
+ if(LoadSysConfigAndInfo(&ShmSysConfigAndInfo->SysConfig) != PASS)
|
|
|
+ {
|
|
|
+ DEBUG_INFO("Re-load configuration fail.\r\n");
|
|
|
+ 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)
|
|
|
+ {
|
|
|
+ DEBUG_INFO("Re-write configuration fail.\r\n");
|
|
|
+ result = FAIL;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ DEBUG_INFO("Re-write configuration OK.\r\n");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
sprintf(cmd, "yes|rm %s", ShmCharger->fwUpgradeInfo.location);
|
|
|
system(cmd);
|
|
|
break;
|
|
@@ -1224,8 +1267,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);
|
|
@@ -1310,6 +1360,8 @@ int GetCardSerialNumber()
|
|
|
{
|
|
|
isSuccess = PASS;
|
|
|
}
|
|
|
+
|
|
|
+ sethaltCard(rfidFd,module_type);
|
|
|
}
|
|
|
else if(rfid.cardType == IS014443B)
|
|
|
{
|
|
@@ -1630,8 +1682,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;
|
|
@@ -1773,7 +1826,6 @@ void checkConnectionTimeout()
|
|
|
if(strcmp((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[ConnectionTimeOut].ItemData,"") != 0)
|
|
|
{
|
|
|
ShmCharger->timeoutSpec.Setting_Timeout_Spec = atoi((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[ConnectionTimeOut].ItemData);
|
|
|
-
|
|
|
if(ShmCharger->timeoutSpec.Setting_Timeout_Spec <= 0)
|
|
|
{
|
|
|
ShmCharger->timeoutSpec.Present_Timeout_Spec = TIMEOUT_SPEC_HANDSHAKING;
|
|
@@ -1805,7 +1857,6 @@ int main(void)
|
|
|
if(CreatShareMemory()==0)
|
|
|
{
|
|
|
DEBUG_ERROR("CreatShareMemory NG\r\n");
|
|
|
-
|
|
|
if(ShmStatusCodeData!=NULL)
|
|
|
{
|
|
|
ShmStatusCodeData->AlarmCode.AlarmEvents.bits.FailToCreateShareMemory=1;
|
|
@@ -1839,7 +1890,7 @@ int main(void)
|
|
|
ShmSysConfigAndInfo->SysInfo.OcppConnStatus = ShmOCPP16Data->OcppConnStatus;
|
|
|
|
|
|
//==========================================
|
|
|
- // Ethernet Mac address
|
|
|
+ // Ethernet MAC address
|
|
|
//==========================================
|
|
|
getEth0MacAddress();
|
|
|
|
|
@@ -1849,7 +1900,7 @@ int main(void)
|
|
|
checkTask();
|
|
|
|
|
|
//==========================================
|
|
|
- // Check timeout spec
|
|
|
+ // Check connection timeout specification
|
|
|
//==========================================
|
|
|
checkConnectionTimeout();
|
|
|
|
|
@@ -1864,6 +1915,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);
|
|
@@ -1878,7 +1935,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);
|
|
@@ -1892,10 +1949,12 @@ int main(void)
|
|
|
//==========================================
|
|
|
if(ShmOCPP16Data->MsMsg.bits.ResetReq)
|
|
|
{
|
|
|
- if((!isMode(0, SYS_MODE_CHARGING) && !isMode(0, SYS_MODE_TERMINATING)) &&
|
|
|
- (AC_QUANTITY>1?(!isMode(1, SYS_MODE_CHARGING) && !isMode(1, SYS_MODE_TERMINATING)):true))
|
|
|
+ if((!isMode(0, SYS_MODE_CHARGING) && !isMode(0, SYS_MODE_TERMINATING) && !isMode(0, SYS_MODE_COMPLETE)) &&
|
|
|
+ (AC_QUANTITY>1?(!isMode(1, SYS_MODE_CHARGING) && !isMode(1, SYS_MODE_TERMINATING) && !isMode(1, SYS_MODE_COMPLETE)):true))
|
|
|
{
|
|
|
ShmOCPP16Data->MsMsg.bits.ResetReq = OFF;
|
|
|
+ sprintf((char*)ShmOCPP16Data->Reset.ResponseStatus, "Accepted");
|
|
|
+ ShmOCPP16Data->MsMsg.bits.ResetConf = ON;
|
|
|
|
|
|
if(strcmp((char*)ShmOCPP16Data->Reset.Type, "Hard") == 0)
|
|
|
{
|
|
@@ -1907,6 +1966,8 @@ int main(void)
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
+ close(wtdFd);
|
|
|
+ sleep(5);
|
|
|
system("/usr/bin/run_evse_restart.sh");
|
|
|
}
|
|
|
}
|
|
@@ -1954,7 +2015,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
|
|
@@ -2000,14 +2068,15 @@ int main(void)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // Charging profile preparation
|
|
|
- if(!ShmOCPP16Data->CSUMsg.bits[gun_index].ChargingProfileConf)
|
|
|
- {
|
|
|
- ShmOCPP16Data->CSUMsg.bits[gun_index].ChargingProfileReq = ON;
|
|
|
- }
|
|
|
- else
|
|
|
+ // Unlock Connector signal check
|
|
|
+ if(ShmOCPP16Data->CsMsg.bits[gun_index].UnlockConnectorReq == ON)
|
|
|
{
|
|
|
- ShmOCPP16Data->CSUMsg.bits[gun_index].ChargingProfileConf = OFF;
|
|
|
+ ShmOCPP16Data->CsMsg.bits[gun_index].UnlockConnectorReq = OFF;
|
|
|
+
|
|
|
+ sprintf((char*)ShmOCPP16Data->UnlockConnector[ShmOCPP16Data->UnlockConnector[gun_index].ConnectorId-1].ResponseStatus, "Unlocked");
|
|
|
+ ShmOCPP16Data->CsMsg.bits[ShmOCPP16Data->UnlockConnector[gun_index].ConnectorId-1].UnlockConnectorConf = ON;
|
|
|
+
|
|
|
+ ShmCharger->gun_info[ShmOCPP16Data->UnlockConnector[gun_index].ConnectorId-1].isUnlockerConnetor = ON;
|
|
|
}
|
|
|
|
|
|
// Connector process
|
|
@@ -2020,7 +2089,7 @@ int main(void)
|
|
|
|
|
|
//CSU Initialization & task spawn
|
|
|
if((Initialization() != PASS) ||
|
|
|
- (SpawnTask() != PASS) )
|
|
|
+ (SpawnTask() != PASS))
|
|
|
{
|
|
|
ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CsuInitFailed = ON;
|
|
|
}
|
|
@@ -2091,10 +2160,14 @@ 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)
|
|
|
+ {
|
|
|
ShmOCPP16Data->CpMsg.bits[gun_index].StopTransactionConf = OFF;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
if(ShmOCPP16Data->OcppConnStatus == ON)
|
|
@@ -2106,8 +2179,8 @@ int main(void)
|
|
|
setLedMotion(gun_index,LED_ACTION_INTERNET_DISCONNECT);
|
|
|
}
|
|
|
|
|
|
- if(((ShmSysConfigAndInfo->SysConfig.AuthorisationMode == AUTH_MODE_FREE) && (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_B)) ||
|
|
|
- ((ShmSysConfigAndInfo->SysConfig.AuthorisationMode == AUTH_MODE_FREE) && (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_C)) ||
|
|
|
+ if(((ShmSysConfigAndInfo->SysConfig.AuthorisationMode == AUTH_MODE_DISABLE) && (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_B)) ||
|
|
|
+ ((ShmSysConfigAndInfo->SysConfig.AuthorisationMode == AUTH_MODE_DISABLE) && (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_C)) ||
|
|
|
(ShmCharger->gun_info[gun_index].rfidReq == ON) ||
|
|
|
(ShmCharger->gun_info[gun_index].bleConfigData.isRequestStart == ON) ||
|
|
|
(ShmOCPP16Data->CsMsg.bits[gun_index].RemoteStartTransactionReq == ON))
|
|
@@ -2119,7 +2192,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
|
|
@@ -2196,12 +2268,11 @@ int main(void)
|
|
|
if(isModeChange(gun_index))
|
|
|
{
|
|
|
ftime(&startTime[gun_index][TMR_IDX_AUTH]);
|
|
|
-
|
|
|
if(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartMethod == START_METHOD_RFID)
|
|
|
{
|
|
|
switch(ShmSysConfigAndInfo->SysConfig.AuthorisationMode)
|
|
|
{
|
|
|
- case AUTH_MODE_BACKEND_OCPP:
|
|
|
+ case AUTH_MODE_ENABLE:
|
|
|
if(ShmOCPP16Data->OcppConnStatus)
|
|
|
{
|
|
|
// On line
|
|
@@ -2225,7 +2296,7 @@ int main(void)
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
|
- case AUTH_MODE_FREE:
|
|
|
+ case AUTH_MODE_DISABLE:
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
@@ -2237,22 +2308,21 @@ int main(void)
|
|
|
// Authorization timeout process.
|
|
|
ShmCharger->gun_info[gun_index].rfidReq = OFF;
|
|
|
setChargerMode(gun_index, SYS_MODE_IDLE);
|
|
|
- DEBUG_WARN("Authorize timeout!\r\n");
|
|
|
+ DEBUG_WARN("Authorize timeout !!!\r\n");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
switch(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartMethod)
|
|
|
{
|
|
|
case START_METHOD_RFID:
|
|
|
- if(ShmOCPP16Data->SpMsg.bits.AuthorizeConf ||
|
|
|
- (ShmSysConfigAndInfo->SysConfig.AuthorisationMode == AUTH_MODE_FREE) ||
|
|
|
- !ShmOCPP16Data->OcppConnStatus ||
|
|
|
- ((isValidLocalWhiteCard() == PASS) && (ShmSysConfigAndInfo->SysConfig.OfflinePolicy == OFF_POLICY_LOCALLIST)))
|
|
|
+ if((ShmOCPP16Data->SpMsg.bits.AuthorizeConf) ||
|
|
|
+ (!ShmOCPP16Data->OcppConnStatus && (ShmSysConfigAndInfo->SysConfig.OfflinePolicy == OFF_POLICY_FREE)) ||
|
|
|
+ (!ShmOCPP16Data->OcppConnStatus && (isValidLocalWhiteCard() == PASS) && (ShmSysConfigAndInfo->SysConfig.OfflinePolicy == OFF_POLICY_LOCALLIST)) ||
|
|
|
+ (ShmSysConfigAndInfo->SysConfig.OfflinePolicy == OFF_POLICY_NOCHARGE))
|
|
|
{
|
|
|
if((strcmp((char*)ShmOCPP16Data->Authorize.ResponseIdTagInfo.Status, "Accepted")==0) ||
|
|
|
- (ShmSysConfigAndInfo->SysConfig.AuthorisationMode == AUTH_MODE_FREE) ||
|
|
|
- (!ShmOCPP16Data->OcppConnStatus&&(ShmSysConfigAndInfo->SysConfig.OfflinePolicy == OFF_POLICY_FREE)) ||
|
|
|
- ((isValidLocalWhiteCard() == PASS) && (ShmSysConfigAndInfo->SysConfig.OfflinePolicy == OFF_POLICY_LOCALLIST)))
|
|
|
+ (!ShmOCPP16Data->OcppConnStatus && (ShmSysConfigAndInfo->SysConfig.OfflinePolicy == OFF_POLICY_FREE)) ||
|
|
|
+ (!ShmOCPP16Data->OcppConnStatus && (isValidLocalWhiteCard() == PASS) && (ShmSysConfigAndInfo->SysConfig.OfflinePolicy == OFF_POLICY_LOCALLIST)))
|
|
|
{
|
|
|
DEBUG_INFO("Authorize pass.\r\n");
|
|
|
setSpeaker(ON,SPEAKER_SHORT);
|
|
@@ -2312,13 +2382,14 @@ int main(void)
|
|
|
|
|
|
if(DiffTimebWithNow(startTime[gun_index][TMR_IDX_HANDSHAKING]) > (ShmCharger->timeoutSpec.Present_Timeout_Spec+3000))
|
|
|
{
|
|
|
- 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))
|
|
|
{
|
|
|
setSpeaker(ON,SPEAKER_SHORT);
|
|
|
+ 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);
|
|
@@ -2341,11 +2412,22 @@ 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))
|
|
|
{
|
|
|
setChargerMode(gun_index, SYS_MODE_TERMINATING);
|
|
|
}
|
|
@@ -2360,21 +2442,27 @@ int main(void)
|
|
|
|
|
|
// Response StartTransactionConf
|
|
|
if(ShmOCPP16Data->CpMsg.bits[gun_index].StartTransactionConf == ON)
|
|
|
+ {
|
|
|
ShmOCPP16Data->CpMsg.bits[gun_index].StartTransactionConf = OFF;
|
|
|
+ }
|
|
|
|
|
|
// Checking profile id > 0 and current time is between charging profile validFrom & validTo
|
|
|
if((ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingProfileId>0) &&
|
|
|
(((strlen((char*)ShmOCPP16Data->SmartChargingProfile[gun_index].ValidFrom)>0) && (strlen((char*)ShmOCPP16Data->SmartChargingProfile[gun_index].ValidTo)>0)) ? isProfileValid(gun_index) : ON))
|
|
|
{
|
|
|
- DEBUG_INFO("Profile ID found: %d\r\n", ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingProfileId);
|
|
|
- DEBUG_INFO("Valid from: %s\r\n", ShmOCPP16Data->SmartChargingProfile[gun_index].ValidFrom);
|
|
|
- DEBUG_INFO("Valid to: %s\r\n", ShmOCPP16Data->SmartChargingProfile[gun_index].ValidTo);
|
|
|
- DEBUG_INFO("Start schedule: %s\r\n", ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.StartSchedule);
|
|
|
- DEBUG_INFO("Profile kind: %s\r\n", ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingProfileKind);
|
|
|
- DEBUG_INFO("RecurrencyKind: %s\r\n", ShmOCPP16Data->SmartChargingProfile[gun_index].RecurrencyKind);
|
|
|
- DEBUG_INFO("Profile purpose: %s\r\n", ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingProfilePurpose);
|
|
|
- DEBUG_INFO("Transaction ID: %d\r\n", ShmOCPP16Data->SmartChargingProfile[gun_index].TransactionId);
|
|
|
- DEBUG_INFO("ChargingRateUnit: %s\r\n", ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingRateUnit);
|
|
|
+ // Debug information
|
|
|
+ if(DiffTimebWithNow(startTime[gun_index][TMR_IDX_LOGPPRINTOUT]) > TIMEOUT_SPEC_LOGPPRINTOUT)
|
|
|
+ {
|
|
|
+ DEBUG_INFO("Profile ID found: %d\r\n", ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingProfileId);
|
|
|
+ DEBUG_INFO("Valid from: %s\r\n", ShmOCPP16Data->SmartChargingProfile[gun_index].ValidFrom);
|
|
|
+ DEBUG_INFO("Valid to: %s\r\n", ShmOCPP16Data->SmartChargingProfile[gun_index].ValidTo);
|
|
|
+ DEBUG_INFO("Start schedule: %s\r\n", ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.StartSchedule);
|
|
|
+ DEBUG_INFO("Profile kind: %s\r\n", ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingProfileKind);
|
|
|
+ DEBUG_INFO("RecurrencyKind: %s\r\n", ShmOCPP16Data->SmartChargingProfile[gun_index].RecurrencyKind);
|
|
|
+ DEBUG_INFO("Profile purpose: %s\r\n", ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingProfilePurpose);
|
|
|
+ DEBUG_INFO("Transaction ID: %d\r\n", ShmOCPP16Data->SmartChargingProfile[gun_index].TransactionId);
|
|
|
+ DEBUG_INFO("ChargingRateUnit: %s\r\n", ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingRateUnit);
|
|
|
+ }
|
|
|
|
|
|
// Checking profile kind
|
|
|
if((mystrcmp((char*)ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingProfileKind, "Absolute") == PASS))
|
|
@@ -2472,9 +2560,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]);
|
|
|
}
|
|
|
|
|
@@ -2499,7 +2589,8 @@ 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))))
|
|
|
{
|
|
@@ -2533,7 +2624,13 @@ int main(void)
|
|
|
ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedDuration = DiffTimeb(startChargingTime[gun_index], endChargingTime[gun_index])/1000;
|
|
|
}
|
|
|
|
|
|
- setLedMotion(gun_index, LED_ACTION_STOP);
|
|
|
+ if(!ShmCharger->gun_info[gun_index].primaryMcuState.relay_state)
|
|
|
+ {
|
|
|
+ setLedMotion(gun_index, LED_ACTION_STOP);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {}
|
|
|
+
|
|
|
getDateTimeString((char*)ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StopDateTime);
|
|
|
}
|
|
|
|
|
@@ -2591,7 +2688,7 @@ int main(void)
|
|
|
{
|
|
|
switch(ShmSysConfigAndInfo->SysConfig.AuthorisationMode)
|
|
|
{
|
|
|
- case AUTH_MODE_BACKEND_OCPP:
|
|
|
+ case AUTH_MODE_ENABLE:
|
|
|
if(ShmOCPP16Data->OcppConnStatus)
|
|
|
{
|
|
|
// On line
|
|
@@ -2615,7 +2712,7 @@ int main(void)
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
|
- case AUTH_MODE_FREE:
|
|
|
+ case AUTH_MODE_DISABLE:
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
@@ -2624,11 +2721,11 @@ int main(void)
|
|
|
else
|
|
|
{
|
|
|
if(ShmOCPP16Data->SpMsg.bits.AuthorizeConf ||
|
|
|
- (ShmSysConfigAndInfo->SysConfig.AuthorisationMode == AUTH_MODE_FREE) ||
|
|
|
+ (ShmSysConfigAndInfo->SysConfig.AuthorisationMode == AUTH_MODE_DISABLE) ||
|
|
|
!ShmOCPP16Data->OcppConnStatus)
|
|
|
{
|
|
|
if((strcmp((char*)ShmOCPP16Data->Authorize.ResponseIdTagInfo.Status, "Accepted")==0) ||
|
|
|
- (ShmSysConfigAndInfo->SysConfig.AuthorisationMode == AUTH_MODE_FREE) ||
|
|
|
+ (ShmSysConfigAndInfo->SysConfig.AuthorisationMode == AUTH_MODE_DISABLE) ||
|
|
|
(!ShmOCPP16Data->OcppConnStatus&&(ShmSysConfigAndInfo->SysConfig.OfflinePolicy == OFF_POLICY_FREE)))
|
|
|
{
|
|
|
ShmCharger->gun_info[gun_index].isAuthPassEnd = ON;
|
|
@@ -2636,6 +2733,11 @@ int main(void)
|
|
|
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);
|
|
|
}
|
|
|
|
|
|
ShmOCPP16Data->SpMsg.bits.AuthorizeConf = OFF;
|
|
@@ -2648,56 +2750,36 @@ int main(void)
|
|
|
(ShmCharger->gun_info[gun_index].isAuthPassEnd) ||
|
|
|
(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))
|
|
|
{
|
|
|
if(ShmCharger->gun_info[gun_index].legacyRequest.isLegacyRequest == ON)
|
|
|
- setSpeaker(ON,SPEAKER_SHORT);
|
|
|
-
|
|
|
- setRelay(gun_index, OFF);
|
|
|
-
|
|
|
- if(!ShmCharger->gun_info[gun_index].primaryMcuState.relay_state)
|
|
|
{
|
|
|
- if(ShmOCPP16Data->MsMsg.bits.ResetReq)
|
|
|
- {
|
|
|
- if(strcmp((char*)ShmOCPP16Data->Reset.Type, "Hard")==0)
|
|
|
- sprintf((char*)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "HardReset");
|
|
|
- else
|
|
|
- sprintf((char*)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "SoftReset");
|
|
|
- }
|
|
|
- else if(ShmOCPP16Data->CsMsg.bits[gun_index].RemoteStopTransactionReq)
|
|
|
- {
|
|
|
- sprintf((char*)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "Remote");
|
|
|
- }
|
|
|
- else if(ShmCharger->gun_info[gun_index].rfidReq || ShmCharger->gun_info[gun_index].bleConfigData.isRequestStop)
|
|
|
- {
|
|
|
- sprintf((char*)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "Local");
|
|
|
- }
|
|
|
- else if(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_A)
|
|
|
- {
|
|
|
- sprintf((char*)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "EVDisconnected");
|
|
|
- }
|
|
|
- else
|
|
|
+ if(((ShmCharger->gun_info[gun_index].rfidReq == ON) && isMatchStartUser(gun_index)) ||
|
|
|
+ (ShmCharger->gun_info[gun_index].isAuthPassEnd))
|
|
|
{
|
|
|
- sprintf((char*)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "Other");
|
|
|
+ DEBUG_INFO("Authorize pass.\r\n");
|
|
|
+ setSpeaker(ON,SPEAKER_SHORT);
|
|
|
+ setLedMotion(gun_index,LED_ACTION_RFID_PASS);
|
|
|
+ sleep(3);
|
|
|
}
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {}
|
|
|
|
|
|
- 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].rfidReq = OFF;
|
|
|
- ShmCharger->gun_info[gun_index].isAuthPassEnd = OFF;
|
|
|
- ShmCharger->gun_info[gun_index].bleConfigData.isRequestStop = OFF;
|
|
|
- ShmOCPP16Data->CsMsg.bits[gun_index].RemoteStopTransactionReq = OFF;
|
|
|
+ setRelay(gun_index, OFF);
|
|
|
+ setLedMotion(gun_index, LED_ACTION_STOP);
|
|
|
|
|
|
- DB_Insert_Record(localDb, gun_index);
|
|
|
- setChargerMode(gun_index, SYS_MODE_IDLE);
|
|
|
+ if(!ShmCharger->gun_info[gun_index].primaryMcuState.relay_state)
|
|
|
+ {
|
|
|
+ setChargerMode(gun_index, SYS_MODE_COMPLETE);
|
|
|
}
|
|
|
}
|
|
|
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 &&
|
|
@@ -2709,8 +2791,67 @@ int main(void)
|
|
|
setChargerMode(gun_index, SYS_MODE_CHARGING);
|
|
|
}
|
|
|
}
|
|
|
+ break;
|
|
|
+ case SYS_MODE_COMPLETE:
|
|
|
+ if(isModeChange(gun_index))
|
|
|
+ {
|
|
|
+ setLedMotion(gun_index, LED_ACTION_STOP);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(ShmOCPP16Data->MsMsg.bits.ResetReq)
|
|
|
+ {
|
|
|
+ if(strcmp((char*)ShmOCPP16Data->Reset.Type, "Hard")==0)
|
|
|
+ sprintf((char*)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "HardReset");
|
|
|
+ else
|
|
|
+ sprintf((char*)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "SoftReset");
|
|
|
+ }
|
|
|
+ else if(ShmOCPP16Data->CsMsg.bits[gun_index].RemoteStopTransactionReq)
|
|
|
+ {
|
|
|
+ sprintf((char*)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "Remote");
|
|
|
+ }
|
|
|
+ else if(ShmCharger->gun_info[gun_index].rfidReq || ShmCharger->gun_info[gun_index].bleConfigData.isRequestStop)
|
|
|
+ {
|
|
|
+ sprintf((char*)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "Local");
|
|
|
+ }
|
|
|
+ else if(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_A)
|
|
|
+ {
|
|
|
+ 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");
|
|
|
+ }
|
|
|
+ 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].rfidReq = OFF;
|
|
|
+ ShmCharger->gun_info[gun_index].isAuthPassEnd = OFF;
|
|
|
+ ShmCharger->gun_info[gun_index].bleConfigData.isRequestStop = OFF;
|
|
|
+ ShmOCPP16Data->CsMsg.bits[gun_index].RemoteStopTransactionReq = OFF;
|
|
|
+
|
|
|
+ DB_Insert_Record(localDb, gun_index);
|
|
|
+ setChargerMode(gun_index, SYS_MODE_IDLE);
|
|
|
+
|
|
|
break;
|
|
|
case SYS_MODE_ALARM:
|
|
|
+ if((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PreviousSystemStatus == SYS_MODE_CHARGING) ||
|
|
|
+ (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PreviousSystemStatus == SYS_MODE_TERMINATING))
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ setRelay(gun_index, OFF);
|
|
|
+ }
|
|
|
+
|
|
|
if((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode == 0))
|
|
|
{
|
|
|
if((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PreviousSystemStatus == SYS_MODE_CHARGING) ||
|
|
@@ -2751,14 +2892,24 @@ 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;
|
|
|
+ if(ShmStatusCodeData->InfoCode.InfoEvents.bits.CsuFimrwareUpdateFail == ON)
|
|
|
+ ShmStatusCodeData->InfoCode.InfoEvents.bits.CsuFimrwareUpdateFail = OFF;
|
|
|
+
|
|
|
+ ShmCharger->isUpdateSuccess = YES;
|
|
|
+ DEBUG_INFO("Local update success...\r\n");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- ShmCharger->isUpdateSuccess = FAIL;
|
|
|
+ if(ShmStatusCodeData->InfoCode.InfoEvents.bits.CsuFimrwareUpdateFail == OFF)
|
|
|
+ ShmStatusCodeData->InfoCode.InfoEvents.bits.CsuFimrwareUpdateFail = ON;
|
|
|
+
|
|
|
+ ShmCharger->isUpdateSuccess = NO;
|
|
|
+ DEBUG_INFO("Local update unsuccess...\r\n");
|
|
|
}
|
|
|
}
|
|
|
else if(ShmOCPP16Data->MsMsg.bits.UpdateFirmwareReq)
|
|
@@ -2770,7 +2921,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)
|
|
|
{
|
|
@@ -2778,13 +2929,24 @@ 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;
|
|
|
+ if(ShmStatusCodeData->InfoCode.InfoEvents.bits.CsuFimrwareUpdateFail == ON)
|
|
|
+ ShmStatusCodeData->InfoCode.InfoEvents.bits.CsuFimrwareUpdateFail = OFF;
|
|
|
+
|
|
|
+ ShmCharger->isUpdateSuccess = YES;
|
|
|
+ DEBUG_INFO("Remote update success...\r\n");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- ShmCharger->isUpdateSuccess = FAIL;
|
|
|
+ if(ShmStatusCodeData->InfoCode.InfoEvents.bits.CsuFimrwareUpdateFail == OFF)
|
|
|
+ ShmStatusCodeData->InfoCode.InfoEvents.bits.CsuFimrwareUpdateFail = ON;
|
|
|
+
|
|
|
+ ShmCharger->isUpdateSuccess = NO;
|
|
|
+ DEBUG_INFO("Remote update unsuccess...\r\n");
|
|
|
}
|
|
|
}
|
|
|
else
|
|
@@ -2797,7 +2959,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;
|
|
@@ -2814,6 +2976,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");
|
|
|
}
|
|
|
}
|