Closed Alexrai123 closed 1 year ago
for now, py_canoe package supports running only one CANoe application instance at a time.
if you want to run more than one instance then follow below steps:
C:\ProgramData\Vector\CANoe\<version>\CAN.ini
SingleCOMClient
and set value to 1
. example: SingleCOMClient=1
https://github.com/chaitu-ycr/py_canoe/blob/main/src/py_canoe.py#L163
Hopefully this should let you open more than one canoe application instances.
It worked, thank you very much, I wasted a whole week trying to figure it out, love you.
And I got one more thing, it happens when I try to stop the measurement, I get this exception and and my program freeze for some time , it happens when I try to do it manually too
Hi @Alexrai123 This happens when you are trying to operate the CANoe application manually. also make sure there is no duplicate CANoe instance running in background (check in task manager). for me running multiple canoe configurations (start, stop and quit) working fine.
And if I find multiple duplicates in task manager, what should I do ? Close them ?
Looking at the logs when I'm opening both files, yes, it's opening the same files twice each. But got any idea on how to open just one ? Or what to do with the second one if I find them in task manager or somewhere else ?
before running any canoe python script close all the CANoe application instances from task manager. then you can start opening canoe instances from your script. always stop simulation and quit before exiting your script. this will close all the CANoe instances you opened. if you are not closing CANoe instances before exiting, then every time a new instance is created.
i tried below example and its working fine.
from py_canoe import CANoe
if __name__ == '__main__':
canoe_inst = CANoe()
canoe_inst.open(canoe_cfg=r'D:\_kms_local\py_canoe\tests\demo_cfg\demo.cfg')
canoe_inst.get_canoe_version_info()
canoe_inst.start_measurement()
canoe_inst_2 = CANoe()
canoe_inst_2.open(canoe_cfg=r'D:\_kms_local\vector_canoe_tool_notes\capl_basics\demo_cfg.cfg')
canoe_inst_2.get_canoe_version_info()
canoe_inst_2.start_measurement()
canoe_inst.stop_measurement()
canoe_inst_2.stop_measurement()
canoe_inst.quit()
canoe_inst_2.quit()
Each log about opening a file and starting the measurement appears 2 times each, but I cannot find more than 1 instance in task manager while the script is running or any instance when the script is not running.
Hello, I've been using your package to open a target file and a diagnosis file, adding a time delay of more than 20 seconds, but I can't manage to open them both, only one of them, maybe you could give a hand ? I'll leave you my code below so you can give it a look. ////////////////////////////////////////////////////////////////////////// import os import sys import subprocess import time import threading import keyboard import win32com.client from win32com.client import from win32com.client.connect import from py_canoe import CANoe from time import sleep as wait
def just_open(): diagnose = CANoe() diagnose.open(canoe_cfg=r'my_path_for_diagnose_file') diagnose.start_measurement() time.sleep(20) target = CANoe() target.open(canoe_cfg=r'my_path_for_target_file') target.start_measurement()
if name=="main": just_open() ////////////////////////////////////////////////////////////////////////// When I run it, the diagnose file opens, it turns on for 20 seconds, then I get Exception Thrown for the return. def Open(self, config=defaultNamedNotOptArg, autoSave=defaultNamedNotOptArg, promptUser=defaultNamedNotOptArg): 'method Open' return self.oleobj.InvokeTypes(7, LCID, 1, (24, 0), ((8, 1), (11, 17), (11, 17)),config, autoSave, promptUser) Here is the exception: (-2147352567, 'Exception occurred.', (0, None, None, None, 0, -2147467259), None) I got the same exception when I try to open and start the target file first. If I don't start the measurement before opening the second one, the first one closes and the second opens and runs without a problem. Maybe you can give me a hand and try to give me a clue on how to keep both open and run them. Good luck!