Procházet zdrojové kódy

修复0x96报文无法正常上传的bug,增加测试数据

BJQX-ZHENGCHAO\Zhengchao před 1 rokem
rodič
revize
1a5a4d759c
5 změnil soubory, kde provedl 42 přidání a 16 odebrání
  1. 2 2
      code/app/AppGlobalVar.c
  2. 1 1
      code/app/AppTaskCan.c
  3. 36 10
      code/app/AppTaskUart1.c
  4. 2 2
      code/hal/hal_adapter.c
  5. 1 1
      code/main.c

+ 2 - 2
code/app/AppGlobalVar.c

@@ -18,14 +18,14 @@
 
 #define defaultSn "ZLTEST00000000002"
 
-#define APP_RELEASE
+//#define APP_RELEASE
 
 #ifdef APP_RELEASE
 const char WebSiteName[] = "\"iotp.fast-fun.cn\"";
 uint16 WebSitePort = 8712;
 #define EEP_START_SEC_VAR_INIT_8_NO_CACHEABLE
 #include "Eep_MemMap.h"
-AppConfigBody AppConfigInfo = {false, true, {defaultSn}, {0}};
+AppConfigBody AppConfigInfo = {false, false, {defaultSn}, {0}};
 BcuAppSaveBody BcuAppSaveDataInfo = {0};
 #define EEP_STOP_SEC_VAR_INIT_8_NO_CACHEABLE
 #include "Eep_MemMap.h"

+ 1 - 1
code/app/AppTaskCan.c

@@ -934,7 +934,7 @@ void BcuRxDiagnose(void) // 100ms调用一次
 		{
 			BcuRxShortError[i] = 0;
 			BcuRxLongError[i] = 1;
-			BcuRxMsgSetInvalidValue(BcuInTable[i]);
+//			BcuRxMsgSetInvalidValue(BcuInTable[i]);
 			BcuRxErrorCounter[i] = 0;
 		}
 		else if (BcuRxErrorCounter[i] == 0xFF)

+ 36 - 10
code/app/AppTaskUart1.c

@@ -268,8 +268,8 @@ static void TcpDataSendFeqHandFunc(uint8* DataIdx)
 		if(timerDelayFlag == 0)
 		{
 			TcpDataFeq.BattHighFeqCnt[1] = 10;
-			TcpDataFeq.BattAlgmMsgFeqCnt[1] = 10;
 		}
+		TcpDataFeq.BattAlgmMsgFeqCnt[1] = 10;
 	}
 	else if(BMS_Mode==2)//放电中
 	{
@@ -279,8 +279,8 @@ static void TcpDataSendFeqHandFunc(uint8* DataIdx)
 		if(timerDelayFlag == 0)
 		{
 			TcpDataFeq.BattHighFeqCnt[1] = 30;
-			TcpDataFeq.BattAlgmMsgFeqCnt[1] = 10;
 		}
+		TcpDataFeq.BattAlgmMsgFeqCnt[1] = 10;
 	}
 	else//没有上高压状态
 	{
@@ -290,11 +290,13 @@ static void TcpDataSendFeqHandFunc(uint8* DataIdx)
 		if(timerDelayFlag == 0)
 		{
 			TcpDataFeq.BattHighFeqCnt[1] = 60;
-			TcpDataFeq.BattAlgmMsgFeqCnt[1] = 60;
 		}
+		TcpDataFeq.BattAlgmMsgFeqCnt[1] = 60;
 	}
+
+
 	TcpDataFeq.DebugMsgFeqCnt[1] = TcpDataFeq.TrkBattFeqCnt[1];
-	if(BMS_PackSOC <=100 && (BMS_PackCurr>=10000-50 && BMS_PackCurr <=10000+50)) //pack soc(0.4,0) ≤ 25%  and the abs value of pack current(0.1,-10000) ≤ 5A
+	if(BMS_PackSOC * 0.4 <= 25 && (BMS_PackCurr>=10000-50 && BMS_PackCurr <=10000+50)) //pack soc(0.4,0) ≤ 25%  and the abs value of pack current(0.1,-10000) ≤ 5A
 	{
 		if(timerDelayFlag == 0)
 		{
@@ -473,10 +475,10 @@ sint8 TcpConnectFunc(sint8 *ConnectId)
 			uint8 AtCmdSendTotalLen = 0;
 			*ConnectId = 0;
 			/*IP测试更改*/
-			//			char *ATCmdSend = (char *)("\"120.26.68.165\"");
-			//			memset(WebSiteIp,0x00,sizeof(WebSiteIp));
-			//			memcpy(WebSiteIp ,ATCmdSend,strlen(ATCmdSend));
-			//			WebSitePort = 14401;
+//						char *ATCmdSend = (char *)("\"120.26.68.165\"");
+//						memset(WebSiteIp,0x00,sizeof(WebSiteIp));
+//						memcpy(WebSiteIp ,ATCmdSend,strlen(ATCmdSend));
+//						WebSitePort = 15964;
 			/**/
 			sprintf(AtCmdSend, "AT+CIPOPEN=%d,\"TCP\",%s,%d\r\n", *ConnectId, WebSiteIp, WebSitePort); // 此处需要优化
 			AtCmdSendTotalLen = mstrlen(AtCmdSend);
@@ -1300,6 +1302,14 @@ void TcpDataEncode(uint8 DataIdx,uint32 *PtrSendAddr, uint16 *SendLen)
 		*(SendBuffer + 0x22) = (UTC8TimeTcp.hour & 0xFF);		   // uint8	hour
 		*(SendBuffer + 0x23) = (UTC8TimeTcp.minute & 0xFF);		   // uint8	minute
 		*(SendBuffer + 0x24) = (UTC8TimeTcp.second & 0xFF);		   // uint8	second
+
+		BMS_BattVolt = 5678;
+		BMS_PackCurr = 35+10000;
+		BMS_MaxCellVolt = 4235;
+		BMS_MinCellVolt = 4123;
+		BMS_MaxCellTemp = 25+50;
+		BMS_MinCellTemp = 20+50;
+
 		*(SendBuffer + 0x25) = (BMS_BattVolt >> 8) & 0xFF;	   		// 电池包总电压
 		*(SendBuffer + 0x26) = (BMS_BattVolt & 0xFF);
 		*(SendBuffer + 0x27) = ((BMS_PackCurr >> 8) & 0xFF); 		// uint16	电池包总电流,充电为负值,放电为正值 精度_0.1,偏移量_-1000,单位_A
@@ -1308,8 +1318,8 @@ void TcpDataEncode(uint8 DataIdx,uint32 *PtrSendAddr, uint16 *SendLen)
 		*(SendBuffer + 0x2A) = (BMS_MaxCellVolt & 0xFF);
 		*(SendBuffer + 0x2B) = ((BMS_MinCellVolt >> 8) & 0xFF); 	// uint16	电池最高单体电压,1mV
 		*(SendBuffer + 0x2C) = (BMS_MinCellVolt & 0xFF);
-		*(SendBuffer + 0x2D) = ((BMS_MaxCellTemp+10)  & 0xFF); 	// uint16	电池最高单体电压,1mV
-		*(SendBuffer + 0x2E) = ((BMS_MinCellTemp+10) & 0xFF);
+		*(SendBuffer + 0x2D) = ((BMS_MaxCellTemp-10)  & 0xFF); 	// uint16	电池最高单体电压,1mV
+		*(SendBuffer + 0x2E) = ((BMS_MinCellTemp-10) & 0xFF);
 		*(SendBuffer + 0x2F) = bcc_chk(SendBuffer, 0x2F);
 		*PtrSendAddr = (uint32)SendBuffer;
 		break;
@@ -1340,6 +1350,21 @@ void TcpDataEncode(uint8 DataIdx,uint32 *PtrSendAddr, uint16 *SendLen)
 		*(SendBuffer + 0x22) = (UTC8TimeTcp.hour & 0xFF);		   // uint8	hour
 		*(SendBuffer + 0x23) = (UTC8TimeTcp.minute & 0xFF);		   // uint8	minute
 		*(SendBuffer + 0x24) = (UTC8TimeTcp.second & 0xFF);		   // uint8	second
+
+
+		BMS_PackSOC = 20/0.4;
+		BMS_PackSOH = 95/0.4;
+		BBox_PackSOC = 91/0.4;
+		BBox_PackSOH = 96;
+		BBox_TotalDischarCapy = 12345;
+		BBox_TotalCharCapy 	 = 23456;
+		BBox_TotalBackCharCapy = 34567;
+		BBox_TotalDischarEngy = 45678;
+		BBox_TotalCharEngy = 56789;
+		BBox_TotalBackCharEngy= 67890;
+		BBox_Dq_Dv_MAX = 123456;
+		BBox_Dq_Dv_MIN = 111112;
+
 		*(SendBuffer + 0x25) = (BMS_PackSOC) & 0xFF;	   		   // BMS计算SOC
 		*(SendBuffer + 0x26) = (BMS_PackSOH / 25 * 10) & 0xFF;     // SOH 精度1%
 		*(SendBuffer + 0x27) = (BBox_PackSOC & 0xFF); 				// 终端计算SOC
@@ -1382,6 +1407,7 @@ void TcpDataEncode(uint8 DataIdx,uint32 *PtrSendAddr, uint16 *SendLen)
 		*(SendBuffer + 0x47) = ((BBox_Dq_Dv_MIN >> 8) & 0xFF);
 		*(SendBuffer + 0x48) = ((BBox_Dq_Dv_MIN) & 0xFF);
 		*(SendBuffer + 0x49) = bcc_chk(SendBuffer, 0x49);
+		*PtrSendAddr = (uint32)SendBuffer;
 		break;
 	}
 	default:

+ 2 - 2
code/hal/hal_adapter.c

@@ -36,7 +36,7 @@ sint8 AtcmdDelayRecvFunc(uint8 recvChannel,char *ResultStrPtr,uint16 delayTime)
 {
 	sint8 outValue = -1;
 	uint8 delayCnt = 0;
-	uint8 UartData[256];
+	uint8 UartData[256] = {0};
 	uint16 ReadLen = 0;
 	char *retptr = NULL;
 	while (delayCnt<(delayTime/1000)&&outValue!=0)
@@ -1263,7 +1263,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*0.4);
+	BBox_PackSOH 			= (uint8)(BMS_PackSOH /25 *10);
 	BBox_Dq_Dv_MIN 			= (uint32)(socd_Q_dMin * 1000);					//dQ/dV
 	BBox_Dq_Dv_MAX 			= (uint32)(socd_Q_dMax * 1000);					//dQ/dV
 	BBox_TotalCharEngy 		= (uint32)(damd_E_totalChrgEng*10);			//累计充电电量

+ 1 - 1
code/main.c

@@ -89,7 +89,7 @@ int main(void)
 	xTaskCreate(CanTask, (const char *const)"CanTask", 512, (void *)0, main_TASK_PRIORITY + 2, &CanTask_Handle);
 	xTaskCreate(GpsTask, (const char *const)"GpsTask", 2048, (void *)0, main_TASK_PRIORITY + 1, &GpsTask_Handle);
 	xTaskCreate(Uart_4G_Task, (const char *const)"Uart_4G_Task", 2048, (void *)0, main_TASK_PRIORITY + 0, &Uart_4G_Task_Handle);
-//	xTaskCreate(BBox_BCU_Task, (const char *const)"BBox_BCU_Task", 2048, (void *)0, main_TASK_PRIORITY + 3, &BBox_BCU_Task_Handle);
+	xTaskCreate(BBox_BCU_Task, (const char *const)"BBox_BCU_Task", 2048, (void *)0, main_TASK_PRIORITY + 3, &BBox_BCU_Task_Handle);
 	vTaskStartScheduler();
 
 	for (;;)