HVAC_M7_CAN_UDS/CanUds.h

115 lines
2.8 KiB
C

//
// Created by cfif on 20.01.2026.
//
#ifndef HVAC_M7_CANUDS_H
#define HVAC_M7_CANUDS_H
#include "CanSerialPortFrameTP.h"
#include "DeviceStorage.h"
#include "DiagnosticTask.h"
#define CAN_US_QUEUE_SIZE 3
// Время (логарифмическая шкала)
// │
// ├── StMin (0.1-127 мс) ← Между КАДРАМИ
// │ │
// ├── N_As, N_Bs (до 1000 мс) ← Транспортные таймауты
// │ │
// ├── P2Server (до 50 мс) ← Между СООБЩЕНИЯМИ (UDS)
// │ │
// ├── P2*Server (до 5000 мс) ← Ожидание при ResponsePending
// │ │
// └── S3_Server (до 5000 мс) ← ТАЙМЕР ВСЕЙ СЕССИИ
typedef enum {
UDS_DiagnosticSessionControl = 0x10,
UDS_ReadDTCInformation = 0x19,
UDS_ClearDiagnosticInformation = 0x14,
UDS_TesterPresent = 0x3E,
UDS_ReadDataByIdentifier = 0x22,
UDS_WriteDataByIdentifier = 0x2E,
UDS_RoutineControl = 0x31,
UDS_ECUResetService = 0x11,
UDS_InputOutputControlByIdentifier = 0x2F,
UDS_SecurityAccess = 0x27
} eUdsServices;
typedef enum {
UDS_error_incorrectMessageLengthOrInvalidFormat = 0x13,
UDS_error_responseTooLong = 0x14,
UDS_error_requestOutOfRange = 0x31,
UDS_error_securityAccessDenied = 0x33,
UDS_error_sub_functionNotSupported = 0x12,
UDS_error_conditionsNotCorrect = 0x22
} eUdsResponseError;
typedef enum {
UDS_session_defaultSession = 0x1,
UDS_session_programmingSession = 0x2,
UDS_session_extendedDiagnosticSession = 0x3
} eUdsSession;
typedef enum {
UDS_io_returnControlToECU = 0x0,
UDS_io_shortTermAdjustment = 0x3
} eUdsIO;
typedef enum {
UDS_dtc_reportNumberOfDTCByStatusMask = 0x1,
UDS_dtc_reportDTCByStatusMask = 0x2
} eUdsDtc;
typedef enum {
UDS_reset_hardReset = 0x1,
UDS_reset_softReset = 0x3
} eUdsReset;
typedef struct {
eUdsServices service;
uint8_t sub_function;
uint8_t *data;
} tUdsServiceCommand;
typedef struct {
tCanSerialPortFrameTp canSerialPortFrameTp;
tLoggerInterface *logger;
tSerialPortFrameIO *CanIO;
tDeviceStorage *deviceStorage;
tDiagnostic *Diagnostic;
tCanTP_Ext_data canTP_Ext_data;
osMessageQueueId_t queue;
tCanTP_data data;
uint8_t dataResponse[1024];
uint8_t filterIdCount;
uint32_t filterReqId[16];
uint32_t filterRespId[16];
uint8_t filterDirReq[16];
tStaticThreadBlock(512) T_can_Uds;
} tCanUds;
typedef uint16_t (*uds_func_ptr)(tCanUds *env);
typedef struct {
uds_func_ptr func;
char *desc;
} eUds_com;
void CanUds_Init(
tCanUds *env,
tDiagnostic *Diagnostic,
tSerialPortFrameIO *CanIO,
tDeviceStorage *deviceStorage,
tLoggerInterface *logger);
void CanSerialPortCanUds_Start(tCanUds *env);
#endif //HVAC_M7_CANUDS_H