1.勾选使能传输层和支持诊断功能,在下面选择框中勾选需要的诊断服务。
2.导入组件,请根据自己的芯片型号导入响应协议栈,否则组件无法生成代码。
3.将此代码复制进代码中,在程序中调用函数。
typedef enum
{
Positive_response=0,
Negitive_response,
}UDS_ON_LIN_RESPONSE;
/*Init*/
l_sys_init();
l_ifc_init(LI0);
ld_init(LI0);
l_sch_set(LI0, LI0_NormalTable1, 0u);
/*Function*/
UDS_ON_LIN_RESPONSE UDS_ON_LIN_task()
{
UDS_ON_LIN_RESPONSE Retuen_code=Negitive_response;
static uint8_t linRxBuff[8] = {0};
static uint8_t linTxBuff[8] = {0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18};
g_lin_protocol_state_array[LI0].response_buffer_ptr=linRxBuff;
diag_write_data_by_identifier(LI0,74,5,linTxBuff);//2E diagnosic command
if(l_flg_tst_LI0_MasterReq_flag()==true){
l_flg_clr_LI0_MasterReq_flag();
(void)lin_lld_tx_header(LI0, 0X3D);
}
if(l_flg_tst_LI0_SlaveResp_flag()==true)
{
l_flg_clr_LI0_SlaveResp_flag();
if(linRxBuff[1]==0x11)
{
Retuen_code=Positive_response;
}
}
return Retuen_code;
}