Обновление

This commit is contained in:
cfif 2026-01-21 13:22:11 +03:00
parent 6602dfafca
commit d1893882cb
2 changed files with 22 additions and 6 deletions

View File

@ -55,9 +55,17 @@ uint8_t setResponseError(tCanUds *env, eUdsServices service, eUdsResponseError e
// начало ----------------------------- Сессия ------------------------------------------------------------- // начало ----------------------------- Сессия -------------------------------------------------------------
static uint8_t DiagnosticSessionControl_10(tCanUds *env) { static uint8_t DiagnosticSessionControl_10(tCanUds *env) {
if ((env->data.len != 2) ||
(env->data.data[1] != UDS_session_defaultSession) ||
(env->data.data[1] != UDS_session_programmingSession) ||
(env->data.data[1] != UDS_session_extendedDiagnosticSession)) {
return setResponseError(env, UDS_DiagnosticSessionControl, UDS_error_incorrectMessageLengthOrInvalidFormat);
}
tDiagnosticSessionsType *diagnosticSessionsType = (tDiagnosticSessionsType *) env->dataResponse; tDiagnosticSessionsType *diagnosticSessionsType = (tDiagnosticSessionsType *) env->dataResponse;
diagnosticSessionsType->ServiceId = env->data.data[0] | 0b1000000; diagnosticSessionsType->ServiceId = UDS_DiagnosticSessionControl | 0b1000000;
diagnosticSessionsType->diagnosticSessionType = env->data.data[1] & 0b1111111; diagnosticSessionsType->diagnosticSessionType = env->data.data[1];
diagnosticSessionsType->sessionParameterRecord[0] = 0; diagnosticSessionsType->sessionParameterRecord[0] = 0;
diagnosticSessionsType->sessionParameterRecord[1] = 0x32; diagnosticSessionsType->sessionParameterRecord[1] = 0x32;
@ -89,7 +97,7 @@ static uint8_t ReadDataByIdentifier_22(tCanUds *env) {
if (uds_ReadDataByIdentifier_22_com_CF[dataIdentifier_lo].data != NULL) { if (uds_ReadDataByIdentifier_22_com_CF[dataIdentifier_lo].data != NULL) {
uint8_t response_size = uds_ReadDataByIdentifier_22_com_CF[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] = UDS_ReadDataByIdentifier | 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_CF[dataIdentifier_lo].data, response_size); memcpy(&env->dataResponse[3], uds_ReadDataByIdentifier_22_com_CF[dataIdentifier_lo].data, response_size);
@ -102,12 +110,12 @@ static uint8_t ReadDataByIdentifier_22(tCanUds *env) {
if (dataIdentifier_hi == 0xF1) { if (dataIdentifier_hi == 0xF1) {
if (uds_ReadDataByIdentifier_22_com_F1[dataIdentifier_lo].data != NULL) { if (uds_ReadDataByIdentifier_22_com_F1[dataIdentifier_lo].data != NULL) {
uint8_t response_size = uds_ReadDataByIdentifier_22_com_CF[dataIdentifier_lo].size; uint8_t response_size = uds_ReadDataByIdentifier_22_com_F1[dataIdentifier_lo].size;
env->dataResponse[0] = env->data.data[0] | 0b1000000; env->dataResponse[0] = UDS_ReadDataByIdentifier | 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_CF[dataIdentifier_lo].data, response_size); memcpy(&env->dataResponse[3], uds_ReadDataByIdentifier_22_com_F1[dataIdentifier_lo].data, response_size);
return response_size; return response_size;
} }

View File

@ -30,6 +30,14 @@ typedef enum {
} eUdsResponseError; } eUdsResponseError;
typedef enum {
UDS_session_defaultSession = 0x1,
UDS_session_programmingSession= 0x2,
UDS_session_extendedDiagnosticSession= 0x3
} eUdsSession;
typedef struct { typedef struct {
tCanSerialPortFrameTp canSerialPortFrameTp; tCanSerialPortFrameTp canSerialPortFrameTp;
tLoggerInterface *logger; tLoggerInterface *logger;