不久前,我遇到了一个类似的问题,通过谷歌搜索,我得到了以下矢量应用说明:
…检查“2.7调用CAPL函数”部分。
总而言之,请确保将CAPL函数的参数声明为“long”,例如:以下内容似乎对我有效:void function1(long l)
{
write("function1() called with %d!", l);
}
为了完成,这就是我的python代码(上面的例子)的样子:from win32com import client
import pythoncom
import time
function1 = None
canoe_app = None
is_running = False
class EventHandler:
def OnInit(self):
global canoe_app
global function1
function1 = canoe_app.CAPL.GetFunction('function1')
def OnStart(self):
global is_running
is_running = True
canoe_app = client.Dispatch('CANoe.Application')
measurement = canoe_app.Measurement
measurement_events = client.WithEvents(measurement, EventHandler)
measurement.Start()
# The following loop takes care of any pending events and, once, the Measurement
# starts, it will call the CAPL function "function1" 10 times and then exit!
count = 0
while count < 10:
if (is_running):
function1.Call(count)
count += 1
pythoncom.PumpWaitingMessages()
time.sleep(1)