|
@@ -29,11 +29,6 @@
|
|
|
#include "../timeout.h"
|
|
|
#include "DoComm.h"
|
|
|
|
|
|
-//------------------------------------------------------------------------------
|
|
|
-//#define log_info(format, args...) StoreLogMsg("[%s:%d][%s][Info] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
|
|
|
-//#define log_warn(format, args...) StoreLogMsg("[%s:%d][%s][Warn] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
|
|
|
-//#define log_error(format, args...) StoreLogMsg("[%s:%d][%s][Error] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
|
|
|
-
|
|
|
//------------------------------------------------------------------------------
|
|
|
static DoCommGblData gDoCommGblData = {0};
|
|
|
|
|
@@ -52,6 +47,9 @@ static struct ChargingInfoData *pDcChargingInfo = NULL;
|
|
|
static struct timeb gRegTimeUp[2][MAX_REGISTER_NUM] = {0};
|
|
|
static struct WARNING_CODE_INFO gPreSysWarningInfo = {0};
|
|
|
|
|
|
+// Hexdump
|
|
|
+char old_Hexdump[10240];
|
|
|
+
|
|
|
//------------------------------------------------------------------------------
|
|
|
static void removeFaultCodeToBuf(uint8_t *Code);
|
|
|
static void addFaultCodeToBuf(uint8_t *Code);
|
|
@@ -67,39 +65,6 @@ void GetClockTime(struct timespec *_now_time, void *null)
|
|
|
clock_gettime(CLOCK_MONOTONIC, _now_time);
|
|
|
}
|
|
|
|
|
|
-/*static int StoreLogMsg(const char *fmt, ...)
|
|
|
-{
|
|
|
- char Buf[4096 + 256];
|
|
|
- char buffer[4096];
|
|
|
- va_list args;
|
|
|
- struct timeb SeqEndTime;
|
|
|
- struct tm *tm;
|
|
|
-
|
|
|
- va_start(args, fmt);
|
|
|
- int rc = vsnprintf(buffer, sizeof(buffer), fmt, args);
|
|
|
- va_end(args);
|
|
|
-
|
|
|
- memset(Buf, 0, sizeof(Buf));
|
|
|
- ftime(&SeqEndTime);
|
|
|
- SeqEndTime.time = time(NULL);
|
|
|
- tm = localtime(&SeqEndTime.time);
|
|
|
-
|
|
|
- if (pSysConfig->SwitchDebugFlag == 1) {
|
|
|
- sprintf(Buf, "%02d:%02d:%02d:%03d - %s",
|
|
|
- tm->tm_hour, tm->tm_min, tm->tm_sec, SeqEndTime.millitm, buffer);
|
|
|
- printf("%s \n", Buf);
|
|
|
- } else {
|
|
|
- sprintf(Buf, "echo \"%04d-%02d-%02d %02d:%02d:%02d:%03d - %s\" >> /Storage/SystemLog/[%04d.%02d]SystemLog",
|
|
|
- tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, SeqEndTime.millitm,
|
|
|
- buffer,
|
|
|
- tm->tm_year + 1900, tm->tm_mon + 1);
|
|
|
- system(Buf);
|
|
|
- }
|
|
|
-
|
|
|
- return rc;
|
|
|
-}
|
|
|
-*/
|
|
|
-
|
|
|
static int DiffTimeb(struct timeb ST, struct timeb ET)
|
|
|
{
|
|
|
//return milli-second
|
|
@@ -127,8 +92,8 @@ static void Hexdump(const void *p, size_t size)
|
|
|
|
|
|
assert(p);
|
|
|
|
|
|
- //printf("Dumping %u bytes from %p:\r\n", size, p);
|
|
|
- message_len += sprintf(&message[message_len], "\r\nDumping %u bytes from %p:\r\n", (unsigned int)size, p);
|
|
|
+ //printf("Dumping %u bytes from %p:\n", size, p);
|
|
|
+ message_len += sprintf(&message[message_len], "\nDumping %u bytes from %p:\n", (unsigned int)size, p);
|
|
|
|
|
|
while (size > 0) {
|
|
|
for (i = 0; i < 16; i++) {
|
|
@@ -152,7 +117,7 @@ static void Hexdump(const void *p, size_t size)
|
|
|
}
|
|
|
|
|
|
//printf("\n");
|
|
|
- message_len += sprintf(&message[message_len], "\r\n");
|
|
|
+ message_len += sprintf(&message[message_len], "\n");
|
|
|
c += 16;
|
|
|
|
|
|
if (size <= 16) {
|
|
@@ -162,9 +127,11 @@ static void Hexdump(const void *p, size_t size)
|
|
|
size -= 16;
|
|
|
}
|
|
|
|
|
|
- message_len += sprintf(&message[message_len], "\r\n");
|
|
|
-
|
|
|
- log_info("%s", message);
|
|
|
+ //message_len += sprintf(&message[message_len], "\n");
|
|
|
+ if( strcmp(old_Hexdump,message) != EQUAL ) {
|
|
|
+ log_info("%s", message);
|
|
|
+ strcpy(old_Hexdump,message);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
static int string2ByteArray(char *input, uint8_t *output)
|
|
@@ -182,7 +149,7 @@ static int string2ByteArray(char *input, uint8_t *output)
|
|
|
|
|
|
static void unixSocketSigPipeHandle(int sig)
|
|
|
{
|
|
|
- log_error("socket packet error %x\r\n", sig);
|
|
|
+ log_error("socket packet error %x", sig);
|
|
|
}
|
|
|
|
|
|
static void InitSocketSigPipe(void)
|
|
@@ -211,7 +178,7 @@ static int sendTcpSocket(int fd, uint8_t *data, uint16_t dataLen)
|
|
|
size = send(fd, data, dataLen , 0);
|
|
|
if ((size < 0) || (errno == EAGAIN)) {
|
|
|
if (size < 0) {
|
|
|
- log_error("Size = %d, EAGAIN error %d:%s\r\n", size, errno, strerror(errno));
|
|
|
+ log_error("Send Socket Size = %d, EAGAIN error %d:%s", size, errno, strerror(errno));
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -225,7 +192,7 @@ static int recvTcpSocket(int fd, uint8_t *data, uint16_t dataLen)
|
|
|
|
|
|
size = recv(fd, pdata, dataLen, MSG_WAITALL);
|
|
|
if ((errno == EAGAIN) || (size < 0)) {
|
|
|
- log_error("Size = %d, EAGAIN error %d:%s\r\n", size, errno, strerror(errno));
|
|
|
+ log_error("Receive Socket Size = %d, EAGAIN error %d:%s", size, errno, strerror(errno));
|
|
|
}
|
|
|
|
|
|
return size;
|
|
@@ -237,7 +204,7 @@ static int getSO_ERROR(int fd)
|
|
|
socklen_t len = sizeof err;
|
|
|
|
|
|
if (-1 == getsockopt(fd, SOL_SOCKET, SO_ERROR, (char *)&err, &len)) {
|
|
|
- log_error("getSO_ERROR\r\n");
|
|
|
+ log_error("getSO_ERROR");
|
|
|
}
|
|
|
|
|
|
if (err) {
|
|
@@ -256,12 +223,12 @@ static void closeSocket(int fd) // *not* the Windows closesocket()
|
|
|
getSO_ERROR(fd); // first clear any errors, which can cause close to fail
|
|
|
if (shutdown(fd, SHUT_RDWR) < 0) { // secondly, terminate the 'reliable' delivery
|
|
|
if (errno != ENOTCONN && errno != EINVAL) { // SGI causes EINVAL
|
|
|
- log_info("shutdown\r\n");
|
|
|
+ log_info("shutdown");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (close(fd) < 0) { // finally call close()
|
|
|
- log_info("client socket close\r\n");
|
|
|
+ log_info("client socket close");
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -400,10 +367,10 @@ static void setConfirmSelGun(uint8_t selGun)
|
|
|
{
|
|
|
if (selGun == LEFT_GUN_NUM && ShmSelectGunInfo->SelGunInfo.LeftGun == SEL_GUN_RELEASE) {
|
|
|
ShmSelectGunInfo->SelGunInfo.LeftGun = SEL_GUN_CONFIRM;
|
|
|
- //printf("confirmSelGun left\r\n");
|
|
|
+ //printf("confirmSelGun left");
|
|
|
} else if (selGun == RIGHT_GUN_NUM && ShmSelectGunInfo->SelGunInfo.RightGun == SEL_GUN_RELEASE) {
|
|
|
ShmSelectGunInfo->SelGunInfo.RightGun = SEL_GUN_CONFIRM;
|
|
|
- //printf("confirmSelGun right\r\n");
|
|
|
+ //printf("confirmSelGun right");
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -413,7 +380,7 @@ static void setConfirmSelGun(uint8_t selGun)
|
|
|
static int compareOpcode(uint8_t opCode)
|
|
|
{
|
|
|
if (opCode != OP_WAIT_RESPONSE) {
|
|
|
- //log_error("response operative code fail\r\n");
|
|
|
+ //log_error("response operative code fail");
|
|
|
return FAIL;
|
|
|
}
|
|
|
|
|
@@ -423,7 +390,7 @@ static int compareOpcode(uint8_t opCode)
|
|
|
static int compareResult(uint8_t result)
|
|
|
{
|
|
|
if (result != COMMAND_RESULT_OK) {
|
|
|
- //log_error("response result fail\r\n");
|
|
|
+ //log_error("response result fail");
|
|
|
return FAIL;
|
|
|
}
|
|
|
|
|
@@ -433,7 +400,7 @@ static int compareResult(uint8_t result)
|
|
|
static int compareRegister(uint8_t srcReg, uint8_t destReg)
|
|
|
{
|
|
|
if (srcReg != destReg) {
|
|
|
- //log_error("response register fail\r\n");
|
|
|
+ //log_error("response register fail");
|
|
|
return FAIL;
|
|
|
}
|
|
|
|
|
@@ -442,7 +409,7 @@ static int compareRegister(uint8_t srcReg, uint8_t destReg)
|
|
|
|
|
|
static float transPricesUnit(int prices)
|
|
|
{
|
|
|
- //printf("prices = %.2f\r\n", prices * PRICES_UNIT);
|
|
|
+ //printf("prices = %.2f", prices * PRICES_UNIT);
|
|
|
return (prices * PRICES_UNIT);
|
|
|
}
|
|
|
|
|
@@ -461,7 +428,7 @@ static int qrCodeUrlInfoHandle(uint8_t *data)
|
|
|
struct tm *tm;
|
|
|
|
|
|
if ((char *)&data[0] == '\0') {
|
|
|
- log_error("QR code date error\r\n");
|
|
|
+ log_error("QR code date error");
|
|
|
return FAIL;
|
|
|
}
|
|
|
|
|
@@ -479,14 +446,14 @@ static int qrCodeUrlInfoHandle(uint8_t *data)
|
|
|
//copy QR code string
|
|
|
if (strncmp((char *)localTime, (char *)&data[0], timeLen - 2) != 0) {
|
|
|
memset(pSysConfig->SystemId, '\0', sizeof(pSysConfig->SystemId));
|
|
|
- //printf("data = %s\r\n", data);
|
|
|
+ //printf("data = %s", data);
|
|
|
//len =
|
|
|
string2ByteArray((char *)data, (uint8_t *)pSysConfig->SystemId);
|
|
|
- //printf("SystemId = %s\r\n", pSysConfig->SystemId);
|
|
|
+ //printf("SystemId = %s", pSysConfig->SystemId);
|
|
|
}
|
|
|
|
|
|
//if ((char *)&data[len] == '\0') {
|
|
|
- // log_error("power cabinet system date error\r\n");
|
|
|
+ // log_error("power cabinet system date error");
|
|
|
// return FAIL;
|
|
|
//}
|
|
|
|
|
@@ -494,7 +461,7 @@ static int qrCodeUrlInfoHandle(uint8_t *data)
|
|
|
//if (strncmp((char *)localTime, (char *)&data[len], timeLen) != 0) {
|
|
|
// sprintf(cmdBuf, "date -s \"%s\" >> /dev/null", (char *)&data[len]);
|
|
|
// system(cmdBuf);
|
|
|
- // log_info("local time = %s, data time = %s\r\n", localTime, (char *)&data[len]);
|
|
|
+ // log_info("local time = %s, data time = %s", localTime, (char *)&data[len]);
|
|
|
// ShmOCPP16Data->MsMsg.bits.ResetReq = YES;
|
|
|
// strcpy((char *)ShmOCPP16Data->Reset.Type, "Soft");
|
|
|
// sleep(3);
|
|
@@ -510,12 +477,12 @@ static int updateFirmwareHandle(uint8_t *imgName)
|
|
|
char cmdBuf[1024] = {0};
|
|
|
|
|
|
sprintf(cmdBuf, "/mnt/%s", imgName);
|
|
|
- log_info("Program ready to check file %s\n", cmdBuf);
|
|
|
+ log_info("Program ready to check file %s", cmdBuf);
|
|
|
if ( access(cmdBuf, F_OK) != -1) {
|
|
|
- log_info("File '%s' exist.\n", cmdBuf);
|
|
|
+ log_info("File '%s' exist.", cmdBuf);
|
|
|
pSysInfo->FirmwareUpdate = YES;
|
|
|
} else {
|
|
|
- log_info("File '%s' doesn't exist.\n", cmdBuf);
|
|
|
+ log_info("File '%s' doesn't exist.", cmdBuf);
|
|
|
ret = FAIL;
|
|
|
}
|
|
|
|
|
@@ -535,17 +502,17 @@ static int updateFirmwareHandle(uint8_t *imgName)
|
|
|
if (-1 == status) {
|
|
|
printf("system error!");
|
|
|
} else {
|
|
|
- printf("exit status value = [0x%x]\n", status);
|
|
|
+ printf("exit status value = [0x%x]", status);
|
|
|
|
|
|
if (WIFEXITED(status)) {
|
|
|
if (0 == WEXITSTATUS(status)) {
|
|
|
- printf("run shell script successfully.\n");
|
|
|
+ printf("run shell script successfully.");
|
|
|
pSysInfo->FirmwareUpdate = YES;
|
|
|
} else {
|
|
|
- printf("run shell script fail, script exit code: %d\n", WEXITSTATUS(status));
|
|
|
+ printf("run shell script fail, script exit code: %d", WEXITSTATUS(status));
|
|
|
}
|
|
|
} else {
|
|
|
- printf("exit status = [%d]\n", WEXITSTATUS(status));
|
|
|
+ printf("exit status = [%d]", WEXITSTATUS(status));
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -567,7 +534,7 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t plugNum, uint8_t *data)
|
|
|
|
|
|
if (cmdCount < 1) {
|
|
|
gDoCommGblData.MiscCmd = 0;
|
|
|
- //printf("cmdCount fail = %d, data len = %d\r\n", cmdCount, dataLen);
|
|
|
+ //printf("cmdCount fail = %d, data len = %d", cmdCount, dataLen);
|
|
|
return FAIL;
|
|
|
}
|
|
|
|
|
@@ -575,13 +542,13 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t plugNum, uint8_t *data)
|
|
|
pMiscCmd = (MiscCommand *)data + i;
|
|
|
cmd = ntohs(pMiscCmd->CMD);
|
|
|
value = ntohl(*((uint32_t *)&pMiscCmd->Value[0]));
|
|
|
- //log_info("misc command = %x, value = %d\r\n", cmd, value);
|
|
|
+ //log_info("misc command = %x, value = %d", cmd, value);
|
|
|
|
|
|
switch (cmd) {
|
|
|
//--- Execute parameter ---
|
|
|
case MISC_CMD_CONNECOTOR_TIMEOUT:
|
|
|
ShmSelectGunInfo->RemoteSetup.ConnectionTimeout = value;
|
|
|
- log_info("connection timeout = %d\r\n", ShmSelectGunInfo->RemoteSetup.ConnectionTimeout);
|
|
|
+ log_info("connection timeout = %d", ShmSelectGunInfo->RemoteSetup.ConnectionTimeout);
|
|
|
clearMiscCommand();
|
|
|
break;
|
|
|
|
|
@@ -593,7 +560,7 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t plugNum, uint8_t *data)
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
- log_info("change availability plugNum = %d, value = %d\r\n", plugNum, value);
|
|
|
+ log_info("change availability plugNum = %d, value = %d", plugNum, value);
|
|
|
ShmOCPP16Data->CsMsg.bits[plugNum].ChangeAvailabilityReq = YES;
|
|
|
if (value == YES) {
|
|
|
strcpy((char *)ShmOCPP16Data->ChangeAvailability[plugNum].Type, "Operative");
|
|
@@ -608,7 +575,7 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t plugNum, uint8_t *data)
|
|
|
|
|
|
case MISC_CMD_DEFAULT_PRICES:
|
|
|
prices = transPricesUnit((int)value);
|
|
|
- log_info("default prices = %.2f\r\n", prices);
|
|
|
+ log_info("default prices = %.2f", prices);
|
|
|
|
|
|
//pSysConfig->BillingData.isBilling = YES;
|
|
|
for (j = 0; j < 24; j++) {
|
|
@@ -624,8 +591,8 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t plugNum, uint8_t *data)
|
|
|
return FAIL;
|
|
|
}
|
|
|
|
|
|
- //log_info("default currency = %s%c\r\n", (uint8_t *)Currency[value]);
|
|
|
- log_info("default currency = %s\r\n", (uint8_t *)GetCurrency(value));
|
|
|
+ //log_info("default currency = %s%c", (uint8_t *)Currency[value]);
|
|
|
+ log_info("default currency = %s", (uint8_t *)GetCurrency(value));
|
|
|
pSysConfig->BillingData.Currency = value;
|
|
|
clearMiscCommand();
|
|
|
break;
|
|
@@ -638,13 +605,13 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t plugNum, uint8_t *data)
|
|
|
|
|
|
#if defined DD360Audi
|
|
|
if (getConfirmSelectedGun(plugNum) == FAIL) {
|
|
|
- log_info("Remote start not select gun\r\n");
|
|
|
+ log_info("Remote start not select gun");
|
|
|
break;
|
|
|
}
|
|
|
#endif //DD360Audi
|
|
|
|
|
|
ShmSelectGunInfo->PricesInfo[plugNum].Balance = transPricesUnit((int)value);
|
|
|
- log_info("%d misc balance = %.2f\r\n", plugNum, ShmSelectGunInfo->PricesInfo[plugNum].Balance);
|
|
|
+ log_info("%d misc balance = %.2f", plugNum, ShmSelectGunInfo->PricesInfo[plugNum].Balance);
|
|
|
clearMiscCommand();
|
|
|
break;
|
|
|
|
|
@@ -679,7 +646,7 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t plugNum, uint8_t *data)
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
- log_info("Hardware reboot\r\n");
|
|
|
+ log_info("Hardware reboot");
|
|
|
ShmOCPP16Data->MsMsg.bits.ResetReq = YES;
|
|
|
strcpy((char *)ShmOCPP16Data->Reset.Type, "Hard");
|
|
|
clearMiscCommand();
|
|
@@ -692,7 +659,7 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t plugNum, uint8_t *data)
|
|
|
}
|
|
|
|
|
|
clearMiscCommand();
|
|
|
- log_info("Software reboot\r\n");
|
|
|
+ log_info("Software reboot");
|
|
|
ShmOCPP16Data->MsMsg.bits.ResetReq = YES;
|
|
|
strcpy((char *)ShmOCPP16Data->Reset.Type, "Soft");
|
|
|
break;
|
|
@@ -704,11 +671,11 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t plugNum, uint8_t *data)
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
- log_info("Remote start charging plugNum = %d\r\n", plugNum);
|
|
|
+ log_info("Remote start charging plugNum = %d", plugNum);
|
|
|
|
|
|
#if defined DD360Audi
|
|
|
if (getSelGunWaitToAuthor(plugNum) == FAIL) {
|
|
|
- log_error("Remote start gun already charging\r\n");
|
|
|
+ log_error("Remote start gun already charging");
|
|
|
break;
|
|
|
}
|
|
|
|
|
@@ -791,6 +758,16 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t plugNum, uint8_t *data)
|
|
|
pDcChargingInfo->StopChargeFlag = POWER_CABINET_STOP_CHARGING;
|
|
|
}
|
|
|
break;
|
|
|
+ case MISC_CMD_AUTH_DISABLE:
|
|
|
+ pSysConfig->AutoAuth_Disable = value;
|
|
|
+ log_info("Auto Authorize Disable:%d", pSysConfig->AutoAuth_Disable);
|
|
|
+ //clearMiscCommand();
|
|
|
+ break;
|
|
|
+ case MISC_CMD_EVCCID_ENABLE:
|
|
|
+ pSysConfig->EVCCID_Authorize = value;
|
|
|
+ log_info("Authorize By EVCCID:%d",pSysConfig->EVCCID_Authorize);
|
|
|
+ //clearMiscCommand();
|
|
|
+ break;
|
|
|
|
|
|
default:
|
|
|
clearMiscCommand();
|
|
@@ -840,7 +817,7 @@ static int chargingcapabilityHandle(uint8_t *data, uint8_t plugNum)
|
|
|
//MaxVolt = (float)(data[0] << 8 |data[1]);
|
|
|
//MaxCurrent = (float)(data[2] << 8 | data[3]);
|
|
|
//MaxPower = (float)(data[4] << 8 | data[5]);
|
|
|
- //printf("MaxVolt=%f, MaxCurrent=%f, MaxPower=%f,\n", MaxVolt, MaxCurrent, MaxPower);
|
|
|
+ //printf("MaxVolt=%f, MaxCurrent=%f, MaxPower=%f,", MaxVolt, MaxCurrent, MaxPower);
|
|
|
|
|
|
//--- user prices information ----------------------------------------------
|
|
|
addr = (sizeof(CapabilityInfo) - 2); //2 byte reserved
|
|
@@ -856,7 +833,7 @@ static int chargingcapabilityHandle(uint8_t *data, uint8_t plugNum)
|
|
|
pricesInfo[plugNum].UserPrices = ShmSelectGunInfo->PricesInfo[plugNum].UserPrices;
|
|
|
pricesInfo[plugNum].Balance = ShmSelectGunInfo->PricesInfo[plugNum].Balance;
|
|
|
|
|
|
- log_info("id = %d, user prices = %.2f, Total cost = %.2f, Account balances = %.2f, currency = %s\r\n",
|
|
|
+ log_info("id = %d, user prices = %.2f, Total cost = %.2f, Account balances = %.2f, currency = %s",
|
|
|
plugNum,
|
|
|
ShmSelectGunInfo->PricesInfo[plugNum].UserPrices,
|
|
|
pDcChargingInfo->ChargingFee,
|
|
@@ -940,12 +917,12 @@ static int powerCabinetStatusProcess(uint8_t dataLen, uint8_t *data)
|
|
|
remaindLen = dataLen % WARNING_CODE_SIZE;
|
|
|
|
|
|
if (remaindLen != 0) {
|
|
|
- log_info("fail status code length = %d\r\n", dataLen);
|
|
|
+ log_info("fail status code length = %d", dataLen);
|
|
|
dataLen -= remaindLen;
|
|
|
}
|
|
|
|
|
|
if (dataLen < WARNING_CODE_SIZE) {
|
|
|
- log_error("fail status code length = %d\r\n", dataLen);
|
|
|
+ log_error("fail status code length = %d", dataLen);
|
|
|
Hexdump(data, dataLen);
|
|
|
if (pSysWarning->WarningCount > 0) {
|
|
|
for (i = 0; i < pSysWarning->WarningCount; i++) {
|
|
@@ -991,7 +968,7 @@ static int powerCabinetStatusProcess(uint8_t dataLen, uint8_t *data)
|
|
|
if (CompareArrayIsZero((uint8_t *)&data[count], WARNING_CODE_SIZE) == true) {
|
|
|
memset(EventCodeTmp, 0, sizeof(EventCodeTmp));
|
|
|
memcpy(EventCodeTmp, (char *)&data[count], sizeof(EventCodeTmp));
|
|
|
- log_error("error status = %s\r\n", EventCodeTmp);
|
|
|
+ log_error("error status = %s", EventCodeTmp);
|
|
|
continue;
|
|
|
}
|
|
|
|
|
@@ -1015,7 +992,7 @@ static int powerCabinetStatusProcess(uint8_t dataLen, uint8_t *data)
|
|
|
}
|
|
|
} else {
|
|
|
if (CompareArrayIsZero(data, WARNING_CODE_SIZE) == false) {
|
|
|
- log_error("power cabinet status code data length is zero, but have data\r\n");
|
|
|
+ log_error("power cabinet status code data length is zero, but have data");
|
|
|
Hexdump((uint8_t *)data, WARNING_CODE_SIZE);
|
|
|
}
|
|
|
}
|
|
@@ -1077,7 +1054,7 @@ static int responsePackeHandle(int fd, uint8_t *pResult, uint8_t plugNum, uint8_
|
|
|
case REG_CONNECTOR_ID:
|
|
|
gDoCommGblData.ConnectorID[0] = pCsuResult->Data.Data[0];
|
|
|
gDoCommGblData.ConnectorID[1] = pCsuResult->Data.Data[1];
|
|
|
- log_info("OK (Left connector ID = %d, Right connector ID = %d)\n",
|
|
|
+ log_info("OK (Left connector ID = %d, Right connector ID = %d)",
|
|
|
pCsuResult->Data.Data[0],
|
|
|
pCsuResult->Data.Data[1]);
|
|
|
break;
|
|
@@ -1121,7 +1098,7 @@ static int responsePackeHandle(int fd, uint8_t *pResult, uint8_t plugNum, uint8_
|
|
|
break;
|
|
|
|
|
|
case REG_USER_ID:
|
|
|
- //log_info("%s\n", pCsuResult->Data.Data[0] == 1 ? "Accept" : "Reject" );
|
|
|
+ //log_info("%s", pCsuResult->Data.Data[0] == 1 ? "Accept" : "Reject" );
|
|
|
//if (pCsuResult->Data.Data[0] <= 0) {
|
|
|
// return FAIL;
|
|
|
//}
|
|
@@ -1135,7 +1112,7 @@ static int responsePackeHandle(int fd, uint8_t *pResult, uint8_t plugNum, uint8_
|
|
|
break;
|
|
|
|
|
|
case REG_CHARGING_PERMISSION:
|
|
|
- //log_info("id = %d, result = %s, action = %s\r\n",
|
|
|
+ //log_info("id = %d, result = %s, action = %s",
|
|
|
// pCsuResult->Head.ID,
|
|
|
// pCsuResult->Data.Result == 1 ? "OK" : "NG",
|
|
|
// pCsuResult->Data.Data[0] == 1 ? "Permitted" : "NOT permitted");
|
|
@@ -1160,7 +1137,7 @@ static int responsePackeHandle(int fd, uint8_t *pResult, uint8_t plugNum, uint8_
|
|
|
|
|
|
ShmDcCommonData->PcPsuOutput[plugNum].Voltage = ntohs((uint16_t)pPcPsuOutput->Voltage);
|
|
|
ShmDcCommonData->PcPsuOutput[plugNum].Current = ntohs((uint16_t)pPcPsuOutput->Current);
|
|
|
- //log_info("%d power cabinet PSU output vol = %f, cur = %f\r\n",
|
|
|
+ //log_info("%d power cabinet PSU output vol = %f, cur = %f",
|
|
|
// plugNum,
|
|
|
// (float)ShmDcCommonData->PcPsuOutput[plugNum].Voltage,
|
|
|
// (float)ShmDcCommonData->PcPsuOutput[plugNum].Current);
|
|
@@ -1185,7 +1162,7 @@ static int responsePackeHandle(int fd, uint8_t *pResult, uint8_t plugNum, uint8_
|
|
|
GroundFaultDetection *gfd = (GroundFaultDetection *)&pCsuResult->Data.Data[0];
|
|
|
if(pDcChargingInfo->GroundFaultStatus != gfd->Status)
|
|
|
{
|
|
|
- log_info("id = %d, GFD Result = %d\r\n",
|
|
|
+ log_info("id = %d, GFD Result = %d",
|
|
|
pCsuResult->Head.ID,
|
|
|
gfd->Status);
|
|
|
}
|
|
@@ -1231,21 +1208,21 @@ static int composeSocketData(int fd,
|
|
|
|
|
|
//send command packet
|
|
|
if ((size = sendTcpSocket(fd, (uint8_t *)&csuCmdPkt, sendPktLen)) < 0) {
|
|
|
- log_error("TCP socket send packet fail = %d\r\n", size);
|
|
|
+ log_error("TCP socket send packet fail = %d", size);
|
|
|
gDoCommGblData.DisConnCount++;
|
|
|
return FAIL;
|
|
|
}
|
|
|
|
|
|
//receive result head
|
|
|
if ((size = recvTcpSocket(fd, (uint8_t *)&csuResult.Head, sizeof(csuResult.Head))) < 0) {
|
|
|
- log_error("TCP socket RX head fail = %d\r\n", size);
|
|
|
+ log_error("TCP socket RX head fail = %d", size);
|
|
|
gDoCommGblData.DisConnCount++;
|
|
|
return FAIL;
|
|
|
}
|
|
|
|
|
|
//receive result raw data
|
|
|
if ((size = recvTcpSocket(fd, (uint8_t *)&csuResult.Data, csuResult.Head.DataLen)) < 0) {
|
|
|
- log_error("TCP socket RX data fail = %d\r\n", size);
|
|
|
+ log_error("TCP socket RX data fail = %d", size);
|
|
|
gDoCommGblData.DisConnCount++;
|
|
|
return FAIL;
|
|
|
}
|
|
@@ -1269,7 +1246,7 @@ static int writeWaitPlugItState(int fd, uint8_t id)
|
|
|
int ret = PASS;
|
|
|
uint8_t data[2] = {pSysInfo->WaitForPlugit, 0};
|
|
|
|
|
|
- //printf("WaitForPlugit = %d\r\n", pSysInfo->WaitForPlugit);
|
|
|
+ //printf("WaitForPlugit = %d", pSysInfo->WaitForPlugit);
|
|
|
|
|
|
if ((ret = composeSocketData(fd,
|
|
|
id,
|
|
@@ -1468,7 +1445,7 @@ static int writeConnectorState(int fd, uint8_t plugNum, uint8_t id)
|
|
|
(char *)ShmOCPP16Data->StatusNotification[plugNum].VendorErrorCode,
|
|
|
WARNING_CODE_SIZE);
|
|
|
vendorErrorCodeTmp[plugNum][6] = '\0';
|
|
|
- log_info("1 ID = %d, VendorErrorCode = %s\r\n",
|
|
|
+ log_info("1 ID = %d, VendorErrorCode = %s",
|
|
|
plugNum,
|
|
|
(char *)ShmOCPP16Data->StatusNotification[plugNum].VendorErrorCode);
|
|
|
} else {
|
|
@@ -1480,7 +1457,7 @@ static int writeConnectorState(int fd, uint8_t plugNum, uint8_t id)
|
|
|
(char *)ShmOCPP16Data->StatusNotification[plugNum].VendorErrorCode,
|
|
|
WARNING_CODE_SIZE);
|
|
|
vendorErrorCodeTmp[plugNum][6] = '\0';
|
|
|
- log_info("2 ID = %d, VendorErrorCode = %s\r\n",
|
|
|
+ log_info("2 ID = %d, VendorErrorCode = %s",
|
|
|
plugNum,
|
|
|
(char *)ShmOCPP16Data->StatusNotification[plugNum].VendorErrorCode);
|
|
|
}
|
|
@@ -1755,7 +1732,7 @@ static void checkAuthorProcess(int fd, uint8_t plugNum)
|
|
|
strcpy((char *)ShmOCPP16Data->Authorize.ResponseIdTagInfo.Status, "Accepted");
|
|
|
}
|
|
|
|
|
|
- //printf("%d Balance = %.2f, %.2f\r\n",
|
|
|
+ //printf("%d Balance = %.2f, %.2f\n",
|
|
|
// plugNum,
|
|
|
// ShmSelectGunInfo->PricesInfo[plugNum].Balance,
|
|
|
// FAIL_BALANCE_PRICES);
|
|
@@ -1866,7 +1843,7 @@ static int messageTrigger(int fd, uint8_t plugNum, uint8_t gunID, uint8_t curReg
|
|
|
//check misc command from power cabinet
|
|
|
if (gDoCommGblData.MiscCmd != 0) {
|
|
|
if (gDoCommGblData.MiscCmd != REG_MISC_CONTROL) {
|
|
|
- log_error("misc command failed = %x\r\n", gDoCommGblData.MiscCmd);
|
|
|
+ log_error("misc command failed = %x", gDoCommGblData.MiscCmd);
|
|
|
}
|
|
|
curReg = gDoCommGblData.MiscCmd;
|
|
|
} else {
|
|
@@ -1931,7 +1908,7 @@ static int messageTrigger(int fd, uint8_t plugNum, uint8_t gunID, uint8_t curReg
|
|
|
// break;
|
|
|
|
|
|
default:
|
|
|
- log_error("error curReg = %x\r\n", curReg);
|
|
|
+ log_error("error curReg = %x", curReg);
|
|
|
gDoCommGblData.MiscCmd = 0;
|
|
|
gDoCommGblData.DisConnCount = CHECK_NETWORK_FAIL_COUNT;
|
|
|
isContinue = 0;
|
|
@@ -1981,7 +1958,15 @@ static void systemStatusProcess(int fd, uint8_t totalGun, uint8_t plugNum, uint8
|
|
|
writeWaitPlugItState(fd, gunID);
|
|
|
ftime(&gRegTimeUp[plugNum][REG_WAIT_PLUG_IT_STATE]);
|
|
|
}
|
|
|
-
|
|
|
+ /*
|
|
|
+ ftime(&AuthNowTime);
|
|
|
+ if (DiffTimeb(gRegTimeUp[plugNum][REG_MISC_CONTROL], AuthNowTime) > (LOOP_RETRY_TIME / 10) ||
|
|
|
+ DiffTimeb(gRegTimeUp[plugNum][REG_MISC_CONTROL], AuthNowTime) < 0
|
|
|
+ ) {
|
|
|
+ readMiscCommand(fd, gunID);
|
|
|
+ ftime(&gRegTimeUp[plugNum][REG_MISC_CONTROL]);
|
|
|
+ }
|
|
|
+ */
|
|
|
ftime(&AuthNowTime);
|
|
|
if (DiffTimeb(gRegTimeUp[plugNum][REG_CHARGING_CAP], AuthNowTime) > LOOP_RETRY_TIME ||
|
|
|
DiffTimeb(gRegTimeUp[plugNum][REG_CHARGING_CAP], AuthNowTime) < 0
|
|
@@ -2042,7 +2027,7 @@ static void systemStatusProcess(int fd, uint8_t totalGun, uint8_t plugNum, uint8
|
|
|
DiffTimeb(gRegTimeUp[plugNum][REG_CHARGING_PERMISSION], AuthNowTime) < 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",
|
|
|
plugNum,
|
|
|
REG_CHARGING_PERMISSION);
|
|
|
pDcChargingInfo->StopChargeFlag = POWER_CABINET_STOP_CHARGING;
|
|
@@ -2081,7 +2066,7 @@ static void systemStatusProcess(int fd, uint8_t totalGun, uint8_t plugNum, uint8
|
|
|
DiffTimeb(gRegTimeUp[plugNum][REG_CHARGING_PERMISSION], AuthNowTime) < 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",
|
|
|
plugNum,
|
|
|
REG_CHARGING_PERMISSION);
|
|
|
pDcChargingInfo->StopChargeFlag = POWER_CABINET_STOP_CHARGING;
|
|
@@ -2124,11 +2109,11 @@ static void systemStatusProcess(int fd, uint8_t totalGun, uint8_t plugNum, uint8
|
|
|
DiffTimeb(gRegTimeUp[plugNum][REG_CHARGING_PERMISSION], AuthNowTime) < 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",
|
|
|
plugNum,
|
|
|
REG_CHARGING_PERMISSION);
|
|
|
pDcChargingInfo->StopChargeFlag = POWER_CABINET_STOP_CHARGING;
|
|
|
- //printf("%d StopChargeFlag = %d\r\n", plugNum, pDcChargingInfo->StopChargeFlag);
|
|
|
+ //printf("%d StopChargeFlag = %d\n", plugNum, pDcChargingInfo->StopChargeFlag);
|
|
|
}
|
|
|
ftime(&gRegTimeUp[plugNum][REG_CHARGING_PERMISSION]);
|
|
|
}
|
|
@@ -2178,7 +2163,7 @@ static int networkCreatePorcess(void)
|
|
|
|
|
|
while (!CheckNetworkStatus()) {
|
|
|
calDisconnectCount(&gDoCommGblData.DisConnCount, CHECK_NETWORK_FAIL_COUNT);
|
|
|
- log_error("disconnect count = % d\r\n", gDoCommGblData.DisConnCount);
|
|
|
+ log_error("disconnect count = % d", gDoCommGblData.DisConnCount);
|
|
|
}
|
|
|
log_info("Dispenser Network Information checked: IP = % s Netmask = % s, Gateway = % s",
|
|
|
pSysConfig->Eth0Interface.EthIpAddress,
|
|
@@ -2191,7 +2176,7 @@ static int networkCreatePorcess(void)
|
|
|
log_info("Connect to Power Cabinet");
|
|
|
while ((fd = doCommConnToServer()) <= 0) {
|
|
|
calDisconnectCount(&gDoCommGblData.DisConnCount, CONNECT_SERVER_FAIL_COUNT);
|
|
|
- log_error("disconnect count = %d, fd = %d\r\n", gDoCommGblData.DisConnCount, fd);
|
|
|
+ log_error("disconnect count = %d, fd = %d", gDoCommGblData.DisConnCount, fd);
|
|
|
}
|
|
|
log_info("Power cabinet connected(fd = % d): IP = % s Netmask = % s, Gateway = % s",
|
|
|
fd,
|
|
@@ -2223,7 +2208,7 @@ int main(int argc, char *argv[])
|
|
|
|
|
|
/**************** Initialization **********/
|
|
|
if (CreateAllCsuShareMemory() == FAIL) {
|
|
|
- log_error("create share memory error\r\n");
|
|
|
+ log_error("create share memory error");
|
|
|
return FAIL;
|
|
|
}
|
|
|
|
|
@@ -2280,6 +2265,13 @@ int main(int argc, char *argv[])
|
|
|
if (initDone == DISPENSER_SOCKET_RECONN) {
|
|
|
break;
|
|
|
}
|
|
|
+ initDone = messageTrigger(fd,
|
|
|
+ plugNum,
|
|
|
+ gunID,
|
|
|
+ REG_MISC_CONTROL);
|
|
|
+ if (initDone == DISPENSER_SOCKET_RECONN) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|