0

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?

1 Answers1

1

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;
}
MSpiller
  • 3,500
  • 2
  • 12
  • 24
  • That's definitely an idea. But supposing that this event never happens, will the system remain in limbo, suspending all operations until there is any confirmation? Also, the TestWaitForDiagRequestSent function returns error codes. Is it possible to return any values like that? The actual error codes that are available in CAPL are quite extensive, but I all I need is just a result saying whether the request was sent successfully or not. – Gamma-ray-burst Mar 23 '19 at 15:32
  • The event handler is called when the event happens. Nothing is suspended. When the request is seen on the bus, CANoe will check whether there is an event handler for that and call it. If you have to react on the event not sent successfully, you would have to use a timer in addition. I have enhanced the answer. – MSpiller Mar 23 '19 at 16:15