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

倾然丶 夕夏残阳落幕 提交于 2019-12-07 07:07:05

问题


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.



来源:https://stackoverflow.com/questions/33341136/how-to-include-a-h-or-dll-file-in-canoe-capl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!