How to include a .h or .dll file in CANoe/CAPL

2020-06-21 05:12发布

问题:

I want integrate a header .h or .dll file in CAPL (concretly Visa32.dll, visa.h or sicl.h) to control a multimeter 34461A. How can I include the .h files or .dll file in CANoe? I created an ECU module called multimeter. Thanks,

回答1:

Including external DLLs in CAPL is possible, but you will need to create a wrapper for all the functions you're going to use.

Take a look at \CANoe\Demo_AddOn\Capldll directorty which features such a wrapper. It's a MSVC project exporting a few simple functions to CAPL, like int f(int a, int b) {return a+b;}.

What you will need to to is to add your library files (Visa32.dll, visa.h) to this Capldll project and define wrappers for all the functions you want to call from CANoe. For example, if you have int visa_init(double arg) in Visa32.dll, you will create a wrapper:

int CAPLEXPORT far CAPLPASCAL capl_visa_init(double arg)
{
    return visa_init(arg);
}

You will also need to add the prototype of your function to the export table:

CAPL_DLL_INFO CAPL_DLL_INFO_LIST[] =
{
    {"my_visa_init", (CAPL_FARCALL)capl_visa_init, 'D', 1, "F", "\000"},
    ....
    {0,0}
}; 

Once you have successfully build your wrapper DLL (it will be called capldll.dll if you reuse the example), you will need to import it in CANoe, and you will be able to call the function by the name you defined in the export table, e.g. my_visa_init(1.0);



回答2:

CAPL is not C. You can not include .h files.

The easiest would be to control the multimeter over the GPIB bus. Take a look at the CAPL GPIB library.