|
@@ -281,10 +281,10 @@ static int doCommConnToServer(void)
|
|
// fcntl(TcpSock, F_SETFL, flag );
|
|
// fcntl(TcpSock, F_SETFL, flag );
|
|
//}
|
|
//}
|
|
|
|
|
|
- tv.tv_sec = 0;
|
|
|
|
- tv.tv_usec = 100000;
|
|
|
|
- setsockopt(TcpSock, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(struct timeval));
|
|
|
|
- setsockopt(TcpSock, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(struct timeval));
|
|
|
|
|
|
+ tv.tv_sec = 3;
|
|
|
|
+ tv.tv_usec = 0;
|
|
|
|
+ setsockopt(TcpSock, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(struct timeval)); //設定等待3s
|
|
|
|
+ setsockopt(TcpSock, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(struct timeval)); //設定傳送3s
|
|
flag = 1;
|
|
flag = 1;
|
|
setsockopt(TcpSock, SOL_SOCKET, MSG_NOSIGNAL, &flag, sizeof(flag));
|
|
setsockopt(TcpSock, SOL_SOCKET, MSG_NOSIGNAL, &flag, sizeof(flag));
|
|
|
|
|
|
@@ -1154,10 +1154,10 @@ static int responsePackeHandle(int fd, uint8_t *pResult, uint8_t plugNum, uint8_
|
|
|
|
|
|
ShmDcCommonData->PcPsuOutput[plugNum].Voltage = ntohs((uint16_t)pPcPsuOutput->Voltage);
|
|
ShmDcCommonData->PcPsuOutput[plugNum].Voltage = ntohs((uint16_t)pPcPsuOutput->Voltage);
|
|
ShmDcCommonData->PcPsuOutput[plugNum].Current = ntohs((uint16_t)pPcPsuOutput->Current);
|
|
ShmDcCommonData->PcPsuOutput[plugNum].Current = ntohs((uint16_t)pPcPsuOutput->Current);
|
|
- log_info("%d ower cabinet PSU output vol = %d, cur = %d\r\n",
|
|
|
|
- plugNum,
|
|
|
|
- ShmDcCommonData->PcPsuOutput[plugNum].Voltage,
|
|
|
|
- ShmDcCommonData->PcPsuOutput[plugNum].Current);
|
|
|
|
|
|
+ //log_info("%d power cabinet PSU output vol = %f, cur = %f\r\n",
|
|
|
|
+ // plugNum,
|
|
|
|
+ // (float)ShmDcCommonData->PcPsuOutput[plugNum].Voltage,
|
|
|
|
+ // (float)ShmDcCommonData->PcPsuOutput[plugNum].Current);
|
|
break;
|
|
break;
|
|
|
|
|
|
case REG_QRCODE_URL_INFO:
|
|
case REG_QRCODE_URL_INFO:
|
|
@@ -1361,17 +1361,6 @@ static int readMiscCommand(int fd, uint8_t id)
|
|
|
|
|
|
static int readChargePermission(int fd, uint8_t id)
|
|
static int readChargePermission(int fd, uint8_t id)
|
|
{
|
|
{
|
|
- //int ret = PASS;
|
|
|
|
-
|
|
|
|
- //if ((ret = composeSocketData(fd,
|
|
|
|
- // id,
|
|
|
|
- // OP_READ_DATA,
|
|
|
|
- // REG_CHARGING_PERMISSION,
|
|
|
|
- // 0,
|
|
|
|
- // NULL)) == FAIL) {
|
|
|
|
- // return ret;
|
|
|
|
- //}
|
|
|
|
-
|
|
|
|
return composeSocketData(fd,
|
|
return composeSocketData(fd,
|
|
id,
|
|
id,
|
|
OP_READ_DATA,
|
|
OP_READ_DATA,
|
|
@@ -1645,95 +1634,6 @@ static int CheckNetworkStatus(void)
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
-#if 0
|
|
|
|
-static int FindChargingInfoData(uint8_t target, struct ChargingInfoData **chargingData)
|
|
|
|
-{
|
|
|
|
- uint8_t index = 0;
|
|
|
|
-
|
|
|
|
- for (index = 0; index < CHAdeMO_QUANTITY; index++) {
|
|
|
|
- if (pSysInfo->ChademoChargingData[index].Index == target) {
|
|
|
|
- chargingData[target] = &pSysInfo->ChademoChargingData[index];
|
|
|
|
- return 1;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- for (index = 0; index < CCS_QUANTITY; index++) {
|
|
|
|
- if (pSysInfo->CcsChargingData[index].Index == target) {
|
|
|
|
- chargingData[target] = &pSysInfo->CcsChargingData[index];
|
|
|
|
- return 1;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- for (index = 0; index < GB_QUANTITY; index++) {
|
|
|
|
- if (pSysInfo->GbChargingData[index].Index == target) {
|
|
|
|
- chargingData[target] = &pSysInfo->GbChargingData[index];
|
|
|
|
- return 1;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return 0;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-static int InitShareMemory(void)
|
|
|
|
-{
|
|
|
|
- int result = 1;
|
|
|
|
- int MeterSMId = 0;
|
|
|
|
-
|
|
|
|
- if ((MeterSMId = shmget(ShmSysConfigAndInfoKey, sizeof(struct SysConfigAndInfo), 0777)) < 0) {
|
|
|
|
- log_error("shmget ShmSysConfigAndInfo NG\n");
|
|
|
|
- result = 0;
|
|
|
|
- } else if ((ShmSysConfigAndInfo = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
|
|
|
|
- log_error("[shmat ShmSysConfigAndInfo NG\n");
|
|
|
|
- result = 0;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if ((MeterSMId = shmget(ShmStatusCodeKey, sizeof(struct StatusCodeData), 0777)) < 0) {
|
|
|
|
- log_error("shmget ShmStatusCodeData NG\n");
|
|
|
|
- result = 0;
|
|
|
|
- } else if ((ShmStatusCodeData = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
|
|
|
|
- log_error("shmat ShmStatusCodeData NG\n");
|
|
|
|
- result = 0;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //creat ShmPsuData
|
|
|
|
- if ((MeterSMId = shmget(ShmPsuKey, sizeof(struct PsuData), 0777)) < 0) {
|
|
|
|
- log_error("shmget ShmPsuData NG \n");
|
|
|
|
- result = 0;
|
|
|
|
- } else if ((ShmPsuData = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
|
|
|
|
- log_error("shmat ShmPsuData NG \n");
|
|
|
|
- result = 0;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //creat ShmOCPP16Data
|
|
|
|
- if ((MeterSMId = shmget(ShmOcppModuleKey, sizeof(struct OCPP16Data), 0777)) < 0) {
|
|
|
|
- log_error("shmget ShmOCPP16Data NG \n");
|
|
|
|
- result = 0;
|
|
|
|
- } else if ((ShmOCPP16Data = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
|
|
|
|
- log_error("shmat ShmOCPP16Data NG \n");
|
|
|
|
- result = 0;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if ((MeterSMId = shmget(ShmPrimaryMcuKey, sizeof(struct PrimaryMcuData), 0777)) < 0) {
|
|
|
|
- log_error("shmget ShmPrimaryMcuData NG\n");
|
|
|
|
- result = 0;
|
|
|
|
- } else if ((ShmPrimaryMcuData = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
|
|
|
|
- log_error("shmat ShmPrimaryMcuData NG\n");
|
|
|
|
- result = 0;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //creat Audi customization info
|
|
|
|
- if ((MeterSMId = shmget(ShmSelectGunInfoKey, sizeof(SelectGunInfo), IPC_CREAT | 0777)) < 0) {
|
|
|
|
- log_error("[main]CreatShareMemory:shmget select gun info NG \n");
|
|
|
|
- return 0;
|
|
|
|
- } else if ((ShmSelectGunInfo = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
|
|
|
|
- log_error("[main]CreatShareMemory:shmat shmget select gun info \n");
|
|
|
|
- return 0;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return result;
|
|
|
|
-}
|
|
|
|
-#endif //0
|
|
|
|
-
|
|
|
|
static void updateFirmwareProcess(int fd, uint8_t gunID, uint8_t totalConnCount)
|
|
static void updateFirmwareProcess(int fd, uint8_t gunID, uint8_t totalConnCount)
|
|
{
|
|
{
|
|
bool canUpdateFirmware = true;
|
|
bool canUpdateFirmware = true;
|
|
@@ -1787,7 +1687,7 @@ static void checkAuthorProcess(int fd, uint8_t plugNum)
|
|
#else
|
|
#else
|
|
gunID = ID_REGISTER;
|
|
gunID = ID_REGISTER;
|
|
|
|
|
|
- ShmSelectGunInfo->PricesInfo[pSysInfo->CurGunSelected].Balance = 0.0;
|
|
|
|
|
|
+ ShmSelectGunInfo->PricesInfo[pSysInfo->CurGunSelected].Balance = 0.0; //非Audi 不需要等待主櫃回報餘額
|
|
#endif // DD360Audi
|
|
#endif // DD360Audi
|
|
|
|
|
|
if ((ShmOCPP16Data->SpMsg.bits.AuthorizeReq == YES) ||
|
|
if ((ShmOCPP16Data->SpMsg.bits.AuthorizeReq == YES) ||
|
|
@@ -1964,7 +1864,9 @@ static int messageTrigger(int fd, uint8_t plugNum, uint8_t gunID, uint8_t curReg
|
|
|
|
|
|
case REG_QRCODE_URL_INFO:
|
|
case REG_QRCODE_URL_INFO:
|
|
if (gunID == 1) {
|
|
if (gunID == 1) {
|
|
- if (DiffTimeb(gRegTimeUp[plugNum][curReg], NowTime) > (LOOP_RETRY_TIME * 10)) {
|
|
|
|
|
|
+ if (DiffTimeb(gRegTimeUp[plugNum][curReg], NowTime) > (LOOP_RETRY_TIME * 10) ||
|
|
|
|
+ DiffTimeb(gRegTimeUp[plugNum][curReg], NowTime) < 0
|
|
|
|
+ ) {
|
|
readQRcodeURLAndSystemDate(fd);
|
|
readQRcodeURLAndSystemDate(fd);
|
|
ftime(&gRegTimeUp[plugNum][curReg]);
|
|
ftime(&gRegTimeUp[plugNum][curReg]);
|
|
}
|
|
}
|
|
@@ -2026,13 +1928,17 @@ static void systemStatusProcess(int fd, uint8_t totalGun, uint8_t plugNum, uint8
|
|
}
|
|
}
|
|
|
|
|
|
ftime(&AuthNowTime);
|
|
ftime(&AuthNowTime);
|
|
- if (DiffTimeb(gRegTimeUp[plugNum][REG_WAIT_PLUG_IT_STATE], AuthNowTime) > (LOOP_RETRY_TIME / 10)) {
|
|
|
|
|
|
+ if (DiffTimeb(gRegTimeUp[plugNum][REG_WAIT_PLUG_IT_STATE], AuthNowTime) > (LOOP_RETRY_TIME / 10) ||
|
|
|
|
+ DiffTimeb(gRegTimeUp[plugNum][REG_WAIT_PLUG_IT_STATE], AuthNowTime) < 0
|
|
|
|
+ ) {
|
|
writeWaitPlugItState(fd, gunID);
|
|
writeWaitPlugItState(fd, gunID);
|
|
ftime(&gRegTimeUp[plugNum][REG_WAIT_PLUG_IT_STATE]);
|
|
ftime(&gRegTimeUp[plugNum][REG_WAIT_PLUG_IT_STATE]);
|
|
}
|
|
}
|
|
|
|
|
|
ftime(&AuthNowTime);
|
|
ftime(&AuthNowTime);
|
|
- if (DiffTimeb(gRegTimeUp[plugNum][REG_CHARGING_CAP], AuthNowTime) > LOOP_RETRY_TIME) {
|
|
|
|
|
|
+ if (DiffTimeb(gRegTimeUp[plugNum][REG_CHARGING_CAP], AuthNowTime) > LOOP_RETRY_TIME ||
|
|
|
|
+ DiffTimeb(gRegTimeUp[plugNum][REG_CHARGING_CAP], AuthNowTime) < 0
|
|
|
|
+ ) {
|
|
readChargingCapability(fd, gunID);
|
|
readChargingCapability(fd, gunID);
|
|
ftime(&gRegTimeUp[plugNum][REG_CHARGING_CAP]);
|
|
ftime(&gRegTimeUp[plugNum][REG_CHARGING_CAP]);
|
|
}
|
|
}
|
|
@@ -2040,13 +1946,17 @@ static void systemStatusProcess(int fd, uint8_t totalGun, uint8_t plugNum, uint8
|
|
|
|
|
|
case S_PREPARNING: //get permission
|
|
case S_PREPARNING: //get permission
|
|
ftime(&AuthNowTime);
|
|
ftime(&AuthNowTime);
|
|
- if (DiffTimeb(gRegTimeUp[plugNum][REG_CONNECTOR_STATE], AuthNowTime) > LOOP_RETRY_TIME) {
|
|
|
|
|
|
+ if (DiffTimeb(gRegTimeUp[plugNum][REG_CONNECTOR_STATE], AuthNowTime) > LOOP_RETRY_TIME ||
|
|
|
|
+ DiffTimeb(gRegTimeUp[plugNum][REG_CONNECTOR_STATE], AuthNowTime) < 0
|
|
|
|
+ ) {
|
|
writeConnectorState(fd, plugNum, gunID);
|
|
writeConnectorState(fd, plugNum, gunID);
|
|
ftime(&gRegTimeUp[plugNum][REG_CONNECTOR_STATE]);
|
|
ftime(&gRegTimeUp[plugNum][REG_CONNECTOR_STATE]);
|
|
}
|
|
}
|
|
|
|
|
|
ftime(&AuthNowTime);
|
|
ftime(&AuthNowTime);
|
|
- if (DiffTimeb(gRegTimeUp[plugNum][REG_CHARGING_PERMISSION], AuthNowTime) > LOOP_RETRY_TIME) {
|
|
|
|
|
|
+ if (DiffTimeb(gRegTimeUp[plugNum][REG_CHARGING_PERMISSION], AuthNowTime) > LOOP_RETRY_TIME ||
|
|
|
|
+ DiffTimeb(gRegTimeUp[plugNum][REG_CHARGING_PERMISSION], AuthNowTime) < 0
|
|
|
|
+ ) {
|
|
if (readChargePermission(fd, gunID) && readChargingCapability(fd, gunID)) {
|
|
if (readChargePermission(fd, gunID) && readChargingCapability(fd, gunID)) {
|
|
for (i = 0; i < totalGun; i++) {
|
|
for (i = 0; i < totalGun; i++) {
|
|
pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(i);
|
|
pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(i);
|
|
@@ -2059,7 +1969,9 @@ static void systemStatusProcess(int fd, uint8_t totalGun, uint8_t plugNum, uint8
|
|
}
|
|
}
|
|
|
|
|
|
ftime(&AuthNowTime);
|
|
ftime(&AuthNowTime);
|
|
- if (DiffTimeb(gRegTimeUp[plugNum][REG_PRESENT_CHARGING_INFO], AuthNowTime) > LOOP_RETRY_TIME) {
|
|
|
|
|
|
+ if (DiffTimeb(gRegTimeUp[plugNum][REG_PRESENT_CHARGING_INFO], AuthNowTime) > LOOP_RETRY_TIME ||
|
|
|
|
+ DiffTimeb(gRegTimeUp[plugNum][REG_PRESENT_CHARGING_INFO], AuthNowTime) < 0
|
|
|
|
+ ) {
|
|
writePresentChargingInfo(fd, plugNum, gunID);
|
|
writePresentChargingInfo(fd, plugNum, gunID);
|
|
ftime(&gRegTimeUp[plugNum][REG_PRESENT_CHARGING_INFO]);
|
|
ftime(&gRegTimeUp[plugNum][REG_PRESENT_CHARGING_INFO]);
|
|
}
|
|
}
|
|
@@ -2067,13 +1979,17 @@ static void systemStatusProcess(int fd, uint8_t totalGun, uint8_t plugNum, uint8
|
|
|
|
|
|
case S_PREPARING_FOR_EV://wait connector lock
|
|
case S_PREPARING_FOR_EV://wait connector lock
|
|
ftime(&AuthNowTime);
|
|
ftime(&AuthNowTime);
|
|
- if (DiffTimeb(gRegTimeUp[plugNum][REG_CHARGING_CAP], AuthNowTime) > LOOP_RETRY_TIME) {
|
|
|
|
|
|
+ if (DiffTimeb(gRegTimeUp[plugNum][REG_CHARGING_CAP], AuthNowTime) > LOOP_RETRY_TIME ||
|
|
|
|
+ DiffTimeb(gRegTimeUp[plugNum][REG_CHARGING_CAP], AuthNowTime) < 0
|
|
|
|
+ ) {
|
|
readChargingCapability(fd, gunID);
|
|
readChargingCapability(fd, gunID);
|
|
ftime(&gRegTimeUp[plugNum][REG_CHARGING_CAP]);
|
|
ftime(&gRegTimeUp[plugNum][REG_CHARGING_CAP]);
|
|
}
|
|
}
|
|
|
|
|
|
ftime(&AuthNowTime);
|
|
ftime(&AuthNowTime);
|
|
- if (DiffTimeb(gRegTimeUp[plugNum][REG_CHARGING_PERMISSION], AuthNowTime) > LOOP_RETRY_TIME) {
|
|
|
|
|
|
+ if (DiffTimeb(gRegTimeUp[plugNum][REG_CHARGING_PERMISSION], AuthNowTime) > LOOP_RETRY_TIME ||
|
|
|
|
+ DiffTimeb(gRegTimeUp[plugNum][REG_CHARGING_PERMISSION], AuthNowTime) < 0
|
|
|
|
+ ) {
|
|
if (readChargePermission(fd, gunID) == 0) {
|
|
if (readChargePermission(fd, gunID) == 0) {
|
|
log_info("S_PREPARING_FOR_EV Stop charging by power cabinet's permission = %d, %d\r\n",
|
|
log_info("S_PREPARING_FOR_EV Stop charging by power cabinet's permission = %d, %d\r\n",
|
|
plugNum,
|
|
plugNum,
|
|
@@ -2084,7 +2000,9 @@ static void systemStatusProcess(int fd, uint8_t totalGun, uint8_t plugNum, uint8
|
|
}
|
|
}
|
|
|
|
|
|
ftime(&AuthNowTime);
|
|
ftime(&AuthNowTime);
|
|
- if (DiffTimeb(gRegTimeUp[plugNum][REG_PRESENT_CHARGING_INFO], AuthNowTime) > LOOP_RETRY_TIME) {
|
|
|
|
|
|
+ if (DiffTimeb(gRegTimeUp[plugNum][REG_PRESENT_CHARGING_INFO], AuthNowTime) > LOOP_RETRY_TIME ||
|
|
|
|
+ DiffTimeb(gRegTimeUp[plugNum][REG_PRESENT_CHARGING_INFO], AuthNowTime) < 0
|
|
|
|
+ ) {
|
|
writePresentChargingInfo(fd, plugNum, gunID);
|
|
writePresentChargingInfo(fd, plugNum, gunID);
|
|
ftime(&gRegTimeUp[plugNum][REG_PRESENT_CHARGING_INFO]);
|
|
ftime(&gRegTimeUp[plugNum][REG_PRESENT_CHARGING_INFO]);
|
|
}
|
|
}
|
|
@@ -2096,13 +2014,17 @@ static void systemStatusProcess(int fd, uint8_t totalGun, uint8_t plugNum, uint8
|
|
writeChargingTarget(fd, plugNum, gunID);
|
|
writeChargingTarget(fd, plugNum, gunID);
|
|
|
|
|
|
ftime(&AuthNowTime);
|
|
ftime(&AuthNowTime);
|
|
- if (DiffTimeb(gRegTimeUp[plugNum][REG_CHARGING_CAP], AuthNowTime) > LOOP_RETRY_TIME) {
|
|
|
|
|
|
+ if (DiffTimeb(gRegTimeUp[plugNum][REG_CHARGING_CAP], AuthNowTime) > LOOP_RETRY_TIME ||
|
|
|
|
+ DiffTimeb(gRegTimeUp[plugNum][REG_CHARGING_CAP], AuthNowTime) < 0
|
|
|
|
+ ) {
|
|
readChargingCapability(fd, gunID);
|
|
readChargingCapability(fd, gunID);
|
|
ftime(&gRegTimeUp[plugNum][REG_CHARGING_CAP]);
|
|
ftime(&gRegTimeUp[plugNum][REG_CHARGING_CAP]);
|
|
}
|
|
}
|
|
|
|
|
|
ftime(&AuthNowTime);
|
|
ftime(&AuthNowTime);
|
|
- if (DiffTimeb(gRegTimeUp[plugNum][REG_CHARGING_PERMISSION], AuthNowTime) > LOOP_RETRY_TIME) {
|
|
|
|
|
|
+ if (DiffTimeb(gRegTimeUp[plugNum][REG_CHARGING_PERMISSION], AuthNowTime) > LOOP_RETRY_TIME ||
|
|
|
|
+ DiffTimeb(gRegTimeUp[plugNum][REG_CHARGING_PERMISSION], AuthNowTime) < 0
|
|
|
|
+ ) {
|
|
if (readChargePermission(fd, gunID) == 0) {
|
|
if (readChargePermission(fd, gunID) == 0) {
|
|
log_info("S_PREPARING_FOR_EVSE Stop charging by power cabinet's permission = %d, %d\r\n",
|
|
log_info("S_PREPARING_FOR_EVSE Stop charging by power cabinet's permission = %d, %d\r\n",
|
|
plugNum,
|
|
plugNum,
|
|
@@ -2113,7 +2035,9 @@ static void systemStatusProcess(int fd, uint8_t totalGun, uint8_t plugNum, uint8
|
|
}
|
|
}
|
|
|
|
|
|
ftime(&AuthNowTime);
|
|
ftime(&AuthNowTime);
|
|
- if (DiffTimeb(gRegTimeUp[plugNum][REG_PRESENT_CHARGING_INFO], AuthNowTime) > LOOP_RETRY_TIME) {
|
|
|
|
|
|
+ if (DiffTimeb(gRegTimeUp[plugNum][REG_PRESENT_CHARGING_INFO], AuthNowTime) > LOOP_RETRY_TIME ||
|
|
|
|
+ DiffTimeb(gRegTimeUp[plugNum][REG_PRESENT_CHARGING_INFO], AuthNowTime) < 0
|
|
|
|
+ ) {
|
|
writePresentChargingInfo(fd, plugNum, gunID);
|
|
writePresentChargingInfo(fd, plugNum, gunID);
|
|
ftime(&gRegTimeUp[plugNum][REG_PRESENT_CHARGING_INFO]);
|
|
ftime(&gRegTimeUp[plugNum][REG_PRESENT_CHARGING_INFO]);
|
|
}
|
|
}
|
|
@@ -2122,13 +2046,17 @@ static void systemStatusProcess(int fd, uint8_t totalGun, uint8_t plugNum, uint8
|
|
case S_CHARGING: //charging
|
|
case S_CHARGING: //charging
|
|
case S_TERMINATING:
|
|
case S_TERMINATING:
|
|
ftime(&AuthNowTime);
|
|
ftime(&AuthNowTime);
|
|
- if (DiffTimeb(gRegTimeUp[plugNum][REG_CHARGING_CAP], AuthNowTime) > LOOP_RETRY_TIME) {
|
|
|
|
|
|
+ if (DiffTimeb(gRegTimeUp[plugNum][REG_CHARGING_CAP], AuthNowTime) > LOOP_RETRY_TIME ||
|
|
|
|
+ DiffTimeb(gRegTimeUp[plugNum][REG_CHARGING_CAP], AuthNowTime) < 0
|
|
|
|
+ ) {
|
|
readChargingCapability(fd, gunID);
|
|
readChargingCapability(fd, gunID);
|
|
ftime(&gRegTimeUp[plugNum][REG_CHARGING_CAP]);
|
|
ftime(&gRegTimeUp[plugNum][REG_CHARGING_CAP]);
|
|
}
|
|
}
|
|
|
|
|
|
ftime(&AuthNowTime);
|
|
ftime(&AuthNowTime);
|
|
- if (DiffTimeb(gRegTimeUp[plugNum][REG_CHARGING_PERMISSION], AuthNowTime) > LOOP_RETRY_TIME) {
|
|
|
|
|
|
+ if (DiffTimeb(gRegTimeUp[plugNum][REG_CHARGING_PERMISSION], AuthNowTime) > LOOP_RETRY_TIME ||
|
|
|
|
+ DiffTimeb(gRegTimeUp[plugNum][REG_CHARGING_PERMISSION], AuthNowTime) < 0
|
|
|
|
+ ) {
|
|
if (readChargePermission(fd, gunID) == 0) {
|
|
if (readChargePermission(fd, gunID) == 0) {
|
|
log_info("Stop charging by power cabinet's permission = %d, %d\r\n",
|
|
log_info("Stop charging by power cabinet's permission = %d, %d\r\n",
|
|
plugNum,
|
|
plugNum,
|
|
@@ -2141,7 +2069,9 @@ static void systemStatusProcess(int fd, uint8_t totalGun, uint8_t plugNum, uint8
|
|
writeChargingTarget(fd, plugNum, gunID);
|
|
writeChargingTarget(fd, plugNum, gunID);
|
|
|
|
|
|
ftime(&AuthNowTime);
|
|
ftime(&AuthNowTime);
|
|
- if (DiffTimeb(gRegTimeUp[plugNum][REG_PRESENT_CHARGING_INFO], AuthNowTime) > LOOP_RETRY_TIME) {
|
|
|
|
|
|
+ if (DiffTimeb(gRegTimeUp[plugNum][REG_PRESENT_CHARGING_INFO], AuthNowTime) > LOOP_RETRY_TIME ||
|
|
|
|
+ DiffTimeb(gRegTimeUp[plugNum][REG_PRESENT_CHARGING_INFO], AuthNowTime) < 0
|
|
|
|
+ ) {
|
|
writePresentChargingInfo(fd, plugNum, gunID);
|
|
writePresentChargingInfo(fd, plugNum, gunID);
|
|
ftime(&gRegTimeUp[plugNum][REG_PRESENT_CHARGING_INFO]);
|
|
ftime(&gRegTimeUp[plugNum][REG_PRESENT_CHARGING_INFO]);
|
|
}
|
|
}
|
|
@@ -2149,7 +2079,9 @@ static void systemStatusProcess(int fd, uint8_t totalGun, uint8_t plugNum, uint8
|
|
|
|
|
|
case S_COMPLETE:
|
|
case S_COMPLETE:
|
|
ftime(&AuthNowTime);
|
|
ftime(&AuthNowTime);
|
|
- if (DiffTimeb(gRegTimeUp[plugNum][REG_CHARGING_CAP], AuthNowTime) > LOOP_RETRY_TIME) {
|
|
|
|
|
|
+ if (DiffTimeb(gRegTimeUp[plugNum][REG_CHARGING_CAP], AuthNowTime) > LOOP_RETRY_TIME ||
|
|
|
|
+ DiffTimeb(gRegTimeUp[plugNum][REG_CHARGING_CAP], AuthNowTime) < 0
|
|
|
|
+ ) {
|
|
readChargingCapability(fd, gunID);
|
|
readChargingCapability(fd, gunID);
|
|
ftime(&gRegTimeUp[plugNum][REG_CHARGING_CAP]);
|
|
ftime(&gRegTimeUp[plugNum][REG_CHARGING_CAP]);
|
|
}
|
|
}
|
|
@@ -2222,17 +2154,6 @@ int main(int argc, char *argv[])
|
|
InitSocketSigPipe();
|
|
InitSocketSigPipe();
|
|
|
|
|
|
/**************** Initialization **********/
|
|
/**************** Initialization **********/
|
|
- /*if (InitShareMemory() == 0) {
|
|
|
|
- if (ShmStatusCodeData != NULL) {
|
|
|
|
- pAlarmCode->AlarmEvents.bits.FailToCreateShareMemory = YES;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- log_error("DoComm Initial share memory fail\r\n");
|
|
|
|
- sleep(5);
|
|
|
|
-
|
|
|
|
- return 0;
|
|
|
|
- }
|
|
|
|
- */
|
|
|
|
if (CreateAllCsuShareMemory() == FAIL) {
|
|
if (CreateAllCsuShareMemory() == FAIL) {
|
|
log_error("create share memory error\r\n");
|
|
log_error("create share memory error\r\n");
|
|
return FAIL;
|
|
return FAIL;
|
|
@@ -2254,16 +2175,13 @@ int main(int argc, char *argv[])
|
|
totalConnCount = pSysConfig->TotalConnectorCount;
|
|
totalConnCount = pSysConfig->TotalConnectorCount;
|
|
|
|
|
|
for (index = 0; index < totalConnCount; index++) {
|
|
for (index = 0; index < totalConnCount; index++) {
|
|
- //if (!FindChargingInfoData(index, &ChargingData[0])) {
|
|
|
|
- // log_error("FindChargingInfoData false \n");
|
|
|
|
- // break;
|
|
|
|
- //}
|
|
|
|
clearPricesInfo(index);
|
|
clearPricesInfo(index);
|
|
}
|
|
}
|
|
|
|
|
|
//initial trigger message timer
|
|
//initial trigger message timer
|
|
for (index = 0; index < MAX_REGISTER_NUM; index++) {
|
|
for (index = 0; index < MAX_REGISTER_NUM; index++) {
|
|
ftime(&gRegTimeUp[0][index]);
|
|
ftime(&gRegTimeUp[0][index]);
|
|
|
|
+ usleep(128);
|
|
ftime(&gRegTimeUp[1][index]);
|
|
ftime(&gRegTimeUp[1][index]);
|
|
usleep(50000);
|
|
usleep(50000);
|
|
}
|
|
}
|
|
@@ -2280,8 +2198,9 @@ int main(int argc, char *argv[])
|
|
gunID = 0;
|
|
gunID = 0;
|
|
for (plugNum = 0; plugNum < totalConnCount; plugNum++) {
|
|
for (plugNum = 0; plugNum < totalConnCount; plugNum++) {
|
|
//checkAuthorProcess(fd, plugNum);
|
|
//checkAuthorProcess(fd, plugNum);
|
|
- //plugNum = setup chargingData value for bottom layer
|
|
|
|
- //gunID = (plugNum + 1); //connector Id, 1 = left gun, 2 = right gun
|
|
|
|
|
|
+
|
|
|
|
+ //plugNum : setup chargingData value for bottom layer
|
|
|
|
+ //gunID : connector Id from power cabinet, 1 = left gun, 2 = right gun,
|
|
gunID = gDoCommGblData.ConnectorID[plugNum];
|
|
gunID = gDoCommGblData.ConnectorID[plugNum];
|
|
systemStatusProcess(fd, totalConnCount, plugNum, gunID);
|
|
systemStatusProcess(fd, totalConnCount, plugNum, gunID);
|
|
|
|
|
|
@@ -2296,33 +2215,32 @@ int main(int argc, char *argv[])
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- if (initDone == DISPENSER_SOCKET_RECONN) {
|
|
|
|
- //system("udhcpc -r eth0");
|
|
|
|
- log_info("Disconnected from power cabinet...re-connecting");
|
|
|
|
- setTcpStatus(ABNORMAL);
|
|
|
|
-
|
|
|
|
|
|
+ if (initDone != DISPENSER_SOCKET_RECONN) {
|
|
|
|
+ //update dispenser firmware
|
|
|
|
+ updateFirmwareProcess(fd, gDoCommGblData.ConnectorID[0], totalConnCount);
|
|
|
|
|
|
- if (pSysConfig->Eth0Interface.EthDhcpClient == 0) {
|
|
|
|
- sprintf(tmpbuf,
|
|
|
|
- "/sbin/udhcpc -i eth0 -x hostname:CSU3_%s -s /root/dhcp_script/eth0.script > /dev/null &",
|
|
|
|
- pSysConfig->SystemId);
|
|
|
|
- system(tmpbuf);
|
|
|
|
- }
|
|
|
|
|
|
+ usleep(100000);
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
|
|
- gDoCommGblData.DisConnCount = 0;
|
|
|
|
- gDoCommGblData.SeqNum = 0;
|
|
|
|
|
|
+ //Ethernet error recovery handle
|
|
|
|
+ log_info("Disconnected from power cabinet...re-connecting");
|
|
|
|
+ setTcpStatus(ABNORMAL);
|
|
|
|
|
|
- closeSocket(fd);
|
|
|
|
- fd = 0;
|
|
|
|
|
|
|
|
- initDone = DISPENER_INIT_FAIL;
|
|
|
|
|
|
+ if (pSysConfig->Eth0Interface.EthDhcpClient == 0) {
|
|
|
|
+ sprintf(tmpbuf,
|
|
|
|
+ "/sbin/udhcpc -i eth0 -x hostname:CSU3_%s -s /root/dhcp_script/eth0.script > /dev/null &",
|
|
|
|
+ pSysConfig->SystemId);
|
|
|
|
+ system(tmpbuf);
|
|
}
|
|
}
|
|
|
|
|
|
- //update dispenser firmware
|
|
|
|
- if (initDone != DISPENER_INIT_FAIL) {
|
|
|
|
- updateFirmwareProcess(fd, gDoCommGblData.ConnectorID[0], totalConnCount);
|
|
|
|
- }
|
|
|
|
|
|
+ gDoCommGblData.DisConnCount = 0;
|
|
|
|
+ gDoCommGblData.SeqNum = 0;
|
|
|
|
+
|
|
|
|
+ closeSocket(fd);
|
|
|
|
+ fd = 0;
|
|
|
|
|
|
- usleep(100000);
|
|
|
|
|
|
+ initDone = DISPENER_INIT_FAIL;
|
|
}
|
|
}
|
|
}
|
|
}
|