|
@@ -198,7 +198,7 @@ int InitShareMemory()
|
|
|
result = FAIL;
|
|
|
}
|
|
|
|
|
|
- //Initial ShmOcppModuleKey
|
|
|
+ //Initial ShmCharger
|
|
|
if ((MeterSMId = shmget(ShmChargerKey, sizeof(struct Charger), IPC_CREAT | 0777)) < 0)
|
|
|
{
|
|
|
#ifdef SystemLogMessage
|
|
@@ -711,6 +711,7 @@ unsigned char Query_AC_MCU_Status(unsigned char fd, unsigned char targetAddr, Ac
|
|
|
Ret_Buf->meter_state = rx[16];
|
|
|
Ret_Buf->pp_state = rx[17];
|
|
|
Ret_Buf->rating_current = rx[18];
|
|
|
+ Ret_Buf->rotatory_switch = rx[19];
|
|
|
|
|
|
result = PASS;
|
|
|
}
|
|
@@ -1261,6 +1262,37 @@ unsigned char Config_AC_MCU_LEGACY_REQUEST(unsigned char fd, unsigned char targe
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+unsigned char Query_AC_GUN_PLUGIN_TIMES(unsigned char fd, unsigned char targetAddr, Gun_Plugin_Times *Ret_Buf)
|
|
|
+{
|
|
|
+ unsigned char result = FAIL;
|
|
|
+ unsigned char tx[7] = {0xaa, 0x00, targetAddr, CMD_CONFIG_GUN_PLUGIN_TIMES, 0x00, 0x00, 0x00};
|
|
|
+ unsigned char rx[512];
|
|
|
+ unsigned char chksum = 0x00;
|
|
|
+ unsigned char len = tranceive(fd, tx, sizeof(tx), rx);
|
|
|
+
|
|
|
+ if(len > 0)
|
|
|
+ {
|
|
|
+ if(len < 6+(rx[4] | rx[5]<<8))
|
|
|
+ return result;
|
|
|
+
|
|
|
+ for(int idx=0;idx<(rx[4] | rx[5]<<8);idx++)
|
|
|
+ {
|
|
|
+ chksum ^= rx[6+idx];
|
|
|
+ }
|
|
|
+
|
|
|
+ if((chksum == rx[6+(rx[4] | rx[5]<<8)]) &&
|
|
|
+ (rx[2] == tx[1]) &&
|
|
|
+ (rx[1] == tx[2]) &&
|
|
|
+ (rx[3] == tx[3]))
|
|
|
+ {
|
|
|
+ Ret_Buf-> GunPluginTimes = ((uint32_t)rx[6] | (((uint32_t)rx[7])<<8) | (((uint32_t)rx[8])<<16) | (((uint32_t)rx[9])<<24));
|
|
|
+ result = PASS;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+}
|
|
|
+
|
|
|
unsigned char Config_AC_MaxCurrent_And_CpPwmDuty(unsigned char fd, unsigned char targetAddr, Ac_Primary_Mcu_Cp_Pwm_Duty*Set_Buf)
|
|
|
{
|
|
|
unsigned char result = FAIL;
|
|
@@ -1526,7 +1558,7 @@ int main(void)
|
|
|
memcpy(ShmCharger->evseId.serial_number, ShmSysConfigAndInfo->SysConfig.SerialNumber, ARRAY_SIZE(ShmCharger->evseId.serial_number));
|
|
|
if(Config_Serial_Number(Uart1Fd, (gun_index>0?ADDR_AC_PRIMARY_2:ADDR_AC_PRIMARY_1), &ShmCharger->evseId))
|
|
|
{
|
|
|
- DEBUG_INFO("MCU-%d set serial number OK...\r\n");
|
|
|
+ DEBUG_INFO("MCU-%d set serial number : %.12s\r\n",gun_index,ShmCharger->evseId.serial_number);
|
|
|
ShmCharger->gun_info[gun_index].mcuFlag.isSetSerialNumberPass = PASS;
|
|
|
|
|
|
failCount[gun_index] = 0;
|
|
@@ -1549,7 +1581,7 @@ int main(void)
|
|
|
memcpy(ShmCharger->evseId.model_name, ShmSysConfigAndInfo->SysConfig.ModelName, ARRAY_SIZE(ShmCharger->evseId.model_name));
|
|
|
if(Config_Model_Name(Uart1Fd, (gun_index>0?ADDR_AC_PRIMARY_2:ADDR_AC_PRIMARY_1), &ShmCharger->evseId))
|
|
|
{
|
|
|
- DEBUG_INFO("MCU-%d set model name OK...\r\n");
|
|
|
+ DEBUG_INFO("MCU-%d set model name : %.14s\r\n",gun_index,ShmCharger->evseId.model_name);
|
|
|
ShmCharger->gun_info[gun_index].mcuFlag.isSetModelNamePass = PASS;
|
|
|
|
|
|
failCount[gun_index] = 0;
|
|
@@ -1601,6 +1633,25 @@ int main(void)
|
|
|
failCount[gun_index]++;
|
|
|
}
|
|
|
|
|
|
+ //===============================
|
|
|
+ // Query gun plug-in times
|
|
|
+ //===============================
|
|
|
+ if(Query_AC_GUN_PLUGIN_TIMES(Uart1Fd, (gun_index>0?ADDR_AC_PRIMARY_2:ADDR_AC_PRIMARY_1), &ShmCharger->gun_info[gun_index].gunPluginTimes) == PASS)
|
|
|
+ {
|
|
|
+ DEBUG_INFO("MCU-%d get gun plugin times : %.2f\r\n", gun_index, (float)ShmCharger->gun_info[gun_index].gunPluginTimes.GunPluginTimes);
|
|
|
+
|
|
|
+ ShmSysConfigAndInfo->SysConfig.AcPlugInTimes = (float)ShmCharger->gun_info[gun_index].gunPluginTimes.GunPluginTimes;
|
|
|
+
|
|
|
+ failCount[gun_index] = 0;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+
|
|
|
+ DEBUG_WARN("MCU-%d get gun plugin times fail...%d\r\n", gun_index, failCount[gun_index]);
|
|
|
+ if(failCount[gun_index]<1000)
|
|
|
+ failCount[gun_index]++;
|
|
|
+ }
|
|
|
+
|
|
|
//===============================
|
|
|
// Query temperature
|
|
|
//===============================
|
|
@@ -1635,6 +1686,7 @@ int main(void)
|
|
|
DEBUG_INFO("MCU-%d get Meter State : %d\r\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuState.meter_state);
|
|
|
DEBUG_INFO("MCU-%d get PP State : %d\r\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuState.pp_state);
|
|
|
DEBUG_INFO("MCU-%d get Rating Current : %.2f\r\n", gun_index, (float)ShmCharger->gun_info[gun_index].primaryMcuState.rating_current);
|
|
|
+ DEBUG_INFO("MCU-%d get Rotatory switch : %d\r\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuState.rotatory_switch);
|
|
|
|
|
|
ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState = ShmCharger->gun_info[gun_index].primaryMcuState.cp_state;
|
|
|
ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotDuty = (ShmCharger->gun_info[gun_index].primaryMcuState.current_limit>51?(unsigned char)((ShmCharger->gun_info[gun_index].primaryMcuState.current_limit/2.5)+64):(unsigned char)(ShmCharger->gun_info[gun_index].primaryMcuState.current_limit/0.6));
|
|
@@ -1887,7 +1939,6 @@ int main(void)
|
|
|
tmMcu.tm_sec = ShmCharger->gun_info[gun_index].rtc.sec;
|
|
|
mcuTime.time = mktime(&tmMcu);
|
|
|
|
|
|
-
|
|
|
if(ShmCharger->gun_info[gun_index].bleConfigData.isLogin && !ShmOCPP16Data->OcppConnStatus)
|
|
|
{
|
|
|
if(abs(DiffTimeb(csuTime, mcuTime)) > 10000)
|
|
@@ -2043,7 +2094,7 @@ int main(void)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- sleep(3);
|
|
|
+ usleep(100000);
|
|
|
}
|
|
|
|
|
|
return FAIL;
|