126 lines
3.8 KiB
C
126 lines
3.8 KiB
C
/*!
|
|
* @file uds_services.h
|
|
* @brief uds services handler.
|
|
*
|
|
*/
|
|
|
|
#ifndef UDS_SERVICES_H_
|
|
#define UDS_SERVICES_H_
|
|
|
|
#include "uds_types.h"
|
|
|
|
|
|
|
|
#define UDS_UP_FLG 0
|
|
|
|
#define CHECK_SIGN_MAX 1024
|
|
|
|
|
|
#define UDS_P2Sever 50 //50ms
|
|
#define UDS_P2SeverMax 500 //5s
|
|
#define UDS_S3Sever 5000 //5s
|
|
|
|
#define UDS_ID0 0
|
|
#define UDS_ID1 1
|
|
|
|
#define UDS_27SERVICE_ERR_NUM_MAX 2
|
|
|
|
/*!
|
|
* Enum Type. Session Control Type.
|
|
*/
|
|
|
|
typedef enum
|
|
{
|
|
UDS_SERVICE_10_DEFAULTSESSION = 1, /*!< Default Session */
|
|
UDS_SERVICE_10_ECUPROGRAMMINGSESSION, /*!< Programming Session */
|
|
UDS_SERVICE_10_ECUEXTENDEDSESSION, /*!< Extended Session */
|
|
UDS_SERVICE_10_EOLSESSION /*!< Extended Session */
|
|
}UDS_SERVICE_10_SESSION_CTRL_T;
|
|
|
|
/*!
|
|
* Enum Type. Service 27 Type: Request Seed or send key
|
|
*/
|
|
|
|
|
|
typedef enum
|
|
{
|
|
UDS_SERVICE_27_REQUEST_SEED = 0x05, /*!< Request Seed */
|
|
UDS_SERVICE_27_SEND_KEY=0x06, /*!< Send Key */
|
|
UDS_SERVICE_27_REQUEST_FBL_SEED = 0x03,
|
|
UDS_SERVICE_27_SEND_FBL_KEY = 0x04
|
|
}UDS_SERVICE_27_T;
|
|
|
|
|
|
typedef enum
|
|
{
|
|
SECURITY_LEVEL_NULL = 0,
|
|
SECURITY_LEVEL_1 = 1,
|
|
SECURITY_LEVEL_FBL = 2,
|
|
}UDS_SERVICE_27_LEVEL;
|
|
|
|
typedef enum
|
|
{
|
|
IO_CTRL_returnControlToECU = 0,
|
|
IO_CTRL_resetToDefault = 1,
|
|
IO_CTRL_freezeCurrentState = 2,
|
|
IO_CTRL_shortTermAdjustment = 3,
|
|
}UDS_SERVICE_2F_PARAM;
|
|
|
|
typedef enum {
|
|
ERASE_MEMORY_STS_NONE,
|
|
ERASE_MEMORY_STS_IN_PROGRESS,
|
|
ERASE_MEMORY_STS_COMPLETED,
|
|
ERASE_MEMORY_STS_FAILURE,
|
|
}UDS_EraseMemoryStsTypeDef;
|
|
|
|
//诊断服务
|
|
#define DIAG_SERVE_SESSION_CONTROL 0x10 //会话
|
|
#define DIAG_SERVE_ECU_RESET 0x11 //ECU复位
|
|
#define DIAG_SERVE_CLEAR_DTC 0x14 //清除DTC
|
|
#define DIAG_SERVE_READ_DTC 0x19 //读取DTC
|
|
#define DIAG_SERVE_READ_DATA 0x22 //读数据
|
|
#define DIAG_SERVE_READ_MEMORY 0x23 //读内存
|
|
#define DIAG_SERVE_SECURITY_ACCESS 0x27 //安全访问
|
|
#define DIAG_SERVE_COMMUNICATION_CONTROL 0x28 //通信控制
|
|
#define DIAG_SERVE_WRITE_DATA 0x2E //写数据
|
|
#define DIAG_SERVE_IOPUT_CONTROL 0x2F //输入输出控制
|
|
#define DIAG_SERVE_ROUTINE_CONTROL 0x31 //例程控制
|
|
#define DIAG_SERVE_REQUEST_DOWNLOAD 0x34 //请求下载
|
|
#define DIAG_SERVE_TRANSFER_DATA 0x36 //数据传输
|
|
#define DIAG_SERVE_REQUEST_TRANSFER_EXIT 0x37 //请求退出传输
|
|
#define DIAG_SERVE_WRITE_MEMORY 0x3D //写入内存
|
|
#define DIAG_SERVE_TESTER_PRESENT 0x3E //测试设备在线
|
|
#define DIAG_SERVE_NRC 0x7F //否定应答码
|
|
#define DIAG_SERVE_CONTROL_DTC 0x85 //控制DTC
|
|
|
|
|
|
void UDS_Service_Init(void);
|
|
void UDS_Service_34_Ack(uint8_t *pDst,uint16_t pLen);
|
|
void UDS_Service_Transmit_Confirmed(void);
|
|
void UDS_Service_Response_Handler(uint16_t TPReceivexMessageLength, uint8_t N_Result, uint8_t* Rec_Bufer);
|
|
void UDS_Service_37(uint8_t *pdata,uint16_t length);
|
|
void UDS_Service_36(uint8_t* dataBuf, uint16_t BufLen);
|
|
void UDS_Service_34(uint8_t dataformat, uint8_t addrLenFormat, uint8_t* memBuf, uint8_t* sizeBuf);
|
|
void UDS_Service_31(uint8_t* routine_buf, uint8_t bufLen);
|
|
void UDS_Service_27(UDS_SERVICE_27_T in_service, uint8_t *requ, uint8_t* keyBuf);
|
|
void UDS_Service_10_Response(uint8_t in_session);
|
|
void UDS_Service_29(uint8_t* routine_buf, uint8_t bufLen);
|
|
|
|
void UDS_Service_0x19_Response(void);
|
|
void UDS_Service_0x22_Response(void);
|
|
void UDS_Service_0x2E_Response(INT8U *pIn,INT16U pLen);
|
|
void UDS_Service_0x3E_Response(INT8U *pIn);
|
|
void UDS_Service_28(uint8_t* routine_buf, uint8_t bufLen);
|
|
void UDS_Service_20(uint8_t* routine_buf, uint8_t bufLen);
|
|
void UDS_Service_85(uint8_t* routine_buf, uint8_t bufLen);
|
|
void UDS_Service_14(uint8_t* routine_buf, uint8_t bufLen);
|
|
void UDS_Service_11(uint8_t* routine_buf);
|
|
void UDS_Service_NonSupport_Response(INT8U pIn);
|
|
void UDS_Service_31(uint8_t* routine_buf, uint8_t bufLen);
|
|
void UDS_Service_36_Ack(uint8_t* routine_buf, uint8_t bufLen);
|
|
void UDS_Service_0x2F_Response(void);
|
|
void UDS_Nrc78PostProcessing(void);
|
|
|
|
|
|
#endif /* UDS_SERVICES_H_ */
|