Обновление

This commit is contained in:
cfif 2026-01-27 14:33:09 +03:00
parent 4bb2542529
commit a2a6f8d4e5
1 changed files with 19 additions and 5 deletions

View File

@ -557,18 +557,30 @@ static uint16_t SecurityAccess_27(tCanUds *env) {
env->dataResponse[0] = UDS_SecurityAccess | 0b1000000;
env->dataResponse[1] = env->data.data[1] & 0b01111111; // sub-function
// Доступ уже получен
if (env->SA.stateSecurityAccess) {
env->dataResponse[2] = 0;
env->dataResponse[3] = 0;
env->dataResponse[4] = 0;
env->dataResponse[5] = 0;
} else {
if (randomSecuritySeed == 0) {
randomSecuritySeed = 0x11223344;
}
env->dataResponse[2] = randomSecuritySeed >> 24;
env->dataResponse[3] = randomSecuritySeed >> 16;
env->dataResponse[4] = randomSecuritySeed >> 8;
env->dataResponse[5] = randomSecuritySeed;
}
return 6;
}
if (com->sub_function == UDS_sub_sendKey) {
if (env->data.len < 6) {
return setResponseError(env, UDS_SecurityAccess, UDS_error_incorrectMessageLengthOrInvalidFormat);
return setResponseError(env, UDS_SecurityAccess, UDS_error_requestOutOfRange);
}
// Ранее не получен запрос UDS_sub_requestSeed
@ -605,6 +617,8 @@ static uint16_t SecurityAccess_27(tCanUds *env) {
return 2;
}
return setResponseError(env, UDS_SecurityAccess, UDS_error_invalidKey);
}
// конец --------------------------- Security Access -------------------------------------------------------------
// конец --------------------------- Security Access -------------------------------------------------------------