|
@@ -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()
|
|
|
UINT32 currentPackageStartAddr = 0;
|
|
|
BMS_Update_Recv_Msg_Type pUpdateMsgRecv;
|
|
|
UINT8 bmsUpdateFlag = 1;
|
|
|
- UINT8 Cycle_count = 0;
|
|
|
|
|
|
|
|
|
- while(bmsUpdateFlag&&Cycle_count<2)
|
|
|
+ while(bmsUpdateFlag)
|
|
|
{
|
|
|
switch (updateStep)
|
|
|
{
|
|
@@ -899,7 +895,7 @@ void SP_BMS_Update_Service()
|
|
|
{
|
|
|
errorCount++;
|
|
|
}
|
|
|
- #ifdef USING_PRINTF1
|
|
|
+ #ifdef USING_PRINTF
|
|
|
|
|
|
printf("query:");
|
|
|
|
|
@@ -974,7 +970,7 @@ void SP_BMS_Update_Service()
|
|
|
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()
|
|
|
ret = SP_BMS_Update_Query(pUpdateMsgSend, updateMsgSendLen, (UINT8*)(&pUpdateMsgRecv), 0, 500);
|
|
|
|
|
|
updateStep = UPDATE_STEP_CHECK_VERSION_AGAIN;
|
|
|
- #ifdef USING_PRINTF1
|
|
|
+ #ifdef USING_PRINTF
|
|
|
|
|
|
printf("query:");
|
|
|
for(j=0;j<updateMsgSendLen;j++)
|
|
@@ -1069,7 +1065,7 @@ void SP_BMS_Update_Service()
|
|
|
{
|
|
|
errorCount++;
|
|
|
}
|
|
|
- #ifdef USING_PRINTF1
|
|
|
+ #ifdef USING_PRINTF
|
|
|
|
|
|
printf("query:");
|
|
|
|
|
@@ -1110,16 +1106,15 @@ void SP_BMS_Update_Service()
|
|
|
pUpdateMsgSend[10] = 0x61;
|
|
|
pUpdateMsgSend[11] = 0xF5;
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ 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);
|
|
|
-
|
|
|
-
|
|
|
+ printf("ret = %d\n",ret);
|
|
|
if(ret!=0)
|
|
|
{
|
|
|
if(pUpdateMsgRecv.startFlag == 0xEB && pUpdateMsgRecv.endFlag == 0xF5)
|
|
@@ -1157,7 +1152,7 @@ void SP_BMS_Update_Service()
|
|
|
errorCount = 0;
|
|
|
}
|
|
|
|
|
|
- #ifdef USING_PRINTF1
|
|
|
+ #ifdef USING_PRINTF
|
|
|
|
|
|
printf("query:");
|
|
|
for(j=0;j<updateMsgSendLen;j++)
|
|
@@ -1227,7 +1222,7 @@ void SP_BMS_Update_Service()
|
|
|
errorCount = 0;
|
|
|
}
|
|
|
|
|
|
- #ifdef USING_PRINTF1
|
|
|
+ #ifdef USING_PRINTF
|
|
|
|
|
|
printf("query:");
|
|
|
for(j=0;j<updateMsgSendLen;j++)
|
|
@@ -1301,7 +1296,7 @@ void SP_BMS_Update_Service()
|
|
|
errorCount = 0;
|
|
|
}
|
|
|
|
|
|
- #ifdef USING_PRINTF1
|
|
|
+ #ifdef USING_PRINTF
|
|
|
|
|
|
printf("query:");
|
|
|
for(j=0;j<updateMsgSendLen;j++)
|
|
@@ -1369,7 +1364,7 @@ void SP_BMS_Update_Service()
|
|
|
errorCount = 0;
|
|
|
}
|
|
|
|
|
|
- #ifdef USING_PRINTF1
|
|
|
+ #ifdef USING_PRINTF
|
|
|
|
|
|
printf("query:");
|
|
|
for(j=0;j<updateMsgSendLen;j++)
|
|
@@ -1448,7 +1443,7 @@ void SP_BMS_Update_Service()
|
|
|
errorCount = 0;
|
|
|
break;
|
|
|
}
|
|
|
- #ifdef USING_PRINTF1
|
|
|
+ #ifdef USING_PRINTF
|
|
|
|
|
|
printf("query:");
|
|
|
for(j=0;j<updateMsgSendLen;j++)
|
|
@@ -1516,6 +1511,22 @@ void SP_BMS_Update_Service()
|
|
|
updateStep = UPDATE_STEP_RESET;
|
|
|
errorCount = 0;
|
|
|
}
|
|
|
+
|
|
|
+ #ifdef USING_PRINTF
|
|
|
+
|
|
|
+ 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()
|
|
|
pUpdateMsgSend[7] = 0xF5;
|
|
|
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("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()
|
|
|
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()
|
|
|
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);
|
|
|
isRecvTimeout = false;
|
|
|
return 0;
|
|
|
}
|