Browse Source

V0.2.0.13-MS 【重要】1、修复OTA更新未及时删除模组中升级文件(.bin/.zl),导致后期无法远程升级的bug; 2、修改BcuApp的存储量(增加SOH),并预留部分uint8、uint16和float量,同时修改将原有的CRC8改为CRC16,提升可靠性;3、添加BcuAppSaveInfo默认值,除SOH为100,其余值为0;4、增加SOH标定值下发链路,下发SOH精度0.1,真实值范围1-100;5、调试信息内容调整:删除三轴数据,增加BCU相关内容

BJQX-ZHENGCHAO\Zhengchao 1 year ago
parent
commit
9aa2e94df8

+ 1 - 1
Project_Settings/Debugger/S32K146_4G_Debug_FLASH_PNE.launch

@@ -214,7 +214,7 @@
 <listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
 <listEntry value="4"/>
 </listAttribute>
-<stringAttribute key="org.eclipse.dsf.launch.MEMORY_BLOCKS" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;memoryBlockExpressionList context=&quot;reserved-for-future-use&quot;&gt;&#13;&#10;&lt;gdbmemoryBlockExpression address=&quot;536806032&quot; label=&quot;RX_Buffer[UART_LPUART2]&quot;/&gt;&#13;&#10;&lt;gdbmemoryBlockExpression address=&quot;536823956&quot; label=&quot;GpsBufferGet&quot;/&gt;&#13;&#10;&lt;gdbmemoryBlockExpression address=&quot;255&quot; label=&quot;SocketId&quot;/&gt;&#13;&#10;&lt;/memoryBlockExpressionList&gt;&#13;&#10;"/>
+<stringAttribute key="org.eclipse.dsf.launch.MEMORY_BLOCKS" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;memoryBlockExpressionList context=&quot;reserved-for-future-use&quot;&gt;&#13;&#10;&lt;gdbmemoryBlockExpression address=&quot;335544320&quot; label=&quot;0x14000000&quot;/&gt;&#13;&#10;&lt;/memoryBlockExpressionList&gt;&#13;&#10;"/>
 <stringAttribute key="process_factory_id" value="org.eclipse.cdt.dsf.gdb.GdbProcessFactory"/>
 <stringAttribute key="saved_expressions&lt;seperator&gt;Unknown" value="0x1fffbe4b,0x1fffbd8d,0x1fffbe20,0x1fff0508,0x1fff0501,0x1fff0500,0x1fffc158,0x1fffc170,0x1fffc198,0x1fffc518,0x1fffc148,0x1fffc1e0,0x1fffc230,14000000,0x14000000"/>
 </launchConfiguration>

+ 4 - 0
code/BCU/BBox_Bcu.c

@@ -90,6 +90,9 @@ void BCUEEDataRead(void)
     //SOC
 	socd_pct_bcuSocEi = BcuSaveDataInfo.BcuAppSaveDataInfo.socd_pct_bcuSocE;
 	socd_pct_battSocEi = BcuSaveDataInfo.BcuAppSaveDataInfo.socd_pct_battSocE;
+
+	sohd_pct_bcuSoh = BcuSaveDataInfo.BcuAppSaveDataInfo.sohd_pct_bcuSohE;
+
     /*/SOH
 	sohd_flg_countEi = BcuSaveDataInfo.BcuAppSaveDataInfo.sohd_flg_countE;
 	sohd_Q_chrgEi = BcuSaveDataInfo.BcuAppSaveDataInfo.sohd_Q_chrgE;
@@ -146,6 +149,7 @@ void BCUEEDataSave(void)
     //SOC
 	BcuSaveDataInfo.BcuAppSaveDataInfo.socd_pct_bcuSocE = socd_pct_bcuSocEo;
 	BcuSaveDataInfo.BcuAppSaveDataInfo.socd_pct_battSocE = socd_pct_battSocEo;
+	BcuSaveDataInfo.BcuAppSaveDataInfo.sohd_pct_bcuSohE = sohd_pct_bcuSoh;
     /*/SOH
 	BcuSaveDataInfo.BcuAppSaveDataInfo.sohd_flg_countE = sohd_flg_countEo;
 	BcuSaveDataInfo.BcuAppSaveDataInfo.sohd_Q_chrgE = sohd_Q_chrgEo;

+ 16 - 2
code/app/AppGlobalVar.c

@@ -27,6 +27,19 @@ uint16 WebSitePort = 8712;
 #include "Eep_MemMap.h"
 AppConfigBody AppConfigInfo = {false, true, {defaultSn}, {0}};
 BcuSaveType BcuSaveDataInfo = {0};
+BcuAppSaveBody BcuAppSaveDataInfoDefaultValue =
+{
+		//uint8 1*16
+		0,23,01,01,0,0,0,0,
+		0,0,0,0,0,0,0,0,
+		//uint16 2*8
+		0,0,0,0,0,0,0,0,
+		//float 4*24
+		0,0,100,0,0,0,0,0,
+		0,0,0,0,0,0,0,0,
+		0,0,0,0,0,0,0,0
+};
+
 #define EEP_STOP_SEC_VAR_INIT_8_NO_CACHEABLE
 #include "Eep_MemMap.h"
 #else
@@ -41,7 +54,7 @@ BcuSaveType BcuSaveDataInfo = {0};
 #endif
 
 //*全局变量*//
-const uint32 AppSwVersion = 0x0002000C;
+const uint32 AppSwVersion = 0x0002000D;
 const uint8 DataModuleType = 0x02; // 01=NB,02-4G
 const uint16 HwVersion = 0x0102;
 const uint32 BlSwVersion = 0x00000002;
@@ -353,6 +366,7 @@ UINT32 BBox_TotalStaCharCapy = 0x00;				// 累计换电站充入Ah 数,,Re-0.1,O
 UINT32 BBox_Dq_Dv_MAX = 0x00;					//BBox计算dq/dv_MAX,Re-0.001,Off-0,Ah/10mV
 UINT32 BBox_Dq_Dv_MIN = 0x00;					//BBox计算dq/dv_MIN,Re-0.001,Off-0,Ah/10mV
 
-float BBox_SocCorrectionValue = 0x00;			//BBox的SOC修正量,平台下发,Re-0.1,0ff-0,1bit std for 0.1%
+float BBox_SocCorrectionValue = 0x00;			//BBox的SOC修正量,平台下发,Re-0.1,0ff-100,1bit std for 0.1% -100~100
+float BBox_SohCorrectionValue = 0x00;			//BBox的SOHC修正量,平台下发,Re-0.1,0ff-0,1bit std for 0.1% 1~100
 
 #endif

+ 9 - 2
code/app/AppGlobalVar.h

@@ -100,9 +100,10 @@ typedef struct _AppConfigType
 extern AppConfigBody AppConfigInfo;
 
 
+
 typedef struct _BcuSaveHader
 {
-	uint8 crc;
+	uint16 crc16;
 }BcuSaveHader;
 
 
@@ -128,6 +129,7 @@ typedef struct _BcuAppSaveType
 	//float 4*24=96byte
 	float socd_pct_bcuSocE;
 	float socd_pct_battSocE;
+	float sohd_pct_bcuSohE;
 
 	float damd_Q_totalChrgCpE;
 	float damd_E_totalChrgEngE;
@@ -139,7 +141,7 @@ typedef struct _BcuAppSaveType
 	float damd_E_totalVehChrgEngE;
 	float damd_Q_totalSatChrgCpE;
 	float damd_E_totalSatChrgEngE;
-	float reU32[12];
+	float reU32[11];
 } BcuAppSaveBody;
 
 typedef struct _BcuSaveType
@@ -148,7 +150,10 @@ typedef struct _BcuSaveType
 	BcuAppSaveBody BcuAppSaveDataInfo;
 }BcuSaveType;
 
+#define BCU_SAVE_ADDR  400
+
 extern BcuSaveType BcuSaveDataInfo;
+extern BcuAppSaveBody BcuAppSaveDataInfoDefaultValue;
 
 #ifdef APP_CAN_ENABLE
 extern uint8 vehicleStatus;
@@ -382,5 +387,7 @@ extern UINT32 BBox_Dq_Dv_MAX;
 extern UINT32 BBox_Dq_Dv_MIN;
 
 extern float BBox_SocCorrectionValue;
+extern float BBox_SohCorrectionValue;
+
 
 #endif /* APPGLOBALVAR_H_ */

+ 7 - 7
code/app/AppTaskMain.c

@@ -22,12 +22,12 @@ void MainTask(void *pvParameters)
 
 
 //	HAL_EEP_Read(400, (uint8 *)&BcuSaveDataInfo, sizeof(BcuSaveDataInfo));
-//	if (*(uint8 *)(eppromAddStart + 400) == 0xff || BcuSaveDataInfo.BcuAppSaveDataInfo.CRC != bcc_chk(&(BcuAppSaveDataInfo.CRC)+1,sizeof(BcuAppSaveDataInfo)-1));
+//	if (*(uint8 *)(eppromAddStart + 400) == 0xff || BcuSaveDataInfo.BcuAppSaveDataInfo.CRC != crc_chk(&(BcuAppSaveDataInfo.CRC)+1,sizeof(BcuAppSaveDataInfo)-1));
 //	{
 //		memset(&BcuAppSaveDataInfo,0,sizeof(BcuAppSaveBody));
-//		BcuAppSaveDataInfo.CRC = bcc_chk(&(BcuAppSaveDataInfo.CRC)+1,sizeof(BcuAppSaveDataInfo)-1);
+//		BcuAppSaveDataInfo.CRC = crc_chk(&(BcuAppSaveDataInfo.CRC)+1,sizeof(BcuAppSaveDataInfo)-1);
 //		BcuAppSaveDataInfo.bcuSaveFlg = false;
-//		HAL_EEP_Write(400, (uint8 *)&BcuAppSaveDataInfo, sizeof(BcuAppSaveDataInfo));
+//		HAL_EEP_Write(BCU_SAVE_ADDR, (uint8 *)&BcuAppSaveDataInfo, sizeof(BcuAppSaveDataInfo));
 //	}
 
 	while (1)
@@ -49,8 +49,8 @@ void MainTask(void *pvParameters)
 		if(BcuSaveDataInfo.BcuAppSaveDataInfo.bcuSaveFlg)
 		{
 			BcuSaveDataInfo.BcuAppSaveDataInfo.bcuSaveFlg = false;
-			BcuSaveDataInfo.header.crc = bcc_chk(&(BcuSaveDataInfo.BcuAppSaveDataInfo),sizeof(BcuSaveDataInfo.BcuAppSaveDataInfo));
-			HAL_EEP_Write(400, (uint8 *)&BcuSaveDataInfo, sizeof(BcuSaveDataInfo));
+			BcuSaveDataInfo.header.crc16 = crc_chk(&(BcuSaveDataInfo.BcuAppSaveDataInfo),sizeof(BcuSaveDataInfo.BcuAppSaveDataInfo));
+			HAL_EEP_Write(BCU_SAVE_ADDR, (uint8 *)&BcuSaveDataInfo, sizeof(BcuSaveDataInfo));
 		}
 		if (Fota_update_flag==1)
 		{
@@ -60,8 +60,8 @@ void MainTask(void *pvParameters)
 			HAL_EEP_Write(200, (uint8 *)&AppConfigInfo, sizeof(AppConfigInfo));
 
 			BcuSaveDataInfo.BcuAppSaveDataInfo.bcuSaveFlg = false;
-			BcuSaveDataInfo.header.crc = bcc_chk(&(BcuSaveDataInfo.BcuAppSaveDataInfo),sizeof(BcuSaveDataInfo.BcuAppSaveDataInfo));
-			HAL_EEP_Write(400, (uint8 *)&BcuSaveDataInfo, sizeof(BcuSaveDataInfo));
+			BcuSaveDataInfo.header.crc16 = crc_chk(&(BcuSaveDataInfo.BcuAppSaveDataInfo),sizeof(BcuSaveDataInfo.BcuAppSaveDataInfo));
+			HAL_EEP_Write(BCU_SAVE_ADDR, (uint8 *)&BcuSaveDataInfo, sizeof(BcuSaveDataInfo));
 			SystemSoftwareReset();
 		}
 #ifndef SEGGER_RTT_PRINTF

+ 80 - 24
code/app/AppTaskUart1.c

@@ -1022,24 +1022,32 @@ void TcpDataEncode(uint8 DataIdx,uint32 *PtrSendAddr, uint16 *SendLen)
 		DebugMsgtoTcpType DebugMsgInfo;
 		UINT16 DataLen = 0;
 		UINT16 BufferLen = 0;
-		sprintf((char *)rbuf, "{%.2f,%.2f,%.2f,%.2f,%.2f;\
-								%.2f,%.2f,%.2f,%.2f,%.2f,}\
-								{%.2f,%.2f,%.2f,%.2f,%.2f;\
-								%.2f,%.2f,%.2f,%.2f,%.2f,}\
-								{%.2f,%.2f,%.2f,%.2f,%.2f;\
-								%.2f,%.2f,%.2f,%.2f,%.2f,},%s,%d,\
-								{%.2f,%.2f,%.2f,%.2f,\
-								%d,%d,%d,%d,%d,%d}",
-				returnFreq[0][0], returnFreq[0][1], returnFreq[0][2], returnFreq[0][3], returnFreq[0][4],
-				returnP[0][0], returnP[0][1], returnP[0][2], returnP[0][3], returnP[0][4],
-
-				returnFreq[1][0], returnFreq[1][1], returnFreq[1][2], returnFreq[1][3], returnFreq[1][4],
-				returnP[1][0], returnP[1][1], returnP[1][2], returnP[1][3], returnP[1][4],
-
-				returnFreq[2][0], returnFreq[2][1], returnFreq[2][2], returnFreq[2][3], returnFreq[2][4],
-				returnP[2][0], returnP[2][1], returnP[2][2], returnP[2][3], returnP[2][4],tmp,DeviceErrNum,
+//		sprintf((char *)rbuf, "{%.2f,%.2f,%.2f,%.2f,%.2f;\
+//										%.2f,%.2f,%.2f,%.2f,%.2f,}\
+//										{%.2f,%.2f,%.2f,%.2f,%.2f;\
+//										%.2f,%.2f,%.2f,%.2f,%.2f,}\
+//										{%.2f,%.2f,%.2f,%.2f,%.2f;\
+//										%.2f,%.2f,%.2f,%.2f,%.2f,},%s,%d,\
+//										{%.2f,%.2f,%.2f,%.2f,\
+//										%d,%d,%d,%d,%d,%d}",
+//						returnFreq[0][0], returnFreq[0][1], returnFreq[0][2], returnFreq[0][3], returnFreq[0][4],
+//						returnP[0][0], returnP[0][1], returnP[0][2], returnP[0][3], returnP[0][4],
+//
+//						returnFreq[1][0], returnFreq[1][1], returnFreq[1][2], returnFreq[1][3], returnFreq[1][4],
+//						returnP[1][0], returnP[1][1], returnP[1][2], returnP[1][3], returnP[1][4],
+//
+//						returnFreq[2][0], returnFreq[2][1], returnFreq[2][2], returnFreq[2][3], returnFreq[2][4],
+//						returnP[2][0], returnP[2][1], returnP[2][2], returnP[2][3], returnP[2][4],tmp,DeviceErrNum,
+//						socd_pct_ahSoc,socd_pct_battSoc,socd_pct_bcuSoc,socd_pct_ekfSoc,
+//						BBox_TotalCharEngy,BBox_TotalDischarEngy,BBox_TotalBackCharEngy,BBox_TotalCharCapy,BBox_TotalDischarCapy,BBox_TotalBackCharCapy);
+		sprintf((char *)rbuf, "%s,%d,\
+								{%.2f,%.2f,%.2f,%.2f},\
+								{%d,%d,%d,%d,%d,%d},\
+								{%.3f,%.3f,%.3f,%.1f,%d,%d}",
+				tmp,DeviceErrNum,
 				socd_pct_ahSoc,socd_pct_battSoc,socd_pct_bcuSoc,socd_pct_ekfSoc,
-				BBox_TotalCharEngy,BBox_TotalDischarEngy,BBox_TotalBackCharEngy,BBox_TotalCharCapy,BBox_TotalDischarCapy,BBox_TotalBackCharCapy);
+				BBox_TotalCharEngy,BBox_TotalDischarEngy,BBox_TotalBackCharEngy,BBox_TotalCharCapy,BBox_TotalDischarCapy,BBox_TotalBackCharCapy,
+				ihd_V_cellUMax,ihd_V_cellUMin,ihd_V_cellUAvrg,ihd_I_battCurr_T2,BMS_PackSOC,rtev_flg_EESt[3]);
 
 		BufferLen = strlen((const char *)rbuf);
 		*SendLen = BufferLen + sizeof(DebugMsgInfo);
@@ -1745,6 +1753,42 @@ uint16 tcpUdsFunc(uint8 *Ptr, uint8 *AnsPtr)
 						return AnsLength;
 						break;
 					}
+					case 0x0202:  //soh correction did
+					{
+
+						if(udsDataLen == 2)
+						{
+							float sohCorrectionValue = (float)((float)((DataBuffer[0]<<8 | DataBuffer[1])&0xFFFF)*0.1);
+							if(sohCorrectionValue > 0 && sohCorrectionValue<100)  //有效修正
+							{
+								BBox_SohCorrectionValue = sohCorrectionValue;
+								sohCorrectionValue = 0;
+								retLength = tcpUdsAnsMsgEncode(true,udsType_SID,DIDBuffer,0x00,udsAnsBuffer);
+							}
+							else
+							{
+								sohCorrectionValue = 0;
+								retLength = tcpUdsAnsMsgEncode(false,udsType_SID,DIDBuffer,0x13,udsAnsBuffer);
+							}
+						}
+						else
+						{
+							retLength = tcpUdsAnsMsgEncode(false,udsType_SID,DIDBuffer,0x13,udsAnsBuffer);
+						}
+
+						*(AnsPtr + 3) = 0x01;
+						memcpy((AnsPtr + 4), (Ptr + 4), BATT_SN_LEN);
+						*(AnsPtr + 21) = TCP_ENCPT_DISABLE;
+						*(AnsPtr + 22) = 0x00;
+						*(AnsPtr + 23) = 0x06 + retLength + 1;
+						memcpy((AnsPtr + 24), (Ptr + 24), 6);
+						*(AnsPtr + 30) = retLength;
+						memcpy((AnsPtr + 31),udsAnsBuffer,retLength);
+						*(AnsPtr + 31 + retLength) = bcc_chk(AnsPtr, 31 + retLength);
+						AnsLength = 32 + retLength;
+						return AnsLength;
+						break;
+					}
 					default:
 						retLength = tcpUdsAnsMsgEncode(false,udsType_SID,DIDBuffer,0x31,udsAnsBuffer);
 
@@ -1906,18 +1950,30 @@ void Fota_Ftp(uint8 *dataPtrIn)
 		case 1: // login
 		{
 			memset(ATSendDataBuffer, 0x00, sizeof(ATSendDataBuffer));
-			sprintf(ATSendDataBuffer, "AT+CFTPSLOGIN=\"%s\",%s,\"%s\",\"%s\",0\r\n", ftpServerIpPtr, ftpServerPort, accountPtr, passwordPtr);
-			UART_Send_Data(UART_LPUART1, ATSendDataBuffer, mstrlen(ATSendDataBuffer), pdMS_TO_TICKS(100));
-			recvRet = AtcmdDelayRecvFunc(UART_LPUART1, (char *)("+CFTPSLOGIN: 0"), 30000);
-			if (recvRet == 0)
-			{
-				ftp_process++;
+			sprintf(ATSendDataBuffer, "AT+FSDEL=*.*\r\n");
+			recvRet = UART_Query_Data(UART_LPUART1, UART_LPUART1, ATSendDataBuffer, mstrlen(ATSendDataBuffer), UartRecvBuffer, &ReadLen, pdMS_TO_TICKS(5000));
+			if(recvRet == E_OK)
+			{
+				memset(ATSendDataBuffer, 0x00, sizeof(ATSendDataBuffer));
+				sprintf(ATSendDataBuffer, "AT+CFTPSLOGIN=\"%s\",%s,\"%s\",\"%s\",0\r\n", ftpServerIpPtr, ftpServerPort, accountPtr, passwordPtr);
+				UART_Send_Data(UART_LPUART1, ATSendDataBuffer, mstrlen(ATSendDataBuffer), pdMS_TO_TICKS(100));
+				recvRet = AtcmdDelayRecvFunc(UART_LPUART1, (char *)("+CFTPSLOGIN: 0"), 30000);
+				if (recvRet == 0)
+				{
+					ftp_process++;
+				}
+				else
+				{
+					DeviceErrNum = 11;
+					ftp_EndFlg = 1;
+				}
 			}
 			else
 			{
-				DeviceErrNum = 11;
+				DeviceErrNum = 9;
 				ftp_EndFlg = 1;
 			}
+
 			break;
 		}
 		case 2: // transmit bin file from server to module

+ 13 - 7
code/hal/hal_adapter.c

@@ -1262,13 +1262,13 @@ void readConfigAndDataFromEEPROM(void)
 	}
 
 	//read bcu data
-	HAL_EEP_Read(400, (uint8 *)&BcuSaveDataInfo, sizeof(BcuSaveDataInfo));
-	if(BcuSaveDataInfo.header.crc != bcc_chk(&(BcuSaveDataInfo.BcuAppSaveDataInfo),sizeof(BcuSaveDataInfo.BcuAppSaveDataInfo)))
+	HAL_EEP_Read(BCU_SAVE_ADDR, (uint8 *)&BcuSaveDataInfo, sizeof(BcuSaveDataInfo));
+	if(BcuSaveDataInfo.header.crc16 != crc_chk(&(BcuSaveDataInfo.BcuAppSaveDataInfo),sizeof(BcuSaveDataInfo.BcuAppSaveDataInfo)))
 	{
-//		memset(&BcuSaveDataInfo,0,sizeof(BcuSaveType));
+		memcpy(&BcuSaveDataInfo.BcuAppSaveDataInfo,&BcuAppSaveDataInfoDefaultValue,sizeof(BcuSaveDataInfo.BcuAppSaveDataInfo));
 //		BcuSaveDataInfo.BcuAppSaveDataInfo.bcuSaveFlg = false;
-//		BcuSaveDataInfo.header.crc = bcc_chk(&(BcuSaveDataInfo.BcuAppSaveDataInfo),sizeof(BcuSaveDataInfo.BcuAppSaveDataInfo));
-//		HAL_EEP_Write(400, (uint8 *)&BcuSaveDataInfo, sizeof(BcuSaveDataInfo));
+		BcuSaveDataInfo.header.crc16 = crc_chk(&(BcuSaveDataInfo.BcuAppSaveDataInfo),sizeof(BcuSaveDataInfo.BcuAppSaveDataInfo));
+		HAL_EEP_Write(BCU_SAVE_ADDR, (uint8 *)&BcuSaveDataInfo, sizeof(BcuSaveDataInfo));
 		rtev_flg_EESt[0] = 1;
 		rtev_flg_EESt[1] = 1;
 		rtev_flg_EESt[2] = 1;
@@ -1284,7 +1284,13 @@ void IH_Data_Update(void)
 	ihd_pct_socCor = BBox_SocCorrectionValue;
 	BBox_SocCorrectionValue = 0;  //clear the SOC correction value from cloud which only available once
 
-	sohd_pct_bcuSoh = (real32_T)(BMS_PackSOH*0.4);
+	if(BBox_SohCorrectionValue != 0)
+	{
+		sohd_pct_bcuSoh = BBox_SohCorrectionValue;
+		BBox_SohCorrectionValue = 0;
+	}
+
+
 
 	if(BMS_MaxCellVolt != 0 && BMS_MaxCellVolt != 0xFFFF)
 	{
@@ -1318,7 +1324,7 @@ void OH_Data_Update(void)
 	//socd_pct_battSoc;			//电池SOC
 	//socd_pct_bcuSoc;				//显示SOC
 	BBox_PackSOC 			= (uint8)(socd_pct_ahSoc /0.4);		//安时SOC
-	BBox_PackSOH 			= (uint8)(BMS_PackSOH /25 *10);
+	BBox_PackSOH 			= (uint8)(sohd_pct_bcuSoh);		//Soh
 	BBox_Dq_Dv_MIN 			= (uint32)(socd_Q_dMin * 1000);					//dQ/dV
 	BBox_Dq_Dv_MAX 			= (uint32)(socd_Q_dMax * 1000);					//dQ/dV