#include "UDS.h" #include uint8_t status_rq; const uint16_t TIMEOUT_TX_S = 70;// ((uint16_t)700/I15765CFG_TICK_PERIOD) /* tx of CAN frm */ const uint16_t TIMEOUT_TX_R = 70;// ((uint16_t)700/I15765CFG_TICK_PERIOD) /* tx of CAN frm */ const uint16_t TIMEOUT_FC_S = 150;//((uint16_t)1500/I15765CFG_TICK_PERIOD) /* rx of FC */ const uint16_t TIMEOUT_FC_R = 20;//((uint16_t)200/I15765CFG_TICK_PERIOD) /* tx of FC */ const uint16_t TIMEOUT_CF_S = 70;//((uint16_t)700/I15765CFG_TICK_PERIOD) /* tx of CF */ const uint16_t TIMEOUT_CF_R = 150;//((uint16_t)1500/I15765CFG_TICK_PERIOD) /* rx of CF */ /* update period (1 ms units) */ const uint16_t I15765CFG_TICK_PERIOD = 1; //ms const uint8_t UDS_CAN_COM = 0; const uint32_t UDS_TX_MAILBOX = 0; const uint32_t UDS_ECU_RX_MAILBOX = 13; const uint32_t UDS_RX_MAILBOX_FUNCTION = 14; //UDS const uint32_t UDS_RX_MAILBOX_PHYSICAL = 15; //UDS mailbox 0x7DF const uint32_t UDS_RX_ID = 0x701; const uint32_t UDS_TX_ID = 0x709; const uint8_t BUFFER_DATA_LAST = 0x55; const uint8_t BS = 0;//0x08; //Block size const uint8_t STmin = 1;//0x14; //Minimum Separation Time const uint64_t Error_DTC_All = B0 | B1 | B2 | B3 | B4 | B5 | B6 | B7 | B8 | B9 | B10 | B11 | B12 | B13 | B14 | B15 | B16 | B17 | B18 | B19 | B20 | B21 | B22; /* ** Initialization routine. */ void i15765app_init(void) { DiagnosticSessionType = 0x02; } /* ** Indicates a message has been received ** INPUT: msg - pointer to the message */ #if 0 void i15765app_process(i15765_t *msg) { //SID ������ж� data[1] switch (msg->buf[0]) { //��ϻỰ���� case 0x10: { SID_10_function(msg); break; } //��ص�Ԫ��λ case 0x11: { SID_11_function(msg); break; } //��������Ϣ case 0x14: { SID_14_function(msg); break; } //��ȡ DTC ��Ϣ case 0x19: { SID_19_function(msg); break; } //��ȡ���� case 0x22: { SID_22_function(msg); break; } //��ȫ���� case 0x27: { SID_27_function(msg); break; } //ͨ�ſ��� case 0x28: { SID_28_function(msg); break; } //д������ �谲ȫ���� case 0x2E: { SID_2E_function(msg); break; } /* //����������� �谲ȫ���� case 0x2F: { SID_2F_function(msg); } */ //���̿��� �谲ȫ���� case 0x31: { SID_31_function(msg); break; } //�������� �谲ȫ���� case 0x34: { SID_34_function(msg); break; } //���ݴ��� �谲ȫ���� case 0x36: { SID_36_function(msg); break; } //�����˳����� �谲ȫ���� case 0x37: { SID_37_function(msg); break; } //����豸���� �谲ȫ���� case 0x3E: { SID_3E_function(msg); break; } //���� DTC ���� case 0x85: { SID_85_function(msg); break; } default: { if (msg->tat == I15765_TAT_NP11) { NegativeResponse(msg->buf[0], 0x11); //���ij��ȴ�����߸�ʽ�Ƿ� break; } } } } #else #define MAX_MSG_LENGTH 4096 i15765_t msg_new = {0}; uint8_t msg_new_buf[MAX_MSG_LENGTH]; uint8_t SID_11_flag = 0; uint8_t SID_2E_flag = 0; uint8_t SID_31_flag = 0; uint8_t SID_34_flag = 0; uint8_t SID_36_flag = 0; uint8_t SID_37_flag = 0; void i15765app_process(i15765_t *msg) { msg_new.buf_len = msg->buf_len; msg_new.ID = msg->ID; // 深拷贝缓冲区 memcpy(msg_new_buf, msg->buf, msg->buf_len); msg_new.buf = msg_new_buf; // 指向我们的缓冲区 switch (msg->buf[0]) { case 0x11: { SID_11_flag = 1; // SID_11_function(msg); break; } case 0x2E: { SID_2E_flag = 1; // SID_2E_function(msg); break; } case 0x31: { SID_31_flag = 1; // SID_31_function(msg); break; } case 0x34: { SID_34_flag = 1; // SID_34_function(msg); break; } case 0x36: { SID_36_flag = 1; // SID_36_function(msg); break; } case 0x37: { SID_37_flag = 1; // SID_37_function(msg); break; } default: { if (msg->tat == I15765_TAT_NP11) { NegativeResponse(msg->buf[0], 0x11); break; } } } } void check_SID_run(void) { if(SID_11_flag == 1) { SID_11_flag = 0; SID_11_function(&msg_new); } if(SID_31_flag == 1) { SID_31_flag = 0; SID_31_function(&msg_new); } if(SID_34_flag == 1) { SID_34_flag = 0; SID_34_function(&msg_new); } if(SID_36_flag == 1) { SID_36_flag = 0; SID_36_function(&msg_new); } if(SID_37_flag == 1) { SID_37_flag = 0; SID_37_function(&msg_new); } } #endif