How to use function diagGetSuppressResp, diagSetSuppressResp in CAPL

451 Views Asked by At

I am writing a CAPL script to automate testing for service testerPresent and need to send requests with suppressPosRspMsgIndicationBit" ("suppress positive response message indication bit"). This can be done easily by using diagSetParameter(Req_0x3E,"zeroSubFunction",0x80).

However, this is where my problem begin. I have a series of automated testcase which run sequentially. So when I request testerPresent with suppressPos bit set, the testing ECU will not respond (which is correct), but CANoe keep waiting for the P2 client timer in (ISO TP configuration->Diagnostic layer). During this interval, CANoe will not allow any UDS request (even the manual request on diag console), testWaitForDiagRequestSent will return error code. This mean the subsequent testcase can not send UDS request. However, I dont want to adjust this P2 client timer.

I have found that a function diagSetSuppressResp is used to deal with requests with suppressPos on. However, I have failed to find a way to use this function. CANoe keep waiting for the P2 client timer and block UDS request.

If anyone have use this function or have met some similar problem please help me.

My code:P2 timer in CANoe

includes
{
}
variables
{
  //zeroSubFunction
  const byte zeroSubFunction_False = 0x00;
  const byte zeroSubFunction_True = 0x80;
  const byte ISOSAEReserved_0x3E = 0x01;
  
  //Diagnostic objects
  diagRequest BasicDiagnosticsEcu.UDS_Diagnostic_Services_Generic.TesterPresent_Process Req_0x3E;
  diagResponse BasicDiagnosticsEcu.UDS_Diagnostic_Services_Generic.TesterPresent_Process Resp_0x3E;
}
void service0x3E_req(byte expected_NRC,byte session_req)
{
  long ret;
  long ret1;
  diagInitialize(Req_0x3E);
  //diagSetParameter(Req_0x3E,"zeroSubFunction",session_req);
  if(session_req == zeroSubFunction_True)
  {
    diagSetTarget("BasicDiagnosticsEcu");
    ret1 = diagsetSuppressResp(Req_0x3E,1);
    testStep("","Debug ret = %d",ret1);
  }
  else if(session_req == zeroSubFunction_False)
  {
    diagSetTarget("BasicDiagnosticsEcu");
    ret1 = diagsetSuppressResp(Req_0x3E,0);
    testStep("","Debug ret = %d",ret1);
  }
  else diagSetParameter(Req_0x3E,"zeroSubFunction",session_req);
  
  ret = sendDiagObject(Req_0x3E);
  
  
  if(ret == 0)
  {
    if(session_req == zeroSubFunction_True)
    {
      testStepPass("","No response received when request for zeroSubFunction: 0x%02X",session_req);
      //testWaitForTimeout(10000);
      return;
    }
    else testStepFail("","No response received!");
  }

Simplified code:

testcase tc()
{
  long ret;
  diagInitialize(Req_0x3E);
  diagsetSuppressResp(Req_0x3E,1);
  diagSendRequest(Req_0x3E);
  ret = testWaitForDiagRequestSent(Req_0x3E,2000);
    if (ret == 1) 
    {
      testStepPass("Tx","-\tSuccessfully send Diagnostic request message.");
    }
    else
    {
      TestStepFail("Tx","-\tDiagnostic request timeout error! Error code: %ld",ret);
    }
  diagInitialize(Req_0x3E);
  diagsetSuppressResp(Req_0x3E,0);
  diagSendRequest(Req_0x3E);
  ret = testWaitForDiagRequestSent(Req_0x3E,2000);
    if (ret == 1) 
    {
      testStepPass("Tx","-\tSuccessfully send Diagnostic request message.");
    }
    else
    {
      TestStepFail("Tx","-\tDiagnostic request timeout error! Error code: %ld",ret);
    }
}
0

There are 0 best solutions below