Giter VIP home page Giter VIP logo

py_canoe's Introduction

About py_canoe

Python ๐Ÿ Package for controlling Vector CANoe ๐Ÿ›ถ Tool

fork this repo and create pull request to contribute back to this project.

for ideas/discussions please create new discussion here

create issue or request feature here

GitHub Releases ๐Ÿ‘‰ link

PyPi Package ๐Ÿ‘‰ link

Prerequisites link

Python environment setup instructions link

Install py_canoe package

pip install py_canoe --upgrade

Documentation Links

example use cases ๐Ÿ‘‰ link

package reference doc ๐Ÿ‘‰ link

Sample Example

# Import CANoe module
from py_canoe import CANoe

# create CANoe object
canoe_inst = CANoe()

# open CANoe configuration. Replace canoe_cfg with yours.
canoe_inst.open(canoe_cfg=r'tests\demo_cfg\demo.cfg')

# print installed CANoe application version
canoe_inst.get_canoe_version_info()

# Start CANoe measurement
canoe_inst.start_measurement()

# get signal value. Replace arguments with your message and signal data.
sig_val = canoe_inst.get_signal_value('CAN', 1, 'LightState', 'FlashLight')
print(sig_val)

# Stop CANoe Measurement
canoe_inst.stop_measurement()

# Quit / Close CANoe configuration
canoe_inst.quit()

py_canoe's People

Contributors

chaitu-ycr avatar gfabiano avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

py_canoe's Issues

(-2147352567, 'ๅ‘็”Ÿๆ„ๅค–ใ€‚', (0, 'Measurement::Start', 'User interface is busy', 'D:\\Softwares\\canoe\\Help01\\CANoeCANalyzer.chm', 4470, -2147418113), None)

When i use the method start_measure, sometimes i got this error.

(-2147352567, 'ๅ‘็”Ÿๆ„ๅค–ใ€‚', (0, 'Measurement::Start', 'User interface is busy', 'D:\\Softwares\\canoe\\Help01\\CANoeCANalyzer.chm', 4470, -2147418113), None)

This is only an occasional occurrence, and most of the time it works. But I don't know why this happens.

Could you help me analyze the cause of this problem? Thank you very much!!!

Cannot open canoe cfg

Hi ,

i am facing issue with Canoe cfg .when i run the script, its showing below error , i have updated py_canoe also
image

Can we run vtest module through python?

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Library.IReplayBlock instance has no attribute Name

Describe the bug
Attribute 'Name' does not seem to exist for the instance of type Library.IReplayBlock. This prevents setting a replay block file with the set_replay_block_file() function.

To Reproduce
Steps to reproduce the behavior:
I tried to run the exact example code, that is in the docstring. Of course I provided valid paths to .cfg file and valid info for the replayblock.


>>> # The following example sets replay block file
            >>> canoe_inst = CANoe()
            >>> canoe_inst.open(r'D:\_kms_local\vector_canoe\py_canoe\demo_cfg\demo.cfg')
            >>> canoe_inst.set_replay_block_file(block_name='replay block name', recording_file_path='replay file including path')
            >>> canoe_inst.start_measurement()

The following error will appear when executing:

[CANOE_LOG] [INFO] failed to fetch replay blocks. '<win32com.gen_py.CANoe 16.4 Type Library.IReplayBlock instance at 0x12345>' object had no attribute 'Name'

Expected behavior
I expected no error message and that the provided replay log file would be set successfully.

Screenshots
N/A

Desktop (please complete the following information):

  • OS: Windows
  • Version: 10

Vector CANoe (please complete the following information):

  • Version 16.4.4
  • Service Pack SP4

Additional context
Please let me know if anyone can reproduce this bug. If so maybe we can find a solution to fix the problem.

Systen variable handle enhacements

Hello, I've found a few more use cases which aren't covered:

  • A method to set/get variables of type array (Integer Array, Double Array, Data) is missing
    Note: Some elements in Data Array are inverted, so you need to apply hex(value&0xFF) on them.
    Also, make an option to only set part of an array (so add an optional argument for start position).
  • System defined variables cannot be read (getting them works a bit different compared to User defined variables, the namespaces are nested in the same object)

image

ModuleNotFoundError: No module named 'utils'

When i use this library,i got an error.

    from utils.py_canoe_logger import PyCanoeLogger
ModuleNotFoundError: No module named 'utils'
# import CANoe utils here
from utils.py_canoe_logger import PyCanoeLogger
from utils.application import Application
from utils.bus import Bus, Signal
from utils.capl import Capl
from utils.configuration import Configuration
from utils.measurement import Measurement
from utils.networks import Networks
from utils.system import System, Namespaces, Variables
from utils.ui import Ui
from utils.version import Version

Problem opening a CANoe cfg

I followed the documentation and I tried to open a cfg of my configuration.
I get the problem in the picture below.

immagine

Call capl function does not work

Hello,

Thank you for taking an interest in implementing this, but unfortunately it doesn't work.

When calling function it returns KeyError, it cannot find the function in self.meas.user_capl_function_obj_dict.

I have passed the function name as argument during CANoe instance creation.

I'm using CANoe v15 with py_canoe v2.0.1 release.

Dispatch CANoe without opening a configuration

On my environment sometime I restart the Python script but I dont want py_canoe reload everything.
It can be useful to make a dispatch method that not load a configuration in my opinion.

For now I modified the open method removing commenting this line for my configuration and works as expected.

166. # self.__canoe_objects['Application'].Open(canoe_cfg, auto_save, prompt_user)

Getting error while trying to send diagnostic request

I'm trying to use py_canoe package to open CANoe and send diagnostic requests to the ECU. The package seems to open the CANoe cfg file but when i try to send the diagnostic request ('10 01'), I'm facing the below error.
Traceback (most recent call last):
File "D:\CS_Python_MSV\canoe.py", line 14, in
resp = canoe_inst.send_diag_request("Door", '10 01')
File "C:\Users\VF_KPIT\AppData\Roaming\Python\Python39\site-packages\py_canoe.py", line 629, in send_diag_request
diag_req.Send()
File "", line 2, in Send
pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, None, None, None, 0, -2147467259), None)

I'm using Python 3.9.9 version and pywin32 is installed properly.
image

Any solution on how to get this issue sorted would be appreciated. Thank you

Communicating Flask app with py_canoe module, through send_diag_request method getting ECU respond only 1st time.

This error occurs when object of canoe using as local in Flask app.
Diag ECU qualifier (ECU_NAME) not available in loaded CANoe config.

If I am passing canoe object outside of the any route in Flask app, It shows pywin32 related error.
File: <COMObject >", line 2 in CreateRequestFromStream.
like: pywintypes.com_error (-21473221008, "CoInitialize has not been called, None, None")

2nd time while changing the parameter through flask frontend, I got these 2 above error.
I don't want to start and stop canoe measurement for every single request.

call_capl_func ERROR & Requesting Usage Example with any of the Existing Configuration

Describe the bug
we have added a CAPL Test node named "MyFunc" with function defined with no arguments and named as "MyFunc". We are trying to call it using the latest py_canoe Package as below:

canoe_int = CANoe(user_capl_functions=('MyFunc'))
canoe_int.open(canoe_cfg=r"C:\Users\Public\Documents\Vector\CANoe\Sample_Configurations_17.3.91\XCP_AMD\XCP_FlexRay\FlexRayXCP.cfg")
canoe_int.start_measurement()
#Tried a few combinations:
canoe_int.call_capl_function("MyFunc")
canoe_int.call_capl_function("MyFunc.MyFunc")
canoe_int.call_capl_function("MyFunc:MyFunc")
canoe_int.call_capl_function("MyFunc::MyFunc")

The MyFunc.can contains :

/*@!Encoding:65001*/

int MyFunc(){
return timeNow();
}


To Reproduce
Steps to reproduce the behavior:

  1. Go to Default Path for the XCPFlexray.cfg in "C:\Users\Public\Documents\Vector\CANoe\Sample_Configurations_17.3.91\XCP_AMD\XCP_FlexRay\FlexRayXCP.cfg"

  2. Goto Simulation setup

  3. Add Capl Test Node

  4. Click on Edit - which will open a CAPL Browser

  5. Then Enter the code as above

  6. Open Cmd Prompt

  7. pip install py_canoe - downloads the latest version of package

  8. Run the above python code

Error :

*File "c:\Users\KXR1KOR\AppData\Local\Programs\Python\Python39\lib\site-packages\py_canoe.py", line 831, in call_capl_function
exec_sts = capl_obj.call_capl_function(self.application.measurement.user_capl_function_obj_dict[name], arguments)
KeyError: 'MyFunc::MyFunc'

The Ket Error is for all the above combinations mentioned.

Expected behavior
Run the command and print the time in message console as:

[*] [Program / Model] 17032

**py_canoe **
Verison : py_canoe==2.1.3

OS and Vector CANoe (please complete the following information):

  • OS: Microsoft Windows 10 Enterprise
  • OS Version : 10.0.19045
  • Vector CANoe Version : 17.3.91
  • Vector CANoe Service Pack : SP3

We want an Example for the Function use : "call_capl_function"

Thank You in Advance!

Thank You Mate

Opening 2 files at the same time

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!

Have an Idea

Hello Chaitu,

This is Rajadeepan, a devops engineer.

This py_canoe project is very useful for the people like me who are new to CANoe Panels.

I have some configuration which has some test environments which i would like to execute all the test cases one by one. So I have written a code which might be useful if we integrate with this project.

So I would like to contribute to this project to parse test environments and execute all test modules in the CANoe test environment configuration.

I don't have any documentation updated for this. But I have followed some of your standards which you can modify later.

Regards,
Rajadeepan

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.