|
@@ -29,7 +29,6 @@ static UINT8 Uart_DataRecv_func(UartQueryType Uart_Read_Msg_Fun,UINT8* Uart_Recv
|
|
static void UartTask(void* arg)
|
|
static void UartTask(void* arg)
|
|
{
|
|
{
|
|
|
|
|
|
- UINT16 Uart_Uds_LEN;
|
|
|
|
UINT16 Reg_Num = 0;
|
|
UINT16 Reg_Num = 0;
|
|
UINT16 Uart_Recv_LEN;
|
|
UINT16 Uart_Recv_LEN;
|
|
UINT8 UartRecvFlagCounter = 0;
|
|
UINT8 UartRecvFlagCounter = 0;
|
|
@@ -118,8 +117,7 @@ static void UartTask(void* arg)
|
|
Uart_Read_Msg.Reg_Begin_L = 0x00;
|
|
Uart_Read_Msg.Reg_Begin_L = 0x00;
|
|
Uart_Read_Msg.Reg_Num_H = Reg_Num>>8;
|
|
Uart_Read_Msg.Reg_Num_H = Reg_Num>>8;
|
|
Uart_Read_Msg.Reg_Num_L = Reg_Num;
|
|
Uart_Read_Msg.Reg_Num_L = Reg_Num;
|
|
- Uart_Uds_LEN = Reg_Num*2;
|
|
|
|
- memset(UartAnswerData.Header,0x00,Uart_Uds_LEN);
|
|
|
|
|
|
+ memset(&(UartAnswerData),0x00,sizeof(UartAnswerData_S));
|
|
CRC_chk_buffer = crc_chk((UINT8 *)&Uart_Read_Msg,6);
|
|
CRC_chk_buffer = crc_chk((UINT8 *)&Uart_Read_Msg,6);
|
|
Uart_Read_Msg.CRC_L = CRC_chk_buffer;
|
|
Uart_Read_Msg.CRC_L = CRC_chk_buffer;
|
|
Uart_Read_Msg.CRC_H = CRC_chk_buffer>>8;
|
|
Uart_Read_Msg.CRC_H = CRC_chk_buffer>>8;
|
|
@@ -1460,17 +1458,17 @@ updateBMSStatus MS_BMS_Update_Service() //美顺BMS升级服务
|
|
updateDataTotalByteLen = ((ReadNVMTemp[0]<<24)&0xFF000000) | ((ReadNVMTemp[1]<<16)&0xFF0000) | ((ReadNVMTemp[2]<<8)&0xFF00) | (ReadNVMTemp[3]&0xFF) ;
|
|
updateDataTotalByteLen = ((ReadNVMTemp[0]<<24)&0xFF000000) | ((ReadNVMTemp[1]<<16)&0xFF0000) | ((ReadNVMTemp[2]<<8)&0xFF00) | (ReadNVMTemp[3]&0xFF) ;
|
|
updateDataPackageCount = (updateDataTotalByteLen+(64-1))/64; //进一法 e = (a+(b-1))/b
|
|
updateDataPackageCount = (updateDataTotalByteLen+(64-1))/64; //进一法 e = (a+(b-1))/b
|
|
|
|
|
|
- for(i=0; i<((updateDataTotalByteLen+4)+(64-1))/64;i++)
|
|
|
|
|
|
+ for(i=0; i<((updateDataTotalByteLen+headerLen-1)+(64-1))/64;i++)//
|
|
{
|
|
{
|
|
memset(ReadNVMTemp, 0, 64);
|
|
memset(ReadNVMTemp, 0, 64);
|
|
- if((i+1)*64 < (updateDataTotalByteLen+4))
|
|
|
|
|
|
+ if((i+1)*64 <= (updateDataTotalByteLen+headerLen-1))
|
|
{
|
|
{
|
|
tempLen = 64;
|
|
tempLen = 64;
|
|
BSP_QSPI_Read_Safe(ReadNVMTemp,FLASH_BMS_FOTA_START_ADDR+1+i*64,64);
|
|
BSP_QSPI_Read_Safe(ReadNVMTemp,FLASH_BMS_FOTA_START_ADDR+1+i*64,64);
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- tempLen = (updateDataTotalByteLen+4) - i*64;
|
|
|
|
|
|
+ tempLen = (updateDataTotalByteLen+headerLen-1) - i*64;
|
|
BSP_QSPI_Read_Safe(ReadNVMTemp,FLASH_BMS_FOTA_START_ADDR+1+i*64,tempLen);
|
|
BSP_QSPI_Read_Safe(ReadNVMTemp,FLASH_BMS_FOTA_START_ADDR+1+i*64,tempLen);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1478,7 +1476,7 @@ updateBMSStatus MS_BMS_Update_Service() //美顺BMS升级服务
|
|
{
|
|
{
|
|
checkSumCal = (checkSumCal + ReadNVMTemp[j]) & 0xFF;
|
|
checkSumCal = (checkSumCal + ReadNVMTemp[j]) & 0xFF;
|
|
}
|
|
}
|
|
- //osDelay(10);
|
|
|
|
|
|
+ osDelay(10);
|
|
}
|
|
}
|
|
if(checkSum != checkSumCal)
|
|
if(checkSum != checkSumCal)
|
|
{
|
|
{
|
|
@@ -1521,7 +1519,7 @@ updateBMSStatus MS_BMS_Update_Service() //美顺BMS升级服务
|
|
pUpdateMsgSend[5] = CRCtemp&0xFF; //CRC Low
|
|
pUpdateMsgSend[5] = CRCtemp&0xFF; //CRC Low
|
|
|
|
|
|
memset((UINT8*)(bmsAnswerMsg) , 0, 8);
|
|
memset((UINT8*)(bmsAnswerMsg) , 0, 8);
|
|
- ret0 = MS_BMS_Update_Query(pUpdateMsgSend, updateMsgSendLen, (UINT8*)(bmsAnswerMsg), updateMsgReadLen, 500);
|
|
|
|
|
|
+ ret0 = MS_BMS_Update_Query(pUpdateMsgSend, updateMsgSendLen, (UINT8*)(bmsAnswerMsg), updateMsgReadLen, 1000);
|
|
#ifdef USING_PRINTF
|
|
#ifdef USING_PRINTF
|
|
printf("update step 1 answer,updateMsgReadLen = %x:\n",updateMsgReadLen);
|
|
printf("update step 1 answer,updateMsgReadLen = %x:\n",updateMsgReadLen);
|
|
|
|
|
|
@@ -1621,8 +1619,8 @@ updateBMSStatus MS_BMS_Update_Service() //美顺BMS升级服务
|
|
pUpdateMsgSend[5+dataLen] = CRCtemp&0xFF; //CRC Low
|
|
pUpdateMsgSend[5+dataLen] = CRCtemp&0xFF; //CRC Low
|
|
|
|
|
|
memset((UINT8*)(bmsAnswerMsg) , 0, 8);
|
|
memset((UINT8*)(bmsAnswerMsg) , 0, 8);
|
|
- ret0 = MS_BMS_Update_Query(pUpdateMsgSend, updateMsgSendLen, (UINT8*)(bmsAnswerMsg), updateMsgReadLen, 500);
|
|
|
|
- #ifdef USING_PRINTF1
|
|
|
|
|
|
+ ret0 = MS_BMS_Update_Query(pUpdateMsgSend, updateMsgSendLen, (UINT8*)(bmsAnswerMsg), updateMsgReadLen, 1000);
|
|
|
|
+ #ifdef USING_PRINTF
|
|
printf("update step 3 answer:\n");
|
|
printf("update step 3 answer:\n");
|
|
for(ii=0;ii<updateMsgReadLen;ii++)
|
|
for(ii=0;ii<updateMsgReadLen;ii++)
|
|
printf("%x ",bmsAnswerMsg[ii]);
|
|
printf("%x ",bmsAnswerMsg[ii]);
|
|
@@ -1704,8 +1702,8 @@ updateBMSStatus MS_BMS_Update_Service() //美顺BMS升级服务
|
|
pUpdateMsgSend[5+dataLen] = CRCtemp&0xFF; //CRC Low
|
|
pUpdateMsgSend[5+dataLen] = CRCtemp&0xFF; //CRC Low
|
|
|
|
|
|
memset((UINT8*)(bmsAnswerMsg) , 0, 8);
|
|
memset((UINT8*)(bmsAnswerMsg) , 0, 8);
|
|
- ret0 = MS_BMS_Update_Query(pUpdateMsgSend, updateMsgSendLen, (UINT8*)(bmsAnswerMsg), updateMsgReadLen, 500);
|
|
|
|
- #ifdef USING_PRINTF1
|
|
|
|
|
|
+ ret0 = MS_BMS_Update_Query(pUpdateMsgSend, updateMsgSendLen, (UINT8*)(bmsAnswerMsg), updateMsgReadLen, 1000);
|
|
|
|
+ #ifdef USING_PRINTF
|
|
printf("update step 5 answer:\n");
|
|
printf("update step 5 answer:\n");
|
|
for(ii=0;ii<updateMsgReadLen;ii++)
|
|
for(ii=0;ii<updateMsgReadLen;ii++)
|
|
printf("%x ",bmsAnswerMsg[ii]);
|
|
printf("%x ",bmsAnswerMsg[ii]);
|
|
@@ -1769,14 +1767,14 @@ updateBMSStatus MS_BMS_Update_Service() //美顺BMS升级服务
|
|
|
|
|
|
memset(ReadNVMTemp, 0, 64);
|
|
memset(ReadNVMTemp, 0, 64);
|
|
|
|
|
|
- if((i+1)*64 < (updateDataTotalByteLen))
|
|
|
|
|
|
+ if((i+1)*64 <= (updateDataTotalByteLen))
|
|
{
|
|
{
|
|
tempLen = 64;
|
|
tempLen = 64;
|
|
BSP_QSPI_Read_Safe(ReadNVMTemp,FLASH_BMS_FOTA_START_ADDR+headerLen+i*64,64);
|
|
BSP_QSPI_Read_Safe(ReadNVMTemp,FLASH_BMS_FOTA_START_ADDR+headerLen+i*64,64);
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- tempLen = (updateDataTotalByteLen) - i*64;
|
|
|
|
|
|
+ tempLen = (updateDataTotalByteLen) - i*64;//
|
|
BSP_QSPI_Read_Safe(ReadNVMTemp,FLASH_BMS_FOTA_START_ADDR+headerLen+i*64,tempLen);
|
|
BSP_QSPI_Read_Safe(ReadNVMTemp,FLASH_BMS_FOTA_START_ADDR+headerLen+i*64,tempLen);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1804,8 +1802,8 @@ updateBMSStatus MS_BMS_Update_Service() //美顺BMS升级服务
|
|
pUpdateMsgSend[5+dataLen] = CRCtemp&0xFF; //CRC Low
|
|
pUpdateMsgSend[5+dataLen] = CRCtemp&0xFF; //CRC Low
|
|
|
|
|
|
memset((UINT8*)(bmsAnswerMsg) , 0, 8);
|
|
memset((UINT8*)(bmsAnswerMsg) , 0, 8);
|
|
- ret0 = MS_BMS_Update_Query(pUpdateMsgSend, updateMsgSendLen, (UINT8*)(bmsAnswerMsg), updateMsgReadLen, 500);
|
|
|
|
- #ifdef USING_PRINTF1
|
|
|
|
|
|
+ ret0 = MS_BMS_Update_Query(pUpdateMsgSend, updateMsgSendLen, (UINT8*)(bmsAnswerMsg), updateMsgReadLen, 1000);
|
|
|
|
+ #ifdef USING_PRINTF
|
|
printf("update step 7 answer:\n");
|
|
printf("update step 7 answer:\n");
|
|
for(ii=0;ii<updateMsgReadLen;ii++)
|
|
for(ii=0;ii<updateMsgReadLen;ii++)
|
|
printf("%x ",bmsAnswerMsg[ii]);
|
|
printf("%x ",bmsAnswerMsg[ii]);
|
|
@@ -1888,8 +1886,8 @@ updateBMSStatus MS_BMS_Update_Service() //美顺BMS升级服务
|
|
pUpdateMsgSend[5] = CRCtemp&0xFF; //CRC Low
|
|
pUpdateMsgSend[5] = CRCtemp&0xFF; //CRC Low
|
|
|
|
|
|
memset((UINT8*)(bmsAnswerMsg) , 0, 8);
|
|
memset((UINT8*)(bmsAnswerMsg) , 0, 8);
|
|
- ret0 = MS_BMS_Update_Query(pUpdateMsgSend, updateMsgSendLen, (UINT8*)(bmsAnswerMsg), updateMsgReadLen, 500);
|
|
|
|
- #ifdef USING_PRINTF1
|
|
|
|
|
|
+ ret0 = MS_BMS_Update_Query(pUpdateMsgSend, updateMsgSendLen, (UINT8*)(bmsAnswerMsg), updateMsgReadLen, 1000);
|
|
|
|
+ #ifdef USING_PRINTF
|
|
printf("update step 9 answer:\n");
|
|
printf("update step 9 answer:\n");
|
|
for(ii=0;ii<updateMsgReadLen;ii++)
|
|
for(ii=0;ii<updateMsgReadLen;ii++)
|
|
printf("%x ",bmsAnswerMsg[ii]);
|
|
printf("%x ",bmsAnswerMsg[ii]);
|
|
@@ -1951,8 +1949,8 @@ updateBMSStatus MS_BMS_Update_Service() //美顺BMS升级服务
|
|
pUpdateMsgSend[5] = CRCtemp&0xFF; //CRC Low
|
|
pUpdateMsgSend[5] = CRCtemp&0xFF; //CRC Low
|
|
|
|
|
|
memset((UINT8*)(bmsAnswerMsg) , 0, 8);
|
|
memset((UINT8*)(bmsAnswerMsg) , 0, 8);
|
|
- ret0 = MS_BMS_Update_Query(pUpdateMsgSend, updateMsgSendLen, (UINT8*)(bmsAnswerMsg), updateMsgReadLen, 500);
|
|
|
|
- #ifdef USING_PRINTF1
|
|
|
|
|
|
+ ret0 = MS_BMS_Update_Query(pUpdateMsgSend, updateMsgSendLen, (UINT8*)(bmsAnswerMsg), updateMsgReadLen, 1000);
|
|
|
|
+ #ifdef USING_PRINTF
|
|
printf("update step A answer:\n");
|
|
printf("update step A answer:\n");
|
|
for(ii=0;ii<updateMsgReadLen;ii++)
|
|
for(ii=0;ii<updateMsgReadLen;ii++)
|
|
printf("%x ",bmsAnswerMsg[ii]);
|
|
printf("%x ",bmsAnswerMsg[ii]);
|