Преглед на файлове

Merge branch 'master' into DD360Tcci

Simon Xue преди 3 години
родител
ревизия
702cc63f45

+ 31 - 15
EVSE/Modularization/Module_RatedCurrent.c

@@ -57,18 +57,22 @@ static SymStruct regulationTable[] = {
 };
 
 static SymStruct powerTable[] = {
-    {"30", POWER_30W},
-    {"60", POWER_60W},
-	{"80", POWER_80W},
-    {"90", POWER_90W},
-    {"12", POWER_120W},
-    {"15", POWER_150W},
-	{"16", POWER_160W},
-    {"18", POWER_180W},
-    {"24", POWER_240W},
-    {"36", POWER_360W},
-    {"48", POWER_480W},
-    {"72", POWER_720W},
+    {"301", POWER_30W},
+    {"601", POWER_60W},
+	{"801", POWER_80W},
+    {"901", POWER_90W},
+    {"122", POWER_120W},
+    {"152", POWER_150W},
+	{"162", POWER_160W},
+    {"182", POWER_180W},
+    {"212", POWER_210W},
+    {"242", POWER_240W},
+    {"272", POWER_270W},
+    {"302", POWER_300W},
+    {"332", POWER_330W},
+    {"362", POWER_360W},
+    {"482", POWER_480W},
+    {"722", POWER_720W},
 };
 
 static SymStruct gunTypeTable[] = {
@@ -527,9 +531,21 @@ static int exchangePowerValue(uint8_t key)
     case POWER_180W:
         return 1800;
 
+    case POWER_210W:
+        return 2100;
+
     case POWER_240W:
         return 2400;
 
+    case POWER_270W:
+        return 2700;
+
+    case POWER_300W:
+        return 3000;
+
+    case POWER_330W:
+        return 3300;
+
     case POWER_360W:
         return 3600;
 
@@ -566,7 +582,7 @@ int RatedCurrentParsing(char *pModuleName, void *pDestStruct)
     uint32_t ret = 0;
     char model[3] = {'\0'};
     char regulation[2] = {'\0'};
-    char power[3] = {'\0'};
+    char power[4] = {'\0'};
     char gunType[2] = {'\0'};
     ParsingRatedCur *pParsingInfo = NULL;
     RateCurInfo *pGunRateCurInfo = NULL;
@@ -583,8 +599,8 @@ int RatedCurrentParsing(char *pModuleName, void *pDestStruct)
     model[2] = '\0';
     strncpy(regulation, &pModuleName[3], 1);
     regulation[1] = '\0';
-    strncpy(power, &pModuleName[4], 2);
-    power[2] = '\0';
+    strncpy(power, &pModuleName[4], 3);
+    power[3] = '\0';
 
     //get max power value
     powerKey = keyfromstring(&power[0], &powerTable[0], sizeof(powerTable) / sizeof(SymStruct));

+ 8 - 4
EVSE/Modularization/Module_RatedCurrent.h

@@ -54,10 +54,14 @@
 #define POWER_150W                              (0x06)
 #define POWER_160W                              (0x07)
 #define POWER_180W                              (0x08)
-#define POWER_240W                              (0x09)
-#define POWER_360W                              (0x0A)
-#define POWER_480W                              (0x0B)
-#define POWER_720W                              (0x0C)
+#define POWER_210W                              (0x09)
+#define POWER_240W                              (0x0A)
+#define POWER_270W                              (0x0B)
+#define POWER_300W                              (0x0C)
+#define POWER_330W                              (0x0D)
+#define POWER_360W                              (0x0E)
+#define POWER_480W                              (0x0F)
+#define POWER_720W                              (0x10)
 
 //------------------------------------------------------------------------------
 // gun type key

+ 55 - 2
EVSE/Modularization/Module_Upgrade.c

@@ -21,8 +21,11 @@
 #define FAIL                -1
 #define	YES					1
 #define	NO					0
+#define	ON					1
+#define	OFF					0
 #define HEADER_LENGTH		48
 
+
 struct SysConfigAndInfo         *ShmSysConfigAndInfo;
 struct StatusCodeData           *ShmStatusCodeData;
 struct FanModuleData            *ShmFanModuleData;
@@ -122,6 +125,52 @@ int runShellCmd(const char*cmd)
 	return result;
 }
 
+int config_upgrade_flag(unsigned int upgradeFlag, unsigned char isSetFlag)
+{
+	int result = FAIL;
+	int fd;
+	unsigned char envFlash[512*1024];
+	system("rm -f /tmp/envFlash");
+	DEBUG_INFO("Read /dev/mtd2.\n");
+	runShellCmd("nanddump -s 0x0 -l 0x80000 -f /tmp/envFlash /dev/mtd2");
+
+    fd = open("/tmp/envFlash", O_RDWR);
+    if(fd < 0)
+    {
+        DEBUG_ERROR("Open envFlash NG.\n");
+    }
+    else
+    {
+		read(fd,envFlash,ARRAY_SIZE(envFlash));
+		close(fd);
+		system("rm -f /tmp/envFlash");
+
+		envFlash[upgradeFlag] = (isSetFlag?0x00:0xff);
+
+		fd = open("/tmp/envFlash", O_RDWR | O_CREAT | O_EXCL);
+		if(fd < 0)
+		{
+			DEBUG_ERROR("Open envFlash NG.\n");
+		}
+		else
+		{
+			write(fd,envFlash,ARRAY_SIZE(envFlash));
+			close(fd);
+
+			DEBUG_INFO("Erase /dev/mtd2.\n");
+			runShellCmd("flash_erase /dev/mtd2 0 0");
+
+			DEBUG_INFO("Write /dev/mtd2.\n");
+			runShellCmd("nandwrite -p /dev/mtd2 /tmp/envFlash");
+
+			system("rm -f /tmp/envFlash");
+			result = PASS;
+		}
+    }
+
+	return result;
+}
+
 int Upgrade_Flash(unsigned int Type,char *SourcePath,char *ModelName)
 {
     int result = FAIL;
@@ -309,15 +358,15 @@ int Upgrade_Flash(unsigned int Type,char *SourcePath,char *ModelName)
                                 }
                                 else
                                 {
+                                	config_upgrade_flag(UPGRADE_FLAG_DTS, ON);
                                     DEBUG_INFO("Erase /dev/mtd4.\n");
                                     runShellCmd("flash_erase /dev/mtd4 0 0");
-
 									DEBUG_INFO("Write /dev/mtd4.\n");
 									runShellCmd("nandwrite -p /dev/mtd4 /mnt/imgBuffer");
+									config_upgrade_flag(UPGRADE_FLAG_DTS, OFF);
 
 									DEBUG_INFO("Erase /dev/mtd5.\n");
 									runShellCmd("flash_erase /dev/mtd5 0 0");
-
 									DEBUG_INFO("Write /dev/mtd5.\n");
 									runShellCmd("nandwrite -p /dev/mtd5 /mnt/imgBuffer");
 
@@ -346,10 +395,12 @@ int Upgrade_Flash(unsigned int Type,char *SourcePath,char *ModelName)
                                 }
                                 else
                                 {
+                                	config_upgrade_flag(UPGRADE_FLAG_KERNEL, ON);
                                 	DEBUG_INFO("Erase /dev/mtd6.\n");
                                 	runShellCmd("flash_erase /dev/mtd6 0 0");
 									DEBUG_INFO("Write /dev/mtd6.\n");
 									runShellCmd("nandwrite -p /dev/mtd6 /mnt/imgBuffer");
+									config_upgrade_flag(UPGRADE_FLAG_KERNEL, OFF);
 
 									DEBUG_INFO("Erase /dev/mtd7.\n");
 									runShellCmd("flash_erase /dev/mtd7 0 0");
@@ -380,10 +431,12 @@ int Upgrade_Flash(unsigned int Type,char *SourcePath,char *ModelName)
                                 }
                                 else
                                 {
+                                	config_upgrade_flag(UPGRADE_FLAG_ROOTFS, ON);
                                 	DEBUG_INFO("Erase /dev/mtd8.\n");
                                 	runShellCmd("flash_erase /dev/mtd8 0 0");
                                 	DEBUG_INFO("Write /dev/mtd8.\n");
                                 	runShellCmd("nandwrite -p /dev/mtd8 /mnt/imgBuffer");
+                                	config_upgrade_flag(UPGRADE_FLAG_ROOTFS, OFF);
 
                                 	DEBUG_INFO("Erase /dev/mtd9.\n");
                                 	runShellCmd("flash_erase /dev/mtd9 0 0");

+ 6 - 0
EVSE/Modularization/Module_Upgrade.h

@@ -98,6 +98,12 @@ enum Uart_Command
     UART_CMD_UPDATE_FINISH                      = 0xe3,
 };
 
+enum Upgrade_Flag
+{
+	UPGRADE_FLAG_DTS							= 0x7fffd,
+	UPGRADE_FLAG_KERNEL							= 0x7fffe,
+	UPGRADE_FLAG_ROOTFS							= 0x7ffff
+};
 
 int Upgrade_Flash(unsigned int Type,char *SourcePath,char *ModelName);
 int Upgrade_UART(int uartfdOrd,unsigned int Type,unsigned char TargetAddr,char *SourcePath,char *ModelName);

+ 310 - 98
EVSE/Projects/AW-CCS/Apps/LCM/Module_LcmControl.c

@@ -2,9 +2,9 @@
  * Module_LcmControl.c
  *
  * Created on : 2020-10-20
- * Update on : 2022-01-07
+ * Update on : 2022-01-17
  * Author : Folus Wen, Eason Yang
- * Version : V0.26
+ * Version : V0.27
  *
  */
 
@@ -44,6 +44,8 @@ void setQRCodeAlarm();
 void setEthernetIcon();
 uint8_t getCurrentPage();
 void setAlarmCodeAndIcon();
+void setPresentSessionFee();
+void setPresentParkingFee();
 void setBillingFromWebsite();
 int isEthConnected(char *eth);
 void setUserPrice(uint8_t type);
@@ -102,6 +104,8 @@ struct timespec					startTime[AC_QUANTITY][TMR_IDX_SHOW_AUTH_RESULT];
 #define TIME_AUTH_RESULT_TIME			5 // Unit: Second
 #define TIME_REFRESH_INFO				3 // Unit: Second
 
+#define is_error(ptr) 					((unsigned long)ptr > (unsigned long)-4000L)
+
 //=======================================
 // Declare Variable
 //=======================================
@@ -114,7 +118,7 @@ int Uart1Fd;
 //=======================================
 // Record version and date
 //=======================================
-char *FIRMWARE_UPDATE_IMAGE[3] = {"V0.26", "2022-01-07", "REV.02.00"};
+char *FIRMWARE_UPDATE_IMAGE[3] = {"V0.27", "2022-01-17", "REV.03.00"};
 
 //=======================================
 // Common routine
@@ -272,7 +276,8 @@ void getDateTimeString(char* result)
 	CurrentTime = time(NULL);
 	tm=localtime(&CurrentTime);
 
-	sprintf(result, "%04d/%02d/%02d %02d:%02d", tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min);
+	//sprintf(result, "%04d/%02d/%02d %02d:%02d", tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min);
+	sprintf(result, "%04d/%02d/%02d %02d:%02d %s", tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,(tm->tm_hour%12),tm->tm_min,((tm->tm_hour/12)>0?"p.m":"a.m"));
 }
 
 //======================================================
@@ -468,6 +473,8 @@ void page_charging(uint8_t gun_index, uint8_t system_mode)
 				if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_16)
 				{
 					setRunningCost(gun_index, TOTAL_COST);
+					setRunningCost(gun_index, SESSION_FEE);
+					setRunningCost(gun_index, OCCUPANCY_FEE);
 				}
 				else
 				{
@@ -478,16 +485,29 @@ void page_charging(uint8_t gun_index, uint8_t system_mode)
 			{
 				if(ShmSysConfigAndInfo->SysConfig.BillingData.isBilling == ON)
 				{
-					setDisplayValue(ICON_CHARGING_COST, APPEAR);
+					setDisplayValue(ICON_CHARGING_TOTAL_COST, APPEAR);
+					setDisplayValue(ICON_CHARGING_SESSION_FEE, APPEAR);
+					setDisplayValue(ICON_CHARGING_PARKING_FEE, APPEAR);
+
 					setPresentFinalCost(getPresentFinalCost(gun_index));
+					//setPresentSessionFee();
+					setPresentParkingFee();
 				}
 				else
 				{
-					// User spend cost
-					setDisplayValue(ICON_CHARGING_COST, DISAPPEAR);
-					setDisplayValue(TEXT_CHARGING_COST, DISAPPEAR);
+					// Total cost disappear
+					setDisplayValue(ICON_CHARGING_TOTAL_COST, DISAPPEAR);
+					setDisplayValue(TEXT_CHARGING_TOTAL_COST, DISAPPEAR);
+
+					// Session fee disappear
+					setDisplayValue(ICON_CHARGING_SESSION_FEE, DISAPPEAR);
+					setDisplayValue(TEXT_CHARGING_SESSION_FEE, DISAPPEAR);
 
-					// User account balance
+					// Parking fee disappear
+					setDisplayValue(ICON_CHARGING_PARKING_FEE, DISAPPEAR);
+					setDisplayValue(TEXT_CHARGING_PARKING_FEE, DISAPPEAR);
+
+					// User account balance disappear
 					setDisplayValue(ICON_COMPLETE_WALLET, DISAPPEAR);
 					setDisplayValue(TEXT_REMAINING_ACCOUNT_BALANCE, DISAPPEAR);
 				}
@@ -532,6 +552,8 @@ void page_complete(uint8_t gun_index, uint8_t system_mode)
 		if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_16)
 		{
 			setFinalCost(gun_index, TOTAL_COST);
+			setFinalCost(gun_index, SESSION_FEE);
+			setFinalCost(gun_index, OCCUPANCY_FEE);
 			setFinalCost(gun_index, ACCOUNT_BALANCE);
 			//setCurrencyAndUnitFromBackend(FINAL_COST, ACCOUNT_BALANCE, gun_index);
 		}
@@ -544,19 +566,32 @@ void page_complete(uint8_t gun_index, uint8_t system_mode)
 	{
 		if(ShmSysConfigAndInfo->SysConfig.BillingData.isBilling == ON)
 		{
-			setDisplayValue(ICON_CHARGING_COST, APPEAR);
+			setDisplayValue(ICON_CHARGING_TOTAL_COST, APPEAR);
+			setDisplayValue(ICON_CHARGING_SESSION_FEE, APPEAR);
+			setDisplayValue(ICON_CHARGING_PARKING_FEE, APPEAR);
+
 			setPresentFinalCost(getPresentFinalCost(gun_index));
+			//setPresentSessionFee();
+			setPresentParkingFee();
 
 			setDisplayValue(ICON_COMPLETE_WALLET, DISAPPEAR);
 			setDisplayValue(TEXT_REMAINING_ACCOUNT_BALANCE, DISAPPEAR);
 		}
 		else
 		{
-			// User spend cost
-			setDisplayValue(ICON_CHARGING_COST, DISAPPEAR);
-			setDisplayValue(TEXT_CHARGING_COST, DISAPPEAR);
+			// Total cost disappear
+			setDisplayValue(ICON_CHARGING_TOTAL_COST, DISAPPEAR);
+			setDisplayValue(TEXT_CHARGING_TOTAL_COST, DISAPPEAR);
 
-			// User account balance
+			// Session fee disappear
+			setDisplayValue(ICON_CHARGING_SESSION_FEE, DISAPPEAR);
+			setDisplayValue(TEXT_CHARGING_SESSION_FEE, DISAPPEAR);
+
+			// Parking fee disappear
+			setDisplayValue(ICON_CHARGING_PARKING_FEE, DISAPPEAR);
+			setDisplayValue(TEXT_CHARGING_PARKING_FEE, DISAPPEAR);
+
+			// User account balance disappear
 			setDisplayValue(ICON_COMPLETE_WALLET, DISAPPEAR);
 			setDisplayValue(TEXT_REMAINING_ACCOUNT_BALANCE, DISAPPEAR);
 		}
@@ -582,6 +617,8 @@ void page_terminating(uint8_t gun_index, uint8_t system_mode)
 			if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_16)
 			{
 				setRunningCost(gun_index, TOTAL_COST);
+				setRunningCost(gun_index, SESSION_FEE);
+				setRunningCost(gun_index, OCCUPANCY_FEE);
 			}
 			else
 			{
@@ -592,16 +629,29 @@ void page_terminating(uint8_t gun_index, uint8_t system_mode)
 		{
 			if(ShmSysConfigAndInfo->SysConfig.BillingData.isBilling == ON)
 			{
-				setDisplayValue(ICON_CHARGING_COST, APPEAR);
+				setDisplayValue(ICON_CHARGING_TOTAL_COST, APPEAR);
+				setDisplayValue(ICON_CHARGING_SESSION_FEE, APPEAR);
+				setDisplayValue(ICON_CHARGING_PARKING_FEE, APPEAR);
+
 				setPresentFinalCost(getPresentFinalCost(gun_index));
+				//setPresentSessionFee();
+				setPresentParkingFee();
 			}
 			else
 			{
-				// User spend cost
-				setDisplayValue(ICON_CHARGING_COST, DISAPPEAR);
-				setDisplayValue(TEXT_CHARGING_COST, DISAPPEAR);
+				// Total cost disappear
+				setDisplayValue(ICON_CHARGING_TOTAL_COST, DISAPPEAR);
+				setDisplayValue(TEXT_CHARGING_TOTAL_COST, DISAPPEAR);
+
+				// Session fee disappear
+				setDisplayValue(ICON_CHARGING_SESSION_FEE, DISAPPEAR);
+				setDisplayValue(TEXT_CHARGING_SESSION_FEE, DISAPPEAR);
+
+				// Parking fee disappear
+				setDisplayValue(ICON_CHARGING_PARKING_FEE, DISAPPEAR);
+				setDisplayValue(TEXT_CHARGING_PARKING_FEE, DISAPPEAR);
 
-				// User account balance
+				// User account balance disappear
 				setDisplayValue(ICON_COMPLETE_WALLET, DISAPPEAR);
 				setDisplayValue(TEXT_REMAINING_ACCOUNT_BALANCE, DISAPPEAR);
 			}
@@ -1092,15 +1142,52 @@ void setPriceFromWebsite(float monry_rate)
 //=======================================
 void setPresentFinalCost(float cost)
 {
-	uint8_t data[16];
-	uint8_t finalCost[16];
+	uint8_t data[32];
+	uint8_t finalCost[32];
 
 	memset(data, 0x00, ARRAY_SIZE(data));
 	memset(finalCost, 0x00, ARRAY_SIZE(finalCost));
 
 	sprintf((char *)finalCost, "%.2f", cost);
 	string2ByteArray(finalCost, data);
-	lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_COST, data, ARRAY_SIZE(data));
+
+	// Total Cost
+	lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_TOTAL_COST, data, ARRAY_SIZE(data));
+
+	// Session Fee
+	lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_SESSION_FEE, data, ARRAY_SIZE(data));
+}
+
+//=======================================
+// Setting [ Session Fee ] ( WEB PAGE )
+//=======================================
+void setPresentSessionFee()
+{
+	uint8_t data[32];
+	uint8_t sessionFee[32];
+
+	memset(data, 0x00, ARRAY_SIZE(data));
+	memset(sessionFee, 0x00, ARRAY_SIZE(sessionFee));
+
+	strcpy((char*)sessionFee, "-----");
+	string2ByteArray(sessionFee, data);
+	lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_SESSION_FEE, data, ARRAY_SIZE(data));
+}
+
+//=======================================
+// Setting [ Parking Fee ] ( WEB PAGE )
+//=======================================
+void setPresentParkingFee()
+{
+	uint8_t data[32];
+	uint8_t parkingFee[32];
+
+	memset(data, 0x00, ARRAY_SIZE(data));
+	memset(parkingFee, 0x00, ARRAY_SIZE(parkingFee));
+
+	strcpy((char*)parkingFee, "-----");
+	string2ByteArray(parkingFee, data);
+	lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_PARKING_FEE, data, ARRAY_SIZE(data));
 }
 
 //=======================================
@@ -1310,62 +1397,127 @@ void setDefaultPrice(uint8_t type)
 //=======================================
 void setFinalCost(uint8_t gun_index, uint8_t type)
 {
-	uint8_t length;
 	uint8_t output_data[32];
-	char input_data[32];
-	char tmp[256];
-	char *splitString[10];
-	const char *Symbol = ";";
 	unsigned char cost_empty[32];
 	unsigned char balance_empty[32];
+	unsigned char session_empty[32];
+	unsigned char occupancy_empty[32];
+	json_object *jsonDescription;
 
-	memset(tmp, 0, ARRAY_SIZE(tmp));
 	memset(output_data, 0x00, ARRAY_SIZE(output_data));
-	memset(input_data, 0x00, ARRAY_SIZE(input_data));
-	memset(cost_empty, 0x00, ARRAY_SIZE(cost_empty));
 	memset(balance_empty, 0x00, ARRAY_SIZE(balance_empty));
+	memset(cost_empty, 0x00, ARRAY_SIZE(cost_empty));
+	memset(session_empty, 0x00, ARRAY_SIZE(session_empty));
+	memset(occupancy_empty, 0x00, ARRAY_SIZE(occupancy_empty));
 
 	switch(type)
 	{
 		case CONNECTION_FEE:
 			break;
 		case SESSION_FEE:
+
+			if(ShmOCPP16Data->StopTransaction[gun_index].TransactionId != ShmOCPP16Data->Cost.FinalCost[gun_index].txId)
+			{
+				setDisplayValue(ICON_CHARGING_SESSION_FEE, APPEAR);
+
+				strcpy((char*)session_empty, "-----");
+				string2ByteArray(session_empty, output_data);
+				lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_SESSION_FEE, output_data, ARRAY_SIZE(output_data));
+			}
+			else
+			{
+				double chargingCost = 0;
+				jsonDescription = json_tokener_parse((char*)ShmOCPP16Data->Cost.FinalCost[gun_index].description);
+
+				if(!is_error(jsonDescription))
+				{
+					if(json_object_object_get(jsonDescription,"chargingFee") != NULL)
+					{
+						chargingCost += json_object_get_double(json_object_object_get(jsonDescription,"chargingFee"));
+					}
+
+					if(chargingCost> 0)
+						sprintf((char*)output_data, "%.2f", chargingCost);
+					else
+						sprintf((char*)output_data, "-----");
+
+					// APPEAR COST ICON
+					setDisplayValue(ICON_CHARGING_SESSION_FEE, APPEAR);
+					lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_SESSION_FEE, output_data, ARRAY_SIZE(output_data));
+				}
+				json_object_put(jsonDescription);
+			}
 			break;
 		case OCCUPANCY_FEE:
+
+			if(ShmOCPP16Data->StopTransaction[gun_index].TransactionId != ShmOCPP16Data->Cost.FinalCost[gun_index].txId)
+			{
+				setDisplayValue(ICON_CHARGING_PARKING_FEE, APPEAR);
+
+				strcpy((char*)occupancy_empty, "-----");
+				string2ByteArray(occupancy_empty, output_data);
+				lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_PARKING_FEE, output_data, ARRAY_SIZE(output_data));
+			}
+			else
+			{
+				double parkingCost = 0;
+				jsonDescription = json_tokener_parse((char*)ShmOCPP16Data->Cost.FinalCost[gun_index].description);
+
+				if(!is_error(jsonDescription))
+				{
+					if(json_object_object_get(jsonDescription,"parkingFee") != NULL)
+					{
+						parkingCost += json_object_get_double(json_object_object_get(jsonDescription,"parkingFee"));
+					}
+
+					if(parkingCost > 0)
+						sprintf((char*)output_data, "%.2f", parkingCost);
+					else
+						sprintf((char*)output_data, "-----");
+
+					setDisplayValue(ICON_CHARGING_PARKING_FEE, APPEAR);
+					lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_PARKING_FEE, output_data, ARRAY_SIZE(output_data));
+				}
+				json_object_put(jsonDescription);
+			}
 			break;
 		case TOTAL_COST:
 			if(ShmOCPP16Data->StopTransaction[gun_index].TransactionId != ShmOCPP16Data->Cost.FinalCost[gun_index].txId)
 			{
-				setDisplayValue(ICON_CHARGING_COST, APPEAR);
+				setDisplayValue(ICON_CHARGING_TOTAL_COST, APPEAR);
 
 				strcpy((char*)cost_empty, "-----");
 				string2ByteArray(cost_empty, output_data);
-				lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_COST, output_data, ARRAY_SIZE(output_data));
+				lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_TOTAL_COST, output_data, ARRAY_SIZE(output_data));
 			}
 			else
 			{
-				if((strstr((char*)ShmOCPP16Data->Cost.FinalCost[gun_index].description, "Total Cost:") > 0))
-				{
-					// APPEAR COST ICON
-					setDisplayValue(ICON_CHARGING_COST, APPEAR);
+				double chargingCost = 0;
+				double parkingCost = 0;
+				jsonDescription = json_tokener_parse((char*)ShmOCPP16Data->Cost.FinalCost[gun_index].description);
 
-					// APPEAR COST TEXT
-					strcpy((char*)tmp,(char*)ShmOCPP16Data->Cost.FinalCost[gun_index].description);
-					split((char**)splitString, tmp, Symbol);
-					memcpy(input_data, splitString[3], strlen(splitString[3]));
-					length = strlen(input_data);
-					trim_string(input_data,length);
-					memcpy(output_data ,input_data, strlen(input_data));
-					lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_COST, output_data, ARRAY_SIZE(output_data));
-				}
-				else
+				if(!is_error(jsonDescription))
 				{
-					setDisplayValue(ICON_CHARGING_COST, APPEAR);
+					if(json_object_object_get(jsonDescription,"chargingFee") != NULL)
+					{
+						chargingCost += json_object_get_double(json_object_object_get(jsonDescription,"chargingFee"));
+					}
+
+					if(json_object_object_get(jsonDescription,"parkingFee") != NULL)
+					{
+						parkingCost += json_object_get_double(json_object_object_get(jsonDescription,"parkingFee"));
+					}
+
+					if((chargingCost + parkingCost) > 0)
+						sprintf((char*)output_data, "%.2f", (chargingCost + parkingCost));
+					else
+						sprintf((char*)output_data, "-----");
 
-					strcpy((char*)cost_empty, "-----");
-					string2ByteArray(cost_empty, output_data);
-					lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_COST, output_data, ARRAY_SIZE(output_data));
+					// APPEAR COST ICON
+					setDisplayValue(ICON_CHARGING_TOTAL_COST, APPEAR);
+					lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_TOTAL_COST, output_data, ARRAY_SIZE(output_data));
 				}
+				json_object_put(jsonDescription);
 			}
 			break;
 		case ACCOUNT_BALANCE:
@@ -1380,29 +1532,27 @@ void setFinalCost(uint8_t gun_index, uint8_t type)
 			}
 			else
 			{
-				if((strstr((char*)ShmOCPP16Data->Cost.FinalCost[gun_index].description, "Account Balance:") > 0))
-				{
-					// APPEAR BALANCE ICON
-					setDisplayValue(ICON_COMPLETE_WALLET, APPEAR);
+				double accountBalance = 0;
+				jsonDescription = json_tokener_parse((char*)ShmOCPP16Data->Cost.FinalCost[gun_index].description);
 
-					// APPEAR BALANCE TEXT
-					strcpy((char*)tmp,(char*)ShmOCPP16Data->Cost.FinalCost[gun_index].description);
-					split((char**)splitString, tmp, Symbol);
-					memcpy(input_data, splitString[4], strlen(splitString[4]));
-					length = strlen(input_data);
-					trim_string(input_data,length);
-					memcpy(output_data ,input_data, strlen(input_data));
-					lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_REMAINING_ACCOUNT_BALANCE, output_data, ARRAY_SIZE(output_data));
-				}
-				else
+				if(!is_error(jsonDescription))
 				{
-					setDisplayValue(ICON_COMPLETE_WALLET, APPEAR);
+					if(json_object_object_get(jsonDescription,"accountBalance") != NULL)
+					{
+						accountBalance += json_object_get_double(json_object_object_get(jsonDescription,"accountBalance"));
+					}
+
+					if(accountBalance > 0)
+						sprintf((char*)output_data, "%.2f", accountBalance);
+					else
+						sprintf((char*)output_data, "-----");
 
-					strcpy((char*)balance_empty, "-----");
-					string2ByteArray(balance_empty, output_data);
 
+					// APPEAR COST ICON
+					setDisplayValue(ICON_COMPLETE_WALLET, APPEAR);
 					lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_REMAINING_ACCOUNT_BALANCE, output_data, ARRAY_SIZE(output_data));
 				}
+				json_object_put(jsonDescription);
 			}
 			break;
 		default:
@@ -1415,65 +1565,125 @@ void setFinalCost(uint8_t gun_index, uint8_t type)
 //=======================================
 void setRunningCost(uint8_t gun_index, uint8_t type)
 {
-	uint8_t length;
 	uint8_t output_data[32];
-	char input_data[32];
-	char tmp[256];
-	char *splitString[10];
-	const char *Symbol = ";";
 	unsigned char cost_empty[32];
+	unsigned char session_empty[32];
+	unsigned char occupancy_empty[32];
+	json_object *jsonDescription;
 
-	memset(tmp, 0, ARRAY_SIZE(tmp));
 	memset(output_data, 0x00, ARRAY_SIZE(output_data));
-	memset(input_data, 0x00, ARRAY_SIZE(input_data));
 	memset(cost_empty, 0x00, ARRAY_SIZE(cost_empty));
+	memset(session_empty, 0x00, ARRAY_SIZE(session_empty));
+	memset(occupancy_empty, 0x00, ARRAY_SIZE(occupancy_empty));
 
 	switch(type)
 	{
 		case CONNECTION_FEE:
 			break;
 		case SESSION_FEE:
+			if(ShmOCPP16Data->StartTransaction[gun_index].ResponseTransactionId != ShmOCPP16Data->Cost.RunningCost[gun_index].txId)
+			{
+				setDisplayValue(ICON_CHARGING_SESSION_FEE, APPEAR);
+
+				strcpy((char*)session_empty, "-----");
+				string2ByteArray(session_empty, output_data);
+				lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_SESSION_FEE, output_data, ARRAY_SIZE(output_data));
+			}
+			else
+			{
+				double chargingCost = 0;
+				jsonDescription = json_tokener_parse((char*)ShmOCPP16Data->Cost.RunningCost[gun_index].description);
+
+				if(!is_error(jsonDescription))
+				{
+					if(json_object_object_get(jsonDescription,"chargingFee") != NULL)
+					{
+						chargingCost += json_object_get_double(json_object_object_get(jsonDescription,"chargingFee"));
+					}
+
+					if(chargingCost> 0)
+						sprintf((char*)output_data, "%.2f", chargingCost);
+					else
+						sprintf((char*)output_data, "-----");
+
+					// APPEAR COST ICON
+					setDisplayValue(ICON_CHARGING_SESSION_FEE, APPEAR);
+					lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_SESSION_FEE, output_data, ARRAY_SIZE(output_data));
+				}
+				json_object_put(jsonDescription);
+			}
+
 			break;
 		case OCCUPANCY_FEE:
+			if(ShmOCPP16Data->StartTransaction[gun_index].ResponseTransactionId != ShmOCPP16Data->Cost.RunningCost[gun_index].txId)
+			{
+				setDisplayValue(ICON_CHARGING_PARKING_FEE, APPEAR);
+
+				strcpy((char*)occupancy_empty, "-----");
+				string2ByteArray(occupancy_empty, output_data);
+				lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_PARKING_FEE, output_data, ARRAY_SIZE(output_data));
+			}
+			else
+			{
+				double parkingCost = 0;
+				jsonDescription = json_tokener_parse((char*)ShmOCPP16Data->Cost.RunningCost[gun_index].description);
+
+				if(!is_error(jsonDescription))
+				{
+					if(json_object_object_get(jsonDescription,"parkingFee") != NULL)
+					{
+						parkingCost += json_object_get_double(json_object_object_get(jsonDescription,"parkingFee"));
+					}
+
+					if(parkingCost > 0)
+						sprintf((char*)output_data, "%.2f", parkingCost);
+					else
+						sprintf((char*)output_data, "-----");
+
+					setDisplayValue(ICON_CHARGING_PARKING_FEE, APPEAR);
+					lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_PARKING_FEE, output_data, ARRAY_SIZE(output_data));
+				}
+				json_object_put(jsonDescription);
+			}
+
 			break;
 		case TOTAL_COST:
 			if(ShmOCPP16Data->StartTransaction[gun_index].ResponseTransactionId != ShmOCPP16Data->Cost.RunningCost[gun_index].txId)
 			{
-				setDisplayValue(ICON_CHARGING_COST, APPEAR);
+				setDisplayValue(ICON_CHARGING_TOTAL_COST, APPEAR);
 
 				strcpy((char*)cost_empty, "-----");
 				string2ByteArray(cost_empty, output_data);
-				lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_COST, output_data, ARRAY_SIZE(output_data));
+				lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_TOTAL_COST, output_data, ARRAY_SIZE(output_data));
 			}
 			else
 			{
-				if(strlen((char*)ShmOCPP16Data->Cost.RunningCost[gun_index].description) > 0)
+				double chargingCost = 0;
+				double parkingCost = 0;
+				jsonDescription = json_tokener_parse((char*)ShmOCPP16Data->Cost.RunningCost[gun_index].description);
+
+				if(!is_error(jsonDescription))
 				{
-					if((strstr((char*)ShmOCPP16Data->Cost.RunningCost[gun_index].description, "Total Cost:") > 0))
+					if(json_object_object_get(jsonDescription,"chargingFee") != NULL)
 					{
-						// APPEAR COST ICON
-						setDisplayValue(ICON_CHARGING_COST, APPEAR);
+						chargingCost += json_object_get_double(json_object_object_get(jsonDescription,"chargingFee"));
+					}
 
-						// APPEAR COST TEXT
-						strcpy((char*)tmp,(char*)ShmOCPP16Data->Cost.RunningCost[gun_index].description);
-						split((char**)splitString, tmp, Symbol);
-						memcpy(input_data, splitString[3], strlen(splitString[3]));
-						length = strlen(input_data);
-						trim_string(input_data,length);
-						memcpy(output_data ,input_data, strlen(input_data));
-						lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_COST, output_data, ARRAY_SIZE(output_data));
+					if(json_object_object_get(jsonDescription,"parkingFee") != NULL)
+					{
+						parkingCost += json_object_get_double(json_object_object_get(jsonDescription,"parkingFee"));
 					}
+
+					if((chargingCost + parkingCost) > 0)
+						sprintf((char*)output_data, "%.2f", (chargingCost + parkingCost));
 					else
-					{
-						setDisplayValue(ICON_CHARGING_COST, APPEAR);
+						sprintf((char*)output_data, "-----");
 
-						strcpy((char*)cost_empty, "-----");
-						string2ByteArray(cost_empty, output_data);
-						lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_COST, output_data, ARRAY_SIZE(output_data));
-					}
+					// APPEAR COST ICON
+					setDisplayValue(ICON_CHARGING_TOTAL_COST, APPEAR);
+					lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_TOTAL_COST, output_data, ARRAY_SIZE(output_data));
 				}
-				else
-				{}
+				json_object_put(jsonDescription);
 			}
 
 			break;
@@ -2163,9 +2373,11 @@ void setTextToEmpty(uint8_t gun_index)
 	strcpy((char*)text_empty, "    ");
 	string2ByteArray(text_empty, data);
 
-	lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_COST, data, ARRAY_SIZE(data));
-	lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_REMAINING_ACCOUNT_BALANCE, data, ARRAY_SIZE(data));
+	lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_TOTAL_COST, data, ARRAY_SIZE(data));
+	lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_SESSION_FEE, data, ARRAY_SIZE(data));
+	lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_PARKING_FEE, data, ARRAY_SIZE(data));
 	lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_USER_ACCOUNT_BALANCE, data, ARRAY_SIZE(data));
+	lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_REMAINING_ACCOUNT_BALANCE, data, ARRAY_SIZE(data));
 }
 
 //=======================================

+ 3 - 2
EVSE/Projects/AW-CCS/Apps/LCM/lcmComm_dgus.c

@@ -2,9 +2,9 @@
  * lcmComm_dgus.c
  *
  * Created on : 2020-10-20
- * Update on : 2021-12-14
+ * Update on : 2022-01-17
  * Author : Folus Wen, Eason Yang
- * Version : V0.24
+ * Version : V0.27
  *
  */
 
@@ -74,6 +74,7 @@ int transceiverDgus(int32_t fd, uint8_t *tx, uint16_t tx_len, uint8_t *rx, uint1
 		}
 		else if(tx[3] == CMD_REG_READ_DATA)
 		{
+			usleep(100);
 			len = read(fd, rx, rx_len);
 			if(len > 0)
 			{

+ 18 - 14
EVSE/Projects/AW-CCS/Apps/LCM/lcmComm_dgus.h

@@ -2,9 +2,9 @@
  * lcmComm_dwin.h
  *
  * Created on : 2020-10-20
- * Update on : 2021-12-14
+ * Update on : 2022-01-17
  * Author : Folus Wen, Eason Yang
- * Version : V0.24
+ * Version : V0.27
  *
  */
 
@@ -146,27 +146,27 @@
 #define ICON_PREPARING_PLUG_ARROW			0x100B
 #define ICON_PREPARING_TIMER				0x100C
 #define ICON_PREPARING_ENERGY				0x100D
-#define ICON_PREPARING_COST					0x100E
+#define ICON_PREPARING_TOTAL_COST			0x100E
 #define ICON_PREPARING_POWER				0x100F
 #define ICON_PREPARING_ANIMATION			0x1010
-#define Reserve_3							0x1011
-#define Reserve_4							0x1012
+#define ICON_PREPARING_SESSION_FEE			0x1011 // NEW
+#define ICON_PREPARING_PARKING_FEE			0x1012 // NEW
 #define ICON_PRECHARGING_TIMER				0x1013
 #define ICON_PRECHARGING_ENERGY				0x1014
-#define ICON_PRECHARGING_COST				0x1015
+#define ICON_PRECHARGING_TOTAL_COST			0x1015
 #define ICON_PRECHARGING_POWER				0x1016
 #define ICON_PRECHARGING_ANIMATION			0x1017
 #define ICON_PRECHARGING_FUNNEL				0x1018
-#define Reserve_5							0x1019
-#define Reserve_6							0x101A
+#define ICON_PRECHARGING_SESSION_FEE		0x1019 // NEW
+#define ICON_PRECHARGING_PARKING_FEE		0x101A // NEW
 #define ICON_CHARGING_TIMER					0x101B
 #define ICON_CHARGING_ENERGY				0x101C
-#define ICON_CHARGING_COST					0x101D
+#define ICON_CHARGING_TOTAL_COST			0x101D
 #define ICON_CHARGING_POWER					0x101E
 #define ICON_CHARGING_ANIMATION				0x101F
 #define ICON_CHARGING_LIGHTNING				0x1020
-#define Reserve_7							0x1021
-#define Reserve_8							0x1022
+#define ICON_CHARGING_SESSION_FEE			0x1021	// NEW
+#define ICON_CHARGING_PARKING_FEE			0x1022	// NEW
 #define ICON_COMPLETE_TIMER					0x1023
 #define ICON_COMPLETE_ENERGY				0x1024
 #define ICON_COMPLETE_WALLET				0x1025
@@ -221,16 +221,20 @@
 #define Reserve5							0x20F8	// size 16
 #define TEXT_CHARGING_TIMER					0x2108	// size 16
 #define TEXT_CHARGING_ENERGY				0x2118	// size 16
-#define TEXT_CHARGING_COST					0x2128	// size 16
+#define TEXT_CHARGING_TOTAL_COST			0x2128	// size 16
 #define TEXT_CHARGING_POWER					0x2138	// size 16
-#define Reserve6							0x2148	// size 16
-#define Reserve7							0x2158	// size 16
+#define TEXT_CHARGING_SESSION_FEE			0x2148	// size 16	// NEW
+#define TEXT_CHARGING_PARKING_FEE			0x2158	// size 16	// NEW
 #define TEXT_REMAINING_ACCOUNT_BALANCE		0x2168	// size 16
 #define TEXT_USER_ACCOUNT_BALANCE			0x2178	// size 16
 #define TEXT_USER_CURRENCY					0x2188	// size 16
 #define Reserve8							0x2198	// size 16
 #define Reserve9							0x21A8	// siez 16
 #define TEXT_POWER_CONSUMPTION				0x21B8	// size 32
+#define TEXT_PREPARING_SESSION_FEE			0x21D8	// size 16 // NEW
+#define TEXT_PREPARING_PARKING_FEE			0x21E8	// size 16 // NEW
+#define TEXT_PRECHARGING_SESSION_FEE		0x21F8	// size 16 // NEW
+#define TEXT_PRECHARGING_PARKING_FEE		0x2208	// size 16 // NEW
 
 #define TEXT_RTC							0X2500	// size 32
 

+ 65 - 2
EVSE/Projects/AW-CCS/Apps/Module_InternalComm.c

@@ -763,7 +763,7 @@ unsigned char Query_AC_MCU_Status(unsigned char fd, unsigned char targetAddr, Ac
 		{
 			Ret_Buf->cp_state = rx[6];
 			Ret_Buf->current_limit = rx[7] | (rx[8]<<0x08);
-			Ret_Buf->cp_voltage_positive = (rx[9] | (rx[10]<<0x08))/100.0;		
+			Ret_Buf->cp_voltage_positive = (rx[9] | (rx[10]<<0x08))/100.0;
 			Ret_Buf->cp_voltage_negtive = (rx[11] | (rx[12]<<0x08))/100.0;
 			Ret_Buf->locker_state = rx[13];
 			Ret_Buf->relay_state = rx[14];
@@ -1537,7 +1537,7 @@ unsigned char Config_AC_MaxCurrent_And_CpPwmDuty(unsigned char fd, unsigned char
 	tx[4] = 0x01;
 	tx[5] = 0x00;
 	tx[6] = Set_Buf->max_current;
-		DEBUG_WARN("Config_AC_MaxCurrent_And_CpPwmDuty...%d\n", Set_Buf->max_current);
+	DEBUG_WARN("Config_AC_MaxCurrent_And_CpPwmDuty...%d\n", Set_Buf->max_current);
 
 	for(int idx=0;idx<(tx[4] | tx[5]<<8);idx++)
 			chksum ^= tx[6+idx];
@@ -2208,6 +2208,39 @@ int main(void)
 					else
 						failCount[gun_index] = FAIL_SPEC_COMM;
 				}
+				
+				//===============================
+				// Case 11 : Query present output current
+				//===============================
+				if(Query_Present_OutputCurrent(Uart1Fd, (gun_index>0?ADDR_AC_PRIMARY_2:ADDR_AC_PRIMARY_1), &ShmCharger->gun_info[gun_index].outputCurrent) == PASS)
+				{
+#ifndef SIMULATION
+					ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargingCurrent = (float)ShmCharger->gun_info[gun_index].outputCurrent.L1N_L12[0];
+					ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargingCurrentL2 = (float)ShmCharger->gun_info[gun_index].outputCurrent.L2N_L23[0];
+					ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargingCurrentL3 = (float)ShmCharger->gun_info[gun_index].outputCurrent.L3N_L31[0];
+					
+					
+					ShmCharger->gun_info[gun_index].acCcsInfo.EVSEPresentCurrent[0] = (float)ShmCharger->gun_info[gun_index].outputCurrent.L1N_L12[0];
+					ShmCharger->gun_info[gun_index].acCcsInfo.EVSEPresentCurrent[1] = (float)ShmCharger->gun_info[gun_index].outputCurrent.L1N_L12[0];
+					ShmCharger->gun_info[gun_index].acCcsInfo.EVSEPresentCurrent[2] = (float)ShmCharger->gun_info[gun_index].outputCurrent.L1N_L12[0];							
+#else	//SIMULATION
+				ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargingCurrent = (float)(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus==SYS_MODE_CHARGING?(((rand()%10)+((ShmCharger->gun_info[gun_index].targetCurrent*10)-5))/10.0):0);
+				if(ShmSysConfigAndInfo->SysConfig.AcPhaseCount == 3)
+				{
+					ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargingCurrentL2 = (float)(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus==SYS_MODE_CHARGING?(((rand()%10)+((ShmCharger->gun_info[gun_index].targetCurrent*10)-5))/10.0):0);
+					ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargingCurrentL3 = (float)(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus==SYS_MODE_CHARGING?(((rand()%10)+((ShmCharger->gun_info[gun_index].targetCurrent*10)-5))/10.0):0);
+				}
+#endif	//SIMULATION
+					failCount[gun_index] = 0;
+				}
+				else
+				{
+					DEBUG_WARN("MCU-%d get output current fail...%d\n", gun_index, failCount[gun_index]);
+					if(failCount[gun_index]<USHRT_MAX)
+						failCount[gun_index]++;
+					else
+						failCount[gun_index] = FAIL_SPEC_COMM;
+				}
 
 				//==========================================================
 				// High priority polling log print out
@@ -2369,6 +2402,7 @@ int main(void)
 					//===============================
 					// Query primary MCU BLE config
 					//===============================
+					/*
 					if((previousCharger.gun_info[gun_index].bleConfigData.isLogin != ShmCharger->gun_info[gun_index].bleConfigData.isLogin) ||
 					   (previousCharger.gun_info[gun_index].bleConfigData.isRequestStart != ShmCharger->gun_info[gun_index].bleConfigData.isRequestStart) ||
 					   (previousCharger.gun_info[gun_index].bleConfigData.isRequestStop != ShmCharger->gun_info[gun_index].bleConfigData.isRequestStop))
@@ -2387,10 +2421,12 @@ int main(void)
 						previousCharger.gun_info[gun_index].bleConfigData.isRequestStart = ShmCharger->gun_info[gun_index].bleConfigData.isRequestStart;
 						previousCharger.gun_info[gun_index].bleConfigData.isRequestStop = ShmCharger->gun_info[gun_index].bleConfigData.isRequestStop;
 					}
+					*/
 
 					//===============================
 					// Query primary MCU ble login id
 					//===============================
+					/*
 					if((strcmp((char *)&previousCharger.gun_info[gun_index].bleLoginCentralId.id,(char *)&ShmCharger->gun_info[gun_index].bleLoginCentralId.id) != 0))
 					{
 						if(strcmp((char *)&ShmCharger->gun_info[gun_index].bleLoginCentralId.id,"") != 0)
@@ -2403,6 +2439,29 @@ int main(void)
 
 						memcpy(&previousCharger.gun_info[gun_index].bleLoginCentralId.id, ShmCharger->gun_info[gun_index].bleLoginCentralId.id, ARRAY_SIZE(ShmCharger->gun_info[gun_index].bleLoginCentralId.id));
 					}
+					*/
+					
+					//===============================
+					// Query primary Out put current config
+					//===============================
+					if((previousCharger.gun_info[gun_index].outputCurrent.L1N_L12[0] != ShmCharger->gun_info[gun_index].outputCurrent.L1N_L12[0]) ||
+					   (previousCharger.gun_info[gun_index].outputCurrent.L2N_L23[0] != ShmCharger->gun_info[gun_index].outputCurrent.L2N_L23[0]) ||
+					   (previousCharger.gun_info[gun_index].outputCurrent.L3N_L31[0] != ShmCharger->gun_info[gun_index].outputCurrent.L3N_L31[0]))
+					{
+						DEBUG_INFO("===========================================\n");
+						DEBUG_INFO("==== Normal priority polling : Case 3 =====\n");
+						DEBUG_INFO("===========================================\n");
+						DEBUG_INFO("MCU-%d get output current L1: %f\n", gun_index, (float)ShmCharger->gun_info[gun_index].outputCurrent.L1N_L12[0]);
+						if(ShmSysConfigAndInfo->SysConfig.AcPhaseCount == 3)
+						{
+							DEBUG_INFO("MCU-%d get output current L2: %f\n", gun_index, (float)ShmCharger->gun_info[gun_index].outputCurrent.L2N_L23[0]);
+							DEBUG_INFO("MCU-%d get output current L3: %f\n", gun_index, (float)ShmCharger->gun_info[gun_index].outputCurrent.L3N_L31[0]);
+						}
+
+						previousCharger.gun_info[gun_index].outputCurrent.L1N_L12[0] = ShmCharger->gun_info[gun_index].outputCurrent.L1N_L12[0];
+						previousCharger.gun_info[gun_index].outputCurrent.L2N_L23[0] = ShmCharger->gun_info[gun_index].outputCurrent.L2N_L23[0];
+						previousCharger.gun_info[gun_index].outputCurrent.L3N_L31[0] = ShmCharger->gun_info[gun_index].outputCurrent.L3N_L31[0];
+					}
 				}
 			}
 			else
@@ -2444,6 +2503,7 @@ int main(void)
 						}
 						break;
 					case 3:
+						/*
 						//===============================
 						// Query present output current
 						//===============================
@@ -2476,6 +2536,7 @@ int main(void)
 							else
 								failCount[gun_index] = FAIL_SPEC_COMM;
 						}
+						*/
 						break;
 					case 5:
 						//===============================
@@ -2808,6 +2869,7 @@ int main(void)
 					switch(logIndex)
 					{
 						case 1:
+							/*
 							if((previousCharger.gun_info[gun_index].outputCurrent.L1N_L12[0] != ShmCharger->gun_info[gun_index].outputCurrent.L1N_L12[0]) ||
 							   (previousCharger.gun_info[gun_index].outputCurrent.L2N_L23[0] != ShmCharger->gun_info[gun_index].outputCurrent.L2N_L23[0]) ||
 							   (previousCharger.gun_info[gun_index].outputCurrent.L3N_L31[0] != ShmCharger->gun_info[gun_index].outputCurrent.L3N_L31[0]))
@@ -2826,6 +2888,7 @@ int main(void)
 								previousCharger.gun_info[gun_index].outputCurrent.L2N_L23[0] = ShmCharger->gun_info[gun_index].outputCurrent.L2N_L23[0];
 								previousCharger.gun_info[gun_index].outputCurrent.L3N_L31[0] = ShmCharger->gun_info[gun_index].outputCurrent.L3N_L31[0];
 							}
+							*/
 
 							break;
 						case 2:

+ 21 - 17
EVSE/Projects/AW-CCS/Apps/main.c

@@ -2297,9 +2297,11 @@ int LoadSysConfigAndInfo(struct SysConfigData *ptr)
 		if(ShmSysConfigAndInfo->SysConfig.ModelName[7+idx] == '7')
 			ShmCharger->isCcsEnable = ON;
 	}
-        #ifdef ENABLE_CCS
+
+	#ifdef ENABLE_CCS
 	ShmCharger->isCcsEnable = ON;
 	#endif
+
 	RatedCurrentParsing((char*)ShmSysConfigAndInfo->SysConfig.ModelName, &modelnameInfo);
 
 	return PASS;
@@ -2897,7 +2899,8 @@ float presentChargedEnergyTotal(unsigned char gun_index)
 
 	for(int idx=0;idx<ARRAY_SIZE(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].presentChargedEnergyPeriod);idx++)
 	{
-		result += ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].presentChargedEnergyPeriod[idx];
+		//result += ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].presentChargedEnergyPeriod[idx];
+		result += (((int)(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].presentChargedEnergyPeriod[idx]*1000))/(float)1000);
 	}
 
 	return result;
@@ -2964,7 +2967,7 @@ void get_firmware_version(unsigned char gun_index)
 	strcpy((char*)ShmSysConfigAndInfo->SysInfo.CsuPrimFwRev, ShmCharger->gun_info[gun_index].ver.Version_FW);
 
 	// Get CSU root file system version
-	sprintf((char*)ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev, "B0.60.00.0000.00");
+	sprintf((char*)ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev, "B0.61.00.0000.00");
 
 	// Get AC connector type from model name
 	for(uint8_t idx=0;idx<3;idx++)
@@ -4036,20 +4039,20 @@ void checkTask()
 	}
 
 	if(ShmCharger->isCcsEnable == ON)
-        {
-                if((system("pidof -s CsuComm > /dev/null") != 0))
-                {
-                        DEBUG_INFO("CsuComm not running, restart it.\n");
-                        system ("/root/CsuComm &");
-                }
- 
-                if((system("pidof -s SeccComm > /dev/null") != 0))
-                {
-                        sleep(3);
-                        DEBUG_INFO("SeccComm not running, restart it.\n");
-                        system ("/root/SeccComm &");
-                }
-        }
+	{
+		if((system("pidof -s CsuComm > /dev/null") != 0))
+		{
+				DEBUG_INFO("CsuComm not running, restart it.\n");
+				system ("/root/CsuComm &");
+		}
+
+		if((system("pidof -s SeccComm > /dev/null") != 0))
+		{
+				sleep(3);
+				DEBUG_INFO("SeccComm not running, restart it.\n");
+				system ("/root/SeccComm &");
+		}
+	}
 }
 
 void checkConnectionTimeout()
@@ -4392,6 +4395,7 @@ void checkChargingProfileLimit(uint8_t gun_index, uint8_t system_mode)
 				ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty.max_current = ((1 <= ShmCharger->gun_info[gun_index].targetCurrent) && (ShmCharger->gun_info[gun_index].targetCurrent <= 5)? 6:((ShmCharger->gun_info[gun_index].targetCurrent == 0)? 100:ShmCharger->gun_info[gun_index].targetCurrent));
 			}
 			ShmCharger->gun_info[gun_index].mcuFlag.isSetCpPwmDuty = YES;
+
 			break;
 		case SYS_MODE_CHARGING:
 		case SYS_MODE_TERMINATING:

+ 36 - 9
board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/common/autoboot.c

@@ -19,27 +19,27 @@ DECLARE_GLOBAL_DATA_PTR;
 
 #if defined(MT29F16G08_BCH16)
 	#if defined(MT41K256M16HA125E_303)
-		#define uboot_version "02.04"
+		#define uboot_version "02.06"
 	#elif defined(MT41K256M16HA125E_400)
-		#define uboot_version "02.03"
+		#define uboot_version "02.05"
 	#else
-		#define uboot_version "02.04"
+		#define uboot_version "02.06"
 	#endif
 #elif defined(MT29F8G08_BCH16)
 	#if defined(MT41K256M16HA125E_303)
-		#define uboot_version "03.04"
+		#define uboot_version "03.06"
 	#elif defined(MT41K256M16HA125E_400)
-		#define uboot_version "03.03"
+		#define uboot_version "03.05"
 	#else
-		#define uboot_version "03.04"
+		#define uboot_version "03.06"
 	#endif
 #else
 	#if defined(MT41K256M16HA125E_303)
-		#define uboot_version "01.04"
+		#define uboot_version "01.06"
 	#elif defined(MT41K256M16HA125E_400)
-		#define uboot_version "01.03"
+		#define uboot_version "01.05"
 	#else
-		#define uboot_version "01.04"
+		#define uboot_version "01.06"
 	#endif
 #endif
 
@@ -397,6 +397,33 @@ void autoboot_command(const char *s)
 	                memcpy(BufTmp+(0x00600000-4),&Chk,4);
                 	run_command_list("nand erase 0x09000000 0x00600000", -1, 0);
         	        run_command_list("nand write 0x80000000 0x09000000 0x00600000", -1, 0);
+
+			// Valid dts, kernel and rootfs upgrade flag
+			char nandbootStr[256];
+			uint32_t addrDts=0x00300000;
+			uint32_t addrKernel=0x00400000;
+			uint32_t addrRootfs=0x03000000;
+
+			memset(BufTmp,0,0x80000);
+			run_command_list("nand read 0x80000000 0x00180000 0x00080000", -1, 0);
+
+			if(*(BufTmp+0x7fffd) != 0xff)
+                        {
+                                addrDts=0x00380000;
+                        }
+
+			if(*(BufTmp+0x7fffe) != 0xff)
+                        {
+                                addrKernel=0x00e00000;
+                        }
+
+			if(*(BufTmp+0x7ffff) != 0xff)
+			{
+				addrRootfs=0x06000000;
+			}
+
+			sprintf(nandbootStr, "setenv nandboot 'nand read 0x80F80000 0x%08X 0x00080000;nand read 0x85200000 0x%08X 0x00A00000;nand read 0x81000000 0x%08X 0x03000000;bootz 0x85200000 - 0x80F80000'", addrDts, addrKernel, addrRootfs);
+			run_command_list(nandbootStr, -1, 0);
 	        }
 
 		run_command_list(s, -1, 0);