Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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,

like image 744
eloy0107 Avatar asked Oct 26 '15 08:10

eloy0107


People also ask

How do you add a DLL to CAPL?

Enter the DLL in the Options dialog in CANoe. In this case, the DLL will be available to all CAPL programs. You can enter the DLL in the includes section of a CAPL program using the #pragma library command. In this case, it will only be available to this program.

Why is CAPL used?

CAPL is a scripting language that is used to access the CAN protocol with Logical operations. With this, it is possible simulate anything on CAN network using the script code which is almost like C. The script can be used with Vector CANOe and Vector CANalyzer.


2 Answers

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

like image 160
Dmitry Grigoryev Avatar answered Sep 19 '22 11:09

Dmitry Grigoryev


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.

like image 35
sergej Avatar answered Sep 19 '22 11:09

sergej