Przeglądaj źródła

2021-07-23 / Eason Yang
Action:
1. Improve : Charging session initial target current get logic improve.
2. PWM configured logic move to high priority.

File:
1. main.c
Action 1

2. Module_InternalComm.c
Action 2

Image Version: V0.52.XX.XXXX.XX
Image checksum: XXXXXXXX

Hardware PWB P/N: XXXXXXXX
Hardware Version: XXXXXXXX

8009 3 lat temu
rodzic
commit
4ef8d4bad6

+ 2 - 2
EVSE/Projects/Noodoe/Apps/Module_EventLogging.c

@@ -96,7 +96,7 @@ int StoreEventLogMsg(const char *fmt, ...)
 
 	if((ShmSysConfigAndInfo->SysConfig.ModelName != NULL) && (ShmSysConfigAndInfo->SysConfig.SerialNumber != NULL) && (strlen((char*)ShmSysConfigAndInfo->SysConfig.ModelName) >= 14))
 	{
-		sprintf(Buf,"echo \"[%04d.%02d.%02d %02d:%02d:%02d] - %s\" >> /Storage/EventLog/[%04d.%02d]%s_%s_EventLog",
+		sprintf(Buf,"echo -n \"[%04d.%02d.%02d %02d:%02d:%02d] - %s\" >> /Storage/EventLog/[%04d.%02d]%s_%s_EventLog",
 					tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec,
 					buffer,
 					tm->tm_year+1900,tm->tm_mon+1,
@@ -105,7 +105,7 @@ int StoreEventLogMsg(const char *fmt, ...)
 	}
 	else
 	{
-		sprintf(Buf,"echo \"[%04d.%02d.%02d %02d:%02d:%02d] - %s\" >> /Storage/EventLog/[%04d.%02d]EventLog",
+		sprintf(Buf,"echo -n \"[%04d.%02d.%02d %02d:%02d:%02d] - %s\" >> /Storage/EventLog/[%04d.%02d]EventLog",
 					tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec,
 					buffer,
 					tm->tm_year+1900,tm->tm_mon+1);

+ 28 - 23
EVSE/Projects/Noodoe/Apps/Module_InternalComm.c

@@ -15,12 +15,12 @@
 
 #include 	<unistd.h>
 #include 	<stdarg.h>
-#include  	<stdio.h>      /*標準輸入輸出定義*/
-#include  	<stdlib.h>     /*標準函數庫定義*/
-#include  	<unistd.h>     /*Unix 標準函數定義*/
-#include  	<fcntl.h>      /*檔控制定義*/
-#include  	<termios.h>    /*PPSIX 終端控制定義*/
-#include 	<errno.h>      /*錯誤號定義*/
+#include  	<stdio.h>
+#include  	<stdlib.h>
+#include  	<unistd.h>
+#include  	<fcntl.h>
+#include  	<termios.h>
+#include 	<errno.h>
 #include 	<errno.h>
 #include 	<string.h>
 #include	<time.h>
@@ -2035,6 +2035,26 @@ int main(void)
 					}
 				}
 
+				//===============================
+				// Case 8 : Config primary set CP PWN duty
+				//===============================
+				if(ShmCharger->gun_info[gun_index].mcuFlag.isSetCpPwmDuty == ON)
+				{
+					if(Config_AC_MaxCurrent_And_CpPwmDuty(Uart1Fd, (gun_index>0?ADDR_AC_PRIMARY_2:ADDR_AC_PRIMARY_1), &ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty))
+					{
+						failCount[gun_index] = 0;
+						ShmCharger->gun_info[gun_index].mcuFlag.isSetCpPwmDuty = OFF;
+					}
+					else
+					{
+						DEBUG_WARN("MCU-%d set cp pwn duty fail...%d\n", gun_index, failCount[gun_index]);
+						if(failCount[gun_index]<1000)
+						{
+							failCount[gun_index]++;
+						}
+					}
+				}
+
 				//==========================================================
 				// High priority polling log print out
 				//==========================================================
@@ -2244,24 +2264,9 @@ int main(void)
 						break;
 					case 9:
 						//===============================
-						// Config primary set CP PWN duty
+						// Reserve
 						//===============================
-						if(ShmCharger->gun_info[gun_index].mcuFlag.isSetCpPwmDuty == ON)
-						{
-							if(Config_AC_MaxCurrent_And_CpPwmDuty(Uart1Fd, (gun_index>0?ADDR_AC_PRIMARY_2:ADDR_AC_PRIMARY_1), &ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty))
-							{
-								failCount[gun_index] = 0;
-								ShmCharger->gun_info[gun_index].mcuFlag.isSetCpPwmDuty = OFF;
-							}
-							else
-							{
-								DEBUG_WARN("MCU-%d set cp pwn duty fail...%d\n", gun_index, failCount[gun_index]);
-								if(failCount[gun_index]<1000)
-								{
-									failCount[gun_index]++;
-								}
-							}
-						}
+
 						break;
 					case 11:
 						//===============================

+ 17 - 3
EVSE/Projects/Noodoe/Apps/main.c

@@ -3615,7 +3615,7 @@ int main(void)
 						ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedDuration = 0;
 						ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedEnergy = 0;
 						ShmCharger->gun_info[gun_index].targetCurrent = 0xFF;
-						ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty.max_current = (ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent > 0) ? ((ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent<ShmCharger->gun_info[gun_index].primaryMcuState.rating_current)?ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent:ShmCharger->gun_info[gun_index].primaryMcuState.rating_current) : ShmCharger->gun_info[gun_index].primaryMcuState.rating_current;
+
 						ocpp_set_unlocker_req(gun_index, OFF);
 						ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].ReservationId = -1;
 
@@ -3714,6 +3714,22 @@ int main(void)
 						ShmCharger->gun_info[gun_index].isGunPlugged = NO;
 						ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].schedule.isTriggerStart = OFF;
 
+						// Get target current
+						ocpp_set_profile_req(gun_index, ON);
+						sleep(1);
+						checkChargingProfileLimit(gun_index);
+						if(ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent == 0)
+						{
+							ShmCharger->gun_info[gun_index].targetCurrent = ((ShmCharger->gun_info[gun_index].targetCurrent > ShmCharger->gun_info[gun_index].primaryMcuState.rating_current)?ShmCharger->gun_info[gun_index].primaryMcuState.rating_current:ShmCharger->gun_info[gun_index].targetCurrent);
+							ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty.max_current = ((ShmCharger->gun_info[gun_index].targetCurrent > ShmCharger->gun_info[gun_index].primaryMcuState.rating_current)?ShmCharger->gun_info[gun_index].primaryMcuState.rating_current:ShmCharger->gun_info[gun_index].targetCurrent);
+						}
+						else
+						{
+							ShmCharger->gun_info[gun_index].targetCurrent = ((ShmCharger->gun_info[gun_index].targetCurrent > ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent)?ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent:ShmCharger->gun_info[gun_index].targetCurrent);
+							ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty.max_current = ((ShmCharger->gun_info[gun_index].targetCurrent > ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent)?ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent:ShmCharger->gun_info[gun_index].targetCurrent);
+						}
+						ShmCharger->gun_info[gun_index].mcuFlag.isSetCpPwmDuty = YES;
+
 						setChargerMode(gun_index, SYS_MODE_AUTHORIZING);
 					}
 					else
@@ -3757,7 +3773,6 @@ int main(void)
 									break;
 							}
 						}
-						ShmCharger->gun_info[gun_index].mcuFlag.isSetCpPwmDuty = YES;
 					}
 					
 					if(DiffTimebWithNow(startTime[gun_index][TMR_IDX_AUTH]) > TIMEOUT_SPEC_AUTH)
@@ -3780,7 +3795,6 @@ int main(void)
 								   (!ocpp_get_connection_status() && (ShmSysConfigAndInfo->SysConfig.OfflinePolicy == OFF_POLICY_LOCALLIST) && (strcmp((char *)&ShmSysConfigAndInfo->SysConfig.OcppServerURL,"") == 0)))
 								{
 									DEBUG_INFO("ShmOCPP16Data->Authorize.ResponseIdTagInfo.Status: %s \n", ShmOCPP16Data->Authorize.ResponseIdTagInfo.Status);
-
 									if(ocpp_get_auth_result(gun_index) ||
 									   (!ocpp_get_connection_status() && (ShmSysConfigAndInfo->SysConfig.OfflinePolicy == OFF_POLICY_FREE)) ||
 									   (!ocpp_get_connection_status() && (isValidLocalWhiteCard() == PASS) && (ShmSysConfigAndInfo->SysConfig.OfflinePolicy == OFF_POLICY_LOCALLIST)))