فهرست منبع

Revert "北京测试,版本号为1.2.1.15,测试环境,未下线检测,采用4830,更改了bms升级指令,增加了循环次数"

This reverts commit 2768f8641dd9bcc2bc785568e05c3228c373606f.
CHENJIE-PC\QiXiang_CHENJIE 3 سال پیش
والد
کامیت
7a0824565e
1فایلهای تغییر یافته به همراه54 افزوده شده و 59 حذف شده
  1. 54 59
      src/UartTask.c

+ 54 - 59
src/UartTask.c

@@ -108,9 +108,6 @@ static void UartTask(void* arg)
         UartWriteData.Data[1] = 0x03;
     }
     osMessageQueuePut(UartWriteCmdHandle,&UartWriteData,0,1000);
-
-	BMS_Fota_update_flag =TRUE;//测试
-
     while (1)
     {
         switch (gProcess_Uart_Task)
@@ -846,10 +843,9 @@ void SP_BMS_Update_Service() //超力源BMS升级服务
 	UINT32 currentPackageStartAddr = 0;
 	BMS_Update_Recv_Msg_Type pUpdateMsgRecv;
 	UINT8 bmsUpdateFlag = 1;
-	UINT8 Cycle_count = 0;
 	//BMS_Update_Recv_Msg_Type bmsMsg;
 	//static UpdateStep step = UPDATE_STEP_CHECK_VERSION;
-	while(bmsUpdateFlag&&Cycle_count<2)
+	while(bmsUpdateFlag)
 	{
 		switch (updateStep)
 		{
@@ -899,7 +895,7 @@ void SP_BMS_Update_Service() //超力源BMS升级服务
 				{
 					errorCount++;
 				}
-				#ifdef USING_PRINTF1
+				#ifdef USING_PRINTF
 							//printf("update step:%d\n",updateStep);
 							printf("query:");
 							
@@ -974,7 +970,7 @@ void SP_BMS_Update_Service() //超力源BMS升级服务
 					errorCount = 0;
 				}
 				
-				#ifdef USING_PRINTF1
+				#ifdef USING_PRINTF
 							printf("update step:%d\n",updateStep);
 							printf("query:");
 							for(j=0;j<updateMsgSendLen;j++)
@@ -1007,7 +1003,7 @@ void SP_BMS_Update_Service() //超力源BMS升级服务
 				ret = SP_BMS_Update_Query(pUpdateMsgSend, updateMsgSendLen, (UINT8*)(&pUpdateMsgRecv), 0, 500);
 				//updateStep = UPDATE_STEP_SET_BAUD_RATE;
 				updateStep = UPDATE_STEP_CHECK_VERSION_AGAIN;//2021-04-09跳过波特率设置
-				#ifdef USING_PRINTF1
+				#ifdef USING_PRINTF
 							
 							printf("query:");
 							for(j=0;j<updateMsgSendLen;j++)
@@ -1069,7 +1065,7 @@ void SP_BMS_Update_Service() //超力源BMS升级服务
 				{
 					errorCount++;
 				}
-				#ifdef USING_PRINTF1
+				#ifdef USING_PRINTF
 							//printf("update step:%d\n",updateStep);
 							printf("query:");
 							
@@ -1110,16 +1106,15 @@ void SP_BMS_Update_Service() //超力源BMS升级服务
 				pUpdateMsgSend[10] = 0x61;	//check
 				pUpdateMsgSend[11] = 0xF5;	//end flag
 				
-				// printf("query:");
-				// for(j=0;j<updateMsgSendLen;j++)
-				// {
-				// 	printf("%x ",pUpdateMsgSend[j]);
-				// }
-				// printf("\n");
+				printf("query:");
+				for(j=0;j<updateMsgSendLen;j++)
+				{
+					printf("%x ",pUpdateMsgSend[j]);
+				}
+				printf("\n");
 				memset((UINT8*)(&pUpdateMsgRecv) , 0, sizeof(BMS_Update_Recv_Msg_Type));
 				ret = SP_BMS_Update_Query(pUpdateMsgSend, updateMsgSendLen, (UINT8*)(&pUpdateMsgRecv), sizeof(BMS_Update_Recv_Msg_Type), 500);
-				//ret = SP_BMS_Update_Query(pUpdateMsgSend, updateMsgSendLen, (UINT8*)(&pUpdateMsgRecv),sizeof(BMS_Update_Recv_Msg_Type), 100);
-				// printf("ret = %d\n",ret);
+				printf("ret = %d\n",ret);
 				if(ret!=0)
 				{
 					if(pUpdateMsgRecv.startFlag == 0xEB && pUpdateMsgRecv.endFlag == 0xF5)
@@ -1157,7 +1152,7 @@ void SP_BMS_Update_Service() //超力源BMS升级服务
 					errorCount = 0;
 				}
 				
-				#ifdef USING_PRINTF1
+				#ifdef USING_PRINTF
 					//printf("update step:%d\n",updateStep);
 					printf("query:");
 					for(j=0;j<updateMsgSendLen;j++)
@@ -1227,7 +1222,7 @@ void SP_BMS_Update_Service() //超力源BMS升级服务
 					errorCount = 0;
 				}
 				
-				#ifdef USING_PRINTF1
+				#ifdef USING_PRINTF
 					//printf("update step:%d\n",updateStep);
 					printf("query:");
 					for(j=0;j<updateMsgSendLen;j++)
@@ -1301,7 +1296,7 @@ void SP_BMS_Update_Service() //超力源BMS升级服务
 					errorCount = 0;
 				}
 				
-				#ifdef USING_PRINTF1
+				#ifdef USING_PRINTF
 							//printf("update step:%d\n",updateStep);
 							printf("query:");
 							for(j=0;j<updateMsgSendLen;j++)
@@ -1369,7 +1364,7 @@ void SP_BMS_Update_Service() //超力源BMS升级服务
 					errorCount = 0;
 				}
 				
-				#ifdef USING_PRINTF1
+				#ifdef USING_PRINTF
 					//printf("update step:%d\n",updateStep);
 					printf("query:");
 					for(j=0;j<updateMsgSendLen;j++)
@@ -1448,7 +1443,7 @@ void SP_BMS_Update_Service() //超力源BMS升级服务
 						errorCount = 0;
 						break;
 					}
-				#ifdef USING_PRINTF1
+				#ifdef USING_PRINTF
 							//printf("update step:%d\n",updateStep);
 							printf("query:");
 							for(j=0;j<updateMsgSendLen;j++)
@@ -1516,6 +1511,22 @@ void SP_BMS_Update_Service() //超力源BMS升级服务
 					updateStep = UPDATE_STEP_RESET;
 					errorCount = 0;
 				}
+				
+				#ifdef USING_PRINTF
+							//printf("update step:%d\n",updateStep);
+							printf("query:");
+							for(j=0;j<updateMsgSendLen;j++)
+							{
+								printf("%x ",pUpdateMsgSend[j]);
+							}
+							printf("\nanswer:");
+							for(j=0;j<sizeof(BMS_Update_Recv_Msg_Type);j++)
+							{
+								printf("%x ",*(((UINT8*)&pUpdateMsgRecv)+j));
+							}
+							printf("\n");
+							printf("next update step:%d\n",updateStep);
+				#endif
 				osDelay(50);
 				break;			
 
@@ -1532,7 +1543,24 @@ void SP_BMS_Update_Service() //超力源BMS升级服务
 				pUpdateMsgSend[7] = 0xF5;	//end flag
 				memset((UINT8*)(&pUpdateMsgRecv) , 0, sizeof(BMS_Update_Recv_Msg_Type));
 				SP_BMS_Update_Query(pUpdateMsgSend, updateMsgSendLen, (UINT8*)(&pUpdateMsgRecv), 0, 500);
+				
 				updateStep = UPDATE_STEP_END;
+				
+				#ifdef USING_PRINTF
+							//printf("update step:%d\n",updateStep);
+							printf("query:");
+							for(j=0;j<updateMsgSendLen;j++)
+							{
+								printf("%x ",pUpdateMsgSend[j]);
+							}
+							printf("\nanswer:");
+							for(j=0;j<sizeof(BMS_Update_Recv_Msg_Type);j++)
+							{
+								printf("%x ",*(((UINT8*)&pUpdateMsgRecv)+j));
+							}
+							printf("\n");	
+							printf("next update step:%d\n",updateStep);
+				#endif
 				osDelay(50);
 				break;
 			case UPDATE_STEP_END:
@@ -1556,7 +1584,7 @@ void SP_BMS_Update_Service() //超力源BMS升级服务
 				osDelay(50);
 				
 				resetCount++;
-				if(resetCount>2)
+				if(resetCount>=2)
 				{
 					updateStep = UPDATE_STEP_DOWNLOAD_BREAK_OFF;
 					resetCount = 0;
@@ -1583,8 +1611,7 @@ void SP_BMS_Update_Service() //超力源BMS升级服务
 				memset((UINT8*)(&pUpdateMsgRecv) , 0, sizeof(BMS_Update_Recv_Msg_Type));
 				SP_BMS_Update_Query(pUpdateMsgSend, updateMsgSendLen, (UINT8*)(&pUpdateMsgRecv), 0, 500);
 				osDelay(50);
-				updateStep = UPDATE_STEP_CHECK_VERSION;
-				Cycle_count++;
+				updateStep = UPDATE_STEP_ERROR;
 				break;
 			case UPDATE_STEP_ERROR:
 				updateStep = UPDATE_STEP_CHECK_VERSION;
@@ -1606,14 +1633,6 @@ UINT8 SP_BMS_Update_Query(UINT8* pSend,UINT32 sendLen, UINT8* pRead, UINT32 read
 	UINT8 timeCount = 0;
 	UINT8 j=0;
 	USARTdrv->Send(pSend,sendLen);
-	#ifdef USING_PRINTF
-		printf("\nquery in :");
-		for(j=0;j<sendLen;j++)
-		{
-			printf("%x ",*(pSend+j));
-		}
-		printf("\n");	
-	#endif
 	if(readLen>0)
 	{
 		USARTdrv->Receive(pRead,readLen);         
@@ -1627,39 +1646,15 @@ UINT8 SP_BMS_Update_Query(UINT8* pSend,UINT32 sendLen, UINT8* pRead, UINT32 read
 				isRecvTimeout = true;
 				break;
 			}
-		}
-		#ifdef USING_PRINTF
-			printf("\nanswer in :");
-			for(j=0;j<readLen;j++)
-			{
-				printf("%x ",*(pRead+j));
-			}
-			printf("\n");	
-		#endif	
+		}	
 		if (isRecvComplete == true)
 		{
 			isRecvComplete = false;
-			if(*(pRead+0)!=0xEB)
-			{
-				USARTdrv->Uninitialize();
-				osDelay(1000);
-				USARTdrv->Initialize(USART_callback);
-				USARTdrv->PowerControl(ARM_POWER_FULL);
-				USARTdrv->Control(ARM_USART_MODE_ASYNCHRONOUS |
-						ARM_USART_DATA_BITS_8 |
-						ARM_USART_PARITY_NONE |
-						ARM_USART_STOP_BITS_1 |
-						ARM_USART_FLOW_CONTROL_NONE, 9600);
-				#ifdef USING_PRINTF
-					printf("\nuart reset in \n");	
-				#endif
-				return  0;
-			}		  
 			return readLen;
 		}
 		else
 		{
-			//memset(pRead,0x00,readLen);
+			memset(pRead,0x00,readLen);
 			isRecvTimeout = false;
 			return 0;
 		}