Обновление платы на V2

This commit is contained in:
cfif 2026-05-05 15:36:29 +03:00
parent 2a7f6dbd2a
commit b83c8e1efb
2 changed files with 73 additions and 371 deletions

View File

@ -14,8 +14,6 @@ void Diagnostic_Init(tDiagnostic *env, tLoggerInterface *logger) {
env->logger = logger; env->logger = logger;
env->queue = osMessageQueueNew(DIAGNOSTIC_QUEUE_SIZE, 1, NULL);
env->access = osMutexNew(NULL); env->access = osMutexNew(NULL);
// for (uint8_t i = 0; i < COUNT_DTC_CODE_ERROR; ++i) { // for (uint8_t i = 0; i < COUNT_DTC_CODE_ERROR; ++i) {
@ -28,23 +26,31 @@ void Diagnostic_Init(tDiagnostic *env, tLoggerInterface *logger) {
// osPriorityNormal); // osPriorityNormal);
} }
static uint32_t diagnostic_ClearDiagnosticInformation_14(tDiagnostic *env, void *extEnv) { uint32_t diagnostic_ClearDiagnosticInformation_14(tDiagnostic *env) {
// for (uint8_t i = 0; i < COUNT_DTC_CODE_ERROR; ++i) { if (osMutexAcquire(env->access, 5000) == osOK) {
// for (uint8_t i = 0; i < COUNT_DTC_CODE_ERROR; ++i) {
// Тест DTC не был выполнен с момента последней очистки // Тест DTC не был выполнен с момента последней очистки
// dtc_state_error[i] |= UDS_dtc_mask_testNotCompletedSinceLastClear; // dtc_state_error[i] |= UDS_dtc_mask_testNotCompletedSinceLastClear;
// dtc_state_FIX_error[i] |= UDS_dtc_mask_testNotCompletedSinceLastClear; // dtc_state_FIX_error[i] |= UDS_dtc_mask_testNotCompletedSinceLastClear;
// } // }
osMutexRelease(env->access);
} else {
LoggerInfoStatic(LOGGER, LOG_SIGN, "Access error diagnostic_ClearDiagnosticInformation_14");
}
return 0; return 0;
} }
static uint32_t diagnostic_UDS_ReadDTCInformation_19_count(tDiagnostic *env, void *extEnv) { uint32_t diagnostic_UDS_ReadDTCInformation_19_count(tDiagnostic *env, tDiagnosticDTC *diagnosticDTC) {
tDiagnosticDTC *diagnosticDTC = (tDiagnosticDTC *) extEnv;
uint32_t countDTC = 0; uint32_t countDTC = 0;
if (osMutexAcquire(env->access, 5000) == osOK) {
for (uint8_t i = 0; i < COUNT_DTC_CODE_ERROR; ++i) { for (uint8_t i = 0; i < COUNT_DTC_CODE_ERROR; ++i) {
if (env->isNoBitsDTC) { if (env->isNoBitsDTC) {
@ -59,15 +65,21 @@ static uint32_t diagnostic_UDS_ReadDTCInformation_19_count(tDiagnostic *env, voi
} }
osMutexRelease(env->access);
} else {
LoggerInfoStatic(LOGGER, LOG_SIGN, "Access error diagnostic_ClearDiagnosticInformation_14");
}
return countDTC; return countDTC;
} }
static uint32_t diagnostic_UDS_ReadDTCInformation_19_dtc(tDiagnostic *env, void *extEnv) { uint32_t diagnostic_UDS_ReadDTCInformation_19_dtc(tDiagnostic *env, tDiagnosticDTC *diagnosticDTC) {
tDiagnosticDTC *diagnosticDTC = (tDiagnosticDTC *) extEnv;
uint32_t size = 0; uint32_t size = 0;
if (osMutexAcquire(env->access, 5000) == osOK) {
for (uint8_t i = 0; i < COUNT_DTC_CODE_ERROR; ++i) { for (uint8_t i = 0; i < COUNT_DTC_CODE_ERROR; ++i) {
if (env->isNoBitsDTC) { if (env->isNoBitsDTC) {
@ -89,16 +101,22 @@ static uint32_t diagnostic_UDS_ReadDTCInformation_19_dtc(tDiagnostic *env, void
} }
} }
osMutexRelease(env->access);
} else {
LoggerInfoStatic(LOGGER, LOG_SIGN, "Access error diagnostic_UDS_ReadDTCInformation_19_dtc");
}
return size; return size;
} }
static uint32_t diagnostic_UDS_ReadDTCSupportDTC_19_dtc(tDiagnostic *env, void *extEnv) { uint32_t diagnostic_UDS_ReadDTCSupportDTC_19_dtc(tDiagnostic *env, tDiagnosticDTC *diagnosticDTC) {
tDiagnosticDTC *diagnosticDTC = (tDiagnosticDTC *) extEnv;
uint32_t size = 0; uint32_t size = 0;
if (osMutexAcquire(env->access, 5000) == osOK) {
for (uint8_t i = 0; i < COUNT_DTC_CODE_ERROR; ++i) { for (uint8_t i = 0; i < COUNT_DTC_CODE_ERROR; ++i) {
diagnosticDTC->dataResponse[size] = dtc_codes[i].DTCHighByte; diagnosticDTC->dataResponse[size] = dtc_codes[i].DTCHighByte;
@ -108,285 +126,15 @@ static uint32_t diagnostic_UDS_ReadDTCSupportDTC_19_dtc(tDiagnostic *env, void *
size += 4; size += 4;
} }
osMutexRelease(env->access);
} else {
LoggerInfoStatic(LOGGER, LOG_SIGN, "Access error diagnostic_UDS_ReadDTCSupportDTC_19_dtc");
}
return size; return size;
} }
const eDiagnosticState diagnostic_com[] = {
{diagnostic_ClearDiagnosticInformation_14, "diagnostic_ClearDiagnosticInformation_14"},
{diagnostic_UDS_ReadDTCInformation_19_count, "diagnostic_UDS_ReadDTCInformation_19_count"},
{diagnostic_UDS_ReadDTCInformation_19_dtc, "diagnostic_UDS_ReadDTCInformation_19_dtc"},
{diagnostic_UDS_ReadDTCSupportDTC_19_dtc, "diagnostic_UDS_ReadDTCSupportDTC_19_dtc"},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""},
{NULL, ""}
};
uint32_t SetGetDiagnosticData(tDiagnostic *env, eDiagnosticType diagnosticType, void *extEnv) {
uint32_t ret = 0;
if (diagnostic_com[diagnosticType].func != NULL) {
if (osMutexAcquire(env->access, 5000) == osOK) {
ret = diagnostic_com[diagnosticType].func(env, extEnv);
osMutexRelease(env->access);
} else {
LoggerInfoStatic(LOGGER, LOG_SIGN, "Access error SetGetDiagnosticData");
}
}
return ret;
}
void set_NoBitsDTC(tDiagnostic *env, bool noBitsDTC) { void set_NoBitsDTC(tDiagnostic *env, bool noBitsDTC) {
if (osMutexAcquire(env->access, 5000) == osOK) { if (osMutexAcquire(env->access, 5000) == osOK) {
@ -399,8 +147,7 @@ void set_NoBitsDTC(tDiagnostic *env, bool noBitsDTC) {
} }
} }
// Ошибки DTC void set_Dtc_state(tDiagnostic *env) {
void set_Dtc_state_error(tDiagnostic *env) {
if (osMutexAcquire(env->access, 1000) == osOK) { if (osMutexAcquire(env->access, 1000) == osOK) {
memcpy(&dtc_state_error, &rtY.dtc_state_error_model, sizeof(dtc_state_error)); memcpy(&dtc_state_error, &rtY.dtc_state_error_model, sizeof(dtc_state_error));
osMutexRelease(env->access); osMutexRelease(env->access);
@ -409,24 +156,3 @@ void set_Dtc_state_error(tDiagnostic *env) {
} }
} }
static _Noreturn void Diagnostic_Thread(tDiagnostic *env) {
for (;;) {
osStatus_t status = osMessageQueueGet(env->queue, &env->diagnosticType, 0, 1000);
if (status == osOK) {
if (osMutexAcquire(env->access, 1000) == osOK) {
osMutexRelease(env->access);
}
}
}
}
void Diagnostic_StartThread(tDiagnostic *env) {
// if (!env->thread.id) {
// env->thread.id = osThreadNew((osThreadFunc_t) (Diagnostic_Thread), (void *) (env), &env->thread.attr);
// }
}

View File

@ -8,14 +8,6 @@
#include <cmsis_os.h> #include <cmsis_os.h>
#include "LoggerInterface.h" #include "LoggerInterface.h"
#define DIAGNOSTIC_QUEUE_SIZE 10
typedef enum {
DIAGNOSTIC_UDS_ClearDiagnosticInformation_14 = 0x00,
DIAGNOSTIC_UDS_ReadDTCInformation_19_1 = 0x01,
DIAGNOSTIC_UDS_ReadDTCInformation_19_2 = 0x02,
DIAGNOSTIC_UDS_ReadDTCInformation_19_A = 0x03
} eDiagnosticType;
typedef struct { typedef struct {
uint8_t mask; uint8_t mask;
@ -24,36 +16,20 @@ typedef struct {
typedef struct { typedef struct {
osMutexId_t access; osMutexId_t access;
osMessageQueueId_t queue;
eDiagnosticType diagnosticType;
tLoggerInterface *logger; tLoggerInterface *logger;
bool isNoBitsDTC; bool isNoBitsDTC;
// struct {
// osThreadId_t id;
// uint32_t stack[512];
// StaticTask_t controlBlock;
// osThreadAttr_t attr;
// } thread;
} tDiagnostic; } tDiagnostic;
typedef uint32_t (*diagnostic_func_ptr)(tDiagnostic *env, void *extEnv);
typedef struct {
diagnostic_func_ptr func;
char *desc;
} eDiagnosticState;
void Diagnostic_Init(tDiagnostic *env, tLoggerInterface *logger); void Diagnostic_Init(tDiagnostic *env, tLoggerInterface *logger);
void Diagnostic_StartThread(tDiagnostic *env);
void set_NoBitsDTC(tDiagnostic *env, bool noBitsDTC); void set_NoBitsDTC(tDiagnostic *env, bool noBitsDTC);
void set_Dtc_state(tDiagnostic *env);
void set_Dtc_state_error(tDiagnostic *env); uint32_t diagnostic_ClearDiagnosticInformation_14(tDiagnostic *env);
uint32_t diagnostic_UDS_ReadDTCInformation_19_count(tDiagnostic *env, tDiagnosticDTC *diagnosticDTC);
uint32_t SetGetDiagnosticData(tDiagnostic *env, eDiagnosticType diagnosticType, void *extEnv); uint32_t diagnostic_UDS_ReadDTCInformation_19_dtc(tDiagnostic *env, tDiagnosticDTC *diagnosticDTC);
uint32_t diagnostic_UDS_ReadDTCSupportDTC_19_dtc(tDiagnostic *env, tDiagnosticDTC *diagnosticDTC);
#endif //HVAC_M7_DIAGNOSTICTASK_H #endif //HVAC_M7_DIAGNOSTICTASK_H