From 2c8058e6575f4e0238a98140d8ddcb5afb11f44c Mon Sep 17 00:00:00 2001 From: ethan <tzj0429@163.com> Date: Tue, 13 Sep 2022 20:23:06 +0800 Subject: [PATCH] 上传cantp的库 --- Application/source/uds_modules/uds.c | 31 ++++++++++++++----------------- 1 files changed, 14 insertions(+), 17 deletions(-) diff --git a/Application/source/uds_modules/uds.c b/Application/source/uds_modules/uds.c index 153ebff..83b443a 100644 --- a/Application/source/uds_modules/uds.c +++ b/Application/source/uds_modules/uds.c @@ -155,7 +155,7 @@ #define RSP_DATA_LEN (6) #define UDS_TASK_RATE (10) -#define CANTP_RX_BUFFER_SIZE (128) +#define CANTP_RX_BUFFER_SIZE (266) #define FBL_RX_BUFFER_SIZE (256) #define CANTP_TX_BUFFER_SIZE (128) @@ -386,9 +386,9 @@ {ROUTINE_CONTROL, UDS_RoutineControl, false, true, false, false, SECURITY_ACCESS_UNLOCK_LEVEL_2}, {TESTER_PRESENT, UDS_TesterPresent, true, true, true, true, SECURITY_ACCESS_LOCKED}, // {CONTROL_DTC_SETTING, UDS_ControlDTCSetting, false, true, false, true, SECURITY_ACCESS_LOCKED}, - {REQUEST_DOWNLOAD, UDS_RequestDownload, false, true, false, true, SECURITY_ACCESS_UNLOCK_LEVEL_2}, - {TRANSFER_DATA, UDS_TransferData, false, true, false, true, SECURITY_ACCESS_UNLOCK_LEVEL_2}, - {REQUEST_TRANSFER_EXIT, UDS_RequestTransferExit, false, true, false, true, SECURITY_ACCESS_UNLOCK_LEVEL_2}, + {REQUEST_DOWNLOAD, UDS_RequestDownload, false, true, false, false, SECURITY_ACCESS_UNLOCK_LEVEL_2}, + {TRANSFER_DATA, UDS_TransferData, false, true, false, false, SECURITY_ACCESS_UNLOCK_LEVEL_2}, + {REQUEST_TRANSFER_EXIT, UDS_RequestTransferExit, false, true, false, false, SECURITY_ACCESS_UNLOCK_LEVEL_2}, }; /* clang-format on */ @@ -575,14 +575,9 @@ } break; case TRANSFER_DATA: - if (msg_dlc >= TRANSFER_DATA_MIN_LEN) - { - result = true; - } - else - { - result = false; - } + + result = true; + break; case REQUEST_TRANSFER_EXIT: result = true; @@ -1480,14 +1475,15 @@ break; case PROGRAMMING: /* UDS_SendNegResp(NRC_SUBFUNCTION_NOT_SUPPORTED); */ - if (((UDS_L_Diag_session_e == EXTENDED) || (UDS_L_Diag_session_e == PROGRAMMING)) && (UDS_L_ProgrammingPreconditionCheckOK_b == true)) + if (((UDS_L_Diag_session_e == EXTENDED) || (UDS_L_Diag_session_e == PROGRAMMING))) { - /**/ + CDT_RESET(TesterPresentTimer_u16, + UDS_NS_SessionTimeout_u16 / UDS_TASK_RATE); UDS_L_Diag_session_e = PROGRAMMING; UDS_SessionSetOk_b = true; FblSetFblProgramRequestFlag(); } - else if ((UDS_L_Diag_session_e == DEFAULT) || (UDS_L_ProgrammingPreconditionCheckOK_b == false)) /*DEFAULT session can not trans to PROGRAMMING*/ + else if ((UDS_L_Diag_session_e == DEFAULT)) /*DEFAULT session can not trans to PROGRAMMING*/ { UDS_SendNegResp(NRC_CONDITIONS_NOT_CORRECT); } @@ -1498,6 +1494,7 @@ case DEFAULT: if (UDS_L_Diag_session_e == PROGRAMMING) { + UDS_L_Diag_session_e = DEFAULT; UDS_L_tx_msg_buffer[0] = GET_RESPONSE_SERVICE_ID(SESSION_CONTROL); UDS_L_tx_msg_buffer[1] = UDS_L_Diag_session_e; UDS_L_tx_msg_buffer[2] = 0; @@ -1511,6 +1508,7 @@ /* Compose a response message and send a positive */ /* response with the request data */ UDS_RespTxMessage(); + FblClrFblProgramRequestFlag(); while (cnt--) { ; /// wait send command send out and then reset @@ -1936,7 +1934,6 @@ return; } - UDS_L_ResponsePendingRequest_e |= ERASE_RESP_PENDING; UDS_SendNegResp(NRC_SERVICE_BUSY); erase_state = NVM_EraseData(eraseAddress, eraseRemainder); if (erase_state == OP_STATUS_OK) @@ -2215,7 +2212,7 @@ operation_write.current_sequenc = expectedSequenceCnt; operation_write.prev_seqence = currentSequenceCnt; - UDS_SendNegResp(NRC_SERVICE_BUSY); // first send busy + // UDS_SendNegResp(NRC_SERVICE_BUSY); // first send busy write_result = NEM_WriteData(&operation_write); // todo write all data at this function if (write_result == OP_STATUS_OK) { -- Gitblit v1.8.0