Commit 5bffea87 authored by hu's avatar hu

增加故障码收发协议

parent e53f6b3e
...@@ -252,3 +252,14 @@ ...@@ -252,3 +252,14 @@
.\K_BUS\kwp2000_service.h .\K_BUS\kwp2000_service.h
.\K_BUS\kwp2000_tp.c .\K_BUS\kwp2000_tp.c
.\K_BUS\kwp2000_tp.h .\K_BUS\kwp2000_tp.h
.\UDS_M\app_Service.c
.\UDS_M\app_Service.h
.\UDS_M\app_ServiceProc.c
.\UDS_M\app_ServiceProc.h
.\UDS_M\Link_Layer.c
.\UDS_M\Link_Layer.h
.\UDS_M\TP_Layer.c
.\UDS_M\TP_Layer.h
.\UDS_M\UDS_CFG.h
.\UDS_M\UDS_def.h
.\UDS_M\uds_includes.h
...@@ -215,6 +215,7 @@ primaryTarget=v800_standalone.tgt ...@@ -215,6 +215,7 @@ primaryTarget=v800_standalone.tgt
-I..\source\Application\UDS\ -I..\source\Application\UDS\
-I..\source\Application\UDS\TP -I..\source\Application\UDS\TP
-I..\source\Application\K_BUS -I..\source\Application\K_BUS
-I..\source\Application\UDS_M
-MD -MD
-Mn -Mn
......
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
#include "GUI.h" #include "GUI.h"
#include "Data_Fuel_User.h" #include "Data_Fuel_User.h"
#include "app_Service.h"
#include "UART.h" #include "UART.h"
#include "kwp2000_tp.h" #include "kwp2000_tp.h"
#include "kwp2000_protocol.h" #include "kwp2000_protocol.h"
...@@ -219,7 +220,7 @@ void Power_IG_OFF_Init(void) ...@@ -219,7 +220,7 @@ void Power_IG_OFF_Init(void)
void Power_IG_ON_Init(void) void Power_IG_ON_Init(void)
{ {
Kwp2000_Init(); Kwp2000_Init();
DiagnosisInit_main();
Data_ODO_Clear_KL15Init(); Data_ODO_Clear_KL15Init();
Telltales_KL15_Init(); Telltales_KL15_Init();
Line_In_KL15_ON_Init(); Line_In_KL15_ON_Init();
......
...@@ -1156,4 +1156,4 @@ void Common_SetTXNum_18033317(void) ...@@ -1156,4 +1156,4 @@ void Common_SetTXNum_18033317(void)
uint8_t Common_GetTXNum_18033317(void) uint8_t Common_GetTXNum_18033317(void)
{ {
return TXNum_18033317; return TXNum_18033317;
} }
\ No newline at end of file
...@@ -65,4 +65,9 @@ void Id18033317_Send_Service(void); ...@@ -65,4 +65,9 @@ void Id18033317_Send_Service(void);
void MSG_18021733_REC_COPY(uint8_t copy[]); void MSG_18021733_REC_COPY(uint8_t copy[]);
void DoCan_Data_Indicatiom ( uint32_t Identifier, uint8_t dlc, uint8_t pData[] );
void DoCAN_GetEngineDUC_N_PDU ( void );
#endif #endif
\ No newline at end of file
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include "RTE_CAN.h" #include "RTE_CAN.h"
#include "CAN_Communication_Matrix.h" #include "CAN_Communication_Matrix.h"
#include "CAN_FUNC.h"
#include "CAN_Lib.h" #include "CAN_Lib.h"
//#include "CAN_Signal_Tx.h" //#include "CAN_Signal_Tx.h"
#include "AlarmGeneralFilie.h" #include "AlarmGeneralFilie.h"
...@@ -14,6 +15,8 @@ ...@@ -14,6 +15,8 @@
#include "Watchdog.h" #include "Watchdog.h"
#include "RSCAN.h" #include "RSCAN.h"
#include "Link_Layer.h"
static uint16_t Can_Init_Lock = 0U; static uint16_t Can_Init_Lock = 0U;
...@@ -144,14 +147,14 @@ void Can_Read_Msg(uint32_t m_id, uint8_t m_dlc, uint8_t m_Msg[]) ...@@ -144,14 +147,14 @@ void Can_Read_Msg(uint32_t m_id, uint8_t m_dlc, uint8_t m_Msg[])
void Can_Read_Msg2(uint32_t m_id, uint8_t m_dlc, uint8_t m_Msg[]) void Can_Read_Msg2(uint32_t m_id, uint8_t m_dlc, uint8_t m_Msg[])
{ {
ReceivedMsg(m_id, m_dlc); if (m_id == DIAG_ID_Rx_PHY)
//Co_Can_Buff_Set(Co_Can_ConvertSubID(m_id), m_dlc, m_Msg);
if ((m_id == DIAG_ID_Rx_FUN) || (m_id == DIAG_ID_Rx_PHY))
{ {
DoCAN_L_Data_Indication(m_id, m_dlc, m_Msg); LK_Link_main(DIAG_ID_Rx_PHY, (uint8_t*)m_Msg, (m_dlc & 0x0f));
} }
//if ((m_id == DIAG_ID_Rx_FUN) || (m_id == DIAG_ID_Rx_PHY))
//{
// DoCAN_L_Data_Indication(m_id, m_dlc, m_Msg);
//}
} }
void Can_Confirm(uint32_t Identifier, uint8_t TransferStatus) void Can_Confirm(uint32_t Identifier, uint8_t TransferStatus)
......
#define GLOBALS_LK_DIAGNO
#include "Link_Layer.h"
#include <string.h>
volatile _LinkData LinkDataBuf[2];
volatile _LinkData LinkData;
/*-------------------------------------------------------------------------
* Function Name : LK_Link_main
* Description :
* Input :
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
void LK_Link_main(uint16_t PDU_addr, uint8_t *CAN_BufAddr, uint8_t dlc)
{
if (LinkDataBuf[0].TransferStatus == empoty)
{
LinkDataBuf[0].Identifier = PDU_addr; //
(void)memcpy((uint8_t *)&LinkDataBuf[0].Data[0], CAN_BufAddr, dlc);
LinkDataBuf[0].DLC = dlc;
LinkDataBuf[0].TransferStatus = full;
}
else if (LinkDataBuf[1].TransferStatus == empoty)
{
LinkDataBuf[1].Identifier = PDU_addr;
(void)memcpy((uint8_t *)&LinkDataBuf[1].Data[0], CAN_BufAddr, dlc);
LinkDataBuf[1].DLC = dlc;
LinkDataBuf[1].TransferStatus = full;
}
}
/*-------------------------------------------------------------------------
* Function Name : LK_FillMsg
* Description :
* Input :
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
void LK_FillMsg(uint8_t *data, uint8_t FillData, uint8_t dlc)
{
uint8_t i;
for (i = dlc; i < 8; i++)
{
*(data + i) = FillData;
}
}
#ifdef GLOBALS_LK_DIAGNO
#define EXTERN_LK_DIAGNO
#else
#define EXTERN_LK_DIAGNO extern
#endif
#include "uds_includes.h"
#ifndef LK_DIAGNO_H_
#define LK_DIAGNO_H_
EXTERN_LK_DIAGNO volatile _LinkData LinkDataBuf[2];
EXTERN_LK_DIAGNO volatile _LinkData LinkData;
EXTERN_LK_DIAGNO void LK_FillMsg(uint8_t *data, uint8_t FillData, uint8_t dlc);
EXTERN_LK_DIAGNO void LK_Link_main(uint16_t PDU_addr, uint8_t *CAN_BufAddr, uint8_t dlc);
#endif /* LK_DIAGNO_H_ */
#define GLOBALS_TP_DIAGNO
#include "Link_Layer.h"
#include "TP_Layer.h"
#include "UDS_def.h"
#include "UDS_CFG.H"
#include "app_Service.h"
#include "app_ServiceProc.h"
#include <string.h>
#include "RTE_CAN.h"
volatile _N_USData N_US_R_MultiData;
volatile _N_USData N_US_S_MultiData; //仪表外发的数据信息-multi
volatile _N_RSPData N_RSPData; //仪表外发的数据信息
volatile _N_US_Data_FF N_US_R_Data_FF;
volatile _N_US_Data_FF N_US_S_Data_FF;
volatile _N_USSFData N_USSFData[2];
volatile uint16_t N_RecLen;
volatile uint8_t g_bReturn;
/*-------------------------------------------------------------------------
* Function Name : TP_Buffer_handle
* Description :
* Input :
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
void TP_Buffer_handle(void)
{
if (LinkDataBuf[0].TransferStatus == full)
{
(void)memcpy((uint8_t *)&LinkData, (uint8_t *)&LinkDataBuf[0], sizeof(_LinkData));
LinkDataBuf[0].TransferStatus = empoty;
}
else if (LinkDataBuf[1].TransferStatus == full)
{
(void)memcpy((uint8_t *)&LinkData, (uint8_t *)&LinkDataBuf[1], sizeof(_LinkData));
LinkDataBuf[1].TransferStatus = empoty;
}
TP_AbnormalInResSF_handle();
TP_AbnormalInReqFF_handle();
TP_UnknownlPDU_handle();
TP_AbnormalInResCF_handle();
TP_AbnormalInReqFC_handle();
TP_AbnormalInResFC_handle();
TP_TooShortDLC_handle((_LinkData *)&LinkData);
}
/*-------------------------------------------------------------------------
* Function Name : TP_TooShortDLC_handle
* Description :
* Input :
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
void TP_TooShortDLC_handle(_LinkData *LK_Data)
{
uint16_t len;
uint8_t CtrlMask;
CtrlMask = LK_Data->Data[0] & 0xf0;
len = LK_Data->Data[0] & 0x0F;
if (CtrlMask == SingleFrame)
{
if (LK_Data->DLC <= len)
{
LK_Data->TransferStatus = empoty;
}
}
if (CtrlMask == FirstFrame)
{
if (LK_Data->DLC != 8)
{
LK_Data->TransferStatus = empoty;
}
}
if (CtrlMask == FlowControlFrame)
{
if (LK_Data->DLC < 3)
{
LK_Data->TransferStatus = empoty;
N_US_R_MultiData.ind.N_Result = N_WRONG_SN_9;
}
}
if (CtrlMask == ConsecutiveFrame)
{
if ((N_US_R_MultiData.ind.Length / 7) == len)
{
len = len - 1;
if ((len * 7 + 5 + LK_Data->DLC) < N_US_R_MultiData.ind.Length)
{
LK_Data->TransferStatus = empoty;
N_US_R_MultiData.ind.N_Result = N_WRONG_SN_9;
}
}
else
{
if (LK_Data->DLC < 7)
{
LK_Data->TransferStatus = empoty;
N_US_R_MultiData.ind.N_Result = N_WRONG_SN_9;
}
}
}
}
/*-------------------------------------------------------------------------
* Function Name : TP_UnknownlPDU_handle
* Description :
* Input :
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
void TP_AbnormalInResSF_handle(void)
{
uint8_t CtrlMask;
if ((N_US_S_MultiData.ind.N_Result == N_OK_2) && (N_US_S_Data_FF.ind.N_PCI) && (LinkData.TransferStatus == full))
{
CtrlMask = LinkData.Data[0] & 0x30;
if (CtrlMask == FirstFrame)
{
LinkData.TransferStatus = empoty;
}
if (CtrlMask == ConsecutiveFrame)
{
LinkData.TransferStatus = empoty;
}
if (CtrlMask == SingleFrame)
{
LinkData.TransferStatus = empoty;
}
}
}
/*-------------------------------------------------------------------------
* Function Name : TP_UnknownlPDU_handle
* Description :
* Input :
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
void TP_UnknownlPDU_handle(void)
{
uint8_t CtrlMask;
CtrlMask = LinkData.Data[0] & 0xC0;
if (N_US_S_MultiData.ind.N_Result == N_OK_2)
{
if (CtrlMask)
{
LinkData.TransferStatus = empoty;
}
}
if ((N_US_R_MultiData.ind.N_Result == WAIT) || (N_US_R_MultiData.ind.N_Result == CTS))
{
if ((CtrlMask) && (LinkData.TransferStatus == full))
{
LinkData.TransferStatus = empoty;
}
}
}
/*-------------------------------------------------------------------------
* Function Name : TP_AbnormalInReqFF_handle
* Description :
* Input :
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
void TP_AbnormalInReqFF_handle(void)
{
uint8_t CtrlMask;
CtrlMask = LinkData.Data[0] & 0xf0;
if ((CtrlMask == FirstFrame) && (LinkData.TransferStatus == full))
{
if (N_US_R_MultiData.ind.N_Result == CTS)
{
N_US_R_MultiData.ind.N_Result = STATE0;
N_US_R_Data_FF.ind.pos = 0;
N_US_R_Data_FF.ind.N_PCI = 0;
N_US_R_Data_FF.ind.N_RecSN_L = 0;
}
}
}
/*-------------------------------------------------------------------------
* Function Name : TP_AbnormalInResCF_handle
* Description :
* Input :
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
void TP_AbnormalInResCF_handle(void)
{
if (N_US_S_MultiData.ind.N_Result == N_OK_2)
{
if (((LinkData.Data[0] & 0xf0) == ConsecutiveFrame) && (LinkData.TransferStatus == full))
{
LinkData.TransferStatus = empoty;
}
}
}
/*-------------------------------------------------------------------------
* Function Name : TP_AbnormalInReqFC_handle
* Description :
* Input :
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
void TP_AbnormalInReqFC_handle(void)
{
if (N_US_R_MultiData.ind.N_Result == CTS)
{
if (((LinkData.Data[0] & 0xf0) == FlowControlFrame) && (LinkData.TransferStatus == full))
{
LinkData.TransferStatus = empoty;
}
}
}
/*-------------------------------------------------------------------------
* Function Name : TP_AbnormalInResFC_handle
* Description :
* Input :
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
void TP_AbnormalInResFC_handle(void)
{
if (N_US_S_Data_FF.ind.N_PCI == ConsecutiveFrame)
{
if ((LinkData.TransferStatus == full) && ((LinkData.Data[0] & 0x30) == FlowControlFrame))
{
LinkData.TransferStatus = empoty;
}
}
}
/*-------------------------------------------------------------------------
* Function Name : TP_NormalRecFC_handle
* Description :
* Input :
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
void TP_NormalRecFC_handle(void)
{
uint8_t CtrlMask;
uint8_t FC_State;
CtrlMask = LinkData.Data[0] & 0xF0;
if (N_US_S_Data_FF.ind.N_PCI == FC_WAIT)
{
if (CtrlMask == FlowControlFrame)
{
FC_State = LinkData.Data[0] & 0x0f;
if (FC_State == 1)
{
N_US_S_Data_FF.ind.N_PCI = FC_WAIT;
TP_SetBsTimer(N_Bs, (_DiagClock *)&DiagClock);
}
if (FC_State == 2)
{
N_US_S_MultiData.ind.N_Result = OVFLW;
}
if ((FC_State >= 3) && (FC_State <= 0x0F))
{
N_US_S_MultiData.ind.N_Result = N_INVALID_FS_8;
}
if (FC_State == 0)
{
N_US_S_MultiData.ind.N_Result = N_OK_2;
N_US_S_Data_FF.ind.N_PCI = ConsecutiveFrame;
N_US_S_Data_FF.ind.N_FC_Num = 0;
N_US_S_Data_FF.ind.N_BS = LinkData.Data[1];
N_US_S_Data_FF.ind.N_BS_CNT = 0;
if ((LinkData.Data[2] <= 0x7F))
{
DiagnoCtl.N_STmin_0 = LinkData.Data[2] + 1;
}
if ((LinkData.Data[2] >= 0xF1) && (LinkData.Data[2] <= 0xF9))
{
DiagnoCtl.N_STmin_0 = 1;
}
if ((LinkData.Data[2] >= 0xFA) && (LinkData.Data[2] <= 0xFF))
{
DiagnoCtl.N_STmin_0 = 128;
}
DiagClock.TT_BsEnable = 0;
TP_SetSTminTimer(DiagnoCtl.N_STmin_0, (_DiagClock *)&DiagClock);
}
}
}
}
/*-------------------------------------------------------------------------
* Function Name : TP_NormalSendFC_Fun
* Description :
* Input :
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
void TP_NormalSendFC_Fun(void)
{
if (N_US_R_MultiData.ind.N_Result == WAIT)
{
N_RSPData.ind.N_Result = N_OK_2;
N_RSPData.ind.len = 3;
N_RSPData.ind.MsgData[1] = DiagnoCtl.N_REV_MAX_BS;
if (N_US_R_MultiData.ind.Length <= MaxBuff)
{
N_RSPData.ind.MsgData[0] = 0x30;
N_RSPData.ind.MsgData[2] = 0x0A;
N_US_R_MultiData.ind.N_Result = CTS;
TP_SetCrTimer(N_Cr, (_DiagClock *)&DiagClock);
}
else
{
N_RSPData.ind.MsgData[0] = 0x32;
N_RSPData.ind.MsgData[2] = 0x32;
N_US_R_MultiData.ind.N_Result = STATE0;
}
}
if (N_US_R_MultiData.ind.N_Result == CTS)
{
if (TP_CrTimerOver((_DiagClock *)&DiagClock))
{
N_US_R_MultiData.ind.N_Result = N_TIMEOUT_Bs_6;
}
}
}
/*-------------------------------------------------------------------------
* Function Name : TP_ReciveSF_handle
* Description :
* Input :
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
void TP_ReciveSF_handle(void)
{
uint16_t len;
if ((LinkData.Data[0] & 0xf0) == SingleFrame)
{
len = LinkData.Data[0] & 0x0f;
if ((len > 0) && (len <= 7))
{
if ((Exct_USData.ind.N_Result == N_OK_2) || (N_USSFData[0].ind.N_Result == N_OK_2))
{
N_USSFData[1].ind.Length = len;
N_USSFData[1].ind.N_TAtype = LinkData.Identifier;
N_USSFData[1].ind.N_PCI = SingleFrame;
N_USSFData[1].ind.N_Result = N_OK_2;
(void)App_CopyRam((uint8_t *) & (N_USSFData[1].ind.MsgData[0]), (uint8_t *)&LinkData.Data[1], 7);
}
else
{
N_USSFData[0].ind.Length = len;
N_USSFData[0].ind.N_TAtype = LinkData.Identifier;
N_USSFData[0].ind.N_PCI = SingleFrame;
N_USSFData[0].ind.N_Result = N_OK_2;
(void)App_CopyRam((uint8_t *) & (N_USSFData[0].ind.MsgData[0]), (uint8_t *)&LinkData.Data[1], 7);
}
}
}
}
/*-------------------------------------------------------------------------
* Function Name : TP_ReciveMultiF_handle
* Description :
* Input :
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
void TP_ReciveMultiF_handle(void)
{
uint16_t wPos = 0;
uint16_t SN = 0;
uint8_t len = 0;
if (((LinkData.Data[0] & 0xf0) == FirstFrame) && (N_US_R_MultiData.ind.N_Result == STATE0))
{
N_US_R_MultiData.ind.Length = LinkData.Data[0] & 0x0F;
N_US_R_MultiData.ind.Length <<= 8;
N_US_R_MultiData.ind.Length |= LinkData.Data[1];
if (N_US_R_MultiData.ind.Length >= 8)
{
N_US_R_MultiData.ind.N_TAtype = LinkData.Identifier;
N_US_R_Data_FF.ind.N_PCI = FirstFrame;
N_US_R_Data_FF.ind.N_RecSN_L = 0x0001; //
(void)App_CopyRam((uint8_t *)&N_US_R_MultiData.ind.MsgData[0], (uint8_t *)&LinkData.Data[2], 6);
N_US_R_MultiData.ind.N_Result = WAIT;
N_US_R_Data_FF.ind.N_SID = LinkData.Data[2];
}
else
{
N_US_R_Data_FF.ind.N_PCI = 0;
}
N_RecLen = 0;
}
if ((LinkData.Data[0] & 0xf0) == ConsecutiveFrame)
{
N_US_R_Data_FF.ind.N_PCI = ConsecutiveFrame;
}
if ((N_US_R_Data_FF.ind.N_PCI == ConsecutiveFrame) && (N_US_R_MultiData.ind.N_Result == CTS))
{
TP_SetCrTimer(N_Cr, (_DiagClock *)&DiagClock);
N_US_R_Data_FF.ind.N_PCI = 0;
SN = LinkData.Data[0] & 0x0F;
wPos = (1 << SN);
if (N_US_R_Data_FF.ind.N_RecSN_L & wPos)
{
N_US_R_MultiData.ind.N_Result = N_WRONG_SN_9;
}
else
{
N_US_R_Data_FF.ind.N_RecSN_L |= wPos;
}
if (N_US_R_MultiData.ind.Length <= 111)
{
N_RecLen = TP_CalMsgLen(N_US_R_Data_FF.ind.N_RecSN_L, 0);
if (SN == 0)
{
N_US_R_MultiData.ind.N_Result = N_WRONG_SN_9;
}
}
else
{
if (N_RecLen == 0)
{
len = TP_CalMsgLen(N_US_R_Data_FF.ind.N_RecSN_L, 0);
}
else
{
len = TP_CalMsgLen(N_US_R_Data_FF.ind.N_RecSN_L, 1);
}
if (N_US_R_Data_FF.ind.N_RecSN_L == 0xFFFF)
{
N_RecLen += len;
len = 0;
N_US_R_Data_FF.ind.N_RecSN_L = 0;
}
}
if (SN > 0)
{
SN -= 1;
}
(void)App_CopyRam((uint8_t *)&N_US_R_MultiData.ind.MsgData[(N_RecLen + len) - 7], (uint8_t *)&LinkData.Data[1], 7);
if ((N_RecLen + len) >= N_US_R_MultiData.ind.Length)
{
N_US_R_MultiData.ind.N_Result = N_OK_2;
DiagClock.TT_CrEnable = 0;
N_US_R_Data_FF.ind.N_RecSN_L = 0;
N_RecLen = 0;
}
}
}
/*-------------------------------------------------------------------------
* Function Name : TP_TransmitPDU 仪表诊断外发
* Description :
* Input :
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
void TP_TransmitPDU(void)
{
g_txCanMsg.id = ID_ResAddr;
_CAN_Msg canMag;
if (N_US_S_MultiData.ind.N_Result == N_OK_2) //no use
{
if (N_US_S_Data_FF.ind.N_PCI == 0)
{
g_txCanMsg.msg[0] = (uint8_t)N_US_S_MultiData.ind.Length;
(void)App_CopyRam((uint8_t *)&g_txCanMsg.msg[1], (uint8_t *)&N_US_S_MultiData.ind.MsgData[0], 7);
LK_FillMsg((uint8_t *)&g_txCanMsg.msg[0], N_FILL, N_US_S_MultiData.ind.Length + 1);
//g_bReturn = bsp_CANSendFrame(g_txCanMsg.id, txResNum, (uint8_t *)&g_txCanMsg.msg[0], 8);
canMag.MsgID = g_txCanMsg.id;
canMag.MsgDLC = 8u;
canMag.MsgPro = 0u;
canMag.MsgStd = 0u;
canMag.MsgRTR = 0u;
canMag.Msg[0u] = g_txCanMsg.msg[0u];
canMag.Msg[1u] = g_txCanMsg.msg[1u];
canMag.Msg[2u] = g_txCanMsg.msg[2u];
canMag.Msg[3u] = g_txCanMsg.msg[3u];
canMag.Msg[4u] = g_txCanMsg.msg[4u];
canMag.Msg[5u] = g_txCanMsg.msg[5u];
canMag.Msg[6u] = g_txCanMsg.msg[6u];
canMag.Msg[7u] = g_txCanMsg.msg[7u];
g_bReturn = Can_Write(&canMag);
N_US_S_MultiData.ind.N_Result = STATE0;
}
else
{
if (N_US_S_Data_FF.ind.N_PCI == FirstFrame)
{
N_US_S_Data_FF.ind.N_PCI = FC_WAIT;
g_txCanMsg.msg[0] = FirstFrame | (N_US_S_Data_FF.ind.Length >> 8);
g_txCanMsg.msg[1] = (uint8_t)N_US_S_Data_FF.ind.Length;
(void)App_CopyRam((uint8_t *)&g_txCanMsg.msg[2], (uint8_t *)&N_US_S_MultiData.ind.MsgData[0], 6);
//g_bReturn = bsp_CANSendFrame(g_txCanMsg.id, txResNum, (uint8_t *)&g_txCanMsg.msg[0], 8);
canMag.MsgID = g_txCanMsg.id;
canMag.MsgDLC = 8u;
canMag.MsgPro = 0u;
canMag.MsgStd = 0u;
canMag.MsgRTR = 0u;
canMag.Msg[0u] = g_txCanMsg.msg[0u];
canMag.Msg[1u] = g_txCanMsg.msg[1u];
canMag.Msg[2u] = g_txCanMsg.msg[2u];
canMag.Msg[3u] = g_txCanMsg.msg[3u];
canMag.Msg[4u] = g_txCanMsg.msg[4u];
canMag.Msg[5u] = g_txCanMsg.msg[5u];
canMag.Msg[6u] = g_txCanMsg.msg[6u];
canMag.Msg[7u] = g_txCanMsg.msg[7u];
g_bReturn = Can_Write(&canMag);
N_US_S_Data_FF.ind.N_SendSN = 0;
N_US_S_Data_FF.ind.pos = 6;
TP_SetBsTimer(N_Bs, (_DiagClock *)&DiagClock);
}
if (TP_STminTimerOver((_DiagClock *)&DiagClock))
{
if (N_US_S_Data_FF.ind.N_PCI == ConsecutiveFrame)
{
(void)App_CopyRam((uint8_t *)&g_txCanMsg.msg[1], (uint8_t *)&N_US_S_MultiData.ind.MsgData[N_US_S_Data_FF.ind.pos], 7);
N_US_S_Data_FF.ind.N_SendSN++;
N_US_S_Data_FF.ind.N_FC_Num++;
if (N_US_S_Data_FF.ind.N_BS)
{
N_US_S_Data_FF.ind.N_BS_CNT++;
if (N_US_S_Data_FF.ind.N_BS_CNT >= N_US_S_Data_FF.ind.N_BS)
{
N_US_S_Data_FF.ind.N_PCI = FC_WAIT;
TP_SetBsTimer(N_Bs, (_DiagClock *)&DiagClock);
}
}
if (N_US_S_Data_FF.ind.N_SendSN > 0x0F)
{
N_US_S_Data_FF.ind.N_SendSN = 0;
}
N_US_S_Data_FF.ind.pos += 7;
if (N_US_S_Data_FF.ind.pos >= N_US_S_Data_FF.ind.Length)
{
N_US_S_Data_FF.ind.N_PCI = 0;
N_US_S_MultiData.ind.N_Result = STATE0;
if (((N_US_S_Data_FF.ind.Length - 6) % 7) != 0)
{
LK_FillMsg((uint8_t *)&g_txCanMsg.msg[0], N_FILL, ((N_US_S_Data_FF.ind.Length - 6) % 7) + 1);
}
}
else
{
if (N_US_S_Data_FF.ind.N_BS)
{
if (N_US_S_Data_FF.ind.N_FC_Num == N_US_S_Data_FF.ind.N_BS)
{
N_US_S_Data_FF.ind.N_PCI = FC_WAIT;
TP_SetBsTimer(N_Bs, (_DiagClock *)&DiagClock);
}
}
}
g_txCanMsg.msg[0] = ConsecutiveFrame | N_US_S_Data_FF.ind.N_SendSN;
//g_bReturn = bsp_CANSendFrame(g_txCanMsg.id, txResNum, (uint8_t *)&g_txCanMsg.msg[0], 8);
canMag.MsgID = g_txCanMsg.id;
canMag.MsgDLC = 8u;
canMag.MsgPro = 0u;
canMag.MsgStd = 0u;
canMag.MsgRTR = 0u;
canMag.Msg[0u] = g_txCanMsg.msg[0u];
canMag.Msg[1u] = g_txCanMsg.msg[1u];
canMag.Msg[2u] = g_txCanMsg.msg[2u];
canMag.Msg[3u] = g_txCanMsg.msg[3u];
canMag.Msg[4u] = g_txCanMsg.msg[4u];
canMag.Msg[5u] = g_txCanMsg.msg[5u];
canMag.Msg[6u] = g_txCanMsg.msg[6u];
canMag.Msg[7u] = g_txCanMsg.msg[7u];
g_bReturn = Can_Write(&canMag);
TP_SetSTminTimer(DiagnoCtl.N_STmin_0, (_DiagClock *)&DiagClock);
}
}
}
}
//-- 返回正确格式 --//
if (N_RSPData.ind.N_Result == N_OK_2)
{
N_RSPData.ind.N_Result = STATE0; //1
(void)App_CopyRam((uint8_t *)&g_txCanMsg.msg[0], (uint8_t *)&N_RSPData.ind.MsgData[0], 8);
LK_FillMsg((uint8_t *)&g_txCanMsg.msg[0], N_FILL, N_RSPData.ind.len);
//g_bReturn = bsp_CANSendFrame(g_txCanMsg.id, txResNum, (uint8_t *)&g_txCanMsg.msg[0], 8);
canMag.MsgID = g_txCanMsg.id;
canMag.MsgDLC = 8u;
canMag.MsgPro = 0u;
canMag.MsgStd = 0u;
canMag.MsgRTR = 0u;
canMag.Msg[0u] = g_txCanMsg.msg[0u];
canMag.Msg[1u] = g_txCanMsg.msg[1u];
canMag.Msg[2u] = g_txCanMsg.msg[2u];
canMag.Msg[3u] = g_txCanMsg.msg[3u];
canMag.Msg[4u] = g_txCanMsg.msg[4u];
canMag.Msg[5u] = g_txCanMsg.msg[5u];
canMag.Msg[6u] = g_txCanMsg.msg[6u];
canMag.Msg[7u] = g_txCanMsg.msg[7u];
g_bReturn = Can_Write(&canMag);
}
TP_TransmitNegatePDU((_ErrorFrame *)&Error); //返回错误内容
}
/*-------------------------------------------------------------------------
* Function Name : TP_TransmitNegatePDU 服务否定响应
* Description :
* Input :
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
void TP_TransmitNegatePDU(_ErrorFrame *Err)
{
_CAN_Msg canMag;
if (Err->FrameErr)
{
if (N_US_R_Data_FF.ind.N_SID == Err->RespSerId)
{
N_US_R_Data_FF.ind.Length = 0;
N_US_R_Data_FF.ind.N_SID = 0;
}
if (Err->N_TAtype == ID_PhyAddr) //物理寻址--回复错误
{
g_txCanMsg.id = ID_ResAddr;
g_txCanMsg.msg[0] = 3;
g_txCanMsg.msg[1] = NegativeId; //7F
g_txCanMsg.msg[2] = Err->RespSerId; //服务ID-27
g_txCanMsg.msg[3] = Err->FrameErr; //0x35
g_txCanMsg.msg[4] = N_FILL; //0x55
g_txCanMsg.msg[5] = N_FILL; //0x55
g_txCanMsg.msg[6] = N_FILL; //0x55
g_txCanMsg.msg[7] = N_FILL; //0x55
g_txCanMsg.dlc = 8;
//g_bReturn = bsp_CANSendFrame(g_txCanMsg.id, txResNum, (uint8_t *)&g_txCanMsg.msg[0], 8);
canMag.MsgID = g_txCanMsg.id;
canMag.MsgDLC = 8u;
canMag.MsgPro = 0u;
canMag.MsgStd = 0u;
canMag.MsgRTR = 0u;
canMag.Msg[0u] = g_txCanMsg.msg[0u];
canMag.Msg[1u] = g_txCanMsg.msg[1u];
canMag.Msg[2u] = g_txCanMsg.msg[2u];
canMag.Msg[3u] = g_txCanMsg.msg[3u];
canMag.Msg[4u] = g_txCanMsg.msg[4u];
canMag.Msg[5u] = g_txCanMsg.msg[5u];
canMag.Msg[6u] = g_txCanMsg.msg[6u];
canMag.Msg[7u] = g_txCanMsg.msg[7u];
g_bReturn = Can_Write(&canMag);
}
if ((Err->FrameErr != ServiceNotSupported) &&
(Err->FrameErr != SubFunctionNotSupported) &&
(Err->FrameErr != RequestOutOfRange))
{
g_txCanMsg.id = ID_ResAddr;
g_txCanMsg.msg[0] = 3;
g_txCanMsg.msg[1] = NegativeId;
g_txCanMsg.msg[2] = Err->RespSerId;
g_txCanMsg.msg[3] = Err->FrameErr;
g_txCanMsg.msg[4] = N_FILL;
g_txCanMsg.msg[5] = N_FILL;
g_txCanMsg.msg[6] = N_FILL;
g_txCanMsg.msg[7] = N_FILL;
g_txCanMsg.dlc = 8;
//g_bReturn = bsp_CANSendFrame(g_txCanMsg.id, txResNum, (uint8_t *)&g_txCanMsg.msg[0], 8);
canMag.MsgID = g_txCanMsg.id;
canMag.MsgDLC = 8u;
canMag.MsgPro = 0u;
canMag.MsgStd = 0u;
canMag.MsgRTR = 0u;
canMag.Msg[0u] = g_txCanMsg.msg[0u];
canMag.Msg[1u] = g_txCanMsg.msg[1u];
canMag.Msg[2u] = g_txCanMsg.msg[2u];
canMag.Msg[3u] = g_txCanMsg.msg[3u];
canMag.Msg[4u] = g_txCanMsg.msg[4u];
canMag.Msg[5u] = g_txCanMsg.msg[5u];
canMag.Msg[6u] = g_txCanMsg.msg[6u];
canMag.Msg[7u] = g_txCanMsg.msg[7u];
g_bReturn = Can_Write(&canMag);
}
Err->FrameErr = 0;
}
}
/*-------------------------------------------------------------------------
* Function Name : TP_CalMsgLen
* Description :
* Input :
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
uint8_t TP_CalMsgLen(uint16_t BIT_DATA, uint8_t SnLoop)
{
uint16_t wTemp;
uint8_t len;
uint8_t i;
len = 0;
wTemp = BIT_DATA;
for (i = 0; i <= 15; i++)
{
if (wTemp & 0x0001)
{
len += 7;
}
wTemp = wTemp >> 1;
}
if (SnLoop == 0)
{
len -= 1;
}
return len;
}
/*-------------------------------------------------------------------------
* Function Name : TP_SetCrTimer
* Description :
* Input :
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
void TP_SetCrTimer(uint32_t Second, _DiagClock *T)
{
T->TT_CrEnable = 1;
T->OverCrTime = Second;
T->CrTime = 0;
}
/*-------------------------------------------------------------------------
* Function Name : Api_TTimerOver2
* Description :
* Input :
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
uint8_t TP_CrTimerOver(_DiagClock *T)
{
if ((T->CrTime >= T->OverCrTime) && (T->TT_CrEnable))
{
T->TT_CrEnable = 0;
T->CrTime = 0;
return 1;
}
else
{
return 0;
}
}
/*-------------------------------------------------------------------------
* Function Name : TP_SetSTminTimer
* Description :
* Input :
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
void TP_SetSTminTimer(uint32_t Second, _DiagClock *T)
{
T->TT_STminEnable = 1;
T->OverSTminTime = Second;
T->STminTime = 0;
}
/*-------------------------------------------------------------------------
* Function Name : TP_STminTimerOver
* Description :
* Input :
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
uint8_t TP_STminTimerOver(_DiagClock *T)
{
if ((T->STminTime >= T->OverSTminTime) && (T->TT_STminEnable))
{
T->TT_STminEnable = 0;
T->STminTime = 0;
return 1;
}
else
{
return 0;
}
}
/*-------------------------------------------------------------------------
* Function Name : TP_SetBsTimer
* Description :
* Input :
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
void TP_SetBsTimer(uint32_t Second, _DiagClock *T)
{
T->TT_BsEnable = 1;
T->OverBsTime = Second;
T->BsTime = 0;
}
/*-------------------------------------------------------------------------
* Function Name : TP_BsTimerOver
* Description :
* Input :
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
uint8_t TP_BsTimerOver(_DiagClock *T)
{
if ((T->BsTime >= T->OverBsTime) && (T->TT_BsEnable))
{
T->TT_BsEnable = 0;
T->BsTime = 0;
return 1;
}
else
{
return 0;
}
}
#ifdef GLOBALS_TP_DIAGNO
#define EXTERN_TP_DIAGNO
#else
#define EXTERN_TP_DIAGNO extern
#endif
#ifndef _TP_DIAGNO_H_
#define _TP_DIAGNO_H_
#include "uds_includes.h"
#define SingleFrame 0x00
#define FirstFrame 0x10
#define ConsecutiveFrame 0x20
#define FlowControlFrame 0x30
#define FC_WAIT 0x31
typedef struct
{
uint32_t id;
uint8_t msg[8];
uint8_t dlc;
} _SendCanMsg;
EXTERN_TP_DIAGNO volatile _SendCanMsg g_txCanMsg;
extern volatile _N_USData N_US_R_MultiData;
extern volatile _N_USData N_US_S_MultiData;
extern volatile _N_RSPData N_RSPData;
extern volatile _N_US_Data_FF N_US_R_Data_FF;
extern volatile _N_US_Data_FF N_US_S_Data_FF;
extern volatile _N_USSFData N_USSFData[2];
extern volatile uint16_t N_RecLen;
EXTERN_TP_DIAGNO uint8_t TP_CalMsgLen(uint16_t BIT_DATA, uint8_t SnLoop);
EXTERN_TP_DIAGNO void TP_AbnormalInResSF_handle(void);
EXTERN_TP_DIAGNO void TP_AbnormalInResFC_handle(void);
EXTERN_TP_DIAGNO void TP_AbnormalInResCF_handle(void);
EXTERN_TP_DIAGNO void TP_AbnormalInReqFC_handle(void);
EXTERN_TP_DIAGNO void TP_NormalRecFC_handle(void);
EXTERN_TP_DIAGNO void TP_Buffer_handle(void);
EXTERN_TP_DIAGNO void TP_UnknownlPDU_handle(void);
EXTERN_TP_DIAGNO void TP_ReciveSF_handle(void);
EXTERN_TP_DIAGNO void TP_ReciveMultiF_handle(void);
EXTERN_TP_DIAGNO void TP_AbnormalInReqFF_handle(void);
EXTERN_TP_DIAGNO void TP_NormalSendFC_Fun(void);
EXTERN_TP_DIAGNO void TP_TooShortDLC_handle(_LinkData *LK_Data);
EXTERN_TP_DIAGNO void TP_TransmitPDU(void);
EXTERN_TP_DIAGNO void TP_TransmitNegatePDU(_ErrorFrame *Err);
EXTERN_TP_DIAGNO void TP_SetSTminTimer(uint32_t Second, _DiagClock *T);
EXTERN_TP_DIAGNO uint8_t TP_STminTimerOver(_DiagClock *T);
EXTERN_TP_DIAGNO void TP_SetBsTimer(uint32_t Second, _DiagClock *T);
EXTERN_TP_DIAGNO uint8_t TP_BsTimerOver(_DiagClock *T);
EXTERN_TP_DIAGNO void TP_SetCrTimer(uint32_t Second, _DiagClock *T);
EXTERN_TP_DIAGNO uint8_t TP_CrTimerOver(_DiagClock *T);
#endif /* _TP_DIAGNO_H_ */
#ifdef GLOBALS_UDS_CFG
#define EXTERN_UDS_CFG
#else
#define EXTERN_UDS_CFG extern
#endif
#ifndef _UDS_CFG_H_
#define _UDS_CFG_H_
#define N_Unlock 10000
#define N_SequenceOut 500
#define N_Session 5000
#define N_Cr 150
#define N_Bs 150
#define ID_BCM_PhyAddr 0x7E0
#define ID_BCM_ResAddr 0x7E8 //BCM物理响应
#define ID_PhyAddr 0x701
#define ID_ResAddr 0x709 //物理响应
#define ID_FunAddr 0x7df
#define N_FILL 0x00
#endif
#ifndef _UDS_DEF_H_
#define _UDS_DEF_H_
///////////------------------------////////////////////////////
#define SubDefSession 0x01
#define SubProgSession 0x02
#define SubExtSession 0x03
#define SubHardReset 1
#define SubKeyOffOnReset 2
#define SubSoftReset 3
#define SubZeroFun0 0
#define SubReqSeed1 1
#define SubReqSeed3 3
#define SubReqSeed5 5
#define SubReqSeed7 7
#define SubSendKey2 2
#define SubSendKey4 4
#define SubSendKey6 6
#define SubSendKey8 8
#define SubEnableRxAndTx 0 //使能接收发送
#define SubEnableRxAndDisTx 1 //使能接收
#define SubDisableRxAndEnTx 2 //使能发送
#define SubDisableRxAndTx 3 //关闭
#define NOR_Message 1
#define NM_Message 2
#define NOR_NM_Message 3
#define UnLockLv4 4
#define UnLockLv3 3
#define UnLockLv2 2
#define UnLockLv1 1 //解锁
#define Lock 0
#define DefSession 0x01 //默认会话
#define ProgSession 0x02 //编程会话
#define ExtSession 0x03 //扩展会话
#define NegativeId 0x7f //否定响应ID
//-- Request Service Id(服务列表) --//
#define ReqSessionCtlId 0x10
#define ReqECUResetId 0x11
#define ReqClrDiagInfoId 0x14
#define ReqReadDtcId 0x59
#define ReqReadDataId 0x62
#define ReqAccessId 0x27
#define ReqCommCtlId 0x28
#define ReqWriteDataId 0x2e
#define ReqRoutineControlId 0x31
#define ReqDownloadId 0x34
#define ReqMessageId 0x36
#define RequestTransferExitId 0x37
#define ReqTesterId 0x3E //
#define ReqInAndOutCtlId 0x2F
#define ReqCtlDTCSetId 0x85
#define ReqProgModeId 0xA5
#define ReqProgMilId 0x41
//-- N_R否定响应 --//
#define ServiceNotSupported 0x11 //服务不支持 99 Exct_USData.ind.MsgData[0]
#define SubFunctionNotSupported 0x12 //子功能不支持 10 04 SubFunBit0_6
#define ErrFormatLength 0x13 //长度不对 ind.Length
#define RequestOutOfRange 0x31 //超出范围 28 03 04 ind.MsgData[2]
#define FlashEraseFailed 0x32 //31
#define SecurityAccessDenied 0x33 //31
#define InvalidKey 0x35 //秘钥错误
#define ExceedNumberOfAttempts 0x36 //27
#define ReqTimeDelayNotExpired 0x37 //27
#define SubFunctionNotSupportedInActiceSession 0x7e //----------空
#define NotSuppInActiveSession 0x7f //此会话不支持功能
#define ConditNotCorrect 0x22 //----------空
#define ReqSequenceError 0x24 //
#define voltageTooHigh 0x92 //----------空
#define voltageTooLow 0x93 //----------空
#define DtcSetOn 1
#define DtcSetOff 2
//19
#define RepNumByStatusMask 1 //reportNumberOfDTCByStatusMask
#define RepDTCByStatusMask 2 //reportDTCByStatusMask
#define RepSnapRecordDTCNum 4 //reportDTCSnapshotRecordByDTCNumber
#define RepExtDataRecordNum 6 //reportDTCExtendedDataRecordByDTCNumber
#define RepSupportedDTC 0xa //reportSupportedDTC
//A5
#define VerifyProgCondition 1
#define EnableProgMode 3
//2F
#define ReturnControlToECU 0
#define ShortTermAdjustment 3
//
#define UDS_TRUE 1
#define UDS_FALSE 0
#endif
#include "TP_Layer.h"
#include "app_Service.h"
#include "Link_Layer.h"
#include "UDS_def.h"
#include "UDS_CFG.h"
#include "app_ServiceProc.h"
#include <string.h>
#define GLOBALS_UDS_CFG
#define GLOBALS_USER_DEF
volatile _DiagnoCtl DiagnoCtl; //诊断当前状态
volatile _N_USData Exct_USData; //报文接收的ID数据
volatile _DiagClock DiagClock;
volatile _ErrorFrame Error; //错误信息
_DiagReciveDTC DiagReciveDTC;
_DiagReciveGaugePara DiagReciveGaugePara;
//volatile uint32_t CrcCheckSum;
uint8_t NormalCanSt = 0;
uint8_t NMCanSt = 0;
/*-------------------------------------------------------------------------
* Function Name : DiagnosisInit_main
* Description :
* Input :
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
void DiagnosisInit_main(void)
{
N_US_R_MultiData.ind.N_Result = STATE0;
N_US_S_MultiData.ind.N_Result = STATE0;
N_USSFData[0].ind.N_Result = STATE0;
N_USSFData[1].ind.N_Result = STATE0;
Exct_USData.ind.N_Result = STATE0;
N_RSPData.ind.N_Result = STATE0;
LinkDataBuf[0].TransferStatus = empoty;
LinkDataBuf[1].TransferStatus = empoty;
DiagnoCtl.SubFunction = 0;
DiagnoCtl.CommCtl = SubEnableRxAndTx;
DiagnoCtl.SessionType = DefSession;
DiagnoCtl.AccessLock = Lock;
DiagnoCtl.N_REV_MAX_BS = MaxBuff / 8;
DiagnoCtl.N_STmin_0 = 20;
DiagnoCtl.DTCSettingType = DtcSetOn;
DiagnoCtl.tDiagStart = 0;
DiagnoCtl.DTCByStatusMask = 0x09; //0x08已确认的诊断故障代码
//0x01测试失败
Error.FrameErr = 0;
TP_SetSTminTimer(DiagnoCtl.N_STmin_0, (_DiagClock *)&DiagClock);
}
/*-------------------------------------------------------------------------
* Function Name : App_Load_DTCNum
* Description :
* Input :
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
void App_Load_DTCNum(uint32_t *DtcNum, uint8_t *data)
{
*(DtcNum) = data[0];
*(DtcNum) = *(DtcNum) << 8;
*(DtcNum) |= data[1];
*(DtcNum) = *(DtcNum) << 8;
*(DtcNum) |= data[2];
//*(DtcNum) = *(DtcNum);
}
/*-------------------------------------------------------------------------
* Function Name : Diagnosis_main
* Description :
* Input :
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
void Diagnosis_main(void)
{
TP_Buffer_handle();
if (LinkData.TransferStatus == full)
{
TP_ReciveSF_handle();
TP_ReciveMultiF_handle();
TP_NormalRecFC_handle();
LinkData.TransferStatus = empoty;
}
TP_NormalSendFC_Fun();
if (N_USSFData[0].ind.N_Result == N_OK_2)
{
App_CopyRam((uint8_t *)&Exct_USData, (uint8_t *)&N_USSFData[0], sizeof(_N_USSFData));
Exct_USData.ind.N_Result = N_OK_2;
N_USSFData[0].ind.N_Result = STATE0;
}
else if ((N_USSFData[1].ind.N_Result == N_OK_2) && (Exct_USData.ind.N_Result == STATE0))
{
App_CopyRam((uint8_t *)&Exct_USData, (uint8_t *)&N_USSFData[1], sizeof(_N_USSFData));
Exct_USData.ind.N_Result = N_OK_2;
N_USSFData[1].ind.N_Result = STATE0;
}
else if ((N_US_R_MultiData.ind.N_Result == N_OK_2) && (Exct_USData.ind.N_Result == STATE0) &&
(N_US_S_MultiData.ind.N_Result == STATE0))
{
App_CopyRam((uint8_t *)&Exct_USData, (uint8_t *)&N_US_R_MultiData, sizeof(_N_USData));
N_US_R_MultiData.ind.N_Result = STATE0;
}
if (N_US_S_Data_FF.ind.N_PCI == FC_WAIT)
{
if (TP_BsTimerOver((_DiagClock *)&DiagClock))
{
N_US_S_MultiData.ind.N_Result = N_TIMEOUT_Bs_6;
}
}
if (N_US_S_MultiData.ind.N_Result == STATE0)
{
DiagClock.TT_BsEnable = 0;
N_US_S_Data_FF.ind.N_FC_Num = 0;
}
if (N_US_R_MultiData.ind.N_Result == N_OK_2)
{
N_US_R_Data_FF.ind.pos = 0;
N_US_R_Data_FF.ind.N_PCI = 0;
}
if ((N_US_R_MultiData.ind.N_Result == N_TIMEOUT_Bs_6) || (N_US_R_MultiData.ind.N_Result == N_WRONG_SN_9))
{
N_US_R_MultiData.ind.N_Result = STATE0;
N_US_R_Data_FF.ind.pos = 0;
N_US_R_Data_FF.ind.N_PCI = 0;
N_US_R_Data_FF.ind.N_RecSN_L = 0;
}
if ((N_US_S_MultiData.ind.N_Result == N_TIMEOUT_Bs_6) ||
(N_US_S_MultiData.ind.N_Result == OVFLW) ||
(N_US_S_MultiData.ind.N_Result == N_INVALID_FS_8))
{
N_US_S_MultiData.ind.N_Result = STATE0;
N_US_S_Data_FF.ind.N_PCI = 0;
N_US_S_Data_FF.ind.N_SID = 0;
N_US_S_Data_FF.ind.N_BS_CNT = 0;
}
if (App_SessionTimerOver((_DiagClock *)&DiagClock))
{
DiagnoCtl.SessionType = DefSession;
DiagnoCtl.A5_Sequence = 0;
// DiagnoCtl.SubFunction = SubHardReset;
}
if (App_ReUnlockTimerOver((_DiagClock *)&DiagClock))
{
DiagnoCtl.AccessCount = 0;
}
if (DiagnoCtl.SessionType == DefSession)
{
DiagnoCtl.AccessLock = Lock;
DiagnoCtl.CommCtl = SubEnableRxAndTx;
DiagnoCtl.CommType = NOR_NM_Message;
DiagnoCtl.DTCSettingType = DtcSetOn;
}
if (Exct_USData.ind.N_Result == N_OK_2)
{
switch (Exct_USData.ind.N_TAtype)
{
case ID_BCM_ResAddr:
switch (Exct_USData.ind.MsgData[0])
{
case ReqReadDtcId:
App_59_service((_N_USData *)&Exct_USData); //
break;
case ReqReadDataId:
App_62_service((_N_USData *)&Exct_USData); //
break;
case ReqProgMilId:
App_01_service((_N_USData *)&Exct_USData);
break;
default:
/* Error.N_TAtype = ID_PhyAddr;
Error.FrameErr = ServiceNotSupported; //服务不支持
Error.RespSerId = Exct_USData.ind.MsgData[0];*/
break;
}
break;
case ID_PhyAddr:
switch (Exct_USData.ind.MsgData[0])
{
case ReqSessionCtlId:
App_10_service((_N_USData*)&Exct_USData);
break;
case ReqECUResetId:
App_11_service((_N_USData*)&Exct_USData);
break;
default:
/* Error.N_TAtype = ID_PhyAddr;
Error.FrameErr = ServiceNotSupported; //服务不支持
Error.RespSerId = Exct_USData.ind.MsgData[0];*/
break;
}
break;
default:;
}
Exct_USData.ind.N_Result = STATE0;
}
TP_TransmitPDU(); //仪表诊断回复
App_11_Reset_handle();
}
/*-------------------------------------------------------------------------
* Function Name : App_10_service
* Description :
* Input :
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
void App_10_service(_N_USData *AppUSData)
{
_SubFun SubFun;
App_ErrorInfoInit((_N_USData *)AppUSData);
SubFun.SubData = AppUSData->ind.MsgData[1];
if (AppUSData->ind.Length == 0x02) //请求命令的字节长度 2个 10 01
{
if (DiagnoCtl.SessionType == SubDefSession) //当前为默认会话模式
{
if ((SubFun.SubBits.SubFunBit0_6 & 0xf) == SubDefSession) //请求命令子功能 01
{
DiagnoCtl.AccessLock = Lock; //上锁
DiagnoCtl.SessionType = DefSession; //默认模式
if (DiagnoCtl.SessionType != SubFun.SubBits.SubFunBit0_6)
{
DiagnoCtl.SessionType = SubFun.SubBits.SubFunBit0_6;
DiagnoCtl.A5_Sequence = 0;
}
}
else if ((SubFun.SubBits.SubFunBit0_6 & 0xf) == SubExtSession) //请求命令子功能 03
{
DiagnoCtl.AccessLock = Lock;
if (DiagnoCtl.SessionType != SubFun.SubBits.SubFunBit0_6)
{
DiagnoCtl.SessionType = SubFun.SubBits.SubFunBit0_6;
DiagnoCtl.A5_Sequence = 0;
}
App_SetSessionTimer(N_Session, (_DiagClock *)&DiagClock);
}
else
{
Error.FrameErr = SubFunctionNotSupported; //子功能不支持 10 04
}
}
else if (DiagnoCtl.SessionType == SubExtSession) //当前编程模式
{
if ((SubFun.SubBits.SubFunBit0_6 & 0xf) == SubDefSession)
{
DiagnoCtl.AccessLock = Lock;
DiagnoCtl.SessionType = DefSession;
if (DiagnoCtl.SessionType != SubFun.SubBits.SubFunBit0_6)
{
DiagnoCtl.SessionType = SubFun.SubBits.SubFunBit0_6;
DiagnoCtl.A5_Sequence = 0;
}
}
else if ((SubFun.SubBits.SubFunBit0_6 & 0xf) == SubExtSession)
{
DiagnoCtl.AccessLock = Lock;
if (DiagnoCtl.SessionType != SubFun.SubBits.SubFunBit0_6)
{
DiagnoCtl.SessionType = SubFun.SubBits.SubFunBit0_6;
DiagnoCtl.A5_Sequence = 0;
}
App_SetSessionTimer(N_Session, (_DiagClock *)&DiagClock);
}
else if ((SubFun.SubBits.SubFunBit0_6 & 0xf) == SubProgSession)
{
DiagnoCtl.AccessLock = Lock;
if (DiagnoCtl.SessionType != SubFun.SubBits.SubFunBit0_6)
{
DiagnoCtl.SessionType = SubFun.SubBits.SubFunBit0_6;
DiagnoCtl.A5_Sequence = 0;
DiagnoCtl.SubFunction = SubHardReset;
}
App_SetSessionTimer(N_Session, (_DiagClock *)&DiagClock);
}
else
{
Error.FrameErr = SubFunctionNotSupported; //子功能不支持
}
}
else if (DiagnoCtl.SessionType == SubProgSession) //当前为扩展模式
{
if ((SubFun.SubBits.SubFunBit0_6 & 0xf) == SubDefSession)
{
DiagnoCtl.AccessLock = Lock;
DiagnoCtl.SessionType = DefSession;
if (DiagnoCtl.SessionType != SubFun.SubBits.SubFunBit0_6)
{
DiagnoCtl.SessionType = SubFun.SubBits.SubFunBit0_6;
DiagnoCtl.A5_Sequence = 0;
}
DiagnoCtl.SubFunction = SubHardReset;
}
else if ((SubFun.SubBits.SubFunBit0_6 & 0xf) == SubProgSession)
{
DiagnoCtl.AccessLock = Lock;
if (DiagnoCtl.SessionType != SubFun.SubBits.SubFunBit0_6)
{
DiagnoCtl.SessionType = SubFun.SubBits.SubFunBit0_6;
DiagnoCtl.A5_Sequence = 0;
}
App_SetSessionTimer(N_Session, (_DiagClock *)&DiagClock);
}
else
{
Error.FrameErr = SubFunctionNotSupported; //子功能不支持
}
}
}
else
{
Error.FrameErr = ErrFormatLength; //长度不对
}
//格式正确,返回正确 头 + 50 01 00 32 01 F4
if (Error.FrameErr == 0)
{
if (!SubFun.SubBits.SubFunBit7_7) //请求命令子功能 第7位为0
{
N_RSPData.ind.len = 7; //7个字节
N_RSPData.ind.MsgData[0] = N_RSPData.ind.len - 1; //头
N_RSPData.ind.MsgData[1] = AppUSData->ind.MsgData[0] + 0x40; //50
N_RSPData.ind.MsgData[2] = SubFun.SubBits.SubFunBit0_6; //01
N_RSPData.ind.MsgData[3] = 0x00;
N_RSPData.ind.MsgData[4] = 0x32;
N_RSPData.ind.MsgData[5] = 0x01;
N_RSPData.ind.MsgData[6] = 0xF4;
N_RSPData.ind.N_Result = N_OK_2; //正确
}
}
}
/*-------------------------------------------------------------------------
* Function Name : App_11_service
* Description :
* Input :
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
void App_11_service(_N_USData *AppUSData)
{
_SubFun SubFun;
App_ErrorInfoInit((_N_USData *)AppUSData);
if ((DiagnoCtl.SessionType == ExtSession) ||
(DiagnoCtl.SessionType == ProgSession))
{
if (AppUSData->ind.Length > 1)
{
SubFun.SubData = AppUSData->ind.MsgData[1];
switch (SubFun.SubBits.SubFunBit0_6)
{
case SubHardReset: //11 01
if (AppUSData->ind.Length == 0x02)
{
DiagnoCtl.SubFunction = SubHardReset;
}
else
{
Error.FrameErr = ErrFormatLength; //长度不对
}
break;
case SubKeyOffOnReset: //11 02
if (AppUSData->ind.Length == 0x02)
{
DiagnoCtl.SubFunction = SubKeyOffOnReset;
}
else
{
Error.FrameErr = ErrFormatLength; //长度不对
}
break;
case SubSoftReset: //11 03
if (AppUSData->ind.Length == 0x02)
{
DiagnoCtl.SubFunction = SubSoftReset;
}
else
{
Error.FrameErr = ErrFormatLength; //长度不对
}
break;
default:
Error.FrameErr = SubFunctionNotSupported; //子功能不支持
}
}
else
{
Error.FrameErr = ErrFormatLength; //长度不对
}
}
else
{
Error.FrameErr = NotSuppInActiveSession;
}
if (Error.FrameErr == 0)
{
if (!SubFun.SubBits.SubFunBit7_7)
{
N_RSPData.ind.len = 3;
N_RSPData.ind.MsgData[0] = N_RSPData.ind.len - 1;
N_RSPData.ind.MsgData[1] = AppUSData->ind.MsgData[0] + 0x40;
N_RSPData.ind.MsgData[2] = SubFun.SubBits.SubFunBit0_6;
N_RSPData.ind.N_Result = N_OK_2;
}
}
}
/*-------------------------------------------------------------------------
* Function Name : App_85_service
* Description :
* Input :
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
void App_85_service(_N_USData *AppUSData)
{
_SubFun SubFun;
App_ErrorInfoInit((_N_USData *)AppUSData);
if (DiagnoCtl.SessionType == ExtSession)
{
if (AppUSData->ind.Length > 1)
{
SubFun.SubData = AppUSData->ind.MsgData[1];
switch (SubFun.SubBits.SubFunBit0_6)
{
case DtcSetOn:
if (AppUSData->ind.Length == 0x02)
{
DiagnoCtl.DTCSettingType = SubFun.SubBits.SubFunBit0_6;
}
else
{
Error.FrameErr = ErrFormatLength; //长度不对
}
break;
case DtcSetOff:
if (AppUSData->ind.Length == 0x02)
{
DiagnoCtl.DTCSettingType = SubFun.SubBits.SubFunBit0_6;
}
else
{
Error.FrameErr = ErrFormatLength; //长度不对
}
break;
default:
Error.FrameErr = SubFunctionNotSupported; //子功能不支持
}
}
else
{
Error.FrameErr = ErrFormatLength; //长度不对
}
}
else
{
Error.FrameErr = NotSuppInActiveSession;
}
if (Error.FrameErr == 0)
{
if (!SubFun.SubBits.SubFunBit7_7)
{
N_RSPData.ind.len = 3;
N_RSPData.ind.MsgData[0] = N_RSPData.ind.len - 1;
N_RSPData.ind.MsgData[1] = AppUSData->ind.MsgData[0] + 0x40;
N_RSPData.ind.MsgData[2] = SubFun.SubBits.SubFunBit0_6;
N_RSPData.ind.N_Result = N_OK_2;
}
}
}
/*-------------------------------------------------------------------------
* Function Name : App_27_service
* Description :
* Input :
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
void App_27_service(_N_USData *AppUSData)
{
uint16_t ret;
_SubFun SubFun;
App_ErrorInfoInit((_N_USData *)AppUSData);
if ((DiagnoCtl.SessionType == ProgSession) || (DiagnoCtl.SessionType == SubExtSession))
{
if (AppUSData->ind.Length > 0x01)
{
SubFun.SubData = AppUSData->ind.MsgData[1];
switch (SubFun.SubBits.SubFunBit0_6)
{
case SubReqSeed1: //27 01
case SubReqSeed5: //27 05
if (AppUSData->ind.Length == 0x02)
{
if (!SubFun.SubBits.SubFunBit7_7)
{
N_RSPData.ind.len = 7;
N_RSPData.ind.MsgData[0] = N_RSPData.ind.len - 1; //06
N_RSPData.ind.MsgData[1] = AppUSData->ind.MsgData[0] + 0x40; //67
N_RSPData.ind.MsgData[2] = SubFun.SubBits.SubFunBit0_6; //01
if ((DiagnoCtl.AccessLock == UnLockLv1) || (DiagnoCtl.AccessLock == UnLockLv4))
{
N_RSPData.ind.MsgData[3] = 0; //如果已经解锁,则回复0
N_RSPData.ind.MsgData[4] = 0;
N_RSPData.ind.MsgData[5] = 0;
N_RSPData.ind.MsgData[6] = 0;
}
else
{
}
N_RSPData.ind.N_Result = N_OK_2;
}
if (SubFun.SubBits.SubFunBit0_6 == SubReqSeed5) //27 _05
{
}
if (SubFun.SubBits.SubFunBit0_6 == SubReqSeed1) //27 _01
{
}
DiagnoCtl.w27_Sequence = SubFun.SubBits.SubFunBit0_6;
if (DiagClock.TT_UnlockEnable)
{
N_RSPData.ind.len = 4;
N_RSPData.ind.MsgData[0] = N_RSPData.ind.len - 1;
N_RSPData.ind.MsgData[1] = NegativeId;
N_RSPData.ind.MsgData[2] = AppUSData->ind.MsgData[0];
N_RSPData.ind.MsgData[3] = ReqTimeDelayNotExpired;
N_RSPData.ind.N_Result = N_OK_2;
}
}
else
{
Error.FrameErr = ErrFormatLength; //长度不对
}
break;
case SubSendKey2: //27 02 解锁
case SubSendKey6: //27 06 解锁
if (((DiagnoCtl.w27_Sequence == SubReqSeed1) && (SubFun.SubBits.SubFunBit0_6 == SubSendKey2)) ||
((DiagnoCtl.w27_Sequence == SubReqSeed3) && (SubFun.SubBits.SubFunBit0_6 == SubSendKey4)) ||
((DiagnoCtl.w27_Sequence == SubReqSeed5) && (SubFun.SubBits.SubFunBit0_6 == SubSendKey6)) ||
((DiagnoCtl.w27_Sequence == SubReqSeed7) && (SubFun.SubBits.SubFunBit0_6 == SubSendKey8)))
{
DiagnoCtl.w27_Sequence = SubFun.SubBits.SubFunBit0_6;
if (!DiagClock.TT_UnlockEnable)
{
if (AppUSData->ind.Length == 0x06)
{
if (DiagnoCtl.AccessCount < 5)
{
DiagnoCtl.AccessCount++;
}
if (ret == 0)
{
if (!SubFun.SubBits.SubFunBit7_7)
{
N_RSPData.ind.len = 3;
N_RSPData.ind.MsgData[0] = N_RSPData.ind.len - 1;
N_RSPData.ind.MsgData[1] = AppUSData->ind.MsgData[0] + 0x40;
N_RSPData.ind.MsgData[2] = SubFun.SubBits.SubFunBit0_6;
N_RSPData.ind.N_Result = N_OK_2;
}
if (DiagnoCtl.AccessCount <= 3)
{
if (SubFun.SubBits.SubFunBit0_6 == SubSendKey2) //27 _02
{
DiagnoCtl.AccessLock = UnLockLv1; //解锁
}
else if (SubFun.SubBits.SubFunBit0_6 == SubSendKey6) //27 _06
{
DiagnoCtl.AccessLock = UnLockLv4; //解锁
}
/* else if (SubFun.SubBits.SubFunBit0_6 == SubSendKey8)
{
DiagnoCtl.AccessLock = UnLockLv4;
}*/
DiagnoCtl.AccessCount = 0;
}
}
}
else
{
Error.FrameErr = ErrFormatLength;
}
}
}
else
{
Error.FrameErr = ReqSequenceError;
}
break;
default:
Error.FrameErr = SubFunctionNotSupported; //子功能不支持
}
if (Error.FrameErr == 0)
{
if ((DiagnoCtl.w27_Sequence == SubSendKey2) || (DiagnoCtl.w27_Sequence == SubSendKey6))
{
DiagnoCtl.w27_Sequence = 0;
if ((DiagnoCtl.AccessLock != UnLockLv1) && (DiagnoCtl.AccessLock != UnLockLv4))
{
if (DiagnoCtl.AccessCount <= 1)
{
N_RSPData.ind.len = 4;
N_RSPData.ind.MsgData[0] = N_RSPData.ind.len - 1;
N_RSPData.ind.MsgData[1] = NegativeId;
N_RSPData.ind.MsgData[2] = AppUSData->ind.MsgData[0];
N_RSPData.ind.MsgData[3] = InvalidKey; //秘钥错误
N_RSPData.ind.N_Result = N_OK_2;
}
if (DiagnoCtl.AccessCount >= 2)
{
N_RSPData.ind.len = 4;
N_RSPData.ind.MsgData[0] = N_RSPData.ind.len - 1;
N_RSPData.ind.MsgData[1] = NegativeId;
N_RSPData.ind.MsgData[2] = AppUSData->ind.MsgData[0];
N_RSPData.ind.MsgData[3] = ExceedNumberOfAttempts;
N_RSPData.ind.N_Result = N_OK_2;
if (!DiagClock.TT_UnlockEnable)
{
App_SetReUnlockTimer(N_Unlock, (_DiagClock *)&DiagClock);
}
}
}
}
}
}
else
{
Error.FrameErr = ErrFormatLength; //长度不对
}
}
else
{
Error.FrameErr = NotSuppInActiveSession; //此会话不支持功能
}
}
/*-------------------------------------------------------------------------
* Function Name : App_31_service
* Description :
* Input :
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
void App_31_service(_N_USData *AppUSData)
{
uint8_t data = 1;
uint16_t DID;
_SubFun SubFun;
App_ErrorInfoInit((_N_USData *)AppUSData);
if ((DiagnoCtl.SessionType == ProgSession) || (DiagnoCtl.SessionType == SubExtSession))
{
if (AppUSData->ind.Length > 0x01)
{
SubFun.SubData = AppUSData->ind.MsgData[1];
switch (SubFun.SubBits.SubFunBit0_6)
{
case 1: //startRoutine
if (AppUSData->ind.Length >= 4)
{
App_Load_DID((uint16_t *)&DID, (uint8_t *)&AppUSData->ind.MsgData[2]);
if ((DiagnoCtl.AccessLock == UnLockLv1) || (DiagnoCtl.AccessLock == UnLockLv4))
{
if (DID == 0xFF00) //eraseMemory
{
if (AppUSData->ind.Length == 13)
{
if (AppUSData->ind.MsgData[4] == 0x44)
{
}
else
{
Error.FrameErr = RequestOutOfRange;
}
}
else
{
Error.FrameErr = ErrFormatLength; //长度不对
}
}
else if (DID == 0xFF01) //checkProgrammingDependencies
{
if (AppUSData->ind.Length == 4)
{
}
else
{
Error.FrameErr = ErrFormatLength; //长度不对
}
}
else
{
Error.FrameErr = RequestOutOfRange;
}
}
else
{
Error.FrameErr = SecurityAccessDenied;
}
}
else
{
Error.FrameErr = ErrFormatLength; //长度不对
}
break;
case 2: //stopRoutine
if (AppUSData->ind.Length == 4)
{
App_Load_DID((uint16_t *)&DID, (uint8_t *)&AppUSData->ind.MsgData[2]);
if ((DiagnoCtl.AccessLock == UnLockLv1) || (DiagnoCtl.AccessLock == UnLockLv4))
{
if (DID == 0xFF00)
{
}
else
{
Error.FrameErr = RequestOutOfRange;
}
}
else
{
Error.FrameErr = SecurityAccessDenied;
}
}
else
{
Error.FrameErr = ErrFormatLength; //长度不对
}
break;
case 3: //requestRoutineResults
if ((DiagnoCtl.AccessLock == UnLockLv1) || (DiagnoCtl.AccessLock == UnLockLv4))
{
// data = 1;
}
break;
default:;
}
}
else
{
Error.FrameErr = ErrFormatLength; //长度不对
}
}
else
{
Error.FrameErr = NotSuppInActiveSession;
}
if (Error.FrameErr == 0)
{
if (!SubFun.SubBits.SubFunBit7_7)
{
N_RSPData.ind.len = 5;
if (DID == 0x0203)
N_RSPData.ind.len = 8;
N_RSPData.ind.MsgData[0] = N_RSPData.ind.len - 1;
N_RSPData.ind.MsgData[1] = AppUSData->ind.MsgData[0] + 0x40;
N_RSPData.ind.MsgData[2] = SubFun.SubBits.SubFunBit0_6;
N_RSPData.ind.MsgData[3] = (uint8_t)(DID >> 8);
N_RSPData.ind.MsgData[4] = (uint8_t)DID;
N_RSPData.ind.MsgData[5] = data;
N_RSPData.ind.MsgData[6] = 0;
N_RSPData.ind.MsgData[7] = 0;
//N_RSPData.ind.N_Result = N_OK_2;
(void)memcpy((uint8_t *)N_US_S_MultiData.ind.MsgData, (uint8_t *)(N_RSPData.ind.MsgData + 1), N_RSPData.ind.len);
if (N_RSPData.ind.len >= 8)
{
N_US_S_Data_FF.ind.Length = N_RSPData.ind.len;
N_US_S_Data_FF.ind.N_PCI = FirstFrame;
}
else
{
N_US_S_MultiData.ind.Length = N_RSPData.ind.len;
N_US_S_Data_FF.ind.N_PCI = 0;
}
N_US_S_MultiData.ind.N_Result = N_OK_2;
}
}
}
/*-------------------------------------------------------------------------
* Function Name : App_34_service
* Description :
* Input :
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
void App_34_service(_N_USData *AppUSData)
{
App_ErrorInfoInit((_N_USData *)AppUSData);
if (DiagnoCtl.SessionType == ProgSession)
{
if (DiagnoCtl.AccessLock == UnLockLv4)
{
if (AppUSData->ind.Length == 11)
{
}
else
{
Error.FrameErr = ErrFormatLength; //长度不对
}
}
else
{
Error.FrameErr = SecurityAccessDenied;
}
}
else
{
Error.FrameErr = NotSuppInActiveSession;
}
if (DiagnoCtl.AccessLock == UnLockLv4)
{
if (Error.FrameErr == 0)
{
N_RSPData.ind.len = 5;
N_RSPData.ind.MsgData[0] = N_RSPData.ind.len - 1;
N_RSPData.ind.MsgData[1] = AppUSData->ind.MsgData[0] + 0x40;
N_RSPData.ind.MsgData[2] = 0x20;
N_RSPData.ind.MsgData[3] = 0x00;
N_RSPData.ind.MsgData[4] = 128;
N_RSPData.ind.N_Result = N_OK_2;
}
}
}
/*-------------------------------------------------------------------------
* Function Name : App_36_service
* Description :
* Input :
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
void App_36_service(_N_USData *AppUSData)
{
App_ErrorInfoInit((_N_USData *)AppUSData);
if (DiagnoCtl.SessionType == ProgSession)
{
if (DiagnoCtl.AccessLock == UnLockLv4)
{
if ((AppUSData->ind.Length > 2) && (AppUSData->ind.Length <= 1024))
{
}
else
{
Error.FrameErr = ErrFormatLength; //长度不对
}
}
else
{
Error.FrameErr = SecurityAccessDenied;
}
}
else
{
Error.FrameErr = NotSuppInActiveSession;
}
if (Error.FrameErr == 0)
{
N_RSPData.ind.len = 3;
N_RSPData.ind.MsgData[0] = N_RSPData.ind.len - 1;
N_RSPData.ind.MsgData[1] = AppUSData->ind.MsgData[0] + 0x40;
N_RSPData.ind.MsgData[2] = AppUSData->ind.MsgData[1];
N_RSPData.ind.N_Result = N_OK_2;
}
}
/*-------------------------------------------------------------------------
* Function Name : App_37_service
* Description :
* Input :
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
void App_37_service(_N_USData *AppUSData)
{
App_ErrorInfoInit((_N_USData *)AppUSData);
if (DiagnoCtl.SessionType == ProgSession)
{
if (DiagnoCtl.AccessLock == UnLockLv4)
{
if (AppUSData->ind.Length == 1)
{
}
else
{
Error.FrameErr = ErrFormatLength; //长度不对
}
}
else
{
Error.FrameErr = SecurityAccessDenied;
}
}
else
{
Error.FrameErr = NotSuppInActiveSession;
}
if (Error.FrameErr == 0)
{
N_RSPData.ind.len = 2;
N_RSPData.ind.MsgData[0] = N_RSPData.ind.len - 1;
N_RSPData.ind.MsgData[1] = AppUSData->ind.MsgData[0] + 0x40;
N_RSPData.ind.N_Result = N_OK_2;
}
}
/*-------------------------------------------------------------------------
* Function Name : App_28_service
* Description :
* Input :
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
void App_28_service(_N_USData *AppUSData)
{
_SubFun SubFun;
App_ErrorInfoInit((_N_USData *)AppUSData);
if (DiagnoCtl.SessionType == ExtSession)
{
if (AppUSData->ind.Length > 1)
{
SubFun.SubData = AppUSData->ind.MsgData[1];
switch (SubFun.SubBits.SubFunBit0_6) //子功能判断
{
case SubEnableRxAndTx: //28 00
if (AppUSData->ind.Length == 0x03) //长度为3
{
if (AppUSData->ind.MsgData[2] == NOR_Message) //28 00 01 应用报文
{
DiagnoCtl.CommCtl = SubEnableRxAndTx; //使能接收发送
DiagnoCtl.CommType = NOR_Message;
}
else if (AppUSData->ind.MsgData[2] == NM_Message) //28 00 02 网络管理报文
{
DiagnoCtl.CommCtl = SubEnableRxAndTx; //使能接收发送
DiagnoCtl.CommType = NM_Message;
}
else if (AppUSData->ind.MsgData[2] == NOR_NM_Message) //28 00 03 应用和网络管理报文
{
DiagnoCtl.CommCtl = SubEnableRxAndTx; //使能接收发送
DiagnoCtl.CommType = NOR_NM_Message;
}
else
{
Error.FrameErr = RequestOutOfRange; //超出范围
}
}
else
{
Error.FrameErr = RequestOutOfRange; //超出范围
}
break;
case SubDisableRxAndTx: //28 03
if (AppUSData->ind.Length == 0x03)
{
if (AppUSData->ind.MsgData[2] == NOR_Message) //28 03 01 应用报文
{
DiagnoCtl.CommCtl = SubDisableRxAndTx; //关闭
DiagnoCtl.CommType = NOR_Message;
}
else if (AppUSData->ind.MsgData[2] == NM_Message) //28 03 02 网络管理报文
{
DiagnoCtl.CommCtl = SubDisableRxAndTx; //关闭
DiagnoCtl.CommType = NM_Message;
}
else if (AppUSData->ind.MsgData[2] == NOR_NM_Message) //28 03 03 应用和网络管理报文
{
DiagnoCtl.CommCtl = SubDisableRxAndTx; //关闭
DiagnoCtl.CommType = NOR_NM_Message;
}
else
{
Error.FrameErr = RequestOutOfRange;
}
}
else
{
Error.FrameErr = RequestOutOfRange;
}
break;
default:
Error.FrameErr = SubFunctionNotSupported; //子功能不支持
}
}
else
{
Error.FrameErr = ErrFormatLength; //长度不对
}
}
else
{
Error.FrameErr = NotSuppInActiveSession;
}
if (Error.FrameErr == 0)
{
N_RSPData.ind.len = 3;
N_RSPData.ind.MsgData[0] = N_RSPData.ind.len - 1;
N_RSPData.ind.MsgData[1] = AppUSData->ind.MsgData[0] + 0x40;
N_RSPData.ind.MsgData[2] = SubFun.SubBits.SubFunBit0_6;
N_RSPData.ind.N_Result = N_OK_2;
}
}
/*-------------------------------------------------------------------------
* Function Name : App_22_service
* Description :
* Input :
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
void App_62_service(_N_USData *AppUSData)
{
uint16_t DID;
App_ErrorInfoInit((_N_USData *)AppUSData);
//获取DID
App_Load_DID((uint16_t *)&DID, (uint8_t *)&AppUSData->ind.MsgData[1]);
if (AppUSData->ind.Length > 1)
{
switch (DID)
{
case DID0005: //读-当前会话模式
App_CopyRam((uint8_t *)&DiagReciveGaugePara.CoolantTemp, (uint8_t *)&AppUSData->ind.MsgData[3], (AppUSData->ind.Length - 3));
//Reset_CoolantTemp_Signal_Time();
break;
default:
break;
}
}
}
/*-------------------------------------------------------------------------
* Function Name : App_2E_service
* Description :
* Input :
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
void App_2E_service(_N_USData *AppUSData)
{
uint16_t DID;
App_ErrorInfoInit((_N_USData *)AppUSData);
if ((DiagnoCtl.SessionType == ExtSession) || ((DiagnoCtl.SessionType == ProgSession)))
{
if ((DiagnoCtl.AccessLock == UnLockLv1) || (DiagnoCtl.AccessLock == UnLockLv4))
{
if (AppUSData->ind.Length > 1)
{
App_Load_DID((uint16_t *)&DID, (uint8_t *)&AppUSData->ind.MsgData[1]);
}
else
{
Error.FrameErr = ErrFormatLength;
}
}
else
{
Error.FrameErr = SecurityAccessDenied;
}
if ((DiagnoCtl.AccessLock == UnLockLv1) || ((DiagnoCtl.AccessLock == UnLockLv4)))
{
if (Error.FrameErr == 0)
{
N_RSPData.ind.len = 4;
N_RSPData.ind.MsgData[0] = N_RSPData.ind.len - 1;
N_RSPData.ind.MsgData[1] = AppUSData->ind.MsgData[0] + 0x40;
N_RSPData.ind.MsgData[2] = (uint8_t)(DID >> 8);
N_RSPData.ind.MsgData[3] = (uint8_t)(DID);
N_RSPData.ind.N_Result = N_OK_2;
}
}
else
{
Error.FrameErr = SecurityAccessDenied;
}
}
else
{
Error.FrameErr = NotSuppInActiveSession;
}
}
/*-------------------------------------------------------------------------
* Function Name : App_14_service
* Description :
* Input :
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
void App_14_service(_N_USData *AppUSData)
{
App_ErrorInfoInit((_N_USData *)AppUSData);
if (Error.FrameErr == 0)
{
N_RSPData.ind.len = 2;
N_RSPData.ind.MsgData[0] = N_RSPData.ind.len - 1;
N_RSPData.ind.MsgData[1] = AppUSData->ind.MsgData[0] + 0x40;
N_RSPData.ind.N_Result = N_OK_2;
}
}
/*-------------------------------------------------------------------------
* Function Name : App_19_service
* Description :
* Input :
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
void App_59_service(_N_USData *AppUSData)
{
uint16_t DID;
App_ErrorInfoInit((_N_USData *)AppUSData);
//获取DID
App_Load_DID((uint16_t *)&DID, (uint8_t *)&AppUSData->ind.MsgData[1]);
(void)memset((uint8_t *)&DiagReciveDTC.UnionDTC, 0, sizeof(_DiagReciveDTC));
if (AppUSData->ind.Length > 1)
{
if (AppUSData->ind.MsgData[1] == 0x02)
{
App_CopyRam((uint8_t *)&DiagReciveDTC.UnionDTC, (uint8_t *)&AppUSData->ind.MsgData[3], (AppUSData->ind.Length - 3));
}
}
}
/*-------------------------------------------------------------------------
* Function Name : App_2F_service
* Description :
* Input :
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
void App_2F_service(_N_USData *AppUSData)
{
uint8_t InOutCtrlParameter;
uint16_t DID;
uint16_t MsgLen = 4;
App_ErrorInfoInit((_N_USData *)AppUSData);
if (DiagnoCtl.SessionType == ExtSession) //2F + DID + 控制参数 + INfo
{
if ((DiagnoCtl.AccessLock == UnLockLv1) || (DiagnoCtl.AccessLock == UnLockLv4)) //解锁
{
if (AppUSData->ind.Length > 1)
{
App_Load_DID((uint16_t *)&DID, (uint8_t *)&AppUSData->ind.MsgData[1]);
InOutCtrlParameter = AppUSData->ind.MsgData[3]; //2F 10 01 _03..+ 1byte
if (Error.FrameErr == 0)
{
}
}
else
{
Error.FrameErr = ErrFormatLength; //长度不对
}
if (Error.FrameErr == 0)
{
N_US_S_MultiData.ind.MsgData[0] = AppUSData->ind.MsgData[0] + 0x40;
N_US_S_MultiData.ind.MsgData[1] = (uint8_t)(DID >> 8);
N_US_S_MultiData.ind.MsgData[2] = (uint8_t)DID;
N_US_S_MultiData.ind.MsgData[3] = InOutCtrlParameter;
if (MsgLen >= 8)
{
N_US_S_Data_FF.ind.Length = MsgLen;
N_US_S_Data_FF.ind.N_PCI = FirstFrame;
}
else
{
N_US_S_MultiData.ind.Length = MsgLen;
N_US_S_Data_FF.ind.N_PCI = 0;
}
N_US_S_MultiData.ind.N_Result = N_OK_2;
}
}
else
{
Error.FrameErr = SecurityAccessDenied;
}
}
else
{
Error.FrameErr = NotSuppInActiveSession;
}
}
/*-------------------------------------------------------------------------
* Function Name : App_3E_service
* Description :
* Input :
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
void App_3E_service(_N_USData *AppUSData)
{
_SubFun SubFun;
App_ErrorInfoInit((_N_USData *)AppUSData);
if (AppUSData->ind.Length > 1)
{
SubFun.SubData = AppUSData->ind.MsgData[1];
switch (SubFun.SubBits.SubFunBit0_6)
{
case SubZeroFun0:
if (AppUSData->ind.Length == 0x02)
{
if (!SubFun.SubBits.SubFunBit7_7)
{
N_RSPData.ind.len = 3;
N_RSPData.ind.MsgData[0] = N_RSPData.ind.len - 1;
N_RSPData.ind.MsgData[1] = AppUSData->ind.MsgData[0] + 0x40;
N_RSPData.ind.MsgData[2] = SubFun.SubBits.SubFunBit0_6;
N_RSPData.ind.N_Result = N_OK_2;
}
App_SetSessionTimer(N_Session, (_DiagClock *)&DiagClock);
}
else
{
Error.FrameErr = ErrFormatLength; //长度不对
}
break;
default:
Error.FrameErr = SubFunctionNotSupported; //子功能不支持
}
}
else
{
Error.FrameErr = ErrFormatLength; //长度不对
}
}
/*-------------------------------------------------------------------------
* Function Name : App_19_service
* Description :
* Input :
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
void App_01_service(_N_USData *AppUSData)
{
if (AppUSData->ind.Length == 0x06)
{
if (AppUSData->ind.MsgData[1] == 1)
{
DiagReciveGaugePara.MilLamp = 1;
}
else
{
DiagReciveGaugePara.MilLamp = 0;
}
//Reset_Mil_Signal_Time();
//DelfuModuleIn();
}
else
{
;
}
}
/*-------------------------------------------------------------------------
* Function Name : App_SetSequenceTimer
* Description :
* Input :
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
void App_SetSequenceTimer(uint32_t Second, _DiagClock *T)
{
T->TT_SequenceEnable = 1;
T->OverSequenceTime = Second;
T->SequenceTime = 0;
}
/*-------------------------------------------------------------------------
* Function Name : App_SequenceTimerOver
* Description :
* Input :
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
uint8_t App_SequenceTimerOver(_DiagClock *T)
{
if ((T->SequenceTime >= T->OverSequenceTime) && (T->TT_SequenceEnable))
{
T->TT_SequenceEnable = 0;
T->SequenceTime = 0;
return 1;
}
else
{
return 0;
}
}
/*-------------------------------------------------------------------------
* Function Name : App_SetSessionTimer
* Description :
* Input :
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
void App_SetSessionTimer(uint32_t Second, _DiagClock *T)
{
T->TT_SessionEnable = 1;
T->OverSessionTime = Second;
T->SessionTime = 0;
}
/*-------------------------------------------------------------------------
* Function Name : Api_TTimerOver3
* Description :
* Input :
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
uint8_t App_SessionTimerOver(_DiagClock *T)
{
if ((T->SessionTime >= T->OverSessionTime) && (T->TT_SessionEnable))
{
T->TT_SessionEnable = 0;
T->SessionTime = 0;
return 1;
}
else
{
return 0;
}
}
/*-------------------------------------------------------------------------
* Function Name : App_SetReUnlockTimer
* Description :
* Input :
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
void App_SetReUnlockTimer(uint32_t Second, _DiagClock *T)
{
T->TT_UnlockEnable = 1;
T->OverUnlockTime = Second;
T->UnlockTime = 0;
}
/*-------------------------------------------------------------------------
* Function Name : App_ReUnlockTimerOver
* Description :
* Input :
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
uint8_t App_ReUnlockTimerOver(_DiagClock *T)
{
if ((T->UnlockTime >= T->OverUnlockTime) && (T->TT_UnlockEnable))
{
T->TT_UnlockEnable = 0;
T->UnlockTime = 0;
return 1;
}
else
{
return 0;
}
}
#ifdef GLOBALS_SER_DIAGNO
#define EXTERN_SER_DIAGNO
#else
#define EXTERN_SER_DIAGNO extern
#endif
#ifndef SER_DIAGNO_H_
#define SER_DIAGNO_H_
#include "uds_includes.h"
#define DID0005 0x0005
extern volatile _N_USData Exct_USData;
extern volatile _DiagnoCtl DiagnoCtl;
extern volatile _DiagClock DiagClock;
extern volatile _ErrorFrame Error;
extern void App_SetSequenceTimer(uint32_t Second, _DiagClock *T);
extern uint8_t App_SequenceTimerOver(_DiagClock *T);
extern void App_SetSessionTimer(uint32_t Second, _DiagClock *T);
extern uint8_t App_SessionTimerOver(_DiagClock *T);
extern void App_SetReUnlockTimer(uint32_t Second, _DiagClock *T);
extern uint8_t App_ReUnlockTimerOver(_DiagClock *T);
extern void App_10_service(_N_USData *AppUSData); //会话模式
extern void App_11_service(_N_USData *AppUSData); //复位模式
extern void App_14_service(_N_USData *AppUSData); //清除-故障码(DTC)
extern void App_59_service(_N_USData *AppUSData); //读-故障码(DTC)
extern void App_62_service(_N_USData *AppUSData); //读
extern void App_27_service(_N_USData *AppUSData); //解锁
extern void App_28_service(_N_USData *AppUSData); //RxTx
extern void App_2E_service(_N_USData *AppUSData); //写
extern void App_2F_service(_N_USData *AppUSData); //IO
extern void App_31_service(_N_USData *AppUSData); //Boot
extern void App_34_service(_N_USData *AppUSData); //Boot
extern void App_36_service(_N_USData *AppUSData); //Boot
extern void App_37_service(_N_USData *AppUSData); //Boot
extern void App_3E_service(_N_USData *AppUSData); //Boot
extern void App_85_service(_N_USData *AppUSData); //开关-故障码(DTC)
extern void App_01_service(_N_USData *AppUSData);
extern void DiagnosisInit_main(void);
extern void Diagnosis_main(void);
#endif /* SER_DIAGNO_H_ */
#define GLOBALS_SERPROC_DIAGNO
#include "app_Service.h"
#include "TP_Layer.h"
#include "UDS_def.h"
#include "app_ServiceProc.h"
/*-------------------------------------------------------------------------
* Function Name : App_CreateCRCCheckSum
* Description :
* Input : uint8_t *p ,uint8_t Nub
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
uint8_t App_CreateCRCCheckSum(uint8_t *p, uint8_t Nub)
{
uint8_t bCheckSun;
uint8_t i;
bCheckSun = 0;
while (Nub--)
{
bCheckSun ^= *p++;
for (i = 0; i < 8; i++)
{
if (bCheckSun & 0x01)
{
bCheckSun = (bCheckSun >> 1) ^ 0x8C;
}
else
bCheckSun >>= 1;
}
}
return (bCheckSun);
}
/*-------------------------------------------------------------------------
* Function Name : App_CopyRam
* Description : ran copy
* Input :
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
void App_CopyRam(uint8_t *Dp, uint8_t *Sp, uint16_t Nub)
{
uint16_t b;
for (b = 0; b < Nub; b++)
{
*Dp++ = *Sp++;
}
}
/*-------------------------------------------------------------------------
* Function Name : App_Load_DID
* Description :
* Input :
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
void App_Load_DID(uint16_t *DID, uint8_t *data)
{
(*DID) = data[0];
(*DID) = (*DID) << 8;
(*DID) |= data[1];
}
/*-------------------------------------------------------------------------
* Function Name : App_ErrorInfoInit
* Description :
* Input :
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
void App_ErrorInfoInit(_N_USData *AppUSData)
{
Error.RespSerId = AppUSData->ind.MsgData[0];
Error.N_TAtype = AppUSData->ind.N_TAtype;
Error.FrameErr = 0;
}
/*-------------------------------------------------------------------------
* Function Name : App_11_Reset_handle
* Description :
* Input :
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
void App_11_Reset_handle(void)
{
if (N_RSPData.ind.N_Result == STATE0)
{
switch (DiagnoCtl.SubFunction)
{
case SubHardReset:
while (1)
;
case SubSoftReset:
break;
case SubKeyOffOnReset:
break;
default:;
}
DiagnoCtl.SubFunction = 0;
}
}
/*-------------------------------------------------------------------------
* Function Name : App_2F_IOCtl_handle
* Description :
* Input :
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
void Diagno_Tick(uint16_t DiagnoTimeCn)
{
//
if (DiagClock.TT_STminEnable)
{
if (DiagClock.STminTime < DiagClock.OverSTminTime)
{
DiagClock.STminTime += DiagnoTimeCn;
}
}
if (DiagClock.TT_BsEnable)
{
if (DiagClock.BsTime < DiagClock.OverBsTime)
{
DiagClock.BsTime += DiagnoTimeCn;
}
}
if (DiagClock.TT_CrEnable)
{
if (DiagClock.CrTime < DiagClock.OverCrTime)
{
DiagClock.CrTime += DiagnoTimeCn;
}
}
if (DiagClock.TT_SequenceEnable)
{
if (DiagClock.SequenceTime < DiagClock.OverSequenceTime)
{
DiagClock.SequenceTime += DiagnoTimeCn;
}
}
if (DiagClock.TT_SessionEnable)
{
if (DiagClock.SessionTime < DiagClock.OverSessionTime)
{
DiagClock.SessionTime += DiagnoTimeCn;
}
}
if (DiagClock.TT_UnlockEnable)
{
if (DiagClock.UnlockTime < DiagClock.OverUnlockTime)
{
DiagClock.UnlockTime += DiagnoTimeCn;
}
}
}
#ifdef GLOBALS_SERPROC_DIAGNO
#define EXTERN_SERPROC_DIAGNO
#else
#define EXTERN_SERPROC_DIAGNO extern
#endif
#include "uds_includes.h"
#ifndef SERPROC_DIAGNO_H_
#define SERPROC_DIAGNO_H_
extern void App_ErrorInfoInit(_N_USData *AppUSData);
extern void App_Load_DID(uint16_t *DID, uint8_t *data);
extern void App_CopyRam(uint8_t *Dp, uint8_t *Sp, uint16_t Nub);
extern uint8_t App_CreateCRCCheckSum(uint8_t *p, uint8_t Nub);
extern void App_11_Reset_handle(void);
void Diagno_Tick(uint16_t DiagnoTimeCn);
#endif /* SERPROC_DIAGNO_H_ */
/*
* includes.h
*
* Created on: 2014-7-31
* Author: qitiancun
*/
#ifndef _UDS_INCLUDES_H_
#define _UDS_INCLUDES_H_
#include "TYW_stdint.h"
/*
#define uint8_t unsigned char
#define uint16_t unsigned short
#define uint32_t unsigned int
*/
#define MaxBuff 266
typedef enum
{
STATE0 = 1,
N_OK_2,
CTS,
WAIT,
OVFLW,
N_TIMEOUT_Bs_6,
N_ERROR_7,
N_INVALID_FS_8,
N_WRONG_SN_9
} Enum_Result;
typedef enum
{
empoty,
full
} TransSt;
typedef struct
{
uint16_t Identifier; //Fun--PGN--
uint8_t DLC;
uint8_t Data[8];
TransSt TransferStatus;
} _LinkData;
typedef struct
{
struct
{
uint16_t pos;
uint16_t Length;
uint16_t N_FC_Num;
uint16_t N_RecSN_L;
uint8_t N_SendSN;
uint8_t N_BS_CNT;
uint8_t N_BS;
uint8_t N_SA;
uint8_t N_TA;
uint8_t N_PCI;
uint8_t N_SID;
} ind;
} _N_US_Data_FF;
typedef struct
{
struct
{
uint16_t N_TAtype;
uint16_t Length;
uint8_t N_SA;
uint8_t N_TA;
uint8_t N_AE;
uint8_t N_PCI;
uint8_t MsgData[8];
Enum_Result N_Result;
} ind;
} _N_USSFData;
typedef struct
{
struct
{
uint16_t N_TAtype; //PGN 55808--0xDA00
uint16_t Length;
uint8_t N_SA;
uint8_t N_TA;
uint8_t N_AE;
uint8_t N_PCI;
uint8_t MsgData[MaxBuff];
Enum_Result N_Result;
} ind;
} _N_USData;
typedef struct
{
struct
{
uint8_t len;
uint8_t MsgData[8];
uint8_t N_Result;
} ind;
} _N_RSPData;
typedef union
{
struct
{
uint8_t SubFunBit0_6 : 7;
uint8_t SubFunBit7_7 : 1;
} SubBits;
uint8_t SubData;
} _SubFun;
typedef struct
{
uint8_t SessionType;
uint8_t AccessLock;
uint8_t AccessCount;
uint8_t key[4];
uint8_t SubFunction;
uint8_t w27_Sequence;
uint8_t A5_Sequence;
uint8_t DTCSettingType;
uint8_t tDiagStart;
uint8_t tDiagKL30ONStart;
uint8_t N_STmin_0;
uint8_t N_REV_MAX_BS;
uint8_t CommType;
uint8_t CommCtl;
uint8_t DTCByStatusMask;
} _DiagnoCtl;
typedef struct
{
uint16_t N_TAtype; //PGN--55808--DA00
uint8_t FrameErr;
uint8_t RespSerId;
} _ErrorFrame;
typedef struct
{
uint32_t OverBsTime;
uint32_t BsTime;
uint32_t OverSTminTime;
uint32_t STminTime;
uint32_t OverCrTime;
uint32_t CrTime;
uint32_t OverSessionTime;
uint32_t SessionTime;
uint32_t OverSequenceTime;
uint32_t SequenceTime;
uint32_t OverUnlockTime;
uint32_t UnlockTime;
uint8_t TT_BsEnable;
uint8_t TT_STminEnable;
uint8_t TT_CrEnable;
uint8_t TT_SessionEnable;
uint8_t TT_SequenceEnable;
uint8_t TT_UnlockEnable;
uint8_t E2_WriteTime;
} _DiagClock;
typedef union
{
struct
{
uint32_t StructDTC[25];
} SubDTC;
uint8_t UnionDTC[100];
} _DiagReciveDTC;
typedef struct
{
uint8_t CoolantTemp[20];
uint8_t MilLamp;
} _DiagReciveGaugePara;
#include "UDS_Def.h"
#include "UDS_CFG.h"
#include "TP_Layer.h"
#include "Link_Layer.h"
#include "app_ServiceProc.h"
#include "app_Service.h"
extern _DiagReciveDTC DiagReciveDTC ;
extern _DiagReciveGaugePara DiagReciveGaugePara;
#endif /* _UDS_INCLUDES_H_ */
...@@ -41,5 +41,5 @@ const RSCANFD_Filter_st_t CANFD_RX_RULE_TABLE_LIST[CANFD0_RX_RULE_SIZE] = ...@@ -41,5 +41,5 @@ const RSCANFD_Filter_st_t CANFD_RX_RULE_TABLE_LIST[CANFD0_RX_RULE_SIZE] =
{0x98DBFFFAul, 0xDFFFFFFFUL, 0x80000000ul, CANFD0_CH0_RX_SELECT},/*24*/ {0x98DBFFFAul, 0xDFFFFFFFUL, 0x80000000ul, CANFD0_CH0_RX_SELECT},/*24*/
{0x000007E8ul, 0xDFFFFFFFUL, 0x80000000ul, CANFD0_CH2_RX_SELECT},/* 1*/ {0x000007E8ul, 0xDFFFFFFFUL, 0x80000000ul, CANFD0_CH2_RX_SELECT},/* 1*/
{0x00000111ul, 0xDFFFFFFFUL, 0x80000000ul, CANFD0_CH2_RX_SELECT},/* 2*/ //{0x00000111ul, 0xDFFFFFFFUL, 0x80000000ul, CANFD0_CH2_RX_SELECT},/* 2*/
}; };
\ No newline at end of file
...@@ -13,7 +13,7 @@ typedef struct ...@@ -13,7 +13,7 @@ typedef struct
#define CANFD0_CH0_RX_RULE_SIZE 24u #define CANFD0_CH0_RX_RULE_SIZE 24u
#define CANFD0_CH1_RX_RULE_SIZE 0U #define CANFD0_CH1_RX_RULE_SIZE 0U
#define CANFD0_CH2_RX_RULE_SIZE 2U #define CANFD0_CH2_RX_RULE_SIZE 1U
#define CANFD0_RX_RULE_SIZE (CANFD0_CH0_RX_RULE_SIZE + \ #define CANFD0_RX_RULE_SIZE (CANFD0_CH0_RX_RULE_SIZE + \
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include "Graphic.h" #include "Graphic.h"
#include "CAN_Communication_Matrix.h" #include "CAN_Communication_Matrix.h"
#include "CAN_FUNC.h"
#include "PowerManagement.h" #include "PowerManagement.h"
#include "System_Monitor.h" #include "System_Monitor.h"
...@@ -110,6 +111,7 @@ void Sys_Run_Mode_Pseudo_Real_Time_Tasks(void) ...@@ -110,6 +111,7 @@ void Sys_Run_Mode_Pseudo_Real_Time_Tasks(void)
UDS_Server_Application_Service(); UDS_Server_Application_Service();
IS31_Service(); IS31_Service();
BU98R10_Update_Service(); BU98R10_Update_Service();
} }
/*============================================================================*/ /*============================================================================*/
......
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