Обновление
This commit is contained in:
parent
bcf78a1231
commit
5d60e53cc3
75
CanUds.c
75
CanUds.c
|
|
@ -252,7 +252,10 @@ static uint16_t TesterPresent_3E(tCanUds *env) {
|
|||
testerPresent->ServiceId = UDS_TesterPresent | 0b1000000;
|
||||
testerPresent->zeroSubFunction = 0;
|
||||
|
||||
if (osMutexAcquire(env->access, 1000) == osOK) {
|
||||
env->currentSessionTesterPresentTimeout = SystemGetMs() + timeout_session_S3_Server;
|
||||
osMutexRelease(env->access);
|
||||
}
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
|
@ -1210,7 +1213,8 @@ static uint16_t SecurityAccess_27(tCanUds *env) {
|
|||
}
|
||||
|
||||
uint32_t securitySeedFromServer =
|
||||
(env->data->data[2] << 24) | (env->data->data[3] << 16) | (env->data->data[4] << 8) | env->data->data[5];
|
||||
(env->data->data[2] << 24) | (env->data->data[3] << 16) | (env->data->data[4] << 8) |
|
||||
env->data->data[5];
|
||||
|
||||
uint32_t securitySeedMy = generate_key(env->randomSecuritySeed);
|
||||
|
||||
|
|
@ -1289,6 +1293,11 @@ static uint16_t TransferData_36(tCanUds *env) {
|
|||
return setResponseError(env, UDS_TransferData, UDS_error_incorrectMessageLengthOrInvalidFormat);
|
||||
}
|
||||
|
||||
if (osMutexAcquire(env->access, 1000) == osOK) {
|
||||
env->currentSessionTesterPresentTimeout = SystemGetMs() + timeout_session_S3_Server;
|
||||
osMutexRelease(env->access);
|
||||
}
|
||||
|
||||
bool result = env->write_flash_func(env->AdrFlash, &env->data->data[2], env->data->len - 2);
|
||||
|
||||
if (result == false) {
|
||||
|
|
@ -1591,22 +1600,6 @@ void ReceivedTP_func(void *arg, tCanTP_data *data) {
|
|||
tCanUds *env = arg;
|
||||
env->data = data;
|
||||
|
||||
// Контроль TesterPresent
|
||||
if ((env->currentSessionTesterPresentTimeout > 0) &&
|
||||
(env->currentSessionTesterPresentTimeout < SystemGetMs())) {
|
||||
env->currentSessionTesterPresentTimeout = 0;
|
||||
|
||||
#if (LOG_UDS == 1)
|
||||
LoggerFormatInfo(LOGGER, LOG_SIGN, "Resetting the session to default: %d", UDS_session_defaultSession)
|
||||
#endif
|
||||
setDefaultSecurityAccess(env);
|
||||
set_CCU_Mute(env->canSpamTransmitter, false);
|
||||
setNoBitsDTC(env->Diagnostic, false);
|
||||
env->currentSession = UDS_session_defaultSession;
|
||||
statusData.Status_Active_Diagnostic_Session.Active_Diagnostic_Session = env->currentSession;
|
||||
|
||||
}
|
||||
|
||||
uint8_t com = env->data->data[0];
|
||||
|
||||
if (uds_com[com].func != NULL) {
|
||||
|
|
@ -1633,20 +1626,21 @@ void ReceivedTP_func(void *arg, tCanTP_data *data) {
|
|||
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
void CanUds(tCanUds *env) {
|
||||
|
||||
for (;;) {
|
||||
osStatus_t status = osMessageQueueGet(env->queue, &env->data, 0, 1000);
|
||||
|
||||
if (osMutexAcquire(env->access, 1000) == osOK) {
|
||||
|
||||
// Контроль TesterPresent
|
||||
if ((env->currentSessionTesterPresentTimeout > 0) &&
|
||||
(env->currentSessionTesterPresentTimeout < SystemGetMs())) {
|
||||
env->currentSessionTesterPresentTimeout = 0;
|
||||
|
||||
#if (LOG_UDS == 1)
|
||||
//#if (LOG_UDS == 1)
|
||||
LoggerFormatInfo(LOGGER, LOG_SIGN, "Resetting the session to default: %d", UDS_session_defaultSession)
|
||||
#endif
|
||||
//#endif
|
||||
setDefaultSecurityAccess(env);
|
||||
set_CCU_Mute(env->canSpamTransmitter, false);
|
||||
setNoBitsDTC(env->Diagnostic, false);
|
||||
|
|
@ -1655,42 +1649,16 @@ void CanUds(tCanUds *env) {
|
|||
|
||||
}
|
||||
|
||||
if (status == osOK) {
|
||||
|
||||
uint8_t com = env->data->data[0];
|
||||
|
||||
if (uds_com[com].func != NULL) {
|
||||
|
||||
#if (LOG_UDS == 1)
|
||||
sendLogCanUdsHex(env, env->data->data, env->data->len);
|
||||
LoggerFormatInfo(LOGGER, LOG_SIGN, "> %s [%d] %s", uds_com[com].desc, env->data->len, env->hexString)
|
||||
#endif
|
||||
uint8_t response_size = uds_com[com].func(env);
|
||||
|
||||
if (response_size) {
|
||||
#if (LOG_UDS == 1)
|
||||
sendLogCanUdsHex(env, env->dataResponse, response_size);
|
||||
LoggerFormatInfo(LOGGER, LOG_SIGN, "< %s [%d] %s", uds_com[com].desc, response_size, env->hexString)
|
||||
#endif
|
||||
CanSerialPortFrameTpTransmit(&env->canSerialPortFrameTp, env->dataResponse,
|
||||
response_size, PROTOCOL_CAN_ADR_UDS, WAIT_FRAME_WRITE);
|
||||
osMutexRelease(env->access);
|
||||
}
|
||||
|
||||
} else {
|
||||
asm("nop");
|
||||
SystemDelayMs(1000);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
void CanSerialPortCanUds_Start(tCanUds *env) {
|
||||
// ThreadBlock_Start(env->T_can_Uds, env, CanUds);
|
||||
ThreadBlock_Start(env->T_can_Uds, env, CanUds);
|
||||
CanSerialPortFrameTp_Start(&env->canSerialPortFrameTp);
|
||||
}
|
||||
|
||||
|
|
@ -1714,7 +1682,8 @@ void CanUds_Init(
|
|||
env->canSpamTransmitter = canSpamTransmitter;
|
||||
env->clear_flash_func = clear_flash_func;
|
||||
env->write_flash_func = write_flash_func;
|
||||
// env->queue = osMessageQueueNew(CAN_US_QUEUE_SIZE, sizeof(tCanTP_data), NULL);
|
||||
|
||||
env->access = osMutexNew(NULL);
|
||||
|
||||
setDefaultStatus();
|
||||
|
||||
|
|
@ -1768,5 +1737,5 @@ void CanUds_Init(
|
|||
env->currentSession = UDS_session_defaultSession;
|
||||
statusData.Status_Active_Diagnostic_Session.Active_Diagnostic_Session = UDS_session_defaultSession;
|
||||
|
||||
// InitThreadBlock(env->T_can_Uds, "CanUds", osPriorityNormal);
|
||||
InitThreadBlock(env->T_can_Uds, "UdsTester", osPriorityNormal);
|
||||
};
|
||||
4
CanUds.h
4
CanUds.h
|
|
@ -151,7 +151,7 @@ typedef struct {
|
|||
tDiagnostic *Diagnostic;
|
||||
tCanTP_data canTP_Ext_data;
|
||||
|
||||
// osMessageQueueId_t queue;
|
||||
osMutexId_t access;
|
||||
|
||||
tAdcTask *adcTask0;
|
||||
|
||||
|
|
@ -186,7 +186,7 @@ typedef struct {
|
|||
uint32_t SizeWriteFlash;
|
||||
uint8_t blockSequenceCounter;
|
||||
|
||||
// tStaticThreadBlock(384) T_can_Uds;
|
||||
tStaticThreadBlock(384) T_can_Uds;
|
||||
} tCanUds;
|
||||
|
||||
typedef uint16_t (*uds_func_ptr)(tCanUds *env);
|
||||
|
|
|
|||
Loading…
Reference in New Issue