Обновление

This commit is contained in:
cfif 2026-01-21 12:12:37 +03:00
parent dee734d1da
commit 6602dfafca
2 changed files with 40 additions and 6 deletions

View File

@ -42,6 +42,14 @@ void ReceivedTP_func(void *arg, tCanTP_data *data) {
} }
uint8_t setResponseError(tCanUds *env, eUdsServices service, eUdsResponseError error) {
env->dataResponse[0] = 0x7F;
env->dataResponse[1] = service;
env->dataResponse[2] = error;
return 3;
}
// начало ----------------------------- Сессия ------------------------------------------------------------- // начало ----------------------------- Сессия -------------------------------------------------------------
// начало ----------------------------- Сессия ------------------------------------------------------------- // начало ----------------------------- Сессия -------------------------------------------------------------
// начало ----------------------------- Сессия ------------------------------------------------------------- // начало ----------------------------- Сессия -------------------------------------------------------------
@ -68,32 +76,45 @@ static uint8_t DiagnosticSessionControl_10(tCanUds *env) {
// начало --------------------------- Чтение --------------------------------------------------------- // начало --------------------------- Чтение ---------------------------------------------------------
static uint8_t ReadDataByIdentifier_22(tCanUds *env) { static uint8_t ReadDataByIdentifier_22(tCanUds *env) {
if (env->data.len != 3) {
return setResponseError(env, UDS_ReadDataByIdentifier, UDS_error_incorrectMessageLengthOrInvalidFormat);
}
uint8_t dataIdentifier_hi = env->data.data[1]; uint8_t dataIdentifier_hi = env->data.data[1];
uint8_t dataIdentifier_lo = env->data.data[2]; uint8_t dataIdentifier_lo = env->data.data[2];
uint16_t dataIdentifier = (dataIdentifier_hi << 8) | dataIdentifier_lo; // uint16_t dataIdentifier = (dataIdentifier_hi << 8) | dataIdentifier_lo;
if (dataIdentifier_hi == 0xCF) { if (dataIdentifier_hi == 0xCF) {
if (uds_ReadDataByIdentifier_22_com[dataIdentifier_lo].data != NULL) { if (uds_ReadDataByIdentifier_22_com_CF[dataIdentifier_lo].data != NULL) {
uint8_t response_size = uds_ReadDataByIdentifier_22_com[dataIdentifier_lo].size; uint8_t response_size = uds_ReadDataByIdentifier_22_com_CF[dataIdentifier_lo].size;
env->dataResponse[0] = env->data.data[0] | 0b1000000; env->dataResponse[0] = env->data.data[0] | 0b1000000;
env->dataResponse[1] = dataIdentifier_hi; env->dataResponse[1] = dataIdentifier_hi;
env->dataResponse[2] = dataIdentifier_lo; env->dataResponse[2] = dataIdentifier_lo;
memcpy(&env->dataResponse[3], uds_ReadDataByIdentifier_22_com[dataIdentifier_lo].data, response_size); memcpy(&env->dataResponse[3], uds_ReadDataByIdentifier_22_com_CF[dataIdentifier_lo].data, response_size);
return response_size; return response_size;
} }
if (dataIdentifier_lo == 0xFF) { }
if (dataIdentifier_hi == 0xF1) {
if (uds_ReadDataByIdentifier_22_com_F1[dataIdentifier_lo].data != NULL) {
uint8_t response_size = uds_ReadDataByIdentifier_22_com_CF[dataIdentifier_lo].size;
env->dataResponse[0] = env->data.data[0] | 0b1000000; env->dataResponse[0] = env->data.data[0] | 0b1000000;
env->dataResponse[1] = dataIdentifier_hi; env->dataResponse[1] = dataIdentifier_hi;
env->dataResponse[2] = dataIdentifier_lo; env->dataResponse[2] = dataIdentifier_lo;
memcpy(&env->dataResponse[3], uds_ReadDataByIdentifier_22_com[dataIdentifier_lo].data, response_size); memcpy(&env->dataResponse[3], uds_ReadDataByIdentifier_22_com_CF[dataIdentifier_lo].data, response_size);
return response_size;
} }
} }
return setResponseError(env, UDS_ReadDataByIdentifier, UDS_error_requestOutOfRange);
} }
// конец --------------------------- Чтение --------------------------------------------------------- // конец --------------------------- Чтение ---------------------------------------------------------
// конец --------------------------- Чтение --------------------------------------------------------- // конец --------------------------- Чтение ---------------------------------------------------------
@ -411,10 +432,12 @@ void CanSerialPortCanUds_Start(tCanUds *env) {
void CanUds_Init( void CanUds_Init(
tCanUds *env, tCanUds *env,
tSerialPortFrameIO *CanIO, tSerialPortFrameIO *CanIO,
tDeviceStorage *deviceStorage,
tLoggerInterface *logger) { tLoggerInterface *logger) {
env->logger = logger; env->logger = logger;
env->CanIO = CanIO; env->CanIO = CanIO;
env->deviceStorage = deviceStorage;
env->filterIdCount = 0; env->filterIdCount = 0;
env->queue = osMessageQueueNew(CAN_US_QUEUE_SIZE, sizeof(tCanTP_data), NULL); env->queue = osMessageQueueNew(CAN_US_QUEUE_SIZE, sizeof(tCanTP_data), NULL);

View File

@ -6,6 +6,7 @@
#define HVAC_M7_CANUDS_H #define HVAC_M7_CANUDS_H
#include "CanSerialPortFrameTP.h" #include "CanSerialPortFrameTP.h"
#include "DeviceStorage.h"
#define CAN_US_QUEUE_SIZE 3 #define CAN_US_QUEUE_SIZE 3
@ -21,10 +22,19 @@ typedef enum {
UDS_SecurityAccess = 0x27 UDS_SecurityAccess = 0x27
} eUdsServices; } eUdsServices;
typedef enum {
UDS_error_incorrectMessageLengthOrInvalidFormat = 0x13,
UDS_error_responseTooLong= 0x14,
UDS_error_requestOutOfRange= 0x31,
UDS_error_securityAccessDenied= 0x33
} eUdsResponseError;
typedef struct { typedef struct {
tCanSerialPortFrameTp canSerialPortFrameTp; tCanSerialPortFrameTp canSerialPortFrameTp;
tLoggerInterface *logger; tLoggerInterface *logger;
tSerialPortFrameIO *CanIO; tSerialPortFrameIO *CanIO;
tDeviceStorage *deviceStorage;
tCanTP_Ext_data canTP_Ext_data; tCanTP_Ext_data canTP_Ext_data;
@ -51,6 +61,7 @@ typedef struct {
void CanUds_Init( void CanUds_Init(
tCanUds *env, tCanUds *env,
tSerialPortFrameIO *CanIO, tSerialPortFrameIO *CanIO,
tDeviceStorage *deviceStorage,
tLoggerInterface *logger); tLoggerInterface *logger);
void CanSerialPortCanUds_Start(tCanUds *env); void CanSerialPortCanUds_Start(tCanUds *env);