Эх сурвалжийг харах

2021-06-30 / Eason Yang
Action :
1. Improve : Call ocpp_set_profile_req() when the system mode on SYS_MODE_TERMINATING.
2. Improve : If temperature over 75 derating PWM duty to 80% and recover if temperature less than 65.
3. Fixed : Charging profile limit equal 0 can not back to SYS_MODE_CHARGING fixed.
4. Merge : Module_Debug.c from AW-Regular to Noodoe project.
5. Merge : Module_ConfigTools.c from AW-Regular to Noodoe project.
6. Added : temCoefficient variable.

File :
1. main.c
Action 1
Action 2
Action 3

2. Module_Debug.c
Action 4

3. Module_ConfigTools.c
Action 5

4. main.h
Action 6

Version : V0.52.XX.XXXX.NX

8009 3 жил өмнө
parent
commit
8580233e26

+ 127 - 0
EVSE/Projects/Noodoe/Apps/Module_ConfigTools.c

@@ -247,6 +247,7 @@ int main(void)
 		printf("\n  system: system configuration menu.");
 		printf("\n  ocpp: ocpp configuration menu.");
 		printf("\n  network: netwok configuration menu.");
+		printf("\n  test: charger start/stop test.");
 		printf("\n  upgrade: trigger firmware upgrade.");
 		printf("\n  save: Save config.");
 		printf("\n  exit: Exit config tools.");
@@ -261,6 +262,8 @@ int main(void)
 			printf("\n ***** system configuration menu ******************");
 			printf("\n  modelname: EVSE model name.");
 			printf("\n  serialnumber: EVSE serial number.");
+			printf("\n  authentication: Authentication function.");
+			printf("\n  rfidendian: RFID read endian.");
 			printf("\n *************************************************");
 			printf("\n  Please input operation item: ");
 			scanf("%s", &cmd[0]);
@@ -305,6 +308,34 @@ int main(void)
 					strcpy((char*)&ShmSysConfigAndInfo->SysConfig.SerialNumber[0], (char*)&cmd[0]);
 				}
 			}
+			else if(strcmp(cmd, "authentication") == 0)
+			{
+				memset(cmd, 0x00, ARRAY_SIZE(cmd));
+				printf("\n *************************************************");
+				printf("\n  0: Enable.");
+				printf("\n  1: Disable.");
+				printf("\n *************************************************");
+
+				printf("\n  Current mode: %d", ShmSysConfigAndInfo->SysConfig.AuthorisationMode);
+				printf("\n  Please input authentication mode: ");
+				scanf("%s", &cmd[0]);
+
+				ShmSysConfigAndInfo->SysConfig.AuthorisationMode = ((0<=atoi(cmd))&&(atoi(cmd)<=1)?atoi(cmd):0);
+			}
+			else if(strcmp(cmd, "rfidendian") == 0)
+			{
+				memset(cmd, 0x00, ARRAY_SIZE(cmd));
+				printf("\n *************************************************");
+				printf("\n  0: Little endian.");
+				printf("\n  1: Big endian.");
+				printf("\n *************************************************");
+
+				printf("\n  Current mode: %d", ShmSysConfigAndInfo->SysConfig.RfidCardNumEndian);
+				printf("\n  Please input rfid endian mode: ");
+				scanf("%s", &cmd[0]);
+
+				ShmSysConfigAndInfo->SysConfig.RfidCardNumEndian = ((0<=atoi(cmd))&&(atoi(cmd)<=1)?atoi(cmd):0);
+			}
 		}
 		else if(strcmp(cmd, "ocpp") == 0)
 		{
@@ -312,6 +343,9 @@ int main(void)
 			printf("\n *************************************************");
 			printf("\n  ocppurl: OCPP backend server url.");
 			printf("\n  cboxid: Charger box id.");
+			printf("\n  vender: Charger point vender.");
+			printf("\n  offlinepolicy: Charger off line policy.");
+			printf("\n  localloadbalance: Charger local load balance.");
 			printf("\n *************************************************");
 			printf("\n  Please input operation item: ");
 			scanf("%s", &cmd[0]);
@@ -356,6 +390,55 @@ int main(void)
 					strcpy((char*)&ShmSysConfigAndInfo->SysConfig.ChargeBoxId[0], (char*)&cmd[0]);
 				}
 			}
+			else if(strcmp(cmd, "vender") == 0)
+			{
+				memset(cmd, 0x00, ARRAY_SIZE(cmd));
+				printf("\n *************************************************");
+				printf("\n  Current OCPP vender: %s", ShmSysConfigAndInfo->SysConfig.chargePointVendor);
+				printf("\n  0: Keep current config.");
+				printf("\n  1: Input new charger box id.");
+				printf("\n *************************************************");
+				printf("\n  Please input operation item: ");
+				scanf("%s", &cmd[0]);
+
+				if(atoi(cmd) == 1)
+				{
+					printf("\n  Please input OCPP vender: ");
+					scanf("%s", &cmd[0]);
+
+					memset(&ShmSysConfigAndInfo->SysConfig.chargePointVendor[0], 0x00, ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.chargePointVendor));
+					strcpy((char*)&ShmSysConfigAndInfo->SysConfig.chargePointVendor[0], (char*)&cmd[0]);
+				}
+			}
+			else if(strcmp(cmd, "offlinepolicy") == 0)
+			{
+				memset(cmd, 0x00, ARRAY_SIZE(cmd));
+				printf("\n *************************************************");
+				printf("\n  0: Local list.");
+				printf("\n  2: Free charging.");
+				printf("\n  3: Deny charging.");
+				printf("\n *************************************************");
+
+				printf("\n  Current mode: %d", ShmSysConfigAndInfo->SysConfig.OfflinePolicy);
+				printf("\n  Please input off line policy mode: ");
+				scanf("%s", &cmd[0]);
+
+				ShmSysConfigAndInfo->SysConfig.OfflinePolicy = ((0<=atoi(cmd))&&(atoi(cmd)<=3)&&(atoi(cmd)!=1)?atoi(cmd):0);
+			}
+			else if(strcmp(cmd, "localloadbalance") == 0)
+			{
+				memset(cmd, 0x00, ARRAY_SIZE(cmd));
+				printf("\n *************************************************");
+				printf("\n  0: Disable.");
+				printf("\n  1: Enable.");
+				printf("\n *************************************************");
+
+				printf("\n  Current mode: %d", ShmSysConfigAndInfo->SysConfig.isEnableLocalPowerSharging);
+				printf("\n  Please input local load balance mode: ");
+				scanf("%s", &cmd[0]);
+
+				ShmSysConfigAndInfo->SysConfig.isEnableLocalPowerSharging = ((0<=atoi(cmd))&&(atoi(cmd)<=1)?atoi(cmd):0);
+			}
 		}
 		else if(strcmp(cmd, "network") == 0)
 		{
@@ -532,6 +615,50 @@ int main(void)
 				}
 			}
 		}
+		else if(strcmp(cmd, "test") == 0)
+		{
+			memset(cmd, 0x00, ARRAY_SIZE(cmd));
+			printf("\n ***** test menu ******************");
+			printf("\n  start: EVSE start charging request.");
+			printf("\n  stop: EVSE stop charging request.");
+			printf("\n  cancel: return to main menu.");
+			printf("\n *************************************************");
+			printf("\n  Please input operation item: ");
+			scanf("%s", &cmd[0]);
+
+			if(strcmp(cmd, "start") == 0)
+			{
+				memset(cmd, 0x00, ARRAY_SIZE(cmd));
+				printf("\n  Please input gun index(1~2): ");
+				scanf("%s", &cmd[0]);
+
+				if((0 < atoi(cmd)) && (atoi(cmd) < 3))
+				{
+					ShmSysConfigAndInfo->SysInfo.AcChargingData[atoi(cmd)-1].schedule.isTriggerStart = ON;
+				}
+				else
+				{
+					printf("\n  Invalid input gun_index.");
+				}
+			}
+			else if(strcmp(cmd, "stop") == 0)
+			{
+				memset(cmd, 0x00, ARRAY_SIZE(cmd));
+				printf("\n  Please input gun index(1~2): ");
+				scanf("%s", &cmd[0]);
+
+				if((0 < atoi(cmd)) && (atoi(cmd) < 3))
+				{
+					ShmSysConfigAndInfo->SysInfo.AcChargingData[atoi(cmd)-1].schedule.isTriggerStop = ON;
+				}
+				else
+				{
+					printf("\n  Invalid input gun_index.");
+				}
+			}
+			else if(strcmp(cmd, "cancel") == 0)
+			{}
+		}
 		else if(strcmp(cmd, "upgrade") == 0)
 		{
 			printf("\n  Firmware upgrade trigger.");

+ 92 - 0
EVSE/Projects/Noodoe/Apps/Module_Debug.c

@@ -40,6 +40,7 @@
 
 struct SysConfigAndInfo			*ShmSysConfigAndInfo;
 struct StatusCodeData 			*ShmStatusCodeData;
+struct OCPP16Data				*ShmOCPP16Data;
 struct Charger					*ShmCharger;
 
 int StoreLogMsg(const char *fmt, ...)
@@ -113,6 +114,18 @@ int InitShareMemory()
 		result = FAIL;
 	}
 
+	// Initial ShmOCPP16Data
+	if ((MeterSMId = shmget(ShmOcppModuleKey, sizeof(struct OCPP16Data), 0777)) < 0)
+	{
+		DEBUG_ERROR("shmget ShmOCPP16Data NG\n");
+		result = FAIL;
+	}
+	else if ((ShmOCPP16Data = shmat(MeterSMId, NULL, 0)) == (void *) -1)
+	{
+		DEBUG_ERROR("shmat ShmOCPP16Data NG\n");
+		result = FAIL;
+	}
+
 	//Initial ShmCharger
 	if ((MeterSMId = shmget(ShmChargerKey, sizeof(struct Charger), 0777)) < 0)
 	{
@@ -165,6 +178,7 @@ int main(void)
 		memset(cmd, 0x00, ARRAY_SIZE(cmd));
 		printf("\n ============== Debug main menu ==================");
 		printf("\n  info: List charger status info.");
+		printf("\n  test: Charger test command.");
 		printf("\n  exit: Exit Module_Debug_Test.");
 		printf("\n =================================================");
 		printf("\n  Please input debug command: ");
@@ -195,14 +209,26 @@ int main(void)
 
 					gun_index = gun_index<AC_QUANTITY?gun_index:0;
 
+					printf("\n  CSU u-boot version: %s", ShmSysConfigAndInfo->SysInfo.CsuBootLoadFwRev);
+					printf("\n  CSU kernel version: %s", ShmSysConfigAndInfo->SysInfo.CsuKernelFwRev);
+					printf("\n  CSU rootfs version: %s", ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev);
+					printf("\n --------------------------------------------------");
 					printf("\n  Charger connector plug times: %d", ShmCharger->gun_info[gun_index].gunPluginTimes.GunPluginTimes);
+					printf("\n --------------------------------------------------");
 					printf("\n  CP positive voltage: %.2f", ShmCharger->gun_info[gun_index].PilotVoltage.PilotVoltagePositive);
 					printf("\n  CP negative voltage: %.2f", ShmCharger->gun_info[gun_index].PilotVoltage.PilotVoltageNegative);
+					printf("\n --------------------------------------------------");
 					printf("\n  CSU to MCU legacyRequest: %d", ShmCharger->gun_info[gun_index].legacyRequest.isLegacyRequest);
 					printf("\n  CSU to MCU relay on request: %d", ShmCharger->gun_info[gun_index].legacyRequest.isRelayOn);
+					printf("\n --------------------------------------------------");
 					printf("\n  Charger charging mode BS/HLC: %d", ShmCharger->gun_info[gun_index].chargingMode);
+					printf("\n --------------------------------------------------");
 					printf("\n  Charger input voltage L1: %.2f", ShmCharger->gun_info[gun_index].inputVoltage.L1N_L12);
+					printf("\n --------------------------------------------------");
 					printf("\n  CSU output current L1: %.2f", ShmCharger->gun_info[gun_index].outputCurrent.L1N_L12[0]);
+					printf("\n --------------------------------------------------");
+					printf("\n  CSU power total consumption: %.2f", (ShmCharger->gun_info[gun_index].powerConsumption.power_consumption/100.0));
+					printf("\n --------------------------------------------------");
 					printf("\n  CSU temperature: %d", ShmCharger->gun_info[gun_index].temperature.point[0]);
 
 					wait();
@@ -213,7 +239,9 @@ int main(void)
 					scanf("%d", &gun_index);
 					printf("\n  MCU info.\n\n");
 
+					gun_index = gun_index<AC_QUANTITY?gun_index:0;
 
+					printf("\n  Firmware version: %s", ShmCharger->gun_info[gun_index].ver.Version_FW);
 
 					wait();
 				}
@@ -224,6 +252,70 @@ int main(void)
 				}
 			}while(!isExit);
 		}
+		else if(strcmp(cmd, "test") == 0)
+		{
+			int gun_index;
+
+			memset(cmd, 0x00, ARRAY_SIZE(cmd));
+			printf("\n ***************** Info menu *********************");
+			printf("\n  start: start charging session");
+			printf("\n  stop: stop charging session");
+			printf("\n  operative: enable charger gun");
+			printf("\n  inoperative: disable charger gun");
+			printf("\n  exit: exit to previous menu.");
+			printf("\n *************************************************");
+			printf("\n  Please input command: ");
+			scanf("%s", &cmd[0]);
+
+			if(strcmp(cmd, "start") == 0)
+			{
+				printf("\n  Please input gun index: ");
+				scanf("%d", &gun_index);
+
+				ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].schedule.isTriggerStart = ON;
+			}
+			else if(strcmp(cmd, "stop") == 0)
+			{
+				printf("\n  Please input gun index: ");
+				scanf("%d", &gun_index);
+
+				ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].schedule.isTriggerStop = ON;
+			}
+			else if(strcmp(cmd, "operative") == 0)
+			{
+				printf("\n  Please input gun index: ");
+				scanf("%d", &gun_index);
+
+				if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_16)
+				{
+					sprintf((char*)ShmOCPP16Data->ChangeAvailability[gun_index].Type, "Operative");
+					ShmOCPP16Data->CsMsg.bits[gun_index].ChangeAvailabilityReq = ON;
+				}
+				else
+				{
+				
+				}
+			}
+			else if(strcmp(cmd, "inoperative") == 0)
+			{
+				printf("\n  Please input gun index: ");
+				scanf("%d", &gun_index);
+
+				if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_16)
+				{
+					sprintf((char*)ShmOCPP16Data->ChangeAvailability[gun_index].Type, "Inoperative");
+					ShmOCPP16Data->CsMsg.bits[gun_index].ChangeAvailabilityReq = ON;
+				}
+				else
+				{
+				
+				}
+			}
+			else if(strcmp(cmd, "exit") == 0)
+			{
+				printf("\n  Exit to previous.\n\n");
+			}
+		}
 		else if(strcmp(cmd, "exit") == 0)
 		{
 			printf("\n  exit program.\n\n");

+ 94 - 1
EVSE/Projects/Noodoe/Apps/main.c

@@ -34,6 +34,9 @@
 #define TIMEOUT_SPEC_PROFILE_PREPARE	5000
 #define TIMEOUT_SPEC_PWN_CHANGE			5000
 
+#define SPEC_TEMPERATURE_WARN			75
+#define SPEC_TEMPERATURE_RECOVER		65
+
 #define MtdBlockSize 					0x300000
 
 #define DB_FILE							"/Storage/ChargeLog/localCgargingRecord.db"
@@ -1986,6 +1989,53 @@ unsigned char isModeChange(unsigned char gun_index)
 	return result;
 }
 
+void gpio_set_value(unsigned int gpio, unsigned int value)
+{
+	int fd;
+	char buf[256];
+
+	sprintf(buf, "/sys/class/gpio/gpio%d/value", gpio);
+	fd = open(buf, O_WRONLY);
+	if (fd < 0)
+	{
+		DEBUG_ERROR("GPIO-%d set %d fail.\n", gpio, value);
+	    return;
+	}
+
+	if (value)
+		write(fd, "1", 2);
+	else
+	    write(fd, "0", 2);
+
+	close(fd);
+}
+
+int gpio_get_value(unsigned int gpio)
+{
+    int fd;
+    char buf[256];
+    char ch;
+    int8_t result = FAIL;
+
+    sprintf(buf, "/sys/class/gpio/gpio%d/value", gpio);
+    fd = open(buf, O_RDONLY);
+    if (fd < 0)
+    {
+        DEBUG_ERROR("GPIO-%d get fail\n", gpio);
+        return result;
+    }
+
+    read(fd, &ch, 1);
+    if (ch != '0')
+        result = 1;
+    else
+        result = 0;
+
+    close(fd);
+
+    return result;
+}
+
 //===============================================
 // Get firmware version
 //===============================================
@@ -3350,7 +3400,7 @@ int main(void)
 				{
 					setLedMotion(gun_index,LED_ACTION_INIT);
 				}
-
+				
 				sleep(5);
 				system("cd /root;./Module_FactoryConfig -m");
 				system("rm -f /Storage/OCPP/OCPPConfiguration");
@@ -4013,6 +4063,17 @@ int main(void)
 						// Checking profile id > 0 and current time is between charging profile validFrom & validTo
 						checkChargingProfileLimit(gun_index);
 
+						// If temperature warning derating PWM duty 20%
+						if(ShmSysConfigAndInfo->SysInfo.SystemAmbientTemp >= SPEC_TEMPERATURE_WARN)
+						{
+							ShmCharger->gun_info[gun_index].tempCoefficient = 0.8;
+						}
+						else if(ShmSysConfigAndInfo->SysInfo.SystemAmbientTemp <= SPEC_TEMPERATURE_RECOVER)
+						{
+							ShmCharger->gun_info[gun_index].tempCoefficient = 1.0;
+						}
+						ShmCharger->gun_info[gun_index].targetCurrent = (ShmCharger->gun_info[gun_index].targetCurrent==0?ShmCharger->gun_info[gun_index].targetCurrent:(((ShmCharger->gun_info[gun_index].targetCurrent*ShmCharger->gun_info[gun_index].tempCoefficient)>=6) ?	(ShmCharger->gun_info[gun_index].targetCurrent*ShmCharger->gun_info[gun_index].tempCoefficient):6));
+
 						// Determine max charging current to MCU
 						if(ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent == 0)
 						{
@@ -4335,6 +4396,38 @@ int main(void)
 							}
 						}
 
+						// Charging profile preparation
+						if(DiffTimebWithNow(startTime[gun_index][TMR_IDX_PROFILE_PREPARE]) > TIMEOUT_SPEC_PROFILE_PREPARE)
+						{
+							if(!ocpp_get_profile_conf(gun_index))
+							{
+								ocpp_set_profile_req(gun_index, ON);
+								ftime(&startTime[gun_index][TMR_IDX_PROFILE_PREPARE]);
+							}
+							else
+							{
+								ocpp_set_profile_conf(gun_index, OFF);
+							}
+						}
+
+						// Check target current if charging profile limit > 0
+						checkChargingProfileLimit(gun_index);
+						if(ShmCharger->gun_info[gun_index].targetCurrent > 0)
+						{
+							setRelay(gun_index, ON);
+						}
+
+						// Debug information
+						if(DiffTimebWithNow(startTime[gun_index][TMR_IDX_LOGPPRINTOUT]) > TIMEOUT_SPEC_LOGPPRINTOUT)
+						{
+							DEBUG_INFO("=============================================================\n");
+							DEBUG_INFO("ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent: %d\n", ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent);
+							DEBUG_INFO("ShmCharger->gun_info[%d].primaryMcuCp_Pwn_Duty.max_current: %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty.max_current);
+							DEBUG_INFO("ShmCharger->gun_info[%d].targetCurrent: %d\n", gun_index, ShmCharger->gun_info[gun_index].targetCurrent);
+							DEBUG_INFO("=============================================================\n");
+							ftime(&startTime[gun_index][TMR_IDX_LOGPPRINTOUT]);
+						}
+
 						if((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_C) &&
 						   (ShmCharger->gun_info[gun_index].rfidReq != ON) &&
 						   (ShmCharger->gun_info[gun_index].bleConfigData.isRequestStop != ON)  &&

+ 1 - 0
EVSE/Projects/Noodoe/Apps/main.h

@@ -413,6 +413,7 @@ typedef struct GUN_INFO
 	Set_Led_Brightness								setLedBrightness;
 	uint8_t											chargingMode;
 	uint16_t										targetCurrent;
+	float											tempCoefficient;
 	uint16_t										isAuthPassEnd:1;
 	uint16_t										rfidReq:1;
 	uint16_t										isGunPlugged:1;

BIN
EVSE/Projects/Noodoe/Images/FactoryDefaultConfig.bin


BIN
EVSE/Projects/Noodoe/Images/ramdisk.gz