|
@@ -2595,6 +2595,11 @@ int isMatchStartUser(unsigned char gun_index)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ DEBUG_INFO("==== isMatchStartUser ==== \n");
|
|
|
+ DEBUG_INFO("tmpUser : %s \n", tmpUser);
|
|
|
+ DEBUG_INFO("StartUserId : %s \n", ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartUserId);
|
|
|
+ DEBUG_INFO("========================== \n");
|
|
|
+
|
|
|
return ((strcmp((char*)tmpUser, (char*)ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartUserId)==0)?YES:NO);
|
|
|
}
|
|
|
|
|
@@ -2823,9 +2828,9 @@ int isReachableInternet()
|
|
|
char buf[512];
|
|
|
char tmp[512];
|
|
|
|
|
|
+ // Get ip address & net mask
|
|
|
strcpy(cmd, "ifconfig eth0");
|
|
|
fp = popen(cmd, "r");
|
|
|
-
|
|
|
if(fp != NULL)
|
|
|
{
|
|
|
while(fgets(buf, sizeof(buf), fp) != NULL)
|
|
@@ -2834,7 +2839,6 @@ int isReachableInternet()
|
|
|
{
|
|
|
sscanf(buf, "%*s%s", tmp);
|
|
|
substr(tmp, tmp, strspn(tmp, "addr:"), strlen(buf)-strspn(tmp, "addr:"));
|
|
|
-
|
|
|
if (strcmp(tmp, (char *)ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthIpAddress) != 0)
|
|
|
{
|
|
|
strcpy((char *) ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthIpAddress, tmp);
|
|
@@ -2933,7 +2937,7 @@ int isRouteFail()
|
|
|
int isReservationExpired(unsigned char gun_index)
|
|
|
{
|
|
|
int result = NO;
|
|
|
-
|
|
|
+
|
|
|
if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_16)
|
|
|
{
|
|
|
if(isOvertNow(ShmOCPP16Data->ReserveNow[gun_index].ExpiryDate))
|
|
@@ -3185,6 +3189,15 @@ void checkTask()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ if(strcmp((char *)&ShmSysConfigAndInfo->SysConfig.MaintainServerURL,"") != 0)
|
|
|
+ {
|
|
|
+ if(system("pidof -s OcppBackendPH > /dev/null") != 0)
|
|
|
+ {
|
|
|
+ DEBUG_INFO("OcppBackendPH not running, restart it.\n");
|
|
|
+ system("/root/OcppBackendPH &");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
if(system("pidof -s Module_AlarmDetect > /dev/null") != 0)
|
|
|
{
|
|
|
DEBUG_INFO("Module_AlarmDetect not running, restart it.\n");
|
|
@@ -3208,13 +3221,6 @@ void checkTask()
|
|
|
DEBUG_INFO("Module_ProduceUtils not running, restart it.\n");
|
|
|
system ("/root/Module_ProduceUtils &");
|
|
|
}
|
|
|
-/*
|
|
|
- if((system("pidof -s Module_InitUpgrade > /dev/null") != 0) &&
|
|
|
- ShmSysConfigAndInfo->SysConfig.isReqFirstUpgrade)
|
|
|
- {
|
|
|
- DEBUG_INFO("Module_InitUpgrade not running, restart it.\n");
|
|
|
- system ("/root/Module_InitUpgrade &");
|
|
|
- }*/
|
|
|
}
|
|
|
|
|
|
void checkConnectionTimeout()
|
|
@@ -3522,6 +3528,8 @@ void checkChargingProfileLimit(uint8_t gun_index)
|
|
|
|
|
|
void checkStopReason(uint8_t gun_index)
|
|
|
{
|
|
|
+ sleep(2);
|
|
|
+
|
|
|
if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_16)
|
|
|
{
|
|
|
memset(ShmOCPP16Data->StopTransaction[gun_index].IdTag, 0x00, ARRAY_SIZE(ShmOCPP16Data->StopTransaction[gun_index].IdTag));
|
|
@@ -3533,7 +3541,7 @@ void checkStopReason(uint8_t gun_index)
|
|
|
{
|
|
|
sprintf((char*)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "EmergencyStop");
|
|
|
}
|
|
|
- else if(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_A)
|
|
|
+ else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_A) || (ShmCharger->gun_info[gun_index].isGunUnpluggedBefore == YES))
|
|
|
{
|
|
|
sprintf((char*)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "EVDisconnected");
|
|
|
memcpy((char*)ShmOCPP16Data->StopTransaction[gun_index].IdTag, (char*)ShmOCPP16Data->StartTransaction[gun_index].IdTag, ARRAY_SIZE(ShmOCPP16Data->StopTransaction[gun_index].IdTag));
|
|
@@ -3586,7 +3594,7 @@ void checkStopReason(uint8_t gun_index)
|
|
|
{
|
|
|
sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.stoppedReason, "EmergencyStop");
|
|
|
}
|
|
|
- else if(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_A)
|
|
|
+ else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_A) || (ShmCharger->gun_info[gun_index].isGunUnpluggedBefore == YES))
|
|
|
{
|
|
|
sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.stoppedReason, "EVDisconnected");
|
|
|
}
|
|
@@ -3651,6 +3659,7 @@ void checkRemoteUpgradeStatus()
|
|
|
{
|
|
|
DEBUG_INFO("Firmware remote upgrading...\n");
|
|
|
sprintf((char*)ShmOCPP16Data->FirmwareStatusNotification.Status, "Installing");
|
|
|
+ sleep(1);
|
|
|
ShmOCPP16Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
|
|
|
ShmOCPP16Data->MsMsg.bits.UpdateFirmwareReq = OFF;
|
|
|
int result = upgrade_check();
|
|
@@ -3720,7 +3729,9 @@ void checkRemoteUpgradeStatus()
|
|
|
//===============================================
|
|
|
int main(void)
|
|
|
{
|
|
|
- //Create all share memory
|
|
|
+ //==================================================
|
|
|
+ // Create all share memory
|
|
|
+ //==================================================
|
|
|
if(CreatShareMemory()==0)
|
|
|
{
|
|
|
DEBUG_ERROR("CreatShareMemory NG\n");
|
|
@@ -3748,12 +3759,14 @@ int main(void)
|
|
|
ShmCharger->gun_info[gun_index].isSetLedBrightness = OFF;
|
|
|
}
|
|
|
|
|
|
+ //==================================================
|
|
|
// Main loop
|
|
|
+ //==================================================
|
|
|
for(;;)
|
|
|
{
|
|
|
- //==========================================
|
|
|
+ //==============================================
|
|
|
// Synchronize share memory from OCPP struct
|
|
|
- //==========================================
|
|
|
+ //==============================================
|
|
|
ShmSysConfigAndInfo->SysInfo.OcppConnStatus = ocpp_get_connection_status();
|
|
|
|
|
|
//==============================================
|
|
@@ -3775,9 +3788,9 @@ int main(void)
|
|
|
ftime(&startTime[0][TMR_IDX_CHECK_TASK]);
|
|
|
}
|
|
|
|
|
|
- //==========================================
|
|
|
+ //==============================================
|
|
|
// Something need run in Idle mode
|
|
|
- //==========================================
|
|
|
+ //==============================================
|
|
|
if(((ShmSysConfigAndInfo->SysInfo.AcChargingData[0].SystemStatus==SYS_MODE_IDLE) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[0].SystemStatus==SYS_MODE_ALARM)) &&
|
|
|
(AC_QUANTITY>1?((ShmSysConfigAndInfo->SysInfo.AcChargingData[1].SystemStatus==SYS_MODE_IDLE) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[1].SystemStatus==SYS_MODE_ALARM)):true))
|
|
|
{
|
|
@@ -3824,15 +3837,15 @@ int main(void)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //==========================================
|
|
|
+ //==============================================
|
|
|
// Check remote reset request
|
|
|
- //==========================================
|
|
|
+ //==============================================
|
|
|
checkReset();
|
|
|
|
|
|
- //==========================================
|
|
|
- // Check RFID
|
|
|
- //==========================================
|
|
|
- if(!ShmCharger->gun_info[ShmCharger->gun_selectd].rfidReq)
|
|
|
+ //==============================================
|
|
|
+ // Check RFID authorization
|
|
|
+ //==============================================
|
|
|
+ if((!ShmCharger->gun_info[ShmCharger->gun_selectd].rfidReq) && (ShmSysConfigAndInfo->SysConfig.AuthorisationMode != AUTH_MODE_DISABLE))
|
|
|
{
|
|
|
if(GetCardSerialNumber()!= FAIL)
|
|
|
{
|
|
@@ -3840,9 +3853,9 @@ int main(void)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //==========================================
|
|
|
+ //==============================================
|
|
|
// Connector loop
|
|
|
- //==========================================
|
|
|
+ //==============================================
|
|
|
for(int gun_index = 0;gun_index<AC_QUANTITY;gun_index++)
|
|
|
{
|
|
|
// Synchronize current rating value from MCU
|
|
@@ -3873,10 +3886,14 @@ int main(void)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //==========================================
|
|
|
// Reservation request check
|
|
|
+ //==========================================
|
|
|
checkReservation(gun_index);
|
|
|
|
|
|
+ //==========================================
|
|
|
// Change availability check
|
|
|
+ //==========================================
|
|
|
checkAvailability(gun_index);
|
|
|
|
|
|
if(ShmCharger->gun_info[gun_index].isOperactive)
|
|
@@ -3894,10 +3911,14 @@ int main(void)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //==========================================
|
|
|
// Unlock Connector signal check
|
|
|
+ //==========================================
|
|
|
checkUnlocker(gun_index);
|
|
|
|
|
|
+ //==========================================
|
|
|
// Connector process
|
|
|
+ //==========================================
|
|
|
switch(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus)
|
|
|
{
|
|
|
case SYS_MODE_BOOTING:
|
|
@@ -3969,6 +3990,7 @@ int main(void)
|
|
|
setRelay(gun_index,OFF);
|
|
|
setRequest(gun_index,OFF);
|
|
|
ShmCharger->gun_info[gun_index].isGunPlugged = NO;
|
|
|
+ ShmCharger->gun_info[gun_index].isGunUnpluggedBefore = NO;
|
|
|
ShmCharger->gun_info[gun_index].rfidReq = OFF;
|
|
|
ShmCharger->gun_info[gun_index].bleConfigData.isRequestStart = OFF;
|
|
|
ShmCharger->gun_info[gun_index].bleConfigData.isRequestStop = OFF;
|
|
@@ -3980,7 +4002,6 @@ int main(void)
|
|
|
ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedDuration = 0;
|
|
|
ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedEnergy = 0;
|
|
|
ShmCharger->gun_info[gun_index].targetCurrent = 0xFF;
|
|
|
-
|
|
|
ocpp_set_unlocker_req(gun_index, OFF);
|
|
|
ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].ReservationId = -1;
|
|
|
|
|
@@ -4074,6 +4095,7 @@ int main(void)
|
|
|
ocpp_set_remotestart(gun_index, OFF);
|
|
|
ShmCharger->gun_info[gun_index].bleConfigData.isRequestStart = OFF;
|
|
|
ShmCharger->gun_info[gun_index].isGunPlugged = NO;
|
|
|
+ ShmCharger->gun_info[gun_index].isGunUnpluggedBefore = NO;
|
|
|
ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].schedule.isTriggerStart = OFF;
|
|
|
|
|
|
// Get target current
|
|
@@ -4255,22 +4277,14 @@ int main(void)
|
|
|
{
|
|
|
ftime(&startTime[gun_index][TMR_IDX_HANDSHAKING]);
|
|
|
setLedMotion(gun_index,LED_ACTION_CONNECTED);
|
|
|
+ ocpp_set_profile_req(gun_index, ON);
|
|
|
}
|
|
|
|
|
|
- // If control pilot detect Bx, skip watch dog time out.
|
|
|
- /*
|
|
|
- if((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_B) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_C))
|
|
|
- {
|
|
|
- setRequest(gun_index,ON);
|
|
|
- ftime(&startTime[gun_index][TMR_IDX_HANDSHAKING]);
|
|
|
- ShmCharger->gun_info[gun_index].isGunPlugged = YES;
|
|
|
- }
|
|
|
- */
|
|
|
-
|
|
|
// Unplug charging gun to Idle mode
|
|
|
if((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_A) && (ShmCharger->gun_info[gun_index].isGunPlugged == YES))
|
|
|
{
|
|
|
DEBUG_INFO("Charging gun is plugged before.\n");
|
|
|
+ ShmCharger->gun_info[gun_index].isGunUnpluggedBefore = YES;
|
|
|
setChargerMode(gun_index, SYS_MODE_IDLE);
|
|
|
}
|
|
|
|
|
@@ -4286,10 +4300,10 @@ int main(void)
|
|
|
ShmCharger->gun_info[gun_index].rfidReq = OFF;
|
|
|
}
|
|
|
|
|
|
+ // Handshaking timeout and the system back to idle
|
|
|
if(DiffTimebWithNow(startTime[gun_index][TMR_IDX_HANDSHAKING]) > ShmCharger->timeoutSpec.Present_Timeout_Spec)
|
|
|
{
|
|
|
setLedMotion(gun_index, LED_ACTION_HANDSHAKE_FAIL);
|
|
|
-
|
|
|
if(DiffTimebWithNow(startTime[gun_index][TMR_IDX_HANDSHAKING]) > (ShmCharger->timeoutSpec.Present_Timeout_Spec+5000))
|
|
|
{
|
|
|
DEBUG_INFO("Handshaking timeout...\n");
|
|
@@ -4301,7 +4315,8 @@ int main(void)
|
|
|
setRequest(gun_index,ON);
|
|
|
ftime(&startTime[gun_index][TMR_IDX_HANDSHAKING]);
|
|
|
ShmCharger->gun_info[gun_index].isGunPlugged = YES;
|
|
|
-
|
|
|
+ ShmCharger->gun_info[gun_index].isGunUnpluggedBefore = NO;
|
|
|
+
|
|
|
// Set relay on when the system is state C
|
|
|
if(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_C)
|
|
|
setRelay(gun_index, ON);
|
|
@@ -4336,8 +4351,14 @@ int main(void)
|
|
|
ocpp_set_profile_req(gun_index, ON);
|
|
|
ShmCharger->gun_info[gun_index].isChargerStopByCondition = NO;
|
|
|
}
|
|
|
+ if(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_A)
|
|
|
+ {
|
|
|
+ ShmCharger->gun_info[gun_index].isGunUnpluggedBefore = YES;
|
|
|
+ DEBUG_INFO("Unplugged the charging gun during charging. \n");
|
|
|
+ }
|
|
|
|
|
|
- if((ShmCharger->gun_info[gun_index].rfidReq == ON) ||
|
|
|
+ if((ShmCharger->gun_info[gun_index].isGunUnpluggedBefore == YES) ||
|
|
|
+ (ShmCharger->gun_info[gun_index].rfidReq == ON) ||
|
|
|
(ShmCharger->gun_info[gun_index].bleConfigData.isRequestStop == ON) ||
|
|
|
ocpp_get_remotestop(gun_index) ||
|
|
|
(ocpp_get_connection_status() && !ocpp_get_starttransaction_result(gun_index)) ||
|
|
@@ -4673,7 +4694,10 @@ int main(void)
|
|
|
getDateTimeString((char*)ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StopDateTime);
|
|
|
startTime[gun_index][TMR_IDX_AUTH].time -= TIMEOUT_SPEC_AUTH;
|
|
|
|
|
|
- sleep(3);
|
|
|
+ if(ShmCharger->gun_info[gun_index].isGunUnpluggedBefore == YES)
|
|
|
+ setRelay(gun_index, OFF);
|
|
|
+
|
|
|
+ sleep(1);
|
|
|
}
|
|
|
|
|
|
// End authorize pass
|
|
@@ -4682,7 +4706,7 @@ int main(void)
|
|
|
(ShmCharger->gun_info[gun_index].bleConfigData.isRequestStop == ON) ||
|
|
|
ocpp_get_remotestop(gun_index) ||
|
|
|
(ocpp_get_connection_status() && !ocpp_get_starttransaction_result(gun_index)) ||
|
|
|
- ((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_A) && ocpp_get_StopTransactionOnEVSideDisconnect()) ||
|
|
|
+ (((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_A) || (ShmCharger->gun_info[gun_index].isGunUnpluggedBefore == YES)) && ocpp_get_StopTransactionOnEVSideDisconnect()) ||
|
|
|
ocpp_get_reset_req() ||
|
|
|
ocpp_get_unlocker_req(gun_index) ||
|
|
|
(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].schedule.isTriggerStop == ON))
|
|
@@ -4936,7 +4960,8 @@ int main(void)
|
|
|
ftime(&startTime[gun_index][TMR_IDX_LOGPPRINTOUT]);
|
|
|
}
|
|
|
|
|
|
- if((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_C) &&
|
|
|
+ if((ShmCharger->gun_info[gun_index].isGunUnpluggedBefore != YES) &&
|
|
|
+ (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_C) &&
|
|
|
(ShmCharger->gun_info[gun_index].rfidReq != ON) &&
|
|
|
(ShmCharger->gun_info[gun_index].bleConfigData.isRequestStop != ON) &&
|
|
|
!ocpp_get_remotestop(gun_index) &&
|
|
@@ -4970,6 +4995,7 @@ int main(void)
|
|
|
ShmCharger->gun_info[gun_index].bleConfigData.isRequestStop = OFF;
|
|
|
ocpp_set_remotestop(gun_index, OFF);
|
|
|
ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].schedule.isTriggerStop = OFF;
|
|
|
+ ShmCharger->gun_info[gun_index].isGunUnpluggedBefore = NO;
|
|
|
|
|
|
DB_Insert_Record(localDb, gun_index);
|
|
|
setChargerMode(gun_index, SYS_MODE_IDLE);
|