简体   繁体   中英

How to get return value from a CAPL function called from python?

I would like to get the return data from a CAPL function called from python. Please help me with this.

Currently I can only call the function with parameter in the example .

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('Test1')

    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):
        ret = []
        function1.Call(count)
        function1.Call(count+1)
        print(ret)
        count += 1

    pythoncom.PumpWaitingMessages()
    time.sleep(1)

measurement.Stop()

You just have to assign the calling statement to a variable.
var1 = (int)function1.Call(count)
Note that the return variable type should only be int .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM