|
@@ -58,7 +58,7 @@ static process_Uart gProcess_Uart_Task = PROCESS_UART_STATE_IDLE;
|
|
|
|
|
|
//函数声明区
|
|
//函数声明区
|
|
void USART_callback(uint32_t event);
|
|
void USART_callback(uint32_t event);
|
|
-UINT8 Uart_Transmit_func(UINT8* Uart_Read_Msg,UINT8* Uart_Recv_Buffer);
|
|
|
|
|
|
+UINT8 Uart_DataRecv_func(UINT8* Uart_Read_Msg,UINT8* Uart_Recv_Buffer);
|
|
UINT8 Uart_WriteCmd_func(Uart_Write_Data_Type UartWriteData);
|
|
UINT8 Uart_WriteCmd_func(Uart_Write_Data_Type UartWriteData);
|
|
UINT16 crc_chk(UINT8* data, UINT8 length);
|
|
UINT16 crc_chk(UINT8* data, UINT8 length);
|
|
void battSOCDisplay(void);
|
|
void battSOCDisplay(void);
|
|
@@ -93,6 +93,7 @@ static void UartTask(void* arg)
|
|
BOOL uartReadSuccessFlag = false;
|
|
BOOL uartReadSuccessFlag = false;
|
|
Uart_Read_Msg_Type Uart_Read_Msg;
|
|
Uart_Read_Msg_Type Uart_Read_Msg;
|
|
Uart_Write_Data_Type UartWriteData; //Uart控制命令
|
|
Uart_Write_Data_Type UartWriteData; //Uart控制命令
|
|
|
|
+ UINT8 *Uart_Buffer_Ptr;
|
|
if(UartWriteCmdHandle == NULL)//Uart控制命令传输指针
|
|
if(UartWriteCmdHandle == NULL)//Uart控制命令传输指针
|
|
{
|
|
{
|
|
UartWriteCmdHandle = osMessageQueueNew(3,sizeof(Uart_Write_Data_Type), NULL);
|
|
UartWriteCmdHandle = osMessageQueueNew(3,sizeof(Uart_Write_Data_Type), NULL);
|
|
@@ -179,7 +180,6 @@ static void UartTask(void* arg)
|
|
}
|
|
}
|
|
case PROCESS_UART_STATE_READ:
|
|
case PROCESS_UART_STATE_READ:
|
|
{
|
|
{
|
|
- osStatus_t result = osMutexAcquire(UartMutex, osWaitForever);
|
|
|
|
Reg_Num = 0x21+BATT_CELL_VOL_NUM+BATT_TEMP_NUM + 2;//按照协议里面的0x21+X+N的结束地址
|
|
Reg_Num = 0x21+BATT_CELL_VOL_NUM+BATT_TEMP_NUM + 2;//按照协议里面的0x21+X+N的结束地址
|
|
Uart_Read_Msg.Bms_Address = BMS_ADDRESS_CODE;
|
|
Uart_Read_Msg.Bms_Address = BMS_ADDRESS_CODE;
|
|
Uart_Read_Msg.Bms_Funcode = UART_READ_CODE;
|
|
Uart_Read_Msg.Bms_Funcode = UART_READ_CODE;
|
|
@@ -188,8 +188,13 @@ static void UartTask(void* arg)
|
|
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;
|
|
Uart_Uds_LEN = Reg_Num*2;
|
|
- memset(UartReadMsg.Header,0x00,Uart_Uds_LEN);
|
|
|
|
- Uart_Recv_LEN = Uart_Transmit_func((UINT8 *)&Uart_Read_Msg,UartReadMsg.Header);
|
|
|
|
|
|
+ Uart_Buffer_Ptr = malloc(Uart_Uds_LEN);
|
|
|
|
+ memset(Uart_Buffer_Ptr,0x00,Uart_Uds_LEN);
|
|
|
|
+ Uart_Recv_LEN = Uart_DataRecv_func((UINT8 *)&Uart_Read_Msg,Uart_Buffer_Ptr);
|
|
|
|
+ osStatus_t result = osMutexAcquire(UartMutex, osWaitForever);
|
|
|
|
+ memcpy(UartReadMsg.Header,Uart_Buffer_Ptr,Uart_Uds_LEN);
|
|
|
|
+ osMutexRelease(UartMutex);
|
|
|
|
+ free(Uart_Buffer_Ptr);
|
|
if(Uart_Recv_LEN>0)
|
|
if(Uart_Recv_LEN>0)
|
|
{
|
|
{
|
|
UartReadMsg.UartFlag = TRUE;
|
|
UartReadMsg.UartFlag = TRUE;
|
|
@@ -216,7 +221,6 @@ static void UartTask(void* arg)
|
|
}
|
|
}
|
|
printf("\n");
|
|
printf("\n");
|
|
#endif
|
|
#endif
|
|
- osMutexRelease(UartMutex);
|
|
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
case PROCESS_UART_STATE_WRITE:
|
|
case PROCESS_UART_STATE_WRITE:
|
|
@@ -377,7 +381,7 @@ UINT8 Uart_WriteCmd_func(Uart_Write_Data_Type UartWriteData)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//Uart发送接收函数
|
|
//Uart发送接收函数
|
|
-UINT8 Uart_Transmit_func(UINT8* Uart_Read_Msg,UINT8* Uart_Recv_Buffer)
|
|
|
|
|
|
+UINT8 Uart_DataRecv_func(UINT8* Uart_Read_Msg,UINT8* Uart_Recv_Buffer)
|
|
{
|
|
{
|
|
UINT16 CRC_Rece_buffer;
|
|
UINT16 CRC_Rece_buffer;
|
|
UINT16 CRC_chk_buffer;
|
|
UINT16 CRC_chk_buffer;
|