Search code examples
caplcanoe

how to define a CAPL function taking a sysvar argument


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).


Solution

  • 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