web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Unanswered

How can we simulate some functions coded in CAPL with python

(0) ShareShare
ReportReport
Posted on by 5

I would like to simulate some calculation in a script CAPL using python. Can you please help me to implement this?

I have the same question (0)
  • rahul6sharma Profile Picture
    5 on at
    RE: How can we simulate some functions coded in CAPL with python

    I ran into a similar problem a while back and some Googling led me to the following application note by Vector:

    vector.com/.../AN-AND-1-117_CANoe_CANalyzer_as_a_COM_Server.pdf

    ...checkout section "2.7 Calling CAPL Functions".

    To sum it up, make sure to declare your CAPL function's parameters as "long", .e.g: the following seemed to work for me:

    void function1(long l)

    {

      write("function1() called with %d!", l);

    }

    For the sake of completion, this is how my python code (for the example above) looks like:

    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)

    .

    .

    .

    <a href=www.sevenmentor.com/best-python-classes-in-pune.php>Python courses in Pune</a>

  • Quinton Profile Picture
    5 on at
    RE: How can we simulate some functions coded in CAPL with python

    Right now I'm trying to call a CAPL function in CANoe with the CANoe COM API using the python comtypes package GarageBand For Android

    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)

  • Rajesh swamireddy Profile Picture
    on at
    RE: How can we simulate some functions coded in CAPL with python

    Hi Elenaflorence,

    The mentioned ask is not in our scope.

    Could you please check with any support teams on this.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
Sahan Hasitha Profile Picture

Sahan Hasitha 394

#2
Nimsara Jayathilaka. Profile Picture

Nimsara Jayathilaka. 123

#3
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 103 Super User 2025 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans