UDS_14Service_Main.c 2.64 KB
Newer Older
时昊's avatar
时昊 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
#include "UDS_14Service_Main.h"

/**
  *14服务函数入口
  *@param A_TA_type 收到数据的地址
  *@param A_Length 收到数据的长度
  *@param A_Data 收到数据的数据
  */
void UDS_Service_14_Indication(uint32_t A_TA_type, uint16_t A_Length, uint8_t A_Data[])
{
    uint8_t NRC = positiveResponse;
    setDiagMSG(A_TA_type, A_Length, A_Data);
    if(NRC == positiveResponse)
    {
        NRC = UDS_14Service_NRC11();                                            /*14服务是否支持功能寻址*/
    }
    if(NRC == positiveResponse)
    {
        NRC = UDS_14Service_NRC7F();                                            /*14服务会话是否支持验证*/
    }
    if(NRC == positiveResponse)
    {
        NRC = UDS_14Service_NRC33();                                            /*14服务解锁等级验证*/
    }
    if(NRC == positiveResponse)
    {
        NRC = UDS_14Service_NRC13_MinLengthCheck();                             /*14服务最小长度验证*/
    }
    if(NRC == positiveResponse)
    {
        NRC = UDS_14Service_NRC31();                                            /*14服务超出请求范围验证*/
    }
    if(NRC == positiveResponse)
    {
        NRC = UDS_14Service_NRC13_TotalLengthCheck();                           /*14服务总长度长度验证*/
    }
    if(NRC == positiveResponse)
    {
        NRC = UDS_14Service_NRC22();                                            /*14服务条件验证*/
    }
    if(NRC == positiveResponse)
    {
        UDS_14Service();                                                        /*14服务功能*/
    }
    clearDiagMSG();                                                             /*清除诊断信息*/
}

/**
  *14服务功能
  */
void UDS_14Service(void)
{
    uint32_t eCanTxBuffStatus;
    uint32_t eCanTxStatus;
    uint8_t enResult = 0u;
    UDS_NRC78_Sand(0x14u);
    enResult = DTC_Clear();
    UDS_Delay(500u);
   /* eCanTxBuffStatus = CANFD_ReadTX_Buf();
    eCanTxStatus = CANFD_ReadTX_Status();
    eCanTxBuffStatus &= (1u << 26u);
    eCanTxStatus &= (1u << 26u);
    
    while((eCanTxBuffStatus ==1u) || (eCanTxStatus ==0u) )
    {
      UDS_Delay(500u);
      eCanTxBuffStatus = CANFD_ReadTX_Buf();
      eCanTxStatus = CANFD_ReadTX_Status();
      eCanTxBuffStatus &= (1u << 26u);
      eCanTxStatus &= (1u << 26u);
    }*/
    if(enResult == 0)
    {
        /*UDS_14_SendRsp(0x14u);*/
        UDS_Service_Response(0x14u, POSITIVE_RSP, DIAG_ID_Tx, 0u, DiagMSG.msgData.Data);
    }
    else
    {
        enResult = generalProgrammingFailure;
        /*UDS_SendNRCRsp(0x14u,enResult);*/
        UDS_Service_Response(0x14u, NEGATIVE_RSP, DIAG_ID_Tx, 1u, (uint8_t*)&enResult);
    }
}