Gamma-ray-burst
Gamma-ray-burst

Reputation: 45

Alternative to CAPL Function "TestWaitForDiagRequestSent"

I'm looking for a function in CAPL that provides the same functionality as the above-mentioned function.

This function is used to wait for confirmation about whether a Diagnostic request was successfully sent or not. The parameters passed in are the DiagRequest object and a specific wait-period. If no confirmation is received at the end of this period, then it returns an error code corresponding to timeout. Another error code refers to other reasons for failure as well, like, a protocol error or such.

My main issue with this established "TestWaitForDiagRequestSent" function, is that it can be used only within a Test Case structure, either implemented through a CAPL, XML or .NET test module in the Simulation Setup in CANoe. I need to implement the same functionality, without having to use Test Modules.

Could anyone suggest another CAPL function that does the same job minus the Test Modules, or suggest a practical means of achieving this?

Upvotes: 0

Views: 1660

Answers (1)

mspiller
mspiller

Reputation: 3839

Testmodules are allowed to "wait" during the simulation.

All other nodes or functionality is not allowed to wait because that would block the simulation. Basically the simulation calls a CAPL-function and waits until the functions returns. No events on the bus are handled until the function returns.

There is an event handler which is called when a diagnostic request has been sent successfully. So you would have to break up your code into sending of the request by using

diagSendRequest(req)

and reacting on a successful sent by using

on diagRequestSent <service>
{
  ...
}

For reacting on a request not den successfully, you could use a timer and set a global variable accordingly, or maybe a system variable.

Something similar to the following should do.

variables
{
  timer requestTimer;
  int sentSuccessfully;
}

void sendRequest()
{
  ....
  sentSuccessfully = 0;
  diagSendRequest(req);
  setTimer(requestTimer, <timeout>);

}

on diagRequestSent ....
{
  sentSuccessfully = 1;
  cancelTimer(requestTimer);
}

on requestTimer 
{
  sentSuccessfully = -1;
}

Upvotes: 1

Related Questions