Commit 343070c7 authored by 李俭双's avatar 李俭双

🐞 fix:43272,更改故障码显示不正确问题

parent 8531ea77
...@@ -23,7 +23,7 @@ const st_CANMsgAttribute CAN_CH0_CAN_MSG_CONST_ARRAY[CAN_CH0_ID_TOTAL_MAX] = ...@@ -23,7 +23,7 @@ const st_CANMsgAttribute CAN_CH0_CAN_MSG_CONST_ARRAY[CAN_CH0_ID_TOTAL_MAX] =
1000ul, 1000ul,
0x402ul, 0x402ul,
(( void * )0), (( void * )0),
(( void * )0), (Fault_Code_Receive),
(( void * )0), (( void * )0),
}, },
{ {
......
#include "FaultCode\FaultCode.h" #include "FaultCode\FaultCode.h"
#include "Application.h" #include "Application.h"
uint8_t DTC_Amnt_Number = 0; //Diag402ReceiveDTCNumberTemp uint8_t DTC_Amnt_Number = 0;
uint8_t DTC_Amnt_Number_Count = 0; //Diag402ReceiveDTCCount uint8_t DTC_Amnt_Number_Count = 0;
uint8_t FaultCode_Number = 0; //Diag402ReceiveDTCNumber uint8_t FaultCode_Number = 0;
uint32_t DTC_Data[254] = {0}; //Diag402ReceiveDTC
uint32_t DTC_Data_Count[254] = {0}; //Diag402ReceiveDTCTemp
uint32_t FaultCode_Data[254] = {0}; //DtcCurFaultGrpup
uint32_t DTC_Data[FualtCodeMax] = {0};
uint32_t DTC_Data_Count[FualtCodeMax] = {0};
uint32_t FaultCode_Data[FualtCodeMax] = {0};
uint32_t u32Countbuf = 0UL;
void Fault_Code_Receive(uint8_t CopyData[])
{
uint8_t i = 0;
ECU_FaultCode_Processing_Service();
}
uint8_t FaultCode_Compare(uint32_t FaultCode, uint32_t* CodeList, uint8_t len) uint8_t FaultCode_Compare(uint32_t FaultCode, uint32_t* CodeList, uint8_t len)
{ {
uint8_t i = 0; uint8_t i = 0;
...@@ -22,7 +28,28 @@ uint8_t FaultCode_Compare(uint32_t FaultCode, uint32_t* CodeList, uint8_t len) ...@@ -22,7 +28,28 @@ uint8_t FaultCode_Compare(uint32_t FaultCode, uint32_t* CodeList, uint8_t len)
} }
return result; return result;
} }
static void Fault_Code_App_Swap(uint32_t *pData1, uint32_t *pData2)
{
uint32_t psw;
if ((*pData1) > (*pData2))
{
psw = (*pData2);
(*pData2) = (*pData1);
(*pData1) = psw;
}
}
static void Fault_Code_App_SortNByte(uint32_t *SortData, uint8_t len)
{
uint8_t n = 0, m;
for (; n < len - 1; n++)
{
for (m = n + 1; m < len; m++)
{
Fault_Code_App_Swap((SortData + n), (SortData + m));
}
}
}
void ECU_FaultCode_Processing_Service ( void ) void ECU_FaultCode_Processing_Service ( void )
{ {
uint8_t DTCH1 = 0; uint8_t DTCH1 = 0;
...@@ -121,12 +148,16 @@ void ECU_FaultCode_Processing_Service ( void ) ...@@ -121,12 +148,16 @@ void ECU_FaultCode_Processing_Service ( void )
DTC2 |= DTCM2 & 0xF ; DTC2 |= DTCM2 & 0xF ;
} }
if(DTC_Amnt_Number == 0)
if (DTC_Amnt_Number == 0)
{ {
for (i = 0; i < 255; i++) for (i = 0; i < FualtCodeMax; i++)
{ {
FaultCode_Data[i] = 0; FaultCode_Data[i] = 0;
DTC_Data_Count[i] = 0;
DTC_Data[i] = 0;
} }
DTC_Amnt_Number_Count = 0;
} }
if(DTC_Amnt_Number_Count < DTC_Amnt_Number) if(DTC_Amnt_Number_Count < DTC_Amnt_Number)
{ {
...@@ -134,6 +165,7 @@ void ECU_FaultCode_Processing_Service ( void ) ...@@ -134,6 +165,7 @@ void ECU_FaultCode_Processing_Service ( void )
{ {
DTC_Data_Count[DTC_Amnt_Number_Count] = DTC1; DTC_Data_Count[DTC_Amnt_Number_Count] = DTC1;
DTC_Amnt_Number_Count ++; DTC_Amnt_Number_Count ++;
Fault_Code_App_SortNByte(DTC_Data_Count, DTC_Amnt_Number_Count);
} }
} }
if(DTC_Amnt_Number_Count < DTC_Amnt_Number) if(DTC_Amnt_Number_Count < DTC_Amnt_Number)
...@@ -142,21 +174,37 @@ void ECU_FaultCode_Processing_Service ( void ) ...@@ -142,21 +174,37 @@ void ECU_FaultCode_Processing_Service ( void )
{ {
DTC_Data_Count[DTC_Amnt_Number_Count] = DTC2; DTC_Data_Count[DTC_Amnt_Number_Count] = DTC2;
DTC_Amnt_Number_Count ++; DTC_Amnt_Number_Count ++;
Fault_Code_App_SortNByte(DTC_Data_Count, DTC_Amnt_Number_Count);
} }
} }
if(DTC_Amnt_Number_Count > DTC_Amnt_Number)
{
for (i = 0; i < FualtCodeMax; i++)
{
//FaultCode_Data[i] = 0;
DTC_Data_Count[i] = 0;
DTC_Data[i] = 0;
}
DTC_Amnt_Number_Count = 0;
}
if (DTC_Amnt_Number_Count == DTC_Amnt_Number) if (DTC_Amnt_Number_Count == DTC_Amnt_Number)
{ {
for(i = 0; i < DTC_Amnt_Number_Count; i++) for(i = 0; i < DTC_Amnt_Number_Count; i++)
{ {
DTC_Data[i] = DTC_Data_Count[i]; DTC_Data[i] = DTC_Data_Count[i];
DTC_Data_Count[i] = 0; DTC_Data_Count[i] = 0;
Fault_Code_App_SortNByte(DTC_Data, FaultCode_Number);
} }
FaultCode_Number = DTC_Amnt_Number; FaultCode_Number = DTC_Amnt_Number;
DTC_Amnt_Number_Count = 0; DTC_Amnt_Number_Count = 0;
for(i = 0; i < FaultCode_Number; i++) for(i = 0; i < FaultCode_Number; i++)
{ {
FaultCode_Data[i] = DTC_Data[i]; if(FaultCode_Data[i] != DTC_Data[i])
{
FaultCode_Data[i] = DTC_Data[i];
Fault_Code_App_SortNByte(FaultCode_Data, FaultCode_Number);
}
} }
} }
......
...@@ -3,8 +3,13 @@ ...@@ -3,8 +3,13 @@
#include "Application.h" #include "Application.h"
#include "common.h" #include "common.h"
extern uint32_t FaultCode_Data[254] ; #define FualtCodeMax 72
extern uint32_t FaultCode_Data[FualtCodeMax] ;
extern uint8_t FaultCode_Number; extern uint8_t FaultCode_Number;
uint8_t FaultCode_Compare(uint32_t FaultCode, uint32_t* CodeList, uint8_t len); uint8_t FaultCode_Compare(uint32_t FaultCode, uint32_t* CodeList, uint8_t len);
void ECU_FaultCode_Processing_Service ( void ); void ECU_FaultCode_Processing_Service ( void );
//void Fault_Code_Sort(void);
extern void Fault_Code_Receive(uint8_t CopyData[]);
static void Fault_Code_App_SortNByte(uint32_t *SortData, uint8_t len);
static void Fault_Code_App_Swap(uint32_t *pData1, uint32_t *pData2);
#endif #endif
\ No newline at end of file
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
uint8_t DTC_DISCount = 0; uint8_t DTC_DISCount = 0;
uint32_t Current_DTC_CODE = 0; uint32_t Current_DTC_CODE = 0;
uint32_t Current_DTC_CODE_BACK = 0;
uint8_t DTC_DISTimer = 0; uint8_t DTC_DISTimer = 0;
/*数字显示数组*/ /*0, 1 2 3 4 5 6 7 8 9 null - P A b C d E F*/ /*数字显示数组*/ /*0, 1 2 3 4 5 6 7 8 9 null - P A b C d E F*/
const uint8_t SEG_DISPLAY_NUMBER0[] = {0x3Fu, 0x06u, 0x5Bu, 0x4Fu, 0x66u, 0x6Du, 0x7Du, 0x07u, 0x7Fu, 0x6Fu, 0x00, 0x40, 0x73, 0x77, 0x7C, 0x39, 0x5E, 0x79, 0x71}; const uint8_t SEG_DISPLAY_NUMBER0[] = {0x3Fu, 0x06u, 0x5Bu, 0x4Fu, 0x66u, 0x6Du, 0x7Du, 0x07u, 0x7Fu, 0x6Fu, 0x00, 0x40, 0x73, 0x77, 0x7C, 0x39, 0x5E, 0x79, 0x71};
...@@ -2470,7 +2471,8 @@ void SEG_SET_ODO_TRIP_FAULTCODE_TCS_DIS(uint8_t m_Uint, uint32_t m_NUM_ODO, uint ...@@ -2470,7 +2471,8 @@ void SEG_SET_ODO_TRIP_FAULTCODE_TCS_DIS(uint8_t m_Uint, uint32_t m_NUM_ODO, uint
{ {
SEG_SET_DTC_NUM(0); SEG_SET_DTC_NUM(0);
DTC_DISTimer = 0; DTC_DISTimer = 0;
Current_DTC_CODE = 0; Current_DTC_CODE = 0;
Current_DTC_CODE_BACK = 0;
} }
else else
{ {
...@@ -2485,6 +2487,7 @@ void SEG_SET_ODO_TRIP_FAULTCODE_TCS_DIS(uint8_t m_Uint, uint32_t m_NUM_ODO, uint ...@@ -2485,6 +2487,7 @@ void SEG_SET_ODO_TRIP_FAULTCODE_TCS_DIS(uint8_t m_Uint, uint32_t m_NUM_ODO, uint
Current_DTC_CODE = FaultCode_Data[DTC_DISCount] ; Current_DTC_CODE = FaultCode_Data[DTC_DISCount] ;
DTC_DISTimer = 0; DTC_DISTimer = 0;
} }
Current_DTC_CODE_BACK = Current_DTC_CODE;
} }
else if (DTC_DISTimer >= 100) else if (DTC_DISTimer >= 100)
{ {
...@@ -2495,6 +2498,11 @@ void SEG_SET_ODO_TRIP_FAULTCODE_TCS_DIS(uint8_t m_Uint, uint32_t m_NUM_ODO, uint ...@@ -2495,6 +2498,11 @@ void SEG_SET_ODO_TRIP_FAULTCODE_TCS_DIS(uint8_t m_Uint, uint32_t m_NUM_ODO, uint
} }
Current_DTC_CODE = FaultCode_Data[DTC_DISCount] ; Current_DTC_CODE = FaultCode_Data[DTC_DISCount] ;
DTC_DISTimer = 0; DTC_DISTimer = 0;
if(Current_DTC_CODE == Current_DTC_CODE_BACK)
{
DTC_DISCount ++ ;
Current_DTC_CODE = FaultCode_Data[DTC_DISCount] ;
}
} }
SEG_SET_DTC_NUM(Current_DTC_CODE); SEG_SET_DTC_NUM(Current_DTC_CODE);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment