[Python] CANoe Python COM Automation: Server Busy popup when calling exported CAPL function...

Discussão em 'Python' iniciado por Stack, Agosto 6, 2025.

  1. Stack

    Stack Membro Participativo

    I'm migrating an automated test workflow from Vector VtestStudio to a Python-based tool. Previously, in VtestStudio, we could execute a separate .can CAPL script in the middle of a test without issues.

    In the new setup, most of the automation works using the COM objects described in Vector documentation (accessed from Python). For running specific CAPL scripts, we use the GetFunction object on the CAPL interface, like this (in Visual Studio Code's Jupyter notebook):

    func = canoe.CAPL.GetFunction('MyExportedCaplFunc') # gets the exported CAPL function

    func.Call() # tries to execute it


    The problem:


    • The Python code executes and reports no error.


    • However, in CANoe, a "Server Busy" pop-up appears (see attached screenshot).


    • If I restart the notebook kernel and then click "Retry" on the CANoe pop-up, the remaining code after function call gets executed(main problem after function call in my opinion)

    I’m not sure what is causing this "Server Busy" dialog or how to avoid it in Python automation.

    What I’ve tried:


    • Waiting/delaying in Python after the COM call.


    • Calling the function after confirming initialization via OnInit.


    • Not calling Stop() or stopping measurement—popup still appears after Call().

    Has anyone seen this and found a reliable solution? Is there a pattern to safely trigger CAPL exported functions via Python COM without locking up CANoe’s GUI/main thread?

    Python Sample script used -

    class MeasurementEventHandler:
    def __init__(self):
    self.capl_func = None
    self.on_init = False

    def OnInit(self):
    # This method is called by CANoe when measurement init finishes
    print("OnInit event fired. Obtaining CAPL function...")
    self.capl_func = c.CAPL.GetFunction("COMTest_WriteWindow") # Replace "square" with your function name
    self.on_init = True

    # Create CANoe application and get Measurement object
    c = Dispatch("CANoe.Application")
    measurement = c.Measurement

    # Attach event handler for OnInit event
    handler = WithEvents(measurement, MeasurementEventHandler)

    # Start measurement to trigger OnInit event asynchronously
    c.CAPL.Compile()
    measurement.Start()

    # Wait for OnInit event with message pumping
    timeout = 20
    start = time.time()
    while not handler.on_init and (time.time() - start < timeout):
    pythoncom.PumpWaitingMessages()
    time.sleep(0.1)

    if not handler.on_init:
    raise Exception("Timeout waiting for OnInit event")

    # Now safely call the CAPL function acquired in OnInit
    print("Calling CAPL function captured in OnInit...")
    handler.capl_func.Call()
    print("CAPL function call completed.")

    measurement.Stop()


    CAPL script used(sample) -

    includes
    {

    }

    variables
    {

    }

    MainTest(){
    COMTest_WriteWindow();
    }


    export void COMTest_WriteWindow()
    {
    write("Function called successfully");
    }


    CAPL

    on init class(object)

    at the last of execution

    server busy pop up

    Continue reading...

Compartilhe esta Página