Skip to main content

Pythonic wrapper around the VECTOR CANape API

Project description

pyCANape

PyPI - Version PyPI - Python Version Documentation Status

This is a pythonic wrapper around the VECTOR CANape API. The documentation is available here.

Example usage

Open and close CANape

import pycanape

canape = pycanape.CANape(
    project_path="C:\\Users\\Public\\Documents\\Vector CANape 17\\Examples\\XCPDemo",
    modal_mode=True,
)
canape.exit(close_canape=True)

Create Module

from pycanape import DriverType, Channels

# Create XCPsim module
xcpsim = canape.create_module(
    module_name="XCPSim",
    database_filename=r"C:\Users\Public\Documents\Vector CANape 17\Examples\XCPDemo\XCPsim.a2l",
    driver=DriverType.ASAP3_DRIVER_XCP,
    channel=Channels.DEV_CAN1,
    go_online=True,
)

Calibration

# get scalar (0D) calibration object
scalar_obj = xcpsim.get_calibration_object("map1Counter")

# read scalar value
print(scalar_obj.value)

# set scalar value
scalar_obj.value = 2.0

# get axis (1D) calibration object
axis_obj = xcpsim.get_calibration_object("Curve1")

# read axis length
axis_dim = axis_obj.dimension

# read axis values
print(axis_obj.axis)

# set axis values
axis_obj.axis = [0] * axis_dim

How to contribute

Setup your development environment:

# clone the repository
git clone https://github.com/zariiii9003/pycanape.git

# install pyCANape in editable mode with all development dependencies
pip install -e .[dev,doc]

# install the pre-commit hook
pre-commit install

After you implement your changes you should run the static code analysis and check the documentation:

# install pycanape in editable mode
python -m pip install -e .[dev,doc]

# format the code with black
black .

# run the linter
ruff check --fix src

# run the type checker
mypy .

# run the tests
python -m pytest --cov-config=./pyproject.toml --cov=pycanape  --cov-report=term --cov-report=html

# build the documentation
python -m sphinx -Wan --keep-going docs build

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pycanape-0.7.2.tar.gz (39.8 kB view details)

Uploaded Source

Built Distribution

pyCANape-0.7.2-py3-none-any.whl (41.6 kB view details)

Uploaded Python 3

File details

Details for the file pycanape-0.7.2.tar.gz.

File metadata

  • Download URL: pycanape-0.7.2.tar.gz
  • Upload date:
  • Size: 39.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for pycanape-0.7.2.tar.gz
Algorithm Hash digest
SHA256 35eb99076b57b018556ce834a782ab2e2662fbca65e5b662e7a8f5874f1ac29e
MD5 946b26e5525c4b2453b144f97479a557
BLAKE2b-256 e1df205a0bbe8f960595888f2f12e165cfbae90703546dab601fd1061e885d05

See more details on using hashes here.

File details

Details for the file pyCANape-0.7.2-py3-none-any.whl.

File metadata

  • Download URL: pyCANape-0.7.2-py3-none-any.whl
  • Upload date:
  • Size: 41.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for pyCANape-0.7.2-py3-none-any.whl
Algorithm Hash digest
SHA256 257b8e1d669b9c018e97f88c5cd7bd6895086f54ab988e8a4151f3d6f4a643cf
MD5 6c21d894abfa5fc1457ea71ad20c5686
BLAKE2b-256 b165195e4e2e9b725b716faf5148e7ca9a75af8d71868680d0d1c9527069eb4f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page