diff --git a/CanUds.c b/CanUds.c index f501787..7a9fd1f 100644 --- a/CanUds.c +++ b/CanUds.c @@ -66,6 +66,61 @@ static void PrintfDebug(uint8_t *data, uint8_t dlc) { } +bool isSecurityAccessDenied(tCanUds *env, tPermissionSession isPermissionSession) { + bool result = false; + + switch (isPermissionSession) { + + case perm_session_defaultSession: { + if (env->currentSession == UDS_session_defaultSession) + result = true; + break; + } + + case perm_session_programmingSession: { + if (env->currentSession == UDS_session_programmingSession) + result = true; + break; + } + + case perm_session_extendedDiagnosticSession: { + if (env->currentSession == UDS_session_extendedDiagnosticSession) + result = true; + break; + } + + case perm_session_defaultSession_programmingSession: { + if ((env->currentSession == UDS_session_defaultSession) || + (env->currentSession == UDS_session_programmingSession)) + result = true; + break; + } + + case perm_session_defaultSession_extendedDiagnosticSession: { + if ((env->currentSession == UDS_session_defaultSession) || + (env->currentSession == UDS_session_extendedDiagnosticSession)) + result = true; + break; + } + + case perm_session_extendedDiagnosticSession_programmingSession: { + if ((env->currentSession == UDS_session_extendedDiagnosticSession) || + (env->currentSession == UDS_session_programmingSession)) + result = true; + break; + } + + case perm_session_all: { + result = true; + break; + } + + default: + break; + } + + return result; +} char *sendLogCanUdsHex(tCanUds *env, uint8_t *data, size_t size) { memset(env->hexString, 0, sizeof(env->hexString)); @@ -222,6 +277,14 @@ static uint16_t ReadDataByIdentifier_22(tCanUds *env) { if (dataIdentifier_hi == 0xCF) { if (uds_ReadDataByIdentifier_22_com_CF[dataIdentifier_lo].data != NULL) { + + +// if (uds_ReadDataByIdentifier_22_com_CF[dataIdentifier_lo].isPermissionSession != NULL) { +// +// } + + + uint16_t response_size = uds_ReadDataByIdentifier_22_com_CF[dataIdentifier_lo].size; env->dataResponse[0] = UDS_ReadDataByIdentifier | 0b1000000;