|
@@ -29,7 +29,7 @@
|
|
|
#define TMR_IDX_9 9
|
|
|
|
|
|
#define TIMEOUT_SPEC_HANDSHAKING 180000
|
|
|
-#define TIMEOUT_SPEC_AUTH 30000
|
|
|
+#define TIMEOUT_SPEC_AUTH 10000
|
|
|
#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;
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -247,7 +249,6 @@ int CreatShareMemory()
|
|
|
int result = PASS;
|
|
|
int MeterSMId;
|
|
|
|
|
|
-
|
|
|
|
|
|
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 = 120;
|
|
|
|
|
|
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 &");
|
|
|
|
|
|
+
|
|
|
+ sprintf(tmpbuf, "echo %s > /etc/hostname", ShmSysConfigAndInfo->SysConfig.SystemId);
|
|
|
+ system(tmpbuf);
|
|
|
+
|
|
|
|
|
|
pid = fork();
|
|
|
|
|
@@ -855,69 +924,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 +979,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 +1070,7 @@ void get_firmware_version(unsigned char gun_index)
|
|
|
strcpy((char*)ShmSysConfigAndInfo->SysInfo.CsuPrimFwRev, ShmCharger->gun_info[gun_index].ver.Version_FW);
|
|
|
|
|
|
|
|
|
- sprintf((char*)ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev, "B0.22.00.0000.00");
|
|
|
+ sprintf((char*)ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev, "B0.23.00.0000.00");
|
|
|
|
|
|
|
|
|
for(uint8_t idx=0;idx<3;idx++)
|
|
@@ -1191,8 +1200,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 +1262,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 +1355,8 @@ int GetCardSerialNumber()
|
|
|
{
|
|
|
isSuccess = PASS;
|
|
|
}
|
|
|
+
|
|
|
+ sethaltCard(rfidFd,module_type);
|
|
|
}
|
|
|
else if(rfid.cardType == IS014443B)
|
|
|
{
|
|
@@ -1630,8 +1677,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;
|
|
@@ -1805,7 +1853,6 @@ int main(void)
|
|
|
if(CreatShareMemory()==0)
|
|
|
{
|
|
|
DEBUG_ERROR("CreatShareMemory NG\r\n");
|
|
|
-
|
|
|
if(ShmStatusCodeData!=NULL)
|
|
|
{
|
|
|
ShmStatusCodeData->AlarmCode.AlarmEvents.bits.FailToCreateShareMemory=1;
|
|
@@ -1864,6 +1911,12 @@ int main(void)
|
|
|
|
|
|
if(ShmSysConfigAndInfo->SysInfo.FactoryConfiguration)
|
|
|
{
|
|
|
+
|
|
|
+ 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 +1931,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);
|
|
@@ -1907,6 +1960,7 @@ int main(void)
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
+ close(wtdFd);
|
|
|
system("/usr/bin/run_evse_restart.sh");
|
|
|
}
|
|
|
}
|
|
@@ -1954,7 +2008,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 +2061,12 @@ int main(void)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- if(!ShmOCPP16Data->CSUMsg.bits[gun_index].ChargingProfileConf)
|
|
|
+
|
|
|
+ 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;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -2091,14 +2150,16 @@ 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;
|
|
|
|
|
|
|
|
|
if(ShmOCPP16Data->CpMsg.bits[gun_index].StopTransactionConf == ON)
|
|
|
ShmOCPP16Data->CpMsg.bits[gun_index].StopTransactionConf = OFF;
|
|
|
}
|
|
|
|
|
|
- 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))
|
|
@@ -2110,7 +2171,6 @@ int main(void)
|
|
|
{
|
|
|
ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartMethod = START_METHOD_RFID;
|
|
|
DEBUG_INFO("Start Method : RFID...\r\n");
|
|
|
-
|
|
|
if(ShmSysConfigAndInfo->SysConfig.RfidCardNumEndian)
|
|
|
{
|
|
|
|
|
@@ -2187,12 +2247,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)
|
|
|
{
|
|
|
|
|
@@ -2216,7 +2275,7 @@ int main(void)
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
|
- case AUTH_MODE_FREE:
|
|
|
+ case AUTH_MODE_DISABLE:
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
@@ -2235,15 +2294,12 @@ int main(void)
|
|
|
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))
|
|
|
{
|
|
|
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);
|
|
@@ -2302,12 +2358,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);
|
|
@@ -2330,11 +2387,22 @@ int main(void)
|
|
|
ftime(&startTime[gun_index][TMR_IDX_LOGPPRINTOUT]);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ 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);
|
|
|
}
|
|
@@ -2349,7 +2417,9 @@ int main(void)
|
|
|
|
|
|
|
|
|
if(ShmOCPP16Data->CpMsg.bits[gun_index].StartTransactionConf == ON)
|
|
|
+ {
|
|
|
ShmOCPP16Data->CpMsg.bits[gun_index].StartTransactionConf = OFF;
|
|
|
+ }
|
|
|
|
|
|
|
|
|
if((ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingProfileId>0) &&
|
|
@@ -2461,9 +2531,11 @@ int main(void)
|
|
|
|
|
|
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]);
|
|
|
}
|
|
|
|
|
@@ -2487,8 +2559,10 @@ int main(void)
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
+
|
|
|
|
|
|
- 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))))
|
|
|
{
|
|
@@ -2522,7 +2596,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);
|
|
|
}
|
|
|
|
|
@@ -2580,7 +2660,7 @@ int main(void)
|
|
|
{
|
|
|
switch(ShmSysConfigAndInfo->SysConfig.AuthorisationMode)
|
|
|
{
|
|
|
- case AUTH_MODE_BACKEND_OCPP:
|
|
|
+ case AUTH_MODE_ENABLE:
|
|
|
if(ShmOCPP16Data->OcppConnStatus)
|
|
|
{
|
|
|
|
|
@@ -2604,7 +2684,7 @@ int main(void)
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
|
- case AUTH_MODE_FREE:
|
|
|
+ case AUTH_MODE_DISABLE:
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
@@ -2613,11 +2693,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;
|
|
@@ -2625,6 +2705,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;
|
|
@@ -2637,56 +2722,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 &&
|
|
@@ -2698,6 +2763,57 @@ 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");
|
|
|
+ sprintf((char*)ShmOCPP16Data->UnlockConnector[ShmOCPP16Data->UnlockConnector[gun_index].ConnectorId-1].ResponseStatus, "Unlocked");
|
|
|
+ ShmOCPP16Data->CsMsg.bits[ShmOCPP16Data->UnlockConnector[gun_index].ConnectorId-1].UnlockConnectorConf = ON;
|
|
|
+ }
|
|
|
+ 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((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode == 0))
|
|
@@ -2740,14 +2856,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)
|
|
@@ -2759,7 +2879,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)
|
|
|
{
|
|
@@ -2767,13 +2887,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
|
|
@@ -2786,7 +2911,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;
|
|
@@ -2803,6 +2928,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");
|
|
|
}
|
|
|
}
|