tao_z
2022-08-07 f453cfb645516628a6d1fa36e2ca633e1da6d708
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)
    {