0

In Vector CANoe, is it possible to define a function that takes a system variable argument like the system function TestWaitForSignalMatch()?

For my use case it is not sufficient to supply the current value of the system variable because I want to pass the system variable to TestWaitForSignalMatch() or similar system functions.

The CANoe help seems to show examples:

long TestWaitForSignalMatch (Signal aSignal, float aCompareValue, dword aTimeout); // form 1
long TestWaitForSignalMatch (sysvar aSysVar, float aCompareValue, dword aTimeout); // form 3

I tried like this

void foo(sysvar aSysvar) {}
         ^

or this

void foo(sysvar *aSysvar) {}
         ^

but I get a parse error at the marked position of the sysvar keyword in both cases.

I successfully created functions that take a signal argument, but unlike the syntax in the CANoe help I have to use a pointer. This works:

void foo(signal *aSignal) {}

Obviously the documentation in the help is not correct in this point. It results in a parse error after the signal keyword when I omit the * as shown in the help:

void bar(signal aSignal) {}
               ^

So what's the correct syntax for defining a function that takes a sysvar argument? (if possible)

In case the version matters, I'm currently testing with CANoe 9.0.53(SP1), 9.0.135(SP7) or 10.0.125(SP6).

dan1st
  • 12,568
  • 8
  • 34
  • 67
Bodo
  • 9,287
  • 1
  • 13
  • 29

2 Answers2

1

You have to use the correct type. You have the following possibilities to declare system variables in functions:

  • Integer: sysvarInt*
  • Float: sysvarFloat*
  • String: sysvarString*
  • Integer Array: sysvarIntArray*
  • Float Array: sysvarFloatArray*
  • Data: sysvarData*

Examples:

void PutSysVarIntArrayToByteArray (sysvarIntArray * from, byte to[], word length)
{
  word ii;
  for (ii = 0; ii < length; ii++)
  {
    to[ii] = (byte)@from[ii];
  }
}

You can also write to the system variable:

void PutByteToSysVarInt (byte from, sysvarInt * to) {
  @to = from;
}

See also CANoe Help page "Test Features » XML » Declaration and Transfer of CAPL Test Case and Test Function Parameters"

Firlefunke
  • 21
  • 4
0

Yes, you can. Just define a bit further your sysvar type, not just sysvar.

System variables, with indication of type and *. Possible types: Data, Int, Float, String, IntArray, and FloatArray. Example declaration: sysvarFloat * sv

You didn't specify the CANoe SP version, so it may not be supported in older versions, but to make sure of this, search for Function parameter in Help/Index, then you should get the full list of possible function parameters you can use in your current CANoe setup. Should start like this:

  • Integers (byte, word, dword, int, long, qword, int64) Example declaration: long 1
  • Integers (byte, word, dword, int, long, qword, int64) Example declaration: long 1
  • Individual characters (char) Example declaration: char ch
  • Enums Example declaration: enum Colors c
  • Associative fields Example declaration: int m[float]. Associative fields are transferred as reference automatically.

.............

  • System variables, with indication of type and *. Possible types: Data, Int, Float, String, IntArray, and FloatArray. Example declaration: sysvarFloat * sv
VioletVynil
  • 502
  • 5
  • 11
  • Thank you. I added the exact version numbers to my original question. I successfully compiled a sample function using sysvarFloat* in CANoe 9.0.53(SP1). – Bodo Nov 09 '18 at 13:22