Right now I'm trying to call a CAPL function in CANoe with the CANoe COM API using the python comtypes package.
For this I created the following small short python program:
from comtypes.client import CreateObject
c=CreateObject("CANoe.Application")
squareFunction=c.CAPL.GetFunction("square")
res=squareFunction.Call(5)
print(res==25)
This should call my short CAPL function:
int square(int x) {
return x*x;
}
Unfortunately, the program yields in c.CAPL.GetFunction("square")
an exception, in case the simulation is running in CANoe.
COMError: (-2147418113, 'Critical Error', (None, None, None, 0, None))
If the simulation in CANoe is stopped, there is no error, but the call of the function yields None
.
Does anyone knows, what is going on here?