Procházet zdrojové kódy

2020-05-11 / Eason Yang
1.Change : main.c
Reason :
1.Rename version
2.Added copy UserId into StartUserId for OCPP IdTag
3.Fixed Meter value save into define.h PowerConsumption for OCPP MeterStart and MetetStop
4.Added CRC32() method.
5.Fixed Bluetooth stop charging logic.
Version : B0.25.XX.XXXX.XX

8009 před 4 roky
rodič
revize
61d9de1629

+ 50 - 33
EVSE/Projects/BYTON-GB/Apps/main.c

@@ -1178,7 +1178,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, "D0.24.60.XXXX.B0");
+	sprintf((char*)ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev, "B0.25.00.0000.00");
 
 	// Get AC connector type from model name
 	for(uint8_t idx=0;idx<3;idx++)
@@ -1482,9 +1482,30 @@ int GetCardSerialNumber()
 }
 
 //===============================================
-//	Check PH RFID
+// Calculation CRC32 function
 //===============================================
+unsigned int CRC32(uint8_t const * p_data, uint32_t size)
+{
+	uint32_t crc;
+	crc = 0xFFFFFFFF;
+	for (uint32_t i = 0; i < size; i++)
+	{
+		if( (i<0x22) || (i>0x2f))
+		{
+			crc = crc ^ p_data[i];
+			for (uint32_t j = 8; j > 0; j--)
+			{
+				crc = (crc >> 1) ^ (0xEDB88320U & ((crc & 1) ? 0xFFFFFFFF : 0));
+			}
+		}
+	}
 
+	return ~crc;
+}
+
+//===============================================
+//	Check PH RFID
+//===============================================
 int isValidPHCard()
 {
 	int isSuccess = FAIL;
@@ -1515,7 +1536,7 @@ int isValidPHCard()
 		buf = malloc(25 + sn_len);
 		memcpy(buf, ShmSysConfigAndInfo->SysConfig.SystemId, 25);
 		memcpy(&buf[25], rfid.currentCard, sn_len);
-		crc_result = crc32(buf, 25 + sn_len);
+		crc_result = CRC32(buf, 25 + sn_len);
 		
 		if(((data_read[0] << 8) | (data_read[1] << 0) | (data_read[2] << 24) | (data_read[3] << 16)) == ~crc_result)
 		{
@@ -1527,13 +1548,10 @@ int isValidPHCard()
 			DEBUG_INFO("PH logic checked fail.\r\n");
 		}	
 		
-		free(buf);		
-		
+		free(buf);	
 	}
 	else
-	{
-			
-	}
+	{}
 
 	return isSuccess;
 }
@@ -2461,6 +2479,7 @@ int main(void)
 									break;
 							}
 						}
+						
 						ShmCharger->gun_info[gun_index].mcuFlag.isSetCpPwmDuty = YES;
 					}
 					
@@ -2502,10 +2521,10 @@ int main(void)
 											setChargerMode(gun_index, SYS_MODE_IDLE);
 											
 										}
+										
 										sethaltCard(rfidFd,MODULE_EWT);
 										ShmCharger->gun_info[gun_index].rfidReq = OFF;
 										ShmOCPP16Data->SpMsg.bits.AuthorizeConf = OFF;
-										
 									}
 									break;
 								case START_METHOD_BACKEND:
@@ -2517,7 +2536,6 @@ int main(void)
 									ShmCharger->gun_info[gun_index].isHandshakeTimeOn = ON;
 									break;
 							}
-							
 						}
 					}
 					else
@@ -2533,19 +2551,18 @@ int main(void)
 						{
 							setChargerMode(gun_index, SYS_MODE_PREPARING);
 						}
-
-
-					// Use RFID card to stop handshaking
-					if((ShmCharger->gun_info[gun_index].rfidReq == ON) && isMatchStartUser(gun_index))
-					{
-						DEBUG_INFO("Use RFID card to stop handshaking.\r\n");
-						setChargerMode(gun_index, SYS_MODE_IDLE);
-						sethaltCard(rfidFd,MODULE_EWT);
-					}
-					else
-					{
-						ShmCharger->gun_info[gun_index].rfidReq = OFF;
-					}
+						
+						// Use RFID card to stop handshaking
+						if((ShmCharger->gun_info[gun_index].rfidReq == ON) && isMatchStartUser(gun_index))
+						{
+							DEBUG_INFO("Use RFID card to stop handshaking.\r\n");
+							setChargerMode(gun_index, SYS_MODE_IDLE);
+							sethaltCard(rfidFd,MODULE_EWT);
+						}
+						else
+						{
+							ShmCharger->gun_info[gun_index].rfidReq = OFF;
+						}
 						
 						if(DiffTimebWithNow(startTime[gun_index][TMR_IDX_HANDSHAKING]) > ShmCharger->timeoutSpec.Present_Timeout_Spec)
 						{
@@ -2554,8 +2571,8 @@ int main(void)
 							DEBUG_INFO("Handshaking timeout...");
 							setChargerMode(gun_index, SYS_MODE_IDLE);
 						}	
-	
-					}					
+					}
+					
 					break;
 				case SYS_MODE_PREPARING:
 					if(isModeChange(gun_index))
@@ -2589,8 +2606,8 @@ int main(void)
 						ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedEnergy = 0;
 						getDateTimeString((char*)ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartDateTime);
 						ShmCharger->gun_info[gun_index].powerConsumption.power_consumption_at_start = ShmCharger->gun_info[gun_index].powerConsumption.power_consumption;
-						ShmOCPP16Data->StartTransaction[gun_index].MeterStart = (ShmCharger->gun_info[gun_index].powerConsumption.power_consumption/100);
-						//memcpy((char*)ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartUserId, ShmSysConfigAndInfo->SysConfig.UserId, ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.UserId));
+						ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PowerConsumption = (ShmCharger->gun_info[gun_index].powerConsumption.power_consumption/100);
+						memcpy((char*)ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartUserId, ShmSysConfigAndInfo->SysConfig.UserId, ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.UserId));
 
 						memcpy((char*)ShmOCPP16Data->StartTransaction[gun_index].IdTag, (char*)ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartUserId, ARRAY_SIZE(ShmOCPP16Data->StartTransaction[gun_index].IdTag));
 						ShmOCPP16Data->CpMsg.bits[gun_index].StartTransactionReq = ON;
@@ -2620,7 +2637,7 @@ int main(void)
 					else
 					{
 						setLedMotion(gun_index,LED_ACTION_CHARGING);
-						ShmOCPP16Data->StopTransaction[gun_index].MeterStop = (ShmCharger->gun_info[gun_index].powerConsumption.power_consumption/100);
+						ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PowerConsumption = (ShmCharger->gun_info[gun_index].powerConsumption.power_consumption/100);
 						ftime(&endChargingTime[gun_index]);
 						ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedDuration = DiffTimeb(startChargingTime[gun_index], endChargingTime[gun_index])/1000;
 						ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedEnergy = ((float)(ShmCharger->gun_info[gun_index].powerConsumption.power_consumption - ShmCharger->gun_info[gun_index].powerConsumption.power_consumption_at_start))/100;
@@ -2921,10 +2938,10 @@ int main(void)
 						}
 						else
 						{
-							if((ShmOCPP16Data->SpMsg.bits.AuthorizeConf ||
-							  (ShmSysConfigAndInfo->SysConfig.AuthorisationMode == AUTH_MODE_DISABLE) ||
-							  !ShmOCPP16Data->OcppConnStatus ) && (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartMethod != START_METHOD_BLE) ||
-						          (!ShmOCPP16Data->OcppConnStatus&&(ShmSysConfigAndInfo->SysConfig.OfflinePolicy == OFF_POLICY_FREE)))
+							if(((ShmOCPP16Data->SpMsg.bits.AuthorizeConf) ||
+							   (ShmSysConfigAndInfo->SysConfig.AuthorisationMode == AUTH_MODE_DISABLE) ||
+							   (!ShmOCPP16Data->OcppConnStatus&&(ShmSysConfigAndInfo->SysConfig.OfflinePolicy == OFF_POLICY_FREE))) && 
+							   (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartMethod != START_METHOD_BLE))   
 							{
 								if((strcmp((char*)ShmOCPP16Data->Authorize.ResponseIdTagInfo.Status, "Accepted")==0) ||
 								   (ShmSysConfigAndInfo->SysConfig.AuthorisationMode == AUTH_MODE_DISABLE) ||
@@ -3029,7 +3046,7 @@ int main(void)
 					DEBUG_INFO("Gun-%d : StopReason [ %s ]...\r\n.",gun_index,ShmOCPP16Data->StopTransaction[gun_index].StopReason);
 
 					memcpy((char*)ShmOCPP16Data->StopTransaction[gun_index].IdTag, (char*)ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartUserId, ARRAY_SIZE(ShmOCPP16Data->StopTransaction[gun_index].IdTag));
-					ShmOCPP16Data->StopTransaction[gun_index].MeterStop = (ShmCharger->gun_info[gun_index].powerConsumption.power_consumption/100);
+					ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PowerConsumption = (ShmCharger->gun_info[gun_index].powerConsumption.power_consumption/100);
 					ShmOCPP16Data->CpMsg.bits[gun_index].StopTransactionReq = ON;
 
 					ShmCharger->gun_info[gun_index].rfidReq = OFF;

binární
EVSE/Projects/BYTON-GB/Images/FactoryDefaultConfig.bin


binární
EVSE/Projects/BYTON-GB/Images/MLO


binární
EVSE/Projects/BYTON-GB/Images/ramdisk.gz


binární
EVSE/Projects/BYTON-GB/Images/u-boot.img


binární
EVSE/Projects/BYTON-GB/Images/zImage


+ 1 - 5
board-support/linux-4.9.59+gitAUTOINC+a75d8e9305-ga75d8e9305/.version

@@ -1,5 +1 @@
-<<<<<<< HEAD
-6
-=======
-5
->>>>>>> 2a673e9659741b0debbecf3568616850e1f27a7c
+1

+ 3 - 4
board-support/linux-4.9.59+gitAUTOINC+a75d8e9305-ga75d8e9305/arch/arm/boot/dts/.am335x-evm.dtb.dts.tmp

@@ -1444,7 +1444,6 @@
                 compatible = "nxp,pcf85063";
                 reg = <0x51>;
         };
-
 };
 
 &usb {
@@ -1479,7 +1478,7 @@
 &elm {
  status = "okay";
 };
-# 403 "arch/arm/boot/dts/am335x-evm.dts"
+# 402 "arch/arm/boot/dts/am335x-evm.dts"
 &gpmc {
  status = "okay";
  pinctrl-names = "default", "sleep";
@@ -1665,7 +1664,7 @@
   };
  };
 };
-# 509 "arch/arm/boot/dts/am335x-evm.dts" 2
+# 508 "arch/arm/boot/dts/am335x-evm.dts" 2
 
 &tps {
  vcc1-supply = <&vbat>;
@@ -1764,7 +1763,7 @@
   phy-mode = "mii";
 
 };
-# 615 "arch/arm/boot/dts/am335x-evm.dts"
+# 614 "arch/arm/boot/dts/am335x-evm.dts"
 &tscadc {
  status = "okay";
 

+ 0 - 1
board-support/linux-4.9.59+gitAUTOINC+a75d8e9305-ga75d8e9305/arch/arm/boot/dts/am335x-evm.dts

@@ -344,7 +344,6 @@
                 compatible = "nxp,pcf85063";
                 reg = <0x51>;
         };
-
 };
 #endif
 &usb {