Commit a905affa authored by 李向行's avatar 李向行

🐞 fix:修改PGN判断,增加对应PGN多包掉线

parent b7155f76
...@@ -2,6 +2,9 @@ ...@@ -2,6 +2,9 @@
#include "CAN_1939.h" #include "CAN_1939.h"
#include "CAN_1939_user.h" #include "CAN_1939_user.h"
CAN_1939_uint16_t g_u1618ECFF03TimeoutCount = 0U;
CAN_1939_uint16_t g_u1618ECFF00TimeoutCount = 0U;
const CAN1939_Attribute_st_t stCAN1939Attribute [ CAN1939_SA_MAX ] = { const CAN1939_Attribute_st_t stCAN1939Attribute [ CAN1939_SA_MAX ] = {
{0x18ECFF03, 0x18EBFF03, 5000}, {0x18ECFF03, 0x18EBFF03, 5000},
{0x18ECFF00, 0x18EBFF00, 5000}, {0x18ECFF00, 0x18EBFF00, 5000},
...@@ -54,27 +57,35 @@ void CAN_1939_Process(void) ...@@ -54,27 +57,35 @@ void CAN_1939_Process(void)
{ {
if ( CAN_J1939_Get_Update_Flag(CAN1939_SA_03) == 2UL ) if ( CAN_J1939_Get_Update_Flag(CAN1939_SA_03) == 2UL )
{ {
CAN_1939_uint8_t u8DataLenBuf = CAN_J1939_Get_Message_Len(CAN1939_SA_03); if(0xFECA == CAN_J1939_Get_Message_PGN(CAN1939_SA_03))
CAN_1939_uint8_t *pu8CAN1939DataBuf = CAN_J1939_Get_Message_Content(CAN1939_SA_03);
if ( u8DataLenBuf > 8 )
{ {
u8DataLenBuf = (u8DataLenBuf - 2) / 4; CAN_1939_uint8_t u8DataLenBuf = CAN_J1939_Get_Message_Len(CAN1939_SA_03);
CAN_1939_uint8_t *pu8CAN1939DataBuf = CAN_J1939_Get_Message_Content(CAN1939_SA_03);
u8RecDataLamp03 [ 0 ] = *pu8CAN1939DataBuf; if ( u8DataLenBuf > 8 )
u8RecDataLamp03 [ 1 ] = *(pu8CAN1939DataBuf + 1); {
pu8CAN1939DataBuf += 2; u8DataLenBuf = (u8DataLenBuf - 2) / 4;
u8DTC0XCEF0E0xx = CAN_1939_DTC_Check(0xCEF0E000, ( DTC_1939 * )(pu8CAN1939DataBuf), u8DataLenBuf); u8RecDataLamp03 [ 0 ] = *pu8CAN1939DataBuf;
u8DTC0XB9F0E0xx = CAN_1939_DTC_Check(0XB9F0E000, ( DTC_1939 * )(pu8CAN1939DataBuf), u8DataLenBuf); u8RecDataLamp03 [ 1 ] = *(pu8CAN1939DataBuf + 1);
u8DTC0XC1F0E0xx = CAN_1939_DTC_Check(0XC1F0E000, ( DTC_1939 * )(pu8CAN1939DataBuf), u8DataLenBuf); pu8CAN1939DataBuf += 2;
u8DTC0X66F1E0xx = CAN_1939_DTC_Check(0X66F1E000, ( DTC_1939 * )(pu8CAN1939DataBuf), u8DataLenBuf);
u8DTC0XB8F0E0xx = CAN_1939_DTC_Check(0XB8F0E000, ( DTC_1939 * )(pu8CAN1939DataBuf), u8DataLenBuf); u8DTC0XCEF0E0xx = CAN_1939_DTC_Check(0xCEF0E000, ( DTC_1939 * )(pu8CAN1939DataBuf), u8DataLenBuf);
u8DTC0XCCF0E0xx = CAN_1939_DTC_Check(0XCCF0E000, ( DTC_1939 * )(pu8CAN1939DataBuf), u8DataLenBuf); u8DTC0XB9F0E0xx = CAN_1939_DTC_Check(0XB9F0E000, ( DTC_1939 * )(pu8CAN1939DataBuf), u8DataLenBuf);
u8DTC0XCD160Bxx = CAN_1939_DTC_Check(0XCD160B00, ( DTC_1939 * )(pu8CAN1939DataBuf), u8DataLenBuf); u8DTC0XC1F0E0xx = CAN_1939_DTC_Check(0XC1F0E000, ( DTC_1939 * )(pu8CAN1939DataBuf), u8DataLenBuf);
u8DTC0X66F1E0xx = CAN_1939_DTC_Check(0X66F1E000, ( DTC_1939 * )(pu8CAN1939DataBuf), u8DataLenBuf);
u8DTC0XB8F0E0xx = CAN_1939_DTC_Check(0XB8F0E000, ( DTC_1939 * )(pu8CAN1939DataBuf), u8DataLenBuf);
u8DTC0XCCF0E0xx = CAN_1939_DTC_Check(0XCCF0E000, ( DTC_1939 * )(pu8CAN1939DataBuf), u8DataLenBuf);
u8DTC0XCD160Bxx = CAN_1939_DTC_Check(0XCD160B00, ( DTC_1939 * )(pu8CAN1939DataBuf), u8DataLenBuf);
}
else
{
u8DataLenBuf = 0;
}
g_u1618ECFF03TimeoutCount = 0;
} }
else else
{ {
u8DataLenBuf = 0; CAN_J1939_18ECFF03_Timeout();
} }
CAN_J1939_Clear_Update_Flag(CAN1939_SA_03); CAN_J1939_Clear_Update_Flag(CAN1939_SA_03);
...@@ -95,23 +106,31 @@ void CAN_1939_Process(void) ...@@ -95,23 +106,31 @@ void CAN_1939_Process(void)
if ( CAN_J1939_Get_Timeout_Flag(CAN1939_SA_00) ) if ( CAN_J1939_Get_Timeout_Flag(CAN1939_SA_00) )
{ {
if ( CAN_J1939_Get_Update_Flag(CAN1939_SA_00) == 2UL ) if ( CAN_J1939_Get_Update_Flag(CAN1939_SA_00) == 2UL )
{ {
CAN_1939_uint8_t u8DataLenBuf = CAN_J1939_Get_Message_Len(CAN1939_SA_00); if(0xFECA == CAN_J1939_Get_Message_PGN(CAN1939_SA_00))
CAN_1939_uint8_t *pu8CAN1939DataBuf = CAN_J1939_Get_Message_Content(CAN1939_SA_00);
if ( u8DataLenBuf > 8 )
{ {
u8DataLenBuf = (u8DataLenBuf - 2) / 4; CAN_1939_uint8_t u8DataLenBuf = CAN_J1939_Get_Message_Len(CAN1939_SA_00);
CAN_1939_uint8_t *pu8CAN1939DataBuf = CAN_J1939_Get_Message_Content(CAN1939_SA_00);
u8RecDataLamp00 [ 0 ] = *pu8CAN1939DataBuf; if ( u8DataLenBuf > 8 )
u8RecDataLamp00 [ 1 ] = *(pu8CAN1939DataBuf + 1); {
pu8CAN1939DataBuf += 2; u8DataLenBuf = (u8DataLenBuf - 2) / 4;
u8RecDataLamp00 [ 0 ] = *pu8CAN1939DataBuf;
u8RecDataLamp00 [ 1 ] = *(pu8CAN1939DataBuf + 1);
pu8CAN1939DataBuf += 2;
}
else
{
u8DataLenBuf = 0;
}
g_u1618ECFF00TimeoutCount = 0;
} }
else else
{ {
u8DataLenBuf = 0; CAN_J1939_18ECFF00_Timeout();
} }
CAN_J1939_Clear_Update_Flag(CAN1939_SA_00); CAN_J1939_Clear_Update_Flag(CAN1939_SA_00);
} }
} }
...@@ -182,3 +201,53 @@ CAN_1939_uint8_t Get_CAN_CH0_ID_18EBFF00_Sig_AmberWarnLamp(void) ...@@ -182,3 +201,53 @@ CAN_1939_uint8_t Get_CAN_CH0_ID_18EBFF00_Sig_AmberWarnLamp(void)
{ {
return ((u8RecDataLamp00 [ 0 ] >> 2) & 0X03U); return ((u8RecDataLamp00 [ 0 ] >> 2) & 0X03U);
} }
void CAN_J1939_FECA_Timeout_Count(CAN_1939_uint8_t taskTime)
{
if (g_u1618ECFF03TimeoutCount <= (0xFFFF - taskTime))
{
g_u1618ECFF03TimeoutCount += taskTime;
}
if (g_u1618ECFF00TimeoutCount <= (0xFFFF - taskTime))
{
g_u1618ECFF00TimeoutCount += taskTime;
}
}
/*返回值:0--报文超时,1--报文在线*/
CAN_1939_uint8_t CAN_J1939_18ECFF03_Timeout(void)
{
CAN_1939_uint8_t u8Timeout = 1U;
if (g_u1618ECFF00TimeoutCount >= 5000U)
{
u8Timeout = 0U;
//添加掉线处理
u8RecDataLamp03[0] = 0UL;
u8RecDataLamp03[1] = 0UL;
u8DTC0XCEF0E0xx = 0UL;
u8DTC0XB9F0E0xx = 0UL;
u8DTC0XC1F0E0xx = 0UL;
u8DTC0X66F1E0xx = 0UL;
u8DTC0XB8F0E0xx = 0UL;
u8DTC0XCCF0E0xx = 0UL;
u8DTC0XCD160Bxx = 0UL;
}
return u8Timeout;
}
CAN_1939_uint8_t CAN_J1939_18ECFF00_Timeout(void)
{
CAN_1939_uint8_t u8Timeout = 1U;
if (g_u1618ECFF00TimeoutCount >= 5000U)
{
u8Timeout = 0U;
//添加掉线处理
u8RecDataLamp00[0] = 0UL;
u8RecDataLamp00[1] = 0UL;
}
return u8Timeout;
}
...@@ -28,5 +28,10 @@ extern CAN_1939_uint8_t Get_CAN_CH0_ID_18EBFF03_Sig_AT_RedStopLamp(void); ...@@ -28,5 +28,10 @@ extern CAN_1939_uint8_t Get_CAN_CH0_ID_18EBFF03_Sig_AT_RedStopLamp(void);
extern CAN_1939_uint8_t Get_CAN_CH0_ID_18EBFF00_Sig_RedStopLamp(void); extern CAN_1939_uint8_t Get_CAN_CH0_ID_18EBFF00_Sig_RedStopLamp(void);
extern CAN_1939_uint8_t Get_CAN_CH0_ID_18EBFF00_Sig_AmberWarnLamp(void); extern CAN_1939_uint8_t Get_CAN_CH0_ID_18EBFF00_Sig_AmberWarnLamp(void);
extern void CAN_J1939_FECA_Timeout_Count(CAN_1939_uint8_t taskTime);
extern CAN_1939_uint8_t CAN_J1939_18ECFF03_Timeout(void);
extern CAN_1939_uint8_t CAN_J1939_18ECFF00_Timeout(void);
#endif #endif
...@@ -137,6 +137,7 @@ void Sys_Run_Mode_20ms_Tasks_Group0(void) ...@@ -137,6 +137,7 @@ void Sys_Run_Mode_20ms_Tasks_Group0(void)
Data_Vehicle_Speed_Processing_Service(); Data_Vehicle_Speed_Processing_Service();
CAN_J1939_Time_Handle(20U); CAN_J1939_Time_Handle(20U);
CAN_1939_Process(); CAN_1939_Process();
CAN_J1939_FECA_Timeout_Count(20u);
} }
......
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